@muyichengshayu/promptx 0.2.13 → 0.2.15

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 (52) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/apps/server/src/agentSessionDiscovery.js +180 -7
  3. package/apps/web/dist/assets/{CodexSessionManagerDialog-Dic9kMHK.js → CodexSessionManagerDialog-y7O-JTxP.js} +1 -1
  4. package/apps/web/dist/assets/{TaskDiffReviewDialog-CKiZdXqi.js → TaskDiffReviewDialog-CTr_zoAn.js} +1 -1
  5. package/apps/web/dist/assets/{WorkbenchSettingsDialog-CP0z90bm.js → WorkbenchSettingsDialog-Bf2DCuN_.js} +1 -1
  6. package/apps/web/dist/assets/{WorkbenchView-D1oxqNr4.css → WorkbenchView-CK1snPBz.css} +1 -1
  7. package/apps/web/dist/assets/WorkbenchView-Gq3mmtsK.js +60 -0
  8. package/apps/web/dist/assets/index-Co1Ssha9.js +2 -0
  9. package/apps/web/dist/index.html +1 -1
  10. package/package.json +21 -14
  11. package/apps/runner/src/engines/claudeCodeRunner.test.js +0 -467
  12. package/apps/runner/src/engines/kimiCodeRunner.test.js +0 -127
  13. package/apps/runner/src/engines/openCodeRunner.test.js +0 -236
  14. package/apps/runner/src/engines/runnerContract.test.js +0 -449
  15. package/apps/runner/src/engines/shellRunner.test.js +0 -46
  16. package/apps/runner/src/runManager.test.js +0 -913
  17. package/apps/runner/src/serverClient.test.js +0 -93
  18. package/apps/server/src/agentSessionDiscovery.test.js +0 -186
  19. package/apps/server/src/appPaths.test.js +0 -52
  20. package/apps/server/src/assetRoutes.test.js +0 -168
  21. package/apps/server/src/codex.test.js +0 -518
  22. package/apps/server/src/codexRoutes.test.js +0 -376
  23. package/apps/server/src/codexRuns.test.js +0 -160
  24. package/apps/server/src/codexSessions.test.js +0 -369
  25. package/apps/server/src/db.test.js +0 -182
  26. package/apps/server/src/gitDiff.test.js +0 -542
  27. package/apps/server/src/gitDiffClient.test.js +0 -140
  28. package/apps/server/src/internalRoutes.test.js +0 -134
  29. package/apps/server/src/maintenance.test.js +0 -154
  30. package/apps/server/src/processControl.test.js +0 -147
  31. package/apps/server/src/relayClient.test.js +0 -478
  32. package/apps/server/src/relayConfig.test.js +0 -73
  33. package/apps/server/src/relayProtocol.test.js +0 -49
  34. package/apps/server/src/relayServer.test.js +0 -798
  35. package/apps/server/src/relayTenants.test.js +0 -137
  36. package/apps/server/src/relayUsageStore.test.js +0 -65
  37. package/apps/server/src/repository.test.js +0 -150
  38. package/apps/server/src/runDispatchService.test.js +0 -563
  39. package/apps/server/src/runEventIngest.test.js +0 -225
  40. package/apps/server/src/runRecovery.test.js +0 -73
  41. package/apps/server/src/runnerClient.test.js +0 -80
  42. package/apps/server/src/runnerDispatch.test.js +0 -136
  43. package/apps/server/src/systemConfig.test.js +0 -112
  44. package/apps/server/src/systemRoutes.test.js +0 -319
  45. package/apps/server/src/taskRoutes.test.js +0 -775
  46. package/apps/server/src/upload.test.js +0 -30
  47. package/apps/server/src/webAppRoutes.test.js +0 -67
  48. package/apps/server/src/workspaceFiles.test.js +0 -279
  49. package/apps/web/dist/assets/WorkbenchView-noayQwj4.js +0 -60
  50. package/apps/web/dist/assets/index-HLkdzIYF.js +0 -2
  51. package/packages/shared/src/dailyLogStream.test.js +0 -29
  52. package/packages/shared/src/shellCommands.test.js +0 -45
@@ -0,0 +1,60 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-theme-github-dark-default-DBX58552.js","assets/vendor-shiki-core-1BqeTDsZ.js","assets/vendor-misc-u-M8sNMf.js","assets/vendor-misc-ClI1dyrl.css","assets/vendor-shiki-theme-github-light-RLAvZv0q.js","assets/vendor-shiki-lang-bash-zsQu0xn-.js","assets/vendor-shiki-lang-c-BDF8vgks.js","assets/vendor-shiki-lang-cpp-DyDAaXl6.js","assets/vendor-shiki-lang-csharp-BWfTXJXw.js","assets/vendor-shiki-lang-css-DbAm1fUO.js","assets/vendor-shiki-lang-diff-DmGC1G26.js","assets/vendor-shiki-lang-dockerfile-3x-8396r.js","assets/vendor-shiki-lang-dotenv--IVOlX2Q.js","assets/vendor-shiki-lang-fish-Bpv3hhJP.js","assets/vendor-shiki-lang-go-CIGC59jP.js","assets/vendor-shiki-lang-html-Bt_TLLZN.js","assets/vendor-shiki-lang-ini-BIllfys4.js","assets/vendor-shiki-lang-java-CXxu9crF.js","assets/vendor-shiki-lang-javascript-Cha7GNZm.js","assets/vendor-shiki-lang-json-CCZCjDUh.js","assets/vendor-shiki-lang-less-DAToytC5.js","assets/vendor-shiki-lang-markdown-C6lwMXFp.js","assets/vendor-shiki-lang-python-Bi9rmtY7.js","assets/vendor-shiki-lang-powershell-lrpuM0ez.js","assets/vendor-shiki-lang-rust-GTGDbY6A.js","assets/vendor-shiki-lang-sass-DFtHupN8.js","assets/vendor-shiki-lang-scss-BrfBNyyi.js","assets/vendor-shiki-lang-sql-H6--iFN-.js","assets/vendor-shiki-lang-toml-aTteTWYL.js","assets/vendor-shiki-lang-tsx-DoKZm6AV.js","assets/vendor-shiki-lang-typescript-B5awnqri.js","assets/vendor-shiki-lang-vue-CnrgQ7Z5.js","assets/vendor-shiki-lang-xml-Bv-TNPJt.js","assets/vendor-shiki-lang-yaml-DpxUxQ6M.js","assets/CodexSessionManagerDialog-y7O-JTxP.js","assets/index-Co1Ssha9.js","assets/vendor-router-Dn8q3tJM.js","assets/index-BAfqUG7o.css","assets/vendor-ui-BglsaDbv.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-CTr_zoAn.js","assets/TaskDiffReviewDialog-NsLGEda4.css","assets/WorkbenchSettingsDialog-Bf2DCuN_.js"])))=>i.map(i=>d[i]);
2
+ import{u as Et,t as Ge,f as $r,_ as qe,a as Pr,b as Dr,g as Xs,s as Ma,c as Ba}from"./index-Co1Ssha9.js";import{w as Ae,ak as Rt,aD as h,aI as Ee,aG as le,aJ as Qe,aE as _,aK as Ze,aL as we,aF as i,aM as sn,u as a,aN as de,aO as Lr,aP as vs,c as G,aQ as T,aR as ot,aS as ut,aT as bn,n as at,o as pn,aU as en,aV as Bn,b as z,aW as Zt,aX as as,aY as Ko,r as ys,aC as Ra,aZ as Sn,f as Na,a_ as xo,a$ as Os,G as Oa,al as Fa,b0 as En,b1 as An}from"./vendor-misc-u-M8sNMf.js";import{X as Mr,T as Ua,L as Wt,C as Po,a as Fs,B as Wo,S as ja,P as fs,b as Br,c as Va,A as za,F as Hn,d as Pn,e as Rr,f as Ha,E as qa,g as Ka,h as Go,i as Do,j as Us,k as Wa,l as Ga,m as Xa,U as Ya,W as Ja,n as Nr,o as Qa,p as js,q as Ys,I as Or,r as Za,s as ei,t as ti,u as ni,G as si,v as oi,w as ri,x as ai,y as ii}from"./vendor-ui-BglsaDbv.js";import{M as Fr}from"./vendor-markdown-9aQhqbjm.js";import{n as Lo,N as Ur,a as Mo,i as li,V as oo,b as Xo,u as ui,c as ci,E as di}from"./vendor-tiptap-rwYdQb1L.js";const fi="shell",pi=new Set(["!","!"]),Yo="text";function Is(e=""){return String(e||"").replace(/\r\n/g,`
3
+ `).trim()}function mi(e=""){const t=String(e||"");return pi.has(t.charAt(0))}function gi(e=""){const t=Is(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function hi(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(u=>!!Is(u==null?void 0:u.content)),o=n.length>0,s=o?n.filter(u=>String((u==null?void 0:u.type)||"").trim()===Yo).map(u=>Is(u==null?void 0:u.content)).filter(Boolean).join(`
4
+
5
+ `).trim():Is(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()!==Yo))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=gi(s).slice(1).trim();return l?{mode:fi,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const cn={NONE:"none",LATEST:"latest",ALL:"all"};function vi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===cn.ALL?cn.ALL:n===cn.LATEST?cn.LATEST:n===cn.NONE?cn.NONE:t.includeEvents?cn.ALL:t.includeLatestEvents?cn.LATEST:cn.NONE}const qt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function jr(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?qt.AGENT_EVENT:t}const xt={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"},rt={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"},yi={none:{label:"不过期",hours:null}};Object.entries(yi).map(([e,t])=>({value:e,label:t.label}));const is={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode",KIMI_CODE:"kimi-code"},Bo=[{value:is.CODEX,label:"Codex",enabled:!0},{value:is.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:is.OPENCODE,label:"OpenCode",enabled:!0},{value:is.KIMI_CODE,label:"Kimi Code",enabled:!0}],Bt={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},Si=[{value:"local",label:"跟随本机时区"}],wi={SKIP:"skip"},xi=[{value:wi.SKIP,label:"已有运行时跳过本次"}],ro={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},bi=[{value:ro.DINGTALK,label:"钉钉 Webhook"},{value:ro.FEISHU,label:"飞书 Webhook"},{value:ro.WEBHOOK,label:"通用 Webhook"}],ao={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},ki=[{value:ao.COMPLETED,label:"本次运行结束后"},{value:ao.SUCCESS,label:"本次运行成功后"},{value:ao.ERROR,label:"本次运行失败后"}],Ti={SUMMARY:"summary"},_i=[{value:Ti.SUMMARY,label:"摘要消息"}],Jo={ZH_CN:"zh-CN",EN_US:"en-US"},Ci=[{value:Jo.ZH_CN,label:"简体中文"},{value:Jo.EN_US,label:"English"}];function Vs(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Bo.find(o=>o.value===t))==null?void 0:n.value)||is.CODEX}function dt(e){var t;return((t=Bo.find(n=>n.value===Vs(e)))==null?void 0:t.label)||"Codex"}function Fy(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 Ei(e=[],t=10){const n=e.find(o=>{var s;return(o.type===Bt.TEXT||o.type===Bt.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const Ai={class:"min-w-0 flex-1"},Ii={key:0,class:"flex items-center gap-2"},$i=["disabled"],Js={__name:"DialogShell",props:{open:{type:Boolean,default:!1},backdropClass:{type:String,default:""},stackLevel:{type:Number,default:0},panelClass:{type:String,default:""},headerClass:{type:String,default:"px-4 py-4 sm:px-5"},bodyClass:{type:String,default:"min-h-0 flex-1"},showClose:{type:Boolean,default:!0},closeDisabled:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},lockBodyScroll:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,s=G(()=>n.backdropClass?n.backdropClass:`${n.stackLevel>=4?"z-[90]":n.stackLevel===3?"z-[75]":n.stackLevel===2?"z-[70]":n.stackLevel===1?"z-[60]":"z-50"} items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6`);function 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 Ae(()=>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}),Rt(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",u)}),(m,k)=>(h(),Ee(vs,{to:"body"},[le(Lr,{name:"dialog-shell"},{default:Qe(()=>[e.open?(h(),_("div",{key:0,class:we(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:Ze(l,["self"])},[i("section",{class:we(["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?(h(),_("div",{key:0,class:we(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",Ai,[sn(m.$slots,"header",{},()=>[sn(m.$slots,"title")])]),m.$slots["header-actions"]||e.showClose?(h(),_("div",Ii,[sn(m.$slots,"header-actions"),e.showClose?(h(),_("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[le(a(Mr),{class:"h-4 w-4"})],8,$i)):de("",!0)])):de("",!0)],2)):de("",!0),i("div",{class:we(e.bodyClass)},[sn(m.$slots,"default")],2)],2)],2)):de("",!0)]),_:3})]))}},Pi={class:"flex items-start gap-3"},Di={class:"theme-heading text-base font-semibold"},Li={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},Mi={class:"flex justify-end gap-2 px-5 py-4"},Bi=["disabled"],Ri=["disabled"],ks={__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}=Et(),r=G(()=>n.title||s("common.confirm")),l=G(()=>n.confirmText||s("common.confirm")),u=G(()=>n.cancelText||s("common.cancel"));return(m,k)=>(h(),Ee(Js,{open:e.open,"stack-level":4,"panel-class":"max-w-md","header-class":"px-5 py-4","body-class":"flex flex-col","close-disabled":e.loading,"close-on-backdrop":!e.loading,"close-on-escape":!e.loading,onClose:k[2]||(k[2]=c=>o("cancel"))},{title:Qe(()=>[i("div",Pi,[i("span",{class:we(["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"])},[le(a(Ua),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Di,T(r.value),1),e.description?(h(),_("p",Li,T(e.description),1)):de("",!0)])])]),default:Qe(()=>[i("div",Mi,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:k[0]||(k[0]=c=>o("cancel"))},T(u.value),9,Bi),i("button",{type:"button",class:we(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:k[1]||(k[1]=c=>o("confirm"))},T(e.loading?a(s)("common.processing"):l.value),11,Ri)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Ni={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"},Oi={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},Fi=["onClick"],Ui={class:"min-w-0"},ji={class:"text-sm font-medium"},Vi={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},zi={__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)=>(h(),_("aside",Ni,[i("nav",Oi,[(h(!0),_(ot,null,ut(e.sections,l=>(h(),_("button",{key:l.id,type:"button",class:we(["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)},[(h(),Ee(bn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Ui,[i("div",ji,T(l.label),1),i("p",Vi,T(l.description),1)])],10,Fi))),128))])]))}},Hi=["aria-label","disabled","onKeydown"],qi={class:"min-w-0 flex-1"},Ki={class:"theme-muted-text text-sm"},Wi={class:"flex min-h-0 w-full flex-col"},Gi={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Xi=["onClick"],Yi={class:"theme-empty-state px-3 py-4 text-sm"},dn={__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}=Et(),r=z(null),l=z(null),u=z(!1),m=z(!1),k=z({}),c=G(()=>{const R=String(n.modelValue??"");return n.options.find(te=>String(n.getOptionValue(te)??"")===R)||null}),C=G(()=>n.placeholder||s("common.select")),v=G(()=>n.emptyText||s("common.noOptions"));function g(R){return R&&typeof R=="object"&&Object.prototype.hasOwnProperty.call(R,"label")?String(R.label||""):String(n.getOptionValue(R)??"")}function p(){n.disabled||(u.value||o("refresh-intent"),u.value=!0)}function P(){u.value=!1}function Z(){if(u.value){P();return}p()}function S(R){o("update:modelValue",String(n.getOptionValue(R)??"").trim()),P()}function B(){if(!u.value||!r.value||typeof window>"u")return;const R=r.value.getBoundingClientRect(),te=window.innerWidth,A=window.innerHeight,Y=8,fe=8,me=160,D=360,ee=Math.max(0,A-R.bottom-fe),ae=Math.max(0,R.top-fe);m.value=ee<260&&ae>ee;const Q=m.value?ae-Y:ee-Y,ge=Math.max(Math.min(D,Math.max(Q,0)),Math.min(me,m.value?ae:ee)),I=Math.min(R.width,te-fe*2),X=Math.min(Math.max(fe,R.left),Math.max(fe,te-fe-I));k.value={left:`${X}px`,top:m.value?`${R.top-Y}px`:`${R.bottom+Y}px`,width:`${I}px`,maxHeight:`${Math.max(ge,120)}px`,transform:m.value?"translateY(-100%)":"none"}}function K(R){var te;!u.value||!r.value||r.value.contains(R.target)||(te=l.value)!=null&&te.contains(R.target)||P()}function j(R){R.key==="Escape"&&P()}return Ae(()=>n.disabled,R=>{R&&P()}),Ae(u,async R=>{R&&(await at(),B())}),pn(()=>{document.addEventListener("pointerdown",K),document.addEventListener("keydown",j),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0)}),Rt(()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",j),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}),(R,te)=>(h(),_("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:we(["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:Z,onKeydown:[en(Ze(p,["prevent"]),["down"]),en(Ze(Z,["prevent"]),["enter"]),en(Ze(Z,["prevent"]),["space"])]},[i("div",qi,[sn(R.$slots,"trigger",{selectedOption:c.value,open:u.value,loading:e.loading,disabled:e.disabled},()=>[i("div",Ki,T(c.value?g(c.value):C.value),1)])]),i("div",{class:we(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(h(),Ee(a(Wt),{key:0,class:"h-4 w-4 animate-spin"})):de("",!0),le(a(Po),{class:we(["h-4 w-4 transition",u.value?"rotate-180":""])},null,8,["class"])],2)],42,Hi),(h(),Ee(vs,{to:"body"},[u.value?(h(),_("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:Bn(k.value)},[i("div",Wi,[sn(R.$slots,"header",{loading:e.loading,options:e.options}),i("div",Gi,[e.options.length?(h(!0),_(ot,{key:0},ut(e.options,A=>sn(R.$slots,"option",{key:String(e.getOptionValue(A)??""),option:A,selected:String(e.getOptionValue(A)??"")===String(e.modelValue??""),select:()=>S(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:Y=>S(A)},T(g(A)),9,Xi)])),128)):sn(R.$slots,"empty",{key:1},()=>[i("div",Yi,T(v.value),1)])])])],4)):de("",!0)]))],512))}},Qo={},Vr=typeof import.meta<"u"&&Qo?Qo:{};function Ji(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Vr.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 Ro(){return(Vr.VITE_API_BASE_URL||Ji()).replace(/\/$/,"")}function No(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=Ge(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||Ge(t)}async function et(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Ro()}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error(No(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Xn(){return Ro()}function $s(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`${Ro()}${e}`}function Uy(){return et("/api/meta",{cache:"no-store"})}function Qi(){return et("/api/tasks")}function Zi(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)}),et(`/api/tasks/workspace-diff-summaries?${n.toString()}`,{cache:"no-store"})}function el(e){return et("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function tl(e=[]){return et("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function zr(e){return et(`/api/tasks/${e}`)}function Hr(e,t){return et(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function nl(e){return et(`/api/tasks/${e}`,{method:"DELETE"})}async function sl(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Xn()}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(No(o,"errors.uploadFailed"))}return n.json()}async function ol(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Xn()}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(No(o,"errors.pdfImportFailed"))}return n.json()}const rl=Xn();function al(){return et("/api/codex/sessions")}function il(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return et(`/api/codex/workspaces${o?`?${o}`:""}`)}function jy(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 et(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function Vy(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 et(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function zy(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 et(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function ll(e){return et("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function ul(e,t){return et(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function cl(e){return et(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function dl(e){return et(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function fl(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 et(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function pl(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 et(`/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 et(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function gl(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 et(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function hl(e,t){return et(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function vl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=vi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return et(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function yl(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 et(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function Hy(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 et(`/api/tasks/${encodeURIComponent(e)}/git-diff${k?`?${k}`:""}`,{cache:"no-store"})}function qy(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`${rl}/api/tasks/${encodeURIComponent(e)}/git-diff/blob${u?`?${u}`:""}`}function Sl(e,t){return et(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function wl(e){return et(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function xl(e){return et(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const bl={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},kl={class:"theme-muted-text mt-1 text-xs"},Tl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},_l={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},Cl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},El={key:1,class:"space-y-4"},Al={key:0,class:"space-y-4"},Il={class:"theme-heading text-base font-medium"},$l={class:"theme-muted-text mt-1 text-xs leading-5"},Pl={class:"settings-section-card px-4 py-4"},Dl={class:"block space-y-1.5"},Ll={class:"theme-muted-text text-xs"},Ml=["placeholder"],Bl={key:1,class:"space-y-4"},Rl={class:"flex items-start justify-between gap-3"},Nl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ol={class:"theme-muted-text mt-1 text-xs leading-5"},Fl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Ul={class:"settings-section-card px-4 py-4"},jl={class:"grid gap-4 sm:grid-cols-2"},Vl={class:"space-y-1.5 sm:col-span-2"},zl={class:"theme-muted-text text-xs"},Hl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},ql={class:"space-y-1.5"},Kl={class:"theme-muted-text text-xs"},Wl=["disabled"],Gl={key:0,class:"space-y-1.5"},Xl={class:"theme-muted-text text-xs"},Yl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Jl={class:"space-y-1.5"},Ql={class:"theme-muted-text text-xs"},Zl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},eu={class:"theme-muted-text text-xs"},tu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},nu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},su={key:2,class:"space-y-4"},ou={class:"flex items-start justify-between gap-3"},ru={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},au={class:"theme-muted-text mt-1 text-xs leading-5"},iu={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},lu={class:"settings-section-card px-4 py-4"},uu={class:"grid gap-4 sm:grid-cols-2"},cu={class:"space-y-1.5"},du={class:"theme-muted-text text-xs"},fu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},pu={class:"space-y-1.5"},mu={class:"theme-muted-text text-xs"},gu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},hu={class:"space-y-1.5 sm:col-span-2"},vu={class:"theme-muted-text text-xs"},yu=["placeholder","disabled"],Su={class:"space-y-1.5"},wu={class:"theme-muted-text text-xs"},xu=["placeholder","disabled"],bu={class:"space-y-1.5"},ku={class:"theme-muted-text text-xs"},Tu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},_u={class:"space-y-1.5"},Cu={class:"theme-muted-text text-xs"},Eu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Au={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Iu={key:0,class:"theme-danger-text"},$u={key:3,class:"theme-danger-text text-sm"},Pu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},Du={class:"theme-muted-text theme-note-text"},Lu={class:"flex items-center justify-end gap-2"},Mu=["disabled"],Bu=["disabled"],Ru="0 9 * * 1-5",io="weekdays",os="09:00",Un="1",Nu={__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}=Et(),l=z(!1),u=z(!1),m=z(""),k=z("basic"),c=ys({title:"",automationEnabled:!1,automationMode:io,automationTime:os,automationWeekday:Un,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),C=G(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),v=G(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:fs},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Fs},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Wo}]),g=G(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),p=G(()=>[{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=G(()=>Si.map(I=>({...I,label:I.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):I.label}))),Z=G(()=>xi.map(I=>({...I,label:I.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):I.label}))),S=G(()=>bi.map(I=>({...I,label:I.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):I.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):I.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):I.label}))),B=G(()=>ki.map(I=>({...I,label:I.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):I.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):I.value==="error"?r("taskDialog.sections.notification.triggerError"):I.label}))),K=G(()=>_i.map(I=>({...I,label:I.value==="summary"?r("taskDialog.sections.notification.messageSummary"):I.label}))),j=G(()=>Ci.map(I=>({...I,label:I.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):I.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):I.label}))),R=G(()=>c.notificationEnabled?c.notificationLastStatus==="success"?r("taskDialog.sections.notification.statusSuccess"):c.notificationLastStatus==="error"?r("taskDialog.sections.notification.statusError"):r("taskDialog.sections.notification.statusPending"):r("taskDialog.sections.notification.statusDisabled"));function te(){c.title="",c.automationEnabled=!1,c.automationMode=io,c.automationTime=os,c.automationWeekday=Un,c.automationTimezone="local",c.automationConcurrencyPolicy="skip",c.automationLastTriggeredAt="",c.automationNextTriggerAt="",c.notificationEnabled=!1,c.notificationChannelType="dingtalk",c.notificationWebhookUrl="",c.notificationSecret="",c.notificationTriggerOn="completed",c.notificationLocale=String(s.value||"zh-CN"),c.notificationMessageMode="summary",c.notificationLastStatus="",c.notificationLastError="",c.notificationLastSentAt=""}function A(I=0){return String(I).padStart(2,"0")}function Y(I=""){const X=String(I||"").trim().replace(/\s+/g," ");let $=X.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return $?{mode:"weekdays",time:`${A($[2])}:${A($[1])}`,weekday:Un}:($=X.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),$?{mode:"daily",time:`${A($[2])}:${A($[1])}`,weekday:Un}:($=X.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),$?{mode:"weekly",time:`${A($[2])}:${A($[1])}`,weekday:String($[3])}:{mode:io,time:os,weekday:Un}))}function fe(I=""){const $=String(I||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!$)return os;const Te=Number($[1]),Me=Number($[2]);return!Number.isInteger(Te)||!Number.isInteger(Me)||Te<0||Te>23||Me<0||Me>59?os:`${A(Te)}:${A(Me)}`}function me(){var Re;const I=fe(c.automationTime),[X,$]=I.split(":"),Te=Number(X),Me=Number($);if(c.automationMode==="daily")return`${Me} ${Te} * * *`;if(c.automationMode==="weekly"){const Ne=((Re=p.value.find(Ve=>Ve.value===String(c.automationWeekday||"")))==null?void 0:Re.value)||Un;return`${Me} ${Te} * * ${Ne}`}return`${Me} ${Te} * * 1-5`}function D(I={}){var $,Te,Me,Re,Ne,Ve,We,ke,W,oe,ce,$e,he,Le,pe,De;c.title=String(I.title||""),c.automationEnabled=!!(($=I.automation)!=null&&$.enabled);const X=Y(((Te=I.automation)==null?void 0:Te.cron)||Ru);c.automationMode=X.mode,c.automationTime=X.time,c.automationWeekday=X.weekday,c.automationTimezone=String(((Me=I.automation)==null?void 0:Me.timezone)||"local"),c.automationConcurrencyPolicy=String(((Re=I.automation)==null?void 0:Re.concurrencyPolicy)||"skip"),c.automationLastTriggeredAt=String(((Ne=I.automation)==null?void 0:Ne.lastTriggeredAt)||""),c.automationNextTriggerAt=String(((Ve=I.automation)==null?void 0:Ve.nextTriggerAt)||""),c.notificationEnabled=!!((We=I.notification)!=null&&We.enabled),c.notificationChannelType=String(((ke=I.notification)==null?void 0:ke.channelType)||"dingtalk"),c.notificationWebhookUrl=String(((W=I.notification)==null?void 0:W.webhookUrl)||""),c.notificationSecret=String(((oe=I.notification)==null?void 0:oe.secret)||""),c.notificationTriggerOn=String(((ce=I.notification)==null?void 0:ce.triggerOn)||"completed"),c.notificationLocale=String((($e=I.notification)==null?void 0:$e.locale)||s.value||"zh-CN"),c.notificationMessageMode=String(((he=I.notification)==null?void 0:he.messageMode)||"summary"),c.notificationLastStatus=String(((Le=I.notification)==null?void 0:Le.lastStatus)||""),c.notificationLastError=String(((pe=I.notification)==null?void 0:pe.lastError)||""),c.notificationLastSentAt=String(((De=I.notification)==null?void 0:De.lastSentAt)||"")}async function ee(){const I=String(n.taskSlug||"").trim();if(!I){te();return}l.value=!0,m.value="";try{const X=await zr(I);D(X)}catch(X){m.value=(X==null?void 0:X.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function ae(){return{title:c.title,automation:{enabled:c.automationEnabled,cron:me(),timezone:c.automationTimezone,concurrencyPolicy:c.automationConcurrencyPolicy},notification:{enabled:c.notificationEnabled,channelType:c.notificationChannelType,webhookUrl:c.notificationWebhookUrl,secret:c.notificationSecret,triggerOn:c.notificationTriggerOn,locale:c.notificationLocale,messageMode:c.notificationMessageMode}}}async function Q(){const I=String(n.taskSlug||"").trim();if(!(!I||l.value||u.value)){u.value=!0,m.value="";try{const X=await Hr(I,ae());D(X),o("saved",X),o("close")}catch(X){m.value=(X==null?void 0:X.message)||r("taskDialog.saveFailed")}finally{u.value=!1}}}function ge(I=""){if(!I)return r("common.notAvailable");const X=new Date(I);return Number.isNaN(X.getTime())?r("common.notAvailable"):$r(X.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Ae(()=>n.open,I=>{if(I){k.value="basic",ee();return}},{immediate:!0}),Ae(()=>n.taskSlug,()=>{n.open&&ee()}),(I,X)=>(h(),Ee(Js,{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:X[16]||(X[16]=$=>o("close"))},{title:Qe(()=>[i("div",null,[i("div",bl,[le(a(fs),{class:"h-4 w-4"}),i("span",null,T(a(r)("taskDialog.title")),1)]),i("p",kl,T(a(r)("taskDialog.currentTask",{title:C.value})),1)])]),default:Qe(()=>[i("div",Tl,[le(zi,{modelValue:k.value,"onUpdate:modelValue":X[0]||(X[0]=$=>k.value=$),sections:v.value},null,8,["modelValue","sections"]),i("div",_l,[l.value?(h(),_("div",Cl,[le(a(Wt),{class:"h-4 w-4 animate-spin"}),i("span",null,T(a(r)("taskDialog.loading")),1)])):(h(),_("div",El,[k.value==="basic"?(h(),_("section",Al,[i("div",null,[i("div",Il,T(a(r)("taskDialog.sections.basic.title")),1),i("p",$l,T(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",Pl,[i("label",Dl,[i("span",Ll,T(a(r)("taskDialog.sections.basic.taskTitle")),1),Zt(i("input",{"onUpdate:modelValue":X[1]||(X[1]=$=>c.title=$),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,Ml),[[as,c.title]])])])])):k.value==="automation"?(h(),_("section",Bl,[i("div",Rl,[i("div",null,[i("div",Nl,[le(a(Fs),{class:"h-4 w-4"}),i("span",null,T(a(r)("taskDialog.sections.automation.title")),1)]),i("p",Ol,T(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",Fl,[Zt(i("input",{"onUpdate:modelValue":X[2]||(X[2]=$=>c.automationEnabled=$),type:"checkbox",class:"h-4 w-4"},null,512),[[Ko,c.automationEnabled]]),i("span",null,T(a(r)("taskDialog.enabled")),1)])]),i("section",Ul,[i("div",jl,[i("label",Vl,[i("span",zl,T(a(r)("taskDialog.sections.automation.mode")),1),le(dn,{modelValue:c.automationMode,"onUpdate:modelValue":X[3]||(X[3]=$=>c.automationMode=$),options:g.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",Hl,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",ql,[i("span",Kl,T(a(r)("taskDialog.sections.automation.time")),1),Zt(i("input",{"onUpdate:modelValue":X[4]||(X[4]=$=>c.automationTime=$),type:"time",class:"tool-input",disabled:!c.automationEnabled},null,8,Wl),[[as,c.automationTime]])]),c.automationMode==="weekly"?(h(),_("label",Gl,[i("span",Xl,T(a(r)("taskDialog.sections.automation.weekday")),1),le(dn,{modelValue:c.automationWeekday,"onUpdate:modelValue":X[5]||(X[5]=$=>c.automationWeekday=$),options:p.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",Yl,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):de("",!0),i("label",Jl,[i("span",Ql,T(a(r)("taskDialog.sections.automation.timezone")),1),le(dn,{modelValue:c.automationTimezone,"onUpdate:modelValue":X[6]||(X[6]=$=>c.automationTimezone=$),options:P.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",Zl,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:we(["space-y-1.5",c.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",eu,T(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),le(dn,{modelValue:c.automationConcurrencyPolicy,"onUpdate:modelValue":X[7]||(X[7]=$=>c.automationConcurrencyPolicy=$),options:Z.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",tu,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",nu,[i("p",null,T(a(r)("taskDialog.sections.automation.lastTriggered",{value:ge(c.automationLastTriggeredAt)})),1),i("p",null,T(a(r)("taskDialog.sections.automation.nextTriggered",{value:ge(c.automationNextTriggerAt)})),1)])])])):(h(),_("section",su,[i("div",ou,[i("div",null,[i("div",ru,[le(a(Wo),{class:"h-4 w-4"}),i("span",null,T(a(r)("taskDialog.sections.notification.title")),1)]),i("p",au,T(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",iu,[Zt(i("input",{"onUpdate:modelValue":X[8]||(X[8]=$=>c.notificationEnabled=$),type:"checkbox",class:"h-4 w-4"},null,512),[[Ko,c.notificationEnabled]]),i("span",null,T(a(r)("taskDialog.enabled")),1)])]),i("section",lu,[i("div",uu,[i("label",cu,[i("span",du,T(a(r)("taskDialog.sections.notification.channelType")),1),le(dn,{modelValue:c.notificationChannelType,"onUpdate:modelValue":X[9]||(X[9]=$=>c.notificationChannelType=$),options:S.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",fu,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",pu,[i("span",mu,T(a(r)("taskDialog.sections.notification.triggerOn")),1),le(dn,{modelValue:c.notificationTriggerOn,"onUpdate:modelValue":X[10]||(X[10]=$=>c.notificationTriggerOn=$),options:B.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",gu,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",hu,[i("span",vu,T(a(r)("taskDialog.sections.notification.webhookUrl")),1),Zt(i("input",{"onUpdate:modelValue":X[11]||(X[11]=$=>c.notificationWebhookUrl=$),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!c.notificationEnabled},null,8,yu),[[as,c.notificationWebhookUrl]])]),i("label",Su,[i("span",wu,T(a(r)("taskDialog.sections.notification.secret")),1),Zt(i("input",{"onUpdate:modelValue":X[12]||(X[12]=$=>c.notificationSecret=$),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!c.notificationEnabled},null,8,xu),[[as,c.notificationSecret]])]),i("label",bu,[i("span",ku,T(a(r)("taskDialog.sections.notification.locale")),1),le(dn,{modelValue:c.notificationLocale,"onUpdate:modelValue":X[13]||(X[13]=$=>c.notificationLocale=$),options:j.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",Tu,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",_u,[i("span",Cu,T(a(r)("taskDialog.sections.notification.messageMode")),1),le(dn,{modelValue:c.notificationMessageMode,"onUpdate:modelValue":X[14]||(X[14]=$=>c.notificationMessageMode=$),options:K.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:Qe(({selectedOption:$})=>[i("div",Eu,T(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",Au,[i("p",null,T(a(r)("taskDialog.sections.notification.status",{value:R.value})),1),i("p",null,T(a(r)("taskDialog.sections.notification.lastSent",{value:ge(c.notificationLastSentAt)})),1),c.notificationLastError?(h(),_("p",Iu,T(a(r)("taskDialog.sections.notification.lastError",{value:c.notificationLastError})),1)):de("",!0)])])])),m.value?(h(),_("p",$u,T(m.value),1)):de("",!0)]))])]),i("div",Pu,[i("p",Du,T(a(r)("taskDialog.footerHint")),1),i("div",Lu,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:u.value,onClick:X[15]||(X[15]=$=>o("close"))},T(a(r)("common.cancel")),9,Mu),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:Q},[u.value?(h(),Ee(a(Wt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),Ee(a(ja),{key:1,class:"h-4 w-4"})),i("span",null,T(u.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,Bu)])])]),_:1},8,["open"]))}};function Ou(e=[]){return(Array.isArray(e)&&e.length?e:Bo).filter(n=>n&&typeof n=="object").map(n=>{const o=Vs(n.value);return{...n,value:o,label:String(n.label||dt(o)).trim()||dt(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function Fu(e=[]){return Ou(e).filter(t=>t.enabled&&t.available)}async function Ky(){const e=await et("/api/meta",{cache:"no-store"});return Fu(e==null?void 0:e.agentEngineOptions)}function qr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=dt(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const Uu={key:0,class:"flex items-center gap-2 text-sm"},ju={class:"min-w-0 flex-1 truncate"},Vu={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},zu={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},Hu={key:1,class:"theme-muted-text text-sm"},qu={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},Ku=["onClick"],Wu={class:"flex items-center gap-3"},Gu={class:"min-w-0 flex-1"},Xu={class:"flex items-center gap-2 text-sm sm:hidden"},Yu={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},Ju={class:"hidden items-center gap-2 text-sm sm:flex"},Qu={class:"min-w-0 flex-1 truncate"},Zu={class:"font-medium text-[var(--theme-textPrimary)]"},ec={class:"theme-muted-text ml-2 font-mono text-[11px]"},tc={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},nc={__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}=Et();function s(c){return(c==null?void 0:c.title)||o("projectManager.untitledProject")}function r(c){return(c==null?void 0:c.cwd)||o("projectManager.notSet")}function l(c){return c!=null&&c.running?o("projectManager.running"):o("projectManager.idle")}function u(c){return c!=null&&c.running?"theme-status-warning":"theme-status-success"}function m(c){var v;const C=Math.max(0,Number((v=c==null?void 0:c.agentBindings)==null?void 0:v.length)||0);return C>1?o("projectManager.agentCount",{count:C}):dt(c==null?void 0:c.engine)}function k(c){return c?"theme-filter-active":"theme-filter-idle"}return(c,C)=>(h(),Ee(dn,{"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":v=>(v==null?void 0:v.id)||"","onUpdate:modelValue":C[0]||(C[0]=v=>n("update:modelValue",v)),onRefreshIntent:C[1]||(C[1]=v=>n("refresh-intent"))},{trigger:Qe(({selectedOption:v,disabled:g})=>[v?(h(),_("div",Uu,[i("span",ju,[i("span",{class:we(["font-medium",g?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},T(s(v)),3),i("span",Vu,T(r(v)),1)]),i("span",zu,T(m(v)),1),i("span",{class:we(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",u(v)])},T(l(v)),3)])):(h(),_("div",Hu,T(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:Qe(()=>[i("div",qu,[i("span",null,T(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(h(),Ee(a(Wt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):de("",!0)])]),option:Qe(({option:v,selected:g,select:p})=>[i("button",{type:"button",class:we(["w-full rounded-sm border border-dashed p-3 text-left transition",k(g)]),onClick:p},[i("div",Wu,[i("div",Gu,[i("div",Xu,[i("span",Yu,T(s(v)),1)]),i("div",Ju,[i("span",Qu,[i("span",Zu,T(s(v)),1),i("span",ec,T(r(v)),1)]),i("span",tc,T(m(v)),1),i("span",{class:we(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",u(v)])},T(l(v)),3)])]),g?(h(),Ee(a(Br),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):de("",!0)])],10,Ku)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},sc=["disabled"],oc=["disabled"],rc=["src","alt"],Kr={__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}=Et(),r=z(1),l=G(()=>n.images.map(S=>String(S||"").trim()).filter(Boolean)),u=G(()=>l.value.findIndex(S=>S===n.modelValue)),m=G(()=>u.value>=0?l.value[u.value]:"");function k(){o("update:modelValue",""),r.value=1}function c(S){o("update:modelValue",String(S||"").trim()),r.value=1}function C(){u.value<=0||c(l.value[u.value-1])}function v(){u.value<0||u.value>=l.value.length-1||c(l.value[u.value+1])}function g(S){const B=Math.min(3,Math.max(.5,r.value+S));r.value=Math.round(B*100)/100}function p(){r.value=1}function P(S){m.value&&(S.preventDefault(),g(S.deltaY<0?.1:-.1))}function Z(S){var B,K;if(m.value){if((B=S.stopPropagation)==null||B.call(S),(K=S.stopImmediatePropagation)==null||K.call(S),S.key==="Escape"){S.preventDefault(),k();return}if(S.key==="ArrowLeft"){S.preventDefault(),C();return}if(S.key==="ArrowRight"){S.preventDefault(),v();return}if(S.key==="+"||S.key==="="){S.preventDefault(),g(.1);return}if(S.key==="-"){S.preventDefault(),g(-.1);return}S.key==="0"&&(S.preventDefault(),p())}}return Ae(()=>n.modelValue,S=>{S||(r.value=1)}),Ae(l,S=>{if(n.modelValue){if(!S.length){k();return}if(!S.includes(n.modelValue)){const B=Math.min(u.value,S.length-1);c(S[B]||S[0])}}},{immediate:!0}),pn(()=>{window.addEventListener("keydown",Z,{capture:!0})}),Rt(()=>{window.removeEventListener("keydown",Z,{capture:!0})}),(S,B)=>(h(),Ee(vs,{to:"body"},[m.value?(h(),_("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]=Ze(()=>{},["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))},T(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:p},T(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))},T(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:B[3]||(B[3]=Ze(()=>{},["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:C},T(a(s)("imagePreview.previous")),9,sc),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:v},T(a(s)("imagePreview.next")),9,oc),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:k},T(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:Bn({transform:`scale(${r.value})`}),onClick:B[4]||(B[4]=Ze(()=>{},["stop"]))},null,12,rc)],32)):de("",!0)]))}};let lo=null;const Wy={maxLines:2e3,maxChars:2e5},uo={maxLines:2e3,maxChars:2e5},ac={"github-dark-default":()=>qe(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>qe(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},ic={bash:()=>qe(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>qe(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>qe(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>qe(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>qe(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>qe(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>qe(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>qe(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>qe(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>qe(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>qe(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>qe(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>qe(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>qe(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>qe(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>qe(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>qe(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>qe(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>qe(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>qe(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>qe(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>qe(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>qe(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>qe(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>qe(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>qe(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>qe(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>qe(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>qe(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function Wr(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Oo(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 Fo(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 lc(e=[],t={}){const n=Oo(e);return Fo(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function uc(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
6
+ `);return lc(n?n.split(`
7
+ `):[],t)}async function Gr(){return lo||(lo=Promise.all([qe(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.F),__vite__mapDeps([1,2,3])),qe(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.G),__vite__mapDeps([1,2,3]))]).then(async([e,t])=>e.createHighlighterCore({engine:t.createJavaScriptRegexEngine(),langs:[],themes:[]}))),lo}async function Xr(e,t){if(!t||e.getLoadedThemes().includes(t))return;const n=ac[t];n&&await e.loadTheme(await n())}async function Yr(e,t){if(!t||e.getLoadedLanguages().includes(t))return;const n=ic[t];n&&await e.loadLanguage(await n())}function qn(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const cc={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 Qs(e=""){const t=String(e||"").trim().toLowerCase();return t?cc[t]||t:""}function Gy(e="",t=""){const n=Qs(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 Jr(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=qn((e==null?void 0:e.content)||"");return`<span${t.length?` style="${t.join(";")}"`:""}>${n}</span>`}function Qr(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:Wr(e.length)}}function Xy(e=[]){return(Array.isArray(e)?e.map(n=>String(n??"")):[]).map(n=>n?qn(n):"&#8203;")}function co(e=""){const t=String(e||"").replace(/\r\n/g,`
8
+ `);return Qr(t.split(`
9
+ `).map(n=>n?qn(n):"&#8203;"),{})}async function dc(e=[],t={}){const n=Oo(e),o=n.lines,s=t.isDark?"github-dark-default":"github-light",r=Qs(t.language);if(!o.length)return[];if(Fo(n,t))return o.map(l=>l?qn(l):"&#8203;");if(!r)return o.map(l=>l?qn(l):"&#8203;");try{const l=await Gr();return await Xr(l,s),await Yr(l,r),(await l.codeToTokens(o.join(`
10
+ `),{lang:r,theme:s})).tokens.map(m=>m.length?m.map(Jr).join(""):"&#8203;")}catch{return o.map(l=>l?qn(l):"&#8203;")}}async function fc(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
11
+ `),o=t.isDark?"github-dark-default":"github-light",s=Qs(t.language),r=n?n.split(`
12
+ `):[],l=Oo(r);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:Wr(0)};if(Fo(l,t)||!s)return co(n);try{const u=await Gr();await Xr(u,o),await Yr(u,s);const m=await u.codeToTokens(n,{lang:s,theme:o});return Qr(m.tokens.map(k=>k.length?k.map(Jr).join(""):"&#8203;"),{bg:m.bg||"",fg:m.fg||""})}catch{return co(n)}}const pc=new Fr,mc="__PROMPTX_FENCE__";function Zr(e=""){return String(e||"").trim().toLowerCase()}function Ts(e=""){return pc.utils.escapeHtml(String(e||""))}function gc(e=""){const t=Zr(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 ea(e={}){const t=new Fr({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,c)=>{const C=l[u];return C.attrSet("target","_blank"),C.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,u,m,k,c):c.renderToken(l,u,m)},t.renderer.rules.table_open=(l,u,m,k,c)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,u,m,k,c):c.renderToken(l,u,m)}`,t.renderer.rules.table_close=(l,u,m,k,c)=>`${typeof s=="function"?s(l,u,m,k,c):c.renderToken(l,u,m)}</div>`,e.captureFences?t.renderer.rules.fence=(l,u,m,k={},c)=>{const C=l[u],v=Array.isArray(k.__promptxFences)?k.__promptxFences:[],g=v.length,p=`${mc}${g}__`;return v.push({content:String((C==null?void 0:C.content)||""),language:String((C==null?void 0:C.info)||"").trim().split(/\s+/)[0]||"",placeholder:p}),k.__promptxFences=v,p}:typeof r=="function"&&(t.renderer.rules.fence=r),t}const hc=ea({captureFences:!0}),vc=ea();async function yc(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
13
+ `),s=Zr(t),r=Qs(s),u=(await dc(o.split(`
14
+ `),{isDark:!!n.isDark,language:r||s})).join(`
15
+ `),m=s?` class="language-${Ts(s)}"`:"",k=gc(t),c=Ts(String(n.copyLabel||"Copy")),C=Ts(String(n.copyAriaLabel||c)),g=`<div class="codex-code-block__header">${k?`<span class="codex-code-block__language">${Ts(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="${C}">${c}</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 Sc(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>yc(s.content,s.language,n)));return t.reduce((s,r,l)=>s.replace(r.placeholder,o[l]||r.placeholder),e)}async function wc(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=hc.render(n,o);return Sc(s,o.__promptxFences||[],t)}function ta(e=""){const t=String(e||"").trim();return t?vc.render(t):""}function xc(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function Zo(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${xc(JSON.stringify(e||{}))}`}function bc(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,r)=>{const l=Zo(r);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const r=Zo(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 kc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},Tc={key:0,class:"process-detail-meta"},_c={key:0,class:"process-detail-meta__label"},Cc={key:1,class:"process-detail-panel"},Ec={class:"space-y-1.5"},Ac={key:1,class:"process-detail-checklist__dot"},Ic={key:0,class:"process-detail-footnote"},$c={key:0},Pc={key:2,class:"process-detail-panel"},Dc={class:"process-detail-directory__heading"},Lc={key:0,class:"font-medium"},Mc={key:1,class:"process-detail-directory__type"},Bc={class:"process-detail-directory__list"},Rc={key:0,class:"process-detail-footnote"},Nc={key:0},Oc={key:3,class:"process-detail-panel"},Fc={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},Uc={key:0,class:"process-detail-footnote"},jc={key:4,class:"process-detail-panel"},Vc={class:"space-y-1.5"},zc={class:"process-detail-filechange__kind"},Hc={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},qc={key:5,class:"process-detail-panel"},Kc={class:"space-y-2"},Wc={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},Gc={class:"min-w-0 flex flex-1 items-center gap-2"},Xc={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},Yc=["title"],Jc=["onClick"],Qc={class:"process-detail-directory__type shrink-0"},Zc={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},ed={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},td=["innerHTML"],nd={key:7,class:"process-detail-text"},sd=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}=Et(),o=z(new Set),s=G(()=>{const D=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return D.length?D:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),r=G(()=>bc(s.value)),l=G(()=>r.value.map(D=>D.key));Ae(s,(D=[])=>{const ee=new Set;D.forEach((ae,Q)=>{(ae==null?void 0:ae.type)==="sub_agent_list"&&(Array.isArray(ae.items)?ae.items:[]).forEach((ge,I)=>{ee.add(te(Q,ge,I))})}),o.value=new Set([...o.value].filter(ae=>ee.has(ae)))},{immediate:!0});function u(D=""){return ta(String(D||""))}function m(D=""){const ee=String(D||"").trim();return n(ee==="create"?"processDetail.changeCreate":ee==="delete"?"processDetail.changeDelete":ee==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function k(D={}){const ee=String((D==null?void 0:D.label)||"").trim().toLowerCase(),ae=String((D==null?void 0:D.value)||"").trim();return ae?ae.length>56||["命令","command","目标","target","url","路径","path"].includes(ee)&&ae.length>28?!0:ae.includes(" ")&&ae.length>36:!1}function c(D={},ee=[]){const ae=String((D==null?void 0:D.label)||"").trim().toLowerCase();return["命令","command"].includes(ae)?Array.isArray(ee)&&ee.length===1:!1}function C(D={}){const ee=String((D==null?void 0:D.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(ee)}function v(D={}){return D!=null&&D.completed?"completed":String((D==null?void 0:D.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function g(D=0){return n("processDetail.hiddenItems",{count:D})}function p(D=0){return n("processDetail.directorySummary",{count:D})}function P(D=0){return n("processDetail.directoryHidden",{count:D})}function Z(D=0){return l.value[D]||`block-${D}`}function S(D=""){const ee=String(D||"").trim().toLowerCase();return n(ee==="completed"?"processDetail.subAgentCompleted":ee==="failed"?"processDetail.subAgentFailed":ee==="running"?"processDetail.subAgentRunning":ee==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function B(D={}){return String((D==null?void 0:D.title)||(D==null?void 0:D.target)||(D==null?void 0:D.id)||"").trim()}function K(D={}){const ee=B(D),ae=[],Q=String((D==null?void 0:D.role)||"").trim(),ge=String((D==null?void 0:D.target)||"").trim(),I=String((D==null?void 0:D.model)||"").trim();return Q&&Q.toLowerCase()!=="default"&&ae.push(Q),ge&&ge!==ee&&ae.push(ge),I&&ae.push(I),ae.join(" · ")}function j(D={}){return!!String((D==null?void 0:D.message)||"").trim()}function R(D={}){const ee=String((D==null?void 0:D.message)||"").replace(/\s+/g," ").trim();return ee||K(D)}function te(D=0,ee={},ae=0){return`${Z(D)}:sub-agent:${String((ee==null?void 0:ee.id)||(ee==null?void 0:ee.target)||(ee==null?void 0:ee.title)||ae)}`}function A(D=0,ee={},ae=0){return o.value.has(te(D,ee,ae))}function Y(D=0,ee={},ae=0){const Q=te(D,ee,ae),ge=new Set(o.value);ge.has(Q)?ge.delete(Q):ge.add(Q),o.value=ge}function fe(D={}){return Array.isArray(D==null?void 0:D.messageBlocks)?D.messageBlocks.filter(Boolean):[]}function me(D={}){return fe(D).some(ae=>!["text","markdown"].includes(String((ae==null?void 0:ae.type)||"").trim()))}return(D,ee)=>{const ae=Ra("ProcessDetailRenderer",!0);return s.value.length?(h(),_("div",kc,[(h(!0),_(ot,null,ut(s.value,(Q,ge)=>(h(),_(ot,{key:l.value[ge]||`${Q.type}-${ge}`},[Q.type==="meta"?(h(),_("div",Tc,[(h(!0),_(ot,null,ut(Q.items||[],(I,X)=>(h(),_("div",{key:`${ge}-meta-${X}`,class:we(["process-detail-meta__item",{"process-detail-meta__item--long":k(I),"process-detail-meta__item--value-only":c(I,Q.items)}])},[c(I,Q.items)?de("",!0):(h(),_("span",_c,T(I.label),1)),i("span",{class:we(["process-detail-meta__value",{"process-detail-mobile-code-scroll":k(I),"process-detail-meta__value--mono":C(I)}])},T(I.value),3)],2))),128))])):Q.type==="checklist"?(h(),_("div",Cc,[i("div",Ec,[(h(!0),_(ot,null,ut(Q.items||[],(I,X)=>(h(),_("div",{key:`${ge}-check-${X}`,class:"process-detail-checklist__item"},[i("span",{class:we(["process-detail-checklist__icon",`is-${v(I)}`])},[v(I)==="completed"?(h(),Ee(a(Br),{key:0,class:"h-3 w-3"})):v(I)==="in_progress"?(h(),_("span",Ac)):de("",!0)],2),i("span",{class:we(v(I)==="completed"?"line-through":"")},T(I.text),3)]))),128))]),Q.totalCount?(h(),_("div",Ic,[Sn(T(`已完成 ${(Q.items||[]).filter(I=>I.completed).length} / ${Q.totalCount}`)+" ",1),Q.hiddenCount?(h(),_("span",$c,T(`,还有 ${Q.hiddenCount} 项`),1)):de("",!0)])):de("",!0)])):Q.type==="directory_list"?(h(),_("div",Pc,[i("div",Dc,[Q.path?(h(),_("span",Lc,T(Q.path),1)):de("",!0),Q.entryType?(h(),_("span",Mc,T(Q.entryType),1)):de("",!0)]),i("div",Bc,[(h(!0),_(ot,null,ut(Q.entries||[],(I,X)=>(h(),_("div",{key:`${ge}-entry-${X}`,class:"process-detail-directory__item"},T(I),1))),128))]),Q.totalCount?(h(),_("div",Rc,[Sn(T(p(Q.totalCount))+" ",1),Q.hiddenCount?(h(),_("span",Nc,T(P(Q.hiddenCount)),1)):de("",!0)])):de("",!0)])):Q.type==="bullet_list"?(h(),_("div",Oc,[i("ul",Fc,[(h(!0),_(ot,null,ut(Q.items||[],(I,X)=>(h(),_("li",{key:`${ge}-bullet-${X}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},T(I),1))),128))]),Q.hiddenCount?(h(),_("div",Uc,T(g(Q.hiddenCount)),1)):de("",!0)])):Q.type==="file_changes"?(h(),_("div",jc,[i("div",Vc,[(h(!0),_(ot,null,ut(Q.items||[],(I,X)=>(h(),_("div",{key:`${ge}-change-${X}`,class:"process-detail-filechange__item"},[i("span",zc,T(m(I.kind)),1),i("span",Hc,T(I.path),1)]))),128))])])):Q.type==="sub_agent_list"?(h(),_("div",qc,[i("div",Kc,[(h(!0),_(ot,null,ut(Q.items||[],(I,X)=>(h(),_("div",{key:`${ge}-sub-agent-${X}`,class:"min-w-0"},[i("div",Wc,[i("div",Gc,[i("span",Xc,T(B(I)),1),R(I)?(h(),_("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:R(I)},T(R(I)),9,Yc)):de("",!0)]),j(I)?(h(),_("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:$=>Y(ge,I,X)},T(A(ge,I,X)?a(n)("common.collapse"):a(n)("common.expand")),9,Jc)):de("",!0),i("span",Qc,T(S(I.status)),1)]),j(I)&&A(ge,I,X)?(h(),_("div",Zc,[me(I)?(h(),Ee(ae,{key:0,blocks:fe(I),kind:"sub-agent-message"},null,8,["blocks"])):(h(),_("pre",ed,T(I.message),1))])):de("",!0)]))),128))])])):Q.type==="markdown"?(h(),_("div",{key:6,class:we(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:u(Q.text)},null,10,td)):(h(),_("pre",nd,T(Q.text),1))],64))),128))])):de("",!0)}}}),na={__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)=>(h(),_("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:Bn({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[r[0]||(r[0]=en(Ze(l=>o("click"),["prevent"]),["enter"])),r[1]||(r[1]=en(Ze(l=>o("click"),["prevent"]),["space"]))]},T(e.label),37))}},sa=96,er=34,yn=8,od=72;function rd(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function tr(e,t,n){var r;const o=rd(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 ad(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function id(e,t,{codeLeft:n=0,buttonWidth:o=sa,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,c=r+yn,C=r+Math.max(yn,l-o-yn),v=Math.max(c,Math.min(C,k||r+yn)),g=e.bottom-t.top+s+yn,p=e.top-t.top+s-er-yn,P=s+yn,Z=s+u-yn;return{top:g+er<=Z?g:Math.max(P,p),left:v}}function oa(e={}){const t=z([]),n=z({visible:!1,top:0,left:0,content:""});let o=null,s=0;function r(){var j;return typeof e.getContainer=="function"?e.getContainer():((j=e.containerRef)==null?void 0:j.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(j=[]){var R;t.value=j,(R=e.onSelectedRowsChange)==null||R.call(e,j)}function c({clearBrowserSelection:j=!1}={}){var R,te,A,Y;u(),m(),j&&((A=(te=(R=window.getSelection)==null?void 0:R.call(window))==null?void 0:te.removeAllRanges)==null||A.call(te)),n.value={visible:!1,top:0,left:0,content:""},k([]),(Y=e.onClear)==null||Y.call(e)}function C(j){return j?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(j).filter(Boolean):[...j.querySelectorAll(String(e.rowSelector||""))]:[]}function v(j){var R;return((R=e.mapRowElement)==null?void 0:R.call(e,j))??j}function g(j,R,te){const A=String(e.rowSelector||"").trim(),Y=C(te);if(!A||!Y.length)return[];const fe=tr(j.anchorNode,A,te),me=tr(j.focusNode,A,te);if(fe&&me){const D=Y.indexOf(fe),ee=Y.indexOf(me);if(D>=0&&ee>=0){const[ae,Q]=D<=ee?[D,ee]:[ee,D];return Y.slice(ae,Q+1)}}return Y.filter(D=>{try{return R.intersectsNode(D)}catch{return!1}})}function p(){var X,$,Te;const j=(X=window.getSelection)==null?void 0:X.call(window),R=r(),te=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!j||j.rangeCount<1||j.isCollapsed||!R||!te){c();return}const Y=j.getRangeAt(0),fe=ad(Y);if(!fe||!R.contains(fe)){c();return}const me=String(j.toString()||"").replace(/\u200b/g,"");if(!me.trim()){c();return}const D=g(j,Y,R);if(!D.length){c();return}const ee=D.map(Me=>v(Me)).filter(Me=>Me!==null&&typeof Me<"u");if(!ee.length){c();return}const ae=Y.getBoundingClientRect(),Q=($=te.getBoundingClientRect)==null?void 0:$.call(te);if(!Q){c();return}const ge=((Te=e.getCodeLeft)==null?void 0:Te.call(e,D[0]))||ae.left,I=id(ae,Q,{codeLeft:ge,buttonWidth:Number(e.buttonWidth||sa),scrollTop:Number(te.scrollTop||0),scrollLeft:Number(te.scrollLeft||0),clientWidth:Number(te.clientWidth||0),clientHeight:Number(te.clientHeight||0)});n.value={visible:!0,top:I.top,left:I.left,content:me},k(ee)}function P(){u(),o=window.setTimeout(()=>{o=null,p()},Number(e.debounceMs||od))}function Z(){P()}function S(){P()}function B(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,p()}))}function K(){B()}return pn(()=>{var j,R,te,A;document.addEventListener("selectionchange",S),document.addEventListener("mouseup",S),document.addEventListener("scroll",K,!0),window.addEventListener("resize",K),(R=(j=window.visualViewport)==null?void 0:j.addEventListener)==null||R.call(j,"resize",K),(A=(te=window.visualViewport)==null?void 0:te.addEventListener)==null||A.call(te,"scroll",K)}),Rt(()=>{var j,R,te,A;c({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",S),document.removeEventListener("mouseup",S),document.removeEventListener("scroll",K,!0),window.removeEventListener("resize",K),(R=(j=window.visualViewport)==null?void 0:j.removeEventListener)==null||R.call(j,"resize",K),(A=(te=window.visualViewport)==null?void 0:te.removeEventListener)==null||A.call(te,"scroll",K)}),{selectedRows:t,selectionAction:n,clearSelectionState:c,clearScheduledSelectionUpdate:u,handleSelectionMouseUp:Z,scheduleSelectionUpdate:P,updateSelectionActionFromDom:p}}const ld=250,ud=350,cd=180,Ps=2;function ra(e){return(e==null?void 0:e.name)==="AbortError"}const fo="promptx:codex-recent-paths",dd=12;function aa(e){const{getMode:t,props:n,onSelect:o}=e,s=z([]),r=z(!1),l=z(""),u=z([]),m=z(!1),k=z(""),c=z([]),C=z([]),v=z("tree"),g=z(""),p=new Map;let P=null,Z=0,S=0,B=null;const K=G(()=>String(n.query||"").trim()),j=G(()=>Math.max(1,Number(e.minimumQueryLength)||Ps)),R=G(()=>K.value.length>=j.value),te=G(()=>typeof t=="function"),A=G(()=>te.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":v.value),Y=G(()=>We(s.value)),fe=G(()=>String(n.sessionId||"").trim()),me=G(()=>fe.value?`promptx:codex-tree-expanded:${fe.value}`:""),D=G(()=>{if(!K.value)return c.value;const H=new Set(u.value.map(J=>J.path));return c.value.filter(J=>H.has(J.path))}),ee=G(()=>{const H=new Set(D.value.map(J=>J.path));return u.value.filter(J=>!H.has(J.path))}),ae=G(()=>K.value?[...D.value,...ee.value]:c.value),Q=G(()=>A.value==="search"?ae.value:Y.value),ge=G(()=>A.value==="search"?m.value:r.value),I=G(()=>A.value==="search"?k.value:l.value),X=G(()=>A.value==="search"&&!!n.sessionId&&R.value&&!m.value&&!k.value&&!ae.value.length),$=G(()=>A.value==="search"&&!!n.sessionId&&!!K.value&&!R.value&&!m.value&&!k.value),Te=G(()=>A.value==="tree"&&!!n.sessionId&&!r.value&&!l.value&&!Y.value.length);function Me(H,J){if(!H||typeof window>"u")return J;try{const ue=window.localStorage.getItem(H);return ue?JSON.parse(ue):J}catch{return J}}function Re(H,J){if(!(!H||typeof window>"u"))try{window.localStorage.setItem(H,JSON.stringify(J))}catch{}}function Ne(H=[]){return[...H].sort((J,ue)=>{const ve=+(J.type!=="directory")-+(ue.type!=="directory");return ve||String(J.path||J.name||"").localeCompare(String(ue.path||ue.name||""),"zh-CN")})}function Ve(H){return{...H,children:[],expanded:!1,loaded:!1,loading:!1}}function We(H=[],J=0,ue=[]){return H.forEach(ve=>{ue.push({...ve,depth:J}),ve.type==="directory"&&ve.expanded&&ve.children.length&&We(ve.children,J+1,ue)}),ue}function ke(H,J=s.value){for(const ue of J){if(ue.path===H)return ue;if(ue.children.length){const ve=ke(H,ue.children);if(ve)return ve}}return null}function W(){s.value=[...s.value]}function oe(){P&&(window.clearTimeout(P),P=null),B&&(B.abort(),B=null)}function ce(H=s.value,J=[]){return H.forEach(ue=>{ue.type==="directory"&&ue.expanded&&(J.push(ue.path),ue.children.length&&ce(ue.children,J))}),J}function $e(){if(!me.value)return;const H=[...new Set(ce())];C.value=H,Re(me.value,H)}function he(){C.value=me.value?Me(me.value,[]).filter(Boolean):[]}function Le(H=s.value,J=new Set){if(!J.size)return!1;const ue=H.filter(ve=>ve.type==="directory"&&ve.hasChildren).map(ve=>ve.path);return!ue.length||ue.length!==J.size?!1:ue.every(ve=>J.has(ve))}function pe(){const H=Me(fo,[]);if(!Array.isArray(H)||!fe.value){c.value=[];return}c.value=H.filter(J=>J&&J.sessionId===fe.value&&J.path).sort((J,ue)=>Number(ue.usedAt||0)-Number(J.usedAt||0)).slice(0,dd)}function De(H){return H.name||H.path||"."}function ze(H){return H.path||"."}function Ie(H){if(!fe.value||!(H!=null&&H.path))return;const J={sessionId:fe.value,path:H.path,name:H.name||De(H),type:H.type||"file",usedAt:Date.now()},ue=Me(fo,[]),ve=[J];Array.isArray(ue)&&ue.forEach(Ue=>{!(Ue!=null&&Ue.path)||!(Ue!=null&&Ue.sessionId)||Ue.sessionId===J.sessionId&&Ue.path===J.path||ve.push(Ue)}),Re(fo,ve.slice(0,40)),pe()}function mt(H=""){const J=String(H||"").trim();return!J||!J.includes("/")?"":J.slice(0,J.lastIndexOf("/"))}function Ke(){const H=Q.value;if(!H.length)return-1;const J=H.findIndex(ue=>ue.path===g.value);return J>=0?J:0}function it(){const H=Q.value,J=Ke();return J<0||!H.length?null:H[J]||null}function gt(){const H=Q.value;if(!H.length){g.value="";return}H.some(J=>J.path===g.value)||(g.value=H[0].path)}function ht(H,J){if(J){p.set(H,J);return}p.delete(H)}function Oe(){var J;const H=p.get(g.value);(J=H==null?void 0:H.scrollIntoView)==null||J.call(H,{block:"nearest"})}function _e(H=""){return String(H||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ct(H="",J=""){const ue=String(H||""),ve=String(J||"").trim().toLowerCase();if(!ue||!ve)return null;const Ue=ue.toLowerCase(),pt=Ue.indexOf(ve);if(pt>=0)return{start:pt,end:pt+ve.length};const Ft=ve.split(/[\\/\s_.-]+/).filter(Boolean).sort((Ut,It)=>It.length-Ut.length);for(const Ut of Ft){if(Ut.length<2)continue;const It=Ue.indexOf(Ut);if(It>=0)return{start:It,end:It+Ut.length}}return null}function lt(H="",J=""){const ue=String(H||""),ve=ct(ue,J);return ve?`${_e(ue.slice(0,ve.start))}<mark class="theme-search-highlight">${_e(ue.slice(ve.start,ve.end))}</mark>${_e(ue.slice(ve.end))}`:_e(ue)}function L(H){return lt(De(H),K.value)}function N(H){return lt(ze(H),K.value)}async function ne(H="",J={}){if(!n.sessionId){s.value=[],l.value="",r.value=!1;return}const ue=!H,ve=ue?null:ke(H);if(!(!ue&&!ve)&&!(!J.force&&(ue&&s.value.length||!ue&&ve.loaded))){ue?(r.value=!0,l.value=""):(ve.loading=!0,l.value="",W());try{const Ue=await fl(n.sessionId,{path:H,refreshToken:J.refreshToken||""}),pt=Ne(Ue.items||[]).map(Ve);if(ue){s.value=pt;return}ve.children=pt,ve.loaded=!0}catch(Ue){l.value=Ue.message}finally{ue?r.value=!1:(ve.loading=!1,W())}}}async function xe(H=s.value,J=new Set,ue={}){for(const ve of H)ve.type!=="directory"||!J.has(ve.path)||(ve.expanded=!0,W(),await ne(ve.path,ue),ve.children.length&&await xe(ve.children,J,ue))}async function Fe(H={}){await ne("",H);const J=new Set(C.value),ue=Le(s.value,J),ve=J.size>0&&!ue;ue&&(C.value=[],Re(me.value,[]),J.clear());for(const Ue of s.value)Ue.type!=="directory"||!Ue.hasChildren||(Ue.expanded=ve?J.has(Ue.path):!1);if(W(),ve){await xe(s.value,J,H);return}}async function Pe(H){if(A.value!=="tree")return;const J=ke(H);if(!(!J||J.type!=="directory")){if(!J.loaded&&!J.loading){J.expanded=!0,W(),await ne(J.path),$e();return}J.expanded=!J.expanded,W(),$e()}}function Ye(H){return H!=null&&H.path?(Ie(H),o==null||o(H),!0):!1}async function tt(H={}){const J=K.value;Z+=1;const ue=Z,ve=H.refreshToken||"";if(oe(),!n.open||!n.sessionId||!J||!R.value){m.value=!1,k.value="",u.value=[];return}B=new AbortController;try{const Ue=await pl(n.sessionId,J,{limit:80,refreshToken:ve,signal:B.signal});if(ue!==Z)return;u.value=Ue.items||[]}catch(Ue){if(ra(Ue)||ue!==Z)return;k.value=Ue.message,u.value=[]}finally{ue===Z&&(B=null),ue===Z&&(m.value=!1)}}function bt(H={}){if(oe(),!n.open||!n.sessionId||!K.value||!R.value){m.value=!1,k.value="",u.value=[];return}m.value=!0,k.value="",P=window.setTimeout(()=>{P=null,tt(H)},ld)}function ft(){if(!n.sessionId){s.value=[],l.value="",r.value=!1,u.value=[],k.value="",m.value=!1;return}S=Date.now(),s.value=[],l.value="",u.value=[],k.value="",Fe({force:!0,refreshToken:S}),bt({refreshToken:S})}function kt(){if(te.value)return!1;const H=K.value?"search":"tree";return v.value===H?!1:(v.value=H,!0)}function vt(){pe(),he(),kt(),ft()}function At(){oe(),u.value=[],k.value="",m.value=!1}function Gt(H){const J=Q.value;if(!J.length)return!1;const ue=Ke(),ve=ue<0?0:(ue+H+J.length)%J.length;return g.value=J[ve].path,at(Oe),!0}async function Kt(){if(A.value!=="tree")return!1;const H=it();if(!H||H.type!=="directory")return!1;if(!H.expanded)return await Pe(H.path),g.value=H.path,!0;const J=Q.value,ue=Ke(),ve=J[ue+1];return ve&&mt(ve.path)===H.path?(g.value=ve.path,!0):!1}function se(){if(A.value!=="tree")return!1;const H=it();if(!H)return!1;if(H.type==="directory"&&H.expanded){const ue=ke(H.path);return ue&&(ue.expanded=!1,W(),$e()),g.value=H.path,!0}const J=mt(H.path);return J?(g.value=J,!0):!1}function Be(){const H=Q.value;return H.length?Ye(H[Ke()]):!1}function st(){s.value=[],l.value="",r.value=!1,u.value=[],k.value="",m.value=!1,pe(),he(),n.sessionId&&n.open&&(Fe({force:!0}),bt())}function Xe(){kt(),bt()}function Dt(){gt(),at(Oe)}return Rt(()=>{oe()}),{activeKey:g,collapseActiveDirectory:se,confirmActive:Be,currentError:I,currentLoading:ge,emitSelect:Ye,expandActiveDirectory:Kt,getDisplayName:De,getHighlightedName:L,getHighlightedPath:N,handleQueryChange:Xe,handleSessionChange:st,handleVisibleItemsChange:Dt,initializeData:vt,moveActive:Gt,normalSearchItems:ee,normalizedQuery:K,recentSearchItems:D,resetData:At,setItemRef:ht,showSearchPromptState:$,showSearchEmptyState:X,showTreeEmptyState:Te,toggleDirectory:Pe,treeItems:Y,visibleItems:Q}}const fd={class:"min-w-0"},pd={class:"theme-heading truncate text-sm font-medium"},md={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},gd={class:"theme-divider border-b px-4 py-3"},hd={class:"block"},vd={class:"sr-only"},yd={class:"relative"},Sd=["placeholder","onKeydown"],wd=["title","aria-label"],xd={class:"min-h-0 flex-1 overflow-y-auto p-2"},bd={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},kd={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},Td={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},_d={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},Cd={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},Ed={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},Ad={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},Id={key:7,class:"theme-empty-state px-3 py-4 text-[12px]"},$d={key:8,class:"theme-empty-state px-3 py-4 text-[12px]"},Pd={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},Dd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},Ld={key:11,class:"space-y-1"},Md={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Bd=["onClick"],Rd={class:"min-w-0 flex-1"},Nd=["innerHTML"],Od=["innerHTML"],Fd={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Ud=["onClick"],jd={class:"min-w-0 flex-1"},Vd=["innerHTML"],zd=["innerHTML"],Hd={key:12,class:"space-y-3"},qd={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},Kd={class:"min-w-0 flex-1"},Wd={class:"theme-list-item-title theme-list-item-title--strong break-all"},Gd={key:0,class:"theme-list-item-meta truncate"},Xd={class:"theme-list-item-meta shrink-0 pt-0.5"},Yd={class:"space-y-1 px-2 py-2"},Jd=["onClick"],Qd=["innerHTML"],Zd={key:0,class:"theme-muted-text px-1 text-[12px]"},ef={key:13,class:"space-y-1"},tf=["onClick"],nf={class:"flex items-start gap-1.5"},sf=["onClick"],of={key:1,class:"block h-5 w-5 shrink-0"},rf=["onClick"],af={class:"flex min-h-0 flex-col overflow-hidden"},lf={class:"theme-divider border-b px-4 py-2"},uf={class:"flex items-center justify-between gap-3"},cf={class:"min-w-0"},df={key:0,class:"theme-muted-text truncate text-[12px]"},ff={key:1,class:"theme-muted-text mt-1 text-[11px]"},pf={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},mf={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},gf={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},hf={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},vf={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},yf={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},Sf=["src","alt"],wf={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},xf={class:"source-code-view"},bf={class:"source-code-view__table"},kf=["innerHTML"],Tf=20,_f={__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}=Et(),{isDark:l}=Dr(),u=ys({open:!1,sessionId:"",query:""}),m=z(""),k=z(""),c=z(!1),C=z(""),v=z(null),g=z(""),p=z("path"),P=z([]),Z=z(!1),S=z(""),B=z(""),K=z(!1),j=z(""),R=new Map,te=z(null),A=z(null),Y=z(0),fe=z([]),me=z("");let D=0,ee=0,ae=null,Q=null;const ge=ud,I=cd;let X=null;const $=new Map,Te=G(()=>{var d;return String(((d=o.session)==null?void 0:d.id)||"").trim()}),Me=G(()=>{var d;return String(((d=o.session)==null?void 0:d.cwd)||"").trim()}),Re=G(()=>p.value!=="content"),Ne=G(()=>p.value==="content"),Ve=G(()=>String(g.value||"").trim()),We=G(()=>Ve.value.length>=Ps),ke=G(()=>{var d;return((d=v.value)==null?void 0:d.name)||m.value||""}),W=G(()=>{var d;return((d=v.value)==null?void 0:d.path)||m.value||""}),oe=G(()=>{var d;return E(((d=v.value)==null?void 0:d.size)||0)}),ce=G(()=>{var M,U;const d=[];return(W.value||ke.value)&&d.push(W.value||ke.value),(M=v.value)!=null&&M.size&&d.push(oe.value),(U=v.value)!=null&&U.truncated&&d.push(r("sourceBrowser.truncated")),d.join(" ")}),$e=G(()=>{var d;return!!((d=v.value)!=null&&d.previewUrl)}),he=G(()=>{var d,M;return!!((d=v.value)!=null&&d.binary&&!((M=v.value)!=null&&M.previewUrl))}),Le=G(()=>!!(v.value&&!v.value.binary&&!v.value.previewUrl)),pe=z(""),De=z(""),ze=z(""),Ie=z("2.6rem"),{selectedRows:mt,selectionAction:Ke,clearSelectionState:it,handleSelectionMouseUp:gt,updateSelectionActionFromDom:ht}=oa({getContainer:()=>A.value,isActive:()=>o.open&&Le.value,rowSelector:".source-code-view__line",mapRowElement:d=>{var U;const M=Number(((U=d==null?void 0:d.getAttribute)==null?void 0:U.call(d,"data-line"))||0);return M>0?M:null},getCodeLeft:d=>{var be,He,je;const M=(be=d==null?void 0:d.querySelector)==null?void 0:be.call(d,".source-code-view__code");if(!M)return 0;const U=(He=M.getBoundingClientRect)==null?void 0:He.call(M),F=(je=window.getComputedStyle)==null?void 0:je.call(window,M),re=Number.parseFloat((F==null?void 0:F.paddingLeft)||"0")||0;return((U==null?void 0:U.left)||0)+re},debounceMs:72}),Oe=G(()=>[...new Set(mt.value)].map(d=>Number(d)||0).filter(d=>d>0).sort((d,M)=>d-M)),_e=G(()=>{var U;const d=String(((U=v.value)==null?void 0:U.content)||"").replace(/\r\n/g,`
16
+ `),M=d?d.split(`
17
+ `):[];return[...Oe.value].sort((F,re)=>F-re).map(F=>({lineNumber:F,content:String(M[F-1]||"")})).filter(F=>F.lineNumber>0)}),ct=G(()=>_e.value.length>0),lt=G(()=>Ne.value?r("sourceBrowser.contentSearchPlaceholder"):r("sourceBrowser.searchPlaceholder")),L=G(()=>Ne.value?r("sourceBrowser.searchModeContent"):r("sourceBrowser.searchModePath")),N=G(()=>!!Ve.value),ne=G(()=>N.value?"search":"tree"),xe=G(()=>N.value&&Ne.value?Z.value:Be.value),Fe=G(()=>Re.value&&mn.value),Pe=G(()=>Re.value&&Lt.value),Ye=G(()=>N.value&&Ne.value&&!We.value&&!Z.value&&!S.value),tt=G(()=>N.value&&Ne.value&&We.value&&!!B.value&&!Z.value&&!S.value&&!P.value.length),bt=G(()=>N.value&&Ne.value&&We.value&&!Z.value&&!S.value&&!B.value&&!P.value.length),ft=G(()=>{const d=[],M=new Map;return P.value.forEach(U=>{const F=String((U==null?void 0:U.path)||"").trim();if(!F)return;let re=M.get(F);re||(re={path:F,name:String((U==null?void 0:U.name)||F.split("/").pop()||F),items:[]},M.set(F,re),d.push(re)),re.items.push(U)}),d}),kt=G(()=>P.value.map(d=>_t(d)).join("|")),vt=G(()=>Mt.value.map(d=>{const M=String((d==null?void 0:d.path)||"").trim(),U=d!=null&&d.expanded?1:0,F=d!=null&&d.loading?1:0;return`${M}:${U}:${F}`}).join("|")),{activeKey:At,collapseActiveDirectory:Gt,expandActiveDirectory:Kt,currentError:se,currentLoading:Be,getDisplayName:st,getHighlightedName:Xe,getHighlightedPath:Dt,handleQueryChange:H,handleSessionChange:J,handleVisibleItemsChange:ue,initializeData:ve,moveActive:Ue,normalSearchItems:pt,recentSearchItems:Ft,resetData:Ut,setItemRef:It,showSearchPromptState:Lt,showSearchEmptyState:mn,showTreeEmptyState:Tt,toggleDirectory:tn,treeItems:gn,visibleItems:Mt}=aa({getMode:()=>ne.value,props:u,onSelect:_n});function Xt(d=""){return String(d||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function _t(d){return`${(d==null?void 0:d.path)||""}:${(d==null?void 0:d.line)||0}:${(d==null?void 0:d.column)||0}`}function kn(d,M){if(M){R.set(d,M);return}R.delete(d)}function on(){var M;const d=R.get(j.value);(M=d==null?void 0:d.scrollIntoView)==null||M.call(d,{block:"nearest"})}function rn(d="",M=""){const U=String(d||""),F=String(M||"").trim();if(!U||!F)return Xt(U);const re=U.toLowerCase(),be=F.toLowerCase(),He=re.indexOf(be);if(He<0)return Xt(U);const je=He+be.length;return`${Xt(U.slice(0,He))}<mark class="theme-search-highlight">${Xt(U.slice(He,je))}</mark>${Xt(U.slice(je))}`}function an(d="",M=""){const U=String(d||""),F=String(M||"").trim();if(!U||!F)return[];const re=U.toLowerCase(),be=F.toLowerCase(),He=[];let je=0;for(;je<re.length;){const y=re.indexOf(be,je);if(y<0)break;He.push({start:y,end:y+be.length}),je=y+be.length}return He}function ln(d,M,U){if(!d)return null;if(d.nodeType===Node.TEXT_NODE){const re=d.textContent||"",be=U.offset,He=be+re.length;if(U.offset=He,!re)return document.createTextNode("");const je=M.filter(ye=>ye.start<He&&ye.end>be);if(!je.length)return document.createTextNode(re);const y=document.createDocumentFragment();let q=0;return je.forEach(ye=>{const Se=Math.max(0,ye.start-be),Je=Math.min(re.length,ye.end-be);if(Se>q&&y.appendChild(document.createTextNode(re.slice(q,Se))),Je>Se){const nt=document.createElement("mark");nt.className="source-code-view__search-hit",nt.textContent=re.slice(Se,Je),y.appendChild(nt)}q=Math.max(q,Je)}),q<re.length&&y.appendChild(document.createTextNode(re.slice(q))),y}if(d.nodeType!==Node.ELEMENT_NODE)return d.cloneNode(!0);const F=d.cloneNode(!1);return Array.from(d.childNodes||[]).forEach(re=>{const be=ln(re,M,U);be&&F.appendChild(be)}),F}function hn(d=A.value){var M,U,F;d&&((F=(U=(M=d.querySelectorAll)==null?void 0:M.call(d,".source-code-view__line-inner[data-original-html]"))==null?void 0:U.forEach)==null||F.call(U,re=>{const be=re.dataset.originalHtml;typeof be=="string"&&(re.innerHTML=be)}))}function Yt(){var U,F,re;const d=A.value,M=String(me.value||"").trim();d&&(hn(d),M&&((re=(F=(U=d.querySelectorAll)==null?void 0:U.call(d,".source-code-view__line.is-match .source-code-view__line-inner"))==null?void 0:F.forEach)==null||re.call(F,be=>{be.dataset.originalHtml||(be.dataset.originalHtml=be.innerHTML);const He=an(be.textContent||"",M);if(!He.length)return;const je=document.createDocumentFragment(),y={offset:0};Array.from(be.childNodes||[]).forEach(q=>{const ye=ln(q,He,y);ye&&je.appendChild(ye)}),be.replaceChildren(je)})))}function E(d=0){const M=Math.max(0,Number(d)||0);return M<1024?`${M} B`:M<1024*1024?`${(M/1024).toFixed(M<10*1024?1:0)} KB`:`${(M/(1024*1024)).toFixed(1)} MB`}function b(){var M,U,F;const d=A.value;d&&(hn(d),(F=(U=(M=d.querySelectorAll)==null?void 0:M.call(d,".source-code-view__line.is-match, .source-code-view__line.is-focus-match"))==null?void 0:U.forEach)==null||F.call(U,re=>re.classList.remove("is-match","is-focus-match")))}function V(){var M,U,F;const d=A.value;d&&((F=(U=(M=d.querySelectorAll)==null?void 0:M.call(d,".source-code-view__line.is-selected"))==null?void 0:U.forEach)==null||F.call(U,re=>re.classList.remove("is-selected")))}function f(){V();const d=A.value;!d||!Oe.value.length||Oe.value.forEach(M=>{var re,be;const U=d.querySelector(`.source-code-view__gutter[data-line="${M}"]`),F=(re=U==null?void 0:U.closest)==null?void 0:re.call(U,"tr");(be=F==null?void 0:F.classList)==null||be.add("is-selected")})}function x(){if(!Oe.value.length)return"";const d=[...Oe.value].sort((M,U)=>M-U);return d[0]===d[d.length-1]?`L${d[0]}`:`L${d[0]}-${d[d.length-1]}`}function w(){var M,U,F,re;if(!v.value||!ct.value)return;const d=_e.value.map(be=>be.lineNumber);s("insert-code-context",{source:"source",filePath:W.value,language:String(((M=v.value)==null?void 0:M.language)||""),rangeLabel:x(),lineStart:Math.min(...d),lineEnd:Math.max(...d),content:String(Ke.value.content||"").trim()||_e.value.map(be=>be.content).join(`
18
+ `)}),(re=(F=(U=window.getSelection)==null?void 0:U.call(window))==null?void 0:F.removeAllRanges)==null||re.call(F),it(),s("close")}function ie(d){var He,je,y,q;const M=(He=window.getSelection)==null?void 0:He.call(window),U=A.value;if(!M||M.rangeCount<1||M.isCollapsed||!U)return;ht();const re=M.getRangeAt(0).commonAncestorContainer;if(!U.contains((re==null?void 0:re.nodeType)===1?re:re==null?void 0:re.parentNode))return;const be=String(M.toString()||"").replace(/\u200b/g,"");be&&((y=(je=d==null?void 0:d.clipboardData)==null?void 0:je.setData)==null||y.call(je,"text/plain",be),(q=d==null?void 0:d.preventDefault)==null||q.call(d))}function Ce(){X&&(window.clearTimeout(X),X=null)}function $t(){$.clear()}function Vt(d=""){const M=String(d||"").trim();if(!M||!$.has(M))return null;const U=$.get(M);return $.delete(M),$.set(M,U),U}function nn(d="",M=null){const U=String(d||"").trim();if(!(!U||!M))for($.delete(U),$.set(U,M);$.size>Tf;){const F=$.keys().next().value;if(!F)break;$.delete(F)}}function un(d){Ce(),X=window.setTimeout(()=>{X=null,d==null||d()},I)}function St(){at(()=>{var d,M;(M=(d=te.value)==null?void 0:d.focus)==null||M.call(d)})}function zt(d=""){const M=String(d||"").trim();return M?(p.value="path",Jt(),g.value=M,u.query=M,St(),!0):!1}function wt(d){var M,U,F;if((M=d==null?void 0:d.preventDefault)==null||M.call(d),Ve.value){(U=d==null?void 0:d.stopPropagation)==null||U.call(d),g.value="";return}(F=d==null?void 0:d.stopPropagation)==null||F.call(d),s("close")}function vn(){Ce(),D+=1,$t(),m.value="",k.value="",c.value=!1,C.value="",v.value=null,pe.value="",De.value="",ze.value="",Ie.value="2.6rem",Y.value=0,fe.value=[],me.value="",it(),b()}function Jt(){ee+=1,ae&&(window.clearTimeout(ae),ae=null),Q&&(Q.abort(),Q=null),P.value=[],Z.value=!1,S.value="",B.value="",K.value=!1,j.value="",fe.value=[],me.value="",b()}function Zs(){if(ae&&(window.clearTimeout(ae),ae=null),!o.open||!Te.value||!Ne.value)return;if(!Ve.value||!We.value){Jt();return}Z.value=!0,S.value="",ae=window.setTimeout(()=>{ae=null,ts()},ge)}function Nn(d=1){const M=P.value;if(!M.length)return!1;const U=M.findIndex(re=>_t(re)===j.value),F=U<0?0:(U+d+M.length)%M.length;return j.value=_t(M[F]),at(on),!0}function On(){return Mt.value.length&&(Mt.value.find(d=>d.path===At.value)||Mt.value[0])||null}function Qt(d,M={}){return d?(At.value=(d==null?void 0:d.path)||"",j.value="",m.value=String((d==null?void 0:d.path)||"").trim(),k.value=String((d==null?void 0:d.type)||"").trim(),C.value="",Y.value=0,fe.value=[],me.value="",(d==null?void 0:d.type)==="directory"?(Ce(),v.value=null,M.toggleDirectory&&!N.value&&tn(d.path),!0):M.previewMode==="debounced"?(un(()=>es(d==null?void 0:d.path)),!0):(Ce(),es(d==null?void 0:d.path),!0)):!1}function ws(){const d=P.value;if(!d.length)return!1;const M=d.find(U=>_t(U)===j.value)||d[0];return Cn(M),!0}function eo(d){const M=String((d==null?void 0:d.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(M)&&!(N.value&&(M==="ArrowLeft"||M==="ArrowRight"))){if(Ne.value&&N.value){if(M==="ArrowDown"){if(d.preventDefault(),Nn(1)){const U=P.value,F=U.find(re=>_t(re)===j.value)||U[0];Cn(F,{previewMode:"debounced"})}return}if(M==="ArrowUp"){if(d.preventDefault(),Nn(-1)){const U=P.value,F=U.find(re=>_t(re)===j.value)||U[0];Cn(F,{previewMode:"debounced"})}return}if(M==="Enter"){d.preventDefault(),ws();return}M==="Escape"&&wt(d);return}if(M==="ArrowDown"){d.preventDefault(),Ue(1)&&at(()=>{Qt(On(),{previewMode:"debounced"})});return}if(M==="ArrowUp"){d.preventDefault(),Ue(-1)&&at(()=>{Qt(On(),{previewMode:"debounced"})});return}if(M==="ArrowRight"){d.preventDefault(),Kt();return}if(M==="ArrowLeft"){d.preventDefault(),Gt();return}if(M==="Enter"){d.preventDefault(),Qt(On(),{toggleDirectory:!0});return}M==="Escape"&&wt(d)}}async function Fn(){const d=Ne.value?"path":"content";if(p.value=d,!Ve.value){d==="content"?Jt():(Jt(),u.query="");return}if(d==="content"){u.query="",ts();return}Jt(),u.query=g.value}function to(d){var M;d.preventDefault(),(M=d.stopPropagation)==null||M.call(d),Fn().finally(()=>{St()})}async function Tn(){var be;if(await at(),b(),!A.value)return;const d=[...new Set(fe.value.map(He=>Math.max(0,Number(He)||0)).filter(He=>He>0))],M=Math.max(0,Number(Y.value)||0);if(d.forEach(He=>{var q,ye;const je=A.value.querySelector(`.source-code-view__gutter[data-line="${He}"]`),y=(q=je==null?void 0:je.closest)==null?void 0:q.call(je,"tr");(ye=y==null?void 0:y.classList)==null||ye.add("is-match")}),Yt(),!M){f();return}const U=M,F=A.value.querySelector(`.source-code-view__gutter[data-line="${U}"]`),re=(be=F==null?void 0:F.closest)==null?void 0:be.call(F,"tr");if(!re){f();return}re.classList.add("is-match","is-focus-match"),Yt(),re.scrollIntoView({block:"center",inline:"nearest"}),f()}async function Zn(){var be,He,je;if(!Le.value){pe.value="",De.value="",ze.value="";return}const d=D,M=String(((be=v.value)==null?void 0:be.content)||"").replace(/\r\n/g,`
19
+ `),U=((He=v.value)==null?void 0:He.language)||"",F=uc(M,uo),re=await fc(((je=v.value)==null?void 0:je.content)||"",{isDark:l.value,language:U,maxHighlightLines:uo.maxLines,maxHighlightChars:uo.maxChars});d===D&&(pe.value=re.html,De.value=F?"":re.bg||"",ze.value=F?"":re.fg||"",Ie.value=re.gutterWidth||"2.6rem",await at(),f())}async function es(d="",M={}){var He;const U=String(d||"").trim();if(!Te.value||!U)return;Y.value=Math.max(0,Number(M.focusLine)||0),it();const F=String(((He=v.value)==null?void 0:He.path)||"").trim();if(!M.forceReload&&F===U&&!c.value&&!C.value){await Tn();return}if(!M.forceReload&&c.value&&m.value===U)return;D+=1;const re=D;C.value="";const be=M.forceReload?null:Vt(U);if(be){c.value=!1,v.value=be,await Zn(),re===D&&Le.value&&await Tn();return}c.value=!0;try{const je=await ml(Te.value,{path:U,limit:204800,refreshToken:String(Date.now())});if(re!==D)return;v.value=je,nn(U,je),await Zn()}catch(je){if(re!==D)return;v.value=null,C.value=(je==null?void 0:je.message)||r("sourceBrowser.previewFailed")}finally{re===D&&(c.value=!1,Le.value&&await Tn())}}function _n(d){Qt(d,{toggleDirectory:!0}),at(St)}function xs(d,M){var U,F;(F=(U=d==null?void 0:d.currentTarget)==null?void 0:U.focus)==null||F.call(U),_n(M)}async function ts(){const d=Ve.value;if(!o.open||!Te.value)return;ee+=1;const M=ee;if(!d||!We.value){Jt();return}Q&&(Q.abort(),Q=null),Z.value=!0,S.value="",P.value=[],K.value=!1,j.value="",Q=new AbortController;try{const U=await gl(Te.value,d,{limit:80,refreshToken:String(Date.now()),signal:Q.signal});if(M!==ee)return;B.value=d,P.value=Array.isArray(U.items)?U.items:[],K.value=!!U.truncated,j.value=P.value[0]?_t(P.value[0]):"",P.value[0]&&Cn(P.value[0],{previewMode:"debounced"})}catch(U){if(ra(U)||M!==ee)return;B.value=d,P.value=[],S.value=(U==null?void 0:U.message)||r("sourceBrowser.contentSearchFailed")}finally{M===ee&&(Q=null),M===ee&&(Z.value=!1)}}function Cn(d,M={}){j.value=_t(d),At.value=(d==null?void 0:d.path)||"",m.value=String((d==null?void 0:d.path)||"").trim(),k.value="file",C.value="",me.value=B.value||Ve.value,fe.value=P.value.filter(F=>(F==null?void 0:F.path)===(d==null?void 0:d.path)).map(F=>Number((F==null?void 0:F.line)||0)).filter(F=>F>0);const U=()=>es(d==null?void 0:d.path,{focusLine:d==null?void 0:d.line});if(M.previewMode==="debounced"){un(U),at(St);return}Ce(),U(),at(St)}function no(d){const M=String((d==null?void 0:d.path)||"").trim();if(!M)return"";const U=M.split("/");return U[U.length-1]||M}function ns(d){const M=String((d==null?void 0:d.path)||"").trim();return!M||!M.includes("/")?"":M.slice(0,M.lastIndexOf("/"))}function so(d){return`${Array.isArray(d==null?void 0:d.items)?d.items.length:0} 处`}function ss(d){const M=B.value||Ve.value;return rn((d==null?void 0:d.preview)||"",M)}return Ae(()=>o.open,d=>{var M,U,F,re,be,He;if(u.open=d,d){(F=(U=(M=window.getSelection)==null?void 0:M.call(window))==null?void 0:U.removeAllRanges)==null||F.call(U),u.sessionId=Te.value,g.value="",p.value="path",u.query="",vn(),Jt(),ve(),zt(o.initialSearchQuery)||St();return}(He=(be=(re=window.getSelection)==null?void 0:re.call(window))==null?void 0:be.removeAllRanges)==null||He.call(be),g.value="",p.value="path",vn(),Jt(),Ut()},{immediate:!0}),Ae(Te,d=>{u.sessionId=d,o.open&&(vn(),Jt(),J())}),Ae(()=>o.initialSearchQuery,d=>{o.open&&zt(d)}),Ae(g,d=>{if(Re.value){u.query=d;return}String(d||"").trim()!==String(B.value||"").trim()&&(me.value="",Yt()),Zs()}),Ae(()=>u.query,()=>{Re.value&&H()}),Ae(kt,()=>{at(on)}),Ae(vt,()=>{ue(),!(!N.value||!Re.value)&&at(()=>{const d=On();d&&Qt(d,{previewMode:"debounced"})})}),Ae(l,async()=>{!o.open||!Le.value||(await Zn(),await Tn())}),Ae(Oe,()=>{f()}),Rt(()=>{var d,M,U;(U=(M=(d=window.getSelection)==null?void 0:d.call(window))==null?void 0:M.removeAllRanges)==null||U.call(M),it({clearBrowserSelection:!0}),Ce()}),t({applyPathSearch:zt}),(d,M)=>(h(),Ee(Js,{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:M[2]||(M[2]=U=>s("close"))},{title:Qe(()=>[i("div",fd,[i("div",pd,T(Me.value||a(r)("sourceBrowser.title")),1)])]),default:Qe(()=>{var U;return[i("div",md,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:eo},[i("div",gd,[i("label",hd,[i("span",vd,T(a(r)("sourceBrowser.searchLabel")),1),i("div",yd,[le(a(Va),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),Zt(i("input",{ref_key:"searchInputRef",ref:te,"onUpdate:modelValue":M[0]||(M[0]=F=>g.value=F),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:lt.value,onKeydown:[en(wt,["esc"]),en(Ze(to,["prevent"]),["tab"])]},null,40,Sd),[[as,g.value]]),xe.value?(h(),Ee(a(Wt),{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:L.value,"aria-label":L.value,onClick:Ze(Fn,["stop","prevent"])},[le(a(za),{class:"h-3.5 w-3.5"})],8,wd)])])]),i("div",xd,[Te.value?N.value&&Ne.value&&S.value?(h(),_("div",kd,T(S.value),1)):a(se)?(h(),_("div",Td,T(a(se)),1)):Pe.value?(h(),_("div",_d,T(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(Ps)})),1)):Fe.value?(h(),_("div",Cd,T(a(r)("sourceBrowser.searchEmpty")),1)):Ye.value?(h(),_("div",Ed,T(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(Ps)})),1)):bt.value?(h(),_("div",Ad,T(a(r)("sourceBrowser.contentSearchPrompt")),1)):tt.value?(h(),_("div",Id,T(a(r)("sourceBrowser.contentSearchEmpty")),1)):a(Tt)?(h(),_("div",$d,T(a(r)("sourceBrowser.treeEmpty")),1)):N.value&&Ne.value&&Z.value&&!P.value.length?(h(),_("div",Pd,T(a(r)("sourceBrowser.contentSearching")),1)):a(Be)&&!a(Mt).length?(h(),_("div",Dd,T(a(r)("sourceBrowser.loadingFiles")),1)):N.value&&Re.value?(h(),_("div",Ld,[a(Ft).length?(h(),_("div",Md,T(a(r)("sourceBrowser.recent")),1)):de("",!0),(h(!0),_(ot,null,ut(a(Ft),F=>(h(),_("button",{key:`recent-${F.path}`,ref_for:!0,ref:re=>a(It)(F.path,re),type:"button",class:we(["theme-list-row focus:outline-none",a(At)===F.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:re=>_n(F)},[(h(),Ee(bn(F.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",Rd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Xe)(F)},null,8,Nd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Dt)(F)},null,8,Od)])],10,Bd))),128)),u.query.trim()&&a(pt).length?(h(),_("div",Fd,T(a(r)("sourceBrowser.results")),1)):de("",!0),(h(!0),_(ot,null,ut(a(pt),F=>(h(),_("button",{key:`result-${F.path}`,ref_for:!0,ref:re=>a(It)(F.path,re),type:"button",class:we(["theme-list-row focus:outline-none",a(At)===F.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:re=>_n(F)},[(h(),Ee(bn(F.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",jd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Xe)(F)},null,8,Vd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Dt)(F)},null,8,zd)])],10,Ud))),128))])):N.value?(h(),_("div",Hd,[(h(!0),_(ot,null,ut(ft.value,F=>(h(),_("div",{key:F.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",qd,[le(a(Pn),{class:"theme-list-item-icon"}),i("div",Kd,[i("div",Wd,T(no(F)),1),ns(F)?(h(),_("div",Gd,T(ns(F)),1)):de("",!0)]),i("div",Xd,T(so(F)),1)]),i("div",Yd,[(h(!0),_(ot,null,ut(F.items,re=>(h(),_("button",{key:_t(re),ref_for:!0,ref:be=>kn(_t(re),be),type:"button",class:we(["theme-list-row gap-0 focus:outline-none",j.value===_t(re)?"theme-list-item-active":"theme-list-item-hover"]),onClick:be=>Cn(re)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:ss(re)},null,8,Qd)],10,Jd))),128))])]))),128)),K.value?(h(),_("div",Zd,T(a(r)("sourceBrowser.contentSearchTruncated")),1)):de("",!0)])):(h(),_("div",ef,[(h(!0),_(ot,null,ut(a(gn),F=>(h(),_("div",{key:F.path,ref_for:!0,ref:re=>a(It)(F.path,re),class:we(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(At)===F.path?"theme-list-item-active":F.type==="directory"&&F.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Bn({paddingLeft:`${F.depth*16+6}px`}),tabindex:"-1",onClick:re=>xs(re,F)},[i("div",nf,[F.type==="directory"?(h(),_("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Ze(re=>a(tn)(F.path),["stop"])},[F.loading?(h(),Ee(a(Wt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),Ee(a(Rr),{key:1,class:we(["h-3.5 w-3.5 transition",F.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,sf)):(h(),_("span",of)),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:Ze(re=>_n(F),["stop"])},[(h(),Ee(bn(F.type==="directory"?a(Hn):a(Pn)),{class:we(["h-4 w-4 shrink-0",F.type==="directory"&&F.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:we(["theme-list-item-title min-w-0 flex-1 truncate",F.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},T(a(st)(F)),3)],8,rf)])],14,tf))),128))])):(h(),_("div",bd,T(a(r)("sourceBrowser.noProject")),1))])],32),i("section",af,[i("div",lf,[i("div",uf,[i("div",cf,[ce.value?(h(),_("p",df,T(ce.value),1)):de("",!0),Le.value?(h(),_("p",ff,T(a(r)("sourceBrowser.selectCodeLineHint")),1)):de("",!0)])])]),i("div",pf,[c.value?(h(),_("div",mf,[i("span",null,T(a(r)("sourceBrowser.previewLoading")),1)])):C.value?(h(),_("div",gf,T(C.value),1)):k.value==="directory"?(h(),_("div",hf,T(a(r)("sourceBrowser.selectFileHint")),1)):m.value?$e.value?(h(),_("div",yf,[i("img",{src:v.value.previewUrl,alt:ke.value,class:"source-browser-image object-contain"},null,8,Sf)])):he.value?(h(),_("div",wf,[le(a(Ha),{class:"h-8 w-8"}),i("span",null,T((U=v.value)!=null&&U.tooLarge?a(r)("sourceBrowser.binaryTooLarge"):a(r)("sourceBrowser.binaryUnsupported")),1)])):Le.value?(h(),_("div",{key:6,ref_key:"previewContainerRef",ref:A,class:"source-browser-code relative rounded-sm border",style:Bn({"--source-code-bg":De.value||"var(--theme-panel)","--source-code-fg":ze.value||"var(--theme-textPrimary)","--source-code-gutter-width":Ie.value}),onCopy:ie,onMouseup:M[1]||(M[1]=(...F)=>a(gt)&&a(gt)(...F))},[i("div",xf,[i("table",bf,[i("tbody",{innerHTML:pe.value},null,8,kf)])]),e.open&&a(Ke).visible?(h(),Ee(na,{key:0,top:a(Ke).top,left:a(Ke).left,label:a(r)("sourceBrowser.insertSelection"),onClick:w},null,8,["top","left","label"])):de("",!0)],36)):de("",!0):(h(),_("div",vf,T(a(r)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},Cf=Pr(_f,[["__scopeId","data-v-f17d487a"]]);function Ef(e={}){const{items:t,themeKey:n,getCacheKey:o=S=>String((S==null?void 0:S.id)||"").trim(),getSource:s=S=>String((S==null?void 0:S.content)||""),shouldRender:r=()=>!0,renderAsync:l=async S=>S,renderFallback:u=S=>S,onRendered:m=null}=e,k=new Map,c=new Map,C=z(0),v=G(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(S=>{const B=!!r(S),K=String(o(S)||"").trim(),j=B?String(s(S)||""):"";return{item:S,active:B,cacheKey:K,source:j}}));function g(S){if(C.value,!r(S))return"";const B=String(s(S)||""),K=String(o(S)||"").trim(),j=String((n==null?void 0:n.value)||"");if(!K)return u(B,S);const R=k.get(K);return(R==null?void 0:R.source)===B&&(R==null?void 0:R.theme)===j?R.html:u(B,S)}async function p(S){if(!r(S))return;const B=String(s(S)||""),K=String(o(S)||"").trim();if(!K)return;const j=String((n==null?void 0:n.value)||""),R=k.get(K);if((R==null?void 0:R.source)===B&&(R==null?void 0:R.theme)===j)return;const te=Symbol(K);c.set(K,te);try{const A=await l(B,S,{themeKey:j});if(c.get(K)!==te)return;k.set(K,{source:B,theme:j,html:A}),C.value+=1,m==null||m(S,{cacheKey:K,source:B,themeKey:j})}catch{}finally{c.get(K)===te&&c.delete(K)}}function P(S=[]){S.forEach(B=>{B!=null&&B.item&&p(B.item)})}function Z(S=[]){const B=new Set((Array.isArray(S)?S:[]).filter(j=>j==null?void 0:j.active).map(j=>String((j==null?void 0:j.cacheKey)||"").trim()).filter(Boolean));let K=!1;for(const j of k.keys())B.has(j)||(k.delete(j),K=!0);for(const j of c.keys())B.has(j)||c.delete(j);K&&(C.value+=1)}return Ae(v,()=>{Z(v.value||[]),P(v.value||[])},{immediate:!0}),Ae(n,()=>{P(v.value||[])}),Rt(()=>{c.clear()}),{getRenderedHtml:g}}const Af=`${Xn()}/api/events/stream`,Kn=new Set;let Dn=null,Ds=null;function bo(){Ds&&(window.clearTimeout(Ds),Ds=null)}function ia(){Dn&&(Dn.close(),Dn=null)}function If(e){Kn.forEach(t=>{try{t(e)}catch{}})}function la(){typeof window>"u"||typeof window.EventSource>"u"||Dn||!Kn.size||(bo(),Dn=new window.EventSource(Af),Dn.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;If(t)}catch{}},Dn.onerror=()=>{ia(),Kn.size&&(bo(),Ds=window.setTimeout(()=>{la()},1500))})}function $f(e){return typeof e!="function"?()=>{}:(Kn.add(e),la(),()=>{Kn.delete(e),!Kn.size&&(bo(),ia())})}const ua=z(0),ko=z(0),Ls=z(""),ls=z(""),Ms=z(0),ca=ys({}),To=ys({}),_o=ys({}),us=new Map;let nr=!1;const Pf=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),Df=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function po(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function Lf(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&Pf.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 Mf(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:Df.has(r)}function Bf(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=us.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function Rf(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=Lf(e);if(t){if(t==="ready"){ua.value+=1,Ls.value="",ls.value="",Ms.value+=1;return}if(t==="tasks.changed"){Ls.value=n,ls.value=String(e.reason||"").trim(),o.updatesTaskList&&(ko.value+=1),o.updatesTaskDiff&&po(To,n);return}if(t==="runs.changed"){Ls.value=n,ls.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},r=n&&_o[n]||null,l=Mf(r,s);n&&(_o[n]=s),o.updatesTaskList&&!l&&(ko.value+=1),o.updatesSessions&&(Ms.value+=1),o.updatesTaskRuns&&po(ca,n),o.updatesTaskDiff&&!l&&po(To,n);return}if(t==="sessions.changed"){ls.value="",o.updatesSessions&&(Ms.value+=1);return}t==="run.event"&&Bf(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function da(){nr||typeof window>"u"||($f(e=>{Rf(e)}),nr=!0)}function Nf(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(ca[t])||0):0}function Of(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(To[t])||0):0}function Ff(e=""){const t=String(e||"").trim();return t&&_o[t]||null}function Uf(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};da();const o=us.get(n)||new Set;return o.add(t),us.set(n,o),()=>{const s=us.get(n);s&&(s.delete(t),s.size||us.delete(n))}}function fa(){return da(),{readyVersion:ua,listSyncVersion:ko,listSyncTaskSlug:Ls,listSyncReason:ls,sessionsSyncVersion:Ms,getTaskRunSyncVersion:Nf,getTaskRunChange:Ff,getTaskDiffSyncVersion:Of}}const jf=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,Vf=/\u001B\[[0-?]*[ -/]*[@-~]/g,zf=/\u001B[@-_]/g,Hf=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function qf(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function Jn(e=""){return qf(String(e||"")).replace(jf,"").replace(Vf,"").replace(zf,"").replace(/\r\n/g,`
20
+ `).replace(/\r/g,`
21
+ `).replace(Hf,"")}function Ss(e=""){return Jn(e)}function Rn(e=""){return String(e||"").replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function Uo(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 Kf(e=""){const t=Rn(Ss(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=Rn(n.slice(1).join(`
23
+ `));return{meta:{type:"meta",items:[{label:s[1].trim(),value:s[2].trim()}]},rest:u}}function Wf(e="",t={}){const n=Rn(Ss(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}=Uo(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 Gf(e="",t={}){const n=Rn(Ss(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}=Uo(s,t.maxItems??12);return{type:"checklist",items:r,totalCount:s.length,hiddenCount:l}}function Xf(e="",t={}){const n=Rn(Ss(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}=Uo(s,t.maxItems??12);return{type:"bullet_list",items:r,totalCount:s.length,hiddenCount:l}}function Yf(e="",t={}){return{type:t.preferMarkdown?"markdown":"text",text:e}}function Jf(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 Qf(e="",t={}){const n=String(e||"").split(/\n{2,}/).map(l=>Rn(l)).filter(l=>l.trim());if(n.length<2)return null;const o=Jf(n.flatMap(l=>jo(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 jo(e="",t={}){const n=Rn(Ss(e));if(!n.trim())return[];const o=Kf(n);if(o!=null&&o.rest){const u=jo(o.rest,t);return[o.meta,...u.length?u:[{type:"text",text:o.rest}]]}const s=Wf(n,t);if(s)return[s];const r=Gf(n,t);if(r)return[r];const l=Xf(n,t);if(l)return[l];if(!t._disableMixedSegmentation){const u=Qf(n,t);if(u!=null&&u.length)return u}return[Yf(n,t)]}const Zf=new Set(["queued","starting","running","stopping"]);function wn(){return Xs()==="en-US"}function O(e,t){return wn()?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=Ge(t,n);if(o&&o!==t)return o}return String((e==null?void 0:e.message)||"").trim()}function sr(e=""){const t=Date.parse(String(e||""));return Number.isFinite(t)?t:0}function or(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=sr(o.updatedAt)-sr(n.updatedAt);return l||String(n.title||n.cwd||n.id).localeCompare(String(o.title||o.cwd||o.id),Xs())})}function pa(e="",t=24,n=2400){const o=Jn(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 $n(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||O("未命名任务","Untitled Task")}`}).join(`
32
+ `):""}function Nt(e=0){const t=Number(e||0);return Number.isFinite(t)?t.toLocaleString(Xs()):"0"}function Vo(e=""){return String(e||"").trim().toLowerCase()==="shell"}function ep(e=""){return Vo(e)?O("Shell","Shell"):dt(e)}function tp(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 ma(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 zs(e={}){return ma(e).length}function ga(e={}){const t=ma(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:tp(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?Mn(r):[]}})}function np(e={},t=120){const n=ga(e).map(o=>o.message).filter(Boolean);return yt(n.join(wn()?" | ":"|"),t)}function ha(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?wn()?`${n}h ${o}m ${s}s`:`${n}小时${o}分${s}秒`:wn()?`${o}m ${s}s`:`${o}分${s}秒`}function yt(e="",t=140){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,t)}...`:""}function va(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 ps(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 sp(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 op(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)||O("未命名任务","Untitled Task")}function Bs(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=sp(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:op(t)}}).filter(Boolean)}function rr(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return Bs(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return Bs(n.todos);if(Array.isArray(n.items))return Bs(n.items)}}catch{return[]}return[]}function ya(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function zo(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(([,c])=>c.includes(l)))==null?void 0:k[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:r,category:m}}function ms(e={},t=null){const n=t||zo(e.command);if(n.category!=="todo")return[];const o=rr(e.aggregated_output);return o.length?o:rr(n.subject)}function Mn(e="",t={}){return jo(Jn(e),t)}function ar(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=ps([n?{label:O("关键词","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 ir(e={}){const t=String(e.tool||"").trim(),n=zs(e),o=String(e.prompt||"").trim(),s=ga(e),r=[],l=[t?{label:O("工具","Tool"),value:t}:null,n?{label:O("子代理","Sub-agent"),value:String(n)}:null],u=ps(l);return u&&r.push(u),s.length&&r.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&r.push(...Mn(o,{preferMarkdown:!0})),r}function lr(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 _s(e={},t=!1,n="codex"){const o=[],s=zo(e.command),r=ms(e,s),l=ya(r),u=typeof e.exit_code=="number",m=u?e.exit_code===0:e.status==="completed",k=ps([s.toolName?{label:O("工具","Tool"),value:s.toolName}:null,l||s.category!=="shell"?null:s.subject?{label:O("命令","Command"),value:s.subject}:e.command?{label:O("命令","Command"),value:e.command}:null,n&&n!=="codex"?{label:O("引擎","Engine"),value:ep(n)}:null,u&&!m?{label:O("退出码","Exit code"),value:String(e.exit_code)}:null]);if(k&&o.push(k),l&&o.push(l),t){if(l)return o;const c=pa(e.aggregated_output);c&&o.push(...Mn(c,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function Vn(e={}){const t=zo(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function mo(e={}){const t=Array.isArray(e.items)?Bs(e.items):[];return t.length?[ya(t)]:[]}function Qn(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function Co(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function rp(e,t,n,o,s){const r=Co(e,t);return r?(r.events=[],r.lastEventSeq=0,r.summary=Qn(),((n==null?void 0:n.items)||[]).forEach(l=>{qo(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 Sa(e={}){const t=String((e==null?void 0:e.displayEngine)||"").trim();return t?Vs(t):Vo(e==null?void 0:e.engine)?"codex":Vs(e==null?void 0:e.engine)}function Ot(e={}){return dt(Sa(e))}function ap(e={}){return Vo(e==null?void 0:e.engine)}function gs(e=""){return Zf.has(String(e||"").trim())}function Ho(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 ur(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"?O("正在搜索网页","Searching the web"):O("已搜索网页","Web search completed"),detail:va(s?O(`关键词:${s}`,`Query: ${s}`):"",r.length>1?r:[])}:o==="open_page"?{kind:"command",title:t==="started"?O("正在打开网页","Opening page"):O("已打开网页","Page opened"),detail:l}:{kind:"command",title:t==="started"?O("准备网页检索","Preparing web search"):O("网页检索已更新","Web search updated"),detail:s}}function cr(e={},t="completed"){const n=String(e.tool||"").trim(),o=zs(e),s=yt(e.prompt);return n==="spawn_agent"?{kind:"todo",title:t==="started"?O("正在启动子代理","Starting sub-agent"):O(`已启动 ${o||1} 个子代理`,`Started ${o||1} sub-agent(s)`),detail:s?O(`任务:${s}`,`Task: ${s}`):""}:n==="wait"?{kind:"todo",title:t==="started"?o?O(`等待 ${o} 个子代理返回结果`,`Waiting for ${o} sub-agent result(s)`):O("等待子代理返回结果","Waiting for sub-agent results"):O("子代理结果已汇总","Sub-agent results aggregated"),detail:s?O(`等待内容:${s}`,`Waiting on: ${s}`):""}:{kind:"todo",title:t==="started"?O(`正在执行协作工具:${n||"未知工具"}`,`Running collaboration tool: ${n||"Unknown tool"}`):O(`协作工具完成:${n||"未知工具"}`,`Collaboration tool completed: ${n||"Unknown tool"}`),detail:s?O(`任务:${s}`,`Task: ${s}`):""}}function dr(e={},t="completed"){const n=Array.isArray(e.changes)?e.changes:[],o={create:O("新增","Added"),update:O("更新","Updated"),delete:O("删除","Deleted")};return{kind:"command",title:t==="started"?O("正在整理文件变更","Collecting file changes"):O(`已记录 ${n.length||0} 个文件改动`,`Recorded ${n.length||0} file change(s)`),detail:va("",n.map(s=>{const r=String((s==null?void 0:s.path)||"").trim();return`${o[String((s==null?void 0:s.kind)||"").trim()]||O("变更","Changed")} ${r||O("未命名文件","Unnamed file")}`}))}}function ip(e,t={}){var l,u,m,k,c,C,v,g;e!=null&&e.summary||(e.summary=Qn());const n=e.summary,o=Ot(e),s=String(t.type||"").trim(),r=t.item||{};if(s===xt.TURN_STARTED){n.currentActivity=O("正在分析任务","Analyzing task"),n.latestActivity=O(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===xt.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=O(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===xt.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=O("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===xt.ERROR){const p=Ho(hs(t));if(p){n.currentActivity=O(`网络异常,正在重试 (${p.attempt}/${p.total})`,`Network error, retrying (${p.attempt}/${p.total})`),n.latestActivity=n.currentActivity,n.latestDetail=yt(p.reason,120);return}n.currentActivity="",n.latestActivity=O(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=yt(hs(t),120);return}if(s===xt.ITEM_STARTED){if(r.type===rt.REASONING){n.currentActivity=O("正在思考","Thinking"),n.latestActivity=O("正在思考","Thinking"),n.latestDetail=yt(r.text,120);return}if(r.type===rt.COMMAND_EXECUTION){if(Vn(r).groupType==="todo"){const P=$n(ms(r));n.currentActivity=O("正在更新待办列表","Updating todo list"),n.latestActivity=O("正在更新待办列表","Updating todo list"),n.latestDetail=yt(P,120);return}n.currentActivity=O("正在执行命令","Running command"),n.latestActivity=O("开始执行命令","Command started"),n.latestDetail=yt(r.command,120);return}if(r.type===rt.WEB_SEARCH){n.currentActivity=((l=r.action)==null?void 0:l.type)==="open_page"?O("正在打开网页","Opening page"):O("正在搜索网页","Searching the web"),n.latestActivity=n.currentActivity,n.latestDetail=yt(((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===rt.COLLAB_TOOL_CALL){if(r.tool==="wait"){const p=zs(r);n.waitingAgentCount=p,n.currentActivity=p?O(`等待 ${p} 个子代理返回结果`,`Waiting for ${p} sub-agent result(s)`):O("等待子代理返回结果","Waiting for sub-agent results"),n.latestActivity=n.currentActivity,n.latestDetail=yt(r.prompt,120);return}if(r.tool==="spawn_agent"){n.currentActivity=O("正在启动子代理","Starting sub-agent"),n.latestActivity=O("正在启动子代理","Starting sub-agent"),n.latestDetail=yt(r.prompt,120);return}}if(r.type===rt.FILE_CHANGE){n.currentActivity=O("正在整理文件变更","Collecting file changes"),n.latestActivity=O("正在整理文件变更","Collecting file changes"),n.latestDetail=yt((r.changes||[]).map(p=>p==null?void 0:p.path).filter(Boolean).join(wn()?", ":","),120);return}r.type===rt.TODO_LIST&&(n.currentActivity=O("正在规划执行步骤","Planning steps"),n.latestActivity=O("正在规划执行步骤","Planning steps"),n.latestDetail=yt((r.items||[]).map(p=>p==null?void 0:p.text).filter(Boolean).join(wn()?"; ":";"),120));return}if(s===xt.ITEM_COMPLETED){if(r.type===rt.COMMAND_EXECUTION){if(Vn(r).groupType==="todo"){n.currentActivity="",n.latestActivity=O("待办列表已更新","Todo list updated"),n.latestDetail=yt($n(ms(r)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=O("命令执行完成","Command completed"),n.latestDetail=yt(r.command,120);return}if(r.type===rt.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((c=r.action)==null?void 0:c.type)==="open_page"?O("已打开网页","Page opened"):O("已搜索网页","Web search completed"),n.latestDetail=yt(((C=r.action)==null?void 0:C.type)==="open_page"?((v=r.action)==null?void 0:v.url)||r.query:r.query||((g=r.action)==null?void 0:g.query),120);return}if(r.type===rt.COLLAB_TOOL_CALL){if(r.tool==="spawn_agent"){const p=zs(r);n.subAgentCount+=p,n.currentActivity="",n.latestActivity=p?O(`已启动 ${p} 个子代理`,`Started ${p} sub-agent(s)`):O("已启动子代理","Started sub-agent"),n.latestDetail=yt(r.prompt,120);return}if(r.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=O("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=np(r,120)||yt(r.prompt,120);return}n.currentActivity="",n.latestActivity=O(`协作工具完成:${r.tool||"未知工具"}`,`Collaboration tool completed: ${r.tool||"Unknown tool"}`),n.latestDetail=yt(r.prompt,120);return}if(r.type===rt.FILE_CHANGE){const p=Array.isArray(r.changes)?r.changes:[];n.fileChangeCount+=p.length,n.currentActivity="",n.latestActivity=p.length?O(`已记录 ${p.length} 个文件改动`,`Recorded ${p.length} file change(s)`):O("已记录文件改动","Recorded file changes"),n.latestDetail=yt(p.map(P=>P==null?void 0:P.path).filter(Boolean).join(wn()?", ":","),120);return}if(r.type===rt.TODO_LIST){n.currentActivity="",n.latestActivity=O("待办列表已更新","Todo list updated"),n.latestDetail=yt((r.items||[]).map(p=>p==null?void 0:p.text).filter(Boolean).join(wn()?"; ":";"),120);return}r.type===rt.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=O(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=yt(r.text,120))}}function lp(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(gs(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 wa(e={},t={}){const n=e.summary||Qn(),o=[],s=lp(e,t);return s>0&&o.push({key:"elapsed",label:O("耗时","Elapsed"),value:ha(s)}),n.webSearchCount&&o.push({key:"web",label:O("网页","Web"),value:Nt(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:O("命令","Command"),value:Nt(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:O("改动","Changes"),value:Nt(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:O("子代理","Sub-agent"),value:Nt(n.subAgentCount)}),o}function xa(e={}){const t=e.summary||Qn();return t.waitingAgentCount>0?O(`当前:等待 ${Nt(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${Nt(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?O(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?O(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):gs(e.status)?O(`当前:正在等待 ${Ot(e)} 返回更多事件`,`Current: waiting for more events from ${Ot(e)}`):""}function ba(e={}){const t=e.summary||Qn();return String(t.latestDetail||"").trim()}function up(e={}){return!!(wa(e).length||xa(e)||ba(e))}const cp=[{type:"startup_config",title:e=>O(`${dt(e)} 启动配置冲突`,`${dt(e)} startup config conflict`),summary:e=>O(`${dt(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${dt(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:O("额度或账单异常","Quota or billing issue"),summary:e=>O(`${dt(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${dt(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:O("权限不足","Insufficient permissions"),summary:e=>O(`${dt(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${dt(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:O("请求过于频繁","Too many requests"),summary:e=>O(`${dt(e)} 可能触发了限流,请稍后再试。`,`${dt(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:O("上下文过长","Context too long"),summary:O("这次发送的内容可能过长,超过了模型可处理的上下文限制。","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:O("模型或服务暂不可用","Model or service unavailable"),summary:e=>O(`${dt(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${dt(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:O("网络连接异常","Network connection issue"),summary:e=>O(`${dt(e)} 在请求过程中遇到了网络问题或连接超时。`,`${dt(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=>O(`${dt(e)} CLI 不可用`,`${dt(e)} CLI unavailable`),summary:e=>O(`当前环境没有正确安装或配置 ${dt(e)} CLI。`,`${dt(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 Yn(e="",t="codex"){const n=Jn(e).trim();if(!n)return null;const o=cp.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 fn(e="",t="codex"){const n=Jn(e).trim();if(!n)return"";const o=Yn(n,t);return o?`${o.summary}
35
+
36
+ ${O("原始错误","Raw error")}: ${o.rawMessage}`:n}function Eo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return Jn(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=Eo(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=Eo(o,t+1);if(s)return s}return""}function hs(e={}){return Eo(e)}function dp(e={},t="Codex",n="codex"){var r,l,u,m;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:O(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===xt.THREAD_STARTED){const k=e.thread_id?O(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:O(`${t} 会话已创建`,`${t} session created`),detail:k,detailBlocks:k?[ps([{label:"ID",value:e.thread_id}])]:[]}}if(o===xt.TURN_STARTED)return{title:O(`${t} 开始执行`,`${t} started`),detail:""};if(o===xt.TURN_COMPLETED){const k=e.usage?[O(`输入 ${Nt(e.usage.input_tokens)}`,`Input ${Nt(e.usage.input_tokens)}`),e.usage.cached_input_tokens?O(`缓存 ${Nt(e.usage.cached_input_tokens)}`,`Cached ${Nt(e.usage.cached_input_tokens)}`):"",O(`输出 ${Nt(e.usage.output_tokens)}`,`Output ${Nt(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:O(`${t} 执行完成`,`${t} completed`),detail:k,detailBlocks:e.usage?[ps([{label:O("输入","Input"),value:Nt(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:O("缓存","Cached"),value:Nt(e.usage.cached_input_tokens)}:null,{label:O("输出","Output"),value:Nt(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===xt.ERROR||o===xt.TURN_FAILED){const k=hs(e)||O(`${t} 执行失败`,`${t} failed`),c=o===xt.ERROR?Ho(k):null;if(c)return{kind:"info",title:O(`网络异常,正在重试 (${c.attempt}/${c.total})`,`Network error, retrying (${c.attempt}/${c.total})`),detail:fn(c.reason||c.rawMessage,n),detailBlocks:Mn(fn(c.reason||c.rawMessage,n),{preferMarkdown:!0})};const C=Yn(k,n);return{kind:"error",title:(C==null?void 0:C.title)||(o===xt.TURN_FAILED?O("本轮运行失败","This run failed"):O(`${t} 返回错误`,`${t} returned an error`)),detail:fn(k,n),detailBlocks:Mn(fn(k,n),{preferMarkdown:!0})}}if(o===xt.ITEM_STARTED)return s.type===rt.REASONING?{kind:"reasoning",title:O("思考过程","Thinking"),detail:s.text||"",detailBlocks:Mn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===rt.WEB_SEARCH?{...ur(s,"started"),detailBlocks:ar(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===rt.COLLAB_TOOL_CALL?{...cr(s,"started"),detailBlocks:ir(s)}:s.type===rt.FILE_CHANGE?{...dr(s,"started"),detailBlocks:lr(s)}:s.type===rt.COMMAND_EXECUTION?Vn(s).groupType==="todo"?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(ms(s)),detailBlocks:_s(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:O("开始执行命令","Command started"),detail:s.command||"",detailBlocks:_s(s,!1,n),...Vn(s),phase:"started"}:s.type===rt.TODO_LIST?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(s.items),detailBlocks:mo(s),groupType:"todo",phase:"started"}:{title:O(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===xt.ITEM_UPDATED&&s.type===rt.TODO_LIST)return{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(s.items),detailBlocks:mo(s),groupType:"todo",phase:"updated"};if(o===xt.ITEM_COMPLETED){if(s.type===rt.AGENT_MESSAGE&&s.text)return{kind:"result",title:O(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===rt.WEB_SEARCH)return{...ur(s,"completed"),detailBlocks:ar(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===rt.COLLAB_TOOL_CALL)return{...cr(s,"completed"),detailBlocks:ir(s)};if(s.type===rt.FILE_CHANGE)return{...dr(s,"completed"),detailBlocks:lr(s)};if(s.type===rt.COMMAND_EXECUTION){if(Vn(s).groupType==="todo"){const C=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:C?"todo":"error",title:C?O("更新待办列表","Update todo list"):O("更新待办列表失败","Todo list update failed"),detail:$n(ms(s)),detailBlocks:_s(s,!0,n),groupType:"todo",phase:"completed"}}const c=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:c?"command":"error",title:c?O("命令执行完成","Command completed"):O(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,pa(s.aggregated_output)].filter(Boolean).join(`
37
+
38
+ `),detailBlocks:_s(s,!0,n),...Vn(s),phase:"completed"}}return s.type===rt.TODO_LIST?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(s.items),detailBlocks:mo(s),groupType:"todo",phase:"completed"}:{title:O(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:O(`事件: ${o}`,`Event: ${o}`),detail:""}}function fp(e){return e.status==="queued"?O("排队中","Queued"):e.status==="starting"?O("启动中","Starting"):e.status==="stopping"?O("停止中","Stopping"):e.status==="running"?O("进行中","Running"):e.status==="error"?O("失败","Failed"):e.status==="interrupted"?O("已中断","Interrupted"):e.status==="stopped"?O("已停止","Stopped"):e.status==="stop_timeout"?O("停止超时","Stop timeout"):O("已完成","Completed")}function ka(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?Mn(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 pp(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"?$s(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:Qn()}}function In(e,t,n){const o=ka(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function mp(e,t,n){var s;const o=ka(t,n);if(o){for(let r=e.events.length-1;r>=0;r-=1){const l=O("网络异常,正在重试","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 gp(e,t={},n,o=()=>{}){var r,l,u,m,k,c,C,v,g;const s=jr(t.type);if(s===qt.SESSION){o(t.session);return}if(s===qt.SESSION_UPDATED){o(t.session);return}if(s===qt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;In(e,{title:cs(t)||O("状态已更新","Status updated"),detail:""},n);return}if(s===qt.STDERR){const p=Yn(t.text,e.engine);In(e,{kind:"error",title:(p==null?void 0:p.title)||"stderr",detail:fn(t.text,e.engine)},n);return}if(s===qt.STDOUT){In(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===qt.AGENT_EVENT){if(ip(e,t.event),((r=t.event)==null?void 0:r.type)===xt.THREAD_STARTED)return;const p=dp(t.event,Ot(e),e.engine);String(p.title||"").startsWith(O("网络异常,正在重试","Network error, retrying"))?mp(e,p,n):In(e,p,n),((l=t.event)==null?void 0:l.type)===xt.ITEM_COMPLETED&&((m=(u=t.event)==null?void 0:u.item)==null?void 0:m.type)===rt.AGENT_MESSAGE&&((c=(k=t.event)==null?void 0:k.item)!=null&&c.text)&&(e.responseMessage=t.event.item.text);const P=hs(t.event)||O(`${Ot(e)} 执行失败`,`${Ot(e)} failed`);if(!(((C=t.event)==null?void 0:C.type)==="error"?Ho(P):null)&&(((v=t.event)==null?void 0:v.type)===xt.ERROR||((g=t.event)==null?void 0:g.type)===xt.TURN_FAILED)){const S=hs(t.event)||O(`${Ot(e)} 执行失败`,`${Ot(e)} failed`);e.errorMessage=fn(S,e.engine),e.status="error"}return}if(s===qt.COMPLETED){In(e,{kind:"result",title:O("本轮执行结束","Run finished"),detail:""},n);const p=cs(t);p&&(e.responseMessage=p);return}if(s===qt.STOPPED){In(e,{title:cs(t)||O("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===qt.ERROR){const p=cs(t),P=Yn(p,e.engine);In(e,{kind:"error",title:(P==null?void 0:P.title)||O("执行失败","Execution failed"),detail:fn(p||O(`${Ot(e)} 执行失败`,`${Ot(e)} failed`),e.engine)},n)}}function hp(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=Yn(o,n),l=Yn(s,n);return!r&&!!l}function vp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=fn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=hp(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=O(`本轮 ${Ot(e)} 执行已完成,没有返回额外文本。`,`${Ot(e)} completed in this run without returning additional text.`)),e}function qo(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)||{};gp(e,r,n,o);const l=jr(r.type);return l===qt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===qt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===qt.ERROR&&(e.status="error",e.errorMessage=fn(String(cs(r)||e.errorMessage||O(`${Ot(e)} 执行失败`,`${Ot(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 fr(e,t,n,o){const s=pp(e,t);return(e.events||[]).forEach(r=>{qo(s,r,n,o)}),vp(s,e)}const yp=1800,pr=7200,Sp=15e3,go={clearTaskCodexRuns:wl,listCodexRunEvents:yl,listTaskCodexRuns:vl};function ds(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 wp(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>ds(o,t)))}function xp(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function bp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:u,supportsServerEvents:m,scheduleScrollToBottom:k,resetAutoStickToBottom:c,mergeSessionRecord:C,mergeSession:v,loadSessions:g,showProcessLogs:p}=e;let P=0,Z=0,S=null,B="",K=null,j=null,R="",te=!!(p!=null&&p.value),A=0;const Y=new Map;function fe(){return P+=1,P}function me(){return Z+=1,Z}function D(){K&&(window.clearInterval(K),K=null)}function ee(){j&&(window.clearInterval(j),j=null)}function ae(){A=Date.now()}function Q(){Y.clear(),n.value=[],s.value=!1,r.value=0,l.value="",R="",B="",P=0,Z=0,c()}function ge(){const W=[...n.value].reverse().find(oe=>gs(oe.status))||null;if(l.value=(W==null?void 0:W.runId)||"",s.value=!!W,W!=null&&W.startedAt){const oe=Date.parse(String(W.startedAt||""));r.value=Number.isFinite(oe)?oe:Date.now();return}r.value=0}function I(W=null){return W?{...W}:xp()}function X(W,oe=null){if(!(oe!=null&&oe.runId)||W.eventsLoaded||!oe.eventsLoaded)return Y.has(W.runId)&&(W.eventsLoading=!0),W;const ce=Math.max(Math.max(0,Number(oe.lastEventSeq)||0),Math.max(0,Number(oe.eventCount)||0),Array.isArray(oe.events)?oe.events.length:0),$e=Math.max(0,Number(W.eventCount)||0);return ce<$e?(Y.has(W.runId)&&(W.eventsLoading=!0),W):(W.events=Array.isArray(oe.events)?[...oe.events]:[],W.eventCount=Math.max(Math.max(0,Number(W.eventCount)||0),Math.max(0,Number(oe.eventCount)||0),W.events.length),W.eventsLoaded=!0,W.eventsLoading=Y.has(W.runId),W.lastEventSeq=Math.max(0,Number(oe.lastEventSeq)||0),W.summary=I(oe.summary),W)}function $(W,oe){const ce=Co(n.value,W);return ce?(ce.eventsLoading=!!oe,n.value=[...n.value],ce):null}async function Te(W,oe={}){const ce=String((W==null?void 0:W.runId)||"").trim(),{force:$e=!1}=oe;if(!ce)return[];const he=Co(n.value,ce)||W;if(he!=null&&he.eventsLoaded&&!$e)return he.events;if(Y.has(ce))return Y.get(ce);$(ce,!0);const Le=(async()=>{var pe;try{const De=ds(he,!!(p!=null&&p.value)),ze=await go.listCodexRunEvents(ce,{limit:5e3}),Ie=rp(n.value,ce,ze,me,Ke=>{v(Ke,{preserveRunning:!0})});if(!Ie)return Array.isArray(he==null?void 0:he.events)?he.events:[];const mt=JSON.stringify(De)!==JSON.stringify(ds(Ie,!!(p!=null&&p.value)));return n.value=[...n.value],mt&&t.active&&((pe=n.value.at(-1))==null?void 0:pe.runId)===ce&&k(),Ie.events}catch(De){throw u.value=De.message,De}finally{$(ce,!1),Y.delete(ce)}})();return Y.set(ce,Le),Le}function Me(W,oe){const ce=String(W||"").trim();if(!ce||!oe)return!1;const $e=n.value.findIndex(ze=>ze.runId===ce);if($e<0)return!1;const he=n.value[$e],Le=ds(he,!!(p!=null&&p.value));if(!qo(he,oe,me,ze=>{v(ze,{preserveRunning:!0})}))return!0;const De=JSON.stringify(Le)!==JSON.stringify(ds(he,!!(p!=null&&p.value)));return n.value=[...n.value],ge(),De&&k(),!0}function Re(){if(D(),ee(),!(!t.active||!s.value||!t.taskSlug)){if(m){j=window.setInterval(()=>{Ve({force:!0}).catch(()=>{});const W=Date.now();W-A<pr||(A=W,g({force:!0}).catch(()=>{}))},Sp);return}K=window.setInterval(()=>{Ve({force:!0}).catch(()=>{});const W=Date.now();W-A<pr||(A=W,g({force:!0}).catch(()=>{}))},yp)}}function Ne(W=[]){const oe=[...o.value],ce=new Map(n.value.filter(he=>String((he==null?void 0:he.runId)||"").trim()).map(he=>[String(he.runId||"").trim(),he])),$e=he=>{if(!(he!=null&&he.id))return;const Le=oe.findIndex(pe=>pe.id===he.id);Le>=0?oe[Le]=C(oe[Le],he,{preserveRunning:!0}):oe.unshift(C(null,he,{preserveRunning:!0}))};P=0,Z=0,n.value=[...W||[]].reverse().map(he=>{const Le=fr(he,fe,me,$e);return X(Le,ce.get(String((he==null?void 0:he.id)||"").trim())||null)}),o.value=oe,ge()}async function Ve(W={}){const{force:oe=!1,scrollToLatest:ce=!1}=W,$e=String(t.taskSlug||"").trim();if(!(!$e||!t.active&&!oe))return S&&B===$e||S&&!oe||(B=$e,S=(async()=>{try{const Le=(await go.listTaskCodexRuns($e,{limit:30,events:"latest"})).items||[],pe=!!(p!=null&&p.value),De=wp(Le,pe),ze=ce||R&&te===pe&&De!==R;Ne(Le),R=De,te=pe,Re();const Ie=n.value.at(-1)||null;if(Ie!=null&&Ie.runId&&!Ie.eventsLoaded){const mt=Ie.runId;Te(Ie).catch(()=>{}).finally(()=>{var Ke;ce&&t.active&&((Ke=n.value.at(-1))==null?void 0:Ke.runId)===mt&&k({force:!0})})}ze&&k({force:ce})}catch(he){u.value=he.message}finally{S=null,B=""}})()),S}function We(W={}){const oe=(W==null?void 0:W.run)||null,ce=(W==null?void 0:W.session)||null;if(ce&&v(ce,{preserveRunning:!0}),!(oe!=null&&oe.id)){ge(),k({force:!0});return}const he=fr(oe,fe,me,pe=>{v(pe,{preserveRunning:!0})}),Le=n.value.findIndex(pe=>pe.runId===he.runId);if(Le>=0){const pe=[...n.value];pe.splice(Le,1,he),n.value=pe}else n.value=[...n.value,he];ge(),k({force:!0})}async function ke(){if(!(!t.taskSlug||s.value))try{await go.clearTaskCodexRuns(t.taskSlug),Q(),k({force:!0})}catch(W){u.value=W.message}}return{applyCreatedRun:We,applyIncomingRunEvent:Me,clearRealtimeReconcileTimer:ee,clearRunPollTimer:D,clearTurns:ke,loadTurnEvents:Te,markFallbackSessionPollNow:ae,refreshRunHistory:Ve,resetRunHistoryState:Q,syncRunningStateFromTurns:ge,updatePollingState:Re}}const kp=1500,Tp=3e4;function _p(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:u,sessionError:m,showManager:k,selectedSessionId:c,currentRunningRunId:C,supportsServerEvents:v,mergeSession:g,applyCreatedRun:p,refreshRunHistory:P,markFallbackSessionPollNow:Z,showToast:S,getActiveAgentBinding:B=null}=e;let K=null,j=null,R=0,te=0;const A=G(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),Y=G(()=>n.value.length>0),fe=G(()=>or(n.value,c.value)),me=G(()=>Y.value?"":Ge("projectManager.noProjects"));async function D(ke={}){const{force:W=!1}=ke;if(K)return K;const oe=Date.now();return!W&&R&&oe-R<kp?{items:n.value,workspaces:o.value}:(K=(async()=>{s.value=!0,m.value="";try{const $e=(await al()).items||[];return n.value=$e,R=Date.now(),{items:$e,workspaces:o.value}}catch(ce){throw m.value=ce.message,ce}finally{s.value=!1,K=null}})(),K)}async function ee(ke={}){const{force:W=!1}=ke;if(j)return j;const oe=Date.now();return!W&&te&&oe-te<Tp?{items:o.value}:(j=(async()=>{try{const ce=await il();return o.value=ce.items||[],te=Date.now(),{items:o.value}}finally{j=null}})(),j)}async function ae(ke={}){const{forceSessions:W=!1,forceWorkspaces:oe=!1}=ke,[ce,$e]=await Promise.all([D({force:W}),ee({force:oe})]);return{items:(ce==null?void 0:ce.items)||n.value,workspaces:($e==null?void 0:$e.items)||o.value}}function Q(ke=""){const W=String(ke||"").trim();!W||o.value.includes(W)||(o.value=[W,...o.value])}function ge(){k.value=!0,ee().catch(()=>{})}function I(){k.value=!1}function X(ke){const W=String(ke||"").trim();if(t.sessionSelectionLocked&&W&&W!==c.value){m.value=t.sessionSelectionLockReason||Ge("taskActions.sessionLocked");return}c.value=W}function $(){ae({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function Te(ke){r.value=!0,m.value="";try{const W=await ll(ke);return g(W),Q(W.cwd),c.value=W.id,W}catch(W){throw m.value=W.message,W}finally{r.value=!1}}async function Me(ke,W){r.value=!0,m.value="";try{const oe=await ul(ke,W);return g(oe),Q(oe.cwd),oe}catch(oe){throw m.value=oe.message,oe}finally{r.value=!1}}async function Re(ke){var oe;const W=String(ke||"").trim();if(!W)return{deletedSessionId:"",selectedSessionId:c.value};r.value=!0,m.value="";try{await cl(W);const ce=n.value.filter(he=>he.id!==W);n.value=ce;let $e=c.value;return c.value===W&&($e=((oe=or(ce,"")[0])==null?void 0:oe.id)||"",c.value=$e),{deletedSessionId:W,selectedSessionId:$e}}catch(ce){throw m.value=ce.message,ce}finally{r.value=!1}}async function Ne(ke){const W=String(ke||"").trim();if(!W)return null;r.value=!0,m.value="";try{const oe=await dl(W);return oe!=null&&oe.session&&g(oe.session),Z(),await Promise.all([P({force:!0}),D({force:!0})]),S==null||S({message:Ge("projectManager.sessionReset"),type:"success"}),oe}catch(oe){throw m.value=oe.message,oe}finally{r.value=!1}}async function Ve(){if(!t.taskSlug||!A.value||l.value||u.value)return!1;if(!c.value){const ke=Ge("projectManager.selectProject");return m.value=ke,S==null||S({message:ke,type:"warning"}),!1}m.value="";try{await ae({forceSessions:!0});const ke=n.value.find(Ie=>Ie.id===c.value)||null;if(!ke)return m.value=Ge("projectManager.projectMissing"),!1;if(ke.running)return m.value=Ge("sessionTurns.currentProjectRunning"),!1;const W=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,oe=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],ce=hi({prompt:W,promptBlocks:oe});if(ce.reason){const Ie=ce.reason==="unsupported_blocks"?Ge("sessionPanel.shellUnsupportedBlocks"):Ge("sessionPanel.shellEmptyCommand");return m.value=Ie,S==null||S({message:Ie,type:"warning"}),!1}if(!String(W||"").trim())return m.value=Ge("sessionTurns.noPromptToSend"),!1;const $e=Cp(ke),he=typeof B=="function"?B(ke):null,Le=String((he==null?void 0:he.engine)||"").trim();if(Le&&!$e.some(Ie=>Ie.engine===Le)){const Ie=Ge("sessionPanel.agentNotEnabled");return m.value=Ie,S==null||S({message:Ie,type:"warning"}),!1}const pe=he,De=String(ce.mode==="shell"?c.value:(pe==null?void 0:pe.sessionRecordId)||c.value).trim(),ze=await Sl(t.taskSlug,{projectSessionId:c.value,sessionId:De,displayEngine:Le,prompt:ce.mode==="shell"?ce.prompt:W,promptBlocks:oe,commandMode:ce.mode,command:ce.command});return p(ze),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Ie=>{console.error("[promptx] afterSend failed",Ie)}),v||(Z(),Promise.all([P({force:!0}),D({force:!0})]).catch(Ie=>{m.value=Ie.message})),!0}catch(ke){return m.value=ke.message,!1}}async function We(){if(!(!C.value||u.value))try{u.value=!0,await xl(C.value),v||(Z(),await Promise.all([P({force:!0}),D({force:!0})]))}catch(ke){u.value=!1,m.value=ke.message}}return{closeManager:I,handleCreateSession:Te,handleDeleteSession:Re,handleResetSession:Ne,handleSelectSession:X,handleSend:Ve,handleUpdateSession:Me,hasPrompt:A,helperText:me,loadSessions:D,loadSessionResources:ae,loadWorkspaces:ee,openManager:ge,refreshSessionsForSelection:$,sortedSessions:fe,stopSending:We}}function Cp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:Ep(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function Ep(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 Ap=1200,Ip=[0,80,220,500,900];function $p(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,u=!1,m=0,k=!0,c=0,C=[],v=0,g=null;function p(){const $=typeof window<"u"?window:globalThis;return typeof($==null?void 0:$.setTimeout)!="function"||typeof($==null?void 0:$.clearTimeout)!="function"?null:{setTimeout:$.setTimeout.bind($),clearTimeout:$.clearTimeout.bind($)}}function P(){if(typeof window>"u"||!r.length){r=[];return}r.forEach($=>{window.cancelAnimationFrame($)}),r=[]}function Z(){s+=1,P()}function S(){const $=p();if(!$){C=[],v=0;return}C.forEach(Te=>{$.clearTimeout(Te)}),C=[],v&&($.clearTimeout(v),v=0)}function B(){var $;($=g==null?void 0:g.disconnect)==null||$.call(g),g=null}function K(){return c>Date.now()}function j($){u=!!$,(n==null?void 0:n.value)!==void 0&&(n.value=u)}function R(){l=!1,m+=1,k=!0,j(!1)}function te($=t==null?void 0:t.value){return $?$.scrollHeight-$.scrollTop-$.clientHeight<=o:!0}function A(){return K()||k&&!l}function Y(){k&&!l&&j(!1)}function fe(){if(k=te(),!k){Z();return}Y()}function me(){m+=1,l=!0,c=0,S(),B(),Z()}function D(){const $=m+1;m=$,at(()=>{$===m&&requestAnimationFrame(()=>{$===m&&(l=!1,k=te(),Y())})})}function ee(){l=!0,c=0,S(),B(),Z()}function ae(){D()}function Q($={}){const{force:Te=!1}=$;Te&&R(),Z();const Me=s;at(()=>{if(!(t==null?void 0:t.value)||Me!==s)return;if(!Te&&!A()){j(!0);return}const Ne=()=>{const We=t==null?void 0:t.value;!We||Me!==s||(We.scrollTop=We.scrollHeight,k=!0,j(!1))};Ne(),r=[requestAnimationFrame(()=>{Ne(),r=[requestAnimationFrame(Ne)]})]})}function ge(){Q({force:!0})}function I($={}){const Te=Number($.durationMs),Me=Math.max(0,Number.isFinite(Te)?Te:Ap),Re=p();R(),c=Date.now()+Me,S(),B(),Re&&(C=Ip.map(Ne=>Re.setTimeout(()=>{K()&&Q({force:!0})},Ne)),v=Re.setTimeout(()=>{c=0,v=0,S(),B()},Me+40)),typeof window<"u"&&typeof window.ResizeObserver=="function"&&(g=new window.ResizeObserver(()=>{K()&&Q({force:!0})}),t!=null&&t.value&&g.observe(t.value)),Q({force:!0})}function X(){m+=1,c=0,S(),B(),Z()}return{cancelScheduledScrollToBottom:Z,destroy:X,handleTranscriptScroll:fe,handleTranscriptTouchEnd:ae,handleTranscriptTouchMove:ee,handleTranscriptTouchStart:me,beginForceFollowWindow:I,isTranscriptNearBottom:te,resetAutoStickToBottom:R,scheduleScrollToBottom:Q,scrollToBottom:ge}}const Pp=150,Ta="promptx:session-panel:show-process";function Dp(e){return!(e==="0"||e==="false")}function Lp(){if(typeof window>"u")return!0;try{return Dp(window.localStorage.getItem(Ta))}catch{return!0}}function Mp(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 Bp(e,t){const n=fa(),o=z([]),s=z([]),r=z(!1),l=z(!1),u=z(!1),m=z(!1),k=z(""),c=z([]),C=z(null),v=z(0),g=z(0),p=z(!1),P=z(""),Z=z(!1),S=z(Lp()),B=typeof window<"u"&&typeof window.EventSource<"u";function K(se=""){const Be=typeof se=="object"&&se!==null?String(se.message||"").trim():String(se||"").trim();Be&&t("toast",typeof se=="object"&&se!==null?{...se,message:Be}:Be)}let j=null,R=null,te=null,A={sessions:!1,runs:!1};const Y=G({get(){return String(e.selectedSessionId||"").trim()},set(se){t("selected-session-change",String(se||"").trim())}}),fe=G(()=>m.value?Ge("sessionPanel.stopping"):`${Ge("projectManager.running")} (${ha(g.value)})`),me=G(()=>o.value.find(se=>se.id===Y.value)||null),D=G(()=>{var Be;if(Array.isArray((Be=me.value)==null?void 0:Be.agentBindings)&&me.value.agentBindings.length)return me.value.agentBindings;const se=me.value;return se!=null&&se.id?[{engine:se.engine,sessionRecordId:se.id,sessionId:se.sessionId||"",started:!!se.started,running:!!se.running,isDefault:!0}]:[]}),ee=G({get(){var Be,st;const se=ho(e.selectedAgentEngine,D.value);return se||((Be=D.value.find(Xe=>Xe.isDefault))==null?void 0:Be.engine)||((st=D.value[0])==null?void 0:st.engine)||""},set(se){const Be=ho(se,D.value);Be&&t("update:selectedAgentEngine",Be)}}),ae=G(()=>D.value.find(se=>se.engine===ee.value)||D.value[0]||null),{beginForceFollowWindow:Q,destroy:ge,handleTranscriptScroll:I,handleTranscriptTouchEnd:X,handleTranscriptTouchMove:$,handleTranscriptTouchStart:Te,resetAutoStickToBottom:Me,scheduleScrollToBottom:Re,scrollToBottom:Ne}=$p({transcriptRef:C,hasNewerMessages:Z});function Ve(se,Be,st={}){return Mp(se,Be,st)}function We(se,Be={}){if(!(se!=null&&se.id))return;const st=[...o.value],Xe=st.findIndex(Dt=>Dt.id===se.id);Xe>=0?st[Xe]=Ve(st[Xe],se,Be):st.unshift(Ve(null,se,Be)),o.value=st}const{applyCreatedRun:ke,applyIncomingRunEvent:W,clearRealtimeReconcileTimer:oe,clearRunPollTimer:ce,clearTurns:$e,loadTurnEvents:he,markFallbackSessionPollNow:Le,refreshRunHistory:pe,resetRunHistoryState:De,updatePollingState:ze}=bp({props:e,turns:c,sessions:o,sending:u,sendingStartedAt:v,currentRunningRunId:P,sessionError:k,supportsServerEvents:B,scheduleScrollToBottom:Re,resetAutoStickToBottom:Me,showProcessLogs:S,mergeSessionRecord:Ve,mergeSession:We,loadSessions:(...se)=>ct(...se)}),{closeManager:Ie,handleCreateSession:mt,handleDeleteSession:Ke,handleResetSession:it,handleSelectSession:gt,handleSend:ht,handleUpdateSession:Oe,helperText:_e,loadSessions:ct,loadSessionResources:lt,loadWorkspaces:L,openManager:N,refreshSessionsForSelection:ne,sortedSessions:xe,stopSending:Fe}=_p({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:u,stopping:m,sessionError:k,showManager:p,selectedSessionId:Y,currentRunningRunId:P,supportsServerEvents:B,mergeSession:We,applyCreatedRun:ke,refreshRunHistory:pe,markFallbackSessionPollNow:Le,showToast:K,getActiveAgentBinding:()=>ae.value});function Pe(){j&&(window.clearInterval(j),j=null)}function Ye(){Pe(),v.value||(v.value=Date.now()),g.value=Math.max(0,Math.floor((Date.now()-v.value)/1e3)),j=window.setInterval(()=>{g.value=Math.max(0,Math.floor((Date.now()-v.value)/1e3))},1e3)}function tt(){te&&(window.clearTimeout(te),te=null)}function bt(){tt();const se=A;A={sessions:!1,runs:!1},se.sessions&&ct({force:!0}).catch(()=>{}),se.runs&&pe({force:!0}).catch(()=>{})}function ft(se={}){typeof window>"u"||(A={sessions:A.sessions||!!se.sessions,runs:A.runs||!!se.runs},!(te||!A.sessions&&!A.runs)&&(te=window.setTimeout(()=>{bt()},Pp)))}function kt(se){return wa(se,{currentRunningRunId:P.value,runningElapsedSeconds:g.value,nowMs:Date.now()})}function vt(se=""){if(!se)return"";const Be=new Date(se);return Number.isNaN(Be.getTime())?"":Be.toLocaleTimeString(Xs(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function At(se){return se.status==="error"||se.status==="stop_timeout"?"theme-process-error":se.status==="interrupted"||se.status==="stopped"?"theme-process-stopped":se.status==="completed"?"theme-process-completed":"theme-process-running"}function Gt(){S.value=!S.value}function Kt(se){return!!(se.responseMessage||se.errorMessage||se.status==="completed")}return Ae(S,se=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ta,se?"true":"false")}catch{}},{immediate:!0}),Ae(u,se=>{se?(v.value||(v.value=Date.now()),Ye()):(Pe(),v.value=0,g.value=0,m.value=!1),ze(),t("sending-change",se)},{immediate:!0}),Ae(g,(se,Be)=>{e.active&&Be===0&&se>0&&Re()}),Ae(()=>!!e.taskRunning,se=>{!e.active||se||!u.value||ft({sessions:!0,runs:!0})}),Ae(()=>e.active,se=>{if(se){lt({forceSessions:!0}).catch(()=>{});return}tt(),oe(),ce()},{immediate:!0}),Ae(()=>e.taskSlug,()=>{De(),p.value=!1,k.value="",e.active&&(Q(),pe({force:!0,scrollToLatest:!0}).catch(()=>{}))},{immediate:!0}),Ae(()=>{var se;return[((se=me.value)==null?void 0:se.id)||"",D.value.map(Be=>Be.engine).join(","),e.selectedAgentEngine||""].join(`
39
+ `)},()=>{var H,J,ue;const se=String(((H=me.value)==null?void 0:H.id)||"").trim(),Be=D.value,st=ee.value;if(t("agent-bindings-change",{sessionId:se,bindings:Be,selectedEngine:st}),!se||ho(e.selectedAgentEngine,Be))return;const Dt=((J=Be.find(ve=>ve.isDefault))==null?void 0:J.engine)||((ue=Be[0])==null?void 0:ue.engine)||"";Dt&&t("update:selectedAgentEngine",Dt)},{immediate:!0}),Rt(()=>{Pe(),oe(),ce(),tt(),ge(),R==null||R()}),Ae(()=>n.readyVersion.value,()=>{const se=String(e.taskSlug||"").trim();!e.active&&!p.value||(p.value&&L().catch(()=>{}),ft({sessions:!0,runs:!!se}))}),Ae(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!p.value||ft({sessions:!0})}),Ae(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||ft({sessions:!0,runs:!0})}),Ae(()=>String(e.taskSlug||"").trim(),se=>{R==null||R(),R=null,se&&(R=Uf(se,({runId:Be,event:st})=>{if(!e.active)return;W(Be,st)||ft({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:ae,activeAgentEngine:ee,clearTurns:$e,closeManager:Ie,formatTurnTime:vt,getProcessCardClass:At,getProcessStatus:fp,getTurnAgentLabel:Ot,getTurnSummaryDetail:ba,getDisplayTurnSummaryItems:kt,getTurnSummaryStatus:xa,handleCreateSession:mt,handleDeleteSession:Ke,handleResetSession:it,handleSelectSession:gt,handleSend:ht,handleUpdateSession:Oe,loadTurnEvents:he,hasTurnSummary:up,helperText:_e,loading:r,managerBusy:l,openManager:N,refreshSessionsForSelection:ne,selectedSessionId:Y,sending:u,showProcessLogs:S,stopping:m,sessionError:k,shouldShowResponse:Kt,showManager:p,sortedSessions:xe,stopSending:Fe,toggleProcessLogs:Gt,hasNewerMessages:Z,transcriptRef:C,turns:c,workspaces:s,workingLabel:fe,sessions:o,loadSessions:ct,currentProjectAgentBindings:D,handleTranscriptScroll:I,handleTranscriptTouchEnd:X,handleTranscriptTouchMove:$,handleTranscriptTouchStart:Te,scheduleScrollToBottom:Re,scrollToBottom:Ne}}function ho(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const Rp=8,Np=320,Op=10,Fp=400;function mr(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function Up(e={}){const{turns:t,loadTurnEvents:n}=e,o=z({}),s=z({}),r=z({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function u(A){const Y=l(A);return!!Y&&Y===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!gs(A==null?void 0:A.status)&&!u(A)&&m(A)>3}function c(A){return mr(A==null?void 0:A.prompt,Rp,Np)}function C(A){return!gs(A==null?void 0:A.status)&&!u(A)&&c(A)}function v(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function g(A){return mr(v(A),Op,Fp)}function p(A){return!(A!=null&&A.errorMessage)&&!u(A)&&g(A)}function P(A){return m(A)>0}function Z(A=[]){const Y=new Set((A||[]).map(D=>l(D)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([D])=>Y.has(D))),s.value=Object.fromEntries(Object.entries(s.value).filter(([D])=>Y.has(D))),r.value=Object.fromEntries(Object.entries(r.value).filter(([D])=>Y.has(D)));const fe=(A||[]).at(-1)||null,me=l(fe);me&&(Object.prototype.hasOwnProperty.call(o.value,me)||(o.value={...o.value,[me]:!1}),Object.prototype.hasOwnProperty.call(s.value,me)||(s.value={...s.value,[me]:!1}),Object.prototype.hasOwnProperty.call(r.value,me)||(r.value={...r.value,[me]:!1}))}function S(A){const Y=l(A);return Y?Object.prototype.hasOwnProperty.call(o.value,Y)?!!o.value[Y]:k(A):!1}async function B(A){const Y=l(A);if(!Y)return;const fe=!S(A);o.value={...o.value,[Y]:fe},!fe&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function K(A){const Y=l(A);return Y?Object.prototype.hasOwnProperty.call(s.value,Y)?!!s.value[Y]:C(A):!1}function j(A){const Y=l(A);!Y||!c(A)||(s.value={...s.value,[Y]:!K(A)})}function R(A){const Y=l(A);return Y?Object.prototype.hasOwnProperty.call(r.value,Y)?!!r.value[Y]:p(A):!1}function te(A){const Y=l(A);!Y||!g(A)||(r.value={...r.value,[Y]:!R(A)})}return Ae(t,A=>{Z(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:m,hasTurnEventHistory:P,isLatestTurn:u,isPromptCollapsed:K,isResponseCollapsed:R,isTurnEventsCollapsed:S,togglePrompt:j,toggleResponse:te,toggleTurnEvents:B}}function jp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Vp(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 zp(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function vo(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 yo(e="",t=[],n=[]){var l;const o=jp(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=Vp([{label:"类型",value:zp(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 _a(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:vo(n,e.length),detail:"",detailBlocks:yo(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:vo(n,e.length),detail:"",detailBlocks:yo(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:vo(n,o.length),detail:"",detailBlocks:yo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Hp(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]=_a(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 qp(e=[]){var o;const t=Hp(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(..._a(u))}return n}const Kp={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Wp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Gp={class:"flex flex-col gap-2"},Xp={class:"flex items-center gap-2"},Yp=["title"],Jp={class:"flex shrink-0 items-center gap-1.5"},Qp=["aria-pressed","aria-label","title"],Zp=["disabled"],em={class:"hidden sm:inline"},tm=["disabled"],nm={class:"hidden sm:inline"},sm=["aria-label"],om=["aria-pressed"],rm=["aria-pressed","title","onClick"],am={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},im={class:"min-h-0 flex-1"},lm={key:0,class:"theme-empty-state px-4 py-6 text-sm"},um={key:1,class:"theme-empty-state px-4 py-6 text-sm"},cm=["data-turn-id","data-run-id"],dm={class:"flex justify-end"},fm={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)]"},pm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},mm={class:"font-semibold"},gm={class:"flex items-center gap-2"},hm=["onClick"],vm={class:"relative mt-2"},ym={key:0,class:"space-y-3"},Sm={key:0,class:"whitespace-pre-wrap break-words leading-7"},wm=["onClick"],xm=["src","alt"],bm={key:1,class:"whitespace-pre-wrap break-words leading-7"},km={key:0,class:"flex min-w-0 justify-start"},Tm={class:"flex items-center justify-between gap-3 text-xs"},_m={class:"font-semibold"},Cm={class:"flex items-center gap-2"},Em=["disabled","onClick"],Am={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Im={key:1,class:"mt-2 min-w-0 space-y-2"},$m={class:"text-sm font-medium leading-6"},Pm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Dm={key:3,class:"mt-2 text-xs text-current"},Lm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Mm={key:0,class:"leading-5"},Bm={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},Rm={key:2,class:"mt-2 flex flex-wrap gap-2"},Nm={class:"font-medium"},Om={key:1,class:"flex justify-start"},Fm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Um={class:"font-semibold"},jm={class:"flex items-center gap-2"},Vm=["onClick"],zm=["onClick"],Hm={class:"relative mt-2"},qm={key:0,class:"whitespace-pre-wrap break-words"},Km=["innerHTML"],Wm={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"},Gm=["disabled"],Xm={key:2,class:"task-loading-dots","aria-hidden":"true"},gr="promptx:selected-agent-filter-map",Ym={__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=xo(()=>qe(()=>import("./CodexSessionManagerDialog-y7O-JTxP.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:c,getDisplayTurnSummaryItems:C,getTurnSummaryDetail:v,getTurnSummaryStatus:g,handleCreateSession:p,handleDeleteSession:P,handleResetSession:Z,handleSelectSession:S,handleSend:B,handleTranscriptScroll:K,handleTranscriptTouchEnd:j,handleTranscriptTouchMove:R,handleTranscriptTouchStart:te,handleUpdateSession:A,helperText:Y,loadTurnEvents:fe,loading:me,managerBusy:D,openManager:ee,refreshSessionsForSelection:ae,selectedSessionId:Q,sending:ge,showProcessLogs:I,stopping:X,hasTurnSummary:$,hasNewerMessages:Te,sessionError:Me,shouldShowResponse:Re,showManager:Ne,sortedSessions:Ve,stopSending:We,toggleProcessLogs:ke,transcriptRef:W,turns:oe,workspaces:ce,sessions:$e,loadSessions:he,currentProjectAgentBindings:Le,scheduleScrollToBottom:pe,scrollToBottom:De}=Bp(r,s),ze=z(null),Ie=z(!1),mt=z(""),Ke=z(""),it=z("");function gt(){try{const f=JSON.parse(window.localStorage.getItem(gr)||"{}");if(f&&typeof f=="object"&&!Array.isArray(f))return f}catch{}return{}}function ht(f){window.localStorage.setItem(gr,JSON.stringify(f))}const Oe=z("all");Ae(Oe,f=>{const x=String(r.taskSlug||"").trim();if(!x)return;const w=gt();w[x]=f,ht(w)});const{t:_e}=Et(),{isDark:ct}=Dr(),lt=G(()=>ct.value?"dark":"light"),L=G(()=>{const f=new Set;return(Array.isArray(Le.value)?Le.value:[]).filter(x=>{const w=String((x==null?void 0:x.engine)||"").trim();return!w||f.has(w)?!1:(f.add(w),!0)})}),N=G(()=>L.value.length>1),ne=G(()=>{const f=String(Oe.value||"").trim();return!N.value||f==="all"?oe.value:oe.value.filter(x=>Sa(x)===f)}),{selectionAction:xe,clearSelectionState:Fe,handleSelectionMouseUp:Pe}=oa({getContainer:()=>W.value,isActive:()=>!!(r.active&&oe.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:f=>[...f.querySelectorAll("[data-response-selection-root]")],getCodeLeft:f=>{var x,w;return((w=(x=f==null?void 0:f.getBoundingClientRect)==null?void 0:x.call(f))==null?void 0:w.left)||0},debounceMs:72});Ae([Oe,()=>L.value.map(f=>f.engine).join(`
40
+ `)],()=>{Oe.value!=="all"&&L.value.length&&(L.value.some(f=>f.engine===Oe.value)||(Oe.value="all"))},{immediate:!0}),Ae(Oe,()=>{Fe({clearBrowserSelection:!0}),pe({force:!0})}),Ae(()=>r.taskSlug,(f,x)=>{if(!String(f||"").trim()||f===x)return;const ie=gt()[f];Oe.value=ie||"all"},{immediate:!0});function Ye(f={}){const x=String((f==null?void 0:f.title)||"").trim();return x?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/ 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(w=>w.test(x)):!1}function tt(f={}){return _e("sessionPanel.promptTitleWithAgent",{agent:c(f)})}function bt(f={}){return f.errorMessage?_e("sessionPanel.errorSuffix",{agent:c(f)}):_e("sessionPanel.responseSuffix",{agent:c(f)})}const{getTurnEventCount:ft,hasTurnEventHistory:kt,isTurnEventsCollapsed:vt,toggleTurnEvents:At}=Up({turns:oe,loadTurnEvents:fe});function Gt(f){return String((f==null?void 0:f.runId)||(f==null?void 0:f.id)||"").trim()}function Kt(f){f!=null&&f.runId&&s("open-diff",{scope:"run",runId:f.runId})}function se(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Be}=Ef({items:oe,themeKey:lt,getCacheKey:Gt,getSource:f=>String((f==null?void 0:f.responseMessage)||""),shouldRender:f=>!!(f!=null&&f.responseMessage)&&!(f!=null&&f.errorMessage),renderAsync:f=>wc(f,{isDark:ct.value,copyLabel:_e("sessionPanel.copyCode"),copyAriaLabel:_e("sessionPanel.copyCodeAria")}),renderFallback:f=>ta(f),onRendered:f=>{const x=oe.value.at(-1)||null;!r.active||!(x!=null&&x.runId)||x.runId!==(f==null?void 0:f.runId)||pe()}});function st(f){it.value=String(f||"").trim()}async function Xe(f){var w;if((w=navigator.clipboard)!=null&&w.writeText&&window.isSecureContext){await navigator.clipboard.writeText(f);return}const x=document.createElement("textarea");x.value=f,x.setAttribute("readonly","true"),x.style.position="fixed",x.style.opacity="0",x.style.pointerEvents="none",document.body.appendChild(x),x.select(),document.execCommand("copy"),document.body.removeChild(x)}function Dt(f={}){const w=(Array.isArray(f==null?void 0:f.promptBlocks)?f.promptBlocks:[]).filter(ie=>(ie==null?void 0:ie.type)==="text"||(ie==null?void 0:ie.type)==="imported_text").map(ie=>String((ie==null?void 0:ie.content)||"").replace(/\u200b/g,"").trim()).filter(Boolean).join(`
41
+
42
+ `);return w||String((f==null?void 0:f.prompt)||"").replace(/\u200b/g,"").trim()}function H(f={}){const x=Dt(f);x&&s("insert-code-context",{source:"response",content:x})}async function J(f){var $t,Vt,nn,un,St;const x=(Vt=($t=f==null?void 0:f.target)==null?void 0:$t.closest)==null?void 0:Vt.call($t,'[data-copy-code="1"]');if(!x)return!1;const w=x.closest(".codex-code-block"),ie=(nn=w==null?void 0:w.querySelector)==null?void 0:nn.call(w,"pre code"),Ce=String((ie==null?void 0:ie.textContent)||"").replace(/\u200b/g,"");if(!Ce)return!1;(un=f.preventDefault)==null||un.call(f),(St=f.stopPropagation)==null||St.call(f);try{return await Xe(Ce),s("toast",{message:_e("sessionPanel.codeCopied"),type:"success"}),!0}catch{return s("toast",{message:_e("errors.requestFailed"),type:"warning"}),!0}}function ue(f=""){return String(f||"").trim().split(/[?#]/)[0].replace(/:(\d+)(?::\d+)?$/,"")}function ve(f=""){const x=String(f||"").trim();try{return decodeURI(x)}catch{return x}}function Ue(f=""){return ve(f).replace(/\\/g,"/").replace(/\/+/g,"/").trim()}function pt(f=""){const x=Ue(f).replace(/^\.\//,"").split("/").filter(Boolean);return!x.length||x.some(w=>w==="."||w==="..")?"":x.join("/")}function Ft(f=""){const x=String(f||"").trim();if(!x||x.startsWith("#")||x.startsWith("//"))return"";if(/^(?:https?:|mailto:|tel:|data:|blob:|javascript:)/i.test(x))try{const w=new URL(x);return w.origin!==window.location.origin?"":ue(w.pathname)}catch{return""}return ue(x)}function Ut(f=""){const x=Yt(),w=Ue((x==null?void 0:x.cwd)||"").replace(/\/$/,""),ie=Ue(Ft(f));return!w||!ie?"":ie.startsWith("/")?ie===w||!ie.startsWith(`${w}/`)?"":pt(ie.slice(w.length+1)):pt(ie)}function It(f){var ie,Ce,$t,Vt;const x=(Ce=(ie=f==null?void 0:f.target)==null?void 0:ie.closest)==null?void 0:Ce.call(ie,".codex-markdown a[href]");if(!x)return!1;const w=Ut(x.getAttribute("href")||"");return w?(($t=f.preventDefault)==null||$t.call(f),(Vt=f.stopPropagation)==null||Vt.call(f),E(null,{searchQuery:w})||s("toast",{message:_e("sourceBrowser.noProject"),type:"warning"}),!0):!1}function Lt(f){It(f)||J(f)}function mn(){if(!xe.value.visible)return;const f=String(xe.value.content||"").replace(/\u200b/g,"").trim();if(!f){Fe({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:f}),Fe({clearBrowserSelection:!0})}function Tt(f={}){if(f!=null&&f.errorMessage)return;const x=String((f==null?void 0:f.responseMessage)||"").replace(/\u200b/g,"").trim();x&&s("insert-code-context",{source:"response",content:x})}const tn=G(()=>oe.value.flatMap(f=>(Array.isArray(f==null?void 0:f.promptBlocks)?f.promptBlocks:[]).filter(x=>(x==null?void 0:x.type)==="image").map(x=>x.content)));function gn(f){const w=(Array.isArray(f==null?void 0:f.events)?f.events:[]).filter(ie=>!Ye(ie));return qp(w)}function Mt(f){return ft(f)}function Xt(f){return f!=null&&f.eventsLoaded?Mt(f)>0:kt(f)}function _t(f){return!!(f!=null&&f.eventsLoading)}function kn(f){return!!(f!=null&&f.eventsLoaded)&&gn(f).length>0&&!vt(f)}function on(f){return!!(f!=null&&f.eventsLoaded)&&Mt(f)>0&&vt(f)}function rn(f){return kt(f)&&!(f!=null&&f.eventsLoaded)&&!(f!=null&&f.eventsLoading)}function an(f={}){return qr(f,{defaultLabel:_e("sessionPanel.defaultAgent")})}function ln(f={}){return!ap(f)}function hn(f={}){return"bg-[var(--theme-appPanelStrong)]"}function Yt(f=null){const x=String((f==null?void 0:f.id)||"").trim();if(x)return $e.value.find(ie=>ie.id===x)||null;const w=String(Q.value||"").trim();return w?$e.value.find(ie=>ie.id===w)||null:Ve.value[0]||null}function E(f=null,x={}){const w=Yt(f);return w!=null&&w.cwd?(mt.value=w.id,Ke.value=String(x.searchQuery||"").trim(),Ie.value=!0,!0):!1}function b(){return D.value?!1:(ee(),!0)}function V(){var f,x;return Ie.value?(Ie.value=!1,!0):(x=(f=ze.value)==null?void 0:f.closeTopDialog)!=null&&x.call(f)?!0:Ne.value?(l(),!0):!1}return t({closeTopDialog:V,openProjectManager:b,openSourceBrowser:E,send:B,scrollToBottom:De,stop:We}),(f,x)=>(h(),_("section",Kp,[le(Cf,{open:Ie.value,session:a($e).find(w=>w.id===mt.value)||null,"initial-search-query":Ke.value,onInsertCodeContext:x[0]||(x[0]=w=>s("insert-code-context",w)),onClose:x[1]||(x[1]=w=>Ie.value=!1)},null,8,["open","session","initial-search-query"]),le(a(o),{ref_key:"managerDialogRef",ref:ze,open:a(Ne),sessions:a($e),workspaces:a(ce),"selected-session-id":a(Q),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(me),sending:a(ge),"on-refresh":a(he),"on-create":a(p),"on-update":a(A),"on-delete":a(P),"on-reset":a(Z),onClose:a(l),onOpenSourceBrowser:x[2]||(x[2]=w=>E(w)),onProjectCreated:x[3]||(x[3]=w=>s("project-created",w)),onSelectSession:a(S)},null,8,["open","sessions","workspaces","selected-session-id","selection-locked","selection-lock-reason","loading","sending","on-refresh","on-create","on-update","on-delete","on-reset","onClose","onSelectSession"]),i("div",Wp,[i("div",Gp,[i("div",Xp,[i("div",{class:"min-w-0 flex-1",title:a(Y)||""},[le(nc,{modelValue:a(Q),"onUpdate:modelValue":x[4]||(x[4]=w=>Na(Q)?Q.value=w:null),sessions:a(Ve),loading:a(me),disabled:a(ge)||a(D)||e.sessionSelectionLocked,onRefreshIntent:a(ae)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,Yp),i("div",Jp,[i("button",{type:"button",class:we(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(I)?"tool-button-accent-subtle":""]),"aria-pressed":a(I)?"true":"false","aria-label":a(I)?a(_e)("sessionPanel.hideProcessToggle"):a(_e)("sessionPanel.showProcessToggle"),title:a(I)?a(_e)("sessionPanel.hideProcessToggle"):a(_e)("sessionPanel.showProcessToggle"),onClick:x[5]||(x[5]=(...w)=>a(ke)&&a(ke)(...w))},[a(I)?(h(),Ee(a(qa),{key:0,class:"h-4 w-4"})):(h(),Ee(a(Ka),{key:1,class:"h-4 w-4"}))],10,Qp),e.diffSupported?(h(),_("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:se},[le(a(Go),{class:"h-4 w-4"}),x[17]||(x[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",em,T(a(_e)("sessionPanel.diff")),1)],8,Zp)):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(D),onClick:x[6]||(x[6]=(...w)=>a(ee)&&a(ee)(...w))},[le(a(fs),{class:"h-4 w-4"}),x[18]||(x[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",nm,T(a(_e)("sessionPanel.manageProjects")),1)],8,tm)])]),N.value?(h(),_("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(_e)("sessionPanel.agentFilter")},[i("button",{type:"button",class:we(["theme-agent-selector-button",Oe.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Oe.value==="all"?"true":"false",onClick:x[7]||(x[7]=w=>Oe.value="all")},T(a(_e)("sessionPanel.allAgents")),11,om),(h(!0),_(ot,null,ut(L.value,w=>(h(),_("button",{key:w.engine,type:"button",class:we(["theme-agent-selector-button",Oe.value===w.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Oe.value===w.engine?"true":"false",title:an(w),onClick:ie=>Oe.value=w.engine},T(an(w)),11,rm))),128))],8,sm)):de("",!0),a(Me)?(h(),_("p",am,[le(a(Do),{class:"h-4 w-4"}),i("span",null,T(a(Me)),1)])):de("",!0)])]),i("div",im,[i("div",{ref_key:"transcriptRef",ref:W,"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:x[9]||(x[9]=(...w)=>a(K)&&a(K)(...w)),onTouchstartPassive:x[10]||(x[10]=(...w)=>a(te)&&a(te)(...w)),onTouchmovePassive:x[11]||(x[11]=(...w)=>a(R)&&a(R)(...w)),onTouchendPassive:x[12]||(x[12]=(...w)=>a(j)&&a(j)(...w)),onTouchcancelPassive:x[13]||(x[13]=(...w)=>a(j)&&a(j)(...w))},[a(oe).length?ne.value.length?de("",!0):(h(),_("div",um,T(a(_e)("sessionPanel.emptyAgentFilter")),1)):(h(),_("div",lm,T(a(_e)("sessionPanel.empty")),1)),(h(!0),_(ot,null,ut(ne.value,w=>(h(),_("div",{key:w.id,"data-promptx-turn":"1","data-turn-id":w.id,"data-run-id":w.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",dm,[i("div",fm,[i("div",pm,[i("span",mm,T(tt(w)),1),i("div",gm,[Dt(w)?(h(),_("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:ie=>H(w)},[le(a(Us),{class:"h-3 w-3"}),i("span",null,T(a(_e)("sessionPanel.insert")),1)],8,hm)):de("",!0),i("span",null,T(a(u)(w.startedAt)),1)])]),i("div",vm,[Array.isArray(w.promptBlocks)&&w.promptBlocks.length?(h(),_("div",ym,[(h(!0),_(ot,null,ut(w.promptBlocks,(ie,Ce)=>(h(),_(ot,{key:`${w.id}-prompt-${Ce}`},[ie.type==="text"||ie.type==="imported_text"?(h(),_("pre",Sm,T(ie.content),1)):(h(),_("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:$t=>st(ie.content)},[i("img",{src:ie.content,alt:a(_e)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,xm)],8,wm))],64))),128))])):(h(),_("pre",bm,T(w.prompt),1))])])]),a(I)&&ln(w)?(h(),_("div",km,[i("div",{class:we(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(m)(w)])},[i("div",Tm,[i("span",_m,T(a(_e)("sessionPanel.processTitle")),1),i("div",Cm,[Xt(w)?(h(),_("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:w.eventsLoading,onClick:ie=>a(At)(w)},[_t(w)?(h(),Ee(a(Wt),{key:0,class:"h-3 w-3 animate-spin"})):a(vt)(w)?(h(),Ee(a(Po),{key:1,class:"h-3 w-3"})):(h(),Ee(a(Wa),{key:2,class:"h-3 w-3"})),i("span",null,T(w.eventsLoading?a(_e)("sessionPanel.loading"):a(vt)(w)?`${a(_e)("sessionPanel.expand")} (${Mt(w)})`:a(_e)("sessionPanel.collapse")),1)],8,Em)):de("",!0),i("span",null,T(a(k)(w)),1)])]),_t(w)?(h(),_("div",Am,T(a(_e)("sessionPanel.loadingEvents")),1)):kn(w)?(h(),_("div",Im,[(h(!0),_(ot,null,ut(gn(w),ie=>(h(),_("div",{key:ie.id,class:we(["transcript-event-card min-w-0 rounded-sm px-3 py-2",hn(ie)])},[i("div",$m,T(ie.title),1),ie.detail||Array.isArray(ie.detailBlocks)&&ie.detailBlocks.length?(h(),Ee(sd,{key:0,detail:ie.detail,blocks:ie.detailBlocks,kind:ie.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):de("",!0)],2))),128))])):on(w)||rn(w)?(h(),_("div",Pm,T(w.eventsLoaded?a(_e)("sessionPanel.hiddenEventsLoaded",{count:Mt(w)}):a(_e)("sessionPanel.hiddenEventsLoadLater",{count:Mt(w)})),1)):(h(),_("p",Dm,T(["queued","starting","running","stopping"].includes(w.status)?a(_e)("sessionPanel.waitingEvents",{agent:a(c)(w)}):a(_e)("sessionPanel.noEvents")),1)),a($)(w)?(h(),_("div",Lm,[a(g)(w)?(h(),_("div",Mm,T(a(g)(w)),1)):de("",!0),a(v)(w)?(h(),_("div",Bm,T(a(v)(w)),1)):de("",!0),a(C)(w).length?(h(),_("div",Rm,[(h(!0),_(ot,null,ut(a(C)(w),ie=>(h(),_("span",{key:ie.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,T(ie.label),1),i("span",Nm,T(ie.value),1)]))),128))])):de("",!0)])):de("",!0)],2)])):de("",!0),a(Re)(w)?(h(),_("div",Om,[i("div",{class:we(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",w.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",Fm,[i("span",Um,T(bt(w)),1),i("div",jm,[e.diffSupported&&w.runId?(h(),_("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:ie=>Kt(w)},[le(a(Go),{class:"h-3 w-3"}),i("span",null,T(a(_e)("sessionPanel.view")),1)],8,Vm)):de("",!0),w.responseMessage&&!w.errorMessage?(h(),_("button",{key:1,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:ie=>Tt(w)},[le(a(Us),{class:"h-3 w-3"}),i("span",null,T(a(_e)("sessionPanel.insert")),1)],8,zm)):de("",!0),i("span",null,T(a(u)(w.finishedAt||w.startedAt)),1)])]),i("div",Hm,[w.errorMessage?(h(),_("div",qm,T(w.errorMessage),1)):(h(),_("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:x[8]||(x[8]=(...ie)=>a(Pe)&&a(Pe)(...ie)),onClick:Lt,innerHTML:a(Be)(w)},null,40,Km))])],2)])):de("",!0)],8,cm))),128)),a(xe).visible?(h(),Ee(na,{key:2,top:a(xe).top,left:a(xe).left,label:a(_e)("sourceBrowser.insertSelection"),onClick:mn},null,8,["top","left","label"])):de("",!0)],544),i("div",Wm,[a(Te)?(h(),_("button",{key:0,type:"button",class:we([a(ge)?"mb-10 sm:mb-8":"","tool-button pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur"]),onClick:x[14]||(x[14]=(...w)=>a(De)&&a(De)(...w))},[le(a(Ga),{class:"h-3.5 w-3.5"}),i("span",null,T(a(_e)("sessionPanel.jumpToLatest")),1)],2)):de("",!0),a(ge)?(h(),_("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(X),onClick:x[15]||(x[15]=(...w)=>a(We)&&a(We)(...w))},[a(X)?(h(),Ee(a(Wt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),Ee(a(Xa),{key:1,class:"h-3.5 w-3.5"})),i("span",null,T(a(X)?a(_e)("sessionPanel.stopping"):a(_e)("sessionPanel.stop")),1),a(X)?de("",!0):(h(),_("span",Xm,[...x[19]||(x[19]=[i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1)])]))],8,Gm)):de("",!0)])]),le(Kr,{modelValue:it.value,"onUpdate:modelValue":x[16]||(x[16]=w=>it.value=w),images:tn.value},null,8,["modelValue","images"])]))}},Jm={key:0,class:"h-full min-h-0"},Qm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},hr={__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=z(null);function r(){var C,v;return(v=(C=s.value)==null?void 0:C.send)==null?void 0:v.call(C)}function l(){var C,v;(v=(C=s.value)==null?void 0:C.stop)==null||v.call(C)}function u(){var C,v;(v=(C=s.value)==null?void 0:C.scrollToBottom)==null||v.call(C)}function m(){var C,v;return((v=(C=s.value)==null?void 0:C.openProjectManager)==null?void 0:v.call(C))||!1}function k(){var C,v;return((v=(C=s.value)==null?void 0:C.openSourceBrowser)==null?void 0:v.call(C))||!1}function c(){var C,v;return((v=(C=s.value)==null?void 0:C.closeTopDialog)==null?void 0:v.call(C))||!1}return t({closeTopDialog:c,openProjectManager:m,openSourceBrowser:k,send:r,stop:l,scrollToBottom:u}),(C,v)=>e.taskSlug?(h(),_("div",Jm,[le(Ym,{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:v[0]||(v[0]=g=>o("agent-bindings-change",g)),onInsertCodeContext:v[1]||(v[1]=g=>o("insert-code-context",g)),onProjectCreated:v[2]||(v[2]=g=>o("project-created",g)),onSendingChange:v[3]||(v[3]=g=>o("sending-change",g)),onSelectedSessionChange:v[4]||(v[4]=g=>o("selected-session-change",g)),"onUpdate:selectedAgentEngine":v[5]||(v[5]=g=>o("update:selectedAgentEngine",g)),onOpenDiff:v[6]||(v[6]=g=>o("open-diff",g)),onToast:v[7]||(v[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?(h(),_("section",Qm,T(e.emptyMessage),1)):de("",!0)}},Zm=["title"],eg={class:"flex min-w-0 items-center gap-1.5"},tg=["aria-pressed","title","data-agent-engine","onClick"],vr={__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}=Et(),r=G(()=>{const c=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(C=>{const v=String((C==null?void 0:C.engine)||"").trim();return!v||c.has(v)?!1:(c.add(v),!0)})}),l=G(()=>r.value.length>1),u=G(()=>{var C,v;const c=String(n.selectedAgentEngine||"").trim();return r.value.some(g=>g.engine===c)?c:((C=r.value.find(g=>g.isDefault))==null?void 0:C.engine)||((v=r.value[0])==null?void 0:v.engine)||""}),m=G(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function k(c={}){return qr(c,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(c,C)=>l.value?(h(),_("div",{key:0,class:we(["flex w-full overflow-x-auto pb-0.5",m.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:C[1]||(C[1]=Ze(()=>{},["stop"]))},[i("div",eg,[(h(!0),_(ot,null,ut(r.value,v=>(h(),_("button",{key:v.engine,type:"button",class:we(["theme-agent-selector-button",v.engine===u.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":v.engine===u.value,title:k(v),"data-agent-engine":v.engine,onMousedown:C[0]||(C[0]=Ze(()=>{},["prevent"])),onClick:g=>o("update:selectedAgentEngine",v.engine)},T(k(v)),43,tg))),128))])],42,Zm)):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":""},sg={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},og=["disabled","title","aria-label"],rg={class:"sr-only sm:not-sr-only sm:inline"},ag=["title","aria-label"],ig={class:"sr-only sm:not-sr-only sm:inline"},lg=["disabled","title","aria-label"],ug={class:"sr-only sm:not-sr-only sm:inline"},cg=["title","aria-label"],dg={class:"sr-only sm:not-sr-only sm:inline"},fg={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"},pg=["disabled","title","aria-label"],mg={class:"sr-only sm:not-sr-only sm:inline"},yr={__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}=Et(),r=G(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(u,m)=>(h(),_("div",ng,[i("div",sg,[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]=Ze(()=>{},["prevent"])),onClick:m[1]||(m[1]=k=>o("open-file-picker"))},[e.uploading?(h(),Ee(a(Wt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),Ee(a(Ya),{key:1,class:"h-4 w-4"})),i("span",rg,T(a(s)("editor.chooseFiles")),1)],40,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",title:a(s)("editor.clear"),"aria-label":a(s)("editor.clear"),"data-promptx-editor-action":"clear",onMousedown:m[2]||(m[2]=Ze(()=>{},["prevent"])),onClick:m[3]||(m[3]=k=>o("clear-request"))},[le(a(Ja),{class:"h-4 w-4"}),i("span",ig,T(a(s)("editor.clear")),1)],40,ag),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]=Ze(()=>{},["prevent"])),onClick:m[5]||(m[5]=k=>o("add-todo"))},[le(a(Us),{class:"h-4 w-4"}),i("span",ug,T(a(s)("editor.todo")),1)],40,lg),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]=Ze(()=>{},["prevent"])),onClick:m[7]||(m[7]=k=>o("manage-todo"))},[le(a(Nr),{class:"h-4 w-4"}),i("span",dg,T(l()),1),e.todoCount>0?(h(),_("span",fg,T(e.todoCount>9?"9+":e.todoCount),1)):de("",!0)],40,cg),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]=Ze(()=>{},["prevent"])),onClick:m[9]||(m[9]=k=>o("send-request"))},[r.value?(h(),Ee(a(Wt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),Ee(a(Qa),{key:1,class:"h-4 w-4"})),i("span",mg,T(a(s)("editor.send")),1)],40,pg)])]))}};function gg(e){const{props:t,panelRef:n,onClose:o}=e,s=z({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=z(!1),l=z("bottom");function u(){o==null||o()}function m(g=!1){const p=window.innerWidth,P=window.innerHeight,Z=12,S=8,B=320,K=560,j=420,R=180,te=Math.min(K,Math.max(B,p-Z*2)),A=Math.min(te,p-Z*2),Y=t.anchorRect||{left:(p-A)/2,top:P/2,bottom:P/2};let fe=Y.left;fe+A>p-Z&&(fe=p-Z-A),fe<Z&&(fe=Z);const me=Math.max(0,P-Z-(Y.bottom+S)),D=Math.max(0,Y.top-S-Z);g?l.value=me>=D?"bottom":"top":l.value==="bottom"&&me<R&&D>me+24?l.value="top":l.value==="top"&&D<R&&me>D+24&&(l.value="bottom");const ee=l.value,ae=ee==="bottom"?me:D,Q=Math.max(140,P-Z*2),ge=Math.min(Q,Math.max(Math.min(j,ae||j),R)),I={left:`${Math.round(fe)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ge)}px`,top:"auto",bottom:"auto"};return ee==="bottom"?I.top=`${Math.round(Math.max(Z,Y.bottom+S))}px`:I.bottom=`${Math.round(Math.max(Z,P-Y.top+S))}px`,I}function k(g=!1){const p=m(g);s.value={...s.value,left:p.left,top:p.top,bottom:p.bottom,width:p.width,maxHeight:p.maxHeight}}function c(){return!t.open||!t.anchorRect?!1:(l.value="bottom",k(!0),r.value=!0,!0)}function C(){r.value=!1}function v(g){!t.open||!n.value||n.value.contains(g.target)||u()}return pn(()=>{document.addEventListener("pointerdown",v)}),Rt(()=>{document.removeEventListener("pointerdown",v)}),{closePicker:u,initializePanel:c,panelReady:r,panelStyle:s,resetPanel:C,updatePanelPosition:k}}function hg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:u,panelStyle:m,resetPanel:k,updatePanelPosition:c}=gg({props:t,panelRef:n,onClose:o}),C=aa({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return Ae(()=>t.open,v=>{if(!v){C.resetData(),k();return}k(),t.anchorRect&&l()&&C.initializeData()},{flush:"sync"}),Ae(()=>t.anchorRect,v=>{if(!(!t.open||!v)){if(!u.value){l()&&C.initializeData();return}c(!1)}},{flush:"sync"}),Ae(()=>t.sessionId,()=>{C.handleSessionChange()},{flush:"sync",immediate:!0}),Ae(()=>t.query,()=>{C.handleQueryChange()},{immediate:!0}),Ae(C.visibleItems,()=>{C.handleVisibleItemsChange()},{immediate:!0}),{...C,closePicker:r,panelReady:u,panelStyle:m}}const vg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},yg={class:"flex shrink-0 items-center gap-2"},Sg={class:"min-h-0 flex-1 overflow-y-auto p-2"},wg={key:0,class:"theme-empty-state px-3 py-4 text-xs"},xg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},bg={key:2,class:"theme-empty-state px-3 py-4 text-xs"},kg={key:3,class:"theme-empty-state px-3 py-4 text-xs"},Tg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},_g={key:5,class:"space-y-1"},Cg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Eg=["onClick"],Ag={class:"min-w-0 flex-1"},Ig=["innerHTML"],$g=["innerHTML"],Pg={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Dg=["onClick"],Lg={class:"min-w-0 flex-1"},Mg=["innerHTML"],Bg=["innerHTML"],Rg={key:6,class:"space-y-1"},Ng={class:"flex items-start gap-1.5"},Og=["onClick"],Fg={key:1,class:"block h-5 w-5 shrink-0"},Ug=["onClick"],jg={class:"min-w-0 flex-1"},Vg={class:"flex items-center gap-1.5"},zg={__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=z(null),{t:l}=Et(),{activeKey:u,closePicker:m,collapseActiveDirectory:k,confirmActive:c,currentError:C,currentLoading:v,emitSelect:g,expandActiveDirectory:p,getDisplayName:P,getHighlightedName:Z,getHighlightedPath:S,moveActive:B,normalSearchItems:K,normalizedQuery:j,panelReady:R,panelStyle:te,recentSearchItems:A,setItemRef:Y,showSearchEmptyState:fe,showTreeEmptyState:me,toggleDirectory:D,treeItems:ee,visibleItems:ae}=hg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:Q=>s("select",Q)});return t({collapseActiveDirectory:k,moveActive:B,confirmActive:c,expandActiveDirectory:p}),(Q,ge)=>(h(),Ee(vs,{to:"body"},[e.open&&a(R)?(h(),_("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:Bn(a(te))},[i("div",vg,[i("div",yg,[i("div",{class:we(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(v)?"opacity-100":"opacity-0"])},[le(a(Wt),{class:"h-3.5 w-3.5 animate-spin"})],2),i("button",{type:"button",class:"tool-button inline-flex h-7 w-7 items-center justify-center",onClick:ge[0]||(ge[0]=(...I)=>a(m)&&a(m)(...I))},[le(a(Mr),{class:"h-4 w-4"})])])]),i("div",Sg,[e.sessionId?a(C)?(h(),_("div",xg,T(a(C)),1)):a(fe)?(h(),_("div",bg,T(a(l)("pathPicker.noResults")),1)):a(me)?(h(),_("div",kg,T(a(l)("pathPicker.emptyDirectory")),1)):a(v)&&!a(ae).length?(h(),_("div",Tg,T(a(l)("pathPicker.loading")),1)):a(j)?(h(),_("div",_g,[a(A).length?(h(),_("div",Cg,T(a(l)("pathPicker.recent")),1)):de("",!0),(h(!0),_(ot,null,ut(a(A),I=>(h(),_("button",{key:I.path,ref_for:!0,ref:X=>a(Y)(I.path,X),type:"button",class:we(["theme-list-row focus:outline-none",a(u)===I.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:X=>a(g)(I)},[(h(),Ee(bn(I.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",Ag,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Z)(I)},null,8,Ig)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(S)(I)},null,8,$g)])],10,Eg))),128)),a(j)&&a(K).length?(h(),_("div",Pg,T(a(l)("pathPicker.results")),1)):de("",!0),(h(!0),_(ot,null,ut(a(K),I=>(h(),_("button",{key:I.path,ref_for:!0,ref:X=>a(Y)(I.path,X),type:"button",class:we(["theme-list-row focus:outline-none",a(u)===I.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:X=>a(g)(I)},[(h(),Ee(bn(I.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",Lg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Z)(I)},null,8,Mg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(S)(I)},null,8,Bg)])],10,Dg))),128))])):(h(),_("div",Rg,[(h(!0),_(ot,null,ut(a(ee),I=>(h(),_("div",{key:I.path,ref_for:!0,ref:X=>a(Y)(I.path,X),class:we(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(u)===I.path?"theme-list-item-active":I.type==="directory"&&I.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Bn({paddingLeft:`${I.depth*16+6}px`})},[i("div",Ng,[I.type==="directory"?(h(),_("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Ze(X=>a(D)(I.path),["stop"])},[I.loading?(h(),Ee(a(Wt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),Ee(a(Rr),{key:1,class:we(["h-3.5 w-3.5 transition",I.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Og)):(h(),_("span",Fg)),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:X=>a(g)(I)},[(h(),Ee(bn(I.type==="directory"?a(Hn):a(Pn)),{class:we(["h-4 w-4 shrink-0",I.type==="directory"&&I.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",jg,[i("div",Vg,[i("span",{class:we(["theme-list-item-title truncate",I.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},T(a(P)(I)),3)])])],8,Ug)])],6))),128))])):(h(),_("div",wg,T(a(l)("pathPicker.selectProjectFirst")),1))])],4)):de("",!0)]))}},Hg={__name:"TiptapTextBlockView",props:Lo,setup(e){return(t,n)=>(h(),Ee(a(Mo),{"data-promptx-node":"text"},{default:Qe(()=>[le(a(Ur),{"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}))}},Ca={__name:"TiptapSpecialBlockFrame",props:{frameClass:{type:String,default:""},headerPaddingClass:{type:String,default:"px-4 py-3"},headerClass:{type:String,default:""},selected:{type:Boolean,default:!1}},setup(e){const t=e,n=G(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=G(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(h(),_("div",{class:we(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:we(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[sn(s.$slots,"header",{actionsStateClass:o.value})],2),sn(s.$slots,"default")],2))}},Pt={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function qg(){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 Wn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||qg()),meta:e!=null&&e.meta?{...e.meta}:{}}}function zn(e=""){return Wn({type:Bt.TEXT,content:e,meta:{}})}function Cs(e){return e&&e.type!==Bt.TEXT}function Ln(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[zn("")];const n=[];return t.forEach((o,s)=>{const r=Wn(o),l=n[n.length-1];!l&&Cs(r)&&n.push(zn("")),l&&Cs(l)&&Cs(r)&&n.push(zn("")),n.push(r),s===t.length-1&&Cs(r)&&n.push(zn(""))}),n}function Ao(e=""){const t=String(e||"").split(`
43
+ `),n=[];return t.forEach((o,s)=>{o&&n.push({type:Pt.TEXT,text:o}),s<t.length-1&&n.push({type:Pt.HARD_BREAK})}),n}function Kg(e=""){return Ao(e)}function Wg(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 Hs(e=[]){return Wg(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===Pt.TEXT?String(t.text||""):n===Pt.HARD_BREAK?`
44
+ `:Hs((t==null?void 0:t.content)||[])}).join("")}function Gg(e=[]){return Hs(e)}function Xg(e={}){var n,o;const t=Wn(e);return t.type===Bt.IMAGE?{type:Pt.IMAGE_BLOCK,attrs:{clientId:t.clientId,src:String(t.content||"")}}:t.type===Bt.IMPORTED_TEXT?{type:Pt.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:Ao(t.content)}:{type:Pt.TEXT_BLOCK,attrs:{clientId:t.clientId},content:Ao(t.content)}}function Ea(e=[]){return Ln(e).map(Xg)}function Es(e=[]){return{type:Pt.DOC,content:Ea(e)}}function Yg(e={}){var t,n,o,s,r,l;return(e==null?void 0:e.type)===Pt.IMAGE_BLOCK?Wn({type:Bt.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)===Pt.IMPORTED_TEXT_BLOCK?Wn({type:Bt.IMPORTED_TEXT,content:Hs(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)===Pt.TEXT_BLOCK?Wn({type:Bt.TEXT,content:Hs(e.content||[]),clientId:String(((l=e.attrs)==null?void 0:l.clientId)||""),meta:{}}):null}function Jg(e=null){const n=(Array.isArray(e==null?void 0:e.content)?e.content:[]).map(Yg).filter(Boolean);return Ln(n)}function rs(e=[]){return JSON.stringify(Ln(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 Qg(e=""){const t=String(e);return{lines:t?t.split(`
45
+ `).length:0,chars:t.length}}function Rs(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 Zg={class:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5","data-promptx-imported-meta":""},eh=["aria-expanded"],th={class:"theme-heading inline-flex items-center gap-1.5 text-xs font-medium leading-5"},nh=["aria-expanded"],sh={class:"mt-0.5 break-all text-[12px] leading-4 text-[var(--theme-textSecondary)]"},oh=["aria-label"],rh={class:"max-h-[8.5rem] overflow-hidden whitespace-pre-wrap break-words leading-6"},ah={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-[var(--theme-appPanelMuted)] to-transparent"},ih={key:1,class:"theme-muted-text absolute bottom-2 right-4 bg-[var(--theme-appPanelMuted)] pl-2 text-xs"},So="tool-button inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",lh={__name:"TiptapImportedTextBlockView",props:Lo,setup(e){const t=e,{t:n}=Et(),o=G(()=>{var g;return Gg(((g=t.node)==null?void 0:g.content)||[])}),s=G(()=>{var g,p;return String(((p=(g=t.node)==null?void 0:g.attrs)==null?void 0:p.fileName)||n("blockEditor.unnamedFile"))}),r=G(()=>{const g=Qg(o.value);return n("blockEditor.stats",g)}),l=G(()=>n("blockEditor.fileSummary",{name:s.value,stats:r.value})),u=G(()=>{const g=String(o.value||"").replace(/\r\n/g,`
46
+ `),p=g.split(`
47
+ `),P=[];let Z=0;for(const K of p){const j=K.trimEnd(),R=j.length?j:"";if(!(!R&&P[P.length-1]==="")&&(P.push(R),Z+=R.length,P.length>=4||Z>=220))break}const S=P.join(`
48
+ `).trim(),B=g.trim();return{text:S,truncated:P.length<p.length||S.length<B.length}}),m=`${So} tool-button-danger-subtle`;function k(g){g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),c())}function c(){var g,p,P;(P=t.updateAttributes)==null||P.call(t,{collapsed:!((p=(g=t.node)==null?void 0:g.attrs)!=null&&p.collapsed)}),Rs(t.editor)}function C(){var S;const{editor:g,getPos:p,node:P}=t;if(!g||typeof p!="function"||!P)return;const Z=p();g.chain().focus().insertContentAt({from:Z,to:Z+P.nodeSize},{type:Pt.TEXT_BLOCK,attrs:{clientId:String(((S=P.attrs)==null?void 0:S.clientId)||"")},content:Kg(o.value)}).run(),Rs(t.editor)}function v(){var g;(g=t.deleteNode)==null||g.call(t),Rs(t.editor)}return(g,p)=>(h(),Ee(a(Mo),{class:"group relative","data-promptx-node":"imported_text"},{default:Qe(()=>[le(Ca,{selected:g.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:Qe(({actionsStateClass:P})=>{var Z,S,B,K;return[i("div",Zg,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((Z=g.node.attrs)!=null&&Z.collapsed)),onClick:c,onKeydown:k},[i("p",th,[le(a(js),{class:"h-3.5 w-3.5 shrink-0"}),Sn(" "+T(a(n)("blockEditor.file")),1)])],40,eh),i("div",{"data-promptx-imported-actions":"",class:we(["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:we(So),contenteditable:"false",onClick:c},[le(a(Po),{class:we(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(S=g.node.attrs)!=null&&S.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,T((B=g.node.attrs)!=null&&B.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:we(So),contenteditable:"false",onClick:C},[le(a(js),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,T(a(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:we(m),contenteditable:"false",onClick:v},[le(a(Ys),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,T(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:c,onKeydown:k},[i("p",sh,T(l.value),1)],40,nh)])]}),default:Qe(()=>{var P,Z;return[Zt(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:c,onKeydown:k},[i("div",rh,T(u.value.text||a(n)("blockEditor.emptyContent")),1),u.value.truncated?(h(),_("div",ah)):de("",!0),u.value.truncated?(h(),_("span",ih,"...")):de("",!0)],40,oh),[[Os,(P=g.node.attrs)==null?void 0:P.collapsed]]),Zt(le(a(Ur),{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),[[Os,!((Z=g.node.attrs)!=null&&Z.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},uh={class:"flex min-w-0 items-center justify-between gap-3"},ch={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},dh={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},fh=["src","alt"],ph="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]",mh={__name:"TiptapImageBlockView",props:Lo,setup(e){const t=e,{t:n}=Et();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),Rs(t.editor)}return(r,l)=>(h(),Ee(a(Mo),{class:"group","data-promptx-node":"image"},{default:Qe(()=>[le(Ca,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:Qe(({actionsStateClass:u})=>[i("div",uh,[i("div",ch,[le(a(Or),{class:"h-3.5 w-3.5 shrink-0"}),Sn(" "+T(a(n)("blockEditor.image")),1)]),i("div",{class:we(["shrink-0 transition",u])},[i("button",{type:"button",class:we(ph),contenteditable:"false",onClick:s},[le(a(Ys),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,T(a(n)("blockEditor.delete")),1)])],2)])]),default:Qe(()=>{var u;return[i("div",dh,[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,fh)])])]}),_:1},8,["selected"])]),_:1}))}},gh=["accept"],Sr=10*1024*1024,wr=2*1024*1024,xr=8*1024*1024,hh=1500,vh={__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}=Et(),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=z(null),c=z(null),C=z(""),v=z(ze()),g=z(null),p=z(null),P=z(!1),Z=z(0),S=G(()=>Ln(o.modelValue)),B=G(()=>S.value.filter(L=>(L==null?void 0:L.type)===Bt.IMAGE&&String(L.content||"").trim()).map(L=>String(L.content||"").trim()));let K=rs(S.value);function j(L=Y.value){if(!L)return!1;const N=Jg(L.getJSON()),ne=rs(N);return ne===K?!1:(K=ne,s("update:modelValue",N),!0)}const R=li.extend({name:Pt.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return oo(Hg)}}),te=Xo.create({name:Pt.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:L}){return["div",{...L,"data-type":"promptx-imported-text-block"}]},addNodeView(){return oo(lh)}}),A=Xo.create({name:Pt.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:L}){return["div",{...L,"data-type":"promptx-image-block"}]},addNodeView(){return oo(mh)}}),Y=ui({extensions:[ci.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}),R,te,A],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(L,N){return Ma(N,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:he()})?(N.preventDefault(),N.stopPropagation(),s("send-request"),!0):!N.shiftKey&&!N.altKey&&(N.metaKey||N.ctrlKey)&&String(N.key||"").toLowerCase()==="k"?_e():lt(N)}},content:Es(S.value),onCreate({editor:L}){Oe(L)},onFocus({editor:L}){P.value=!0,Oe(L)},onBlur(){P.value=!1},onSelectionUpdate({editor:L}){Oe(L)},onUpdate({editor:L}){Z.value=Date.now(),j(L),Oe(L)}});Ae(Y,L=>{if(!L)return;const N=Ln(o.modelValue);K=rs(N),L.commands.setContent(Es(N),!1)},{immediate:!0}),Ae(()=>o.modelValue,L=>{const N=Y.value;if(!N){K=rs(Ln(L));return}const ne=Ln(L),xe=rs(ne);xe!==K&&(K=xe,N.commands.setContent(Es(ne),!1))},{deep:!0});function fe(L){const N=String(L||"").trim();N&&s("file-feedback",N)}function me(L){const N=String((L==null?void 0:L.name)||"").trim().toLowerCase();return N.includes(".")?`.${N.split(".").pop()}`:""}function D(L,N){return String((L==null?void 0:L.name)||"").trim()||r(N)}function ee(L){const N=Math.max(0,Number(L)||0);return N>=1024*1024?`${(N/(1024*1024)).toFixed(N>=10*1024*1024?0:1)} MB`:N>=1024?`${Math.round(N/1024)} KB`:`${N} B`}function ae(L){if(!L)return!1;const N=String(L.type||"").toLowerCase(),ne=me(L);return N.startsWith("text/")||l.has(ne)||u.has(N)}function Q(L){if(!L)return!1;const N=String(L.name||"").toLowerCase(),ne=String(L.type||"").toLowerCase();return N.endsWith(".pdf")||ne==="application/pdf"}function ge(L){const N=Array.from(L||[]).filter(Boolean),ne={imageFiles:[],textFiles:[],pdfFiles:[]},xe=[],Fe=[];return N.forEach(Pe=>{if(Pe.type.startsWith("image/")){if(Pe.size>Sr){Fe.push({name:D(Pe,"blockEditor.unnamedImage"),limit:ee(Sr)});return}ne.imageFiles.push(Pe);return}if(Q(Pe)){if(Pe.size>xr){Fe.push({name:D(Pe,"blockEditor.unnamedPdf"),limit:ee(xr)});return}ne.pdfFiles.push(Pe);return}if(ae(Pe)){if(Pe.size>wr){Fe.push({name:D(Pe,"blockEditor.unnamedFile"),limit:ee(wr)});return}ne.textFiles.push(Pe);return}xe.push(D(Pe,"blockEditor.unnamedFile"))}),{...ne,unsupportedFiles:xe,oversizedFiles:Fe}}function I({unsupportedFiles:L=[],oversizedFiles:N=[]}={}){var ne;L.length&&fe(r("blockEditor.unsupportedFiles",{names:L.slice(0,3).join("、"),extra:Math.max(0,L.length-3)})),N.length&&fe(r("blockEditor.oversizedFiles",{names:N.slice(0,2).map(xe=>xe.name).join("、"),extra:Math.max(0,N.length-2),limit:((ne=N[0])==null?void 0:ne.limit)||""}))}function X(L){const{imageFiles:N,textFiles:ne,pdfFiles:xe,unsupportedFiles:Fe,oversizedFiles:Pe}=ge(L);return I({unsupportedFiles:Fe,oversizedFiles:Pe}),ne.length&&s("import-text-files",ne),xe.length&&s("import-pdf-files",xe),N.length&&s("upload-files",N),N.length+ne.length+xe.length>0}function $(L){const N=[...L.clipboardData.items].filter(ne=>ne.kind==="file").map(ne=>ne.getAsFile()).filter(Boolean);N.length&&(L.preventDefault(),X(N))}function Te(L){L.preventDefault(),X(L.dataTransfer.files)}function Me(L){const N=Y.value;if(!N)return;const ne=L.target instanceof Element?L.target:null,xe=L.currentTarget instanceof Element?L.currentTarget:null,Fe=N.view.dom instanceof Element?N.view.dom:null;!ne||!xe||!Fe||ne.closest('button, input, textarea, select, a, [contenteditable="false"]')||!xe.contains(ne)||ne.closest("[data-promptx-node]")||!(ne===xe||ne===Fe||xe.contains(ne))||(L.preventDefault(),Ve())}function Re(L){X(L.target.files),L.target.value=""}function Ne(){var L;(L=k.value)==null||L.click()}function Ve(){const L=Y.value;L&&L.chain().focus("end").run()}function We(){var ne,xe;const L=Y.value;if(!L)return!1;(xe=(ne=L.view.domObserver)==null?void 0:ne.flush)==null||xe.call(ne);const N=j(L);return N&&(Z.value=Date.now()),Oe(L),N}function ke(L=[]){const N=Y.value;!N||!L.length||N.chain().focus().insertContent(L).run()}function W(L=[]){ke(Ea(L))}function oe(L=[]){W(L)}function ce(L=[]){W(L)}function $e(){const L=Y.value;L&&L.commands.setContent(Es([zn("")]),!0)}function he(){var L,N;return!!((N=(L=Y.value)==null?void 0:L.view)!=null&&N.composing)}function Le(){var L;return he()||P.value||(L=Y.value)!=null&&L.isFocused?!0:Date.now()-Z.value<hh}function pe(){var xe;const L=Y.value;if(!L)return!1;const N=L.state.selection,ne=N.$from.nodeAfter||N.$from.parent;return((xe=ne==null?void 0:ne.type)==null?void 0:xe.name)===Pt.IMPORTED_TEXT_BLOCK}function De(L){var ne;const N=String(((ne=L==null?void 0:L.detail)==null?void 0:ne.src)||"").trim();N&&(C.value=N)}function ze(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function Ie(L=null,N=null){return!L||!N?!1:L.start===N.start&&L.end===N.end&&L.query===N.query&&L.clientId===N.clientId}function mt(){g.value=null}function Ke(L={}){const{suppressCurrent:N=!1}=L,ne=v.value;N&&ne.open&&(p.value={start:ne.start,end:ne.end,query:ne.query,clientId:ne.clientId}),v.value=ze(),mt()}function it(){Ke({suppressCurrent:!0})}function gt(L=Y.value){var Ye,tt,bt;if(!L)return null;const N=L.state.selection;if(!N.empty)return null;const{$from:ne,from:xe}=N,Fe=((tt=(Ye=ne.parent)==null?void 0:Ye.type)==null?void 0:tt.name)||"";if(![Pt.TEXT_BLOCK,Pt.IMPORTED_TEXT_BLOCK].includes(Fe))return null;const Pe=ne.parent.textBetween(0,ne.parentOffset,`
49
+ `,"\0");return{from:xe,node:ne.parent,nodeTypeName:Fe,nodeStart:ne.start(),parentOffset:ne.parentOffset,clientId:String(((bt=ne.parent.attrs)==null?void 0:bt.clientId)||""),textBefore:Pe}}function ht(L=v.value.end){const N=Y.value;if(typeof L=="object"&&L!==null&&(L=v.value.end),!N||!v.value.open||L<0){mt();return}try{const ne=N.view.coordsAtPos(L);g.value={left:ne.left,right:ne.left,top:ne.bottom,bottom:ne.bottom,width:0,height:0}}catch{mt()}}function Oe(L=Y.value){const N=gt(L),ne=v.value;if(ne.open&&ne.trigger==="shortcut"){if(!N||N.clientId!==ne.clientId||N.from<ne.start){Ke();return}const tt=L.state.doc.textBetween(ne.start,N.from,`
50
+ `,"\0");if(/\s/.test(tt)){Ke();return}p.value=null,v.value={...ne,end:N.from,query:tt},ht(N.from);return}if(!N){Ke();return}const xe=N.textBefore.lastIndexOf("@");if(xe<0){Ke();return}const Fe=N.textBefore.slice(xe+1);if(/\s/.test(Fe)){Ke();return}const Pe=N.nodeStart+xe,Ye=N.from;Ie(p.value,{start:Pe,end:Ye,query:Fe,clientId:N.clientId})||(p.value=null,v.value={open:!0,start:Pe,end:Ye,query:Fe,trigger:"mention",blockType:N.nodeTypeName,clientId:N.clientId},ht(Ye))}function _e(){const L=Y.value,N=gt(L);return!L||!N?!1:(p.value=null,v.value={open:!0,start:N.from,end:N.from,query:"",trigger:"shortcut",blockType:N.nodeTypeName,clientId:N.clientId},ht(N.from),!0)}function ct(L){const N=Y.value,ne=String((L==null?void 0:L.path)||"").trim(),xe=v.value;if(!N||!ne||xe.start<0||xe.end<xe.start)return Ke(),!1;const Fe=xe.trigger==="shortcut"?`${ne} `:`@${ne} `,Pe=xe.start+Fe.length;return N.chain().focus().command(({tr:Ye,dispatch:tt})=>(Ye.insertText(Fe,xe.start,xe.end),Ye.setSelection(Oa.create(Ye.doc,Pe)),tt==null||tt(Ye),!0)).run(),Z.value=Date.now(),p.value=null,Ke(),!0}function lt(L){var N,ne,xe,Fe,Pe,Ye,tt,bt,ft,kt;if(!v.value.open)return!1;if(L.key==="Escape")return it(),!0;if(L.key==="ArrowDown")return!!((ne=(N=c.value)==null?void 0:N.moveActive)!=null&&ne.call(N,1));if(L.key==="ArrowUp")return!!((Fe=(xe=c.value)==null?void 0:xe.moveActive)!=null&&Fe.call(xe,-1));if(v.value.query&&(L.key==="ArrowLeft"||L.key==="ArrowRight"))return!1;if(L.key==="ArrowRight"){const vt=(Ye=(Pe=c.value)==null?void 0:Pe.expandActiveDirectory)==null?void 0:Ye.call(Pe);return vt&&typeof vt.then=="function"?(vt.catch(()=>{}),!0):!!vt}return L.key==="ArrowLeft"?!!((bt=(tt=c.value)==null?void 0:tt.collapseActiveDirectory)!=null&&bt.call(tt)):!L.shiftKey&&!L.altKey&&!L.metaKey&&!L.ctrlKey&&L.key==="Enter"?!!((kt=(ft=c.value)==null?void 0:ft.confirmActive)!=null&&kt.call(ft)):!1}return pn(()=>{window.addEventListener("promptx:tiptap-image-preview",De),window.addEventListener("resize",ht),window.addEventListener("scroll",ht)}),Rt(()=>{window.removeEventListener("promptx:tiptap-image-preview",De),window.removeEventListener("resize",ht),window.removeEventListener("scroll",ht)}),Ae(()=>o.codexSessionId,()=>{Ke()}),t({clearContent:$e,flushPendingInput:We,focusEditor:Ve,insertBlocks:W,insertImportedBlocks:oe,insertUploadedBlocks:ce,isComposing:he,isEditing:Le,isImportedBlockActive:pe,openFilePicker:Ne}),(L,N)=>(h(),_("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:Te,onDragover:N[1]||(N[1]=Ze(()=>{},["prevent"])),onPaste:$},[i("input",{ref_key:"fileInputRef",ref:k,class:"hidden",type:"file",accept:a(m),multiple:"",onChange:Re},null,40,gh),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:Me},[a(Y)?(h(),Ee(a(di),{key:0,editor:a(Y),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):de("",!0)],32),le(Kr,{modelValue:C.value,"onUpdate:modelValue":N[0]||(N[0]=ne=>C.value=ne),images:B.value},null,8,["modelValue","images"]),le(zg,{ref_key:"mentionPickerRef",ref:c,open:v.value.open&&!!g.value,"session-id":e.codexSessionId,query:v.value.query,"anchor-rect":g.value,onClose:it,onSelect:ct},null,8,["open","session-id","query","anchor-rect"])],32))}},yh={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},br={__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=z(null),{t:l}=Et(),u=G({get:()=>o.modelValue,set:S=>s("update:modelValue",S)});function m(){var S,B;(B=(S=r.value)==null?void 0:S.openFilePicker)==null||B.call(S)}function k(){var S,B;(B=(S=r.value)==null?void 0:S.focusEditor)==null||B.call(S)}function c(){var S,B;return((B=(S=r.value)==null?void 0:S.flushPendingInput)==null?void 0:B.call(S))||!1}function C(S){var B,K;(K=(B=r.value)==null?void 0:B.insertBlocks)==null||K.call(B,S)}function v(S){var B,K;(K=(B=r.value)==null?void 0:B.insertImportedBlocks)==null||K.call(B,S)}function g(S){var B,K;(K=(B=r.value)==null?void 0:B.insertUploadedBlocks)==null||K.call(B,S)}function p(){var S,B;return((B=(S=r.value)==null?void 0:S.isImportedBlockActive)==null?void 0:B.call(S))||!1}function P(){var S,B;return((B=(S=r.value)==null?void 0:S.isComposing)==null?void 0:B.call(S))||!1}function Z(){var S,B;return((B=(S=r.value)==null?void 0:S.isEditing)==null?void 0:B.call(S))||!1}return t({focusEditor:k,flushPendingInput:c,insertBlocks:C,insertImportedBlocks:v,insertUploadedBlocks:g,isComposing:P,isEditing:Z,isImportedBlockActive:p,openFilePicker:m}),(S,B)=>e.loading&&!e.modelValue.length?(h(),_("section",yh,T(a(l)("workbench.loadingTaskContent")),1)):(h(),Ee(vh,{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"]))}},Sh={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},wh={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},xh={class:"flex items-center gap-2"},bh=["title","aria-label"],kh={class:"min-w-0 flex-1"},Th=["value","placeholder"],_h=["disabled"],Ch={class:"truncate"},Eh={__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}=Et();return(s,r)=>(h(),_("section",Sh,[i("div",wh,[i("div",xh,[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"))},[le(a(Za),{class:"h-3.5 w-3.5"})],8,bh),i("div",kh,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(h(),_("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]=en(Ze(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=en(Ze(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,Th)):(h(),_("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",Ch,T(e.title||a(o)("workbench.untitledTask")),1),le(a(fs),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,_h))])])])]))}},Ah={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},Ih={class:"workbench-panel-header theme-divider border-b px-4 py-4"},$h={class:"flex items-center justify-between gap-3"},Ph={class:"flex min-h-8 items-center"},Dh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Lh=["title"],Mh=["disabled","title"],Bh={class:"whitespace-nowrap"},Rh={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},Nh={key:0,class:"theme-empty-state px-3 py-4 text-sm"},Oh=["onClick"],Fh={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},Uh={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"},jh={class:"flex items-start justify-between gap-3"},Vh={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},zh=["title","aria-label"],Hh={class:"flex h-5 min-w-0 flex-1 items-center"},qh=["value","placeholder"],Kh=["title","onClick"],Wh={class:"min-w-0 truncate"},Gh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Xh={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},Yh={class:"mt-2 flex items-center justify-between gap-3"},Jh={class:"min-w-0 text-[11px] opacity-70"},Qh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Zh={class:"theme-divider border-t px-3 py-3"},ev={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},tv={class:"min-w-0 break-words"},nv={class:"grid grid-cols-2 gap-2"},sv=["disabled","title"],ov={class:"whitespace-nowrap"},rv=["disabled","title"],av={class:"whitespace-nowrap"},iv={__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}=Et(),r=z([]);Ae(()=>n.tasks,v=>{r.value=Array.isArray(v)?[...v]:[]},{immediate:!0});function l(v){return v.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":v.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function u(){return"theme-status-warning"}function m(v){const g=new Date(v.updatedAt);return Number.isNaN(g.getTime())?"":$r(g.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function k(v){var g,p;return!!((g=v==null?void 0:v.workspaceDiffSummary)!=null&&g.supported&&((p=v==null?void 0:v.workspaceDiffSummary)!=null&&p.fileCount))}function c(v){return v.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function C(v){if(n.mobile)return;const g=Number(v==null?void 0:v.oldIndex),p=Number(v==null?void 0:v.newIndex);!Number.isInteger(g)||!Number.isInteger(p)||g===p||o("reorder-task",r.value.map(P=>String((P==null?void 0:P.slug)||"").trim()).filter(Boolean))}return(v,g)=>(h(),_("aside",Ah,[i("div",Ih,[i("div",$h,[i("div",Ph,[i("div",Dh,[le(a(ei),{class:"h-4 w-4"}),i("span",null,T(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]=p=>o("open-settings"))},[le(a(ti),{class:"h-4 w-4"}),i("span",{class:we(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},T(a(s)("workbench.settings")),3)],8,Lh)]),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]=p=>o("create-task"))},[le(a(Us),{class:"h-4 w-4"}),i("span",Bh,T(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,Mh)]),i("div",Rh,[e.loadingTasks&&!e.tasks.length?(h(),_("div",Nh,T(a(s)("workbench.loadingTasks")),1)):(h(),Ee(a(ni),{key:1,modelValue:r.value,"onUpdate:modelValue":g[8]||(g[8]=p=>r.value=p),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:C},{default:Qe(()=>[(h(!0),_(ot,null,ut(r.value,p=>{var P,Z;return h(),_("article",{key:p.slug,class:we(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(p)]),onClick:S=>o("select-task",p.slug)},[p.slug===e.currentTaskSlug?(h(),_("span",Fh)):de("",!0),p.hasUnreadUpdate?(h(),_("span",Uh)):de("",!0),i("div",jh,[i("div",Vh,[e.mobile?de("",!0):(h(),_("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]=Ze(()=>{},["stop"]))},[le(a(si),{class:"h-3.5 w-3.5"})],8,zh)),i("div",Hh,[p.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===p.slug?(h(),_("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]=Ze(()=>{},["stop"])),onInput:g[4]||(g[4]=S=>o("update:draftTitle",S.target.value)),onKeydown:[g[5]||(g[5]=en(Ze(S=>S.target.blur(),["prevent"]),["enter"])),g[6]||(g[6]=en(Ze(S=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:g[7]||(g[7]=S=>o("title-blur"))},null,40,qh)):(h(),_("button",{key:1,type:"button",class:we(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",p.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:p.displayTitle,onClick:Ze(S=>o("title-click",p.slug),["stop"])},[(P=p.automation)!=null&&P.enabled?(h(),Ee(a(Fs),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):de("",!0),i("span",Wh,T(p.displayTitle),1)],10,Kh))])]),i("div",Gh,[p.sending?(h(),_("span",{key:0,class:we(["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,T(a(s)("workbench.running")),1)],2)):de("",!0)])]),i("div",Xh,T(p.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Yh,[i("div",Jh,T(m(p)),1),i("div",Qh,[k(p)?(h(),_("span",{key:0,class:we(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",c(p)])},[i("span",null,T(a(s)("workbench.filesCount",{count:((Z=p.workspaceDiffSummary)==null?void 0:Z.fileCount)||0})),1)],2)):de("",!0)])])],10,Oh)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Zh,[e.error?(h(),_("div",ev,[le(a(Do),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",tv,T(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]=p=>o("edit-task"))},[le(a(fs),{class:"h-4 w-4"}),i("span",ov,T(a(s)("workbench.editTask")),1)],8,sv),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]=p=>o("delete-task"))},[le(a(Ys),{class:"h-4 w-4"}),i("span",av,T(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,rv)])])]))}},kr=Pr(iv,[["__scopeId","data-v-200c2c76"]]),lv={class:"min-w-0"},uv={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},cv={class:"theme-muted-text mt-1 text-xs leading-5"},dv={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},fv={class:"theme-muted-text"},pv={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},mv={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},gv={class:"space-y-3"},hv={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},vv={class:"min-w-0 flex-1"},yv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},Sv={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},wv={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},xv={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},bv={class:"rounded-sm border border-dashed px-2 py-1"},kv={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Tv={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},_v={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Cv={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},Ev=["onClick"],Av=["onClick"],Iv={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},$v={__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}=Et(),r=G(()=>(n.items||[]).map(u=>{var p;const m=Array.isArray(u==null?void 0:u.blocks)?u.blocks:[],k=((p=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:p.content)||"",c=String(k||"").replace(/\s+/g," ").trim().slice(0,120),C=m.filter(P=>String((P==null?void 0:P.type)||"")==="image").length,v=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:C,importedCount:v,preview:c||(C?s("todoDialog.imagePreview",{count:C}):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)=>(h(),Ee(Js,{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:Qe(()=>[i("div",lv,[i("div",uv,[le(a(Nr),{class:"h-4 w-4"}),i("span",null,T(a(s)("todoDialog.title")),1)]),i("p",cv,T(a(s)("todoDialog.intro")),1)])]),default:Qe(()=>[i("div",dv,[i("span",fv,T(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",pv,T(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(h(),_("div",mv,[i("div",gv,[(h(!0),_(ot,null,ut(r.value,k=>(h(),_("article",{key:k.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",hv,[i("div",vv,[i("div",yv,[i("span",null,T(a(s)("todoDialog.itemTitle")),1),i("span",Sv,[le(a(Fs),{class:"h-3.5 w-3.5"}),Sn(" "+T(k.timeLabel),1)])]),i("p",wv,T(k.preview),1),i("div",xv,[i("span",bv,T(a(s)("todoDialog.blockCount",{count:k.blockCount})),1),k.textCount?(h(),_("span",kv,[le(a(js),{class:"h-3.5 w-3.5"}),Sn(" "+T(a(s)("todoDialog.textCount",{count:k.textCount})),1)])):de("",!0),k.importedCount?(h(),_("span",Tv,[le(a(js),{class:"h-3.5 w-3.5"}),Sn(" "+T(a(s)("todoDialog.importedCount",{count:k.importedCount})),1)])):de("",!0),k.imageCount?(h(),_("span",_v,[le(a(Or),{class:"h-3.5 w-3.5"}),Sn(" "+T(a(s)("todoDialog.imageCount",{count:k.imageCount})),1)])):de("",!0)])]),i("div",Cv,[i("button",{type:"button",class:"tool-button inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("use",k.id)},[le(a(oi),{class:"h-4 w-4"}),i("span",null,T(a(s)("todoDialog.use")),1)],8,Ev),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("delete",k.id)},[le(a(Ys),{class:"h-4 w-4"}),i("span",null,T(a(s)("todoDialog.delete")),1)],8,Av)])])]))),128))])])):(h(),_("div",Iv,T(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},Pv={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},Dv={__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"?Do:s==="error"?ri:s==="info"?ai:ii}return(s,r)=>(h(),Ee(vs,{to:"body"},[i("div",Pv,[le(Lr,{"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:Qe(()=>[e.message?(h(),_("div",{key:0,class:we(["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)])},[(h(),Ee(bn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,T(e.message),1)],2)):de("",!0)]),_:1})])]))}};function Lv(e,t=!1){const n=z(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return pn(()=>{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))}),Rt(()=>{s()}),{matches:n}}const Mv="(max-width: 1023px)",Ns="promptxWorkbenchMobileView";function wo(e){return(e==null?void 0:e[Ns])==="detail"}function Bv({currentTaskSlug:e}){const{matches:t}=Lv(Mv),n=z("tasks"),o=z("activity");function s(C="tasks"){if(typeof window>"u")return;const v={...window.history.state||{}};C==="detail"?v[Ns]="detail":delete v[Ns],window.history.replaceState(v,"")}function r(){if(typeof window>"u")return;const C={...window.history.state||{},[Ns]:"detail"};window.history.pushState(C,"")}function l(C=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=wo(C)?"detail":"tasks"}function u(C){t.value=!!C,l(typeof window>"u"?null:window.history.state)}function m(C={}){const{pushHistory:v=!0}=C;if(n.value="detail",!!t.value){if(v){r();return}s("detail")}}function k(C={}){const{useHistory:v=!0}=C;if(!t.value){n.value="tasks";return}if(v&&typeof window<"u"&&wo(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function c(C){t.value&&(n.value=wo(C.state)&&e.value?"detail":"tasks")}return pn(()=>{typeof window>"u"||window.addEventListener("popstate",c)}),Rt(()=>{typeof window<"u"&&window.removeEventListener("popstate",c)}),Ae(t,C=>{u(C)},{immediate:!0}),Ae(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:m,isMobileLayout:t,leaveMobileDetail:k,mobileDetailTab:o,mobileView:n}}const qs="PromptX";function Rv(e=""){const t=String(a(e)||"").trim();return t?`${qs} (${t})`:qs}function Nv(e="",t={}){Fa(()=>{if(typeof document>"u")return;const o=String(a(e)||"").trim();document.title=a(t.raw)?o||qs:Rv(o)}),Rt(()=>{typeof document>"u"||(document.title=qs)})}const Gn="success";function Ov(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Gn).trim()||Gn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Gn,duration:t}}function Fv(e=2200){const t=z(""),n=z(Gn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Gn}function r(l,u=e){const m=Ov(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=Gn,o=null},m.duration)}return Rt(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function Uv(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 jv(e=""){const t=String(e||"").replace(/\r\n/g,`
51
+ `).split(`
52
+ `);for(;t.length&&!String(t[0]||"").trim();)t.shift();for(;t.length&&!String(t[t.length-1]||"").trim();)t.pop();return t.join(`
53
+ `)}function Vv(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===Bt.TEXT||s.type===Bt.IMPORTED_TEXT){const r=jv(s.content);r&&n.push(r,"");continue}if(s.type===Bt.IMAGE){const r=Uv(s.content,t);r&&n.push(r,"")}}return n.join(`
54
+ `).trim()}function zv(e,t){return Vv(e,t)}const Io="promptx:active-task-slug",Hv=150,qv=1500,Kv=800,Ks=500,Wv=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function Ws(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 xn(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 jt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:xn((t==null?void 0:t.blocks)||[])}))}function Tr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:xn(e.blocks||[]),todoItems:jt(e.todoItems||[])}}function Aa(e=[]){return xn(e).filter(t=>(t==null?void 0:t.type)===Bt.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function Gv(e=[]){return Aa(e).length>0}function Xv(){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 _r(){return xn([{type:Bt.TEXT,content:"",meta:{}}])}function $o(e=[],t=16){return Ei(e,t)||""}function Yv(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 Cr(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=$o(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):Ge("workbench.untitledTask")}function Gs(e={}){return!!(e!=null&&e.running)}function Jv(e={},t=!1){return t&&!Gs(e)?"sending":Gs(e)?"running":"idle"}function Qv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Ia(e=""){return Wv.has(String(e||"").trim())}function Zv(e={},t={}){return!!(String((e==null?void 0:e.codexSessionId)||"").trim()&&Ia(t==null?void 0:t.status))}function $a(e="",t="",n=!1){const o=String(e||"").trim();return!!(o&&o===String(t||"").trim()&&n)}function ey(e={},t="",n={}){const o=String(t||"").trim();return!o||$a(o,n.currentTaskSlug,n.pageFocused)?{unreadMap:e,didMark:!1}:e!=null&&e[o]?{unreadMap:e,didMark:!1}:{unreadMap:{...e||{},[o]:!0},didMark:!0}}function Pa(e={},t=""){const n=String(t||"").trim();if(!n||!(e!=null&&e[n]))return e;const o={...e||{}};return delete o[n],o}function ty(e={},t={}){return t.pageFocused?Pa(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 Da(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 La(e={},t=Ks){const n=Math.max(1,Number(t)||Ks),o=Object.entries(e||{});return o.length<=n?e:Object.fromEntries(o.slice(-n))}function sy(e={},t=[],n=Ks){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=Da(l);u.taskSlug&&o.has(u.taskSlug)&&(s[r]=u)}),La(s,n)}function oy(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||!Ia(s))return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!1};if(Da(l[o]).status===s)return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!0};const m=La({...l,[o]:{taskSlug:t,status:s}},e.maxNotifiedRuns),k=ey(r,t,{currentTaskSlug:e.currentTaskSlug,pageFocused:e.pageFocused});return{unreadMap:k.unreadMap,notifiedMap:m,didMark:k.didMark,didDedupe:!1}}function Er(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function ry(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 Ar(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:Ws(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:Ws(u.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function ay(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 As(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(Io,t);return}window.localStorage.removeItem(Io)}function iy(){return typeof window>"u"?"":String(window.localStorage.getItem(Io)||"").trim()}function ly(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function uy(){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 jn(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=Ws(e.workspaceDiffSummary)),t}function cy(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Xn(),r=fa(),l=z(null),u=z([]),m=z({}),k=z({}),c=z({}),C=z({}),v=z({}),g=z(""),p=z({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),P=z(!0),Z=z(!1),S=z(!1),B=z(!1),K=z(!1),j=z(!1),R=z(""),te=z(!1),A=z("");let Y=null,fe=null,me=0,D=null,ee=0,ae=null;const Q=new Set;let ge=null,I=0,X={};const $=G(()=>$o(p.value.blocks)),Te=G(()=>Cr({title:p.value.title,autoTitle:p.value.autoTitle,preview:Yv(p.value.blocks)},p.value.blocks));function Me(E,b={}){const V=String(E||"").trim();if(!V)return"";const f=b.summary||it(V),x=b.cachedDraft===void 0?gt(V):b.cachedDraft,w=V===g.value;return Object.prototype.hasOwnProperty.call(k.value,V)?String(k.value[V]||"").trim():w?String(p.value.codexSessionId||(f==null?void 0:f.codexSessionId)||"").trim():String((x==null?void 0:x.codexSessionId)||(f==null?void 0:f.codexSessionId)||"").trim()}const Re=G(()=>Me(g.value)),Ne=G(()=>Jv(it(g.value),c.value[g.value])),Ve=G(()=>Ne.value!=="idle"),We=G(()=>u.value.some(E=>Gs(E))||Object.values(c.value).some(Boolean)),ke=G(()=>Object.values(C.value).some(Boolean)),W=z(0),oe=G(()=>Gv(p.value.blocks)),ce=G(()=>jt(p.value.todoItems)),$e=G(()=>Te.value||Ge("workbench.untitledTask")),he=G(()=>u.value.map(E=>_e(E)));function Le(E=""){const b=String(E||"").trim();if(!b||b.startsWith("/uploads/"))return b;const V=Xn();if(V&&b.startsWith(V))return b.slice(V.length);if(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?\/uploads\//.test(b)){const f=b.match(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/uploads\/.*)$/);if(f)return f[3]}return b}function pe(E=""){const b=String(E||"").replace(/\r\n/g,`
55
+ `).split(`
56
+ `);for(;b.length&&!String(b[0]||"").trim();)b.shift();for(;b.length&&!String(b[b.length-1]||"").trim();)b.pop();return b.join(`
57
+ `)}function De(E=[]){return E.map(b=>({id:Number.isInteger(Number(b==null?void 0:b.id))?Number(b.id):null,type:b==null?void 0:b.type,content:(b==null?void 0:b.type)==="image"?Le(b.content):pe(b.content),meta:b!=null&&b.meta?{...b.meta}:{}}))}function ze(E=[]){return(E||[]).map(b=>({id:String((b==null?void 0:b.id)||"").trim(),createdAt:String((b==null?void 0:b.createdAt)||""),blocks:De((b==null?void 0:b.blocks)||[])}))}function Ie(E=p.value.title,b=p.value.autoTitle,V=p.value.lastPromptPreview,f=p.value.todoItems,x=p.value.codexSessionId,w=p.value.blocks){return JSON.stringify({title:String(E||""),autoTitle:String(b||""),lastPromptPreview:String(V||""),todoItems:ze(f),codexSessionId:String(x||""),blocks:De(w)})}function mt(){return Ie()!==A.value}function Ke(){var E,b;return!!((b=(E=l.value)==null?void 0:E.isEditing)!=null&&b.call(E))}function it(E){return u.value.find(b=>b.slug===E)||null}function gt(E){return E&&m.value[E]||null}function ht(E,b=""){const V=String(E||"").trim();V&&(X={...X,[V]:String(b||"").trim()})}function Oe(E=""){var x;const b=String(E||"").trim();if(!b)return!1;const V=String(((x=it(b))==null?void 0:x.updatedAt)||"").trim(),f=String(X[b]||"").trim();return!!(V&&f&&V===f)}function _e(E){const b=gt(E.slug),V=E.slug===g.value?p.value.blocks:(b==null?void 0:b.blocks)||[],f=E.slug===g.value?p.value.title:(b==null?void 0:b.title)??E.title,x=E.slug===g.value?p.value.autoTitle:(b==null?void 0:b.autoTitle)??E.autoTitle,w=E.slug===g.value?jt(p.value.todoItems).length:jt((b==null?void 0:b.todoItems)||[]).length||Number(E.todoCount||0),ie=E.slug===g.value?p.value.lastPromptPreview||E.lastPromptPreview||"":(b==null?void 0:b.lastPromptPreview)||E.lastPromptPreview||"",Ce=Me(E.slug,{summary:E,cachedDraft:b});return{...E,title:f,autoTitle:x,todoCount:w,preview:ie,codexSessionId:Ce,sessionSelectionLocked:!!(Ce&&Number(E.codexRunCount||0)>0),sessionSelectionLockReason:Ce&&Number(E.codexRunCount||0)>0?Ge("taskActions.sessionLocked"):"",displayTitle:Cr({title:f,autoTitle:x,preview:ie},V),sending:Gs(E),hasUnreadUpdate:!!C.value[E.slug]}}function ct(E,b={}){const{insertAtStart:V=!1}=b;if(!(E!=null&&E.slug))return;const f=[...u.value],x=f.findIndex(w=>w.slug===E.slug);if(x>=0){f.splice(x,1,{...f[x],...E}),u.value=f;return}V?f.unshift(E):f.push(E),u.value=f}function lt(E,b){E&&(m.value={...m.value,[E]:Tr(b)})}function L(E){return E?`${s}/api/tasks/${E}/raw`:`${s}/api/tasks/`}function N(E=""){const b=String(E||"").trim();if(!b)return;const V=it(b),f=r.getTaskRunChange(b);if(!V||!(f!=null&&f.status))return;const x=Qv(f.status);!!V.running!==x&&ct({...V,running:x})}function ne(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function xe(E=""){return $a(E,g.value,ne())}function Fe(E=""){C.value=Pa(C.value,E)}function Pe(){C.value=ty(C.value,{currentTaskSlug:g.value,pageFocused:ne()})}function Ye(E=[]){C.value=ny(C.value,E),v.value=sy(v.value,E)}function tt(E=""){const b=String(E||"").trim();if(!b)return;const V=oy({unreadMap:C.value,notifiedMap:v.value,taskSlug:b,change:r.getTaskRunChange(b),currentTaskSlug:g.value,pageFocused:ne(),maxNotifiedRuns:Ks});C.value=V.unreadMap,v.value=V.notifiedMap,V.didMark&&(W.value+=1)}function bt(E,b){c.value={...c.value,[E]:!!b}}function ft(E=u.value){const b={};(E||[]).forEach(V=>{V!=null&&V.slug&&(b[V.slug]=!!V.running)}),c.value=b}function kt(E,b){E&&(k.value={...k.value,[E]:String(b||"").trim()})}async function vt(E,b){const V=String(E||"").trim();if(!V)return;const f=String(b||"").trim(),x=it(V),w=k.value[V]||(x==null?void 0:x.codexSessionId)||"";if(!!(w&&Number((x==null?void 0:x.codexRunCount)||0)>0)&&f!==w){R.value=Ge("taskActions.sessionLocked");return}kt(V,f);const Ce=gt(V);Ce&&lt(V,{...Ce,codexSessionId:f}),x&&ct({...x,codexSessionId:f,workspaceDiffSummary:f&&f===w?x.workspaceDiffSummary:null}),V===g.value&&(p.value={...p.value,codexSessionId:f});try{await hl(V,f)}catch($t){kt(V,w),Ce&&lt(V,{...Ce,codexSessionId:w}),x&&ct({...x,codexSessionId:w}),V===g.value&&(p.value={...p.value,codexSessionId:w}),R.value=$t.message}}function At(){Y&&(window.clearTimeout(Y),Y=null)}function Gt(){D&&(window.clearTimeout(D),D=null)}function Kt(){At(),!(Z.value||!g.value)&&(Y=window.setTimeout(()=>{Ft({auto:!0,silent:!0})},1500))}function se(){if(!g.value)return;const E=it(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};ct({...E,title:String(p.value.title||""),autoTitle:String(p.value.autoTitle||""),lastPromptPreview:String(p.value.lastPromptPreview||""),todoCount:jt(p.value.todoItems).length,codexSessionId:Re.value,preview:String(p.value.lastPromptPreview||"")})}function Be(E={}){const b=String((E==null?void 0:E.slug)||"").trim();if(!b)return;const V=jn(E);ct(V),ht(b,V.updatedAt||E.updatedAt||""),b===g.value&&(Object.prototype.hasOwnProperty.call(E,"title")&&(p.value.title=String(E.title||"")),Object.prototype.hasOwnProperty.call(E,"autoTitle")&&(p.value.autoTitle=String(E.autoTitle||"")),lt(b,{...p.value}))}function st(E=[]){const b=new Map((E||[]).map(V=>{const f=String((V==null?void 0:V.slug)||"").trim();return f?[f,Ws(V.workspaceDiffSummary)]:null}).filter(Boolean));b.size&&(u.value=u.value.map(V=>b.has(V.slug)?{...V,workspaceDiffSummary:b.get(V.slug)}:V))}async function Xe(E=u.value){const b=Array.isArray(E)?E:[],V=b.filter(x=>String((x==null?void 0:x.codexSessionId)||"").trim()),f=++ee;if(!V.length){u.value=b.map(x=>Object.prototype.hasOwnProperty.call(x,"workspaceDiffSummary")?x:{...x,workspaceDiffSummary:null});return}try{const x=await Zi({limit:b.length||30,slugs:V.map(w=>w.slug)});if(f!==ee)return;st(x.items||[])}catch{}}function Dt(E=""){const b=String(E||"").trim();if(!b)return;const V=r.getTaskRunChange(b),x=u.value.find(w=>w.slug===b);Zv(x,V)&&(Q.add(b),ae&&window.clearTimeout(ae),ae=window.setTimeout(()=>{ae=null;const w=new Set(Q);Q.clear();const ie=u.value.filter(Ce=>w.has(Ce.slug));Xe(ie)},Kv))}async function H(E={}){const{silent:b=!1}=E;b||(P.value=!0,R.value="");try{const V=u.value,f=await Qi(),x=Ar(V,(f.items||[]).map(jn));u.value=x,Ye(x),ft(x),ay(V,x)&&Xe(x)}catch(V){b||(R.value=V.message)}finally{b||(P.value=!1)}}async function J(E=[]){const b=ry(u.value,E),V=u.value.map(w=>String((w==null?void 0:w.slug)||"").trim()).filter(Boolean),f=b.map(w=>String((w==null?void 0:w.slug)||"").trim()).filter(Boolean);if(!f.length||f.join(",")===V.join(","))return!1;const x=u.value;u.value=b;try{const w=await tl(f);I=Date.now()+qv;const ie=Ar(x,(w.items||[]).map(jn));return u.value=ie,Ye(ie),ft(ie),!0}catch(w){return u.value=x,R.value=w.message,!1}}async function ue(E=""){const b=String(g.value||"").trim(),V=String(E||"").trim();if(!b)return;if(!u.value.some(x=>x.slug===b)){if(u.value.length){await pt(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",As(""),p.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Ie("","","",[],"",[]),te.value=!1;return}V&&V!==b||V&&(Ke()||mt()||te.value||K.value||j.value||Z.value||await pt(b,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function ve(E=""){const b=String(E||"").trim();ge===null?ge=b:ge!==b&&(ge=""),!D&&(D=window.setTimeout(async()=>{const V=ge;ge=null,D=null,await H({silent:!0}),await ue(V||"")},Hv))}async function Ue(E){const b=await zr(E),V=(b.blocks||[]).map(x=>({...x,content:x.type==="image"?$s(x.content):x.content}));return{state:{title:String(b.title||""),autoTitle:String(b.autoTitle||""),lastPromptPreview:String(b.lastPromptPreview||""),codexSessionId:String(b.codexSessionId||""),blocks:V,todoItems:jt(b.todoItems||[])},summary:jn({...b,blocks:V}),updatedAt:String(b.updatedAt||"")}}async function pt(E,b={}){const{focusEditor:V=!1,force:f=!1,skipIfDirtyOnApply:x=!1,skipIfEditingOnApply:w=!1,scrollPanelToBottom:ie=!1}=b,Ce=String(E||"").trim();if(!Ce)return!1;const $t=++me;Z.value=!0,R.value="",t();try{const Vt=String(g.value||"").trim(),nn=gt(Ce),un=f&&nn&&Oe(Ce);let St=f&&!un?null:nn,zt=null;if(!St){const wt=await Ue(Ce);St=(wt==null?void 0:wt.state)||null,zt=(wt==null?void 0:wt.summary)||null,ht(Ce,(wt==null?void 0:wt.updatedAt)||(zt==null?void 0:zt.updatedAt)||"")}return $t!==me||x&&Ce===g.value&&(mt()||te.value)||w&&Ce===g.value&&Ke()?!1:(g.value=Ce,As(Ce),xe(Ce)&&Fe(Ce),p.value=Tr(St),lt(Ce,St),zt&&ct(zt),kt(Ce,St.codexSessionId),A.value=Ie(p.value.title,p.value.autoTitle,p.value.lastPromptPreview,p.value.todoItems,p.value.codexSessionId,p.value.blocks),te.value=!1,V&&at(()=>{var wt,vn;return(vn=(wt=l.value)==null?void 0:wt.focusEditor)==null?void 0:vn.call(wt)}),(ie||Ce!==Vt)&&o(),!0)}catch(Vt){return $t===me&&(R.value=Vt.message),!1}finally{$t===me&&(Z.value=!1)}}async function Ft(E={}){const{auto:b=!1,silent:V=!1}=E;return g.value?Ie()===A.value?!0:fe||(At(),K.value=!0,R.value="",fe=(async()=>{try{const x=await Hr(g.value,{title:String(p.value.title||""),autoTitle:String(p.value.autoTitle||""),lastPromptPreview:String(p.value.lastPromptPreview||""),todoItems:jt(p.value.todoItems),codexSessionId:Re.value,expiry:"none",visibility:"private",blocks:De(p.value.blocks)}),w={title:String(x.title||""),autoTitle:String(x.autoTitle||""),lastPromptPreview:String(x.lastPromptPreview||""),todoItems:jt(x.todoItems||p.value.todoItems||[]),codexSessionId:Re.value||String(x.codexSessionId||"").trim(),blocks:xn(p.value.blocks)};return lt(g.value,w),A.value=Ie(w.title,w.autoTitle,w.lastPromptPreview,w.todoItems,w.codexSessionId,w.blocks),te.value=!1,ct(jn(x)),ht(g.value,x.updatedAt||""),!b&&!V&&n({message:Ge("taskActions.taskSaved"),type:"success"}),!0}catch(x){return R.value=x.message,!1}finally{K.value=!1,fe=null,Ie()!==A.value&&(te.value=!0,Kt())}})(),fe):!1}async function Ut(){return j.value?(R.value=Ge("taskActions.fileProcessing"),!1):fe||(te.value?Ft({auto:!1,silent:!0}):!0)}async function It(){if(!await Ut()&&g.value)return!1;S.value=!0,R.value="";try{const E=await el({title:"",expiry:"none",visibility:"private"}),b={title:String(E.title||""),autoTitle:String(E.autoTitle||""),lastPromptPreview:String(E.lastPromptPreview||""),codexSessionId:String(E.codexSessionId||""),blocks:xn(E.blocks||[]),todoItems:jt(E.todoItems||[])};return lt(E.slug,b),ct(jn(E),{insertAtStart:!0}),await pt(E.slug,{focusEditor:!0}),n({message:Ge("taskActions.taskCreated"),type:"success"}),!0}catch(E){return R.value=E.message,!1}finally{S.value=!1}}async function Lt(E){const b=String(E||"").trim();!b||b===g.value||!await Ut()||await pt(b)}async function mn(){if(g.value){B.value=!0,R.value="";try{const E=g.value;await nl(E),u.value=u.value.filter(x=>x.slug!==E);const b={...m.value};delete b[E],m.value=b;const V={...k.value};delete V[E],k.value=V;const f={...c.value};delete f[E],c.value=f,Fe(E),u.value.length?await pt(u.value[0].slug,{focusEditor:!0}):(g.value="",As(""),p.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Ie("","","",[],"",[]),te.value=!1,await It())}catch(E){R.value=E.message}finally{B.value=!1}}}function Tt(E={}){const{silent:b=!1}=E;g.value&&(p.value={...p.value,blocks:_r()},lt(g.value,p.value),se(),te.value=!0,at(()=>{var V,f;(f=(V=l.value)==null?void 0:V.focusEditor)==null||f.call(V)}),b||n({message:Ge("taskActions.taskCleared"),type:"info"}))}function tn(){if(!g.value)return!1;const E=Aa(p.value.blocks);return E.length?(p.value={...p.value,blocks:_r(),todoItems:[{id:Xv(),createdAt:new Date().toISOString(),blocks:E},...jt(p.value.todoItems)]},lt(g.value,p.value),se(),te.value=!0,at(()=>{var b,V;(V=(b=l.value)==null?void 0:b.focusEditor)==null||V.call(b)}),n({message:Ge("taskActions.todoAdded"),type:"success"}),!0):!1}function gn(E=""){const b=String(E||"").trim();if(!g.value||!b)return!1;const V=jt(p.value.todoItems).filter(f=>f.id!==b);return V.length===jt(p.value.todoItems).length?!1:(p.value={...p.value,todoItems:V},lt(g.value,p.value),se(),te.value=!0,!0)}function Mt(E=""){const b=String(E||"").trim();if(!g.value||!b)return null;const V=jt(p.value.todoItems).find(f=>f.id===b);return V?(p.value={...p.value,blocks:xn(V.blocks),todoItems:jt(p.value.todoItems).filter(f=>f.id!==b)},lt(g.value,p.value),se(),te.value=!0,at(()=>{var f,x;(x=(f=l.value)==null?void 0:f.focusEditor)==null||x.call(f)}),V):null}async function Xt(){var x;if(await H(),!u.value.length){await It();return}const E=ly();if(E){const w=await pt(E,{focusEditor:!0,force:!0});if(uy(),w)return}const b=((x=u.value.find(w=>!!(w!=null&&w.running)))==null?void 0:x.slug)||"",V=iy(),f=b||(u.value.some(w=>w.slug===V)?V:u.value[0].slug);await pt(f,{focusEditor:!0,force:!0})}async function _t(E){var b,V,f;j.value=!0,R.value="";try{const x=((V=(b=l.value)==null?void 0:b.isImportedBlockActive)==null?void 0:V.call(b))||!1,w=[];for(const ie of E){const Ce=await sl(ie);w.push({type:"image",content:$s(Ce.url),meta:{}})}(f=l.value)==null||f.insertUploadedBlocks(w),n({message:Ge("taskActions.imageInserted",{count:w.length,appended:x}),type:"success"})}catch(x){R.value=x.message}finally{j.value=!1}}async function kn(E){var b,V,f;R.value="";try{const x=((V=(b=l.value)==null?void 0:b.isImportedBlockActive)==null?void 0:V.call(b))||!1,w=[];for(const ie of E){const Ce=await ie.text();Ce.trim()&&w.push({type:"imported_text",content:Ce,meta:{fileName:ie.name||Ge("workbench.untitledTask"),collapsed:!0}})}if(!w.length){n({message:Ge("taskActions.noTextImported"),type:"warning"});return}(f=l.value)==null||f.insertImportedBlocks(w),n({message:Ge("taskActions.importedBlocksInserted",{count:w.length,appended:x}),type:"success"})}catch{R.value=Ge("taskActions.textImportFailed")}}async function on(E){var b;j.value=!0,R.value="";try{let V=0,f=0;for(const x of E){const w=await ol(x),ie=(w.blocks||[]).map(Ce=>({...Ce,content:Ce.type==="image"?$s(Ce.content):Ce.content}));ie.length&&((b=l.value)==null||b.insertBlocks(ie),V+=ie.length,f+=Number(w.pageCount||0))}if(!V){n({message:Ge("taskActions.noPdfContent"),type:"warning"});return}n({message:Ge("taskActions.pdfBlocksInserted",{blockCount:V,pageCount:f}),type:"success"})}catch(V){R.value=V.message||Ge("taskActions.pdfImportFailed")}finally{j.value=!1}}function rn(E){const b=E===g.value?p.value:gt(E);return b?zv({title:String(b.title||""),blocks:De(b.blocks||[])},L(E)):""}function an(E){const b=E===g.value?p.value:gt(E);return b?xn(De(b.blocks||[])):[]}async function ln(E){return j.value?(R.value=Ge("taskActions.fileProcessingBeforeSend"),!1):E!==g.value?!0:K.value&&fe?fe:te.value?Ft({auto:!1,silent:!0}):!0}async function hn(E){return await ln(E)?rn(E):""}function Yt(E,b){const V=Er(b);!V||E!==g.value||(p.value.lastPromptPreview=V,lt(g.value,p.value),se())}return Ae(p,()=>{if(Z.value||!g.value)return;const E=$o(p.value.blocks);!String(p.value.title||"").trim()&&E&&E!==p.value.autoTitle&&(p.value.autoTitle=E),lt(g.value,p.value),te.value=Ie()!==A.value,se(),te.value&&!K.value&&Kt()},{deep:!0}),Ae(g,E=>{E&&(As(E),Pe())}),pn(()=>{typeof window>"u"||(window.addEventListener("focus",Pe),document.addEventListener("visibilitychange",Pe))}),Rt(()=>{At(),Gt(),ae&&(window.clearTimeout(ae),ae=null),Q.clear(),typeof window<"u"&&(window.removeEventListener("focus",Pe),document.removeEventListener("visibilitychange",Pe))}),Ae(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<I||(tt(r.listSyncTaskSlug.value),N(r.listSyncTaskSlug.value),Dt(r.listSyncTaskSlug.value),ve(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:tn,applyTaskSettingsUpdate:Be,buildPromptForTask:rn,getPromptBlocksForTask:an,buildPromptPreview:Er,clearCurrentTaskContent:Tt,createTaskAndSelect:It,currentProjectSessionId:Re,currentTaskSendState:Ne,currentTaskAutoTitle:$,currentTaskDisplayTitle:Te,currentTaskSlug:g,draft:p,editorRef:l,error:R,handleImportPdfFiles:on,handleImportTextFiles:kn,handleTaskSendingChange:bt,handleTaskSessionChange:vt,handleUpload:_t,hasCurrentDraftContent:oe,hasAnyTaskSending:We,hasUnsavedChanges:te,hasUnreadTaskUpdates:ke,initializeWorkbench:Xt,isCurrentTaskSending:Ve,loadingTask:Z,loadingTasks:P,pageTitle:$e,prepareCodexPromptForTask:hn,currentTodoItems:ce,removeTodoItem:gn,removeCurrentTask:mn,reorderTaskList:J,removingTask:B,renderedTasks:he,refreshTaskList:H,saveTask:Ft,saving:K,selectTask:Lt,selectedSessionMap:k,sendingTaskMap:c,taskDraftMap:m,tasks:u,unreadNotificationVersion:W,useTodoItem:Mt,updateLastPromptPreview:Yt,uploading:j,creatingTask:S}}const dy={class:"flex h-full min-h-0 flex-col overflow-hidden"},fy={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"},py={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},my={class:"min-h-0 min-w-0 overflow-hidden"},gy={class:"min-h-0 min-w-0 overflow-hidden"},hy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},vy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},yy={class:"flex flex-col gap-2"},Sy={class:"min-h-0 flex-1 overflow-hidden"},wy={key:1,class:"min-h-0 flex-1 overflow-hidden"},xy={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},by={class:"workbench-mobile-tabs-panel shrink-0"},ky={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Ty={class:"min-h-0 flex-1 overflow-hidden"},_y={class:"h-full min-h-0"},Cy={class:"h-full min-h-0"},Ey={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Ay={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},Iy={class:"flex flex-col gap-2"},$y={class:"min-h-0 flex-1 overflow-hidden"},Py="/sounds/notify-didi.wav?v=20260420-1",Dy=3e3,Ir="promptx:selected-agent-engine-map",Ly={__name:"WorkbenchView",setup(e){const t=z(!1),n=z(!1),o=z(!1),s=z(!1),r=z(!1),l=z(!1),u=z(!1),m=z(!1),k=z(""),c=z(""),C=z(""),v=z(0),g=z("workspace"),p=z(""),{t:P}=Et(),{toastMessage:Z,toastType:S,flashToast:B,clearToast:K}=Fv(),{notificationSoundEnabled:j,sendBehavior:R}=Ba(),te=xo(()=>qe(()=>import("./TaskDiffReviewDialog-CTr_zoAn.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),A=xo(()=>qe(()=>import("./WorkbenchSettingsDialog-Bf2DCuN_.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),Y=z(null),fe=z([]);function me(){try{const y=JSON.parse(window.localStorage.getItem(Ir)||"{}");if(y&&typeof y=="object"&&!Array.isArray(y))return y}catch{}return{}}function D(y){window.localStorage.setItem(Ir,JSON.stringify(y))}const ee=z(me());let ae=null,Q=!1,ge=0;function I(y="",q=fe.value){const ye=String(y||"").trim();return ye&&q.some(Se=>(Se==null?void 0:Se.engine)===ye)?ye:""}function X(y=fe.value){var q,ye;return((q=y.find(Se=>Se==null?void 0:Se.isDefault))==null?void 0:q.engine)||((ye=y[0])==null?void 0:ye.engine)||""}const $=G({get(){const y=String(pe.value||"").trim();if(!y)return"";const q=String(ee.value[y]||"").trim();return q||X()},set(y){const q=String(pe.value||"").trim(),ye=String(y||"").trim();!q||!ye||(ee.value={...ee.value,[q]:ye},D(ee.value))}});function Te(y){return y?Y.value:null}function Me(){at(()=>{var y,q;(q=(y=Te(pe.value))==null?void 0:y.scrollToBottom)==null||q.call(y)})}const{addCurrentDraftToTodo:Re,applyTaskSettingsUpdate:Ne,buildPromptForTask:Ve,getPromptBlocksForTask:We,clearCurrentTaskContent:ke,createTaskAndSelect:W,creatingTask:oe,currentProjectSessionId:ce,currentTaskSendState:$e,currentTaskAutoTitle:he,currentTaskDisplayTitle:Le,currentTaskSlug:pe,draft:De,editorRef:ze,error:Ie,handleImportPdfFiles:mt,handleImportTextFiles:Ke,handleTaskSendingChange:it,handleTaskSessionChange:gt,handleUpload:ht,hasCurrentDraftContent:Oe,hasUnsavedChanges:_e,hasUnreadTaskUpdates:ct,initializeWorkbench:lt,isCurrentTaskSending:L,loadingTask:N,loadingTasks:ne,pageTitle:xe,prepareCodexPromptForTask:Fe,currentTodoItems:Pe,removeTodoItem:Ye,removeCurrentTask:tt,reorderTaskList:bt,removingTask:ft,renderedTasks:kt,saveTask:vt,saving:At,selectTask:Gt,unreadNotificationVersion:Kt,updateLastPromptPreview:se,useTodoItem:Be,uploading:st}=cy({clearToast:K,flashToast:B,scrollCurrentPanelToBottom:Me}),Xe=G(()=>kt.value.find(y=>y.slug===pe.value)||null),Dt=G(()=>ct.value?P("workbench.newMessageTitle"):xe.value),H=G(()=>ct.value),J=G(()=>{var y,q;return!!((q=(y=Xe.value)==null?void 0:y.workspaceDiffSummary)!=null&&q.supported)}),ue=G(()=>{const y=Xe.value;return y?()=>Fe(y.slug):null}),ve=G(()=>{const y=Xe.value;return y?()=>We(y.slug):null}),Ue=G(()=>({creatingTask:oe.value,currentTaskAutoTitle:De.value.autoTitle||he.value,currentTaskSlug:pe.value,draftTitle:De.value.title,editingTaskTitleSlug:C.value,error:Ie.value,isCurrentTaskSending:L.value,loadingTask:N.value,loadingTasks:ne.value,removingTask:ft.value,tasks:kt.value,uploading:st.value})),pt=G(()=>{var y,q,ye,Se;return{buildPromptBlocks:ve.value,buildPrompt:ue.value,diffSupported:J.value,selectedAgentEngine:$.value,selectedSessionId:ce.value,sessionSelectionLockReason:((y=Xe.value)==null?void 0:y.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((q=Xe.value)!=null&&q.sessionSelectionLocked),taskSlug:((ye=Xe.value)==null?void 0:ye.slug)||"",taskRunning:!!((Se=Xe.value)!=null&&Se.running)}}),Ft=G(()=>({codexSessionId:ce.value,sendBehavior:R.value,loading:N.value})),Ut=G(()=>({currentTaskAutoTitle:De.value.autoTitle||he.value,currentTaskSlug:pe.value,editingTaskTitleSlug:C.value,title:Le.value,titleInputValue:De.value.title})),{enterMobileDetail:It,isMobileLayout:Lt,leaveMobileDetail:mn,mobileDetailTab:Tt,mobileView:tn}=Bv({currentTaskSlug:pe});function gn(y){return y!=null&&y.sending||Number((y==null?void 0:y.codexRunCount)||0)>0?"activity":"input"}Nv(Dt,{raw:H});function Mt(){return typeof window>"u"?null:(ae||(ae=new Audio(Py),ae.preload="auto",ae.volume=.7),ae)}function Xt(){if(!j.value)return;const y=Mt();if(!(!y||Q))try{y.muted=!0;const q=y.play();if(q&&typeof q.then=="function"){q.then(()=>{y.pause(),y.currentTime=0,y.muted=!1,Q=!0}).catch(()=>{y.muted=!1});return}y.pause(),y.currentTime=0,y.muted=!1,Q=!0}catch{y.muted=!1}}function _t(){Xt()}function kn(){const y=Mt();if(!y||!j.value)return;const q=Date.now();if(!(q-ge<Dy)){ge=q;try{y.muted=!1,y.currentTime=0,y.play().catch(()=>{})}catch{}}}function on(y="workspace",q=""){g.value=y==="run"?"run":y==="task"?"task":"workspace",p.value=g.value==="run"?String(q||""):"",o.value=!0,v.value+=1}function rn(){o.value=!1}function an(){s.value=!0}function ln(){s.value=!1}function hn(){pe.value&&(r.value=!0)}function Yt(){r.value=!1}function E(){l.value=!0}function b(){l.value=!1,V(),f()}function V(){u.value=!1,k.value=""}function f(){m.value=!1,c.value=""}function x(y){Ne(y)}function w(y){De.value.title=y}async function ie(){C.value="",_e.value&&await vt({auto:!1,silent:!0})}function Ce(y){y===pe.value&&(C.value=y,at(()=>{var ye,Se;const q=document.querySelector('[data-task-title-input="current"]');(ye=q==null?void 0:q.focus)==null||ye.call(q),(Se=q==null?void 0:q.select)==null||Se.call(q)}))}async function $t(y){if(Lt.value){await Fn(y);return}if(y!==pe.value){await Fn(y);return}Ce(y)}function Vt(){n.value=!0}function nn(){ft.value||(n.value=!1)}async function un(){await tt(),n.value=!1,Lt.value&&mn({useHistory:!1})}function St(){t.value=!0}function zt(){t.value=!1}function wt(){t.value=!1,ke()}function vn(y){const q=Xe.value;q&&it(q.slug,y)}function Jt(y){const q=Xe.value;q&&gt(q.slug,y)}function Zs(y={}){const q=String((y==null?void 0:y.sessionId)||"").trim(),ye=ce.value;if(q&&q!==ye)return;const Se=Array.isArray(y==null?void 0:y.bindings)?y.bindings:[];fe.value=Se;const Je=String(pe.value||"").trim();if(!Je)return;const nt=String(ee.value[Je]||"").trim();if(nt&&Se.some(Ht=>(Ht==null?void 0:Ht.engine)===nt)){$.value!==nt&&($.value=nt);return}const Ct=I(y==null?void 0:y.selectedEngine,Se)||X(Se);Ct&&$.value!==Ct&&($.value=Ct)}Ae(ce,(y,q)=>{String(y||"").trim()!==String(q||"").trim()&&(fe.value=[])});function Nn(y){$.value=y}function On(y){B(y),!(!Lt.value||!pe.value)&&(Tt.value="activity")}async function Qt(){var y,q,ye,Se,Je,nt,Ct,Ht;typeof document<"u"&&((q=(y=ze.value)==null?void 0:y.isComposing)!=null&&q.call(y))&&((Se=(ye=document.activeElement)==null?void 0:ye.blur)==null||Se.call(ye)),(nt=(Je=ze.value)==null?void 0:Je.flushPendingInput)==null||nt.call(Je),await at(),(Ht=(Ct=ze.value)==null?void 0:Ct.flushPendingInput)==null||Ht.call(Ct),await at()}async function ws(){await Qt(),await navigator.clipboard.writeText(Ve(pe.value)),B({message:P("workbench.promptCopied"),type:"info"})}async function eo(){await W()&&Lt.value&&(Tt.value="input",It())}async function Fn(y){const q=String(y||"").trim();q&&(q!==pe.value&&await Gt(q),Lt.value&&pe.value===q&&(Tt.value=gn(Xe.value),It()))}async function to(y=[]){await bt(y)}async function Tn(){await Qt(),Re()}function Zn(y={}){const q=String((y==null?void 0:y.rangeLabel)||"").trim();if(q)return q;const ye=Math.max(0,Number(y==null?void 0:y.lineStart)||0),Se=Math.max(0,Number(y==null?void 0:y.lineEnd)||0);return ye&&Se&&ye!==Se?`L${ye}-L${Se}`:ye||Se?`L${ye||Se}`:""}function es(y=""){return`code-context-${String(y||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function _n(y={}){const q=String((y==null?void 0:y.filePath)||"").trim(),ye=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
58
+ `).trimEnd();if(!q||!ye.trim())return null;const Se=String((y==null?void 0:y.language)||"").trim(),Je=Zn(y),nt=String((y==null?void 0:y.source)||"").trim()==="diff"?P("workbench.codeContextSourceDiff"):P("workbench.codeContextSourceFile"),Ct=Se?`\`\`\`${Se}`:"```",Ht=[P("workbench.codeContextTitle"),P("workbench.codeContextFile",{path:q}),Je?P("workbench.codeContextRange",{range:Je}):"",P("workbench.codeContextSource",{source:nt}),"",Ct,ye,"```"].filter(bs=>bs!=="");return{type:Bt.IMPORTED_TEXT,content:Ht.join(`
59
+ `),meta:{fileName:es(q),collapsed:!1}}}async function xs(y=[],q="insertBlocks"){var Se,Je,nt,Ct;const ye=Array.isArray(y)?y.filter(Boolean):[];return ye.length?(await Qt(),(Je=(Se=ze.value)==null?void 0:Se[q])==null||Je.call(Se,ye),await at(),(Ct=(nt=ze.value)==null?void 0:nt.focusEditor)==null||Ct.call(nt),Lt.value&&pe.value&&(Tt.value="input"),B({message:P("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function ts(y={}){const q=String((y==null?void 0:y.source)||"").trim(),ye=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
60
+ `).trim();if(q==="response"){if(!ye)return;await xs([zn(ye)],"insertBlocks");return}const Se=_n(y);Se&&await xs([Se],"insertImportedBlocks")}function Cn(y){k.value=String(y||"").trim(),u.value=!!k.value}function no(){k.value&&(Ye(k.value),V())}async function ns(y=c.value){const q=String(y||"").trim();return!q||!Be(q)?!1:(f(),b(),!0)}async function so(y){await Qt();const q=String(y||"").trim();if(q){if(!Oe.value){await ns(q);return}c.value=q,m.value=!0}}async function ss(){var Se,Je,nt,Ct;const y=pe.value;if(!y)return;const q=!!((Je=(Se=Xe.value)==null?void 0:Se.automation)!=null&&Je.enabled);await Qt(),se(y,Ve(y)),!(!await((Ct=(nt=Te(y))==null?void 0:nt.send)==null?void 0:Ct.call(nt))||y!==pe.value)&&(Lt.value&&(Tt.value="activity"),q||ke({silent:!0}),await vt({auto:!1,silent:!0}))}function d(){!Lt.value||tn.value!=="detail"||Tt.value!=="input"||!pe.value||at(()=>{var y,q;(q=(y=ze.value)==null?void 0:y.focusEditor)==null||q.call(y)})}function M(y){!_e.value&&!st.value&&!At.value||(y.preventDefault(),y.returnValue="")}function U(){var y,q;return m.value?(f(),!0):u.value?(V(),!0):t.value?(zt(),!0):n.value?(nn(),!0):r.value?(Yt(),!0):l.value?(b(),!0):o.value?(rn(),!0):s.value?(ln(),!0):!!((q=(y=Te(pe.value))==null?void 0:y.closeTopDialog)!=null&&q.call(y))}function F(y){var Je,nt,Ct,Ht,bs;const q=String(y.key||""),ye=q.toLowerCase(),Se=y.metaKey||y.ctrlKey;if(q==="Escape"){U()&&(y.preventDefault(),(Je=y.stopImmediatePropagation)==null||Je.call(y));return}if(Se){if(ye==="s"){y.preventDefault(),vt({auto:!1});return}if(y.shiftKey&&q==="Backspace"){y.preventDefault(),St();return}if(!y.isComposing){if(y.shiftKey&&y.code==="Comma"){y.preventDefault(),an();return}if(y.shiftKey&&ye==="k"){y.preventDefault(),(Ct=(nt=Te(pe.value))==null?void 0:nt.openProjectManager)==null||Ct.call(nt);return}if(y.shiftKey&&ye==="o"){y.preventDefault(),(bs=(Ht=Te(pe.value))==null?void 0:Ht.openSourceBrowser)==null||bs.call(Ht);return}y.shiftKey&&ye==="d"&&(y.preventDefault(),J.value&&on("workspace"))}}}pn(()=>{lt(),window.addEventListener("beforeunload",M),window.addEventListener("keydown",F),window.addEventListener("pointerdown",_t,{passive:!0})}),Rt(()=>{window.removeEventListener("beforeunload",M),window.removeEventListener("keydown",F),window.removeEventListener("pointerdown",_t)}),Ae([Lt,tn,Tt,pe],([y,q,ye,Se])=>{!y||q!=="detail"||ye!=="input"||!Se||d()}),Ae(Kt,(y,q)=>{Number(y)<=Number(q||0)||kn()});const re={"update:draftTitle":w,"cancel-title-edit":()=>{C.value=""},"create-task":eo,"edit-task":hn,"delete-task":Vt,"open-settings":an,"reorder-task":to,"select-task":Fn,"title-blur":ie,"title-click":$t},be={"agent-bindings-change":Zs,"insert-code-context":ts,"open-diff":({scope:y,runId:q})=>on(y,q),"project-created":()=>B({message:P("workbench.projectCreated"),type:"success"}),"selected-session-change":Jt,"update:selectedAgentEngine":Nn,"sending-change":vn,toast:On},He={"clear-request":St,"file-feedback":y=>B({message:y,type:"warning"}),"import-pdf-files":mt,"import-text-files":Ke,"send-request":ss,"upload-files":ht},je={"begin-edit":()=>Ce(pe.value),back:mn,"cancel-title-edit":()=>{C.value=""},"title-blur":ie,"update:titleInputValue":w};return(y,q)=>(h(),_("div",dy,[le(Dv,{message:a(Z),type:a(S)},null,8,["message","type"]),le(ks,{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:zt,onConfirm:wt},null,8,["open","title","description","confirm-text","cancel-text"]),le(ks,{open:n.value,title:a(P)("workbench.confirmDeleteTitle"),description:a(P)("workbench.confirmDeleteDescription",{title:a(Le)}),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),loading:a(ft),danger:"",onCancel:nn,onConfirm:un},null,8,["open","title","description","confirm-text","cancel-text","loading"]),le(ks,{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:V,onConfirm:no},null,8,["open","title","description","confirm-text","cancel-text"]),le(ks,{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:f,onConfirm:q[0]||(q[0]=ye=>ns())},null,8,["open","title","description","confirm-text","cancel-text"]),le($v,{open:l.value,items:a(Pe),onClose:b,onDelete:Cn,onUse:so},null,8,["open","items"]),le(a(te),{open:o.value,"task-slug":a(pe),"task-title":a(Le),"preferred-scope":g.value,"preferred-run-id":p.value,"focus-token":v.value,onInsertCodeContext:ts,onClose:rn},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),le(a(A),{open:s.value,onClose:ln},null,8,["open"]),le(Nu,{open:r.value,"task-slug":a(pe),"task-title":a(Le),onClose:Yt,onSaved:x},null,8,["open","task-slug","task-title"]),a(Lt)?(h(),_("div",wy,[a(tn)==="tasks"?(h(),Ee(kr,En({key:0},Ue.value,{mobile:""},An(re)),null,16)):(h(),_("div",xy,[le(Eh,En(Ut.value,An(je)),null,16),i("section",by,[i("div",ky,[i("button",{type:"button",class:we(["tool-button px-3 py-1.5 text-sm",a(Tt)==="activity"?"tool-button-accent-subtle":""]),onClick:q[3]||(q[3]=ye=>Tt.value="activity")},T(a(P)("workbench.activity")),3),i("button",{type:"button",class:we(["tool-button px-3 py-1.5 text-sm",a(Tt)==="input"?"tool-button-accent-subtle":""]),onClick:q[4]||(q[4]=ye=>Tt.value="input")},T(a(P)("workbench.input")),3)])]),i("div",Ty,[Zt(i("div",_y,[le(hr,En({ref_key:"codexPanelRef",ref:Y},pt.value,{"empty-message":a(P)("workbench.selectTask")},An(be)),null,16,["empty-message"])],512),[[Os,a(Tt)==="activity"]]),Zt(i("div",Cy,[i("div",Ey,[i("div",Ay,[i("div",Iy,[le(yr,{"can-add-todo":a(Oe),"is-current-task-sending":a(L),"send-state":a($e),"todo-count":a(Pe).length,uploading:a(st),onAddTodo:Tn,onOpenFilePicker:q[5]||(q[5]=ye=>{var Se,Je;return(Je=(Se=a(ze))==null?void 0:Se.openFilePicker)==null?void 0:Je.call(Se)}),onClearRequest:St,onCopyRequest:ws,onManageTodo:E,onSendRequest:ss},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),le(vr,{"agent-bindings":fe.value,"selected-agent-engine":$.value,"onUpdate:selectedAgentEngine":Nn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",$y,[le(br,En({ref_key:"editorRef",ref:ze,modelValue:a(De).blocks,"onUpdate:modelValue":q[6]||(q[6]=ye=>a(De).blocks=ye)},Ft.value,An(He)),null,16,["modelValue"])])])],512),[[Os,a(Tt)==="input"]])])]))])):(h(),_("div",fy,[le(kr,En(Ue.value,An(re)),null,16),i("div",py,[i("div",my,[Xe.value?(h(),Ee(hr,En({key:0,ref_key:"codexPanelRef",ref:Y},pt.value,An(be)),null,16)):de("",!0)]),i("div",gy,[i("div",hy,[i("div",vy,[i("div",yy,[le(yr,{"can-add-todo":a(Oe),"is-current-task-sending":a(L),"send-state":a($e),"todo-count":a(Pe).length,uploading:a(st),onAddTodo:Tn,onOpenFilePicker:q[1]||(q[1]=ye=>{var Se,Je;return(Je=(Se=a(ze))==null?void 0:Se.openFilePicker)==null?void 0:Je.call(Se)}),onClearRequest:St,onCopyRequest:ws,onManageTodo:E,onSendRequest:ss},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),le(vr,{"agent-bindings":fe.value,"selected-agent-engine":$.value,align:"end","onUpdate:selectedAgentEngine":Nn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Sy,[le(br,En({ref_key:"editorRef",ref:ze,modelValue:a(De).blocks,"onUpdate:modelValue":q[2]||(q[2]=ye=>a(De).blocks=ye)},Ft.value,An(He)),null,16,["modelValue"])])])])])]))]))}},Yy=Object.freeze(Object.defineProperty({__proto__:null,default:Ly},Symbol.toStringTag,{value:"Module"}));export{Fy as A,Yy as B,Wy as D,Ps as W,Kr as _,oa as a,qy as b,na as c,dc as d,lc as e,Lv as f,Hy as g,dn as h,Gy as i,Js as j,et as k,vl as l,zi as m,Uy as n,ld as o,ra as p,Vy as q,Xy as r,zy as s,dt as t,fa as u,Fu as v,ks as w,Ky as x,Vs as y,jy as z};