@muyichengshayu/promptx 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-BLuZ5eP1.js","assets/index-DCBAbk14.js","assets/vendor-router-Dn8q3tJM.js","assets/index-CN9-fmBM.css","assets/vendor-ui-BwEQCho1.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-2giXkyWK.js","assets/TaskDiffReviewDialog-hxUGDcmF.css","assets/WorkbenchSettingsDialog-BgRcnWAa.js"])))=>i.map(i=>d[i]);
2
+ import{u as _t,t as Ye,f as Tr,_ as Ke,a as Cr,b as Er,g as qs,s as $a,c as Ia}from"./index-DCBAbk14.js";import{w as Pe,ak as Mt,aD as m,aI as Ee,aG as fe,aJ as st,aE as b,aK as ot,aL as be,aF as i,aM as nn,u as a,aN as me,aO as Ar,aP as fs,c as K,aQ as x,aR as lt,aS as pt,aT as yn,o as cn,aU as Qt,aV as In,b as F,n as ft,aW as Jt,aX as ss,aY as zo,r as ps,aC as Pa,aZ as gn,f as Da,a_ as vo,a$ as Ms,G as La,al as Ma,b0 as bn,b1 as kn}from"./vendor-misc-u-M8sNMf.js";import{X as $r,T as Ba,L as Gt,C as Eo,a as Bs,B as Ho,S as Ra,P as is,b as Ir,c as Na,A as Oa,F as jn,d as Cn,e as Pr,f as Fa,E as Ua,g as ja,h as qo,i as Ao,j as Rs,k as Va,l as za,m as Ha,U as qa,W as Ka,n as Dr,o as Wa,p as Ns,q as Ks,I as Lr,r as Ga,s as Xa,t as Ya,u as Ja,G as Qa,v as Za,w as ei,x as ti,y as ni}from"./vendor-ui-BwEQCho1.js";import{M as Mr}from"./vendor-markdown-9aQhqbjm.js";import{n as $o,N as Br,a as Io,i as si,V as eo,b as Ko,u as oi,c as ri,E as ai}from"./vendor-tiptap-rwYdQb1L.js";const ii="shell",li=new Set(["!","!"]),Wo="text";function _s(e=""){return String(e||"").replace(/\r\n/g,`
3
+ `).trim()}function ui(e=""){const t=String(e||"");return li.has(t.charAt(0))}function ci(e=""){const t=_s(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function di(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(u=>!!_s(u==null?void 0:u.content)),o=n.length>0,s=o?n.filter(u=>String((u==null?void 0:u.type)||"").trim()===Wo).map(u=>_s(u==null?void 0:u.content)).filter(Boolean).join(`
4
+
5
+ `).trim():_s(e==null?void 0:e.prompt);if(!ui(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(p=>String((p==null?void 0:p.type)||"").trim()!==Wo))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=ci(s).slice(1).trim();return l?{mode:ii,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const an={NONE:"none",LATEST:"latest",ALL:"all"};function fi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===an.ALL?an.ALL:n===an.LATEST?an.LATEST:n===an.NONE?an.NONE:t.includeEvents?an.ALL:t.includeLatestEvents?an.LATEST:an.NONE}const zt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function Rr(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?zt.AGENT_EVENT:t}const kt={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"},dt={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"},pi={none:{label:"不过期",hours:null}};Object.entries(pi).map(([e,t])=>({value:e,label:t.label}));const Ts={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode"},Po=[{value:Ts.CODEX,label:"Codex",enabled:!0},{value:Ts.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:Ts.OPENCODE,label:"OpenCode",enabled:!0}],Lt={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},mi=[{value:"local",label:"跟随本机时区"}],gi={SKIP:"skip"},hi=[{value:gi.SKIP,label:"已有运行时跳过本次"}],to={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},vi=[{value:to.DINGTALK,label:"钉钉 Webhook"},{value:to.FEISHU,label:"飞书 Webhook"},{value:to.WEBHOOK,label:"通用 Webhook"}],no={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},yi=[{value:no.COMPLETED,label:"本次运行结束后"},{value:no.SUCCESS,label:"本次运行成功后"},{value:no.ERROR,label:"本次运行失败后"}],Si={SUMMARY:"summary"},wi=[{value:Si.SUMMARY,label:"摘要消息"}],Go={ZH_CN:"zh-CN",EN_US:"en-US"},xi=[{value:Go.ZH_CN,label:"简体中文"},{value:Go.EN_US,label:"English"}];function Os(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Po.find(o=>o.value===t))==null?void 0:n.value)||Ts.CODEX}function gt(e){var t;return((t=Po.find(n=>n.value===Os(e)))==null?void 0:t.label)||"Codex"}function Iy(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 bi(e=[],t=10){const n=e.find(o=>{var s;return(o.type===Lt.TEXT||o.type===Lt.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const ki={class:"min-w-0 flex-1"},_i={key:0,class:"flex items-center gap-2"},Ti=["disabled"],Ws={__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=K(()=>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(p){!n.open||!n.closeOnEscape||n.closeDisabled||p.key==="Escape"&&o("close")}return Pe(()=>n.open,p=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",p),p&&n.closeOnEscape){window.addEventListener("keydown",u);return}window.removeEventListener("keydown",u)},{immediate:!0}),Mt(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",u)}),(p,w)=>(m(),Ee(fs,{to:"body"},[fe(Ar,{name:"dialog-shell"},{default:st(()=>[e.open?(m(),b("div",{key:0,class:be(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:ot(l,["self"])},[i("section",{class:be(["panel dialog-shell-panel flex min-h-0 w-full flex-col overflow-hidden",e.panelClass])},[p.$slots.title||p.$slots.header||p.$slots["header-actions"]||e.showClose?(m(),b("div",{key:0,class:be(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",ki,[nn(p.$slots,"header",{},()=>[nn(p.$slots,"title")])]),p.$slots["header-actions"]||e.showClose?(m(),b("div",_i,[nn(p.$slots,"header-actions"),e.showClose?(m(),b("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[fe(a($r),{class:"h-4 w-4"})],8,Ti)):me("",!0)])):me("",!0)],2)):me("",!0),i("div",{class:be(e.bodyClass)},[nn(p.$slots,"default")],2)],2)],2)):me("",!0)]),_:3})]))}},Ci={class:"flex items-start gap-3"},Ei={class:"theme-heading text-base font-semibold"},Ai={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},$i={class:"flex justify-end gap-2 px-5 py-4"},Ii=["disabled"],Pi=["disabled"],ys={__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}=_t(),r=K(()=>n.title||s("common.confirm")),l=K(()=>n.confirmText||s("common.confirm")),u=K(()=>n.cancelText||s("common.cancel"));return(p,w)=>(m(),Ee(Ws,{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:w[2]||(w[2]=c=>o("cancel"))},{title:st(()=>[i("div",Ci,[i("span",{class:be(["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"])},[fe(a(Ba),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Ei,x(r.value),1),e.description?(m(),b("p",Ai,x(e.description),1)):me("",!0)])])]),default:st(()=>[i("div",$i,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:w[0]||(w[0]=c=>o("cancel"))},x(u.value),9,Ii),i("button",{type:"button",class:be(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:w[1]||(w[1]=c=>o("confirm"))},x(e.loading?a(s)("common.processing"):l.value),11,Pi)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Di={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"},Li={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},Mi=["onClick"],Bi={class:"min-w-0"},Ri={class:"text-sm font-medium"},Ni={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},Oi={__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)=>(m(),b("aside",Di,[i("nav",Li,[(m(!0),b(lt,null,pt(e.sections,l=>(m(),b("button",{key:l.id,type:"button",class:be(["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)},[(m(),Ee(yn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Bi,[i("div",Ri,x(l.label),1),i("p",Ni,x(l.description),1)])],10,Mi))),128))])]))}},Fi=["aria-label","disabled","onKeydown"],Ui={class:"min-w-0 flex-1"},ji={class:"theme-muted-text text-sm"},Vi={class:"flex min-h-0 w-full flex-col"},zi={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Hi=["onClick"],qi={class:"theme-empty-state px-3 py-4 text-sm"},ln={__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}=_t(),r=F(null),l=F(null),u=F(!1),p=F(!1),w=F({}),c=K(()=>{const M=String(n.modelValue??"");return n.options.find(J=>String(n.getOptionValue(J)??"")===M)||null}),y=K(()=>n.placeholder||s("common.select")),h=K(()=>n.emptyText||s("common.noOptions"));function g(M){return M&&typeof M=="object"&&Object.prototype.hasOwnProperty.call(M,"label")?String(M.label||""):String(n.getOptionValue(M)??"")}function f(){n.disabled||(u.value||o("refresh-intent"),u.value=!0)}function P(){u.value=!1}function ee(){if(u.value){P();return}f()}function S(M){o("update:modelValue",String(n.getOptionValue(M)??"").trim()),P()}function D(){if(!u.value||!r.value||typeof window>"u")return;const M=r.value.getBoundingClientRect(),J=window.innerWidth,A=window.innerHeight,X=8,ue=8,pe=160,E=360,Z=Math.max(0,A-M.bottom-ue),ce=Math.max(0,M.top-ue);p.value=Z<260&&ce>Z;const ie=p.value?ce-X:Z-X,ve=Math.max(Math.min(E,Math.max(ie,0)),Math.min(pe,p.value?ce:Z)),T=Math.min(M.width,J-ue*2),U=Math.min(Math.max(ue,M.left),Math.max(ue,J-ue-T));w.value={left:`${U}px`,top:p.value?`${M.top-X}px`:`${M.bottom+X}px`,width:`${T}px`,maxHeight:`${Math.max(ve,120)}px`,transform:p.value?"translateY(-100%)":"none"}}function j(M){var J;!u.value||!r.value||r.value.contains(M.target)||(J=l.value)!=null&&J.contains(M.target)||P()}function G(M){M.key==="Escape"&&P()}return Pe(()=>n.disabled,M=>{M&&P()}),Pe(u,async M=>{M&&(await ft(),D())}),cn(()=>{document.addEventListener("pointerdown",j),document.addEventListener("keydown",G),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0)}),Mt(()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",G),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}),(M,J)=>(m(),b("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:be(["workbench-select-trigger flex w-full items-center gap-3 rounded-sm border px-3 py-2 text-left transition focus:outline-none focus:ring-2",[n.triggerClass,e.disabled?"cursor-not-allowed border-[color-mix(in_srgb,var(--theme-borderDefault)_88%,var(--theme-textMuted))] bg-[color-mix(in_srgb,var(--theme-appPanelMuted)_82%,var(--theme-appBg))] text-[var(--theme-textMuted)]":"theme-input-shell text-[var(--theme-textPrimary)] hover:border-[var(--theme-borderStrong)] focus:border-[var(--theme-borderStrong)] focus:ring-[var(--theme-focusRing)]"]]),"aria-label":n.ariaLabel||void 0,disabled:e.disabled,onClick:ee,onKeydown:[Qt(ot(f,["prevent"]),["down"]),Qt(ot(ee,["prevent"]),["enter"]),Qt(ot(ee,["prevent"]),["space"])]},[i("div",Ui,[nn(M.$slots,"trigger",{selectedOption:c.value,open:u.value,loading:e.loading,disabled:e.disabled},()=>[i("div",ji,x(c.value?g(c.value):y.value),1)])]),i("div",{class:be(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(m(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),fe(a(Eo),{class:be(["h-4 w-4 transition",u.value?"rotate-180":""])},null,8,["class"])],2)],42,Fi),(m(),Ee(fs,{to:"body"},[u.value?(m(),b("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:In(w.value)},[i("div",Vi,[nn(M.$slots,"header",{loading:e.loading,options:e.options}),i("div",zi,[e.options.length?(m(!0),b(lt,{key:0},pt(e.options,A=>nn(M.$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:X=>S(A)},x(g(A)),9,Hi)])),128)):nn(M.$slots,"empty",{key:1},()=>[i("div",qi,x(h.value),1)])])])],4)):me("",!0)]))],512))}},Xo={},Nr=typeof import.meta<"u"&&Xo?Xo:{};function Ki(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Nr.VITE_API_PORT||"").trim();if(t)return e.port=t,e.toString().replace(/\/$/,"");const n=String(e.port||"");return new Set(["4173","5173","5174"]).has(n)?(e.port="3000",e.toString().replace(/\/$/,"")):e.toString().replace(/\/$/,"")}const Do=(Nr.VITE_API_BASE_URL||Ki()).replace(/\/$/,"");function Lo(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=Ye(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||Ye(t)}async function rt(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Do}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error(Lo(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Mo(){return Do}function Cs(e){return e?e.startsWith("http")?e:`${Do}${e}`:""}function Py(){return rt("/api/meta",{cache:"no-store"})}function Wi(){return rt("/api/tasks")}function Gi(e=30){const t=new URLSearchParams,n=Math.max(1,Number(e)||30);return t.set("limit",String(n)),rt(`/api/tasks/workspace-diff-summaries?${t.toString()}`,{cache:"no-store"})}function Xi(e){return rt("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function Yi(e=[]){return rt("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function Or(e){return rt(`/api/tasks/${e}`)}function Fr(e,t){return rt(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function Ji(e){return rt(`/api/tasks/${e}`,{method:"DELETE"})}const Ur=Mo();async function Qi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Ur}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(Lo(o,"errors.uploadFailed"))}return n.json()}async function Zi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Ur}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(Lo(o,"errors.pdfImportFailed"))}return n.json()}function el(){return rt("/api/codex/sessions")}function tl(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return rt(`/api/codex/workspaces${o?`?${o}`:""}`)}function Dy(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 rt(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function Ly(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 rt(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function My(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 rt(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function nl(e){return rt("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function sl(e,t){return rt(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function ol(e){return rt(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function rl(e){return rt(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function al(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 rt(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function il(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 rt(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function ll(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 rt(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function ul(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 rt(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function cl(e,t){return rt(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function dl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=fi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return rt(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function fl(e,t={}){const n=new URLSearchParams,o=Math.max(0,Number(t.afterSeq)||0),s=Math.max(1,Number(t.limit)||5e3);o>0&&n.set("afterSeq",String(o)),s>0&&n.set("limit",String(s));const r=n.toString();return rt(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function By(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,p=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"),p>0&&n.set("timeoutMs",String(p));const w=n.toString();return rt(`/api/tasks/${encodeURIComponent(e)}/git-diff${w?`?${w}`:""}`,{cache:"no-store"})}function pl(e,t){return rt(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function ml(e){return rt(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function gl(e){return rt(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const hl={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},vl={class:"theme-muted-text mt-1 text-xs"},yl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},Sl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},wl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},xl={key:1,class:"space-y-4"},bl={key:0,class:"space-y-4"},kl={class:"theme-heading text-base font-medium"},_l={class:"theme-muted-text mt-1 text-xs leading-5"},Tl={class:"settings-section-card px-4 py-4"},Cl={class:"block space-y-1.5"},El={class:"theme-muted-text text-xs"},Al=["placeholder"],$l={key:1,class:"space-y-4"},Il={class:"flex items-start justify-between gap-3"},Pl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Dl={class:"theme-muted-text mt-1 text-xs leading-5"},Ll={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Ml={class:"settings-section-card px-4 py-4"},Bl={class:"grid gap-4 sm:grid-cols-2"},Rl={class:"space-y-1.5 sm:col-span-2"},Nl={class:"theme-muted-text text-xs"},Ol={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Fl={class:"space-y-1.5"},Ul={class:"theme-muted-text text-xs"},jl=["disabled"],Vl={key:0,class:"space-y-1.5"},zl={class:"theme-muted-text text-xs"},Hl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},ql={class:"space-y-1.5"},Kl={class:"theme-muted-text text-xs"},Wl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Gl={class:"theme-muted-text text-xs"},Xl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Yl={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Jl={key:2,class:"space-y-4"},Ql={class:"flex items-start justify-between gap-3"},Zl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},eu={class:"theme-muted-text mt-1 text-xs leading-5"},tu={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},nu={class:"settings-section-card px-4 py-4"},su={class:"grid gap-4 sm:grid-cols-2"},ou={class:"space-y-1.5"},ru={class:"theme-muted-text text-xs"},au={class:"truncate text-sm text-[var(--theme-textPrimary)]"},iu={class:"space-y-1.5"},lu={class:"theme-muted-text text-xs"},uu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},cu={class:"space-y-1.5 sm:col-span-2"},du={class:"theme-muted-text text-xs"},fu=["placeholder","disabled"],pu={class:"space-y-1.5"},mu={class:"theme-muted-text text-xs"},gu=["placeholder","disabled"],hu={class:"space-y-1.5"},vu={class:"theme-muted-text text-xs"},yu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Su={class:"space-y-1.5"},wu={class:"theme-muted-text text-xs"},xu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},bu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},ku={key:0,class:"theme-danger-text"},_u={key:3,class:"theme-danger-text text-sm"},Tu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},Cu={class:"theme-muted-text theme-note-text"},Eu={class:"flex items-center justify-end gap-2"},Au=["disabled"],$u=["disabled"],Iu="0 9 * * 1-5",so="weekdays",ts="09:00",Nn="1",Pu={__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}=_t(),l=F(!1),u=F(!1),p=F(""),w=F("basic"),c=ps({title:"",automationEnabled:!1,automationMode:so,automationTime:ts,automationWeekday:Nn,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),y=K(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),h=K(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:is},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Bs},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Ho}]),g=K(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),f=K(()=>[{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=K(()=>mi.map(T=>({...T,label:T.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):T.label}))),ee=K(()=>hi.map(T=>({...T,label:T.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):T.label}))),S=K(()=>vi.map(T=>({...T,label:T.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):T.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):T.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):T.label}))),D=K(()=>yi.map(T=>({...T,label:T.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):T.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):T.value==="error"?r("taskDialog.sections.notification.triggerError"):T.label}))),j=K(()=>wi.map(T=>({...T,label:T.value==="summary"?r("taskDialog.sections.notification.messageSummary"):T.label}))),G=K(()=>xi.map(T=>({...T,label:T.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):T.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):T.label}))),M=K(()=>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 J(){c.title="",c.automationEnabled=!1,c.automationMode=so,c.automationTime=ts,c.automationWeekday=Nn,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(T=0){return String(T).padStart(2,"0")}function X(T=""){const U=String(T||"").trim().replace(/\s+/g," ");let O=U.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return O?{mode:"weekdays",time:`${A(O[2])}:${A(O[1])}`,weekday:Nn}:(O=U.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),O?{mode:"daily",time:`${A(O[2])}:${A(O[1])}`,weekday:Nn}:(O=U.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),O?{mode:"weekly",time:`${A(O[2])}:${A(O[1])}`,weekday:String(O[3])}:{mode:so,time:ts,weekday:Nn}))}function ue(T=""){const O=String(T||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!O)return ts;const He=Number(O[1]),De=Number(O[2]);return!Number.isInteger(He)||!Number.isInteger(De)||He<0||He>23||De<0||De>59?ts:`${A(He)}:${A(De)}`}function pe(){var je;const T=ue(c.automationTime),[U,O]=T.split(":"),He=Number(U),De=Number(O);if(c.automationMode==="daily")return`${De} ${He} * * *`;if(c.automationMode==="weekly"){const We=((je=f.value.find(Ge=>Ge.value===String(c.automationWeekday||"")))==null?void 0:je.value)||Nn;return`${De} ${He} * * ${We}`}return`${De} ${He} * * 1-5`}function E(T={}){var O,He,De,je,We,Ge,ut,Te,V,te,he,Ae,se,_e,$e,Le;c.title=String(T.title||""),c.automationEnabled=!!((O=T.automation)!=null&&O.enabled);const U=X(((He=T.automation)==null?void 0:He.cron)||Iu);c.automationMode=U.mode,c.automationTime=U.time,c.automationWeekday=U.weekday,c.automationTimezone=String(((De=T.automation)==null?void 0:De.timezone)||"local"),c.automationConcurrencyPolicy=String(((je=T.automation)==null?void 0:je.concurrencyPolicy)||"skip"),c.automationLastTriggeredAt=String(((We=T.automation)==null?void 0:We.lastTriggeredAt)||""),c.automationNextTriggerAt=String(((Ge=T.automation)==null?void 0:Ge.nextTriggerAt)||""),c.notificationEnabled=!!((ut=T.notification)!=null&&ut.enabled),c.notificationChannelType=String(((Te=T.notification)==null?void 0:Te.channelType)||"dingtalk"),c.notificationWebhookUrl=String(((V=T.notification)==null?void 0:V.webhookUrl)||""),c.notificationSecret=String(((te=T.notification)==null?void 0:te.secret)||""),c.notificationTriggerOn=String(((he=T.notification)==null?void 0:he.triggerOn)||"completed"),c.notificationLocale=String(((Ae=T.notification)==null?void 0:Ae.locale)||s.value||"zh-CN"),c.notificationMessageMode=String(((se=T.notification)==null?void 0:se.messageMode)||"summary"),c.notificationLastStatus=String(((_e=T.notification)==null?void 0:_e.lastStatus)||""),c.notificationLastError=String((($e=T.notification)==null?void 0:$e.lastError)||""),c.notificationLastSentAt=String(((Le=T.notification)==null?void 0:Le.lastSentAt)||"")}async function Z(){const T=String(n.taskSlug||"").trim();if(!T){J();return}l.value=!0,p.value="";try{const U=await Or(T);E(U)}catch(U){p.value=(U==null?void 0:U.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function ce(){return{title:c.title,automation:{enabled:c.automationEnabled,cron:pe(),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 ie(){const T=String(n.taskSlug||"").trim();if(!(!T||l.value||u.value)){u.value=!0,p.value="";try{const U=await Fr(T,ce());E(U),o("saved",U),o("close")}catch(U){p.value=(U==null?void 0:U.message)||r("taskDialog.saveFailed")}finally{u.value=!1}}}function ve(T=""){if(!T)return r("common.notAvailable");const U=new Date(T);return Number.isNaN(U.getTime())?r("common.notAvailable"):Tr(U.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Pe(()=>n.open,T=>{if(T){w.value="basic",Z();return}},{immediate:!0}),Pe(()=>n.taskSlug,()=>{n.open&&Z()}),(T,U)=>(m(),Ee(Ws,{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:U[16]||(U[16]=O=>o("close"))},{title:st(()=>[i("div",null,[i("div",hl,[fe(a(is),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.title")),1)]),i("p",vl,x(a(r)("taskDialog.currentTask",{title:y.value})),1)])]),default:st(()=>[i("div",yl,[fe(Oi,{modelValue:w.value,"onUpdate:modelValue":U[0]||(U[0]=O=>w.value=O),sections:h.value},null,8,["modelValue","sections"]),i("div",Sl,[l.value?(m(),b("div",wl,[fe(a(Gt),{class:"h-4 w-4 animate-spin"}),i("span",null,x(a(r)("taskDialog.loading")),1)])):(m(),b("div",xl,[w.value==="basic"?(m(),b("section",bl,[i("div",null,[i("div",kl,x(a(r)("taskDialog.sections.basic.title")),1),i("p",_l,x(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",Tl,[i("label",Cl,[i("span",El,x(a(r)("taskDialog.sections.basic.taskTitle")),1),Jt(i("input",{"onUpdate:modelValue":U[1]||(U[1]=O=>c.title=O),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,Al),[[ss,c.title]])])])])):w.value==="automation"?(m(),b("section",$l,[i("div",Il,[i("div",null,[i("div",Pl,[fe(a(Bs),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.sections.automation.title")),1)]),i("p",Dl,x(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",Ll,[Jt(i("input",{"onUpdate:modelValue":U[2]||(U[2]=O=>c.automationEnabled=O),type:"checkbox",class:"h-4 w-4"},null,512),[[zo,c.automationEnabled]]),i("span",null,x(a(r)("taskDialog.enabled")),1)])]),i("section",Ml,[i("div",Bl,[i("label",Rl,[i("span",Nl,x(a(r)("taskDialog.sections.automation.mode")),1),fe(ln,{modelValue:c.automationMode,"onUpdate:modelValue":U[3]||(U[3]=O=>c.automationMode=O),options:g.value,disabled:!c.automationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",Ol,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Fl,[i("span",Ul,x(a(r)("taskDialog.sections.automation.time")),1),Jt(i("input",{"onUpdate:modelValue":U[4]||(U[4]=O=>c.automationTime=O),type:"time",class:"tool-input",disabled:!c.automationEnabled},null,8,jl),[[ss,c.automationTime]])]),c.automationMode==="weekly"?(m(),b("label",Vl,[i("span",zl,x(a(r)("taskDialog.sections.automation.weekday")),1),fe(ln,{modelValue:c.automationWeekday,"onUpdate:modelValue":U[5]||(U[5]=O=>c.automationWeekday=O),options:f.value,disabled:!c.automationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",Hl,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):me("",!0),i("label",ql,[i("span",Kl,x(a(r)("taskDialog.sections.automation.timezone")),1),fe(ln,{modelValue:c.automationTimezone,"onUpdate:modelValue":U[6]||(U[6]=O=>c.automationTimezone=O),options:P.value,disabled:!c.automationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",Wl,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:be(["space-y-1.5",c.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",Gl,x(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),fe(ln,{modelValue:c.automationConcurrencyPolicy,"onUpdate:modelValue":U[7]||(U[7]=O=>c.automationConcurrencyPolicy=O),options:ee.value,disabled:!c.automationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",Xl,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",Yl,[i("p",null,x(a(r)("taskDialog.sections.automation.lastTriggered",{value:ve(c.automationLastTriggeredAt)})),1),i("p",null,x(a(r)("taskDialog.sections.automation.nextTriggered",{value:ve(c.automationNextTriggerAt)})),1)])])])):(m(),b("section",Jl,[i("div",Ql,[i("div",null,[i("div",Zl,[fe(a(Ho),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.sections.notification.title")),1)]),i("p",eu,x(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",tu,[Jt(i("input",{"onUpdate:modelValue":U[8]||(U[8]=O=>c.notificationEnabled=O),type:"checkbox",class:"h-4 w-4"},null,512),[[zo,c.notificationEnabled]]),i("span",null,x(a(r)("taskDialog.enabled")),1)])]),i("section",nu,[i("div",su,[i("label",ou,[i("span",ru,x(a(r)("taskDialog.sections.notification.channelType")),1),fe(ln,{modelValue:c.notificationChannelType,"onUpdate:modelValue":U[9]||(U[9]=O=>c.notificationChannelType=O),options:S.value,disabled:!c.notificationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",au,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",iu,[i("span",lu,x(a(r)("taskDialog.sections.notification.triggerOn")),1),fe(ln,{modelValue:c.notificationTriggerOn,"onUpdate:modelValue":U[10]||(U[10]=O=>c.notificationTriggerOn=O),options:D.value,disabled:!c.notificationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",uu,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",cu,[i("span",du,x(a(r)("taskDialog.sections.notification.webhookUrl")),1),Jt(i("input",{"onUpdate:modelValue":U[11]||(U[11]=O=>c.notificationWebhookUrl=O),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!c.notificationEnabled},null,8,fu),[[ss,c.notificationWebhookUrl]])]),i("label",pu,[i("span",mu,x(a(r)("taskDialog.sections.notification.secret")),1),Jt(i("input",{"onUpdate:modelValue":U[12]||(U[12]=O=>c.notificationSecret=O),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!c.notificationEnabled},null,8,gu),[[ss,c.notificationSecret]])]),i("label",hu,[i("span",vu,x(a(r)("taskDialog.sections.notification.locale")),1),fe(ln,{modelValue:c.notificationLocale,"onUpdate:modelValue":U[13]||(U[13]=O=>c.notificationLocale=O),options:G.value,disabled:!c.notificationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",yu,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Su,[i("span",wu,x(a(r)("taskDialog.sections.notification.messageMode")),1),fe(ln,{modelValue:c.notificationMessageMode,"onUpdate:modelValue":U[14]||(U[14]=O=>c.notificationMessageMode=O),options:j.value,disabled:!c.notificationEnabled,"get-option-value":O=>O.value},{trigger:st(({selectedOption:O})=>[i("div",xu,x((O==null?void 0:O.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",bu,[i("p",null,x(a(r)("taskDialog.sections.notification.status",{value:M.value})),1),i("p",null,x(a(r)("taskDialog.sections.notification.lastSent",{value:ve(c.notificationLastSentAt)})),1),c.notificationLastError?(m(),b("p",ku,x(a(r)("taskDialog.sections.notification.lastError",{value:c.notificationLastError})),1)):me("",!0)])])])),p.value?(m(),b("p",_u,x(p.value),1)):me("",!0)]))])]),i("div",Tu,[i("p",Cu,x(a(r)("taskDialog.footerHint")),1),i("div",Eu,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:u.value,onClick:U[15]||(U[15]=O=>o("close"))},x(a(r)("common.cancel")),9,Au),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:ie},[u.value?(m(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ee(a(Ra),{key:1,class:"h-4 w-4"})),i("span",null,x(u.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,$u)])])]),_:1},8,["open"]))}};function Du(e=[]){return(Array.isArray(e)&&e.length?e:Po).filter(n=>n&&typeof n=="object").map(n=>{const o=Os(n.value);return{...n,value:o,label:String(n.label||gt(o)).trim()||gt(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function Lu(e=[]){return Du(e).filter(t=>t.enabled&&t.available)}async function Ry(){const e=await rt("/api/meta",{cache:"no-store"});return Lu(e==null?void 0:e.agentEngineOptions)}function jr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=gt(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const Mu={key:0,class:"flex items-center gap-2 text-sm"},Bu={class:"min-w-0 flex-1 truncate"},Ru={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},Nu={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},Ou={key:1,class:"theme-muted-text text-sm"},Fu={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},Uu=["onClick"],ju={class:"flex items-center gap-3"},Vu={class:"min-w-0 flex-1"},zu={class:"flex items-center gap-2 text-sm sm:hidden"},Hu={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},qu={class:"hidden items-center gap-2 text-sm sm:flex"},Ku={class:"min-w-0 flex-1 truncate"},Wu={class:"font-medium text-[var(--theme-textPrimary)]"},Gu={class:"theme-muted-text ml-2 font-mono text-[11px]"},Xu={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Yu={__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}=_t();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 p(c){var h;const y=Math.max(0,Number((h=c==null?void 0:c.agentBindings)==null?void 0:h.length)||0);return y>1?o("projectManager.agentCount",{count:y}):gt(c==null?void 0:c.engine)}function w(c){return c?"theme-filter-active":"theme-filter-idle"}return(c,y)=>(m(),Ee(ln,{"model-value":e.modelValue,options:e.sessions,loading:e.loading,disabled:e.disabled,"trigger-class":"h-9",placeholder:a(o)("projectManager.selectProject"),"empty-text":a(o)("projectManager.noProjectsInSelect"),"get-option-value":h=>(h==null?void 0:h.id)||"","onUpdate:modelValue":y[0]||(y[0]=h=>n("update:modelValue",h)),onRefreshIntent:y[1]||(y[1]=h=>n("refresh-intent"))},{trigger:st(({selectedOption:h,disabled:g})=>[h?(m(),b("div",Mu,[i("span",Bu,[i("span",{class:be(["font-medium",g?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},x(s(h)),3),i("span",Ru,x(r(h)),1)]),i("span",Nu,x(p(h)),1),i("span",{class:be(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",u(h)])},x(l(h)),3)])):(m(),b("div",Ou,x(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:st(()=>[i("div",Fu,[i("span",null,x(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(m(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):me("",!0)])]),option:st(({option:h,selected:g,select:f})=>[i("button",{type:"button",class:be(["w-full rounded-sm border border-dashed p-3 text-left transition",w(g)]),onClick:f},[i("div",ju,[i("div",Vu,[i("div",zu,[i("span",Hu,x(s(h)),1)]),i("div",qu,[i("span",Ku,[i("span",Wu,x(s(h)),1),i("span",Gu,x(r(h)),1)]),i("span",Xu,x(p(h)),1),i("span",{class:be(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",u(h)])},x(l(h)),3)])]),g?(m(),Ee(a(Ir),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):me("",!0)])],10,Uu)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},Ju=["disabled"],Qu=["disabled"],Zu=["src","alt"],Vr={__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}=_t(),r=F(1),l=K(()=>n.images.map(S=>String(S||"").trim()).filter(Boolean)),u=K(()=>l.value.findIndex(S=>S===n.modelValue)),p=K(()=>u.value>=0?l.value[u.value]:"");function w(){o("update:modelValue",""),r.value=1}function c(S){o("update:modelValue",String(S||"").trim()),r.value=1}function y(){u.value<=0||c(l.value[u.value-1])}function h(){u.value<0||u.value>=l.value.length-1||c(l.value[u.value+1])}function g(S){const D=Math.min(3,Math.max(.5,r.value+S));r.value=Math.round(D*100)/100}function f(){r.value=1}function P(S){p.value&&(S.preventDefault(),g(S.deltaY<0?.1:-.1))}function ee(S){if(p.value){if(S.key==="Escape"){S.preventDefault(),w();return}if(S.key==="ArrowLeft"){S.preventDefault(),y();return}if(S.key==="ArrowRight"){S.preventDefault(),h();return}if(S.key==="+"||S.key==="="){S.preventDefault(),g(.1);return}if(S.key==="-"){S.preventDefault(),g(-.1);return}S.key==="0"&&(S.preventDefault(),f())}}return Pe(()=>n.modelValue,S=>{S||(r.value=1)}),Pe(l,S=>{if(n.modelValue){if(!S.length){w();return}if(!S.includes(n.modelValue)){const D=Math.min(u.value,S.length-1);c(S[D]||S[0])}}},{immediate:!0}),cn(()=>{window.addEventListener("keydown",ee)}),Mt(()=>{window.removeEventListener("keydown",ee)}),(S,D)=>(m(),Ee(fs,{to:"body"},[p.value?(m(),b("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-50 flex items-center justify-center p-6",onClick:w,onWheel:P},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:D[2]||(D[2]=ot(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:D[0]||(D[0]=j=>g(-.1))},x(a(s)("imagePreview.zoomOut")),1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:f},x(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:D[1]||(D[1]=j=>g(.1))},x(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:D[3]||(D[3]=ot(()=>{},["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:y},x(a(s)("imagePreview.previous")),9,Ju),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:u.value<0||u.value>=l.value.length-1,onClick:h},x(a(s)("imagePreview.next")),9,Qu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:w},x(a(s)("imagePreview.close")),1)]),i("img",{src:p.value,alt:a(s)("imagePreview.alt"),class:"image-preview-overlay__image max-h-[90vh] max-w-[90vw] object-contain shadow-2xl transition-transform",style:In({transform:`scale(${r.value})`}),onClick:D[4]||(D[4]=ot(()=>{},["stop"]))},null,12,Zu)],32)):me("",!0)]))}};let oo=null;const Ny={maxLines:2e3,maxChars:2e5},ro={maxLines:2e3,maxChars:2e5},ec={"github-dark-default":()=>Ke(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>Ke(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},tc={bash:()=>Ke(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>Ke(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>Ke(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>Ke(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>Ke(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>Ke(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>Ke(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>Ke(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>Ke(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>Ke(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>Ke(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>Ke(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>Ke(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>Ke(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>Ke(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>Ke(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>Ke(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>Ke(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>Ke(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>Ke(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>Ke(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>Ke(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>Ke(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>Ke(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>Ke(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>Ke(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>Ke(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>Ke(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>Ke(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function zr(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Bo(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 Ro(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 nc(e=[],t={}){const n=Bo(e);return Ro(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function sc(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
6
+ `);return nc(n?n.split(`
7
+ `):[],t)}async function Hr(){return oo||(oo=Promise.all([Ke(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.F),__vite__mapDeps([1,2,3])),Ke(()=>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:[]}))),oo}async function qr(e,t){if(!t||e.getLoadedThemes().includes(t))return;const n=ec[t];n&&await e.loadTheme(await n())}async function Kr(e,t){if(!t||e.getLoadedLanguages().includes(t))return;const n=tc[t];n&&await e.loadLanguage(await n())}function Vn(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const oc={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 Gs(e=""){const t=String(e||"").trim().toLowerCase();return t?oc[t]||t:""}function Oy(e="",t=""){const n=Gs(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 Wr(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=Vn((e==null?void 0:e.content)||"");return`<span${t.length?` style="${t.join(";")}"`:""}>${n}</span>`}function Gr(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:zr(e.length)}}function Fy(e=[]){return(Array.isArray(e)?e.map(n=>String(n??"")):[]).map(n=>n?Vn(n):"&#8203;")}function ao(e=""){const t=String(e||"").replace(/\r\n/g,`
8
+ `);return Gr(t.split(`
9
+ `).map(n=>n?Vn(n):"&#8203;"),{})}async function rc(e=[],t={}){const n=Bo(e),o=n.lines,s=t.isDark?"github-dark-default":"github-light",r=Gs(t.language);if(!o.length)return[];if(Ro(n,t))return o.map(l=>l?Vn(l):"&#8203;");if(!r)return o.map(l=>l?Vn(l):"&#8203;");try{const l=await Hr();return await qr(l,s),await Kr(l,r),(await l.codeToTokens(o.join(`
10
+ `),{lang:r,theme:s})).tokens.map(p=>p.length?p.map(Wr).join(""):"&#8203;")}catch{return o.map(l=>l?Vn(l):"&#8203;")}}async function ac(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
11
+ `),o=t.isDark?"github-dark-default":"github-light",s=Gs(t.language),r=n?n.split(`
12
+ `):[],l=Bo(r);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:zr(0)};if(Ro(l,t)||!s)return ao(n);try{const u=await Hr();await qr(u,o),await Kr(u,s);const p=await u.codeToTokens(n,{lang:s,theme:o});return Gr(p.tokens.map(w=>w.length?w.map(Wr).join(""):"&#8203;"),{bg:p.bg||"",fg:p.fg||""})}catch{return ao(n)}}const ic=new Mr,lc="__PROMPTX_FENCE__";function Xr(e=""){return String(e||"").trim().toLowerCase()}function Ss(e=""){return ic.utils.escapeHtml(String(e||""))}function uc(e=""){const t=Xr(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 Yr(e={}){const t=new Mr({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,p,w,c)=>{const y=l[u];return y.attrSet("target","_blank"),y.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,u,p,w,c):c.renderToken(l,u,p)},t.renderer.rules.table_open=(l,u,p,w,c)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,u,p,w,c):c.renderToken(l,u,p)}`,t.renderer.rules.table_close=(l,u,p,w,c)=>`${typeof s=="function"?s(l,u,p,w,c):c.renderToken(l,u,p)}</div>`,e.captureFences?t.renderer.rules.fence=(l,u,p,w={},c)=>{const y=l[u],h=Array.isArray(w.__promptxFences)?w.__promptxFences:[],g=h.length,f=`${lc}${g}__`;return h.push({content:String((y==null?void 0:y.content)||""),language:String((y==null?void 0:y.info)||"").trim().split(/\s+/)[0]||"",placeholder:f}),w.__promptxFences=h,f}:typeof r=="function"&&(t.renderer.rules.fence=r),t}const cc=Yr({captureFences:!0}),dc=Yr();async function fc(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
13
+ `),s=Xr(t),r=Gs(s),u=(await rc(o.split(`
14
+ `),{isDark:!!n.isDark,language:r||s})).join(`
15
+ `),p=s?` class="language-${Ss(s)}"`:"",w=uc(t),c=Ss(String(n.copyLabel||"Copy")),y=Ss(String(n.copyAriaLabel||c)),g=`<div class="codex-code-block__header">${w?`<span class="codex-code-block__language">${Ss(w)}</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="${y}">${c}</button></div>`;return`<div class="${w?"codex-code-block codex-code-block--labeled":"codex-code-block"}">${g}<pre><code${p}>${u}</code></pre></div>`}async function pc(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>fc(s.content,s.language,n)));return t.reduce((s,r,l)=>s.replace(r.placeholder,o[l]||r.placeholder),e)}async function mc(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=cc.render(n,o);return pc(s,o.__promptxFences||[],t)}function Jr(e=""){const t=String(e||"").trim();return t?dc.render(t):""}function gc(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function Yo(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${gc(JSON.stringify(e||{}))}`}function hc(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,r)=>{const l=Yo(r);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const r=Yo(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 vc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},yc={key:0,class:"process-detail-meta"},Sc={key:0,class:"process-detail-meta__label"},wc={key:1,class:"process-detail-panel"},xc={class:"space-y-1.5"},bc={key:1,class:"process-detail-checklist__dot"},kc={key:0,class:"process-detail-footnote"},_c={key:0},Tc={key:2,class:"process-detail-panel"},Cc={class:"process-detail-directory__heading"},Ec={key:0,class:"font-medium"},Ac={key:1,class:"process-detail-directory__type"},$c={class:"process-detail-directory__list"},Ic={key:0,class:"process-detail-footnote"},Pc={key:0},Dc={key:3,class:"process-detail-panel"},Lc={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},Mc={key:0,class:"process-detail-footnote"},Bc={key:4,class:"process-detail-panel"},Rc={class:"space-y-1.5"},Nc={class:"process-detail-filechange__kind"},Oc={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},Fc={key:5,class:"process-detail-panel"},Uc={class:"space-y-2"},jc={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},Vc={class:"min-w-0 flex flex-1 items-center gap-2"},zc={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},Hc=["title"],qc=["onClick"],Kc={class:"process-detail-directory__type shrink-0"},Wc={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},Gc={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},Xc=["innerHTML"],Yc={key:7,class:"process-detail-text"},Jc=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}=_t(),o=F(new Set),s=K(()=>{const E=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return E.length?E:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),r=K(()=>hc(s.value)),l=K(()=>r.value.map(E=>E.key));Pe(s,(E=[])=>{const Z=new Set;E.forEach((ce,ie)=>{(ce==null?void 0:ce.type)==="sub_agent_list"&&(Array.isArray(ce.items)?ce.items:[]).forEach((ve,T)=>{Z.add(J(ie,ve,T))})}),o.value=new Set([...o.value].filter(ce=>Z.has(ce)))},{immediate:!0});function u(E=""){return Jr(String(E||""))}function p(E=""){const Z=String(E||"").trim();return n(Z==="create"?"processDetail.changeCreate":Z==="delete"?"processDetail.changeDelete":Z==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function w(E={}){const Z=String((E==null?void 0:E.label)||"").trim().toLowerCase(),ce=String((E==null?void 0:E.value)||"").trim();return ce?ce.length>56||["命令","command","目标","target","url","路径","path"].includes(Z)&&ce.length>28?!0:ce.includes(" ")&&ce.length>36:!1}function c(E={},Z=[]){const ce=String((E==null?void 0:E.label)||"").trim().toLowerCase();return["命令","command"].includes(ce)?Array.isArray(Z)&&Z.length===1:!1}function y(E={}){const Z=String((E==null?void 0:E.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(Z)}function h(E={}){return E!=null&&E.completed?"completed":String((E==null?void 0:E.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function g(E=0){return n("processDetail.hiddenItems",{count:E})}function f(E=0){return n("processDetail.directorySummary",{count:E})}function P(E=0){return n("processDetail.directoryHidden",{count:E})}function ee(E=0){return l.value[E]||`block-${E}`}function S(E=""){const Z=String(E||"").trim().toLowerCase();return n(Z==="completed"?"processDetail.subAgentCompleted":Z==="failed"?"processDetail.subAgentFailed":Z==="running"?"processDetail.subAgentRunning":Z==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function D(E={}){return String((E==null?void 0:E.title)||(E==null?void 0:E.target)||(E==null?void 0:E.id)||"").trim()}function j(E={}){const Z=D(E),ce=[],ie=String((E==null?void 0:E.role)||"").trim(),ve=String((E==null?void 0:E.target)||"").trim(),T=String((E==null?void 0:E.model)||"").trim();return ie&&ie.toLowerCase()!=="default"&&ce.push(ie),ve&&ve!==Z&&ce.push(ve),T&&ce.push(T),ce.join(" · ")}function G(E={}){return!!String((E==null?void 0:E.message)||"").trim()}function M(E={}){const Z=String((E==null?void 0:E.message)||"").replace(/\s+/g," ").trim();return Z||j(E)}function J(E=0,Z={},ce=0){return`${ee(E)}:sub-agent:${String((Z==null?void 0:Z.id)||(Z==null?void 0:Z.target)||(Z==null?void 0:Z.title)||ce)}`}function A(E=0,Z={},ce=0){return o.value.has(J(E,Z,ce))}function X(E=0,Z={},ce=0){const ie=J(E,Z,ce),ve=new Set(o.value);ve.has(ie)?ve.delete(ie):ve.add(ie),o.value=ve}function ue(E={}){return Array.isArray(E==null?void 0:E.messageBlocks)?E.messageBlocks.filter(Boolean):[]}function pe(E={}){return ue(E).some(ce=>!["text","markdown"].includes(String((ce==null?void 0:ce.type)||"").trim()))}return(E,Z)=>{const ce=Pa("ProcessDetailRenderer",!0);return s.value.length?(m(),b("div",vc,[(m(!0),b(lt,null,pt(s.value,(ie,ve)=>(m(),b(lt,{key:l.value[ve]||`${ie.type}-${ve}`},[ie.type==="meta"?(m(),b("div",yc,[(m(!0),b(lt,null,pt(ie.items||[],(T,U)=>(m(),b("div",{key:`${ve}-meta-${U}`,class:be(["process-detail-meta__item",{"process-detail-meta__item--long":w(T),"process-detail-meta__item--value-only":c(T,ie.items)}])},[c(T,ie.items)?me("",!0):(m(),b("span",Sc,x(T.label),1)),i("span",{class:be(["process-detail-meta__value",{"process-detail-mobile-code-scroll":w(T),"process-detail-meta__value--mono":y(T)}])},x(T.value),3)],2))),128))])):ie.type==="checklist"?(m(),b("div",wc,[i("div",xc,[(m(!0),b(lt,null,pt(ie.items||[],(T,U)=>(m(),b("div",{key:`${ve}-check-${U}`,class:"process-detail-checklist__item"},[i("span",{class:be(["process-detail-checklist__icon",`is-${h(T)}`])},[h(T)==="completed"?(m(),Ee(a(Ir),{key:0,class:"h-3 w-3"})):h(T)==="in_progress"?(m(),b("span",bc)):me("",!0)],2),i("span",{class:be(h(T)==="completed"?"line-through":"")},x(T.text),3)]))),128))]),ie.totalCount?(m(),b("div",kc,[gn(x(`已完成 ${(ie.items||[]).filter(T=>T.completed).length} / ${ie.totalCount}`)+" ",1),ie.hiddenCount?(m(),b("span",_c,x(`,还有 ${ie.hiddenCount} 项`),1)):me("",!0)])):me("",!0)])):ie.type==="directory_list"?(m(),b("div",Tc,[i("div",Cc,[ie.path?(m(),b("span",Ec,x(ie.path),1)):me("",!0),ie.entryType?(m(),b("span",Ac,x(ie.entryType),1)):me("",!0)]),i("div",$c,[(m(!0),b(lt,null,pt(ie.entries||[],(T,U)=>(m(),b("div",{key:`${ve}-entry-${U}`,class:"process-detail-directory__item"},x(T),1))),128))]),ie.totalCount?(m(),b("div",Ic,[gn(x(f(ie.totalCount))+" ",1),ie.hiddenCount?(m(),b("span",Pc,x(P(ie.hiddenCount)),1)):me("",!0)])):me("",!0)])):ie.type==="bullet_list"?(m(),b("div",Dc,[i("ul",Lc,[(m(!0),b(lt,null,pt(ie.items||[],(T,U)=>(m(),b("li",{key:`${ve}-bullet-${U}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},x(T),1))),128))]),ie.hiddenCount?(m(),b("div",Mc,x(g(ie.hiddenCount)),1)):me("",!0)])):ie.type==="file_changes"?(m(),b("div",Bc,[i("div",Rc,[(m(!0),b(lt,null,pt(ie.items||[],(T,U)=>(m(),b("div",{key:`${ve}-change-${U}`,class:"process-detail-filechange__item"},[i("span",Nc,x(p(T.kind)),1),i("span",Oc,x(T.path),1)]))),128))])])):ie.type==="sub_agent_list"?(m(),b("div",Fc,[i("div",Uc,[(m(!0),b(lt,null,pt(ie.items||[],(T,U)=>(m(),b("div",{key:`${ve}-sub-agent-${U}`,class:"min-w-0"},[i("div",jc,[i("div",Vc,[i("span",zc,x(D(T)),1),M(T)?(m(),b("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:M(T)},x(M(T)),9,Hc)):me("",!0)]),G(T)?(m(),b("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:O=>X(ve,T,U)},x(A(ve,T,U)?a(n)("common.collapse"):a(n)("common.expand")),9,qc)):me("",!0),i("span",Kc,x(S(T.status)),1)]),G(T)&&A(ve,T,U)?(m(),b("div",Wc,[pe(T)?(m(),Ee(ce,{key:0,blocks:ue(T),kind:"sub-agent-message"},null,8,["blocks"])):(m(),b("pre",Gc,x(T.message),1))])):me("",!0)]))),128))])])):ie.type==="markdown"?(m(),b("div",{key:6,class:be(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:u(ie.text)},null,10,Xc)):(m(),b("pre",Yc,x(ie.text),1))],64))),128))])):me("",!0)}}}),Qr={__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)=>(m(),b("button",{type:"button",class:"tool-button tool-button-primary absolute z-20 inline-flex items-center gap-2 px-3 py-1.5 text-xs shadow-sm",style:In({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[r[0]||(r[0]=Qt(ot(l=>o("click"),["prevent"]),["enter"])),r[1]||(r[1]=Qt(ot(l=>o("click"),["prevent"]),["space"]))]},x(e.label),37))}},Zr=96,Jo=34,mn=8,Qc=72;function Zc(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function Qo(e,t,n){var r;const o=Zc(e);if(!o||!n)return null;const s=(r=o.closest)==null?void 0:r.call(o,t);return s&&n.contains(s)?s:null}function ed(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function td(e,t,{codeLeft:n=0,buttonWidth:o=Zr,scrollTop:s=0,scrollLeft:r=0,clientWidth:l=0,clientHeight:u=0}={}){const w=Math.max(e.left||0,Number(n)||0)-t.left+r,c=r+mn,y=r+Math.max(mn,l-o-mn),h=Math.max(c,Math.min(y,w||r+mn)),g=e.bottom-t.top+s+mn,f=e.top-t.top+s-Jo-mn,P=s+mn,ee=s+u-mn;return{top:g+Jo<=ee?g:Math.max(P,f),left:h}}function ea(e={}){const t=F([]),n=F({visible:!1,top:0,left:0,content:""});let o=null,s=0;function r(){var G;return typeof e.getContainer=="function"?e.getContainer():((G=e.containerRef)==null?void 0:G.value)||null}function l(){return typeof e.getPositionContainer=="function"?e.getPositionContainer():r()}function u(){o&&(window.clearTimeout(o),o=null)}function p(){s&&(window.cancelAnimationFrame(s),s=0)}function w(G=[]){var M;t.value=G,(M=e.onSelectedRowsChange)==null||M.call(e,G)}function c({clearBrowserSelection:G=!1}={}){var M,J,A,X;u(),p(),G&&((A=(J=(M=window.getSelection)==null?void 0:M.call(window))==null?void 0:J.removeAllRanges)==null||A.call(J)),n.value={visible:!1,top:0,left:0,content:""},w([]),(X=e.onClear)==null||X.call(e)}function y(G){return G?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(G).filter(Boolean):[...G.querySelectorAll(String(e.rowSelector||""))]:[]}function h(G){var M;return((M=e.mapRowElement)==null?void 0:M.call(e,G))??G}function g(G,M,J){const A=String(e.rowSelector||"").trim(),X=y(J);if(!A||!X.length)return[];const ue=Qo(G.anchorNode,A,J),pe=Qo(G.focusNode,A,J);if(ue&&pe){const E=X.indexOf(ue),Z=X.indexOf(pe);if(E>=0&&Z>=0){const[ce,ie]=E<=Z?[E,Z]:[Z,E];return X.slice(ce,ie+1)}}return X.filter(E=>{try{return M.intersectsNode(E)}catch{return!1}})}function f(){var U,O,He;const G=(U=window.getSelection)==null?void 0:U.call(window),M=r(),J=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!G||G.rangeCount<1||G.isCollapsed||!M||!J){c();return}const X=G.getRangeAt(0),ue=ed(X);if(!ue||!M.contains(ue)){c();return}const pe=String(G.toString()||"").replace(/\u200b/g,"");if(!pe.trim()){c();return}const E=g(G,X,M);if(!E.length){c();return}const Z=E.map(De=>h(De)).filter(De=>De!==null&&typeof De<"u");if(!Z.length){c();return}const ce=X.getBoundingClientRect(),ie=(O=J.getBoundingClientRect)==null?void 0:O.call(J);if(!ie){c();return}const ve=((He=e.getCodeLeft)==null?void 0:He.call(e,E[0]))||ce.left,T=td(ce,ie,{codeLeft:ve,buttonWidth:Number(e.buttonWidth||Zr),scrollTop:Number(J.scrollTop||0),scrollLeft:Number(J.scrollLeft||0),clientWidth:Number(J.clientWidth||0),clientHeight:Number(J.clientHeight||0)});n.value={visible:!0,top:T.top,left:T.left,content:pe},w(Z)}function P(){u(),o=window.setTimeout(()=>{o=null,f()},Number(e.debounceMs||Qc))}function ee(){P()}function S(){P()}function D(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,f()}))}function j(){D()}return cn(()=>{var G,M,J,A;document.addEventListener("selectionchange",S),document.addEventListener("mouseup",S),document.addEventListener("scroll",j,!0),window.addEventListener("resize",j),(M=(G=window.visualViewport)==null?void 0:G.addEventListener)==null||M.call(G,"resize",j),(A=(J=window.visualViewport)==null?void 0:J.addEventListener)==null||A.call(J,"scroll",j)}),Mt(()=>{var G,M,J,A;c({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",S),document.removeEventListener("mouseup",S),document.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j),(M=(G=window.visualViewport)==null?void 0:G.removeEventListener)==null||M.call(G,"resize",j),(A=(J=window.visualViewport)==null?void 0:J.removeEventListener)==null||A.call(J,"scroll",j)}),{selectedRows:t,selectionAction:n,clearSelectionState:c,clearScheduledSelectionUpdate:u,handleSelectionMouseUp:ee,scheduleSelectionUpdate:P,updateSelectionActionFromDom:f}}const nd=250,sd=350,od=180,Es=2;function ta(e){return(e==null?void 0:e.name)==="AbortError"}const io="promptx:codex-recent-paths",rd=12;function na(e){const{getMode:t,props:n,onSelect:o}=e,s=F([]),r=F(!1),l=F(""),u=F([]),p=F(!1),w=F(""),c=F([]),y=F([]),h=F("tree"),g=F(""),f=new Map;let P=null,ee=0,S=0,D=null;const j=K(()=>String(n.query||"").trim()),G=K(()=>Math.max(1,Number(e.minimumQueryLength)||Es)),M=K(()=>j.value.length>=G.value),J=K(()=>typeof t=="function"),A=K(()=>J.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":h.value),X=K(()=>ut(s.value)),ue=K(()=>String(n.sessionId||"").trim()),pe=K(()=>ue.value?`promptx:codex-tree-expanded:${ue.value}`:""),E=K(()=>{if(!j.value)return c.value;const z=new Set(u.value.map(Y=>Y.path));return c.value.filter(Y=>z.has(Y.path))}),Z=K(()=>{const z=new Set(E.value.map(Y=>Y.path));return u.value.filter(Y=>!z.has(Y.path))}),ce=K(()=>j.value?[...E.value,...Z.value]:c.value),ie=K(()=>A.value==="search"?ce.value:X.value),ve=K(()=>A.value==="search"?p.value:r.value),T=K(()=>A.value==="search"?w.value:l.value),U=K(()=>A.value==="search"&&!!n.sessionId&&M.value&&!p.value&&!w.value&&!ce.value.length),O=K(()=>A.value==="search"&&!!n.sessionId&&!!j.value&&!M.value&&!p.value&&!w.value),He=K(()=>A.value==="tree"&&!!n.sessionId&&!r.value&&!l.value&&!X.value.length);function De(z,Y){if(!z||typeof window>"u")return Y;try{const de=window.localStorage.getItem(z);return de?JSON.parse(de):Y}catch{return Y}}function je(z,Y){if(!(!z||typeof window>"u"))try{window.localStorage.setItem(z,JSON.stringify(Y))}catch{}}function We(z=[]){return[...z].sort((Y,de)=>{const ge=+(Y.type!=="directory")-+(de.type!=="directory");return ge||String(Y.path||Y.name||"").localeCompare(String(de.path||de.name||""),"zh-CN")})}function Ge(z){return{...z,children:[],expanded:!1,loaded:!1,loading:!1}}function ut(z=[],Y=0,de=[]){return z.forEach(ge=>{de.push({...ge,depth:Y}),ge.type==="directory"&&ge.expanded&&ge.children.length&&ut(ge.children,Y+1,de)}),de}function Te(z,Y=s.value){for(const de of Y){if(de.path===z)return de;if(de.children.length){const ge=Te(z,de.children);if(ge)return ge}}return null}function V(){s.value=[...s.value]}function te(){P&&(window.clearTimeout(P),P=null),D&&(D.abort(),D=null)}function he(z=s.value,Y=[]){return z.forEach(de=>{de.type==="directory"&&de.expanded&&(Y.push(de.path),de.children.length&&he(de.children,Y))}),Y}function Ae(){if(!pe.value)return;const z=[...new Set(he())];y.value=z,je(pe.value,z)}function se(){y.value=pe.value?De(pe.value,[]).filter(Boolean):[]}function _e(z=s.value,Y=new Set){if(!Y.size)return!1;const de=z.filter(ge=>ge.type==="directory"&&ge.hasChildren).map(ge=>ge.path);return!de.length||de.length!==Y.size?!1:de.every(ge=>Y.has(ge))}function $e(){const z=De(io,[]);if(!Array.isArray(z)||!ue.value){c.value=[];return}c.value=z.filter(Y=>Y&&Y.sessionId===ue.value&&Y.path).sort((Y,de)=>Number(de.usedAt||0)-Number(Y.usedAt||0)).slice(0,rd)}function Le(z){return z.name||z.path||"."}function at(z){return z.path||"."}function Me(z){if(!ue.value||!(z!=null&&z.path))return;const Y={sessionId:ue.value,path:z.path,name:z.name||Le(z),type:z.type||"file",usedAt:Date.now()},de=De(io,[]),ge=[Y];Array.isArray(de)&&de.forEach(Ve=>{!(Ve!=null&&Ve.path)||!(Ve!=null&&Ve.sessionId)||Ve.sessionId===Y.sessionId&&Ve.path===Y.path||ge.push(Ve)}),je(io,ge.slice(0,40)),$e()}function et(z=""){const Y=String(z||"").trim();return!Y||!Y.includes("/")?"":Y.slice(0,Y.lastIndexOf("/"))}function Ne(){const z=ie.value;if(!z.length)return-1;const Y=z.findIndex(de=>de.path===g.value);return Y>=0?Y:0}function Je(){const z=ie.value,Y=Ne();return Y<0||!z.length?null:z[Y]||null}function Ie(){const z=ie.value;if(!z.length){g.value="";return}z.some(Y=>Y.path===g.value)||(g.value=z[0].path)}function ct(z,Y){if(Y){f.set(z,Y);return}f.delete(z)}function it(){var Y;const z=f.get(g.value);(Y=z==null?void 0:z.scrollIntoView)==null||Y.call(z,{block:"nearest"})}function Xe(z=""){return String(z||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Pt(z="",Y=""){const de=String(z||""),ge=String(Y||"").trim().toLowerCase();if(!de||!ge)return null;const Ve=de.toLowerCase(),Ct=Ve.indexOf(ge);if(Ct>=0)return{start:Ct,end:Ct+ge.length};const Zt=ge.split(/[\\/\s_.-]+/).filter(Boolean).sort((mt,Ft)=>Ft.length-mt.length);for(const mt of Zt){if(mt.length<2)continue;const Ft=Ve.indexOf(mt);if(Ft>=0)return{start:Ft,end:Ft+mt.length}}return null}function At(z="",Y=""){const de=String(z||""),ge=Pt(de,Y);return ge?`${Xe(de.slice(0,ge.start))}<mark class="theme-search-highlight">${Xe(de.slice(ge.start,ge.end))}</mark>${Xe(de.slice(ge.end))}`:Xe(de)}function C(z){return At(Le(z),j.value)}function N(z){return At(at(z),j.value)}async function ne(z="",Y={}){if(!n.sessionId){s.value=[],l.value="",r.value=!1;return}const de=!z,ge=de?null:Te(z);if(!(!de&&!ge)&&!(!Y.force&&(de&&s.value.length||!de&&ge.loaded))){de?(r.value=!0,l.value=""):(ge.loading=!0,l.value="",V());try{const Ve=await al(n.sessionId,{path:z,refreshToken:Y.refreshToken||""}),Ct=We(Ve.items||[]).map(Ge);if(de){s.value=Ct;return}ge.children=Ct,ge.loaded=!0}catch(Ve){l.value=Ve.message}finally{de?r.value=!1:(ge.loading=!1,V())}}}async function we(z=s.value,Y=new Set,de={}){for(const ge of z)ge.type!=="directory"||!Y.has(ge.path)||(ge.expanded=!0,V(),await ne(ge.path,de),ge.children.length&&await we(ge.children,Y,de))}async function Oe(z={}){await ne("",z);const Y=new Set(y.value),de=_e(s.value,Y),ge=Y.size>0&&!de;de&&(y.value=[],je(pe.value,[]),Y.clear());for(const Ve of s.value)Ve.type!=="directory"||!Ve.hasChildren||(Ve.expanded=ge?Y.has(Ve.path):!1);if(V(),ge){await we(s.value,Y,z);return}}async function Re(z){if(A.value!=="tree")return;const Y=Te(z);if(!(!Y||Y.type!=="directory")){if(!Y.loaded&&!Y.loading){Y.expanded=!0,V(),await ne(Y.path),Ae();return}Y.expanded=!Y.expanded,V(),Ae()}}function Qe(z){return z!=null&&z.path?(Me(z),o==null||o(z),!0):!1}async function Ze(z={}){const Y=j.value;ee+=1;const de=ee,ge=z.refreshToken||"";if(te(),!n.open||!n.sessionId||!Y||!M.value){p.value=!1,w.value="",u.value=[];return}D=new AbortController;try{const Ve=await il(n.sessionId,Y,{limit:80,refreshToken:ge,signal:D.signal});if(de!==ee)return;u.value=Ve.items||[]}catch(Ve){if(ta(Ve)||de!==ee)return;w.value=Ve.message,u.value=[]}finally{de===ee&&(D=null),de===ee&&(p.value=!1)}}function tt(z={}){if(te(),!n.open||!n.sessionId||!j.value||!M.value){p.value=!1,w.value="",u.value=[];return}p.value=!0,w.value="",P=window.setTimeout(()=>{P=null,Ze(z)},nd)}function Tt(){if(!n.sessionId){s.value=[],l.value="",r.value=!1,u.value=[],w.value="",p.value=!1;return}S=Date.now(),s.value=[],l.value="",u.value=[],w.value="",Oe({force:!0,refreshToken:S}),tt({refreshToken:S})}function $t(){if(J.value)return!1;const z=j.value?"search":"tree";return h.value===z?!1:(h.value=z,!0)}function St(){$e(),se(),$t(),Tt()}function Ht(){te(),u.value=[],w.value="",p.value=!1}function Dt(z){const Y=ie.value;if(!Y.length)return!1;const de=Ne(),ge=de<0?0:(de+z+Y.length)%Y.length;return g.value=Y[ge].path,ft(it),!0}async function le(){if(A.value!=="tree")return!1;const z=Je();if(!z||z.type!=="directory")return!1;if(!z.expanded)return await Re(z.path),g.value=z.path,!0;const Y=ie.value,de=Ne(),ge=Y[de+1];return ge&&et(ge.path)===z.path?(g.value=ge.path,!0):!1}function Be(){if(A.value!=="tree")return!1;const z=Je();if(!z)return!1;if(z.type==="directory"&&z.expanded){const de=Te(z.path);return de&&(de.expanded=!1,V(),Ae()),g.value=z.path,!0}const Y=et(z.path);return Y?(g.value=Y,!0):!1}function qe(){const z=ie.value;return z.length?Qe(z[Ne()]):!1}function xt(){s.value=[],l.value="",r.value=!1,u.value=[],w.value="",p.value=!1,$e(),se(),n.sessionId&&n.open&&(Oe({force:!0}),tt())}function Bt(){$t(),tt()}function Vt(){Ie(),ft(it)}return Mt(()=>{te()}),{activeKey:g,collapseActiveDirectory:Be,confirmActive:qe,currentError:T,currentLoading:ve,emitSelect:Qe,expandActiveDirectory:le,getDisplayName:Le,getHighlightedName:C,getHighlightedPath:N,handleQueryChange:Bt,handleSessionChange:xt,handleVisibleItemsChange:Vt,initializeData:St,moveActive:Dt,normalSearchItems:Z,normalizedQuery:j,recentSearchItems:E,resetData:Ht,setItemRef:ct,showSearchPromptState:O,showSearchEmptyState:U,showTreeEmptyState:He,toggleDirectory:Re,treeItems:X,visibleItems:ie}}const ad={class:"min-w-0"},id={class:"theme-heading truncate text-sm font-medium"},ld={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},ud={class:"theme-divider border-b px-4 py-3"},cd={class:"block"},dd={class:"sr-only"},fd={class:"relative"},pd=["placeholder","onKeydown"],md=["title","aria-label"],gd={class:"min-h-0 flex-1 overflow-y-auto p-2"},hd={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},vd={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},yd={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},Sd={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},wd={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},xd={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},bd={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},kd={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]"},Td={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},Cd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},Ed={key:11,class:"space-y-1"},Ad={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},$d=["onClick"],Id={class:"min-w-0 flex-1"},Pd=["innerHTML"],Dd=["innerHTML"],Ld={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Md=["onClick"],Bd={class:"min-w-0 flex-1"},Rd=["innerHTML"],Nd=["innerHTML"],Od={key:12,class:"space-y-3"},Fd={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},Ud={class:"min-w-0 flex-1"},jd={class:"theme-list-item-title theme-list-item-title--strong break-all"},Vd={key:0,class:"theme-list-item-meta truncate"},zd={class:"theme-list-item-meta shrink-0 pt-0.5"},Hd={class:"space-y-1 px-2 py-2"},qd=["onClick"],Kd=["innerHTML"],Wd={key:0,class:"theme-muted-text px-1 text-[12px]"},Gd={key:13,class:"space-y-1"},Xd=["onClick"],Yd={class:"flex items-start gap-1.5"},Jd=["onClick"],Qd={key:1,class:"block h-5 w-5 shrink-0"},Zd=["onClick"],ef={class:"flex min-h-0 flex-col overflow-hidden"},tf={class:"theme-divider border-b px-4 py-2"},nf={class:"flex items-center justify-between gap-3"},sf={class:"min-w-0"},of={key:0,class:"theme-muted-text truncate text-[12px]"},rf={key:1,class:"theme-muted-text mt-1 text-[11px]"},af={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},lf={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},uf={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},cf={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},df={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},ff={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},pf=["src","alt"],mf={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},gf={class:"source-code-view"},hf={class:"source-code-view__table"},vf=["innerHTML"],yf=20,Sf={__name:"CodexSessionSourceBrowserDialog",props:{open:{type:Boolean,default:!1},session:{type:Object,default:null}},emits:["close","insert-code-context"],setup(e,{emit:t}){const n=e,o=t,{t:s}=_t(),{isDark:r}=Er(),l=ps({open:!1,sessionId:"",query:""}),u=F(""),p=F(""),w=F(!1),c=F(""),y=F(null),h=F(""),g=F("path"),f=F([]),P=F(!1),ee=F(""),S=F(""),D=F(!1),j=F(""),G=new Map,M=F(null),J=F(null),A=F(0),X=F([]),ue=F("");let pe=0,E=0,Z=null,ce=null;const ie=sd,ve=od;let T=null;const U=new Map,O=K(()=>{var d;return String(((d=n.session)==null?void 0:d.id)||"").trim()}),He=K(()=>{var d;return String(((d=n.session)==null?void 0:d.cwd)||"").trim()}),De=K(()=>g.value!=="content"),je=K(()=>g.value==="content"),We=K(()=>String(h.value||"").trim()),Ge=K(()=>We.value.length>=Es),ut=K(()=>{var d;return((d=y.value)==null?void 0:d.name)||u.value||""}),Te=K(()=>{var d;return((d=y.value)==null?void 0:d.path)||u.value||""}),V=K(()=>{var d;return q(((d=y.value)==null?void 0:d.size)||0)}),te=K(()=>{var I,R;const d=[];return(Te.value||ut.value)&&d.push(Te.value||ut.value),(I=y.value)!=null&&I.size&&d.push(V.value),(R=y.value)!=null&&R.truncated&&d.push(s("sourceBrowser.truncated")),d.join(" ")}),he=K(()=>{var d;return!!((d=y.value)!=null&&d.previewUrl)}),Ae=K(()=>{var d,I;return!!((d=y.value)!=null&&d.binary&&!((I=y.value)!=null&&I.previewUrl))}),se=K(()=>!!(y.value&&!y.value.binary&&!y.value.previewUrl)),_e=F(""),$e=F(""),Le=F(""),at=F("2.6rem"),{selectedRows:Me,selectionAction:et,clearSelectionState:Ne,handleSelectionMouseUp:Je,updateSelectionActionFromDom:Ie}=ea({getContainer:()=>J.value,isActive:()=>n.open&&se.value,rowSelector:".source-code-view__line",mapRowElement:d=>{var R;const I=Number(((R=d==null?void 0:d.getAttribute)==null?void 0:R.call(d,"data-line"))||0);return I>0?I:null},getCodeLeft:d=>{var ke,ze,Ue;const I=(ke=d==null?void 0:d.querySelector)==null?void 0:ke.call(d,".source-code-view__code");if(!I)return 0;const R=(ze=I.getBoundingClientRect)==null?void 0:ze.call(I),B=(Ue=window.getComputedStyle)==null?void 0:Ue.call(window,I),ae=Number.parseFloat((B==null?void 0:B.paddingLeft)||"0")||0;return((R==null?void 0:R.left)||0)+ae},debounceMs:72}),ct=K(()=>[...new Set(Me.value)].map(d=>Number(d)||0).filter(d=>d>0).sort((d,I)=>d-I)),it=K(()=>{var R;const d=String(((R=y.value)==null?void 0:R.content)||"").replace(/\r\n/g,`
16
+ `),I=d?d.split(`
17
+ `):[];return[...ct.value].sort((B,ae)=>B-ae).map(B=>({lineNumber:B,content:String(I[B-1]||"")})).filter(B=>B.lineNumber>0)}),Xe=K(()=>it.value.length>0),Pt=K(()=>je.value?s("sourceBrowser.contentSearchPlaceholder"):s("sourceBrowser.searchPlaceholder")),At=K(()=>je.value?s("sourceBrowser.searchModeContent"):s("sourceBrowser.searchModePath")),C=K(()=>!!We.value),N=K(()=>C.value?"search":"tree"),ne=K(()=>C.value&&je.value?P.value:Be.value),we=K(()=>De.value&&bt.value),Oe=K(()=>De.value&&Ft.value),Re=K(()=>C.value&&je.value&&!Ge.value&&!P.value&&!ee.value),Qe=K(()=>C.value&&je.value&&Ge.value&&!!S.value&&!P.value&&!ee.value&&!f.value.length),Ze=K(()=>C.value&&je.value&&Ge.value&&!P.value&&!ee.value&&!S.value&&!f.value.length),tt=K(()=>{const d=[],I=new Map;return f.value.forEach(R=>{const B=String((R==null?void 0:R.path)||"").trim();if(!B)return;let ae=I.get(B);ae||(ae={path:B,name:String((R==null?void 0:R.name)||B.split("/").pop()||B),items:[]},I.set(B,ae),d.push(ae)),ae.items.push(R)}),d}),Tt=K(()=>f.value.map(d=>It(d)).join("|")),$t=K(()=>qt.value.map(d=>{const I=String((d==null?void 0:d.path)||"").trim(),R=d!=null&&d.expanded?1:0,B=d!=null&&d.loading?1:0;return`${I}:${R}:${B}`}).join("|")),{activeKey:St,collapseActiveDirectory:Ht,expandActiveDirectory:Dt,currentError:le,currentLoading:Be,getDisplayName:qe,getHighlightedName:xt,getHighlightedPath:Bt,handleQueryChange:Vt,handleSessionChange:z,handleVisibleItemsChange:Y,initializeData:de,moveActive:ge,normalSearchItems:Ve,recentSearchItems:Ct,resetData:Zt,setItemRef:mt,showSearchPromptState:Ft,showSearchEmptyState:bt,showTreeEmptyState:sn,toggleDirectory:dn,treeItems:fn,visibleItems:qt}=na({getMode:()=>N.value,props:l,onSelect:wn});function Kt(d=""){return String(d||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function It(d){return`${(d==null?void 0:d.path)||""}:${(d==null?void 0:d.line)||0}:${(d==null?void 0:d.column)||0}`}function $(d,I){if(I){G.set(d,I);return}G.delete(d)}function Q(){var I;const d=G.get(j.value);(I=d==null?void 0:d.scrollIntoView)==null||I.call(d,{block:"nearest"})}function H(d="",I=""){const R=String(d||""),B=String(I||"").trim();if(!R||!B)return Kt(R);const ae=R.toLowerCase(),ke=B.toLowerCase(),ze=ae.indexOf(ke);if(ze<0)return Kt(R);const Ue=ze+ke.length;return`${Kt(R.slice(0,ze))}<mark class="theme-search-highlight">${Kt(R.slice(ze,Ue))}</mark>${Kt(R.slice(Ue))}`}function Ce(d="",I=""){const R=String(d||""),B=String(I||"").trim();if(!R||!B)return[];const ae=R.toLowerCase(),ke=B.toLowerCase(),ze=[];let Ue=0;for(;Ue<ae.length;){const v=ae.indexOf(ke,Ue);if(v<0)break;ze.push({start:v,end:v+ke.length}),Ue=v+ke.length}return ze}function Xt(d,I,R){if(!d)return null;if(d.nodeType===Node.TEXT_NODE){const ae=d.textContent||"",ke=R.offset,ze=ke+ae.length;if(R.offset=ze,!ae)return document.createTextNode("");const Ue=I.filter(ye=>ye.start<ze&&ye.end>ke);if(!Ue.length)return document.createTextNode(ae);const v=document.createDocumentFragment();let W=0;return Ue.forEach(ye=>{const xe=Math.max(0,ye.start-ke),nt=Math.min(ae.length,ye.end-ke);if(xe>W&&v.appendChild(document.createTextNode(ae.slice(W,xe))),nt>xe){const yt=document.createElement("mark");yt.className="source-code-view__search-hit",yt.textContent=ae.slice(xe,nt),v.appendChild(yt)}W=Math.max(W,nt)}),W<ae.length&&v.appendChild(document.createTextNode(ae.slice(W))),v}if(d.nodeType!==Node.ELEMENT_NODE)return d.cloneNode(!0);const B=d.cloneNode(!1);return Array.from(d.childNodes||[]).forEach(ae=>{const ke=Xt(ae,I,R);ke&&B.appendChild(ke)}),B}function k(d=J.value){var I,R,B;d&&((B=(R=(I=d.querySelectorAll)==null?void 0:I.call(d,".source-code-view__line-inner[data-original-html]"))==null?void 0:R.forEach)==null||B.call(R,ae=>{const ke=ae.dataset.originalHtml;typeof ke=="string"&&(ae.innerHTML=ke)}))}function _(){var R,B,ae;const d=J.value,I=String(ue.value||"").trim();d&&(k(d),I&&((ae=(B=(R=d.querySelectorAll)==null?void 0:R.call(d,".source-code-view__line.is-match .source-code-view__line-inner"))==null?void 0:B.forEach)==null||ae.call(B,ke=>{ke.dataset.originalHtml||(ke.dataset.originalHtml=ke.innerHTML);const ze=Ce(ke.textContent||"",I);if(!ze.length)return;const Ue=document.createDocumentFragment(),v={offset:0};Array.from(ke.childNodes||[]).forEach(W=>{const ye=Xt(W,ze,v);ye&&Ue.appendChild(ye)}),ke.replaceChildren(Ue)})))}function q(d=0){const I=Math.max(0,Number(d)||0);return I<1024?`${I} B`:I<1024*1024?`${(I/1024).toFixed(I<10*1024?1:0)} KB`:`${(I/(1024*1024)).toFixed(1)} MB`}function re(){var I,R,B;const d=J.value;d&&(k(d),(B=(R=(I=d.querySelectorAll)==null?void 0:I.call(d,".source-code-view__line.is-match, .source-code-view__line.is-focus-match"))==null?void 0:R.forEach)==null||B.call(R,ae=>ae.classList.remove("is-match","is-focus-match")))}function oe(){var I,R,B;const d=J.value;d&&((B=(R=(I=d.querySelectorAll)==null?void 0:I.call(d,".source-code-view__line.is-selected"))==null?void 0:R.forEach)==null||B.call(R,ae=>ae.classList.remove("is-selected")))}function Se(){oe();const d=J.value;!d||!ct.value.length||ct.value.forEach(I=>{var ae,ke;const R=d.querySelector(`.source-code-view__gutter[data-line="${I}"]`),B=(ae=R==null?void 0:R.closest)==null?void 0:ae.call(R,"tr");(ke=B==null?void 0:B.classList)==null||ke.add("is-selected")})}function ht(){if(!ct.value.length)return"";const d=[...ct.value].sort((I,R)=>I-R);return d[0]===d[d.length-1]?`L${d[0]}`:`L${d[0]}-${d[d.length-1]}`}function Fe(){var I,R,B,ae;if(!y.value||!Xe.value)return;const d=it.value.map(ke=>ke.lineNumber);o("insert-code-context",{source:"source",filePath:Te.value,language:String(((I=y.value)==null?void 0:I.language)||""),rangeLabel:ht(),lineStart:Math.min(...d),lineEnd:Math.max(...d),content:String(et.value.content||"").trim()||it.value.map(ke=>ke.content).join(`
18
+ `)}),(ae=(B=(R=window.getSelection)==null?void 0:R.call(window))==null?void 0:B.removeAllRanges)==null||ae.call(B),Ne(),o("close")}function en(d){var ze,Ue,v,W;const I=(ze=window.getSelection)==null?void 0:ze.call(window),R=J.value;if(!I||I.rangeCount<1||I.isCollapsed||!R)return;Ie();const ae=I.getRangeAt(0).commonAncestorContainer;if(!R.contains((ae==null?void 0:ae.nodeType)===1?ae:ae==null?void 0:ae.parentNode))return;const ke=String(I.toString()||"").replace(/\u200b/g,"");ke&&((v=(Ue=d==null?void 0:d.clipboardData)==null?void 0:Ue.setData)==null||v.call(Ue,"text/plain",ke),(W=d==null?void 0:d.preventDefault)==null||W.call(d))}function Wt(){T&&(window.clearTimeout(T),T=null)}function Dn(){U.clear()}function Ln(d=""){const I=String(d||"").trim();if(!I||!U.has(I))return null;const R=U.get(I);return U.delete(I),U.set(I,R),R}function on(d="",I=null){const R=String(d||"").trim();if(!(!R||!I))for(U.delete(R),U.set(R,I);U.size>yf;){const B=U.keys().next().value;if(!B)break;U.delete(B)}}function Ut(d){Wt(),T=window.setTimeout(()=>{T=null,d==null||d()},ve)}function vt(){ft(()=>{var d,I;(I=(d=M.value)==null?void 0:d.focus)==null||I.call(d)})}function pn(d){var I,R,B;if((I=d==null?void 0:d.preventDefault)==null||I.call(d),We.value){(R=d==null?void 0:d.stopPropagation)==null||R.call(d),h.value="";return}(B=d==null?void 0:d.stopPropagation)==null||B.call(d),o("close")}function Xn(){Wt(),pe+=1,Dn(),u.value="",p.value="",w.value=!1,c.value="",y.value=null,_e.value="",$e.value="",Le.value="",at.value="2.6rem",A.value=0,X.value=[],ue.value="",Ne(),re()}function tn(){E+=1,Z&&(window.clearTimeout(Z),Z=null),ce&&(ce.abort(),ce=null),f.value=[],P.value=!1,ee.value="",S.value="",D.value=!1,j.value="",X.value=[],ue.value="",re()}function Xs(){if(Z&&(window.clearTimeout(Z),Z=null),!n.open||!O.value||!je.value)return;if(!We.value||!Ge.value){tn();return}P.value=!0,ee.value="",Z=window.setTimeout(()=>{Z=null,Qn()},ie)}function Mn(d=1){const I=f.value;if(!I.length)return!1;const R=I.findIndex(ae=>It(ae)===j.value),B=R<0?0:(R+d+I.length)%I.length;return j.value=It(I[B]),ft(Q),!0}function Bn(){return qt.value.length&&(qt.value.find(d=>d.path===St.value)||qt.value[0])||null}function Yt(d,I={}){return d?(St.value=(d==null?void 0:d.path)||"",j.value="",u.value=String((d==null?void 0:d.path)||"").trim(),p.value=String((d==null?void 0:d.type)||"").trim(),c.value="",A.value=0,X.value=[],ue.value="",(d==null?void 0:d.type)==="directory"?(Wt(),y.value=null,I.toggleDirectory&&!C.value&&dn(d.path),!0):I.previewMode==="debounced"?(Ut(()=>Jn(d==null?void 0:d.path)),!0):(Wt(),Jn(d==null?void 0:d.path),!0)):!1}function gs(){const d=f.value;if(!d.length)return!1;const I=d.find(R=>It(R)===j.value)||d[0];return xn(I),!0}function Ys(d){const I=String((d==null?void 0:d.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(I)&&!(C.value&&(I==="ArrowLeft"||I==="ArrowRight"))){if(je.value&&C.value){if(I==="ArrowDown"){if(d.preventDefault(),Mn(1)){const R=f.value,B=R.find(ae=>It(ae)===j.value)||R[0];xn(B,{previewMode:"debounced"})}return}if(I==="ArrowUp"){if(d.preventDefault(),Mn(-1)){const R=f.value,B=R.find(ae=>It(ae)===j.value)||R[0];xn(B,{previewMode:"debounced"})}return}if(I==="Enter"){d.preventDefault(),gs();return}I==="Escape"&&pn(d);return}if(I==="ArrowDown"){d.preventDefault(),ge(1)&&ft(()=>{Yt(Bn(),{previewMode:"debounced"})});return}if(I==="ArrowUp"){d.preventDefault(),ge(-1)&&ft(()=>{Yt(Bn(),{previewMode:"debounced"})});return}if(I==="ArrowRight"){d.preventDefault(),Dt();return}if(I==="ArrowLeft"){d.preventDefault(),Ht();return}if(I==="Enter"){d.preventDefault(),Yt(Bn(),{toggleDirectory:!0});return}I==="Escape"&&pn(d)}}async function Rn(){const d=je.value?"path":"content";if(g.value=d,!We.value){d==="content"?tn():(tn(),l.query="");return}if(d==="content"){l.query="",Qn();return}tn(),l.query=h.value}function Js(d){var I;d.preventDefault(),(I=d.stopPropagation)==null||I.call(d),Rn().finally(()=>{vt()})}async function Sn(){var ke;if(await ft(),re(),!J.value)return;const d=[...new Set(X.value.map(ze=>Math.max(0,Number(ze)||0)).filter(ze=>ze>0))],I=Math.max(0,Number(A.value)||0);if(d.forEach(ze=>{var W,ye;const Ue=J.value.querySelector(`.source-code-view__gutter[data-line="${ze}"]`),v=(W=Ue==null?void 0:Ue.closest)==null?void 0:W.call(Ue,"tr");(ye=v==null?void 0:v.classList)==null||ye.add("is-match")}),_(),!I){Se();return}const R=I,B=J.value.querySelector(`.source-code-view__gutter[data-line="${R}"]`),ae=(ke=B==null?void 0:B.closest)==null?void 0:ke.call(B,"tr");if(!ae){Se();return}ae.classList.add("is-match","is-focus-match"),_(),ae.scrollIntoView({block:"center",inline:"nearest"}),Se()}async function Yn(){var ke,ze,Ue;if(!se.value){_e.value="",$e.value="",Le.value="";return}const d=pe,I=String(((ke=y.value)==null?void 0:ke.content)||"").replace(/\r\n/g,`
19
+ `),R=((ze=y.value)==null?void 0:ze.language)||"",B=sc(I,ro),ae=await ac(((Ue=y.value)==null?void 0:Ue.content)||"",{isDark:r.value,language:R,maxHighlightLines:ro.maxLines,maxHighlightChars:ro.maxChars});d===pe&&(_e.value=ae.html,$e.value=B?"":ae.bg||"",Le.value=B?"":ae.fg||"",at.value=ae.gutterWidth||"2.6rem",await ft(),Se())}async function Jn(d="",I={}){var ze;const R=String(d||"").trim();if(!O.value||!R)return;A.value=Math.max(0,Number(I.focusLine)||0),Ne();const B=String(((ze=y.value)==null?void 0:ze.path)||"").trim();if(!I.forceReload&&B===R&&!w.value&&!c.value){await Sn();return}if(!I.forceReload&&w.value&&u.value===R)return;pe+=1;const ae=pe;c.value="";const ke=I.forceReload?null:Ln(R);if(ke){w.value=!1,y.value=ke,await Yn(),ae===pe&&se.value&&await Sn();return}w.value=!0;try{const Ue=await ll(O.value,{path:R,limit:204800,refreshToken:String(Date.now())});if(ae!==pe)return;y.value=Ue,on(R,Ue),await Yn()}catch(Ue){if(ae!==pe)return;y.value=null,c.value=(Ue==null?void 0:Ue.message)||s("sourceBrowser.previewFailed")}finally{ae===pe&&(w.value=!1,se.value&&await Sn())}}function wn(d){Yt(d,{toggleDirectory:!0}),ft(vt)}function hs(d,I){var R,B;(B=(R=d==null?void 0:d.currentTarget)==null?void 0:R.focus)==null||B.call(R),wn(I)}async function Qn(){const d=We.value;if(!n.open||!O.value)return;E+=1;const I=E;if(!d||!Ge.value){tn();return}ce&&(ce.abort(),ce=null),P.value=!0,ee.value="",f.value=[],D.value=!1,j.value="",ce=new AbortController;try{const R=await ul(O.value,d,{limit:80,refreshToken:String(Date.now()),signal:ce.signal});if(I!==E)return;S.value=d,f.value=Array.isArray(R.items)?R.items:[],D.value=!!R.truncated,j.value=f.value[0]?It(f.value[0]):"",f.value[0]&&xn(f.value[0],{previewMode:"debounced"})}catch(R){if(ta(R)||I!==E)return;S.value=d,f.value=[],ee.value=(R==null?void 0:R.message)||s("sourceBrowser.contentSearchFailed")}finally{I===E&&(ce=null),I===E&&(P.value=!1)}}function xn(d,I={}){j.value=It(d),St.value=(d==null?void 0:d.path)||"",u.value=String((d==null?void 0:d.path)||"").trim(),p.value="file",c.value="",ue.value=S.value||We.value,X.value=f.value.filter(B=>(B==null?void 0:B.path)===(d==null?void 0:d.path)).map(B=>Number((B==null?void 0:B.line)||0)).filter(B=>B>0);const R=()=>Jn(d==null?void 0:d.path,{focusLine:d==null?void 0:d.line});if(I.previewMode==="debounced"){Ut(R),ft(vt);return}Wt(),R(),ft(vt)}function Qs(d){const I=String((d==null?void 0:d.path)||"").trim();if(!I)return"";const R=I.split("/");return R[R.length-1]||I}function Zn(d){const I=String((d==null?void 0:d.path)||"").trim();return!I||!I.includes("/")?"":I.slice(0,I.lastIndexOf("/"))}function Zs(d){return`${Array.isArray(d==null?void 0:d.items)?d.items.length:0} 处`}function es(d){const I=S.value||We.value;return H((d==null?void 0:d.preview)||"",I)}return Pe(()=>n.open,d=>{var I,R,B,ae,ke,ze;if(l.open=d,d){(B=(R=(I=window.getSelection)==null?void 0:I.call(window))==null?void 0:R.removeAllRanges)==null||B.call(R),l.sessionId=O.value,h.value="",g.value="path",l.query="",Xn(),tn(),de(),vt();return}(ze=(ke=(ae=window.getSelection)==null?void 0:ae.call(window))==null?void 0:ke.removeAllRanges)==null||ze.call(ke),h.value="",g.value="path",Xn(),tn(),Zt()},{immediate:!0}),Pe(O,d=>{l.sessionId=d,n.open&&(Xn(),tn(),z())}),Pe(h,d=>{if(De.value){l.query=d;return}String(d||"").trim()!==String(S.value||"").trim()&&(ue.value="",_()),Xs()}),Pe(()=>l.query,()=>{De.value&&Vt()}),Pe(Tt,()=>{ft(Q)}),Pe($t,()=>{Y(),!(!C.value||!De.value)&&ft(()=>{const d=Bn();d&&Yt(d,{previewMode:"debounced"})})}),Pe(r,async()=>{!n.open||!se.value||(await Yn(),await Sn())}),Pe(ct,()=>{Se()}),Mt(()=>{var d,I,R;(R=(I=(d=window.getSelection)==null?void 0:d.call(window))==null?void 0:I.removeAllRanges)==null||R.call(I),Ne({clearBrowserSelection:!0}),Wt()}),(d,I)=>(m(),Ee(Ws,{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:I[2]||(I[2]=R=>o("close"))},{title:st(()=>[i("div",ad,[i("div",id,x(He.value||a(s)("sourceBrowser.title")),1)])]),default:st(()=>{var R;return[i("div",ld,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:Ys},[i("div",ud,[i("label",cd,[i("span",dd,x(a(s)("sourceBrowser.searchLabel")),1),i("div",fd,[fe(a(Na),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),Jt(i("input",{ref_key:"searchInputRef",ref:M,"onUpdate:modelValue":I[0]||(I[0]=B=>h.value=B),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:Pt.value,onKeydown:[Qt(pn,["esc"]),Qt(ot(Js,["prevent"]),["tab"])]},null,40,pd),[[ss,h.value]]),ne.value?(m(),Ee(a(Gt),{key:0,class:"theme-muted-text pointer-events-none absolute right-10 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin"})):me("",!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:At.value,"aria-label":At.value,onClick:ot(Rn,["stop","prevent"])},[fe(a(Oa),{class:"h-3.5 w-3.5"})],8,md)])])]),i("div",gd,[O.value?C.value&&je.value&&ee.value?(m(),b("div",vd,x(ee.value),1)):a(le)?(m(),b("div",yd,x(a(le)),1)):Oe.value?(m(),b("div",Sd,x(a(s)("sourceBrowser.searchMinKeywordHint",{count:a(Es)})),1)):we.value?(m(),b("div",wd,x(a(s)("sourceBrowser.searchEmpty")),1)):Re.value?(m(),b("div",xd,x(a(s)("sourceBrowser.searchMinKeywordHint",{count:a(Es)})),1)):Ze.value?(m(),b("div",bd,x(a(s)("sourceBrowser.contentSearchPrompt")),1)):Qe.value?(m(),b("div",kd,x(a(s)("sourceBrowser.contentSearchEmpty")),1)):a(sn)?(m(),b("div",_d,x(a(s)("sourceBrowser.treeEmpty")),1)):C.value&&je.value&&P.value&&!f.value.length?(m(),b("div",Td,x(a(s)("sourceBrowser.contentSearching")),1)):a(Be)&&!a(qt).length?(m(),b("div",Cd,x(a(s)("sourceBrowser.loadingFiles")),1)):C.value&&De.value?(m(),b("div",Ed,[a(Ct).length?(m(),b("div",Ad,x(a(s)("sourceBrowser.recent")),1)):me("",!0),(m(!0),b(lt,null,pt(a(Ct),B=>(m(),b("button",{key:`recent-${B.path}`,ref_for:!0,ref:ae=>a(mt)(B.path,ae),type:"button",class:be(["theme-list-row focus:outline-none",a(St)===B.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:ae=>wn(B)},[(m(),Ee(yn(B.type==="directory"?a(jn):a(Cn)),{class:"theme-list-item-icon"})),i("div",Id,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(xt)(B)},null,8,Pd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Bt)(B)},null,8,Dd)])],10,$d))),128)),l.query.trim()&&a(Ve).length?(m(),b("div",Ld,x(a(s)("sourceBrowser.results")),1)):me("",!0),(m(!0),b(lt,null,pt(a(Ve),B=>(m(),b("button",{key:`result-${B.path}`,ref_for:!0,ref:ae=>a(mt)(B.path,ae),type:"button",class:be(["theme-list-row focus:outline-none",a(St)===B.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:ae=>wn(B)},[(m(),Ee(yn(B.type==="directory"?a(jn):a(Cn)),{class:"theme-list-item-icon"})),i("div",Bd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(xt)(B)},null,8,Rd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Bt)(B)},null,8,Nd)])],10,Md))),128))])):C.value?(m(),b("div",Od,[(m(!0),b(lt,null,pt(tt.value,B=>(m(),b("div",{key:B.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",Fd,[fe(a(Cn),{class:"theme-list-item-icon"}),i("div",Ud,[i("div",jd,x(Qs(B)),1),Zn(B)?(m(),b("div",Vd,x(Zn(B)),1)):me("",!0)]),i("div",zd,x(Zs(B)),1)]),i("div",Hd,[(m(!0),b(lt,null,pt(B.items,ae=>(m(),b("button",{key:It(ae),ref_for:!0,ref:ke=>$(It(ae),ke),type:"button",class:be(["theme-list-row gap-0 focus:outline-none",j.value===It(ae)?"theme-list-item-active":"theme-list-item-hover"]),onClick:ke=>xn(ae)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:es(ae)},null,8,Kd)],10,qd))),128))])]))),128)),D.value?(m(),b("div",Wd,x(a(s)("sourceBrowser.contentSearchTruncated")),1)):me("",!0)])):(m(),b("div",Gd,[(m(!0),b(lt,null,pt(a(fn),B=>(m(),b("div",{key:B.path,ref_for:!0,ref:ae=>a(mt)(B.path,ae),class:be(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(St)===B.path?"theme-list-item-active":B.type==="directory"&&B.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:In({paddingLeft:`${B.depth*16+6}px`}),tabindex:"-1",onClick:ae=>hs(ae,B)},[i("div",Yd,[B.type==="directory"?(m(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:ot(ae=>a(dn)(B.path),["stop"])},[B.loading?(m(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(m(),Ee(a(Pr),{key:1,class:be(["h-3.5 w-3.5 transition",B.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Jd)):(m(),b("span",Qd)),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:ot(ae=>wn(B),["stop"])},[(m(),Ee(yn(B.type==="directory"?a(jn):a(Cn)),{class:be(["h-4 w-4 shrink-0",B.type==="directory"&&B.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:be(["theme-list-item-title min-w-0 flex-1 truncate",B.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},x(a(qe)(B)),3)],8,Zd)])],14,Xd))),128))])):(m(),b("div",hd,x(a(s)("sourceBrowser.noProject")),1))])],32),i("section",ef,[i("div",tf,[i("div",nf,[i("div",sf,[te.value?(m(),b("p",of,x(te.value),1)):me("",!0),se.value?(m(),b("p",rf,x(a(s)("sourceBrowser.selectCodeLineHint")),1)):me("",!0)])])]),i("div",af,[w.value?(m(),b("div",lf,[i("span",null,x(a(s)("sourceBrowser.previewLoading")),1)])):c.value?(m(),b("div",uf,x(c.value),1)):p.value==="directory"?(m(),b("div",cf,x(a(s)("sourceBrowser.selectFileHint")),1)):u.value?he.value?(m(),b("div",ff,[i("img",{src:y.value.previewUrl,alt:ut.value,class:"source-browser-image object-contain"},null,8,pf)])):Ae.value?(m(),b("div",mf,[fe(a(Fa),{class:"h-8 w-8"}),i("span",null,x((R=y.value)!=null&&R.tooLarge?a(s)("sourceBrowser.binaryTooLarge"):a(s)("sourceBrowser.binaryUnsupported")),1)])):se.value?(m(),b("div",{key:6,ref_key:"previewContainerRef",ref:J,class:"source-browser-code relative rounded-sm border",style:In({"--source-code-bg":$e.value||"var(--theme-panel)","--source-code-fg":Le.value||"var(--theme-textPrimary)","--source-code-gutter-width":at.value}),onCopy:en,onMouseup:I[1]||(I[1]=(...B)=>a(Je)&&a(Je)(...B))},[i("div",gf,[i("table",hf,[i("tbody",{innerHTML:_e.value},null,8,vf)])]),e.open&&a(et).visible?(m(),Ee(Qr,{key:0,top:a(et).top,left:a(et).left,label:a(s)("sourceBrowser.insertSelection"),onClick:Fe},null,8,["top","left","label"])):me("",!0)],36)):me("",!0):(m(),b("div",df,x(a(s)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},wf=Cr(Sf,[["__scopeId","data-v-100e8f17"]]);function xf(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:p=null}=e,w=new Map,c=new Map,y=F(0),h=K(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(S=>{const D=!!r(S),j=String(o(S)||"").trim(),G=D?String(s(S)||""):"";return{item:S,active:D,cacheKey:j,source:G}}));function g(S){if(y.value,!r(S))return"";const D=String(s(S)||""),j=String(o(S)||"").trim(),G=String((n==null?void 0:n.value)||"");if(!j)return u(D,S);const M=w.get(j);return(M==null?void 0:M.source)===D&&(M==null?void 0:M.theme)===G?M.html:u(D,S)}async function f(S){if(!r(S))return;const D=String(s(S)||""),j=String(o(S)||"").trim();if(!j)return;const G=String((n==null?void 0:n.value)||""),M=w.get(j);if((M==null?void 0:M.source)===D&&(M==null?void 0:M.theme)===G)return;const J=Symbol(j);c.set(j,J);try{const A=await l(D,S,{themeKey:G});if(c.get(j)!==J)return;w.set(j,{source:D,theme:G,html:A}),y.value+=1,p==null||p(S,{cacheKey:j,source:D,themeKey:G})}catch{}finally{c.get(j)===J&&c.delete(j)}}function P(S=[]){S.forEach(D=>{D!=null&&D.item&&f(D.item)})}function ee(S=[]){const D=new Set((Array.isArray(S)?S:[]).filter(G=>G==null?void 0:G.active).map(G=>String((G==null?void 0:G.cacheKey)||"").trim()).filter(Boolean));let j=!1;for(const G of w.keys())D.has(G)||(w.delete(G),j=!0);for(const G of c.keys())D.has(G)||c.delete(G);j&&(y.value+=1)}return Pe(h,()=>{ee(h.value||[]),P(h.value||[])},{immediate:!0}),Pe(n,()=>{P(h.value||[])}),Mt(()=>{c.clear()}),{getRenderedHtml:g}}const bf=`${Mo()}/api/events/stream`,zn=new Set;let En=null,As=null;function yo(){As&&(window.clearTimeout(As),As=null)}function sa(){En&&(En.close(),En=null)}function kf(e){zn.forEach(t=>{try{t(e)}catch{}})}function oa(){typeof window>"u"||typeof window.EventSource>"u"||En||!zn.size||(yo(),En=new window.EventSource(bf),En.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;kf(t)}catch{}},En.onerror=()=>{sa(),zn.size&&(yo(),As=window.setTimeout(()=>{oa()},1500))})}function _f(e){return typeof e!="function"?()=>{}:(zn.add(e),oa(),()=>{zn.delete(e),!zn.size&&(yo(),sa())})}const ra=F(0),So=F(0),$s=F(""),os=F(""),Is=F(0),aa=ps({}),wo=ps({}),xo=ps({}),rs=new Map;let Zo=!1;const Tf=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),Cf=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function lo(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function Ef(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&Tf.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 Af(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:Cf.has(r)}function $f(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=rs.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function If(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=Ef(e);if(t){if(t==="ready"){ra.value+=1,$s.value="",os.value="",Is.value+=1;return}if(t==="tasks.changed"){$s.value=n,os.value=String(e.reason||"").trim(),o.updatesTaskList&&(So.value+=1),o.updatesTaskDiff&&lo(wo,n);return}if(t==="runs.changed"){$s.value=n,os.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},r=n&&xo[n]||null,l=Af(r,s);n&&(xo[n]=s),o.updatesTaskList&&!l&&(So.value+=1),o.updatesSessions&&(Is.value+=1),o.updatesTaskRuns&&lo(aa,n),o.updatesTaskDiff&&!l&&lo(wo,n);return}if(t==="sessions.changed"){os.value="",o.updatesSessions&&(Is.value+=1);return}t==="run.event"&&$f(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function ia(){Zo||typeof window>"u"||(_f(e=>{If(e)}),Zo=!0)}function Pf(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(aa[t])||0):0}function Df(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(wo[t])||0):0}function Lf(e=""){const t=String(e||"").trim();return t&&xo[t]||null}function Mf(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};ia();const o=rs.get(n)||new Set;return o.add(t),rs.set(n,o),()=>{const s=rs.get(n);s&&(s.delete(t),s.size||rs.delete(n))}}function la(){return ia(),{readyVersion:ra,listSyncVersion:So,listSyncTaskSlug:$s,listSyncReason:os,sessionsSyncVersion:Is,getTaskRunSyncVersion:Pf,getTaskRunChange:Lf,getTaskDiffSyncVersion:Df}}const Bf=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,Rf=/\u001B\[[0-?]*[ -/]*[@-~]/g,Nf=/\u001B[@-_]/g,Of=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function Ff(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function Wn(e=""){return Ff(String(e||"")).replace(Bf,"").replace(Rf,"").replace(Nf,"").replace(/\r\n/g,`
20
+ `).replace(/\r/g,`
21
+ `).replace(Of,"")}function ms(e=""){return Wn(e)}function Pn(e=""){return String(e||"").replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function No(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 Uf(e=""){const t=Pn(ms(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=Pn(n.slice(1).join(`
23
+ `));return{meta:{type:"meta",items:[{label:s[1].trim(),value:s[2].trim()}]},rest:u}}function jf(e="",t={}){const n=Pn(ms(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(w=>w.trim()).filter(Boolean).filter(w=>!/^\(\d+\s+entries?\)$/i.test(w)),{items:u,hiddenCount:p}=No(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:p}}function Vf(e="",t={}){const n=Pn(ms(e));if(!n.trim())return null;const o=n.split(`
25
+ `).map(u=>u.trimEnd()),s=o.map(u=>{const p=u.match(/^\s*\[([ xX])\]\s+(.+)$/);return p?{completed:p[1].toLowerCase()==="x",text:p[2].trim()}:null}).filter(Boolean);if(!s.length||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:r,hiddenCount:l}=No(s,t.maxItems??12);return{type:"checklist",items:r,totalCount:s.length,hiddenCount:l}}function zf(e="",t={}){const n=Pn(ms(e));if(!n.trim())return null;const o=n.split(`
26
+ `),s=o.map(u=>{const p=u.match(/^[-*]\s+(.+)$/);return p?p[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}=No(s,t.maxItems??12);return{type:"bullet_list",items:r,totalCount:s.length,hiddenCount:l}}function Hf(e="",t={}){return{type:t.preferMarkdown?"markdown":"text",text:e}}function qf(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 Kf(e="",t={}){const n=String(e||"").split(/\n{2,}/).map(l=>Pn(l)).filter(l=>l.trim());if(n.length<2)return null;const o=qf(n.flatMap(l=>Oo(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 Oo(e="",t={}){const n=Pn(ms(e));if(!n.trim())return[];const o=Uf(n);if(o!=null&&o.rest){const u=Oo(o.rest,t);return[o.meta,...u.length?u:[{type:"text",text:o.rest}]]}const s=jf(n,t);if(s)return[s];const r=Vf(n,t);if(r)return[r];const l=zf(n,t);if(l)return[l];if(!t._disableMixedSegmentation){const u=Kf(n,t);if(u!=null&&u.length)return u}return[Hf(n,t)]}const Wf=new Set(["queued","starting","running","stopping"]);function hn(){return qs()==="en-US"}function L(e,t){return hn()?t:e}function er(e=""){const t=Date.parse(String(e||""));return Number.isFinite(t)?t:0}function tr(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=er(o.updatedAt)-er(n.updatedAt);return l||String(n.title||n.cwd||n.id).localeCompare(String(o.title||o.cwd||o.id),qs())})}function ua(e="",t=24,n=2400){const o=Wn(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 Tn(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||L("未命名任务","Untitled Task")}`}).join(`
32
+ `):""}function Nt(e=0){const t=Number(e||0);return Number.isFinite(t)?t.toLocaleString(qs()):"0"}function Fo(e=""){return String(e||"").trim().toLowerCase()==="shell"}function Gf(e=""){return Fo(e)?L("Shell","Shell"):gt(e)}function Xf(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 ca(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 Fs(e={}){return ca(e).length}function da(e={}){const t=ca(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:Xf(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?$n(r):[]}})}function Yf(e={},t=120){const n=da(e).map(o=>o.message).filter(Boolean);return wt(n.join(hn()?" | ":"|"),t)}function fa(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?hn()?`${n}h ${o}m ${s}s`:`${n}小时${o}分${s}秒`:hn()?`${o}m ${s}s`:`${o}分${s}秒`}function wt(e="",t=140){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,t)}...`:""}function pa(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 ls(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 Jf(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 Qf(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)||L("未命名任务","Untitled Task")}function Ps(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=Jf(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:Qf(t)}}).filter(Boolean)}function nr(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return Ps(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return Ps(n.todos);if(Array.isArray(n.items))return Ps(n.items)}}catch{return[]}return[]}function ma(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function Uo(e=""){var w;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(),p=o?((w=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:w[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:r,category:p}}function us(e={},t=null){const n=t||Uo(e.command);if(n.category!=="todo")return[];const o=nr(e.aggregated_output);return o.length?o:nr(n.subject)}function $n(e="",t={}){return Oo(Wn(e),t)}function sr(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=ls([n?{label:L("关键词","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 or(e={}){const t=String(e.tool||"").trim(),n=Fs(e),o=String(e.prompt||"").trim(),s=da(e),r=[],l=[t?{label:L("工具","Tool"),value:t}:null,n?{label:L("子代理","Sub-agent"),value:String(n)}:null],u=ls(l);return u&&r.push(u),s.length&&r.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&r.push(...$n(o,{preferMarkdown:!0})),r}function rr(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 ws(e={},t=!1,n="codex"){const o=[],s=Uo(e.command),r=us(e,s),l=ma(r),u=typeof e.exit_code=="number",p=u?e.exit_code===0:e.status==="completed",w=ls([s.toolName?{label:L("工具","Tool"),value:s.toolName}:null,l||s.category!=="shell"?null:s.subject?{label:L("命令","Command"),value:s.subject}:e.command?{label:L("命令","Command"),value:e.command}:null,n&&n!=="codex"?{label:L("引擎","Engine"),value:Gf(n)}:null,u&&!p?{label:L("退出码","Exit code"),value:String(e.exit_code)}:null]);if(w&&o.push(w),l&&o.push(l),t){if(l)return o;const c=ua(e.aggregated_output);c&&o.push(...$n(c,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function Fn(e={}){const t=Uo(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function uo(e={}){const t=Array.isArray(e.items)?Ps(e.items):[];return t.length?[ma(t)]:[]}function Gn(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function bo(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function Zf(e,t,n,o,s){const r=bo(e,t);return r?(r.events=[],r.lastEventSeq=0,r.summary=Gn(),((n==null?void 0:n.items)||[]).forEach(l=>{Vo(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 ga(e={}){const t=String((e==null?void 0:e.displayEngine)||"").trim();return t?Os(t):Fo(e==null?void 0:e.engine)?"codex":Os(e==null?void 0:e.engine)}function Ot(e={}){return gt(ga(e))}function ep(e={}){return Fo(e==null?void 0:e.engine)}function cs(e=""){return Wf.has(String(e||"").trim())}function jo(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 ar(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"?L("正在搜索网页","Searching the web"):L("已搜索网页","Web search completed"),detail:pa(s?L(`关键词:${s}`,`Query: ${s}`):"",r.length>1?r:[])}:o==="open_page"?{kind:"command",title:t==="started"?L("正在打开网页","Opening page"):L("已打开网页","Page opened"),detail:l}:{kind:"command",title:t==="started"?L("准备网页检索","Preparing web search"):L("网页检索已更新","Web search updated"),detail:s}}function ir(e={},t="completed"){const n=String(e.tool||"").trim(),o=Fs(e),s=wt(e.prompt);return n==="spawn_agent"?{kind:"todo",title:t==="started"?L("正在启动子代理","Starting sub-agent"):L(`已启动 ${o||1} 个子代理`,`Started ${o||1} sub-agent(s)`),detail:s?L(`任务:${s}`,`Task: ${s}`):""}:n==="wait"?{kind:"todo",title:t==="started"?o?L(`等待 ${o} 个子代理返回结果`,`Waiting for ${o} sub-agent result(s)`):L("等待子代理返回结果","Waiting for sub-agent results"):L("子代理结果已汇总","Sub-agent results aggregated"),detail:s?L(`等待内容:${s}`,`Waiting on: ${s}`):""}:{kind:"todo",title:t==="started"?L(`正在执行协作工具:${n||"未知工具"}`,`Running collaboration tool: ${n||"Unknown tool"}`):L(`协作工具完成:${n||"未知工具"}`,`Collaboration tool completed: ${n||"Unknown tool"}`),detail:s?L(`任务:${s}`,`Task: ${s}`):""}}function lr(e={},t="completed"){const n=Array.isArray(e.changes)?e.changes:[],o={create:L("新增","Added"),update:L("更新","Updated"),delete:L("删除","Deleted")};return{kind:"command",title:t==="started"?L("正在整理文件变更","Collecting file changes"):L(`已记录 ${n.length||0} 个文件改动`,`Recorded ${n.length||0} file change(s)`),detail:pa("",n.map(s=>{const r=String((s==null?void 0:s.path)||"").trim();return`${o[String((s==null?void 0:s.kind)||"").trim()]||L("变更","Changed")} ${r||L("未命名文件","Unnamed file")}`}))}}function tp(e,t={}){var l,u,p,w,c,y,h,g;e!=null&&e.summary||(e.summary=Gn());const n=e.summary,o=Ot(e),s=String(t.type||"").trim(),r=t.item||{};if(s===kt.TURN_STARTED){n.currentActivity=L("正在分析任务","Analyzing task"),n.latestActivity=L(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===kt.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=L(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===kt.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=L("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===kt.ERROR){const f=jo(ds(t));if(f){n.currentActivity=L(`网络异常,正在重试 (${f.attempt}/${f.total})`,`Network error, retrying (${f.attempt}/${f.total})`),n.latestActivity=n.currentActivity,n.latestDetail=wt(f.reason,120);return}n.currentActivity="",n.latestActivity=L(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=wt(ds(t),120);return}if(s===kt.ITEM_STARTED){if(r.type===dt.REASONING){n.currentActivity=L("正在思考","Thinking"),n.latestActivity=L("正在思考","Thinking"),n.latestDetail=wt(r.text,120);return}if(r.type===dt.COMMAND_EXECUTION){if(Fn(r).groupType==="todo"){const P=Tn(us(r));n.currentActivity=L("正在更新待办列表","Updating todo list"),n.latestActivity=L("正在更新待办列表","Updating todo list"),n.latestDetail=wt(P,120);return}n.currentActivity=L("正在执行命令","Running command"),n.latestActivity=L("开始执行命令","Command started"),n.latestDetail=wt(r.command,120);return}if(r.type===dt.WEB_SEARCH){n.currentActivity=((l=r.action)==null?void 0:l.type)==="open_page"?L("正在打开网页","Opening page"):L("正在搜索网页","Searching the web"),n.latestActivity=n.currentActivity,n.latestDetail=wt(((u=r.action)==null?void 0:u.type)==="open_page"?((p=r.action)==null?void 0:p.url)||r.query:r.query||((w=r.action)==null?void 0:w.query),120);return}if(r.type===dt.COLLAB_TOOL_CALL){if(r.tool==="wait"){const f=Fs(r);n.waitingAgentCount=f,n.currentActivity=f?L(`等待 ${f} 个子代理返回结果`,`Waiting for ${f} sub-agent result(s)`):L("等待子代理返回结果","Waiting for sub-agent results"),n.latestActivity=n.currentActivity,n.latestDetail=wt(r.prompt,120);return}if(r.tool==="spawn_agent"){n.currentActivity=L("正在启动子代理","Starting sub-agent"),n.latestActivity=L("正在启动子代理","Starting sub-agent"),n.latestDetail=wt(r.prompt,120);return}}if(r.type===dt.FILE_CHANGE){n.currentActivity=L("正在整理文件变更","Collecting file changes"),n.latestActivity=L("正在整理文件变更","Collecting file changes"),n.latestDetail=wt((r.changes||[]).map(f=>f==null?void 0:f.path).filter(Boolean).join(hn()?", ":","),120);return}r.type===dt.TODO_LIST&&(n.currentActivity=L("正在规划执行步骤","Planning steps"),n.latestActivity=L("正在规划执行步骤","Planning steps"),n.latestDetail=wt((r.items||[]).map(f=>f==null?void 0:f.text).filter(Boolean).join(hn()?"; ":";"),120));return}if(s===kt.ITEM_COMPLETED){if(r.type===dt.COMMAND_EXECUTION){if(Fn(r).groupType==="todo"){n.currentActivity="",n.latestActivity=L("待办列表已更新","Todo list updated"),n.latestDetail=wt(Tn(us(r)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=L("命令执行完成","Command completed"),n.latestDetail=wt(r.command,120);return}if(r.type===dt.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((c=r.action)==null?void 0:c.type)==="open_page"?L("已打开网页","Page opened"):L("已搜索网页","Web search completed"),n.latestDetail=wt(((y=r.action)==null?void 0:y.type)==="open_page"?((h=r.action)==null?void 0:h.url)||r.query:r.query||((g=r.action)==null?void 0:g.query),120);return}if(r.type===dt.COLLAB_TOOL_CALL){if(r.tool==="spawn_agent"){const f=Fs(r);n.subAgentCount+=f,n.currentActivity="",n.latestActivity=f?L(`已启动 ${f} 个子代理`,`Started ${f} sub-agent(s)`):L("已启动子代理","Started sub-agent"),n.latestDetail=wt(r.prompt,120);return}if(r.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=L("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=Yf(r,120)||wt(r.prompt,120);return}n.currentActivity="",n.latestActivity=L(`协作工具完成:${r.tool||"未知工具"}`,`Collaboration tool completed: ${r.tool||"Unknown tool"}`),n.latestDetail=wt(r.prompt,120);return}if(r.type===dt.FILE_CHANGE){const f=Array.isArray(r.changes)?r.changes:[];n.fileChangeCount+=f.length,n.currentActivity="",n.latestActivity=f.length?L(`已记录 ${f.length} 个文件改动`,`Recorded ${f.length} file change(s)`):L("已记录文件改动","Recorded file changes"),n.latestDetail=wt(f.map(P=>P==null?void 0:P.path).filter(Boolean).join(hn()?", ":","),120);return}if(r.type===dt.TODO_LIST){n.currentActivity="",n.latestActivity=L("待办列表已更新","Todo list updated"),n.latestDetail=wt((r.items||[]).map(f=>f==null?void 0:f.text).filter(Boolean).join(hn()?"; ":";"),120);return}r.type===dt.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=L(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=wt(r.text,120))}}function np(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(cs(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 ha(e={},t={}){const n=e.summary||Gn(),o=[],s=np(e,t);return s>0&&o.push({key:"elapsed",label:L("耗时","Elapsed"),value:fa(s)}),n.webSearchCount&&o.push({key:"web",label:L("网页","Web"),value:Nt(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:L("命令","Command"),value:Nt(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:L("改动","Changes"),value:Nt(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:L("子代理","Sub-agent"),value:Nt(n.subAgentCount)}),o}function va(e={}){const t=e.summary||Gn();return t.waitingAgentCount>0?L(`当前:等待 ${Nt(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${Nt(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?L(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?L(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):cs(e.status)?L(`当前:正在等待 ${Ot(e)} 返回更多事件`,`Current: waiting for more events from ${Ot(e)}`):""}function ya(e={}){const t=e.summary||Gn();return String(t.latestDetail||"").trim()}function sp(e={}){return!!(ha(e).length||va(e)||ya(e))}const op=[{type:"startup_config",title:e=>L(`${gt(e)} 启动配置冲突`,`${gt(e)} startup config conflict`),summary:e=>L(`${gt(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${gt(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:L("额度或账单异常","Quota or billing issue"),summary:e=>L(`${gt(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${gt(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:L("权限不足","Insufficient permissions"),summary:e=>L(`${gt(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${gt(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:L("请求过于频繁","Too many requests"),summary:e=>L(`${gt(e)} 可能触发了限流,请稍后再试。`,`${gt(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:L("上下文过长","Context too long"),summary:L("这次发送的内容可能过长,超过了模型可处理的上下文限制。","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:L("模型或服务暂不可用","Model or service unavailable"),summary:e=>L(`${gt(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${gt(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:L("网络连接异常","Network connection issue"),summary:e=>L(`${gt(e)} 在请求过程中遇到了网络问题或连接超时。`,`${gt(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=>L(`${gt(e)} CLI 不可用`,`${gt(e)} CLI unavailable`),summary:e=>L(`当前环境没有正确安装或配置 ${gt(e)} CLI。`,`${gt(e)} CLI is not correctly installed or configured in the current environment.`),patterns:[/找不到 Codex CLI/,/找不到 Claude Code CLI/,/找不到 OpenCode CLI/,/codex --version/i,/claude --version/i,/opencode --version/i,/enoent/i,/not recognized as an internal or external command/i,/command not found/i]}];function Kn(e="",t="codex"){const n=Wn(e).trim();if(!n)return null;const o=op.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 un(e="",t="codex"){const n=Wn(e).trim();if(!n)return"";const o=Kn(n,t);return o?`${o.summary}
35
+
36
+ ${L("原始错误","Raw error")}: ${o.rawMessage}`:n}function ko(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return Wn(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=ko(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=ko(o,t+1);if(s)return s}return""}function ds(e={}){return ko(e)}function rp(e={},t="Codex",n="codex"){var r,l,u,p;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:L(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===kt.THREAD_STARTED){const w=e.thread_id?L(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:L(`${t} 会话已创建`,`${t} session created`),detail:w,detailBlocks:w?[ls([{label:"ID",value:e.thread_id}])]:[]}}if(o===kt.TURN_STARTED)return{title:L(`${t} 开始执行`,`${t} started`),detail:""};if(o===kt.TURN_COMPLETED){const w=e.usage?[L(`输入 ${Nt(e.usage.input_tokens)}`,`Input ${Nt(e.usage.input_tokens)}`),e.usage.cached_input_tokens?L(`缓存 ${Nt(e.usage.cached_input_tokens)}`,`Cached ${Nt(e.usage.cached_input_tokens)}`):"",L(`输出 ${Nt(e.usage.output_tokens)}`,`Output ${Nt(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:L(`${t} 执行完成`,`${t} completed`),detail:w,detailBlocks:e.usage?[ls([{label:L("输入","Input"),value:Nt(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:L("缓存","Cached"),value:Nt(e.usage.cached_input_tokens)}:null,{label:L("输出","Output"),value:Nt(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===kt.ERROR||o===kt.TURN_FAILED){const w=ds(e)||L(`${t} 执行失败`,`${t} failed`),c=o===kt.ERROR?jo(w):null;if(c)return{kind:"info",title:L(`网络异常,正在重试 (${c.attempt}/${c.total})`,`Network error, retrying (${c.attempt}/${c.total})`),detail:un(c.reason||c.rawMessage,n),detailBlocks:$n(un(c.reason||c.rawMessage,n),{preferMarkdown:!0})};const y=Kn(w,n);return{kind:"error",title:(y==null?void 0:y.title)||(o===kt.TURN_FAILED?L("本轮运行失败","This run failed"):L(`${t} 返回错误`,`${t} returned an error`)),detail:un(w,n),detailBlocks:$n(un(w,n),{preferMarkdown:!0})}}if(o===kt.ITEM_STARTED)return s.type===dt.REASONING?{kind:"reasoning",title:L("思考过程","Thinking"),detail:s.text||"",detailBlocks:$n(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===dt.WEB_SEARCH?{...ar(s,"started"),detailBlocks:sr(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===dt.COLLAB_TOOL_CALL?{...ir(s,"started"),detailBlocks:or(s)}:s.type===dt.FILE_CHANGE?{...lr(s,"started"),detailBlocks:rr(s)}:s.type===dt.COMMAND_EXECUTION?Fn(s).groupType==="todo"?{kind:"todo",title:L("更新待办列表","Update todo list"),detail:Tn(us(s)),detailBlocks:ws(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:L("开始执行命令","Command started"),detail:s.command||"",detailBlocks:ws(s,!1,n),...Fn(s),phase:"started"}:s.type===dt.TODO_LIST?{kind:"todo",title:L("更新待办列表","Update todo list"),detail:Tn(s.items),detailBlocks:uo(s),groupType:"todo",phase:"started"}:{title:L(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===kt.ITEM_UPDATED&&s.type===dt.TODO_LIST)return{kind:"todo",title:L("更新待办列表","Update todo list"),detail:Tn(s.items),detailBlocks:uo(s),groupType:"todo",phase:"updated"};if(o===kt.ITEM_COMPLETED){if(s.type===dt.AGENT_MESSAGE&&s.text)return{kind:"result",title:L(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===dt.WEB_SEARCH)return{...ar(s,"completed"),detailBlocks:sr(s),groupType:"web",groupTarget:String(s.query||((u=s.action)==null?void 0:u.query)||((p=s.action)==null?void 0:p.url)||"").trim(),phase:"completed"};if(s.type===dt.COLLAB_TOOL_CALL)return{...ir(s,"completed"),detailBlocks:or(s)};if(s.type===dt.FILE_CHANGE)return{...lr(s,"completed"),detailBlocks:rr(s)};if(s.type===dt.COMMAND_EXECUTION){if(Fn(s).groupType==="todo"){const y=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:y?"todo":"error",title:y?L("更新待办列表","Update todo list"):L("更新待办列表失败","Todo list update failed"),detail:Tn(us(s)),detailBlocks:ws(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?L("命令执行完成","Command completed"):L(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,ua(s.aggregated_output)].filter(Boolean).join(`
37
+
38
+ `),detailBlocks:ws(s,!0,n),...Fn(s),phase:"completed"}}return s.type===dt.TODO_LIST?{kind:"todo",title:L("更新待办列表","Update todo list"),detail:Tn(s.items),detailBlocks:uo(s),groupType:"todo",phase:"completed"}:{title:L(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:L(`事件: ${o}`,`Event: ${o}`),detail:""}}function ap(e){return e.status==="queued"?L("排队中","Queued"):e.status==="starting"?L("启动中","Starting"):e.status==="stopping"?L("停止中","Stopping"):e.status==="running"?L("进行中","Running"):e.status==="error"?L("失败","Failed"):e.status==="interrupted"?L("已中断","Interrupted"):e.status==="stopped"?L("已停止","Stopped"):e.status==="stop_timeout"?L("停止超时","Stop timeout"):L("已完成","Completed")}function Sa(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?$n(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 ip(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"?Cs(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:Gn()}}function _n(e,t,n){const o=Sa(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function lp(e,t,n){var s;const o=Sa(t,n);if(o){for(let r=e.events.length-1;r>=0;r-=1){const l=L("网络异常,正在重试","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 up(e,t={},n,o=()=>{}){var r,l,u,p,w,c,y,h,g;const s=Rr(t.type);if(s===zt.SESSION){o(t.session);return}if(s===zt.SESSION_UPDATED){o(t.session);return}if(s===zt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;_n(e,{title:t.message||L("状态已更新","Status updated"),detail:""},n);return}if(s===zt.STDERR){const f=Kn(t.text,e.engine);_n(e,{kind:"error",title:(f==null?void 0:f.title)||"stderr",detail:un(t.text,e.engine)},n);return}if(s===zt.STDOUT){_n(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===zt.AGENT_EVENT){if(tp(e,t.event),((r=t.event)==null?void 0:r.type)===kt.THREAD_STARTED)return;const f=rp(t.event,Ot(e),e.engine);String(f.title||"").startsWith(L("网络异常,正在重试","Network error, retrying"))?lp(e,f,n):_n(e,f,n),((l=t.event)==null?void 0:l.type)===kt.ITEM_COMPLETED&&((p=(u=t.event)==null?void 0:u.item)==null?void 0:p.type)===dt.AGENT_MESSAGE&&((c=(w=t.event)==null?void 0:w.item)!=null&&c.text)&&(e.responseMessage=t.event.item.text);const P=ds(t.event)||L(`${Ot(e)} 执行失败`,`${Ot(e)} failed`);if(!(((y=t.event)==null?void 0:y.type)==="error"?jo(P):null)&&(((h=t.event)==null?void 0:h.type)===kt.ERROR||((g=t.event)==null?void 0:g.type)===kt.TURN_FAILED)){const S=ds(t.event)||L(`${Ot(e)} 执行失败`,`${Ot(e)} failed`);e.errorMessage=un(S,e.engine),e.status="error"}return}if(s===zt.COMPLETED){_n(e,{kind:"result",title:L("本轮执行结束","Run finished"),detail:""},n),t.message&&(e.responseMessage=t.message);return}if(s===zt.STOPPED){_n(e,{title:t.message||L("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===zt.ERROR){const f=Kn(t.message,e.engine);_n(e,{kind:"error",title:(f==null?void 0:f.title)||L("执行失败","Execution failed"),detail:un(t.message||L(`${Ot(e)} 执行失败`,`${Ot(e)} failed`),e.engine)},n)}}function cp(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=Kn(o,n),l=Kn(s,n);return!r&&!!l}function dp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=un(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=cp(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=L(`本轮 ${Ot(e)} 执行已完成,没有返回额外文本。`,`${Ot(e)} completed in this run without returning additional text.`)),e}function Vo(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)||{};up(e,r,n,o);const l=Rr(r.type);return l===zt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===zt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===zt.ERROR&&(e.status="error",e.errorMessage=un(String(r.message||e.errorMessage||L(`${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 ur(e,t,n,o){const s=ip(e,t);return(e.events||[]).forEach(r=>{Vo(s,r,n,o)}),dp(s,e)}const fp=1800,cr=7200,pp=15e3,co={clearTaskCodexRuns:ml,listCodexRunEvents:fl,listTaskCodexRuns:dl};function as(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 mp(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>as(o,t)))}function gp(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function hp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:u,supportsServerEvents:p,scheduleScrollToBottom:w,resetAutoStickToBottom:c,mergeSessionRecord:y,mergeSession:h,loadSessions:g,showProcessLogs:f}=e;let P=0,ee=0,S=null,D="",j=null,G=null,M="",J=!!(f!=null&&f.value),A=0;const X=new Map;function ue(){return P+=1,P}function pe(){return ee+=1,ee}function E(){j&&(window.clearInterval(j),j=null)}function Z(){G&&(window.clearInterval(G),G=null)}function ce(){A=Date.now()}function ie(){X.clear(),n.value=[],s.value=!1,r.value=0,l.value="",M="",D="",P=0,ee=0,c()}function ve(){const V=[...n.value].reverse().find(te=>cs(te.status))||null;if(l.value=(V==null?void 0:V.runId)||"",s.value=!!V,V!=null&&V.startedAt){const te=Date.parse(String(V.startedAt||""));r.value=Number.isFinite(te)?te:Date.now();return}r.value=0}function T(V=null){return V?{...V}:gp()}function U(V,te=null){if(!(te!=null&&te.runId)||V.eventsLoaded||!te.eventsLoaded)return X.has(V.runId)&&(V.eventsLoading=!0),V;const he=Math.max(Math.max(0,Number(te.lastEventSeq)||0),Math.max(0,Number(te.eventCount)||0),Array.isArray(te.events)?te.events.length:0),Ae=Math.max(0,Number(V.eventCount)||0);return he<Ae?(X.has(V.runId)&&(V.eventsLoading=!0),V):(V.events=Array.isArray(te.events)?[...te.events]:[],V.eventCount=Math.max(Math.max(0,Number(V.eventCount)||0),Math.max(0,Number(te.eventCount)||0),V.events.length),V.eventsLoaded=!0,V.eventsLoading=X.has(V.runId),V.lastEventSeq=Math.max(0,Number(te.lastEventSeq)||0),V.summary=T(te.summary),V)}function O(V,te){const he=bo(n.value,V);return he?(he.eventsLoading=!!te,n.value=[...n.value],he):null}async function He(V,te={}){const he=String((V==null?void 0:V.runId)||"").trim(),{force:Ae=!1}=te;if(!he)return[];const se=bo(n.value,he)||V;if(se!=null&&se.eventsLoaded&&!Ae)return se.events;if(X.has(he))return X.get(he);O(he,!0);const _e=(async()=>{var $e;try{const Le=as(se,!!(f!=null&&f.value)),at=await co.listCodexRunEvents(he,{limit:5e3}),Me=Zf(n.value,he,at,pe,Ne=>{h(Ne,{preserveRunning:!0})});if(!Me)return Array.isArray(se==null?void 0:se.events)?se.events:[];const et=JSON.stringify(Le)!==JSON.stringify(as(Me,!!(f!=null&&f.value)));return n.value=[...n.value],et&&t.active&&(($e=n.value.at(-1))==null?void 0:$e.runId)===he&&w(),Me.events}catch(Le){throw u.value=Le.message,Le}finally{O(he,!1),X.delete(he)}})();return X.set(he,_e),_e}function De(V,te){const he=String(V||"").trim();if(!he||!te)return!1;const Ae=n.value.findIndex(at=>at.runId===he);if(Ae<0)return!1;const se=n.value[Ae],_e=as(se,!!(f!=null&&f.value));if(!Vo(se,te,pe,at=>{h(at,{preserveRunning:!0})}))return!0;const Le=JSON.stringify(_e)!==JSON.stringify(as(se,!!(f!=null&&f.value)));return n.value=[...n.value],ve(),Le&&w(),!0}function je(){if(E(),Z(),!(!t.active||!s.value||!t.taskSlug)){if(p){G=window.setInterval(()=>{Ge({force:!0}).catch(()=>{});const V=Date.now();V-A<cr||(A=V,g({force:!0}).catch(()=>{}))},pp);return}j=window.setInterval(()=>{Ge({force:!0}).catch(()=>{});const V=Date.now();V-A<cr||(A=V,g({force:!0}).catch(()=>{}))},fp)}}function We(V=[]){const te=[...o.value],he=new Map(n.value.filter(se=>String((se==null?void 0:se.runId)||"").trim()).map(se=>[String(se.runId||"").trim(),se])),Ae=se=>{if(!(se!=null&&se.id))return;const _e=te.findIndex($e=>$e.id===se.id);_e>=0?te[_e]=y(te[_e],se,{preserveRunning:!0}):te.unshift(y(null,se,{preserveRunning:!0}))};P=0,ee=0,n.value=[...V||[]].reverse().map(se=>{const _e=ur(se,ue,pe,Ae);return U(_e,he.get(String((se==null?void 0:se.id)||"").trim())||null)}),o.value=te,ve()}async function Ge(V={}){const{force:te=!1,scrollToLatest:he=!1}=V,Ae=String(t.taskSlug||"").trim();if(!(!Ae||!t.active&&!te))return S&&D===Ae||S&&!te||(D=Ae,S=(async()=>{try{const _e=(await co.listTaskCodexRuns(Ae,{limit:30,events:"latest"})).items||[],$e=!!(f!=null&&f.value),Le=mp(_e,$e),at=he||M&&J===$e&&Le!==M;We(_e),M=Le,J=$e,je();const Me=n.value.at(-1)||null;if(Me!=null&&Me.runId&&!Me.eventsLoaded){const et=Me.runId;He(Me).catch(()=>{}).finally(()=>{var Ne;he&&t.active&&((Ne=n.value.at(-1))==null?void 0:Ne.runId)===et&&w({force:!0})})}at&&w({force:he})}catch(se){u.value=se.message}finally{S=null,D=""}})()),S}function ut(V={}){const te=(V==null?void 0:V.run)||null,he=(V==null?void 0:V.session)||null;if(he&&h(he,{preserveRunning:!0}),!(te!=null&&te.id)){ve(),w({force:!0});return}const se=ur(te,ue,pe,$e=>{h($e,{preserveRunning:!0})}),_e=n.value.findIndex($e=>$e.runId===se.runId);if(_e>=0){const $e=[...n.value];$e.splice(_e,1,se),n.value=$e}else n.value=[...n.value,se];ve(),w({force:!0})}async function Te(){if(!(!t.taskSlug||s.value))try{await co.clearTaskCodexRuns(t.taskSlug),ie(),w({force:!0})}catch(V){u.value=V.message}}return{applyCreatedRun:ut,applyIncomingRunEvent:De,clearRealtimeReconcileTimer:Z,clearRunPollTimer:E,clearTurns:Te,loadTurnEvents:He,markFallbackSessionPollNow:ce,refreshRunHistory:Ge,resetRunHistoryState:ie,syncRunningStateFromTurns:ve,updatePollingState:je}}const vp=1500,yp=3e4;function Sp(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:u,sessionError:p,showManager:w,selectedSessionId:c,currentRunningRunId:y,supportsServerEvents:h,mergeSession:g,applyCreatedRun:f,refreshRunHistory:P,markFallbackSessionPollNow:ee,showToast:S,getActiveAgentBinding:D=null}=e;let j=null,G=null,M=0,J=0;const A=K(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),X=K(()=>n.value.length>0),ue=K(()=>tr(n.value,c.value)),pe=K(()=>X.value?"":Ye("projectManager.noProjects"));async function E(Te={}){const{force:V=!1}=Te;if(j)return j;const te=Date.now();return!V&&M&&te-M<vp?{items:n.value,workspaces:o.value}:(j=(async()=>{s.value=!0,p.value="";try{const Ae=(await el()).items||[];return n.value=Ae,M=Date.now(),{items:Ae,workspaces:o.value}}catch(he){throw p.value=he.message,he}finally{s.value=!1,j=null}})(),j)}async function Z(Te={}){const{force:V=!1}=Te;if(G)return G;const te=Date.now();return!V&&J&&te-J<yp?{items:o.value}:(G=(async()=>{try{const he=await tl();return o.value=he.items||[],J=Date.now(),{items:o.value}}finally{G=null}})(),G)}async function ce(Te={}){const{forceSessions:V=!1,forceWorkspaces:te=!1}=Te,[he,Ae]=await Promise.all([E({force:V}),Z({force:te})]);return{items:(he==null?void 0:he.items)||n.value,workspaces:(Ae==null?void 0:Ae.items)||o.value}}function ie(Te=""){const V=String(Te||"").trim();!V||o.value.includes(V)||(o.value=[V,...o.value])}function ve(){w.value=!0,Z().catch(()=>{})}function T(){w.value=!1}function U(Te){const V=String(Te||"").trim();if(t.sessionSelectionLocked&&V&&V!==c.value){p.value=t.sessionSelectionLockReason||Ye("taskActions.sessionLocked");return}c.value=V}function O(){ce({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function He(Te){r.value=!0,p.value="";try{const V=await nl(Te);return g(V),ie(V.cwd),c.value=V.id,V}catch(V){throw p.value=V.message,V}finally{r.value=!1}}async function De(Te,V){r.value=!0,p.value="";try{const te=await sl(Te,V);return g(te),ie(te.cwd),te}catch(te){throw p.value=te.message,te}finally{r.value=!1}}async function je(Te){var te;const V=String(Te||"").trim();if(!V)return{deletedSessionId:"",selectedSessionId:c.value};r.value=!0,p.value="";try{await ol(V);const he=n.value.filter(se=>se.id!==V);n.value=he;let Ae=c.value;return c.value===V&&(Ae=((te=tr(he,"")[0])==null?void 0:te.id)||"",c.value=Ae),{deletedSessionId:V,selectedSessionId:Ae}}catch(he){throw p.value=he.message,he}finally{r.value=!1}}async function We(Te){const V=String(Te||"").trim();if(!V)return null;r.value=!0,p.value="";try{const te=await rl(V);return te!=null&&te.session&&g(te.session),ee(),await Promise.all([P({force:!0}),E({force:!0})]),S==null||S({message:Ye("projectManager.sessionReset"),type:"success"}),te}catch(te){throw p.value=te.message,te}finally{r.value=!1}}async function Ge(){if(!t.taskSlug||!A.value||l.value||u.value)return!1;if(!c.value){const Te=Ye("projectManager.selectProject");return p.value=Te,S==null||S({message:Te,type:"warning"}),!1}p.value="";try{await ce({forceSessions:!0});const Te=n.value.find(Me=>Me.id===c.value)||null;if(!Te)return p.value=Ye("projectManager.projectMissing"),!1;if(Te.running)return p.value=Ye("sessionTurns.currentProjectRunning"),!1;const V=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,te=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],he=di({prompt:V,promptBlocks:te});if(he.reason){const Me=he.reason==="unsupported_blocks"?Ye("sessionPanel.shellUnsupportedBlocks"):Ye("sessionPanel.shellEmptyCommand");return p.value=Me,S==null||S({message:Me,type:"warning"}),!1}if(!String(V||"").trim())return p.value=Ye("sessionTurns.noPromptToSend"),!1;const Ae=wp(Te),se=typeof D=="function"?D(Te):null,_e=String((se==null?void 0:se.engine)||"").trim();if(_e&&!Ae.some(Me=>Me.engine===_e)){const Me=Ye("sessionPanel.agentNotEnabled");return p.value=Me,S==null||S({message:Me,type:"warning"}),!1}const $e=se,Le=String(he.mode==="shell"?c.value:($e==null?void 0:$e.sessionRecordId)||c.value).trim(),at=await pl(t.taskSlug,{projectSessionId:c.value,sessionId:Le,displayEngine:_e,prompt:he.mode==="shell"?he.prompt:V,promptBlocks:te,commandMode:he.mode,command:he.command});return f(at),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Me=>{console.error("[promptx] afterSend failed",Me)}),h||(ee(),Promise.all([P({force:!0}),E({force:!0})]).catch(Me=>{p.value=Me.message})),!0}catch(Te){return p.value=Te.message,!1}}async function ut(){if(!(!y.value||u.value))try{u.value=!0,await gl(y.value),h||(ee(),await Promise.all([P({force:!0}),E({force:!0})]))}catch(Te){u.value=!1,p.value=Te.message}}return{closeManager:T,handleCreateSession:He,handleDeleteSession:je,handleResetSession:We,handleSelectSession:U,handleSend:Ge,handleUpdateSession:De,hasPrompt:A,helperText:pe,loadSessions:E,loadSessionResources:ce,loadWorkspaces:Z,openManager:ve,refreshSessionsForSelection:O,sortedSessions:ue,stopSending:ut}}function wp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:xp(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function xp(e=""){const t=String(e||"").trim().toLowerCase();return t==="claude"||t==="claudecode"?"claude-code":t==="opencode"||t==="open-code"?"opencode":t==="claude-code"?"claude-code":"codex"}function bp(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,u=!1,p=0,w=!0;function c(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(ue=>{window.cancelAnimationFrame(ue)}),r=[]}function y(){s+=1,c()}function h(ue){u=!!ue,(n==null?void 0:n.value)!==void 0&&(n.value=u)}function g(){l=!1,p+=1,w=!0,h(!1)}function f(ue=t==null?void 0:t.value){return ue?ue.scrollHeight-ue.scrollTop-ue.clientHeight<=o:!0}function P(){return w&&!l}function ee(){w&&!l&&h(!1)}function S(){if(w=f(),!w){y();return}ee()}function D(){p+=1,l=!0,y()}function j(){const ue=p+1;p=ue,ft(()=>{ue===p&&requestAnimationFrame(()=>{ue===p&&(l=!1,w=f(),ee())})})}function G(){l=!0,y()}function M(){j()}function J(ue={}){const{force:pe=!1}=ue;pe&&g(),y();const E=s;ft(()=>{if(!(t==null?void 0:t.value)||E!==s)return;if(!pe&&!P()){h(!0);return}const ce=()=>{const ve=t==null?void 0:t.value;!ve||E!==s||(ve.scrollTop=ve.scrollHeight,w=!0,h(!1))};ce(),r=[requestAnimationFrame(()=>{ce(),r=[requestAnimationFrame(ce)]})]})}function A(){J({force:!0})}function X(){p+=1,y()}return{cancelScheduledScrollToBottom:y,destroy:X,handleTranscriptScroll:S,handleTranscriptTouchEnd:M,handleTranscriptTouchMove:G,handleTranscriptTouchStart:D,isTranscriptNearBottom:f,resetAutoStickToBottom:g,scheduleScrollToBottom:J,scrollToBottom:A}}const kp=150,wa="promptx:session-panel:show-process";function _p(e){return!(e==="0"||e==="false")}function Tp(){if(typeof window>"u")return!0;try{return _p(window.localStorage.getItem(wa))}catch{return!0}}function Cp(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 Ep(e,t){const n=la(),o=F([]),s=F([]),r=F(!1),l=F(!1),u=F(!1),p=F(!1),w=F(""),c=F([]),y=F(null),h=F(0),g=F(0),f=F(!1),P=F(""),ee=F(!1),S=F(Tp()),D=typeof window<"u"&&typeof window.EventSource<"u";function j(le=""){const Be=typeof le=="object"&&le!==null?String(le.message||"").trim():String(le||"").trim();Be&&t("toast",typeof le=="object"&&le!==null?{...le,message:Be}:Be)}let G=null,M=null,J=null,A={sessions:!1,runs:!1};const X=K({get(){return String(e.selectedSessionId||"").trim()},set(le){t("selected-session-change",String(le||"").trim())}}),ue=K(()=>p.value?Ye("sessionPanel.stopping"):`${Ye("projectManager.running")} (${fa(g.value)})`),pe=K(()=>o.value.find(le=>le.id===X.value)||null),E=K(()=>{var Be;if(Array.isArray((Be=pe.value)==null?void 0:Be.agentBindings)&&pe.value.agentBindings.length)return pe.value.agentBindings;const le=pe.value;return le!=null&&le.id?[{engine:le.engine,sessionRecordId:le.id,sessionId:le.sessionId||"",started:!!le.started,running:!!le.running,isDefault:!0}]:[]}),Z=K({get(){var Be,qe;const le=fo(e.selectedAgentEngine,E.value);return le||((Be=E.value.find(xt=>xt.isDefault))==null?void 0:Be.engine)||((qe=E.value[0])==null?void 0:qe.engine)||""},set(le){const Be=fo(le,E.value);Be&&t("update:selectedAgentEngine",Be)}}),ce=K(()=>E.value.find(le=>le.engine===Z.value)||E.value[0]||null),{destroy:ie,handleTranscriptScroll:ve,handleTranscriptTouchEnd:T,handleTranscriptTouchMove:U,handleTranscriptTouchStart:O,resetAutoStickToBottom:He,scheduleScrollToBottom:De,scrollToBottom:je}=bp({transcriptRef:y,hasNewerMessages:ee});function We(le,Be,qe={}){return Cp(le,Be,qe)}function Ge(le,Be={}){if(!(le!=null&&le.id))return;const qe=[...o.value],xt=qe.findIndex(Bt=>Bt.id===le.id);xt>=0?qe[xt]=We(qe[xt],le,Be):qe.unshift(We(null,le,Be)),o.value=qe}const{applyCreatedRun:ut,applyIncomingRunEvent:Te,clearRealtimeReconcileTimer:V,clearRunPollTimer:te,clearTurns:he,loadTurnEvents:Ae,markFallbackSessionPollNow:se,refreshRunHistory:_e,resetRunHistoryState:$e,updatePollingState:Le}=hp({props:e,turns:c,sessions:o,sending:u,sendingStartedAt:h,currentRunningRunId:P,sessionError:w,supportsServerEvents:D,scheduleScrollToBottom:De,resetAutoStickToBottom:He,showProcessLogs:S,mergeSessionRecord:We,mergeSession:Ge,loadSessions:(...le)=>Xe(...le)}),{closeManager:at,handleCreateSession:Me,handleDeleteSession:et,handleResetSession:Ne,handleSelectSession:Je,handleSend:Ie,handleUpdateSession:ct,helperText:it,loadSessions:Xe,loadSessionResources:Pt,loadWorkspaces:At,openManager:C,refreshSessionsForSelection:N,sortedSessions:ne,stopSending:we}=Sp({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:u,stopping:p,sessionError:w,showManager:f,selectedSessionId:X,currentRunningRunId:P,supportsServerEvents:D,mergeSession:Ge,applyCreatedRun:ut,refreshRunHistory:_e,markFallbackSessionPollNow:se,showToast:j,getActiveAgentBinding:()=>ce.value});function Oe(){G&&(window.clearInterval(G),G=null)}function Re(){Oe(),h.value||(h.value=Date.now()),g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3)),G=window.setInterval(()=>{g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3))},1e3)}function Qe(){J&&(window.clearTimeout(J),J=null)}function Ze(){Qe();const le=A;A={sessions:!1,runs:!1},le.sessions&&Xe({force:!0}).catch(()=>{}),le.runs&&_e({force:!0}).catch(()=>{})}function tt(le={}){typeof window>"u"||(A={sessions:A.sessions||!!le.sessions,runs:A.runs||!!le.runs},!(J||!A.sessions&&!A.runs)&&(J=window.setTimeout(()=>{Ze()},kp)))}function Tt(le){return ha(le,{currentRunningRunId:P.value,runningElapsedSeconds:g.value,nowMs:Date.now()})}function $t(le=""){if(!le)return"";const Be=new Date(le);return Number.isNaN(Be.getTime())?"":Be.toLocaleTimeString(qs(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function St(le){return le.status==="error"||le.status==="stop_timeout"?"theme-process-error":le.status==="interrupted"||le.status==="stopped"?"theme-process-stopped":le.status==="completed"?"theme-process-completed":"theme-process-running"}function Ht(){S.value=!S.value}function Dt(le){return!!(le.responseMessage||le.errorMessage||le.status==="completed")}return Pe(S,le=>{if(!(typeof window>"u"))try{window.localStorage.setItem(wa,le?"true":"false")}catch{}},{immediate:!0}),Pe(u,le=>{le?(h.value||(h.value=Date.now()),Re()):(Oe(),h.value=0,g.value=0,p.value=!1),Le(),t("sending-change",le)},{immediate:!0}),Pe(()=>!!e.taskRunning,le=>{!e.active||le||!u.value||tt({sessions:!0,runs:!0})}),Pe(()=>e.active,le=>{if(le){Pt({forceSessions:!0}).catch(()=>{});return}Qe(),V(),te()},{immediate:!0}),Pe(()=>e.taskSlug,()=>{$e(),f.value=!1,w.value="",e.active&&_e({force:!0,scrollToLatest:!0}).catch(()=>{})},{immediate:!0}),Pe(()=>{var le;return[((le=pe.value)==null?void 0:le.id)||"",E.value.map(Be=>Be.engine).join(","),e.selectedAgentEngine||""].join(`
39
+ `)},()=>{var Vt,z,Y;const le=String(((Vt=pe.value)==null?void 0:Vt.id)||"").trim(),Be=E.value,qe=Z.value;if(t("agent-bindings-change",{sessionId:le,bindings:Be,selectedEngine:qe}),!le||fo(e.selectedAgentEngine,Be))return;const Bt=((z=Be.find(de=>de.isDefault))==null?void 0:z.engine)||((Y=Be[0])==null?void 0:Y.engine)||"";Bt&&t("update:selectedAgentEngine",Bt)},{immediate:!0}),Mt(()=>{Oe(),V(),te(),Qe(),ie(),M==null||M()}),Pe(()=>n.readyVersion.value,()=>{const le=String(e.taskSlug||"").trim();!e.active&&!f.value||(f.value&&At().catch(()=>{}),tt({sessions:!0,runs:!!le}))}),Pe(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!f.value||tt({sessions:!0})}),Pe(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||tt({sessions:!0,runs:!0})}),Pe(()=>String(e.taskSlug||"").trim(),le=>{M==null||M(),M=null,le&&(M=Mf(le,({runId:Be,event:qe})=>{if(!e.active)return;Te(Be,qe)||tt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:ce,activeAgentEngine:Z,clearTurns:he,closeManager:at,formatTurnTime:$t,getProcessCardClass:St,getProcessStatus:ap,getTurnAgentLabel:Ot,getTurnSummaryDetail:ya,getDisplayTurnSummaryItems:Tt,getTurnSummaryStatus:va,handleCreateSession:Me,handleDeleteSession:et,handleResetSession:Ne,handleSelectSession:Je,handleSend:Ie,handleUpdateSession:ct,loadTurnEvents:Ae,hasTurnSummary:sp,helperText:it,loading:r,managerBusy:l,openManager:C,refreshSessionsForSelection:N,selectedSessionId:X,sending:u,showProcessLogs:S,stopping:p,sessionError:w,shouldShowResponse:Dt,showManager:f,sortedSessions:ne,stopSending:we,toggleProcessLogs:Ht,hasNewerMessages:ee,transcriptRef:y,turns:c,workspaces:s,workingLabel:ue,sessions:o,loadSessions:Xe,currentProjectAgentBindings:E,handleTranscriptScroll:ve,handleTranscriptTouchEnd:T,handleTranscriptTouchMove:U,handleTranscriptTouchStart:O,scheduleScrollToBottom:De,scrollToBottom:je}}function fo(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const Ap=8,$p=320,Ip=10,Pp=400;function dr(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function Dp(e={}){const{turns:t,loadTurnEvents:n}=e,o=F({}),s=F({}),r=F({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function u(A){const X=l(A);return!!X&&X===l(t.value.at(-1))}function p(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 w(A){return!cs(A==null?void 0:A.status)&&!u(A)&&p(A)>3}function c(A){return dr(A==null?void 0:A.prompt,Ap,$p)}function y(A){return!cs(A==null?void 0:A.status)&&!u(A)&&c(A)}function h(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function g(A){return dr(h(A),Ip,Pp)}function f(A){return!(A!=null&&A.errorMessage)&&!u(A)&&g(A)}function P(A){return p(A)>0}function ee(A=[]){const X=new Set((A||[]).map(E=>l(E)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([E])=>X.has(E))),s.value=Object.fromEntries(Object.entries(s.value).filter(([E])=>X.has(E))),r.value=Object.fromEntries(Object.entries(r.value).filter(([E])=>X.has(E)));const ue=(A||[]).at(-1)||null,pe=l(ue);pe&&(Object.prototype.hasOwnProperty.call(o.value,pe)||(o.value={...o.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(s.value,pe)||(s.value={...s.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(r.value,pe)||(r.value={...r.value,[pe]:!1}))}function S(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(o.value,X)?!!o.value[X]:w(A):!1}async function D(A){const X=l(A);if(!X)return;const ue=!S(A);o.value={...o.value,[X]:ue},!ue&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function j(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(s.value,X)?!!s.value[X]:y(A):!1}function G(A){const X=l(A);!X||!c(A)||(s.value={...s.value,[X]:!j(A)})}function M(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(r.value,X)?!!r.value[X]:f(A):!1}function J(A){const X=l(A);!X||!g(A)||(r.value={...r.value,[X]:!M(A)})}return Pe(t,A=>{ee(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:P,isLatestTurn:u,isPromptCollapsed:j,isResponseCollapsed:M,isTurnEventsCollapsed:S,togglePrompt:G,toggleResponse:J,toggleTurnEvents:D}}function Lp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Mp(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 Bp(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function po(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 mo(e="",t=[],n=[]){var l;const o=Lp(t.map(u=>u.groupTarget)),s=[];if(e==="todo"){const u=[...n].reverse().flatMap(p=>Array.isArray(p==null?void 0:p.detailBlocks)?p.detailBlocks:[]).find(p=>(p==null?void 0:p.type)==="checklist");return u?[u]:[]}if(e==="reasoning"){const u=[...t].reverse().find(p=>Array.isArray(p==null?void 0:p.detailBlocks)&&p.detailBlocks.length);return(l=u==null?void 0:u.detailBlocks)!=null&&l.length?u.detailBlocks:[]}const r=Mp([{label:"类型",value:Bp(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 xa(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:po(n,e.length),detail:"",detailBlocks:mo(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:po(n,e.length),detail:"",detailBlocks:mo(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:po(n,o.length),detail:"",detailBlocks:mo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Rp(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]=xa(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 Np(e=[]){var o;const t=Rp(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(...xa(u))}return n}const Op={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Fp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Up={class:"flex flex-col gap-2"},jp={class:"flex items-center gap-2"},Vp=["title"],zp={class:"flex shrink-0 items-center gap-1.5"},Hp=["aria-pressed","aria-label","title"],qp=["disabled"],Kp={class:"hidden sm:inline"},Wp=["disabled"],Gp={class:"hidden sm:inline"},Xp=["aria-label"],Yp=["aria-pressed"],Jp=["aria-pressed","title","onClick"],Qp={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},Zp={class:"min-h-0 flex-1"},em={key:0,class:"theme-empty-state px-4 py-6 text-sm"},tm={key:1,class:"theme-empty-state px-4 py-6 text-sm"},nm=["data-turn-id","data-run-id"],sm={class:"flex justify-end"},om={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)]"},rm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},am={class:"font-semibold"},im={class:"flex items-center gap-2"},lm=["onClick"],um={class:"relative mt-2"},cm={key:0,class:"space-y-3"},dm={key:0,class:"whitespace-pre-wrap break-words leading-7"},fm=["onClick"],pm=["src","alt"],mm={key:1,class:"whitespace-pre-wrap break-words leading-7"},gm={key:0,class:"flex min-w-0 justify-start"},hm={class:"flex items-center justify-between gap-3 text-xs"},vm={class:"font-semibold"},ym={class:"flex items-center gap-2"},Sm=["disabled","onClick"],wm={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},xm={key:1,class:"mt-2 min-w-0 space-y-2"},bm={class:"text-sm font-medium leading-6"},km={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},_m={key:3,class:"mt-2 text-xs text-current"},Tm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Cm={key:0,class:"leading-5"},Em={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},Am={key:2,class:"mt-2 flex flex-wrap gap-2"},$m={class:"font-medium"},Im={key:1,class:"flex justify-start"},Pm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Dm={class:"font-semibold"},Lm={class:"flex items-center gap-2"},Mm=["onClick"],Bm=["onClick"],Rm={class:"relative mt-2"},Nm={key:0,class:"whitespace-pre-wrap break-words"},Om=["innerHTML"],Fm={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"},Um=["disabled"],jm={key:2,class:"task-loading-dots","aria-hidden":"true"},Vm={__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=vo(()=>Ke(()=>import("./CodexSessionManagerDialog-BLuZ5eP1.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:u,getProcessCardClass:p,getProcessStatus:w,getTurnAgentLabel:c,getDisplayTurnSummaryItems:y,getTurnSummaryDetail:h,getTurnSummaryStatus:g,handleCreateSession:f,handleDeleteSession:P,handleResetSession:ee,handleSelectSession:S,handleSend:D,handleTranscriptScroll:j,handleTranscriptTouchEnd:G,handleTranscriptTouchMove:M,handleTranscriptTouchStart:J,handleUpdateSession:A,helperText:X,loadTurnEvents:ue,loading:pe,managerBusy:E,openManager:Z,refreshSessionsForSelection:ce,selectedSessionId:ie,sending:ve,showProcessLogs:T,stopping:U,hasTurnSummary:O,hasNewerMessages:He,sessionError:De,shouldShowResponse:je,showManager:We,sortedSessions:Ge,stopSending:ut,toggleProcessLogs:Te,transcriptRef:V,turns:te,workspaces:he,sessions:Ae,loadSessions:se,currentProjectAgentBindings:_e,scheduleScrollToBottom:$e,scrollToBottom:Le}=Ep(r,s),at=F(null),Me=F(!1),et=F(""),Ne=F(""),Je=F("all"),{t:Ie}=_t(),{isDark:ct}=Er(),it=K(()=>ct.value?"dark":"light"),Xe=K(()=>{const $=new Set;return(Array.isArray(_e.value)?_e.value:[]).filter(Q=>{const H=String((Q==null?void 0:Q.engine)||"").trim();return!H||$.has(H)?!1:($.add(H),!0)})}),Pt=K(()=>Xe.value.length>1),At=K(()=>{const $=String(Je.value||"").trim();return!Pt.value||$==="all"?te.value:te.value.filter(Q=>ga(Q)===$)}),{selectionAction:C,clearSelectionState:N,handleSelectionMouseUp:ne}=ea({getContainer:()=>V.value,isActive:()=>!!(r.active&&te.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:$=>[...$.querySelectorAll("[data-response-selection-root]")],getCodeLeft:$=>{var Q,H;return((H=(Q=$==null?void 0:$.getBoundingClientRect)==null?void 0:Q.call($))==null?void 0:H.left)||0},debounceMs:72});Pe([Je,()=>Xe.value.map($=>$.engine).join(`
40
+ `)],()=>{Je.value!=="all"&&(Xe.value.some($=>$.engine===Je.value)||(Je.value="all"))},{immediate:!0}),Pe(Je,()=>{N({clearBrowserSelection:!0}),$e({force:!0})}),Pe(()=>r.taskSlug,($,Q)=>{!String($||"").trim()||$===Q||(Je.value="all")});function we($={}){if(($==null?void 0:$.kind)==="reasoning")return!0;const Q=String(($==null?void 0:$.title)||"").trim();return Q?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/^Codex 会话已创建$/,/^Claude Code 会话已创建$/,/^OpenCode 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(H=>H.test(Q)):!1}function Oe($={}){return Ie("sessionPanel.promptTitleWithAgent",{agent:c($)})}function Re($={}){return $.errorMessage?Ie("sessionPanel.errorSuffix",{agent:c($)}):Ie("sessionPanel.responseSuffix",{agent:c($)})}const{getTurnEventCount:Qe,hasTurnEventHistory:Ze,isTurnEventsCollapsed:tt,toggleTurnEvents:Tt}=Dp({turns:te,loadTurnEvents:ue});function $t($){return String(($==null?void 0:$.runId)||($==null?void 0:$.id)||"").trim()}function St($){$!=null&&$.runId&&s("open-diff",{scope:"run",runId:$.runId})}function Ht(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Dt}=xf({items:te,themeKey:it,getCacheKey:$t,getSource:$=>String(($==null?void 0:$.responseMessage)||""),shouldRender:$=>!!($!=null&&$.responseMessage)&&!($!=null&&$.errorMessage),renderAsync:$=>mc($,{isDark:ct.value,copyLabel:Ie("sessionPanel.copyCode"),copyAriaLabel:Ie("sessionPanel.copyCodeAria")}),renderFallback:$=>Jr($),onRendered:$=>{const Q=te.value.at(-1)||null;!r.active||!(Q!=null&&Q.runId)||Q.runId!==($==null?void 0:$.runId)||$e()}});function le($){Ne.value=String($||"").trim()}async function Be($){var H;if((H=navigator.clipboard)!=null&&H.writeText&&window.isSecureContext){await navigator.clipboard.writeText($);return}const Q=document.createElement("textarea");Q.value=$,Q.setAttribute("readonly","true"),Q.style.position="fixed",Q.style.opacity="0",Q.style.pointerEvents="none",document.body.appendChild(Q),Q.select(),document.execCommand("copy"),document.body.removeChild(Q)}function qe($={}){const H=(Array.isArray($==null?void 0:$.promptBlocks)?$.promptBlocks:[]).filter(Ce=>(Ce==null?void 0:Ce.type)==="text"||(Ce==null?void 0:Ce.type)==="imported_text").map(Ce=>String((Ce==null?void 0:Ce.content)||"").replace(/\u200b/g,"").trim()).filter(Boolean).join(`
41
+
42
+ `);return H||String(($==null?void 0:$.prompt)||"").replace(/\u200b/g,"").trim()}function xt($={}){const Q=qe($);Q&&s("insert-code-context",{source:"response",content:Q})}async function Bt($){var k,_,q,re,oe;const Q=(_=(k=$==null?void 0:$.target)==null?void 0:k.closest)==null?void 0:_.call(k,'[data-copy-code="1"]');if(!Q)return;const H=Q.closest(".codex-code-block"),Ce=(q=H==null?void 0:H.querySelector)==null?void 0:q.call(H,"pre code"),Xt=String((Ce==null?void 0:Ce.textContent)||"").replace(/\u200b/g,"");if(Xt){(re=$.preventDefault)==null||re.call($),(oe=$.stopPropagation)==null||oe.call($);try{await Be(Xt),s("toast",{message:Ie("sessionPanel.codeCopied"),type:"success"})}catch{s("toast",{message:Ie("errors.requestFailed"),type:"warning"})}}}function Vt(){if(!C.value.visible)return;const $=String(C.value.content||"").replace(/\u200b/g,"").trim();if(!$){N({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:$}),N({clearBrowserSelection:!0})}function z($={}){if($!=null&&$.errorMessage)return;const Q=String(($==null?void 0:$.responseMessage)||"").replace(/\u200b/g,"").trim();Q&&s("insert-code-context",{source:"response",content:Q})}const Y=K(()=>te.value.flatMap($=>(Array.isArray($==null?void 0:$.promptBlocks)?$.promptBlocks:[]).filter(Q=>(Q==null?void 0:Q.type)==="image").map(Q=>Q.content)));function de($){const H=(Array.isArray($==null?void 0:$.events)?$.events:[]).filter(Ce=>!we(Ce));return Np(H)}function ge($){return Qe($)}function Ve($){return $!=null&&$.eventsLoaded?ge($)>0:Ze($)}function Ct($){return!!($!=null&&$.eventsLoading)}function Zt($){return!!($!=null&&$.eventsLoaded)&&de($).length>0&&!tt($)}function mt($){return!!($!=null&&$.eventsLoaded)&&ge($)>0&&tt($)}function Ft($){return Ze($)&&!($!=null&&$.eventsLoaded)&&!($!=null&&$.eventsLoading)}function bt($={}){return jr($,{defaultLabel:Ie("sessionPanel.defaultAgent")})}function sn($={}){return!ep($)}function dn($={}){return"bg-[var(--theme-appPanelStrong)]"}function fn($=null){const Q=String(($==null?void 0:$.id)||"").trim();if(Q)return Ae.value.find(Ce=>Ce.id===Q)||null;const H=String(ie.value||"").trim();return H?Ae.value.find(Ce=>Ce.id===H)||null:Ge.value[0]||null}function qt($=null){const Q=fn($);return Q!=null&&Q.cwd?(et.value=Q.id,Me.value=!0,!0):!1}function Kt(){return E.value?!1:(Z(),!0)}function It(){var $,Q;return Me.value?(Me.value=!1,!0):(Q=($=at.value)==null?void 0:$.closeTopDialog)!=null&&Q.call($)?!0:We.value?(l(),!0):!1}return t({closeTopDialog:It,openProjectManager:Kt,openSourceBrowser:qt,send:D,scrollToBottom:Le,stop:ut}),($,Q)=>(m(),b("section",Op,[fe(wf,{open:Me.value,session:a(Ae).find(H=>H.id===et.value)||null,onInsertCodeContext:Q[0]||(Q[0]=H=>s("insert-code-context",H)),onClose:Q[1]||(Q[1]=H=>Me.value=!1)},null,8,["open","session"]),fe(a(o),{ref_key:"managerDialogRef",ref:at,open:a(We),sessions:a(Ae),workspaces:a(he),"selected-session-id":a(ie),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(pe),sending:a(ve),"on-refresh":a(se),"on-create":a(f),"on-update":a(A),"on-delete":a(P),"on-reset":a(ee),onClose:a(l),onOpenSourceBrowser:Q[2]||(Q[2]=H=>qt(H)),onProjectCreated:Q[3]||(Q[3]=H=>s("project-created",H)),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",Fp,[i("div",Up,[i("div",jp,[i("div",{class:"min-w-0 flex-1",title:a(X)||""},[fe(Yu,{modelValue:a(ie),"onUpdate:modelValue":Q[4]||(Q[4]=H=>Da(ie)?ie.value=H:null),sessions:a(Ge),loading:a(pe),disabled:a(ve)||a(E)||e.sessionSelectionLocked,onRefreshIntent:a(ce)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,Vp),i("div",zp,[i("button",{type:"button",class:be(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(T)?"tool-button-accent-subtle":""]),"aria-pressed":a(T)?"true":"false","aria-label":a(T)?a(Ie)("sessionPanel.hideProcessToggle"):a(Ie)("sessionPanel.showProcessToggle"),title:a(T)?a(Ie)("sessionPanel.hideProcessToggle"):a(Ie)("sessionPanel.showProcessToggle"),onClick:Q[5]||(Q[5]=(...H)=>a(Te)&&a(Te)(...H))},[a(T)?(m(),Ee(a(Ua),{key:0,class:"h-4 w-4"})):(m(),Ee(a(ja),{key:1,class:"h-4 w-4"}))],10,Hp),e.diffSupported?(m(),b("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:!e.taskSlug,onClick:Ht},[fe(a(qo),{class:"h-4 w-4"}),Q[17]||(Q[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Kp,x(a(Ie)("sessionPanel.diff")),1)],8,qp)):me("",!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(E),onClick:Q[6]||(Q[6]=(...H)=>a(Z)&&a(Z)(...H))},[fe(a(is),{class:"h-4 w-4"}),Q[18]||(Q[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Gp,x(a(Ie)("sessionPanel.manageProjects")),1)],8,Wp)])]),Pt.value?(m(),b("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(Ie)("sessionPanel.agentFilter")},[i("button",{type:"button",class:be(["theme-agent-selector-button",Je.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Je.value==="all"?"true":"false",onClick:Q[7]||(Q[7]=H=>Je.value="all")},x(a(Ie)("sessionPanel.allAgents")),11,Yp),(m(!0),b(lt,null,pt(Xe.value,H=>(m(),b("button",{key:H.engine,type:"button",class:be(["theme-agent-selector-button",Je.value===H.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Je.value===H.engine?"true":"false",title:bt(H),onClick:Ce=>Je.value=H.engine},x(bt(H)),11,Jp))),128))],8,Xp)):me("",!0),a(De)?(m(),b("p",Qp,[fe(a(Ao),{class:"h-4 w-4"}),i("span",null,x(a(De)),1)])):me("",!0)])]),i("div",Zp,[i("div",{ref_key:"transcriptRef",ref:V,"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:Q[9]||(Q[9]=(...H)=>a(j)&&a(j)(...H)),onTouchstartPassive:Q[10]||(Q[10]=(...H)=>a(J)&&a(J)(...H)),onTouchmovePassive:Q[11]||(Q[11]=(...H)=>a(M)&&a(M)(...H)),onTouchendPassive:Q[12]||(Q[12]=(...H)=>a(G)&&a(G)(...H)),onTouchcancelPassive:Q[13]||(Q[13]=(...H)=>a(G)&&a(G)(...H))},[a(te).length?At.value.length?me("",!0):(m(),b("div",tm,x(a(Ie)("sessionPanel.emptyAgentFilter")),1)):(m(),b("div",em,x(a(Ie)("sessionPanel.empty")),1)),(m(!0),b(lt,null,pt(At.value,H=>(m(),b("div",{key:H.id,"data-promptx-turn":"1","data-turn-id":H.id,"data-run-id":H.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",sm,[i("div",om,[i("div",rm,[i("span",am,x(Oe(H)),1),i("div",im,[qe(H)?(m(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:Ce=>xt(H)},[fe(a(Rs),{class:"h-3 w-3"}),i("span",null,x(a(Ie)("sessionPanel.insert")),1)],8,lm)):me("",!0),i("span",null,x(a(u)(H.startedAt)),1)])]),i("div",um,[Array.isArray(H.promptBlocks)&&H.promptBlocks.length?(m(),b("div",cm,[(m(!0),b(lt,null,pt(H.promptBlocks,(Ce,Xt)=>(m(),b(lt,{key:`${H.id}-prompt-${Xt}`},[Ce.type==="text"||Ce.type==="imported_text"?(m(),b("pre",dm,x(Ce.content),1)):(m(),b("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:k=>le(Ce.content)},[i("img",{src:Ce.content,alt:a(Ie)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,pm)],8,fm))],64))),128))])):(m(),b("pre",mm,x(H.prompt),1))])])]),a(T)&&sn(H)?(m(),b("div",gm,[i("div",{class:be(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(p)(H)])},[i("div",hm,[i("span",vm,x(a(Ie)("sessionPanel.processTitle")),1),i("div",ym,[Ve(H)?(m(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",disabled:H.eventsLoading,onClick:Ce=>a(Tt)(H)},[Ct(H)?(m(),Ee(a(Gt),{key:0,class:"h-3 w-3 animate-spin"})):a(tt)(H)?(m(),Ee(a(Eo),{key:1,class:"h-3 w-3"})):(m(),Ee(a(Va),{key:2,class:"h-3 w-3"})),i("span",null,x(H.eventsLoading?a(Ie)("sessionPanel.loading"):a(tt)(H)?`${a(Ie)("sessionPanel.expand")} (${ge(H)})`:a(Ie)("sessionPanel.collapse")),1)],8,Sm)):me("",!0),i("span",null,x(a(w)(H)),1)])]),Ct(H)?(m(),b("div",wm,x(a(Ie)("sessionPanel.loadingEvents")),1)):Zt(H)?(m(),b("div",xm,[(m(!0),b(lt,null,pt(de(H),Ce=>(m(),b("div",{key:Ce.id,class:be(["transcript-event-card min-w-0 rounded-sm px-3 py-2",dn(Ce)])},[i("div",bm,x(Ce.title),1),Ce.detail||Array.isArray(Ce.detailBlocks)&&Ce.detailBlocks.length?(m(),Ee(Jc,{key:0,detail:Ce.detail,blocks:Ce.detailBlocks,kind:Ce.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):me("",!0)],2))),128))])):mt(H)||Ft(H)?(m(),b("div",km,x(H.eventsLoaded?a(Ie)("sessionPanel.hiddenEventsLoaded",{count:ge(H)}):a(Ie)("sessionPanel.hiddenEventsLoadLater",{count:ge(H)})),1)):(m(),b("p",_m,x(["queued","starting","running","stopping"].includes(H.status)?a(Ie)("sessionPanel.waitingEvents",{agent:a(c)(H)}):a(Ie)("sessionPanel.noEvents")),1)),a(O)(H)?(m(),b("div",Tm,[a(g)(H)?(m(),b("div",Cm,x(a(g)(H)),1)):me("",!0),a(h)(H)?(m(),b("div",Em,x(a(h)(H)),1)):me("",!0),a(y)(H).length?(m(),b("div",Am,[(m(!0),b(lt,null,pt(a(y)(H),Ce=>(m(),b("span",{key:Ce.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,x(Ce.label),1),i("span",$m,x(Ce.value),1)]))),128))])):me("",!0)])):me("",!0)],2)])):me("",!0),a(je)(H)?(m(),b("div",Im,[i("div",{class:be(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",H.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",Pm,[i("span",Dm,x(Re(H)),1),i("div",Lm,[e.diffSupported&&H.runId?(m(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:Ce=>St(H)},[fe(a(qo),{class:"h-3 w-3"}),i("span",null,x(a(Ie)("sessionPanel.view")),1)],8,Mm)):me("",!0),H.responseMessage&&!H.errorMessage?(m(),b("button",{key:1,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:Ce=>z(H)},[fe(a(Rs),{class:"h-3 w-3"}),i("span",null,x(a(Ie)("sessionPanel.insert")),1)],8,Bm)):me("",!0),i("span",null,x(a(u)(H.finishedAt||H.startedAt)),1)])]),i("div",Rm,[H.errorMessage?(m(),b("div",Nm,x(H.errorMessage),1)):(m(),b("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:Q[8]||(Q[8]=(...Ce)=>a(ne)&&a(ne)(...Ce)),onClick:Bt,innerHTML:a(Dt)(H)},null,40,Om))])],2)])):me("",!0)],8,nm))),128)),a(C).visible?(m(),Ee(Qr,{key:2,top:a(C).top,left:a(C).left,label:a(Ie)("sourceBrowser.insertSelection"),onClick:Vt},null,8,["top","left","label"])):me("",!0)],544),i("div",Fm,[a(He)?(m(),b("button",{key:0,type:"button",class:be([a(ve)?"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:Q[14]||(Q[14]=(...H)=>a(Le)&&a(Le)(...H))},[fe(a(za),{class:"h-3.5 w-3.5"}),i("span",null,x(a(Ie)("sessionPanel.jumpToLatest")),1)],2)):me("",!0),a(ve)?(m(),b("button",{key:1,type:"button",class:"tool-button tool-button-warning-subtle pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur",disabled:a(U),onClick:Q[15]||(Q[15]=(...H)=>a(ut)&&a(ut)(...H))},[a(U)?(m(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(m(),Ee(a(Ha),{key:1,class:"h-3.5 w-3.5"})),i("span",null,x(a(U)?a(Ie)("sessionPanel.stopping"):a(Ie)("sessionPanel.stop")),1),a(U)?me("",!0):(m(),b("span",jm,[...Q[19]||(Q[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,Um)):me("",!0)])]),fe(Vr,{modelValue:Ne.value,"onUpdate:modelValue":Q[16]||(Q[16]=H=>Ne.value=H),images:Y.value},null,8,["modelValue","images"])]))}},zm={key:0,class:"h-full min-h-0"},Hm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},fr={__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=F(null);function r(){var y,h;return(h=(y=s.value)==null?void 0:y.send)==null?void 0:h.call(y)}function l(){var y,h;(h=(y=s.value)==null?void 0:y.stop)==null||h.call(y)}function u(){var y,h;(h=(y=s.value)==null?void 0:y.scrollToBottom)==null||h.call(y)}function p(){var y,h;return((h=(y=s.value)==null?void 0:y.openProjectManager)==null?void 0:h.call(y))||!1}function w(){var y,h;return((h=(y=s.value)==null?void 0:y.openSourceBrowser)==null?void 0:h.call(y))||!1}function c(){var y,h;return((h=(y=s.value)==null?void 0:y.closeTopDialog)==null?void 0:h.call(y))||!1}return t({closeTopDialog:c,openProjectManager:p,openSourceBrowser:w,send:r,stop:l,scrollToBottom:u}),(y,h)=>e.taskSlug?(m(),b("div",zm,[fe(Vm,{ref_key:"panelRef",ref:s,active:!!e.taskSlug,"task-slug":e.taskSlug,"build-prompt":e.buildPrompt||(()=>""),"build-prompt-blocks":e.buildPromptBlocks||(()=>[]),"selected-session-id":e.selectedSessionId,"selected-agent-engine":e.selectedAgentEngine,"session-selection-locked":e.sessionSelectionLocked,"session-selection-lock-reason":e.sessionSelectionLockReason,"diff-supported":e.diffSupported,"task-running":e.taskRunning,onAgentBindingsChange:h[0]||(h[0]=g=>o("agent-bindings-change",g)),onInsertCodeContext:h[1]||(h[1]=g=>o("insert-code-context",g)),onProjectCreated:h[2]||(h[2]=g=>o("project-created",g)),onSendingChange:h[3]||(h[3]=g=>o("sending-change",g)),onSelectedSessionChange:h[4]||(h[4]=g=>o("selected-session-change",g)),"onUpdate:selectedAgentEngine":h[5]||(h[5]=g=>o("update:selectedAgentEngine",g)),onOpenDiff:h[6]||(h[6]=g=>o("open-diff",g)),onToast:h[7]||(h[7]=g=>o("toast",g))},null,8,["active","task-slug","build-prompt","build-prompt-blocks","selected-session-id","selected-agent-engine","session-selection-locked","session-selection-lock-reason","diff-supported","task-running"])])):e.emptyMessage?(m(),b("section",Hm,x(e.emptyMessage),1)):me("",!0)}},qm=["title"],Km={class:"flex min-w-0 items-center gap-1.5"},Wm=["aria-pressed","title","data-agent-engine","onClick"],pr={__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}=_t(),r=K(()=>{const c=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(y=>{const h=String((y==null?void 0:y.engine)||"").trim();return!h||c.has(h)?!1:(c.add(h),!0)})}),l=K(()=>r.value.length>1),u=K(()=>{var y,h;const c=String(n.selectedAgentEngine||"").trim();return r.value.some(g=>g.engine===c)?c:((y=r.value.find(g=>g.isDefault))==null?void 0:y.engine)||((h=r.value[0])==null?void 0:h.engine)||""}),p=K(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function w(c={}){return jr(c,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(c,y)=>l.value?(m(),b("div",{key:0,class:be(["flex w-full overflow-x-auto pb-0.5",p.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:y[1]||(y[1]=ot(()=>{},["stop"]))},[i("div",Km,[(m(!0),b(lt,null,pt(r.value,h=>(m(),b("button",{key:h.engine,type:"button",class:be(["theme-agent-selector-button",h.engine===u.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":h.engine===u.value,title:w(h),"data-agent-engine":h.engine,onMousedown:y[0]||(y[0]=ot(()=>{},["prevent"])),onClick:g=>o("update:selectedAgentEngine",h.engine)},x(w(h)),43,Wm))),128))])],42,qm)):me("",!0)}},Gm={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":""},Xm={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},Ym=["disabled","title","aria-label"],Jm={class:"sr-only sm:not-sr-only sm:inline"},Qm=["title","aria-label"],Zm={class:"sr-only sm:not-sr-only sm:inline"},eg=["disabled","title","aria-label"],tg={class:"sr-only sm:not-sr-only sm:inline"},ng=["title","aria-label"],sg={class:"sr-only sm:not-sr-only sm:inline"},og={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"},rg=["disabled","title","aria-label"],ag={class:"sr-only sm:not-sr-only sm:inline"},mr={__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}=_t(),r=K(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(u,p)=>(m(),b("div",Gm,[i("div",Xm,[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:p[0]||(p[0]=ot(()=>{},["prevent"])),onClick:p[1]||(p[1]=w=>o("open-file-picker"))},[e.uploading?(m(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ee(a(qa),{key:1,class:"h-4 w-4"})),i("span",Jm,x(a(s)("editor.chooseFiles")),1)],40,Ym),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:p[2]||(p[2]=ot(()=>{},["prevent"])),onClick:p[3]||(p[3]=w=>o("clear-request"))},[fe(a(Ka),{class:"h-4 w-4"}),i("span",Zm,x(a(s)("editor.clear")),1)],40,Qm),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:p[4]||(p[4]=ot(()=>{},["prevent"])),onClick:p[5]||(p[5]=w=>o("add-todo"))},[fe(a(Rs),{class:"h-4 w-4"}),i("span",tg,x(a(s)("editor.todo")),1)],40,eg),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:p[6]||(p[6]=ot(()=>{},["prevent"])),onClick:p[7]||(p[7]=w=>o("manage-todo"))},[fe(a(Dr),{class:"h-4 w-4"}),i("span",sg,x(l()),1),e.todoCount>0?(m(),b("span",og,x(e.todoCount>9?"9+":e.todoCount),1)):me("",!0)],40,ng),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:p[8]||(p[8]=ot(()=>{},["prevent"])),onClick:p[9]||(p[9]=w=>o("send-request"))},[r.value?(m(),Ee(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ee(a(Wa),{key:1,class:"h-4 w-4"})),i("span",ag,x(a(s)("editor.send")),1)],40,rg)])]))}};function ig(e){const{props:t,panelRef:n,onClose:o}=e,s=F({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=F(!1),l=F("bottom");function u(){o==null||o()}function p(g=!1){const f=window.innerWidth,P=window.innerHeight,ee=12,S=8,D=320,j=560,G=420,M=180,J=Math.min(j,Math.max(D,f-ee*2)),A=Math.min(J,f-ee*2),X=t.anchorRect||{left:(f-A)/2,top:P/2,bottom:P/2};let ue=X.left;ue+A>f-ee&&(ue=f-ee-A),ue<ee&&(ue=ee);const pe=Math.max(0,P-ee-(X.bottom+S)),E=Math.max(0,X.top-S-ee);g?l.value=pe>=E?"bottom":"top":l.value==="bottom"&&pe<M&&E>pe+24?l.value="top":l.value==="top"&&E<M&&pe>E+24&&(l.value="bottom");const Z=l.value,ce=Z==="bottom"?pe:E,ie=Math.max(140,P-ee*2),ve=Math.min(ie,Math.max(Math.min(G,ce||G),M)),T={left:`${Math.round(ue)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ve)}px`,top:"auto",bottom:"auto"};return Z==="bottom"?T.top=`${Math.round(Math.max(ee,X.bottom+S))}px`:T.bottom=`${Math.round(Math.max(ee,P-X.top+S))}px`,T}function w(g=!1){const f=p(g);s.value={...s.value,left:f.left,top:f.top,bottom:f.bottom,width:f.width,maxHeight:f.maxHeight}}function c(){return!t.open||!t.anchorRect?!1:(l.value="bottom",w(!0),r.value=!0,!0)}function y(){r.value=!1}function h(g){!t.open||!n.value||n.value.contains(g.target)||u()}return cn(()=>{document.addEventListener("pointerdown",h)}),Mt(()=>{document.removeEventListener("pointerdown",h)}),{closePicker:u,initializePanel:c,panelReady:r,panelStyle:s,resetPanel:y,updatePanelPosition:w}}function lg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:u,panelStyle:p,resetPanel:w,updatePanelPosition:c}=ig({props:t,panelRef:n,onClose:o}),y=na({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return Pe(()=>t.open,h=>{if(!h){y.resetData(),w();return}w(),t.anchorRect&&l()&&y.initializeData()},{flush:"sync"}),Pe(()=>t.anchorRect,h=>{if(!(!t.open||!h)){if(!u.value){l()&&y.initializeData();return}c(!1)}},{flush:"sync"}),Pe(()=>t.sessionId,()=>{y.handleSessionChange()},{flush:"sync",immediate:!0}),Pe(()=>t.query,()=>{y.handleQueryChange()},{immediate:!0}),Pe(y.visibleItems,()=>{y.handleVisibleItemsChange()},{immediate:!0}),{...y,closePicker:r,panelReady:u,panelStyle:p}}const ug={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},cg={class:"flex shrink-0 items-center gap-2"},dg={class:"min-h-0 flex-1 overflow-y-auto p-2"},fg={key:0,class:"theme-empty-state px-3 py-4 text-xs"},pg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},mg={key:2,class:"theme-empty-state px-3 py-4 text-xs"},gg={key:3,class:"theme-empty-state px-3 py-4 text-xs"},hg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},vg={key:5,class:"space-y-1"},yg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Sg=["onClick"],wg={class:"min-w-0 flex-1"},xg=["innerHTML"],bg=["innerHTML"],kg={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},_g=["onClick"],Tg={class:"min-w-0 flex-1"},Cg=["innerHTML"],Eg=["innerHTML"],Ag={key:6,class:"space-y-1"},$g={class:"flex items-start gap-1.5"},Ig=["onClick"],Pg={key:1,class:"block h-5 w-5 shrink-0"},Dg=["onClick"],Lg={class:"min-w-0 flex-1"},Mg={class:"flex items-center gap-1.5"},Bg={__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=F(null),{t:l}=_t(),{activeKey:u,closePicker:p,collapseActiveDirectory:w,confirmActive:c,currentError:y,currentLoading:h,emitSelect:g,expandActiveDirectory:f,getDisplayName:P,getHighlightedName:ee,getHighlightedPath:S,moveActive:D,normalSearchItems:j,normalizedQuery:G,panelReady:M,panelStyle:J,recentSearchItems:A,setItemRef:X,showSearchEmptyState:ue,showTreeEmptyState:pe,toggleDirectory:E,treeItems:Z,visibleItems:ce}=lg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:ie=>s("select",ie)});return t({collapseActiveDirectory:w,moveActive:D,confirmActive:c,expandActiveDirectory:f}),(ie,ve)=>(m(),Ee(fs,{to:"body"},[e.open&&a(M)?(m(),b("div",{key:0,ref_key:"panelRef",ref:r,class:"theme-popover fixed z-40 flex flex-col overflow-hidden rounded-sm border shadow-lg",style:In(a(J))},[i("div",ug,[i("div",cg,[i("div",{class:be(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(h)?"opacity-100":"opacity-0"])},[fe(a(Gt),{class:"h-3.5 w-3.5 animate-spin"})],2),i("button",{type:"button",class:"tool-button inline-flex h-7 w-7 items-center justify-center",onClick:ve[0]||(ve[0]=(...T)=>a(p)&&a(p)(...T))},[fe(a($r),{class:"h-4 w-4"})])])]),i("div",dg,[e.sessionId?a(y)?(m(),b("div",pg,x(a(y)),1)):a(ue)?(m(),b("div",mg,x(a(l)("pathPicker.noResults")),1)):a(pe)?(m(),b("div",gg,x(a(l)("pathPicker.emptyDirectory")),1)):a(h)&&!a(ce).length?(m(),b("div",hg,x(a(l)("pathPicker.loading")),1)):a(G)?(m(),b("div",vg,[a(A).length?(m(),b("div",yg,x(a(l)("pathPicker.recent")),1)):me("",!0),(m(!0),b(lt,null,pt(a(A),T=>(m(),b("button",{key:T.path,ref_for:!0,ref:U=>a(X)(T.path,U),type:"button",class:be(["theme-list-row focus:outline-none",a(u)===T.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:U=>a(g)(T)},[(m(),Ee(yn(T.type==="directory"?a(jn):a(Cn)),{class:"theme-list-item-icon"})),i("div",wg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ee)(T)},null,8,xg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(S)(T)},null,8,bg)])],10,Sg))),128)),a(G)&&a(j).length?(m(),b("div",kg,x(a(l)("pathPicker.results")),1)):me("",!0),(m(!0),b(lt,null,pt(a(j),T=>(m(),b("button",{key:T.path,ref_for:!0,ref:U=>a(X)(T.path,U),type:"button",class:be(["theme-list-row focus:outline-none",a(u)===T.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:U=>a(g)(T)},[(m(),Ee(yn(T.type==="directory"?a(jn):a(Cn)),{class:"theme-list-item-icon"})),i("div",Tg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ee)(T)},null,8,Cg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(S)(T)},null,8,Eg)])],10,_g))),128))])):(m(),b("div",Ag,[(m(!0),b(lt,null,pt(a(Z),T=>(m(),b("div",{key:T.path,ref_for:!0,ref:U=>a(X)(T.path,U),class:be(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(u)===T.path?"theme-list-item-active":T.type==="directory"&&T.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:In({paddingLeft:`${T.depth*16+6}px`})},[i("div",$g,[T.type==="directory"?(m(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:ot(U=>a(E)(T.path),["stop"])},[T.loading?(m(),Ee(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(m(),Ee(a(Pr),{key:1,class:be(["h-3.5 w-3.5 transition",T.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Ig)):(m(),b("span",Pg)),i("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:U=>a(g)(T)},[(m(),Ee(yn(T.type==="directory"?a(jn):a(Cn)),{class:be(["h-4 w-4 shrink-0",T.type==="directory"&&T.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",Lg,[i("div",Mg,[i("span",{class:be(["theme-list-item-title truncate",T.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},x(a(P)(T)),3)])])],8,Dg)])],6))),128))])):(m(),b("div",fg,x(a(l)("pathPicker.selectProjectFirst")),1))])],4)):me("",!0)]))}},Rg={__name:"TiptapTextBlockView",props:$o,setup(e){return(t,n)=>(m(),Ee(a(Io),{"data-promptx-node":"text"},{default:st(()=>[fe(a(Br),{"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}))}},ba={__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=K(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=K(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(m(),b("div",{class:be(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:be(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[nn(s.$slots,"header",{actionsStateClass:o.value})],2),nn(s.$slots,"default")],2))}},Et={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function Ng(){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 Hn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||Ng()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Un(e=""){return Hn({type:Lt.TEXT,content:e,meta:{}})}function xs(e){return e&&e.type!==Lt.TEXT}function An(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Un("")];const n=[];return t.forEach((o,s)=>{const r=Hn(o),l=n[n.length-1];!l&&xs(r)&&n.push(Un("")),l&&xs(l)&&xs(r)&&n.push(Un("")),n.push(r),s===t.length-1&&xs(r)&&n.push(Un(""))}),n}function _o(e=""){const t=String(e||"").split(`
43
+ `),n=[];return t.forEach((o,s)=>{o&&n.push({type:Et.TEXT,text:o}),s<t.length-1&&n.push({type:Et.HARD_BREAK})}),n}function Og(e=""){return _o(e)}function Fg(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 Us(e=[]){return Fg(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===Et.TEXT?String(t.text||""):n===Et.HARD_BREAK?`
44
+ `:Us((t==null?void 0:t.content)||[])}).join("")}function Ug(e=[]){return Us(e)}function jg(e={}){var n,o;const t=Hn(e);return t.type===Lt.IMAGE?{type:Et.IMAGE_BLOCK,attrs:{clientId:t.clientId,src:String(t.content||"")}}:t.type===Lt.IMPORTED_TEXT?{type:Et.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:_o(t.content)}:{type:Et.TEXT_BLOCK,attrs:{clientId:t.clientId},content:_o(t.content)}}function ka(e=[]){return An(e).map(jg)}function bs(e=[]){return{type:Et.DOC,content:ka(e)}}function Vg(e={}){var t,n,o,s,r,l;return(e==null?void 0:e.type)===Et.IMAGE_BLOCK?Hn({type:Lt.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)===Et.IMPORTED_TEXT_BLOCK?Hn({type:Lt.IMPORTED_TEXT,content:Us(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)===Et.TEXT_BLOCK?Hn({type:Lt.TEXT,content:Us(e.content||[]),clientId:String(((l=e.attrs)==null?void 0:l.clientId)||""),meta:{}}):null}function zg(e=null){const n=(Array.isArray(e==null?void 0:e.content)?e.content:[]).map(Vg).filter(Boolean);return An(n)}function ns(e=[]){return JSON.stringify(An(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 Hg(e=""){const t=String(e);return{lines:t?t.split(`
45
+ `).length:0,chars:t.length}}function Ds(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 qg={class:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5","data-promptx-imported-meta":""},Kg=["aria-expanded"],Wg={class:"theme-heading inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Gg=["aria-expanded"],Xg={class:"mt-0.5 break-all text-[12px] leading-4 text-[var(--theme-textSecondary)]"},Yg=["aria-label"],Jg={class:"max-h-[8.5rem] overflow-hidden whitespace-pre-wrap break-words leading-6"},Qg={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-[var(--theme-appPanelMuted)] to-transparent"},Zg={key:1,class:"theme-muted-text absolute bottom-2 right-4 bg-[var(--theme-appPanelMuted)] pl-2 text-xs"},go="tool-button inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",eh={__name:"TiptapImportedTextBlockView",props:$o,setup(e){const t=e,{t:n}=_t(),o=K(()=>{var g;return Ug(((g=t.node)==null?void 0:g.content)||[])}),s=K(()=>{var g,f;return String(((f=(g=t.node)==null?void 0:g.attrs)==null?void 0:f.fileName)||n("blockEditor.unnamedFile"))}),r=K(()=>{const g=Hg(o.value);return n("blockEditor.stats",g)}),l=K(()=>n("blockEditor.fileSummary",{name:s.value,stats:r.value})),u=K(()=>{const g=String(o.value||"").replace(/\r\n/g,`
46
+ `),f=g.split(`
47
+ `),P=[];let ee=0;for(const j of f){const G=j.trimEnd(),M=G.length?G:"";if(!(!M&&P[P.length-1]==="")&&(P.push(M),ee+=M.length,P.length>=4||ee>=220))break}const S=P.join(`
48
+ `).trim(),D=g.trim();return{text:S,truncated:P.length<f.length||S.length<D.length}}),p=`${go} tool-button-danger-subtle`;function w(g){g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),c())}function c(){var g,f,P;(P=t.updateAttributes)==null||P.call(t,{collapsed:!((f=(g=t.node)==null?void 0:g.attrs)!=null&&f.collapsed)}),Ds(t.editor)}function y(){var S;const{editor:g,getPos:f,node:P}=t;if(!g||typeof f!="function"||!P)return;const ee=f();g.chain().focus().insertContentAt({from:ee,to:ee+P.nodeSize},{type:Et.TEXT_BLOCK,attrs:{clientId:String(((S=P.attrs)==null?void 0:S.clientId)||"")},content:Og(o.value)}).run(),Ds(t.editor)}function h(){var g;(g=t.deleteNode)==null||g.call(t),Ds(t.editor)}return(g,f)=>(m(),Ee(a(Io),{class:"group relative","data-promptx-node":"imported_text"},{default:st(()=>[fe(ba,{selected:g.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:st(({actionsStateClass:P})=>{var ee,S,D,j;return[i("div",qg,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((ee=g.node.attrs)!=null&&ee.collapsed)),onClick:c,onKeydown:w},[i("p",Wg,[fe(a(Ns),{class:"h-3.5 w-3.5 shrink-0"}),gn(" "+x(a(n)("blockEditor.file")),1)])],40,Kg),i("div",{"data-promptx-imported-actions":"",class:be(["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:be(go),contenteditable:"false",onClick:c},[fe(a(Eo),{class:be(["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,x((D=g.node.attrs)!=null&&D.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:be(go),contenteditable:"false",onClick:y},[fe(a(Ns),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,x(a(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:be(p),contenteditable:"false",onClick:h},[fe(a(Ks),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,x(a(n)("blockEditor.delete")),1)])],2),i("div",{class:"col-span-2 min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((j=g.node.attrs)!=null&&j.collapsed)),onClick:c,onKeydown:w},[i("p",Xg,x(l.value),1)],40,Gg)])]}),default:st(()=>{var P,ee;return[Jt(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:w},[i("div",Jg,x(u.value.text||a(n)("blockEditor.emptyContent")),1),u.value.truncated?(m(),b("div",Qg)):me("",!0),u.value.truncated?(m(),b("span",Zg,"...")):me("",!0)],40,Yg),[[Ms,(P=g.node.attrs)==null?void 0:P.collapsed]]),Jt(fe(a(Br),{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),[[Ms,!((ee=g.node.attrs)!=null&&ee.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},th={class:"flex min-w-0 items-center justify-between gap-3"},nh={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},sh={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},oh=["src","alt"],rh="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]",ah={__name:"TiptapImageBlockView",props:$o,setup(e){const t=e,{t:n}=_t();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),Ds(t.editor)}return(r,l)=>(m(),Ee(a(Io),{class:"group","data-promptx-node":"image"},{default:st(()=>[fe(ba,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:st(({actionsStateClass:u})=>[i("div",th,[i("div",nh,[fe(a(Lr),{class:"h-3.5 w-3.5 shrink-0"}),gn(" "+x(a(n)("blockEditor.image")),1)]),i("div",{class:be(["shrink-0 transition",u])},[i("button",{type:"button",class:be(rh),contenteditable:"false",onClick:s},[fe(a(Ks),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,x(a(n)("blockEditor.delete")),1)])],2)])]),default:st(()=>{var u;return[i("div",sh,[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,oh)])])]}),_:1},8,["selected"])]),_:1}))}},ih=["accept"],gr=10*1024*1024,hr=2*1024*1024,vr=8*1024*1024,lh=1500,uh={__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}=_t(),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"]),p=["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(","),w=F(null),c=F(null),y=F(""),h=F(at()),g=F(null),f=F(null),P=F(!1),ee=F(0),S=K(()=>An(o.modelValue)),D=K(()=>S.value.filter(C=>(C==null?void 0:C.type)===Lt.IMAGE&&String(C.content||"").trim()).map(C=>String(C.content||"").trim()));let j=ns(S.value);function G(C=X.value){if(!C)return!1;const N=zg(C.getJSON()),ne=ns(N);return ne===j?!1:(j=ne,s("update:modelValue",N),!0)}const M=si.extend({name:Et.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return eo(Rg)}}),J=Ko.create({name:Et.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:C}){return["div",{...C,"data-type":"promptx-imported-text-block"}]},addNodeView(){return eo(eh)}}),A=Ko.create({name:Et.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:C}){return["div",{...C,"data-type":"promptx-image-block"}]},addNodeView(){return eo(ah)}}),X=oi({extensions:[ri.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}),M,J,A],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(C,N){return $a(N,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:se()})?(N.preventDefault(),N.stopPropagation(),s("send-request"),!0):!N.shiftKey&&!N.altKey&&(N.metaKey||N.ctrlKey)&&String(N.key||"").toLowerCase()==="k"?Xe():At(N)}},content:bs(S.value),onCreate({editor:C}){it(C)},onFocus({editor:C}){P.value=!0,it(C)},onBlur(){P.value=!1},onSelectionUpdate({editor:C}){it(C)},onUpdate({editor:C}){ee.value=Date.now(),G(C),it(C)}});Pe(X,C=>{if(!C)return;const N=An(o.modelValue);j=ns(N),C.commands.setContent(bs(N),!1)},{immediate:!0}),Pe(()=>o.modelValue,C=>{const N=X.value;if(!N){j=ns(An(C));return}const ne=An(C),we=ns(ne);we!==j&&(j=we,N.commands.setContent(bs(ne),!1))},{deep:!0});function ue(C){const N=String(C||"").trim();N&&s("file-feedback",N)}function pe(C){const N=String((C==null?void 0:C.name)||"").trim().toLowerCase();return N.includes(".")?`.${N.split(".").pop()}`:""}function E(C,N){return String((C==null?void 0:C.name)||"").trim()||r(N)}function Z(C){const N=Math.max(0,Number(C)||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 ce(C){if(!C)return!1;const N=String(C.type||"").toLowerCase(),ne=pe(C);return N.startsWith("text/")||l.has(ne)||u.has(N)}function ie(C){if(!C)return!1;const N=String(C.name||"").toLowerCase(),ne=String(C.type||"").toLowerCase();return N.endsWith(".pdf")||ne==="application/pdf"}function ve(C){const N=Array.from(C||[]).filter(Boolean),ne={imageFiles:[],textFiles:[],pdfFiles:[]},we=[],Oe=[];return N.forEach(Re=>{if(Re.type.startsWith("image/")){if(Re.size>gr){Oe.push({name:E(Re,"blockEditor.unnamedImage"),limit:Z(gr)});return}ne.imageFiles.push(Re);return}if(ie(Re)){if(Re.size>vr){Oe.push({name:E(Re,"blockEditor.unnamedPdf"),limit:Z(vr)});return}ne.pdfFiles.push(Re);return}if(ce(Re)){if(Re.size>hr){Oe.push({name:E(Re,"blockEditor.unnamedFile"),limit:Z(hr)});return}ne.textFiles.push(Re);return}we.push(E(Re,"blockEditor.unnamedFile"))}),{...ne,unsupportedFiles:we,oversizedFiles:Oe}}function T({unsupportedFiles:C=[],oversizedFiles:N=[]}={}){var ne;C.length&&ue(r("blockEditor.unsupportedFiles",{names:C.slice(0,3).join("、"),extra:Math.max(0,C.length-3)})),N.length&&ue(r("blockEditor.oversizedFiles",{names:N.slice(0,2).map(we=>we.name).join("、"),extra:Math.max(0,N.length-2),limit:((ne=N[0])==null?void 0:ne.limit)||""}))}function U(C){const{imageFiles:N,textFiles:ne,pdfFiles:we,unsupportedFiles:Oe,oversizedFiles:Re}=ve(C);return T({unsupportedFiles:Oe,oversizedFiles:Re}),ne.length&&s("import-text-files",ne),we.length&&s("import-pdf-files",we),N.length&&s("upload-files",N),N.length+ne.length+we.length>0}function O(C){const N=[...C.clipboardData.items].filter(ne=>ne.kind==="file").map(ne=>ne.getAsFile()).filter(Boolean);N.length&&(C.preventDefault(),U(N))}function He(C){C.preventDefault(),U(C.dataTransfer.files)}function De(C){const N=X.value;if(!N)return;const ne=C.target instanceof Element?C.target:null,we=C.currentTarget instanceof Element?C.currentTarget:null,Oe=N.view.dom instanceof Element?N.view.dom:null;!ne||!we||!Oe||ne.closest('button, input, textarea, select, a, [contenteditable="false"]')||!we.contains(ne)||ne.closest("[data-promptx-node]")||!(ne===we||ne===Oe||we.contains(ne))||(C.preventDefault(),Ge())}function je(C){U(C.target.files),C.target.value=""}function We(){var C;(C=w.value)==null||C.click()}function Ge(){const C=X.value;C&&C.chain().focus("end").run()}function ut(){var ne,we;const C=X.value;if(!C)return!1;(we=(ne=C.view.domObserver)==null?void 0:ne.flush)==null||we.call(ne);const N=G(C);return N&&(ee.value=Date.now()),it(C),N}function Te(C=[]){const N=X.value;!N||!C.length||N.chain().focus().insertContent(C).run()}function V(C=[]){Te(ka(C))}function te(C=[]){V(C)}function he(C=[]){V(C)}function Ae(){const C=X.value;C&&C.commands.setContent(bs([Un("")]),!0)}function se(){var C,N;return!!((N=(C=X.value)==null?void 0:C.view)!=null&&N.composing)}function _e(){var C;return se()||P.value||(C=X.value)!=null&&C.isFocused?!0:Date.now()-ee.value<lh}function $e(){var we;const C=X.value;if(!C)return!1;const N=C.state.selection,ne=N.$from.nodeAfter||N.$from.parent;return((we=ne==null?void 0:ne.type)==null?void 0:we.name)===Et.IMPORTED_TEXT_BLOCK}function Le(C){var ne;const N=String(((ne=C==null?void 0:C.detail)==null?void 0:ne.src)||"").trim();N&&(y.value=N)}function at(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function Me(C=null,N=null){return!C||!N?!1:C.start===N.start&&C.end===N.end&&C.query===N.query&&C.clientId===N.clientId}function et(){g.value=null}function Ne(C={}){const{suppressCurrent:N=!1}=C,ne=h.value;N&&ne.open&&(f.value={start:ne.start,end:ne.end,query:ne.query,clientId:ne.clientId}),h.value=at(),et()}function Je(){Ne({suppressCurrent:!0})}function Ie(C=X.value){var Qe,Ze,tt;if(!C)return null;const N=C.state.selection;if(!N.empty)return null;const{$from:ne,from:we}=N,Oe=((Ze=(Qe=ne.parent)==null?void 0:Qe.type)==null?void 0:Ze.name)||"";if(![Et.TEXT_BLOCK,Et.IMPORTED_TEXT_BLOCK].includes(Oe))return null;const Re=ne.parent.textBetween(0,ne.parentOffset,`
49
+ `,"\0");return{from:we,node:ne.parent,nodeTypeName:Oe,nodeStart:ne.start(),parentOffset:ne.parentOffset,clientId:String(((tt=ne.parent.attrs)==null?void 0:tt.clientId)||""),textBefore:Re}}function ct(C=h.value.end){const N=X.value;if(typeof C=="object"&&C!==null&&(C=h.value.end),!N||!h.value.open||C<0){et();return}try{const ne=N.view.coordsAtPos(C);g.value={left:ne.left,right:ne.left,top:ne.bottom,bottom:ne.bottom,width:0,height:0}}catch{et()}}function it(C=X.value){const N=Ie(C),ne=h.value;if(ne.open&&ne.trigger==="shortcut"){if(!N||N.clientId!==ne.clientId||N.from<ne.start){Ne();return}const Ze=C.state.doc.textBetween(ne.start,N.from,`
50
+ `,"\0");if(/\s/.test(Ze)){Ne();return}f.value=null,h.value={...ne,end:N.from,query:Ze},ct(N.from);return}if(!N){Ne();return}const we=N.textBefore.lastIndexOf("@");if(we<0){Ne();return}const Oe=N.textBefore.slice(we+1);if(/\s/.test(Oe)){Ne();return}const Re=N.nodeStart+we,Qe=N.from;Me(f.value,{start:Re,end:Qe,query:Oe,clientId:N.clientId})||(f.value=null,h.value={open:!0,start:Re,end:Qe,query:Oe,trigger:"mention",blockType:N.nodeTypeName,clientId:N.clientId},ct(Qe))}function Xe(){const C=X.value,N=Ie(C);return!C||!N?!1:(f.value=null,h.value={open:!0,start:N.from,end:N.from,query:"",trigger:"shortcut",blockType:N.nodeTypeName,clientId:N.clientId},ct(N.from),!0)}function Pt(C){const N=X.value,ne=String((C==null?void 0:C.path)||"").trim(),we=h.value;if(!N||!ne||we.start<0||we.end<we.start)return Ne(),!1;const Oe=we.trigger==="shortcut"?`${ne} `:`@${ne} `,Re=we.start+Oe.length;return N.chain().focus().command(({tr:Qe,dispatch:Ze})=>(Qe.insertText(Oe,we.start,we.end),Qe.setSelection(La.create(Qe.doc,Re)),Ze==null||Ze(Qe),!0)).run(),ee.value=Date.now(),f.value=null,Ne(),!0}function At(C){var N,ne,we,Oe,Re,Qe,Ze,tt,Tt,$t;if(!h.value.open)return!1;if(C.key==="Escape")return Je(),!0;if(C.key==="ArrowDown")return!!((ne=(N=c.value)==null?void 0:N.moveActive)!=null&&ne.call(N,1));if(C.key==="ArrowUp")return!!((Oe=(we=c.value)==null?void 0:we.moveActive)!=null&&Oe.call(we,-1));if(h.value.query&&(C.key==="ArrowLeft"||C.key==="ArrowRight"))return!1;if(C.key==="ArrowRight"){const St=(Qe=(Re=c.value)==null?void 0:Re.expandActiveDirectory)==null?void 0:Qe.call(Re);return St&&typeof St.then=="function"?(St.catch(()=>{}),!0):!!St}return C.key==="ArrowLeft"?!!((tt=(Ze=c.value)==null?void 0:Ze.collapseActiveDirectory)!=null&&tt.call(Ze)):!C.shiftKey&&!C.altKey&&!C.metaKey&&!C.ctrlKey&&C.key==="Enter"?!!(($t=(Tt=c.value)==null?void 0:Tt.confirmActive)!=null&&$t.call(Tt)):!1}return cn(()=>{window.addEventListener("promptx:tiptap-image-preview",Le),window.addEventListener("resize",ct),window.addEventListener("scroll",ct)}),Mt(()=>{window.removeEventListener("promptx:tiptap-image-preview",Le),window.removeEventListener("resize",ct),window.removeEventListener("scroll",ct)}),Pe(()=>o.codexSessionId,()=>{Ne()}),t({clearContent:Ae,flushPendingInput:ut,focusEditor:Ge,insertBlocks:V,insertImportedBlocks:te,insertUploadedBlocks:he,isComposing:se,isEditing:_e,isImportedBlockActive:$e,openFilePicker:We}),(C,N)=>(m(),b("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:He,onDragover:N[1]||(N[1]=ot(()=>{},["prevent"])),onPaste:O},[i("input",{ref_key:"fileInputRef",ref:w,class:"hidden",type:"file",accept:a(p),multiple:"",onChange:je},null,40,ih),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:De},[a(X)?(m(),Ee(a(ai),{key:0,editor:a(X),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):me("",!0)],32),fe(Vr,{modelValue:y.value,"onUpdate:modelValue":N[0]||(N[0]=ne=>y.value=ne),images:D.value},null,8,["modelValue","images"]),fe(Bg,{ref_key:"mentionPickerRef",ref:c,open:h.value.open&&!!g.value,"session-id":e.codexSessionId,query:h.value.query,"anchor-rect":g.value,onClose:Je,onSelect:Pt},null,8,["open","session-id","query","anchor-rect"])],32))}},ch={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},yr={__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=F(null),{t:l}=_t(),u=K({get:()=>o.modelValue,set:S=>s("update:modelValue",S)});function p(){var S,D;(D=(S=r.value)==null?void 0:S.openFilePicker)==null||D.call(S)}function w(){var S,D;(D=(S=r.value)==null?void 0:S.focusEditor)==null||D.call(S)}function c(){var S,D;return((D=(S=r.value)==null?void 0:S.flushPendingInput)==null?void 0:D.call(S))||!1}function y(S){var D,j;(j=(D=r.value)==null?void 0:D.insertBlocks)==null||j.call(D,S)}function h(S){var D,j;(j=(D=r.value)==null?void 0:D.insertImportedBlocks)==null||j.call(D,S)}function g(S){var D,j;(j=(D=r.value)==null?void 0:D.insertUploadedBlocks)==null||j.call(D,S)}function f(){var S,D;return((D=(S=r.value)==null?void 0:S.isImportedBlockActive)==null?void 0:D.call(S))||!1}function P(){var S,D;return((D=(S=r.value)==null?void 0:S.isComposing)==null?void 0:D.call(S))||!1}function ee(){var S,D;return((D=(S=r.value)==null?void 0:S.isEditing)==null?void 0:D.call(S))||!1}return t({focusEditor:w,flushPendingInput:c,insertBlocks:y,insertImportedBlocks:h,insertUploadedBlocks:g,isComposing:P,isEditing:ee,isImportedBlockActive:f,openFilePicker:p}),(S,D)=>e.loading&&!e.modelValue.length?(m(),b("section",ch,x(a(l)("workbench.loadingTaskContent")),1)):(m(),Ee(uh,{key:1,ref_key:"blockEditorRef",ref:r,modelValue:u.value,"onUpdate:modelValue":D[0]||(D[0]=j=>u.value=j),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:D[1]||(D[1]=j=>s("upload-files",j)),onImportTextFiles:D[2]||(D[2]=j=>s("import-text-files",j)),onImportPdfFiles:D[3]||(D[3]=j=>s("import-pdf-files",j)),onFileFeedback:D[4]||(D[4]=j=>s("file-feedback",j)),onClearRequest:D[5]||(D[5]=j=>s("clear-request")),onSendRequest:D[6]||(D[6]=j=>s("send-request"))},null,8,["modelValue","codex-session-id","send-behavior"]))}},dh={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},fh={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},ph={class:"flex items-center gap-2"},mh=["title","aria-label"],gh={class:"min-w-0 flex-1"},hh=["value","placeholder"],vh=["disabled"],yh={class:"truncate"},Sh={__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}=_t();return(s,r)=>(m(),b("section",dh,[i("div",fh,[i("div",ph,[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"))},[fe(a(Ga),{class:"h-3.5 w-3.5"})],8,mh),i("div",gh,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(m(),b("input",{key:0,value:e.titleInputValue,type:"text",maxlength:"140","data-task-title-input":"current",class:"block w-full appearance-none border-0 bg-transparent p-0 text-left text-[13px] font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(o)("workbench.untitledTask"),onInput:r[1]||(r[1]=l=>n("update:titleInputValue",l.target.value)),onKeydown:[r[2]||(r[2]=Qt(ot(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=Qt(ot(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,hh)):(m(),b("button",{key:1,type:"button",class:"inline-flex w-full items-center gap-1 truncate bg-transparent p-0 text-left text-[13px] font-semibold leading-5",disabled:!e.currentTaskSlug,onClick:r[5]||(r[5]=l=>n("begin-edit"))},[i("span",yh,x(e.title||a(o)("workbench.untitledTask")),1),fe(a(is),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,vh))])])])]))}},wh={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},xh={class:"workbench-panel-header theme-divider border-b px-4 py-4"},bh={class:"flex items-center justify-between gap-3"},kh={class:"flex min-h-8 items-center"},_h={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Th=["title"],Ch=["disabled","title"],Eh={class:"whitespace-nowrap"},Ah={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},$h={key:0,class:"theme-empty-state px-3 py-4 text-sm"},Ih=["onClick"],Ph={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},Dh={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"},Lh={class:"flex items-start justify-between gap-3"},Mh={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},Bh=["title","aria-label"],Rh={class:"min-w-0 h-5 flex-1 overflow-hidden"},Nh=["value","placeholder"],Oh=["title","onClick"],Fh={class:"min-w-0 truncate"},Uh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},jh={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},Vh={class:"mt-2 flex items-center justify-between gap-3"},zh={class:"min-w-0 text-[11px] opacity-70"},Hh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},qh={class:"theme-divider border-t px-3 py-3"},Kh={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},Wh={class:"min-w-0 break-words"},Gh={class:"grid grid-cols-2 gap-2"},Xh=["disabled","title"],Yh={class:"whitespace-nowrap"},Jh=["disabled","title"],Qh={class:"whitespace-nowrap"},Zh={__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}=_t(),r=F([]);Pe(()=>n.tasks,h=>{r.value=Array.isArray(h)?[...h]:[]},{immediate:!0});function l(h){return h.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":h.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function u(){return"theme-status-warning"}function p(h){const g=new Date(h.updatedAt);return Number.isNaN(g.getTime())?"":Tr(g.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function w(h){var g,f;return!!((g=h==null?void 0:h.workspaceDiffSummary)!=null&&g.supported&&((f=h==null?void 0:h.workspaceDiffSummary)!=null&&f.fileCount))}function c(h){return h.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function y(h){if(n.mobile)return;const g=Number(h==null?void 0:h.oldIndex),f=Number(h==null?void 0:h.newIndex);!Number.isInteger(g)||!Number.isInteger(f)||g===f||o("reorder-task",r.value.map(P=>String((P==null?void 0:P.slug)||"").trim()).filter(Boolean))}return(h,g)=>(m(),b("aside",wh,[i("div",xh,[i("div",bh,[i("div",kh,[i("div",_h,[fe(a(Xa),{class:"h-4 w-4"}),i("span",null,x(a(s)("workbench.title")),1)])]),i("button",{type:"button",class:"tool-button inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-xs",title:a(s)("workbench.settings"),onClick:g[0]||(g[0]=f=>o("open-settings"))},[fe(a(Ya),{class:"h-4 w-4"}),i("span",{class:be(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},x(a(s)("workbench.settings")),3)],8,Th)]),i("button",{type:"button",class:"tool-button tool-button-primary mt-4 inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:e.creatingTask||e.uploading,title:e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask"),onClick:g[1]||(g[1]=f=>o("create-task"))},[fe(a(Rs),{class:"h-4 w-4"}),i("span",Eh,x(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,Ch)]),i("div",Ah,[e.loadingTasks&&!e.tasks.length?(m(),b("div",$h,x(a(s)("workbench.loadingTasks")),1)):(m(),Ee(a(Ja),{key:1,modelValue:r.value,"onUpdate:modelValue":g[8]||(g[8]=f=>r.value=f),class:"space-y-2",animation:180,disabled:e.mobile||e.tasks.length<=1,handle:".task-drag-handle","ghost-class":"workbench-task-card--ghost","chosen-class":"workbench-task-card--chosen","drag-class":"workbench-task-card--dragging","fallback-tolerance":"6",onEnd:y},{default:st(()=>[(m(!0),b(lt,null,pt(r.value,f=>{var P,ee;return m(),b("article",{key:f.slug,class:be(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(f)]),onClick:S=>o("select-task",f.slug)},[f.slug===e.currentTaskSlug?(m(),b("span",Ph)):me("",!0),f.hasUnreadUpdate?(m(),b("span",Dh)):me("",!0),i("div",Lh,[i("div",Mh,[e.mobile?me("",!0):(m(),b("button",{key:0,type:"button",class:"task-drag-handle mt-0.5 inline-flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm opacity-45 transition hover:opacity-80 active:cursor-grabbing",title:a(s)("workbench.dragToReorder"),"aria-label":a(s)("workbench.dragToReorder"),tabindex:"-1",onClick:g[2]||(g[2]=ot(()=>{},["stop"]))},[fe(a(Qa),{class:"h-3.5 w-3.5"})],8,Bh)),i("div",Rh,[f.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===f.slug?(m(),b("input",{key:0,value:e.draftTitle,type:"text",maxlength:"140","data-task-title-input":"current",class:"block h-5 min-h-0 w-full appearance-none border-0 bg-transparent p-0 text-left text-sm font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(s)("workbench.untitledTask"),onClick:g[3]||(g[3]=ot(()=>{},["stop"])),onInput:g[4]||(g[4]=S=>o("update:draftTitle",S.target.value)),onKeydown:[g[5]||(g[5]=Qt(ot(S=>S.target.blur(),["prevent"]),["enter"])),g[6]||(g[6]=Qt(ot(S=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:g[7]||(g[7]=S=>o("title-blur"))},null,40,Nh)):(m(),b("button",{key:1,type:"button",class:be(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",f.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:f.displayTitle,onClick:ot(S=>o("title-click",f.slug),["stop"])},[(P=f.automation)!=null&&P.enabled?(m(),Ee(a(Bs),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):me("",!0),i("span",Fh,x(f.displayTitle),1)],10,Oh))])]),i("div",Uh,[f.sending?(m(),b("span",{key:0,class:be(["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,x(a(s)("workbench.running")),1)],2)):me("",!0)])]),i("div",jh,x(f.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Vh,[i("div",zh,x(p(f)),1),i("div",Hh,[w(f)?(m(),b("span",{key:0,class:be(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",c(f)])},[i("span",null,x(a(s)("workbench.filesCount",{count:((ee=f.workspaceDiffSummary)==null?void 0:ee.fileCount)||0})),1)],2)):me("",!0)])])],10,Ih)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",qh,[e.error?(m(),b("div",Kh,[fe(a(Ao),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",Wh,x(e.error),1)])):me("",!0),i("div",Gh,[i("button",{type:"button",class:"tool-button inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask,title:a(s)("workbench.editTask"),onClick:g[9]||(g[9]=f=>o("edit-task"))},[fe(a(is),{class:"h-4 w-4"}),i("span",Yh,x(a(s)("workbench.editTask")),1)],8,Xh),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask||e.isCurrentTaskSending,title:e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask"),onClick:g[10]||(g[10]=f=>o("delete-task"))},[fe(a(Ks),{class:"h-4 w-4"}),i("span",Qh,x(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,Jh)])])]))}},Sr=Cr(Zh,[["__scopeId","data-v-5203468b"]]),ev={class:"min-w-0"},tv={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},nv={class:"theme-muted-text mt-1 text-xs leading-5"},sv={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},ov={class:"theme-muted-text"},rv={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},av={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},iv={class:"space-y-3"},lv={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},uv={class:"min-w-0 flex-1"},cv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},dv={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},fv={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},pv={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},mv={class:"rounded-sm border border-dashed px-2 py-1"},gv={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},hv={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},vv={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},yv={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},Sv=["onClick"],wv=["onClick"],xv={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},bv={__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}=_t(),r=K(()=>(n.items||[]).map(u=>{var f;const p=Array.isArray(u==null?void 0:u.blocks)?u.blocks:[],w=((f=p.find(P=>["text","imported_text"].includes(String((P==null?void 0:P.type)||""))&&String((P==null?void 0:P.content)||"").trim()))==null?void 0:f.content)||"",c=String(w||"").replace(/\s+/g," ").trim().slice(0,120),y=p.filter(P=>String((P==null?void 0:P.type)||"")==="image").length,h=p.filter(P=>String((P==null?void 0:P.type)||"")==="imported_text").length,g=p.filter(P=>String((P==null?void 0:P.type)||"")==="text"&&String((P==null?void 0:P.content)||"").trim()).length;return{...u,blockCount:p.length,imageCount:y,importedCount:h,preview:c||(y?s("todoDialog.imagePreview",{count:y}):s("todoDialog.noPreview")),textCount:g,timeLabel:l(u==null?void 0:u.createdAt)}}));function l(u=""){const p=Date.parse(String(u||""));if(!p)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(p))}catch{return String(u||"")}}return(u,p)=>(m(),Ee(Ws,{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:p[0]||(p[0]=w=>o("close"))},{title:st(()=>[i("div",ev,[i("div",tv,[fe(a(Dr),{class:"h-4 w-4"}),i("span",null,x(a(s)("todoDialog.title")),1)]),i("p",nv,x(a(s)("todoDialog.intro")),1)])]),default:st(()=>[i("div",sv,[i("span",ov,x(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",rv,x(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(m(),b("div",av,[i("div",iv,[(m(!0),b(lt,null,pt(r.value,w=>(m(),b("article",{key:w.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",lv,[i("div",uv,[i("div",cv,[i("span",null,x(a(s)("todoDialog.itemTitle")),1),i("span",dv,[fe(a(Bs),{class:"h-3.5 w-3.5"}),gn(" "+x(w.timeLabel),1)])]),i("p",fv,x(w.preview),1),i("div",pv,[i("span",mv,x(a(s)("todoDialog.blockCount",{count:w.blockCount})),1),w.textCount?(m(),b("span",gv,[fe(a(Ns),{class:"h-3.5 w-3.5"}),gn(" "+x(a(s)("todoDialog.textCount",{count:w.textCount})),1)])):me("",!0),w.importedCount?(m(),b("span",hv,[fe(a(Ns),{class:"h-3.5 w-3.5"}),gn(" "+x(a(s)("todoDialog.importedCount",{count:w.importedCount})),1)])):me("",!0),w.imageCount?(m(),b("span",vv,[fe(a(Lr),{class:"h-3.5 w-3.5"}),gn(" "+x(a(s)("todoDialog.imageCount",{count:w.imageCount})),1)])):me("",!0)])]),i("div",yv,[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",w.id)},[fe(a(Za),{class:"h-4 w-4"}),i("span",null,x(a(s)("todoDialog.use")),1)],8,Sv),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",w.id)},[fe(a(Ks),{class:"h-4 w-4"}),i("span",null,x(a(s)("todoDialog.delete")),1)],8,wv)])])]))),128))])])):(m(),b("div",xv,x(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},kv={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},_v={__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"?Ao:s==="error"?ei:s==="info"?ti:ni}return(s,r)=>(m(),Ee(fs,{to:"body"},[i("div",kv,[fe(Ar,{"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:st(()=>[e.message?(m(),b("div",{key:0,class:be(["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)])},[(m(),Ee(yn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,x(e.message),1)],2)):me("",!0)]),_:1})])]))}};function Tv(e,t=!1){const n=F(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return cn(()=>{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))}),Mt(()=>{s()}),{matches:n}}const Cv="(max-width: 1023px)",Ls="promptxWorkbenchMobileView";function ho(e){return(e==null?void 0:e[Ls])==="detail"}function Ev({currentTaskSlug:e}){const{matches:t}=Tv(Cv),n=F("tasks"),o=F("activity");function s(y="tasks"){if(typeof window>"u")return;const h={...window.history.state||{}};y==="detail"?h[Ls]="detail":delete h[Ls],window.history.replaceState(h,"")}function r(){if(typeof window>"u")return;const y={...window.history.state||{},[Ls]:"detail"};window.history.pushState(y,"")}function l(y=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=ho(y)?"detail":"tasks"}function u(y){t.value=!!y,l(typeof window>"u"?null:window.history.state)}function p(y={}){const{pushHistory:h=!0}=y;if(n.value="detail",!!t.value){if(h){r();return}s("detail")}}function w(y={}){const{useHistory:h=!0}=y;if(!t.value){n.value="tasks";return}if(h&&typeof window<"u"&&ho(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function c(y){t.value&&(n.value=ho(y.state)&&e.value?"detail":"tasks")}return cn(()=>{typeof window>"u"||window.addEventListener("popstate",c)}),Mt(()=>{typeof window<"u"&&window.removeEventListener("popstate",c)}),Pe(t,y=>{u(y)},{immediate:!0}),Pe(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:p,isMobileLayout:t,leaveMobileDetail:w,mobileDetailTab:o,mobileView:n}}const js="PromptX";function Av(e=""){const t=String(a(e)||"").trim();return t?`${js} (${t})`:js}function $v(e="",t={}){Ma(()=>{if(typeof document>"u")return;const o=String(a(e)||"").trim();document.title=a(t.raw)?o||js:Av(o)}),Mt(()=>{typeof document>"u"||(document.title=js)})}const qn="success";function Iv(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||qn).trim()||qn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:qn,duration:t}}function Pv(e=2200){const t=F(""),n=F(qn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=qn}function r(l,u=e){const p=Iv(l,u);if(!p.message){s();return}t.value=p.message,n.value=p.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=qn,o=null},p.duration)}return Mt(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function Dv(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 Lv(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 Mv(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===Lt.TEXT||s.type===Lt.IMPORTED_TEXT){const r=Lv(s.content);r&&n.push(r,"");continue}if(s.type===Lt.IMAGE){const r=Dv(s.content,t);r&&n.push(r,"")}}return n.join(`
54
+ `).trim()}function Bv(e,t){return Mv(e,t)}const To="promptx:active-task-slug",Rv=150,Nv=1500,Vs=500,Ov=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function zs(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 vn(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:vn((t==null?void 0:t.blocks)||[])}))}function wr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:vn(e.blocks||[]),todoItems:jt(e.todoItems||[])}}function _a(e=[]){return vn(e).filter(t=>(t==null?void 0:t.type)===Lt.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function Fv(e=[]){return _a(e).length>0}function Uv(){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 xr(){return vn([{type:Lt.TEXT,content:"",meta:{}}])}function Co(e=[],t=16){return bi(e,t)||""}function jv(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 br(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=Co(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):Ye("workbench.untitledTask")}function Hs(e={}){return!!(e!=null&&e.running)}function Vv(e={},t=!1){return t&&!Hs(e)?"sending":Hs(e)?"running":"idle"}function zv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Hv(e=""){return Ov.has(String(e||"").trim())}function Ta(e="",t="",n=!1){const o=String(e||"").trim();return!!(o&&o===String(t||"").trim()&&n)}function qv(e={},t="",n={}){const o=String(t||"").trim();return!o||Ta(o,n.currentTaskSlug,n.pageFocused)?{unreadMap:e,didMark:!1}:e!=null&&e[o]?{unreadMap:e,didMark:!1}:{unreadMap:{...e||{},[o]:!0},didMark:!0}}function Ca(e={},t=""){const n=String(t||"").trim();if(!n||!(e!=null&&e[n]))return e;const o={...e||{}};return delete o[n],o}function Kv(e={},t={}){return t.pageFocused?Ca(e,t.currentTaskSlug):e}function Wv(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 Ea(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 Aa(e={},t=Vs){const n=Math.max(1,Number(t)||Vs),o=Object.entries(e||{});return o.length<=n?e:Object.fromEntries(o.slice(-n))}function Gv(e={},t=[],n=Vs){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=Ea(l);u.taskSlug&&o.has(u.taskSlug)&&(s[r]=u)}),Aa(s,n)}function Xv(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||!Hv(s))return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!1};if(Ea(l[o]).status===s)return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!0};const p=Aa({...l,[o]:{taskSlug:t,status:s}},e.maxNotifiedRuns),w=qv(r,t,{currentTaskSlug:e.currentTaskSlug,pageFocused:e.pageFocused});return{unreadMap:w.unreadMap,notifiedMap:p,didMark:w.didMark,didDedupe:!1}}function kr(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function Yv(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 p=String((u==null?void 0:u.slug)||"").trim();return p?[p,u]:null}).filter(Boolean)),r=o.map(u=>s.get(u)||null).filter(Boolean),l=n.filter(u=>{const p=String((u==null?void 0:u.slug)||"").trim();return p&&!o.includes(p)});return[...r,...l]}function _r(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:zs(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const u=n.get(r),p=String((u==null?void 0:u.codexSessionId)||"").trim();return p&&p===l?{...s,workspaceDiffSummary:zs(u.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function Jv(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 p=String((r==null?void 0:r.codexSessionId)||"").trim(),w=String((u==null?void 0:u.codexSessionId)||"").trim();return!!(p!==w||!!(r!=null&&r.running)!=!!(u!=null&&u.running)||p&&!Object.prototype.hasOwnProperty.call(u||{},"workspaceDiffSummary")||p&&(u==null?void 0:u.workspaceDiffSummary)==null)})}function ks(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(To,t);return}window.localStorage.removeItem(To)}function Qv(){return typeof window>"u"?"":String(window.localStorage.getItem(To)||"").trim()}function Zv(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function ey(){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 On(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=zs(e.workspaceDiffSummary)),t}function ty(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Mo(),r=la(),l=F(null),u=F([]),p=F({}),w=F({}),c=F({}),y=F({}),h=F({}),g=F(""),f=F({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),P=F(!0),ee=F(!1),S=F(!1),D=F(!1),j=F(!1),G=F(!1),M=F(""),J=F(!1),A=F("");let X=null,ue=null,pe=0,E=null,Z=0,ce=null,ie=0,ve={};const T=K(()=>Co(f.value.blocks)),U=K(()=>br({title:f.value.title,autoTitle:f.value.autoTitle,preview:jv(f.value.blocks)},f.value.blocks));function O(k,_={}){const q=String(k||"").trim();if(!q)return"";const re=_.summary||et(q),oe=_.cachedDraft===void 0?Ne(q):_.cachedDraft,Se=q===g.value;return Object.prototype.hasOwnProperty.call(w.value,q)?String(w.value[q]||"").trim():Se?String(f.value.codexSessionId||(re==null?void 0:re.codexSessionId)||"").trim():String((oe==null?void 0:oe.codexSessionId)||(re==null?void 0:re.codexSessionId)||"").trim()}const He=K(()=>O(g.value)),De=K(()=>Vv(et(g.value),c.value[g.value])),je=K(()=>De.value!=="idle"),We=K(()=>u.value.some(k=>Hs(k))||Object.values(c.value).some(Boolean)),Ge=K(()=>Object.values(y.value).some(Boolean)),ut=F(0),Te=K(()=>Fv(f.value.blocks)),V=K(()=>jt(f.value.todoItems)),te=K(()=>U.value||Ye("workbench.untitledTask")),he=K(()=>u.value.map(k=>ct(k)));function Ae(k=""){return!k||!k.startsWith(s)?k:k.slice(s.length)}function se(k=""){const _=String(k||"").replace(/\r\n/g,`
55
+ `).split(`
56
+ `);for(;_.length&&!String(_[0]||"").trim();)_.shift();for(;_.length&&!String(_[_.length-1]||"").trim();)_.pop();return _.join(`
57
+ `)}function _e(k=[]){return k.map(_=>({id:Number.isInteger(Number(_==null?void 0:_.id))?Number(_.id):null,type:_==null?void 0:_.type,content:(_==null?void 0:_.type)==="image"?Ae(_.content):se(_.content),meta:_!=null&&_.meta?{..._.meta}:{}}))}function $e(k=[]){return(k||[]).map(_=>({id:String((_==null?void 0:_.id)||"").trim(),createdAt:String((_==null?void 0:_.createdAt)||""),blocks:_e((_==null?void 0:_.blocks)||[])}))}function Le(k=f.value.title,_=f.value.autoTitle,q=f.value.lastPromptPreview,re=f.value.todoItems,oe=f.value.codexSessionId,Se=f.value.blocks){return JSON.stringify({title:String(k||""),autoTitle:String(_||""),lastPromptPreview:String(q||""),todoItems:$e(re),codexSessionId:String(oe||""),blocks:_e(Se)})}function at(){return Le()!==A.value}function Me(){var k,_;return!!((_=(k=l.value)==null?void 0:k.isEditing)!=null&&_.call(k))}function et(k){return u.value.find(_=>_.slug===k)||null}function Ne(k){return k&&p.value[k]||null}function Je(k,_=""){const q=String(k||"").trim();q&&(ve={...ve,[q]:String(_||"").trim()})}function Ie(k=""){var oe;const _=String(k||"").trim();if(!_)return!1;const q=String(((oe=et(_))==null?void 0:oe.updatedAt)||"").trim(),re=String(ve[_]||"").trim();return!!(q&&re&&q===re)}function ct(k){const _=Ne(k.slug),q=k.slug===g.value?f.value.blocks:(_==null?void 0:_.blocks)||[],re=k.slug===g.value?f.value.title:(_==null?void 0:_.title)??k.title,oe=k.slug===g.value?f.value.autoTitle:(_==null?void 0:_.autoTitle)??k.autoTitle,Se=k.slug===g.value?jt(f.value.todoItems).length:jt((_==null?void 0:_.todoItems)||[]).length||Number(k.todoCount||0),ht=k.slug===g.value?f.value.lastPromptPreview||k.lastPromptPreview||"":(_==null?void 0:_.lastPromptPreview)||k.lastPromptPreview||"",Fe=O(k.slug,{summary:k,cachedDraft:_});return{...k,title:re,autoTitle:oe,todoCount:Se,preview:ht,codexSessionId:Fe,sessionSelectionLocked:!!(Fe&&Number(k.codexRunCount||0)>0),sessionSelectionLockReason:Fe&&Number(k.codexRunCount||0)>0?Ye("taskActions.sessionLocked"):"",displayTitle:br({title:re,autoTitle:oe,preview:ht},q),sending:Hs(k),hasUnreadUpdate:!!y.value[k.slug]}}function it(k,_={}){const{insertAtStart:q=!1}=_;if(!(k!=null&&k.slug))return;const re=[...u.value],oe=re.findIndex(Se=>Se.slug===k.slug);if(oe>=0){re.splice(oe,1,{...re[oe],...k}),u.value=re;return}q?re.unshift(k):re.push(k),u.value=re}function Xe(k,_){k&&(p.value={...p.value,[k]:wr(_)})}function Pt(k){return k?`${s}/api/tasks/${k}/raw`:`${s}/api/tasks/`}function At(k=""){const _=String(k||"").trim();if(!_)return;const q=et(_),re=r.getTaskRunChange(_);if(!q||!(re!=null&&re.status))return;const oe=zv(re.status);!!q.running!==oe&&it({...q,running:oe})}function C(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function N(k=""){return Ta(k,g.value,C())}function ne(k=""){y.value=Ca(y.value,k)}function we(){y.value=Kv(y.value,{currentTaskSlug:g.value,pageFocused:C()})}function Oe(k=[]){y.value=Wv(y.value,k),h.value=Gv(h.value,k)}function Re(k=""){const _=String(k||"").trim();if(!_)return;const q=Xv({unreadMap:y.value,notifiedMap:h.value,taskSlug:_,change:r.getTaskRunChange(_),currentTaskSlug:g.value,pageFocused:C(),maxNotifiedRuns:Vs});y.value=q.unreadMap,h.value=q.notifiedMap,q.didMark&&(ut.value+=1)}function Qe(k,_){c.value={...c.value,[k]:!!_}}function Ze(k=u.value){const _={};(k||[]).forEach(q=>{q!=null&&q.slug&&(_[q.slug]=!!q.running)}),c.value=_}function tt(k,_){k&&(w.value={...w.value,[k]:String(_||"").trim()})}async function Tt(k,_){const q=String(k||"").trim();if(!q)return;const re=String(_||"").trim(),oe=et(q),Se=w.value[q]||(oe==null?void 0:oe.codexSessionId)||"";if(!!(Se&&Number((oe==null?void 0:oe.codexRunCount)||0)>0)&&re!==Se){M.value=Ye("taskActions.sessionLocked");return}tt(q,re);const Fe=Ne(q);Fe&&Xe(q,{...Fe,codexSessionId:re}),oe&&it({...oe,codexSessionId:re,workspaceDiffSummary:re&&re===Se?oe.workspaceDiffSummary:null}),q===g.value&&(f.value={...f.value,codexSessionId:re});try{await cl(q,re)}catch(en){tt(q,Se),Fe&&Xe(q,{...Fe,codexSessionId:Se}),oe&&it({...oe,codexSessionId:Se}),q===g.value&&(f.value={...f.value,codexSessionId:Se}),M.value=en.message}}function $t(){X&&(window.clearTimeout(X),X=null)}function St(){E&&(window.clearTimeout(E),E=null)}function Ht(){$t(),!(ee.value||!g.value)&&(X=window.setTimeout(()=>{ge({auto:!0,silent:!0})},1500))}function Dt(){if(!g.value)return;const k=et(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};it({...k,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:jt(f.value.todoItems).length,codexSessionId:He.value,preview:String(f.value.lastPromptPreview||"")})}function le(k={}){const _=String((k==null?void 0:k.slug)||"").trim();if(!_)return;const q=On(k);it(q),Je(_,q.updatedAt||k.updatedAt||""),_===g.value&&(Object.prototype.hasOwnProperty.call(k,"title")&&(f.value.title=String(k.title||"")),Object.prototype.hasOwnProperty.call(k,"autoTitle")&&(f.value.autoTitle=String(k.autoTitle||"")),Xe(_,{...f.value}))}function Be(k=[]){const _=new Map((k||[]).map(q=>{const re=String((q==null?void 0:q.slug)||"").trim();return re?[re,zs(q.workspaceDiffSummary)]:null}).filter(Boolean));_.size&&(u.value=u.value.map(q=>_.has(q.slug)?{...q,workspaceDiffSummary:_.get(q.slug)}:q))}async function qe(k=u.value){const _=Array.isArray(k)?k:[],q=_.filter(oe=>String((oe==null?void 0:oe.codexSessionId)||"").trim()),re=++Z;if(!q.length){u.value=_.map(oe=>Object.prototype.hasOwnProperty.call(oe,"workspaceDiffSummary")?oe:{...oe,workspaceDiffSummary:null});return}try{const oe=await Gi(_.length||30);if(re!==Z)return;Be(oe.items||[])}catch{}}async function xt(k={}){const{silent:_=!1}=k;_||(P.value=!0,M.value="");try{const q=u.value,re=await Wi(),oe=_r(q,(re.items||[]).map(On));u.value=oe,Oe(oe),Ze(oe),Jv(q,oe)&&qe(oe)}catch(q){_||(M.value=q.message)}finally{_||(P.value=!1)}}async function Bt(k=[]){const _=Yv(u.value,k),q=u.value.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean),re=_.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean);if(!re.length||re.join(",")===q.join(","))return!1;const oe=u.value;u.value=_;try{const Se=await Yi(re);ie=Date.now()+Nv;const ht=_r(oe,(Se.items||[]).map(On));return u.value=ht,Oe(ht),Ze(ht),!0}catch(Se){return u.value=oe,M.value=Se.message,!1}}async function Vt(k=""){const _=String(g.value||"").trim(),q=String(k||"").trim();if(!_)return;if(!u.value.some(oe=>oe.slug===_)){if(u.value.length){await de(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",ks(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Le("","","",[],"",[]),J.value=!1;return}q&&q!==_||q&&(Me()||at()||J.value||j.value||G.value||ee.value||await de(_,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function z(k=""){const _=String(k||"").trim();ce===null?ce=_:ce!==_&&(ce=""),!E&&(E=window.setTimeout(async()=>{const q=ce;ce=null,E=null,await xt({silent:!0}),await Vt(q||"")},Rv))}async function Y(k){const _=await Or(k),q=(_.blocks||[]).map(oe=>({...oe,content:oe.type==="image"?Cs(oe.content):oe.content}));return{state:{title:String(_.title||""),autoTitle:String(_.autoTitle||""),lastPromptPreview:String(_.lastPromptPreview||""),codexSessionId:String(_.codexSessionId||""),blocks:q,todoItems:jt(_.todoItems||[])},summary:On({..._,blocks:q}),updatedAt:String(_.updatedAt||"")}}async function de(k,_={}){const{focusEditor:q=!1,force:re=!1,skipIfDirtyOnApply:oe=!1,skipIfEditingOnApply:Se=!1,scrollPanelToBottom:ht=!1}=_,Fe=String(k||"").trim();if(!Fe)return!1;const en=++pe;ee.value=!0,M.value="",t();try{const Wt=String(g.value||"").trim(),Dn=Ne(Fe),Ln=re&&Dn&&Ie(Fe);let on=re&&!Ln?null:Dn,Ut=null;if(!on){const vt=await Y(Fe);on=(vt==null?void 0:vt.state)||null,Ut=(vt==null?void 0:vt.summary)||null,Je(Fe,(vt==null?void 0:vt.updatedAt)||(Ut==null?void 0:Ut.updatedAt)||"")}return en!==pe||oe&&Fe===g.value&&(at()||J.value)||Se&&Fe===g.value&&Me()?!1:(g.value=Fe,ks(Fe),N(Fe)&&ne(Fe),f.value=wr(on),Xe(Fe,on),Ut&&it(Ut),tt(Fe,on.codexSessionId),A.value=Le(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),J.value=!1,q&&ft(()=>{var vt,pn;return(pn=(vt=l.value)==null?void 0:vt.focusEditor)==null?void 0:pn.call(vt)}),(ht||Fe!==Wt)&&o(),!0)}catch(Wt){return en===pe&&(M.value=Wt.message),!1}finally{en===pe&&(ee.value=!1)}}async function ge(k={}){const{auto:_=!1,silent:q=!1}=k;return g.value?Le()===A.value?!0:ue||($t(),j.value=!0,M.value="",ue=(async()=>{try{const oe=await Fr(g.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:jt(f.value.todoItems),codexSessionId:He.value,expiry:"none",visibility:"private",blocks:_e(f.value.blocks)}),Se={title:String(oe.title||""),autoTitle:String(oe.autoTitle||""),lastPromptPreview:String(oe.lastPromptPreview||""),todoItems:jt(oe.todoItems||f.value.todoItems||[]),codexSessionId:He.value||String(oe.codexSessionId||"").trim(),blocks:vn(f.value.blocks)};return Xe(g.value,Se),A.value=Le(Se.title,Se.autoTitle,Se.lastPromptPreview,Se.todoItems,Se.codexSessionId,Se.blocks),J.value=!1,it(On(oe)),Je(g.value,oe.updatedAt||""),!_&&!q&&n({message:Ye("taskActions.taskSaved"),type:"success"}),!0}catch(oe){return M.value=oe.message,!1}finally{j.value=!1,ue=null,Le()!==A.value&&(J.value=!0,Ht())}})(),ue):!1}async function Ve(){return G.value?(M.value=Ye("taskActions.fileProcessing"),!1):ue||(J.value?ge({auto:!1,silent:!0}):!0)}async function Ct(){if(!await Ve()&&g.value)return!1;S.value=!0,M.value="";try{const k=await Xi({title:"",expiry:"none",visibility:"private"}),_={title:String(k.title||""),autoTitle:String(k.autoTitle||""),lastPromptPreview:String(k.lastPromptPreview||""),codexSessionId:String(k.codexSessionId||""),blocks:vn(k.blocks||[]),todoItems:jt(k.todoItems||[])};return Xe(k.slug,_),it(On(k),{insertAtStart:!0}),await de(k.slug,{focusEditor:!0}),n({message:Ye("taskActions.taskCreated"),type:"success"}),!0}catch(k){return M.value=k.message,!1}finally{S.value=!1}}async function Zt(k){const _=String(k||"").trim();!_||_===g.value||!await Ve()||await de(_)}async function mt(){if(g.value){D.value=!0,M.value="";try{const k=g.value;await Ji(k),u.value=u.value.filter(oe=>oe.slug!==k);const _={...p.value};delete _[k],p.value=_;const q={...w.value};delete q[k],w.value=q;const re={...c.value};delete re[k],c.value=re,ne(k),u.value.length?await de(u.value[0].slug,{focusEditor:!0}):(g.value="",ks(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Le("","","",[],"",[]),J.value=!1,await Ct())}catch(k){M.value=k.message}finally{D.value=!1}}}function Ft(k={}){const{silent:_=!1}=k;g.value&&(f.value={...f.value,blocks:xr()},Xe(g.value,f.value),Dt(),J.value=!0,ft(()=>{var q,re;(re=(q=l.value)==null?void 0:q.focusEditor)==null||re.call(q)}),_||n({message:Ye("taskActions.taskCleared"),type:"info"}))}function bt(){if(!g.value)return!1;const k=_a(f.value.blocks);return k.length?(f.value={...f.value,blocks:xr(),todoItems:[{id:Uv(),createdAt:new Date().toISOString(),blocks:k},...jt(f.value.todoItems)]},Xe(g.value,f.value),Dt(),J.value=!0,ft(()=>{var _,q;(q=(_=l.value)==null?void 0:_.focusEditor)==null||q.call(_)}),n({message:Ye("taskActions.todoAdded"),type:"success"}),!0):!1}function sn(k=""){const _=String(k||"").trim();if(!g.value||!_)return!1;const q=jt(f.value.todoItems).filter(re=>re.id!==_);return q.length===jt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:q},Xe(g.value,f.value),Dt(),J.value=!0,!0)}function dn(k=""){const _=String(k||"").trim();if(!g.value||!_)return null;const q=jt(f.value.todoItems).find(re=>re.id===_);return q?(f.value={...f.value,blocks:vn(q.blocks),todoItems:jt(f.value.todoItems).filter(re=>re.id!==_)},Xe(g.value,f.value),Dt(),J.value=!0,ft(()=>{var re,oe;(oe=(re=l.value)==null?void 0:re.focusEditor)==null||oe.call(re)}),q):null}async function fn(){var oe;if(await xt(),!u.value.length){await Ct();return}const k=Zv();if(k){const Se=await de(k,{focusEditor:!0,force:!0});if(ey(),Se)return}const _=((oe=u.value.find(Se=>!!(Se!=null&&Se.running)))==null?void 0:oe.slug)||"",q=Qv(),re=_||(u.value.some(Se=>Se.slug===q)?q:u.value[0].slug);await de(re,{focusEditor:!0,force:!0})}async function qt(k){var _,q,re;G.value=!0,M.value="";try{const oe=((q=(_=l.value)==null?void 0:_.isImportedBlockActive)==null?void 0:q.call(_))||!1,Se=[];for(const ht of k){const Fe=await Qi(ht);Se.push({type:"image",content:Cs(Fe.url),meta:{}})}(re=l.value)==null||re.insertUploadedBlocks(Se),n({message:Ye("taskActions.imageInserted",{count:Se.length,appended:oe}),type:"success"})}catch(oe){M.value=oe.message}finally{G.value=!1}}async function Kt(k){var _,q,re;M.value="";try{const oe=((q=(_=l.value)==null?void 0:_.isImportedBlockActive)==null?void 0:q.call(_))||!1,Se=[];for(const ht of k){const Fe=await ht.text();Fe.trim()&&Se.push({type:"imported_text",content:Fe,meta:{fileName:ht.name||Ye("workbench.untitledTask"),collapsed:!0}})}if(!Se.length){n({message:Ye("taskActions.noTextImported"),type:"warning"});return}(re=l.value)==null||re.insertImportedBlocks(Se),n({message:Ye("taskActions.importedBlocksInserted",{count:Se.length,appended:oe}),type:"success"})}catch{M.value=Ye("taskActions.textImportFailed")}}async function It(k){var _;G.value=!0,M.value="";try{let q=0,re=0;for(const oe of k){const Se=await Zi(oe),ht=(Se.blocks||[]).map(Fe=>({...Fe,content:Fe.type==="image"?Cs(Fe.content):Fe.content}));ht.length&&((_=l.value)==null||_.insertBlocks(ht),q+=ht.length,re+=Number(Se.pageCount||0))}if(!q){n({message:Ye("taskActions.noPdfContent"),type:"warning"});return}n({message:Ye("taskActions.pdfBlocksInserted",{blockCount:q,pageCount:re}),type:"success"})}catch(q){M.value=q.message||Ye("taskActions.pdfImportFailed")}finally{G.value=!1}}function $(k){const _=k===g.value?f.value:Ne(k);return _?Bv({title:String(_.title||""),blocks:_e(_.blocks||[])},Pt(k)):""}function Q(k){const _=k===g.value?f.value:Ne(k);return _?vn(_e(_.blocks||[])):[]}async function H(k){return G.value?(M.value=Ye("taskActions.fileProcessingBeforeSend"),!1):k!==g.value?!0:j.value&&ue?ue:J.value?ge({auto:!1,silent:!0}):!0}async function Ce(k){return await H(k)?$(k):""}function Xt(k,_){const q=kr(_);!q||k!==g.value||(f.value.lastPromptPreview=q,Xe(g.value,f.value),Dt())}return Pe(f,()=>{if(ee.value||!g.value)return;const k=Co(f.value.blocks);!String(f.value.title||"").trim()&&k&&k!==f.value.autoTitle&&(f.value.autoTitle=k),Xe(g.value,f.value),J.value=Le()!==A.value,Dt(),J.value&&!j.value&&Ht()},{deep:!0}),Pe(g,k=>{k&&(ks(k),we())}),cn(()=>{typeof window>"u"||(window.addEventListener("focus",we),document.addEventListener("visibilitychange",we))}),Mt(()=>{$t(),St(),typeof window<"u"&&(window.removeEventListener("focus",we),document.removeEventListener("visibilitychange",we))}),Pe(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<ie||(Re(r.listSyncTaskSlug.value),At(r.listSyncTaskSlug.value),z(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:bt,applyTaskSettingsUpdate:le,buildPromptForTask:$,getPromptBlocksForTask:Q,buildPromptPreview:kr,clearCurrentTaskContent:Ft,createTaskAndSelect:Ct,currentProjectSessionId:He,currentTaskSendState:De,currentTaskAutoTitle:T,currentTaskDisplayTitle:U,currentTaskSlug:g,draft:f,editorRef:l,error:M,handleImportPdfFiles:It,handleImportTextFiles:Kt,handleTaskSendingChange:Qe,handleTaskSessionChange:Tt,handleUpload:qt,hasCurrentDraftContent:Te,hasAnyTaskSending:We,hasUnsavedChanges:J,hasUnreadTaskUpdates:Ge,initializeWorkbench:fn,isCurrentTaskSending:je,loadingTask:ee,loadingTasks:P,pageTitle:te,prepareCodexPromptForTask:Ce,currentTodoItems:V,removeTodoItem:sn,removeCurrentTask:mt,reorderTaskList:Bt,removingTask:D,renderedTasks:he,refreshTaskList:xt,saveTask:ge,saving:j,selectTask:Zt,selectedSessionMap:w,sendingTaskMap:c,taskDraftMap:p,tasks:u,unreadNotificationVersion:ut,useTodoItem:dn,updateLastPromptPreview:Xt,uploading:G,creatingTask:S}}const ny={class:"flex h-full min-h-0 flex-col overflow-hidden"},sy={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"},oy={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},ry={class:"min-h-0 min-w-0 overflow-hidden"},ay={class:"min-h-0 min-w-0 overflow-hidden"},iy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},ly={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},uy={class:"flex flex-col gap-2"},cy={class:"min-h-0 flex-1 overflow-hidden"},dy={key:1,class:"min-h-0 flex-1 overflow-hidden"},fy={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},py={class:"workbench-mobile-tabs-panel shrink-0"},my={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},gy={class:"min-h-0 flex-1 overflow-hidden"},hy={class:"h-full min-h-0"},vy={class:"h-full min-h-0"},yy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Sy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},wy={class:"flex flex-col gap-2"},xy={class:"min-h-0 flex-1 overflow-hidden"},by="/sounds/notify-didi.wav?v=20260420-1",ky=3e3,_y={__name:"WorkbenchView",setup(e){const t=F(!1),n=F(!1),o=F(!1),s=F(!1),r=F(!1),l=F(!1),u=F(!1),p=F(!1),w=F(""),c=F(""),y=F(""),h=F(0),g=F("workspace"),f=F(""),{t:P}=_t(),{toastMessage:ee,toastType:S,flashToast:D,clearToast:j}=Pv(),{notificationSoundEnabled:G,sendBehavior:M}=Ia(),J=vo(()=>Ke(()=>import("./TaskDiffReviewDialog-2giXkyWK.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),A=vo(()=>Ke(()=>import("./WorkbenchSettingsDialog-BgRcnWAa.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),X=F(null),ue=F([]),pe=F({});let E=null,Z=!1,ce=0;function ie(v="",W=ue.value){const ye=String(v||"").trim();return ye&&W.some(xe=>(xe==null?void 0:xe.engine)===ye)?ye:""}function ve(v=ue.value){var W,ye;return((W=v.find(xe=>xe==null?void 0:xe.isDefault))==null?void 0:W.engine)||((ye=v[0])==null?void 0:ye.engine)||""}const T=K({get(){const v=String(V.value||"").trim();return v?ie(pe.value[v])||ve():""},set(v){const W=String(V.value||"").trim(),ye=ie(v);!W||!ye||(pe.value={...pe.value,[W]:ye})}});function U(v){return v?X.value:null}function O(){ft(()=>{var v,W;(W=(v=U(se.value))==null?void 0:v.scrollToBottom)==null||W.call(v)})}const{addCurrentDraftToTodo:He,applyTaskSettingsUpdate:De,buildPromptForTask:je,getPromptBlocksForTask:We,clearCurrentTaskContent:Ge,createTaskAndSelect:ut,creatingTask:Te,currentProjectSessionId:V,currentTaskSendState:te,currentTaskAutoTitle:he,currentTaskDisplayTitle:Ae,currentTaskSlug:se,draft:_e,editorRef:$e,error:Le,handleImportPdfFiles:at,handleImportTextFiles:Me,handleTaskSendingChange:et,handleTaskSessionChange:Ne,handleUpload:Je,hasCurrentDraftContent:Ie,hasUnsavedChanges:ct,hasUnreadTaskUpdates:it,initializeWorkbench:Xe,isCurrentTaskSending:Pt,loadingTask:At,loadingTasks:C,pageTitle:N,prepareCodexPromptForTask:ne,currentTodoItems:we,removeTodoItem:Oe,removeCurrentTask:Re,reorderTaskList:Qe,removingTask:Ze,renderedTasks:tt,saveTask:Tt,saving:$t,selectTask:St,unreadNotificationVersion:Ht,updateLastPromptPreview:Dt,useTodoItem:le,uploading:Be}=ty({clearToast:j,flashToast:D,scrollCurrentPanelToBottom:O}),qe=K(()=>tt.value.find(v=>v.slug===se.value)||null),xt=K(()=>it.value?P("workbench.newMessageTitle"):N.value),Bt=K(()=>it.value),Vt=K(()=>{var v,W;return!!((W=(v=qe.value)==null?void 0:v.workspaceDiffSummary)!=null&&W.supported)}),z=K(()=>{const v=qe.value;return v?()=>ne(v.slug):null}),Y=K(()=>{const v=qe.value;return v?()=>We(v.slug):null}),de=K(()=>({creatingTask:Te.value,currentTaskAutoTitle:_e.value.autoTitle||he.value,currentTaskSlug:se.value,draftTitle:_e.value.title,editingTaskTitleSlug:y.value,error:Le.value,isCurrentTaskSending:Pt.value,loadingTask:At.value,loadingTasks:C.value,removingTask:Ze.value,tasks:tt.value,uploading:Be.value})),ge=K(()=>{var v,W,ye,xe;return{buildPromptBlocks:Y.value,buildPrompt:z.value,diffSupported:Vt.value,selectedAgentEngine:T.value,selectedSessionId:V.value,sessionSelectionLockReason:((v=qe.value)==null?void 0:v.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((W=qe.value)!=null&&W.sessionSelectionLocked),taskSlug:((ye=qe.value)==null?void 0:ye.slug)||"",taskRunning:!!((xe=qe.value)!=null&&xe.running)}}),Ve=K(()=>({codexSessionId:V.value,sendBehavior:M.value,loading:At.value})),Ct=K(()=>({currentTaskAutoTitle:_e.value.autoTitle||he.value,currentTaskSlug:se.value,editingTaskTitleSlug:y.value,title:Ae.value,titleInputValue:_e.value.title})),{enterMobileDetail:Zt,isMobileLayout:mt,leaveMobileDetail:Ft,mobileDetailTab:bt,mobileView:sn}=Ev({currentTaskSlug:se});function dn(v){return v!=null&&v.sending||Number((v==null?void 0:v.codexRunCount)||0)>0?"activity":"input"}$v(xt,{raw:Bt});function fn(){return typeof window>"u"?null:(E||(E=new Audio(by),E.preload="auto",E.volume=.7),E)}function qt(){if(!G.value)return;const v=fn();if(!(!v||Z))try{v.muted=!0;const W=v.play();if(W&&typeof W.then=="function"){W.then(()=>{v.pause(),v.currentTime=0,v.muted=!1,Z=!0}).catch(()=>{v.muted=!1});return}v.pause(),v.currentTime=0,v.muted=!1,Z=!0}catch{v.muted=!1}}function Kt(){qt()}function It(){const v=fn();if(!v||!G.value)return;const W=Date.now();if(!(W-ce<ky)){ce=W;try{v.muted=!1,v.currentTime=0,v.play().catch(()=>{})}catch{}}}function $(v="workspace",W=""){g.value=v==="run"?"run":v==="task"?"task":"workspace",f.value=g.value==="run"?String(W||""):"",o.value=!0,h.value+=1}function Q(){o.value=!1}function H(){s.value=!0}function Ce(){s.value=!1}function Xt(){se.value&&(r.value=!0)}function k(){r.value=!1}function _(){l.value=!0}function q(){l.value=!1,re(),oe()}function re(){u.value=!1,w.value=""}function oe(){p.value=!1,c.value=""}function Se(v){De(v)}function ht(v){_e.value.title=v}async function Fe(){y.value="",ct.value&&await Tt({auto:!1,silent:!0})}function en(v){v===se.value&&(y.value=v,ft(()=>{var ye,xe;const W=document.querySelector('[data-task-title-input="current"]');(ye=W==null?void 0:W.focus)==null||ye.call(W),(xe=W==null?void 0:W.select)==null||xe.call(W)}))}async function Wt(v){if(mt.value){await Rn(v);return}if(v!==se.value){await Rn(v);return}en(v)}function Dn(){n.value=!0}function Ln(){Ze.value||(n.value=!1)}async function on(){await Re(),n.value=!1,mt.value&&Ft({useHistory:!1})}function Ut(){t.value=!0}function vt(){t.value=!1}function pn(){t.value=!1,Ge()}function Xn(v){const W=qe.value;W&&et(W.slug,v)}function tn(v){const W=qe.value;W&&Ne(W.slug,v)}function Xs(v={}){const W=String((v==null?void 0:v.sessionId)||"").trim(),ye=V.value;if(W&&W!==ye)return;const xe=Array.isArray(v==null?void 0:v.bindings)?v.bindings:[];ue.value=xe;const nt=ie(pe.value[ye],xe)||ie(v==null?void 0:v.selectedEngine,xe)||ve(xe);nt&&(T.value=nt)}Pe(V,(v,W)=>{String(v||"").trim()!==String(W||"").trim()&&(ue.value=[])});function Mn(v){T.value=v}function Bn(v){D(v),!(!mt.value||!se.value)&&(bt.value="activity")}async function Yt(){var v,W,ye,xe,nt,yt,Rt,rn;typeof document<"u"&&((W=(v=$e.value)==null?void 0:v.isComposing)!=null&&W.call(v))&&((xe=(ye=document.activeElement)==null?void 0:ye.blur)==null||xe.call(ye)),(yt=(nt=$e.value)==null?void 0:nt.flushPendingInput)==null||yt.call(nt),await ft(),(rn=(Rt=$e.value)==null?void 0:Rt.flushPendingInput)==null||rn.call(Rt),await ft()}async function gs(){await Yt(),await navigator.clipboard.writeText(je(se.value)),D({message:P("workbench.promptCopied"),type:"info"})}async function Ys(){await ut()&&mt.value&&(bt.value="input",Zt())}async function Rn(v){const W=String(v||"").trim();W&&(W!==se.value&&await St(W),mt.value&&se.value===W&&(bt.value=dn(qe.value),Zt()))}async function Js(v=[]){await Qe(v)}async function Sn(){await Yt(),He()}function Yn(v={}){const W=String((v==null?void 0:v.rangeLabel)||"").trim();if(W)return W;const ye=Math.max(0,Number(v==null?void 0:v.lineStart)||0),xe=Math.max(0,Number(v==null?void 0:v.lineEnd)||0);return ye&&xe&&ye!==xe?`L${ye}-L${xe}`:ye||xe?`L${ye||xe}`:""}function Jn(v=""){return`code-context-${String(v||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function wn(v={}){const W=String((v==null?void 0:v.filePath)||"").trim(),ye=String((v==null?void 0:v.content)||"").replace(/\r\n/g,`
58
+ `).trimEnd();if(!W||!ye.trim())return null;const xe=String((v==null?void 0:v.language)||"").trim(),nt=Yn(v),yt=String((v==null?void 0:v.source)||"").trim()==="diff"?P("workbench.codeContextSourceDiff"):P("workbench.codeContextSourceFile"),Rt=xe?`\`\`\`${xe}`:"```",rn=[P("workbench.codeContextTitle"),P("workbench.codeContextFile",{path:W}),nt?P("workbench.codeContextRange",{range:nt}):"",P("workbench.codeContextSource",{source:yt}),"",Rt,ye,"```"].filter(vs=>vs!=="");return{type:Lt.IMPORTED_TEXT,content:rn.join(`
59
+ `),meta:{fileName:Jn(W),collapsed:!1}}}async function hs(v=[],W="insertBlocks"){var xe,nt,yt,Rt;const ye=Array.isArray(v)?v.filter(Boolean):[];return ye.length?(await Yt(),(nt=(xe=$e.value)==null?void 0:xe[W])==null||nt.call(xe,ye),await ft(),(Rt=(yt=$e.value)==null?void 0:yt.focusEditor)==null||Rt.call(yt),mt.value&&se.value&&(bt.value="input"),D({message:P("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function Qn(v={}){const W=String((v==null?void 0:v.source)||"").trim(),ye=String((v==null?void 0:v.content)||"").replace(/\r\n/g,`
60
+ `).trim();if(W==="response"){if(!ye)return;await hs([Un(ye)],"insertBlocks");return}const xe=wn(v);xe&&await hs([xe],"insertImportedBlocks")}function xn(v){w.value=String(v||"").trim(),u.value=!!w.value}function Qs(){w.value&&(Oe(w.value),re())}async function Zn(v=c.value){const W=String(v||"").trim();return!W||!le(W)?!1:(oe(),q(),!0)}async function Zs(v){await Yt();const W=String(v||"").trim();if(W){if(!Ie.value){await Zn(W);return}c.value=W,p.value=!0}}async function es(){var xe,nt,yt,Rt;const v=se.value;if(!v)return;const W=!!((nt=(xe=qe.value)==null?void 0:xe.automation)!=null&&nt.enabled);await Yt(),Dt(v,je(v)),!(!await((Rt=(yt=U(v))==null?void 0:yt.send)==null?void 0:Rt.call(yt))||v!==se.value)&&(mt.value&&(bt.value="activity"),W||Ge({silent:!0}),await Tt({auto:!1,silent:!0}))}function d(){!mt.value||sn.value!=="detail"||bt.value!=="input"||!se.value||ft(()=>{var v,W;(W=(v=$e.value)==null?void 0:v.focusEditor)==null||W.call(v)})}function I(v){!ct.value&&!Be.value&&!$t.value||(v.preventDefault(),v.returnValue="")}function R(){var v,W;return p.value?(oe(),!0):u.value?(re(),!0):t.value?(vt(),!0):n.value?(Ln(),!0):r.value?(k(),!0):l.value?(q(),!0):o.value?(Q(),!0):s.value?(Ce(),!0):!!((W=(v=U(se.value))==null?void 0:v.closeTopDialog)!=null&&W.call(v))}function B(v){var nt,yt,Rt,rn,vs;const W=String(v.key||""),ye=W.toLowerCase(),xe=v.metaKey||v.ctrlKey;if(W==="Escape"){R()&&(v.preventDefault(),(nt=v.stopImmediatePropagation)==null||nt.call(v));return}if(xe){if(ye==="s"){v.preventDefault(),Tt({auto:!1});return}if(v.shiftKey&&W==="Backspace"){v.preventDefault(),Ut();return}if(!v.isComposing){if(v.shiftKey&&v.code==="Comma"){v.preventDefault(),H();return}if(v.shiftKey&&ye==="k"){v.preventDefault(),(Rt=(yt=U(se.value))==null?void 0:yt.openProjectManager)==null||Rt.call(yt);return}if(v.shiftKey&&ye==="o"){v.preventDefault(),(vs=(rn=U(se.value))==null?void 0:rn.openSourceBrowser)==null||vs.call(rn);return}v.shiftKey&&ye==="d"&&(v.preventDefault(),Vt.value&&$("workspace"))}}}cn(()=>{Xe(),window.addEventListener("beforeunload",I),window.addEventListener("keydown",B),window.addEventListener("pointerdown",Kt,{passive:!0})}),Mt(()=>{window.removeEventListener("beforeunload",I),window.removeEventListener("keydown",B),window.removeEventListener("pointerdown",Kt)}),Pe([mt,sn,bt,se],([v,W,ye,xe])=>{!v||W!=="detail"||ye!=="input"||!xe||d()}),Pe(Ht,(v,W)=>{Number(v)<=Number(W||0)||It()});const ae={"update:draftTitle":ht,"cancel-title-edit":()=>{y.value=""},"create-task":Ys,"edit-task":Xt,"delete-task":Dn,"open-settings":H,"reorder-task":Js,"select-task":Rn,"title-blur":Fe,"title-click":Wt},ke={"agent-bindings-change":Xs,"insert-code-context":Qn,"open-diff":({scope:v,runId:W})=>$(v,W),"project-created":()=>D({message:P("workbench.projectCreated"),type:"success"}),"selected-session-change":tn,"update:selectedAgentEngine":Mn,"sending-change":Xn,toast:Bn},ze={"clear-request":Ut,"file-feedback":v=>D({message:v,type:"warning"}),"import-pdf-files":at,"import-text-files":Me,"send-request":es,"upload-files":Je},Ue={"begin-edit":()=>en(se.value),back:Ft,"cancel-title-edit":()=>{y.value=""},"title-blur":Fe,"update:titleInputValue":ht};return(v,W)=>(m(),b("div",ny,[fe(_v,{message:a(ee),type:a(S)},null,8,["message","type"]),fe(ys,{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:vt,onConfirm:pn},null,8,["open","title","description","confirm-text","cancel-text"]),fe(ys,{open:n.value,title:a(P)("workbench.confirmDeleteTitle"),description:a(P)("workbench.confirmDeleteDescription",{title:a(Ae)}),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),loading:a(Ze),danger:"",onCancel:Ln,onConfirm:on},null,8,["open","title","description","confirm-text","cancel-text","loading"]),fe(ys,{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:re,onConfirm:Qs},null,8,["open","title","description","confirm-text","cancel-text"]),fe(ys,{open:p.value,title:a(P)("workbench.replaceEditorTitle"),description:a(P)("workbench.replaceEditorDescription"),"confirm-text":a(P)("workbench.confirmReplaceAction"),"cancel-text":a(P)("workbench.dontReplaceYet"),onCancel:oe,onConfirm:W[0]||(W[0]=ye=>Zn())},null,8,["open","title","description","confirm-text","cancel-text"]),fe(bv,{open:l.value,items:a(we),onClose:q,onDelete:xn,onUse:Zs},null,8,["open","items"]),fe(a(J),{open:o.value,"task-slug":a(se),"task-title":a(Ae),"preferred-scope":g.value,"preferred-run-id":f.value,"focus-token":h.value,onInsertCodeContext:Qn,onClose:Q},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),fe(a(A),{open:s.value,onClose:Ce},null,8,["open"]),fe(Pu,{open:r.value,"task-slug":a(se),"task-title":a(Ae),onClose:k,onSaved:Se},null,8,["open","task-slug","task-title"]),a(mt)?(m(),b("div",dy,[a(sn)==="tasks"?(m(),Ee(Sr,bn({key:0},de.value,{mobile:""},kn(ae)),null,16)):(m(),b("div",fy,[fe(Sh,bn(Ct.value,kn(Ue)),null,16),i("section",py,[i("div",my,[i("button",{type:"button",class:be(["tool-button px-3 py-1.5 text-sm",a(bt)==="activity"?"tool-button-accent-subtle":""]),onClick:W[3]||(W[3]=ye=>bt.value="activity")},x(a(P)("workbench.activity")),3),i("button",{type:"button",class:be(["tool-button px-3 py-1.5 text-sm",a(bt)==="input"?"tool-button-accent-subtle":""]),onClick:W[4]||(W[4]=ye=>bt.value="input")},x(a(P)("workbench.input")),3)])]),i("div",gy,[Jt(i("div",hy,[fe(fr,bn({ref_key:"codexPanelRef",ref:X},ge.value,{"empty-message":a(P)("workbench.selectTask")},kn(ke)),null,16,["empty-message"])],512),[[Ms,a(bt)==="activity"]]),Jt(i("div",vy,[i("div",yy,[i("div",Sy,[i("div",wy,[fe(mr,{"can-add-todo":a(Ie),"is-current-task-sending":a(Pt),"send-state":a(te),"todo-count":a(we).length,uploading:a(Be),onAddTodo:Sn,onOpenFilePicker:W[5]||(W[5]=ye=>{var xe,nt;return(nt=(xe=a($e))==null?void 0:xe.openFilePicker)==null?void 0:nt.call(xe)}),onClearRequest:Ut,onCopyRequest:gs,onManageTodo:_,onSendRequest:es},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),fe(pr,{"agent-bindings":ue.value,"selected-agent-engine":T.value,"onUpdate:selectedAgentEngine":Mn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",xy,[fe(yr,bn({ref_key:"editorRef",ref:$e,modelValue:a(_e).blocks,"onUpdate:modelValue":W[6]||(W[6]=ye=>a(_e).blocks=ye)},Ve.value,kn(ze)),null,16,["modelValue"])])])],512),[[Ms,a(bt)==="input"]])])]))])):(m(),b("div",sy,[fe(Sr,bn(de.value,kn(ae)),null,16),i("div",oy,[i("div",ry,[qe.value?(m(),Ee(fr,bn({key:0,ref_key:"codexPanelRef",ref:X},ge.value,kn(ke)),null,16)):me("",!0)]),i("div",ay,[i("div",iy,[i("div",ly,[i("div",uy,[fe(mr,{"can-add-todo":a(Ie),"is-current-task-sending":a(Pt),"send-state":a(te),"todo-count":a(we).length,uploading:a(Be),onAddTodo:Sn,onOpenFilePicker:W[1]||(W[1]=ye=>{var xe,nt;return(nt=(xe=a($e))==null?void 0:xe.openFilePicker)==null?void 0:nt.call(xe)}),onClearRequest:Ut,onCopyRequest:gs,onManageTodo:_,onSendRequest:es},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),fe(pr,{"agent-bindings":ue.value,"selected-agent-engine":T.value,align:"end","onUpdate:selectedAgentEngine":Mn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",cy,[fe(yr,bn({ref_key:"editorRef",ref:$e,modelValue:a(_e).blocks,"onUpdate:modelValue":W[2]||(W[2]=ye=>a(_e).blocks=ye)},Ve.value,kn(ze)),null,16,["modelValue"])])])])])]))]))}},Uy=Object.freeze(Object.defineProperty({__proto__:null,default:_y},Symbol.toStringTag,{value:"Module"}));export{Ny as D,Es as W,Qr as _,ea as a,rc as b,Tv as c,ln as d,nc as e,Ws as f,By as g,rt as h,Oy as i,Oi as j,Py as k,dl as l,nd as m,ta as n,Ly as o,gt as p,Lu as q,Fy as r,My as s,ys as t,la as u,Ry as v,Os as w,Dy as x,Iy as y,Uy as z};