@kw-yeh/vibeflow 4.11.40 → 4.11.41

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.
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/9187d5806b3a122c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/9187d5806b3a122c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8c96fd26290e204.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-ba514e8a4a55baf5.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/gmICTBYpLixZfn2Jxgcoy/_buildManifest.js" defer=""></script><script src="/_next/static/gmICTBYpLixZfn2Jxgcoy/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"gmICTBYpLixZfn2Jxgcoy","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/9187d5806b3a122c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/9187d5806b3a122c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8c96fd26290e204.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-ba514e8a4a55baf5.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/m8Qx5CrsoNWKGv6xecckf/_buildManifest.js" defer=""></script><script src="/_next/static/m8Qx5CrsoNWKGv6xecckf/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"m8Qx5CrsoNWKGv6xecckf","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
package/dist/web/404.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/9187d5806b3a122c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/9187d5806b3a122c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8c96fd26290e204.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-ba514e8a4a55baf5.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/gmICTBYpLixZfn2Jxgcoy/_buildManifest.js" defer=""></script><script src="/_next/static/gmICTBYpLixZfn2Jxgcoy/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"gmICTBYpLixZfn2Jxgcoy","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">404: This page could not be found</title><link rel="preload" href="/_next/static/css/9187d5806b3a122c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/9187d5806b3a122c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8c96fd26290e204.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-ba514e8a4a55baf5.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js" defer=""></script><script src="/_next/static/m8Qx5CrsoNWKGv6xecckf/_buildManifest.js" defer=""></script><script src="/_next/static/m8Qx5CrsoNWKGv6xecckf/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"m8Qx5CrsoNWKGv6xecckf","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -4,7 +4,7 @@
4
4
  ⚠️ 啟動 Agent 失敗:${t}`)}finally{$(!1)}}},[u]),q=(0,r.useCallback)(()=>{if(!D.current||G.current)return;let e=_.current;if(!e)return;let t=L.current;K.current!==t&&(K.current=t,Y(e))},[Y]);(0,r.useEffect)(()=>{G.current=c,v.current&&(v.current.options.disableStdin=c)},[c]),(0,r.useEffect)(()=>{let t,n,r,a,i,l,o=!1;D.current=!1;let c=new AbortController;return B.current=()=>c.abort(),(async()=>{let d,[{Terminal:u},{FitAddon:m},{WebLinksAddon:x}]=await Promise.all([s.e(3779).then(s.bind(s,15167)),s.e(5695).then(s.bind(s,95695)),s.e(4847).then(s.bind(s,54847))]);if(o||!j.current)return;let h=new u({fontSize:12,fontFamily:'Menlo, Monaco, "Courier New", monospace',cursorBlink:!0,disableStdin:G.current,linkHandler:{activate:(e,t)=>eZ(t,b),hover:(e,t)=>e5(h,t),leave:()=>e2(h)},theme:{background:"#191919",foreground:"#e6e6e6",cursor:"#4c9bf5",cursorAccent:"#191919",selectionBackground:"rgba(76, 155, 245, 0.30)",selectionForeground:"#ededed",black:"#3b3b3b",red:"#f0716a",green:"#4ec98a",yellow:"#e2b341",blue:"#4c9bf5",magenta:"#c58af9",cyan:"#4dd0e1",white:"#c8c8c8",brightBlack:"#6e6e6e",brightRed:"#ff8b84",brightGreen:"#6bdfa3",brightYellow:"#f2c862",brightBlue:"#7db8ff",brightMagenta:"#d7a6ff",brightCyan:"#72e0ee",brightWhite:"#ffffff"}}),f=new m;h.loadAddon(f),e1(h,p,b),h.loadAddon(new x((e,t)=>eZ(t,b),{hover:(e,t)=>e5(h,t),leave:()=>e2(h)})),h.open(j.current);let g=()=>{let e=j.current;if(!e||0===e.clientWidth||0===e.clientHeight)return;f.fit();let t=h.element?.querySelector(".xterm-screen"),s=h.element?.querySelector(".xterm-viewport");if(!t||!s)return;let n=eU(h.cols,t.getBoundingClientRect().width,s.clientWidth);n!==h.cols&&h.resize(n,h.rows)};if(v.current=h,await document.fonts.ready,_.current||await eJ(j.current,c.signal),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),o||v.current!==h)return;g(),H.current&&h.focus();let N=window.vibeflow;if(!N)return h.writeln("⚠️ 未連線到 VibeFlow core,無法開啟終端。");if(G.current)return h.writeln("ℹ️ 任務已完成 — 終端為唯讀,僅供查閱訊息。");if(!V.current)return h.writeln("⚠️ 尚未設定工作目錄,請先選擇專案或建立任務。");let y=G.current?null:_.current;y&&(K.current=L.current),M.current=!!y,y&&e8(h,O.current);try{d=await N.term.start({taskId:e,sessionKey:p,launch:y??void 0,cols:h.cols,rows:h.rows})}catch(e){M.current=!1,e9(h,e);return}let{scrollback:w}=d;w&&h.write(w),t=N.term.onData(({sessionKey:e,data:t})=>{e===p&&h.write(t)}),n=N.term.onExit(({sessionKey:e,exitCode:t,intentional:s})=>{if(e!==p||s)return;let n=M.current;if(M.current=!1,!n){D.current=!1,h.writeln(`\r
5
5
  ℹ️ 終端已結束(exit code: ${t})`);return}0===t?h.writeln("\r\n✅ Agent 執行完成。"):h.writeln(`\r
6
6
  ⚠️ 連線中斷或異常結束(exit code: ${t})`),h.writeln("\r\nℹ️ 已切回互動終端,可手動輸入命令。"),W()}),h.attachCustomKeyEventHandler(e=>"Enter"!==e.key||!e.shiftKey||!!e.altKey||!!e.ctrlKey||!!e.metaKey||!!e.isComposing||!!G.current||(e.preventDefault(),e.stopPropagation(),"keydown"===e.type&&N.term.input(p,"\x1b\r"),!1)),h.onData(e=>{G.current||(N.term.input(p,e),k())}),h.onScroll(()=>{let e=h.buffer.active;P(e.viewportY<e.baseY)});let k=()=>{clearTimeout(i),i=setTimeout(()=>{N.term.isScrolledBack(p).then(e=>{o||v.current!==h||I(e)})},150)},C=j.current;C?.addEventListener("wheel",k,{capture:!0,passive:!0}),l=()=>C?.removeEventListener("wheel",k,{capture:!0}),r=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{if(!o&&v.current===h)try{let{cols:e,rows:t}=h;if(g(),h.cols===e&&h.rows===t)return;N.term.resize(p,h.cols,h.rows)}catch{}},100)}),j.current&&r.observe(j.current),D.current=!0,q()})(),()=>{o=!0,c.abort(),B.current=null,D.current=!1,t?.(),n?.(),r?.disconnect(),clearTimeout(a),clearTimeout(i),l?.(),(0,F.Vz)(p),v.current?.dispose(),v.current=null}},[e,p,q,W]),(0,r.useEffect)(()=>{i&&B.current?.(),q()},[i,l,q]);let X=async t=>{if(!G.current&&D.current&&0!==t.length){C(!0);try{let s=await eW(t),n=await (0,F.s0)({taskId:e,attachments:s});if(n.length>0){let e=n.map(({path:e})=>`'${e.replace(/'/g,"'\\''")}'`).join(" ");(0,F.zj)(p,`${e} `)}}catch(t){let e=t instanceof Error?t.message:String(t);v.current?.writeln(`\r
7
- ⚠️ 附加檔案失敗:${e}`)}finally{C(!1)}}},Q=async()=>{v.current?.scrollToBottom(),P(!1),await (0,F.kt)(p),I(!1),v.current?.focus()};return(0,n.jsxs)("div",{onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&D.current&&(N.current+=1,w(!0)))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect=c||!D.current?"none":"copy")},onDragLeave:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&D.current&&(N.current=Math.max(0,N.current-1),0===N.current&&w(!1)))},onDrop:e=>{e.preventDefault(),N.current=0,w(!1),!c&&D.current&&X(e.dataTransfer.files)},className:(0,R.cn)("flex min-h-36 w-full flex-1 flex-col overflow-hidden transition-colors",f?"bg-background":"rounded-md border border-border bg-card",y&&(f?"bg-primary/5 ring-1 ring-inset ring-primary":"border-primary bg-primary/5")),children:[(0,n.jsxs)("div",{className:(0,R.cn)("flex shrink-0 items-center border-b border-border",f?"h-10 gap-2 px-3":"justify-between bg-muted/50 px-2 py-1"),children:[f?(0,n.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:x}):(0,n.jsx)("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:a??"(no cwd)"}),k?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs text-muted-foreground",children:"附加檔案中…"}):c?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs uppercase tracking-wide text-muted-foreground",children:"唯讀"}):(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[d&&(0,n.jsxs)(ec,{className:(0,R.cn)((0,eH.r)({variant:"ghost",size:"sm"}),"h-6 shrink-0 px-2 text-xs"),onConfirm:()=>void J(),disabled:!a||S||A,title:"按住以退回 Backlog:停止 Agent,捨棄這張卡在本地的 commit、未 commit 變更與 artifacts(遠端分支不動,無法復原)。之後按「開始」才會重新啟動 Agent",children:[(0,n.jsx)(e3.A,{className:(0,R.cn)("size-3",S&&"animate-pulse")}),S?"退回中…":"按住退回 Backlog"]}),u&&(0,n.jsxs)(eH.$,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void U(),disabled:!a||A||S,title:"只帶入 Agent 設定,不傳入任務內容",children:[(0,n.jsx)(e4.A,{className:(0,R.cn)("size-3",A&&"animate-pulse")}),A?"啟動中…":"啟動 Agent"]})]}),h]}),(0,n.jsxs)("div",{className:"relative min-h-0 w-full flex-1 overflow-hidden bg-background p-1",children:[(0,n.jsx)("div",{ref:j,className:"h-full w-full overflow-hidden"}),(E||T)&&(0,n.jsxs)(eH.$,{variant:"secondary",size:"sm",className:"absolute bottom-3 right-5 h-7 px-2 text-xs shadow-md",onClick:()=>void Q(),children:[(0,n.jsx)(e6.A,{className:"size-3"}),"回到最新"]})]}),null!==g&&(0,n.jsx)(e7,{sessionKey:p,path:g,onClose:()=>b(null)},g)]})}var tt=s(6329),ts=s(86570);let tn={claude:"Claude Code",codex:"Codex CLI"},tr={codex:["gpt-5-codex","gpt-5"]},ta={assignees:[],authors:[]},ti=":unassigned",tl=(e,t)=>e.localeCompare(t);function to(e,t){return Array.from(new Set([...e,...t])).sort(tl)}function tc(e,t){return tl(e.projectName,t.projectName)||t.item.number-e.item.number}function td(e,t,s){return e.flatMap(e=>e[t].map(t=>({item:t,projectName:e.projectName,projectPath:e.projectPath}))).filter(e=>(function(e,t){let{item:s}=e,{assignees:n,authors:r}=t;return(!n.length||!!(0===s.assignees.length?n.includes(ti):s.assignees.some(e=>n.includes(e.login))))&&(!r.length||!!(s.author&&r.includes(s.author.login)))})(e,s)).sort(tc)}let tu=["board","workspace","github","terminals"],tm=["jira","issues","prs"],tx="vibeflow:workspace-rail",th=["vibeflow:terminal-tabs","vibeflow:board-split-px"],tf="vibeflow:inbox-tab",tp="vibeflow:github-filters",tg="vibeflow:jira-scope",tb="vibeflow:diff-view";function tj(e){try{let t=window.localStorage.getItem(e);return null===t?null:JSON.parse(t)}catch{return null}}function tv(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}let tN=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);function ty(e){let t=e??{};return{assignees:tN(t.assignees)?t.assignees:ta.assignees,authors:tN(t.authors)?t.authors:ta.authors}}function tw(e,t){return e.path===t.path&&e.status===t.status&&e.additions===t.additions&&e.deletions===t.deletions&&e.revision===t.revision}var tk=s(68027),tC=s(85320);function tS({copied:e,icon:t=tC.A,className:s="size-3.5"}){let r=(0,c.I)()??!1,a=(0,I.mB)({timing:"micro",transform:{scale:.5},reducedMotion:r});return(0,n.jsx)("span",{className:(0,R.cn)("relative flex shrink-0",s),children:(0,n.jsx)(l.N,{mode:"popLayout",initial:!1,children:(0,n.jsx)(d.PY1.span,{variants:a,initial:"hidden",animate:"visible",exit:"exit",className:"flex size-full",children:e?(0,n.jsx)(S.A,{className:"size-full text-primary"}):(0,n.jsx)(t,{className:"size-full"})},e?"copied":"copy")})})}let tz=(0,r.lazy)(()=>s.e(1201).then(s.bind(s,31201)).then(e=>({default:e.default}))),tA={slaves:"Slaves",task:"任務",spec:"決策",artifacts:"Artifacts",diff:"Git diff"},t$=["task","spec","artifacts","diff"],tE=["task","spec"],tP=["task"],tT={A:"新增",M:"修改",D:"刪除",R:"更名","?":"未追蹤"},tI={image:"截圖",video:"影片",text:"文字",binary:"二進位"},tR="vibeflow:workspace-aside-px",tD="--vf-workspace-aside",tK={slaves:b.A,task:eS.A,spec:ez.A,artifacts:eA.A,diff:e$.A},tB="vibeflow:workspace-inspector",tF=new Set,tM=null;function t_(){return null===tM&&(tM="rail"===window.localStorage.getItem(tB)?"rail":"docked"),tM}function tL(e){for(let t of(tM=e,window.localStorage.setItem(tB,e),tF))t()}function tV(e){return tF.add(e),()=>{tF.delete(e)}}let tG={split:!1,fullContext:!1},tO=new Set,tH=null;function tY(){let e,t;return null===tH&&(tH={split:!0===(t=(e=tj(tb))&&"object"==typeof e?e:{}).split,fullContext:!0===t.fullContext}),tH}function tW(e){for(let t of(tv(tb,tH={...tY(),...e}),tO))t()}function tJ(e){return tO.add(e),()=>{tO.delete(e)}}function tU(){return(0,r.useSyncExternalStore)(tJ,tY,()=>tG)}let tq="(min-width: 1024px)";function tX(e){let t=window.matchMedia(tq);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}let tQ=!1;function tZ(){if(tQ)return;tQ=!0;let e=Number(window.localStorage.getItem(tR));Number.isFinite(e)&&e>=336&&document.documentElement.style.setProperty(tD,`${e}px`)}function t0(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function t1(e){return("image"===e.kind||"video"===e.kind)&&!e.scratch}function t5({title:e,icon:t,children:s,actions:r,count:a,heading:i}){return(0,n.jsxs)("section",{className:"flex min-h-0 flex-1 flex-col border-b border-border last:border-b-0",children:[(0,n.jsxs)("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[i??(0,n.jsxs)("h2",{className:(0,R.cn)(P,"flex min-w-0 items-center gap-2"),children:[t,(0,n.jsx)("span",{className:"truncate",children:e}),void 0!==a&&a>0&&(0,n.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/80",children:a})]}),r]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:s})]})}let t2={MERGED:"bg-primary/15 text-primary",OPEN:"bg-success/15 text-success",CLOSED:"bg-destructive/15 text-destructive"};function t3({outcome:e}){let[t,s]=(0,r.useState)(!1),{pr:a,commits:i,files:l}=e;return(0,n.jsxs)("div",{className:"space-y-4",children:[a&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,R.cn)(P,"flex items-center gap-1.5"),children:[(0,n.jsx)(g.A,{className:"size-3.5"}),"Pull Request"]}),(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5 text-sm",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:(0,R.cn)("shrink-0 rounded-xs px-1.5 py-0.5 text-xs font-medium",t2[a.state]??"bg-secondary text-secondary-foreground"),children:a.state}),(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words text-foreground",children:a.title})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void(0,F.kK)(a.url),className:"flex items-center gap-1.5 rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(eE.A,{className:"size-3"}),"#",a.number]}),a.body&&(0,n.jsx)("button",{type:"button",onClick:()=>s(e=>!e),className:"rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:t?"收合說明":"展開說明"})]}),a.body&&t&&(0,n.jsx)(eV.h,{source:a.body,compact:!0,className:"bg-transparent p-0"})]})]}),i.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,R.cn)(P,"flex items-center gap-1.5"),children:[(0,n.jsx)(eP.A,{className:"size-3.5"}),"Commits",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:i.length})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:i.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("code",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:e.sha}),(0,n.jsx)("span",{className:"min-w-0 break-words",children:e.subject})]},e.sha))})]}),l.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,R.cn)(P,"flex items-center gap-1.5"),children:[(0,n.jsx)(e$.A,{className:"size-3.5"}),"變更檔案",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:l.length}),(0,n.jsxs)("span",{className:"ml-auto font-normal tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:l.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]},e.path))}),e.truncated&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["只列出前 ",l.length," 個檔案。"]})]})]})}function t4({task:e,column:t,progress:s,master:r,onSelectTask:a}){let i="master"===e.role;return(0,n.jsxs)("div",{className:"space-y-4 text-base",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:[(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:"in_progress"===t?"In Progress":"done"===t?"Done":"Backlog"}),i&&(0,n.jsxs)("span",{className:"flex items-center gap-1 rounded-xs bg-master/15 px-1.5 py-0.5 text-xs font-medium text-master",children:[(0,n.jsx)(b.A,{className:"size-3"}),"Master"]})]}),(0,n.jsx)("h3",{className:"break-words text-lg font-semibold tracking-tight text-foreground",children:e.title})]}),"backlog"===t&&e.launchError&&(0,n.jsxs)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2.5 text-sm",children:["上次開始執行時無法建立分支,卡片已退回 Backlog:",e.launchError,(0,n.jsx)("br",{}),(0,n.jsx)("span",{className:"text-muted-foreground",children:"可以編輯分支名稱或基準分支後再開始。"})]}),e.jevRoute?.status==="routing"&&(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",role:"status",children:[(0,n.jsx)(k.A,{className:"size-3.5 shrink-0 animate-spin"}),"Jev:",$(e.jevRoute),"(完成後才會啟動 agent)"]}),e.jevRoute&&"routing"!==e.jevRoute.status&&(0,n.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:[(0,n.jsx)("p",{children:E(e.jevRoute,e.model)}),e.jevRoute.reason&&(0,n.jsxs)("p",{children:["自動選擇未完成:",e.jevRoute.reason]}),e.jevRoute.context&&(0,n.jsxs)("details",{children:[(0,n.jsxs)("summary",{className:"cursor-pointer select-none",children:["前置分析(",e.jevRoute.scoutModel??"高思考模型",")"]}),(0,n.jsx)("div",{className:"mt-2 text-foreground",children:(0,n.jsx)(eV.h,{source:e.jevRoute.context,compact:!0})})]})]}),r&&(0,n.jsxs)("button",{type:"button",onClick:()=>a?.(r.id),title:"開啟 master 卡片",className:"flex w-full items-center gap-2 rounded-md border border-master/30 bg-master/5 p-2.5 text-left text-sm outline-none transition-colors motion-reduce:transition-none hover:bg-master/10 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(b.A,{className:"size-3.5 shrink-0 text-master"}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"屬於"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:r.title}),(0,n.jsx)(eT.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),i?(0,n.jsx)("div",{className:"space-y-1.5 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(eI.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 break-all font-mono text-xs",children:e.worktreePath??e.workDir??"開始執行時建立專屬資料夾"})]})}):(0,n.jsxs)("div",{className:"space-y-1.5 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:[e.projectName&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(j.A,{className:"size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:e.projectName})]}),(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(w.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 break-all",children:[e.branch,"done"!==t&&!e.worktreePath&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:"backlog"===t?"(開始執行時建立)":"(建立中…)"})]})]}),e.baseBranch&&(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(eR.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 break-all",children:["base: ",e.baseBranch]})]})]}),e.description&&(0,n.jsx)(eV.h,{source:e.description}),"backlog"!==t&&(0,n.jsx)(ei,{progress:"in_progress"===t?s:null,usage:e.usage}),e.outcome&&(0,n.jsx)(t3,{outcome:e.outcome})]})}function t6({specs:e}){return(0,n.jsx)("div",{className:"space-y-6",children:e.map(e=>(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.path}),(0,n.jsx)(eV.h,{source:e.markdown,className:"bg-transparent p-0"}),e.truncated&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"內容過長,僅顯示前段。"}),null!=e.updatedAt&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground tabular-nums",children:["更新於 ",new Date(e.updatedAt).toLocaleString()]})]},e.path))})}function t7({taskId:e,artifact:t}){let[s,a]=(0,r.useState)(null),[i,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let s=!0;return a(null),l(!1),(0,F.R9)(e,t.name).then(e=>{s&&a(e?.dataUrl??null)}).catch(()=>{s&&a(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]);let o="video"===t.kind;return!s||i?(0,n.jsx)("div",{className:"flex h-24 items-center justify-center rounded-md border border-border/70 bg-card",children:o?(0,n.jsx)(eD.A,{className:"size-5 text-muted-foreground"}):(0,n.jsx)(eA.A,{className:"size-5 text-muted-foreground"})}):o?(0,n.jsxs)("div",{className:"relative h-24 w-full overflow-hidden rounded-md border border-border/70 bg-card",children:[(0,n.jsx)("video",{src:s,muted:!0,playsInline:!0,preload:"metadata",onError:()=>l(!0),className:"h-full w-full object-contain"}),(0,n.jsx)("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,n.jsx)("span",{className:"flex size-7 items-center justify-center rounded-full bg-background/80 ring-1 ring-border/70",children:(0,n.jsx)(eK.A,{className:"size-3.5 fill-current text-foreground"})})})]}):(0,n.jsx)("img",{src:s,alt:t.name,className:"h-24 w-full rounded-md border border-border/70 bg-card object-contain"})}function t8({taskId:e,artifact:t,onClose:s}){var a;let[i,l]=(0,r.useState)(void 0),[o,c]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=!0;return l(void 0),c(!1),(0,F.R9)(e,t.name).then(e=>{s&&l(e)}).catch(()=>{s&&l(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]),(0,n.jsx)(tt.h,{title:t.name,description:`${tI[t.kind]} \xb7 ${t0(t.size)}${t.scratch?" \xb7 工作暫存":""}`,onClose:s,showHeader:!0,contentClassName:"max-w-5xl",bodyClassName:"p-4",children:void 0===i?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取中…"]}):null===i?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案,可能已被刪除。"}):"image"===i.kind&&i.dataUrl?(0,n.jsx)(ts.p,{src:i.dataUrl,alt:t.name}):"video"===i.kind&&i.dataUrl?o?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"這個影片的編碼無法在 app 內播放。用 Artifacts 分頁的「開啟資料夾」以系統播放器開啟。"}):(0,n.jsx)("video",{src:i.dataUrl,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,onError:()=>c(!0),className:"max-h-[70vh] w-full rounded-md bg-black"}):"binary"===i.kind?(0,n.jsxs)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:["無法內嵌預覽的檔案(",t0(t.size),")。用 Artifacts 分頁的「開啟資料夾」以系統播放器或編輯器開啟。"]}):(0,n.jsxs)(n.Fragment,{children:[(a=t.name,/\.(md|markdown|mdx)$/i.test(a))?(0,n.jsx)(eV.h,{source:i.text??""}):(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded-md bg-muted/30 p-3 font-mono text-xs",children:i.text}),i.truncated&&(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"內容過長,僅顯示開頭 256 KB。"})]})})}function t9({taskId:e,artifacts:t,artifactsDir:s}){let[a,i]=(0,r.useState)(null),[o,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)("idle"),[m,x]=(0,r.useState)(null),h=t.filter(t1),f=t.filter(e=>!t1(e)),p=(0,r.useCallback)(()=>{x(null),(0,F.lr)(e).then(e=>x(e||null)).catch(()=>x("開啟失敗"))},[e]),g=(0,r.useCallback)(()=>{s&&navigator.clipboard.writeText(s).then(()=>{u("copied"),window.setTimeout(()=>u("idle"),1600)}).catch(()=>u("error"))},[s]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-3 space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Artifact 資料夾"}),(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("code",{className:"min-w-0 flex-1 select-all break-all rounded-xs bg-background px-2 py-1.5 font-mono text-xs text-foreground",title:s??"尚無可用路徑",children:s??"尚無可用路徑"}),(0,n.jsxs)(eH.$,{variant:"outline",size:"sm",onClick:g,disabled:!s,title:"複製 Artifact 資料夾路徑",className:"shrink-0 text-xs",children:[(0,n.jsx)(tS,{copied:"copied"===d}),"copied"===d?"已複製":"error"===d?"複製失敗":"複製路徑"]})]})]}),(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-end gap-2",children:[m&&(0,n.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",title:m,children:m}),(0,n.jsxs)(eH.$,{variant:"outline",size:"sm",onClick:p,title:s??"任務的 artifacts 目錄",className:"text-xs",children:[(0,n.jsx)(eI.A,{className:"size-3.5"}),"開啟資料夾"]})]}),0===t.length?(0,n.jsxs)("div",{className:"space-y-2 py-8 text-center",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"還沒有暫存產物。"}),(0,n.jsxs)("p",{className:"text-xs leading-5 text-muted-foreground/80",children:["驗證截圖、錄影與報告可放在上方資料夾,工作暫存可放在其下的 ",(0,n.jsx)("code",{className:"rounded-xs bg-muted/40 px-1 py-0.5 font-mono",children:"scratch/"}),",完成任務時會一併清除。"]})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[h.length>0?(0,n.jsx)("ul",{className:"grid grid-cols-2 gap-2",children:h.map(t=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(t),title:t.name,className:"w-full rounded-md border border-border/70 bg-muted/20 p-2 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(t7,{taskId:e,artifact:t}),(0,n.jsxs)("div",{className:"mt-1.5 flex items-baseline gap-1.5",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.name}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:t0(t.size)})]})]})},t.name))}):(0,n.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"還沒有驗證截圖或錄影。"}),f.length>0&&(0,n.jsxs)("div",{className:"rounded-md border border-border/70",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>c(e=>!e),"aria-expanded":o,className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(eT.A,{className:(0,R.cn)("size-3.5 shrink-0 transition-transform motion-reduce:transition-none",o&&"rotate-90")}),"其他 ",f.length," 個檔案(報告、script、log)"]}),o&&(0,n.jsx)("ul",{className:"border-t border-border/70",children:f.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e),title:e.name,className:"flex w-full items-center gap-2 px-2 py-1 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:["image"===e.kind?(0,n.jsx)(eA.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):"video"===e.kind?(0,n.jsx)(eD.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,n.jsx)(ez.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:e.name}),(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/80",children:[function(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return"剛剛";if(t<60)return`${t} 分前`;let s=Math.floor(t/60);return s<24?`${s} 小時前`:`${Math.floor(s/24)} 天前`}(e.modifiedAt)," \xb7 ",t0(e.size)]})]})},e.name))})]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(t8,{taskId:e,artifact:a,onClose:()=>i(null)},`artifact-${e}-${a.name}`)})]})}function se({slaves:e,progressById:t,onSelectTask:s}){if(0===e.length)return(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"Master 還沒有建立任何 slave 卡片。"});let r=e.filter(e=>"done"===e.column).length;return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[e.length," 張卡片 \xb7 ",r," 完成"]}),(0,n.jsx)("ul",{className:"space-y-1.5",children:e.map(({task:e,column:r})=>{let a=t[e.id],i=ej(r,e,a),l="in_progress"===r?ev(a):null,o="in_progress"===r?a?.todos?.find(e=>"in_progress"===e.status):void 0,c=e.outcome?.pr;return(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>s?.(e.id),title:`開啟:${e.title}`,className:"w-full rounded-md border border-border/70 bg-muted/20 px-2.5 py-2 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(ee,{...i}),(0,n.jsx)(eb,{id:e.id}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:i.label}),l&&(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:l})]}),(0,n.jsxs)("div",{className:"mt-1 flex items-center gap-2 pl-3.5 text-xs text-muted-foreground",children:[(0,n.jsx)(j.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"max-w-[45%] shrink-0 truncate",children:ex(e)}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"backlog"===r&&e.launchError?e.launchError:o?o.activeForm??o.content:e.branch}),c&&(0,n.jsxs)("span",{className:"shrink-0",children:["PR #",c.number]})]})]})},e.id)})})]})}let st=(0,r.memo)(function({file:e,showHeader:t=!0}){let{split:s,fullContext:a}=tU();return(0,n.jsxs)("div",{className:(0,R.cn)("overflow-hidden",t&&"rounded-md border border-border/70"),children:[t&&(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/70 bg-muted/30 px-2 py-1.5",children:[(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:tT[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),e.truncated&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:"已截斷"})]}),(0,n.jsx)("div",{className:"min-w-0 max-w-full overflow-x-auto text-xs [&_.diff-content]:whitespace-pre-wrap [&_.diff-content]:break-words [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_table]:min-w-full [&_table]:table-fixed [&_td]:min-w-0 [&_td]:align-top",children:(0,n.jsx)(r.Suspense,{fallback:null,children:(0,n.jsx)(tz,{oldValue:e.oldValue,newValue:e.newValue,splitView:s,showDiffOnly:!a,useDarkTheme:!0,compareMethod:"diffLines",renderContent:e=>(0,n.jsx)("span",{className:"block min-w-0 max-w-full whitespace-pre-wrap break-words",children:e}),styles:{variables:{dark:{diffViewerBackground:"var(--card)",diffViewerColor:"var(--card-foreground)",addedBackground:"rgba(78, 201, 138, 0.15)",addedColor:"var(--foreground)",removedBackground:"rgba(229, 72, 77, 0.15)",removedColor:"var(--foreground)",wordAddedBackground:"rgba(78, 201, 138, 0.32)",wordRemovedBackground:"rgba(229, 72, 77, 0.32)",addedGutterBackground:"rgba(78, 201, 138, 0.20)",removedGutterBackground:"rgba(229, 72, 77, 0.20)",gutterBackground:"var(--muted)",gutterBackgroundDark:"var(--muted)",gutterColor:"var(--muted-foreground)",addedGutterColor:"var(--foreground)",removedGutterColor:"var(--foreground)",highlightBackground:"rgba(76, 155, 245, 0.15)",highlightGutterBackground:"rgba(76, 155, 245, 0.20)",codeFoldGutterBackground:"var(--muted)",codeFoldBackground:"var(--secondary)",codeFoldContentColor:"var(--muted-foreground)",emptyLineBackground:"var(--card)"}},diffContainer:{width:"100%",maxWidth:"100%",overflowX:"visible"},line:{width:"100%"},content:{width:"100%",maxWidth:"100%",overflowX:"visible"},contentText:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},lineContent:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},gutter:{maxWidth:"2.5rem",minWidth:"2.5rem",width:"2.5rem",paddingLeft:"0.25rem",paddingRight:"0.25rem",whiteSpace:"nowrap"}}})})})]})});function ss(){let{split:e,fullContext:t}=tU(),s=e=>(0,R.cn)("rounded-sm px-2 py-1 text-xs outline-none transition-colors motion-reduce:transition-none",e?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground");return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("div",{role:"group","aria-label":"Diff 版面",className:"flex rounded-md border border-border/70 p-0.5",children:[(0,n.jsx)("button",{type:"button","aria-pressed":!e,onClick:()=>tW({split:!1}),className:(0,R.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",s(!e)),children:"整合"}),(0,n.jsx)("button",{type:"button","aria-pressed":e,onClick:()=>tW({split:!0}),className:(0,R.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",s(e)),children:"左右對照"})]}),(0,n.jsx)("button",{type:"button","aria-pressed":t,onClick:()=>tW({fullContext:!t}),title:t?"只顯示變更附近的行":"顯示檔案的所有行",className:(0,R.cn)("border border-border/70 focus-visible:ring-[3px] focus-visible:ring-ring/50",s(t)),children:t?"收合未變更":"全部展開"})]})}function sn({entry:e,file:t,onClose:s}){return(0,n.jsx)(tt.h,{title:e.path,description:(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{children:tT[e.status]??e.status}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"font-mono tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),t?.truncated&&(0,n.jsx)("span",{children:"\xb7 已截斷"})]}),onClose:s,showHeader:!0,contentClassName:"max-w-6xl",bodyClassName:"p-4",children:void 0===t?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取內容中…"]}):null===t?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案的內容。"}):(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)(ss,{}),(0,n.jsx)(st,{file:t,showHeader:!1})]})})}function sr({diff:e}){return(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(T.K,{"aria-label":"重新整理 Git diff",title:"重新整理(含 fetch origin)",className:"p-1",disabled:e.loading,onClick:e.manualRefresh,children:(0,n.jsx)(eB.A,{className:(0,R.cn)("size-3.5",e.loading&&"animate-spin")})}),e.entries.length>0&&(0,n.jsx)(T.K,{"aria-label":"放大檢視 Git diff",title:"放大檢視(全部展開)",className:"p-1",onClick:e.expand,children:(0,n.jsx)(eF.A,{className:"size-3.5"})})]})}function sa({taskId:e,diff:t}){let{entries:s,contents:r,selectedEntry:a,setSelectedPath:i,loading:o,error:c,expanded:d,fullFiles:u,closeExpanded:m}=t;return(0,n.jsxs)(n.Fragment,{children:[o&&0===s.length?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取 diff 中…"]}):c?(0,n.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:c}):0===s.length?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"與基準分支相比沒有變更。"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("ul",{className:"space-y-1",children:s.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e.path),title:`檢視 ${e.path} 的 diff`,className:"flex w-full items-center gap-2 rounded-md border border-border/70 bg-muted/30 px-2 py-1.5 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:"shrink-0 rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:tT[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),(0,n.jsx)(eT.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]})},e.path))}),s.length>=80&&(0,n.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["變更檔案超過 ",80," 個,僅顯示前 ",80," 個。"]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(sn,{entry:a,file:a.path in r?r[a.path]:void 0,onClose:()=>i(null)},`diff-${e}-${a.path}`)}),d&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex bg-background/95 text-foreground",children:(0,n.jsxs)("div",{className:"flex min-h-0 w-full flex-col",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border px-5",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Git diff"}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[s.length," changed ",1===s.length?"file":"files"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(ss,{}),(0,n.jsx)(T.K,{"aria-label":"關閉 diff 放大檢視",title:"關閉",onClick:m,children:(0,n.jsx)(eM.A,{className:"size-4"})})]})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:(0,n.jsx)("div",{className:"mx-auto w-full max-w-6xl space-y-4",children:null===u?(0,n.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取全部 diff 內容中…"]}):u.map(e=>(0,n.jsx)(st,{file:e},e.path))})})]})})]})}function si({task:e,column:t,progress:s,launch:a,onStart:i,onReturnToBacklog:l,onLaunchAgent:o,onComplete:c,onEdit:d,onDelete:u,active:m=!0,slaves:f=[],progressById:p={},master:g=null,onSelectTask:j}){var v;let N="master"===e.role,[y,k]=(0,r.useState)(null),[C,A]=(0,r.useState)([]),$=(0,r.useId)(),E=(0,r.useId)(),P=`${$}-panel`,I=e=>`${$}-tab-${e}`,K=e.worktreePath??e.projectPath??(N?e.workDir??e.workspacePath:void 0)??null,B="in_progress"!==t||e.worktreePath?null:N?"正在準備 master 的工作資料夾,完成後 agent 會自動啟動…":`正在準備工作環境:從最新的 ${e.baseBranch??"基準分支"} 建立分支 ${e.branch} 與 worktree,有 remote 時會一併推送到 origin。第一次開始執行需要幾秒鐘,完成後 agent 會自動啟動…`,M=function(e,t){let s,n;if(!e||!t)return null;let r=t.replace(/\\/g,"/"),a=(n=(s=e.replace(/\\/g,"/").replace(/\/+$/,"")).lastIndexOf("/"))>=0?s.slice(n+1):s;return`${r}/${a}.artifacts`}(e.worktreePath,e.workspacePath),_=function(e,t){let[s,n]=(0,r.useState)([]),[a,i]=(0,r.useState)({}),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),[x,h]=(0,r.useState)(0),[f,p]=(0,r.useState)(!1),[g,b]=(0,r.useState)(null),j=(0,r.useRef)(new Map),v=(0,r.useCallback)(e=>{let t=new Set(e.map(e=>e.path));for(let e of j.current.keys())t.has(e)||j.current.delete(e);n(t=>(function(e,t){if(e.length!==t.length)return t;let s=!1,n=t.map((t,n)=>{let r=e[n];return tw(r,t)?r:(s=!0,t)});return s?n:e})(t,e)),i(t=>{let s;return s=new Set(e.map(e=>e.path)),Object.keys(t).every(e=>s.has(e))?t:Object.fromEntries(Object.entries(t).filter(([e])=>s.has(e)))})},[]),N=s.find(e=>e.path===l)??null;(0,r.useEffect)(()=>{if(!N)return;let t=N.path,s=j.current.get(t);if(t in a&&s&&tw(s,N))return;let n=!0;return(0,F.sQ)(e,t).then(e=>{n&&(j.current.set(t,N),i(s=>{var n;return(n=s[t])===e||n&&e&&n.path===e.path&&n.status===e.status&&n.additions===e.additions&&n.deletions===e.deletions&&n.oldValue===e.oldValue&&n.newValue===e.newValue&&n.truncated===e.truncated?s:{...s,[t]:e}}))}).catch(()=>{n&&(j.current.set(t,N),i(e=>null===e[t]?e:{...e,[t]:null}))}),()=>{n=!1}},[e,N,a]),(0,r.useEffect)(()=>{let s;if(!t)return;let n=!0,r=!1,a=async t=>{if(r&&(0,tk.o)()){n&&(s=setTimeout(()=>void a(!1),3e3));return}r=!0;try{let s=await (0,F.Wc)(e,{fetch:t});if(!n)return;v(s),m(null)}catch(e){n&&m(e instanceof Error?e.message:String(e))}finally{n&&(d(!1),s=setTimeout(()=>void a(!1),3e3))}};return d(!0),a(!0),()=>{n=!1,s&&clearTimeout(s)}},[e,t,x,v]),(0,r.useEffect)(()=>{l&&!s.some(e=>e.path===l)&&o(null)},[s,l]),(0,r.useEffect)(()=>{if(!f)return;let t=!0;return(0,F.Gw)(e).then(e=>{t&&b(e)}).catch(e=>{t&&m(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[f,e]);let y=(0,r.useCallback)(()=>{p(!1),b(null)},[]);return{entries:s,contents:a,selectedEntry:N,setSelectedPath:o,loading:c,error:u,expanded:f,fullFiles:g,expand:(0,r.useCallback)(()=>p(!0),[]),closeExpanded:y,manualRefresh:(0,r.useCallback)(()=>{i({}),j.current.clear(),h(e=>e+1)},[])}}(e.id,"in_progress"===t&&!N),L=function(e,t,s){let[n,a]=(0,r.useState)([]);return(0,r.useEffect)(()=>{let n;if(a([]),!t)return;let r=!0,i=!1,l=async()=>{if(i&&(0,tk.o)()){r&&s&&(n=setTimeout(()=>void l(),3e3));return}i=!0;try{let t=await (0,F.ly)(e);r&&a(t)}catch{}finally{r&&s&&(n=setTimeout(()=>void l(),3e3))}};return l(),()=>{r=!1,n&&clearTimeout(n)}},[e,t,s]),n}(e.id,"backlog"!==t&&!N,"in_progress"===t&&!N),V=C.filter(t1).length;(0,r.useEffect)(()=>{let s;if("in_progress"!==t)return void A([]);let n=!0,r=!1,a=async()=>{if(r&&(0,tk.o)()){n&&(s=setTimeout(()=>void a(),3e3));return}r=!0;try{let t=await (0,F.wn)(e.id);n&&A(t)}catch{}finally{n&&(s=setTimeout(()=>void a(),3e3))}};return a(),()=>{n=!1,s&&clearTimeout(s)}},[e.id,t]);let G="backlog"===t,O=a?.launch,H=a?.nonce??0,Y=(N?(v=f.length>0,"in_progress"===t?["slaves","task","artifacts"]:v?["slaves","task"]:["task"]):"done"===t?tE:"backlog"===t?tP:t$).filter(e=>"spec"!==e||L.length>0),W="done"===t&&Y.includes("spec")?"spec":Y[0],J=y&&Y.includes(y)?y:W,U=e=>"artifacts"===e?V:"diff"===e?_.entries.length:"slaves"===e?f.length:0,q=(0,n.jsx)(z.o,{id:`${E}-strip`,children:(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視",className:"flex min-w-0 rounded-md border border-border/70 p-0.5",children:Y.map(e=>{let t=U(e);return(0,n.jsxs)("button",{type:"button",role:"tab",id:I(e),"aria-selected":J===e,"aria-controls":P,onClick:()=>{k(e)},className:(0,R.cn)("relative isolate shrink-0 rounded-sm px-2 py-0.5 text-xs outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",J===e?"text-primary":"text-muted-foreground hover:text-foreground"),children:[J===e&&(0,n.jsx)(D,{layoutId:"task-tab",className:"inset-0 -z-10 rounded-sm bg-primary/15"}),tA[e],t>0&&(0,n.jsx)("span",{className:"ml-1 tabular-nums text-muted-foreground/80",children:t})]},e)})})}),X="slaves"===J?(0,n.jsx)(se,{slaves:f,progressById:p,onSelectTask:j}):"task"===J?(0,n.jsx)(t4,{task:e,column:t,progress:s,master:g,onSelectTask:j}):"spec"===J?(0,n.jsx)(t6,{specs:L}):"artifacts"===J?(0,n.jsx)(t9,{taskId:e.id,artifacts:C,artifactsDir:M}):(0,n.jsx)(sa,{taskId:e.id,diff:_}),Q=(0,n.jsx)("div",{role:"tabpanel",id:P,"aria-labelledby":I(J),className:"h-full",children:X}),Z=(0,r.useSyncExternalStore)(tV,t_,()=>"docked"),ee=(0,r.useSyncExternalStore)(tX,()=>window.matchMedia(tq).matches,()=>!0),et=ee&&"docked"===Z,[es,er]=(0,r.useState)(!1),ea=et||es,ei=(0,n.jsx)(t5,{title:tA[J],count:U(J),actions:(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:["diff"===J&&(0,n.jsx)(sr,{diff:_}),et?(0,n.jsx)(T.K,{"aria-label":"收合側欄",title:"收合成圖示列,讓終端機佔滿寬度",className:"p-1",onClick:()=>tL("rail"),children:(0,n.jsx)(e_.A,{className:"size-3.5"})}):(0,n.jsxs)(n.Fragment,{children:[ee&&(0,n.jsx)(T.K,{"aria-label":"固定側欄",title:"固定在終端機旁",className:"p-1",onClick:()=>{er(!1),tL("docked")},children:(0,n.jsx)(eL.A,{className:"size-3.5"})}),(0,n.jsx)(T.K,{"aria-label":"關閉側欄",className:"p-1",onClick:()=>er(!1),children:(0,n.jsx)(eM.A,{className:"size-3.5"})})]})]}),children:Q}),el=(0,n.jsx)(z.o,{id:`${E}-rail`,children:(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視","aria-orientation":"vertical",className:"flex w-11 shrink-0 flex-col items-center gap-1 border-l border-border bg-card/40 py-1.5",children:Y.map(e=>{let t=tK[e],s=U(e),r=ea&&J===e;return(0,n.jsxs)("button",{type:"button",role:"tab",id:I(e),"aria-selected":r,"aria-controls":P,"aria-label":s>0?`${tA[e]}(${s})`:tA[e],title:tA[e],onClick:()=>{var t;return t=e,void(ea&&t===J?et?tL("rail"):er(!1):(k(t),et||er(!0)))},className:(0,R.cn)("relative isolate flex size-8 items-center justify-center rounded-md outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",r?"text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[r&&(0,n.jsx)(D,{layoutId:"task-rail-tab",className:"inset-0 -z-10 rounded-md bg-primary/15"}),(0,n.jsx)(t,{className:"size-4"}),s>0&&(0,n.jsx)("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-semibold tabular-nums text-primary-foreground",children:s})]},e)})})}),[eo,ed]=(0,r.useState)("idle"),eu=(0,r.useRef)(null),em=(0,r.useRef)(null),ex=(0,r.useRef)(null);(0,r.useLayoutEffect)(tZ,[]);let eh=(e,t)=>{let s,n=Math.round(Math.max(336,Math.min(e,Math.max(336,(s=eu.current?.clientWidth??0)>0?s-320-10-44:e))));document.documentElement.style.setProperty(tD,`${n}px`),t&&window.localStorage.setItem(tR,String(n))},ef=()=>{if(!ex.current)return;ex.current=null;let e=em.current?.getBoundingClientRect().width??0;e>0&&eh(e,!0)},ep=e=>{let t=em.current?.getBoundingClientRect().width??0;t<=0||eh(t+e,!0)},eg=(0,n.jsx)(ec,{"aria-label":"按住刪除任務",title:"按住以刪除任務(清理 worktree)",onConfirm:()=>u(e.id),className:"inline-flex shrink-0 items-center justify-center rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-destructive/15 hover:text-destructive",children:(0,n.jsx)(h.A,{className:"size-4"})});return"in_progress"===t?(0,n.jsx)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden bg-background text-foreground",children:(0,n.jsxs)("main",{ref:eu,className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,n.jsxs)("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",onPointerDown:()=>er(!1),children:(0,n.jsx)(te,{taskId:e.id,cwd:K,launchCommand:O,launchNonce:H,provisionNotice:B,readOnly:!1,onReturnToBacklog:()=>l(e),onLaunchAgent:()=>o(e),active:m,toolbarStart:(0,n.jsxs)(n.Fragment,{children:[N?(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 rounded-xs bg-master/15 px-1.5 py-0.5 text-xs font-medium text-master",children:[(0,n.jsx)(b.A,{className:"size-3 shrink-0"}),"Master"]}):(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 rounded-xs bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",title:e.branch,children:[(0,n.jsx)(w.A,{className:"size-3 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"truncate",children:e.branch})]}),e.baseBranch&&(0,n.jsxs)("span",{className:"min-w-0 shrink truncate font-mono text-xs text-muted-foreground",title:`基準分支:${e.baseBranch}`,children:["← ",e.baseBranch]}),(0,n.jsx)(T.K,{"aria-label":"copied"===eo?"已複製 worktree 路徑":"error"===eo?"複製 worktree 路徑失敗":"複製 worktree 路徑",title:K??void 0,className:"p-1",disabled:!K,onClick:()=>{K&&navigator.clipboard.writeText(K).then(()=>ed("copied")).catch(()=>ed("error")).finally(()=>window.setTimeout(()=>ed("idle"),1600))},children:(0,n.jsx)(tS,{copied:"copied"===eo})}),(0,n.jsx)(en,{progress:s})]}),toolbarEnd:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-4 w-px shrink-0 bg-border"}),(0,n.jsxs)(eH.$,{size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:()=>{c(e)},title:"標記完成後會清理 PTY 與 worktree",children:[(0,n.jsx)(S.A,{className:"size-3.5"}),"完成"]}),eg]})})}),!et&&es&&(0,n.jsx)("aside",{"aria-label":tA[J],onKeyDown:e=>{"Escape"!==e.key||(0,tk.o)()||er(!1)},className:"absolute bottom-0 right-0 top-10 z-20 flex w-[min(var(--vf-workspace-aside,24rem),calc(100%-2rem))] flex-col border-l border-border bg-card shadow-xl xl:w-[min(var(--vf-workspace-aside,27rem),calc(100%-2rem))]",children:ei})]}),et&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"調整終端機與側邊面板的寬度",tabIndex:0,onPointerDown:e=>{let t=em.current?.getBoundingClientRect().width??0;t<=0||(ex.current={x:e.clientX,width:t},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=ex.current;t&&eh(t.width-(e.clientX-t.x),!1)},onPointerUp:ef,onPointerCancel:ef,onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),ep(24)):"ArrowRight"===e.key&&(e.preventDefault(),ep(-24))},className:"flex w-2.5 shrink-0 cursor-col-resize items-center justify-center border-x border-border bg-card outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)("span",{className:"h-12 w-0.5 rounded-full bg-input"})}),(0,n.jsx)("aside",{ref:em,className:"flex min-h-0 w-[var(--vf-workspace-aside,24rem)] min-w-0 max-w-[calc(100%-23.375rem)] shrink-0 flex-col bg-card/40 xl:w-[var(--vf-workspace-aside,27rem)]",children:ei})]}),el]})}):(0,n.jsxs)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsxs)("header",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[N?(0,n.jsx)(b.A,{className:"size-3.5 shrink-0 text-master"}):(0,n.jsx)(w.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 truncate text-base font-semibold",children:e.title})]})}),G&&(0,n.jsxs)(eH.$,{size:"sm",variant:"outline",onClick:()=>{i(e)},disabled:!K,children:[(0,n.jsx)(eK.A,{className:"size-3.5"}),"開始"]}),"backlog"===t&&(0,n.jsx)(T.K,{"aria-label":"編輯任務",title:"編輯任務",onClick:()=>{d(e.id)},children:(0,n.jsx)(x.A,{className:"size-4"})}),eg]}),(0,n.jsx)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-card/40",children:"backlog"===t&&1===Y.length?(0,n.jsx)(t5,{title:tA.task,children:(0,n.jsx)(t4,{task:e,column:t,progress:s,master:g,onSelectTask:j})}):(0,n.jsx)(t5,{heading:q,children:Q})})]})}var sl=s(26814),so=s(6684),sc=s(37744);let sd={backlog:"Backlog",in_progress:"In Progress",done:"Done"};function su(e,t){return"backlog"===t?{dot:"bg-muted-foreground/60",label:sd.backlog}:"done"===t?{dot:"bg-success",label:sd.done}:et(e?.activity)}function sm({branch:e}){return(0,n.jsx)("span",{"aria-hidden":"true",className:(0,R.cn)("pointer-events-none absolute -top-1 left-[18px] w-2.5 border-l border-master/50","last"===e?"h-6":"-bottom-1"),children:(0,n.jsx)("span",{className:"absolute left-0 top-[23px] w-full border-t border-master/50"})})}function sx({running:e,viewing:t,selectedTaskId:s,progress:r,onSelect:a,collapsed:i,onCollapsedChange:l}){let o,c=(o=new Set(e.map(e=>e.id)),e.filter(e=>!(e.masterId&&o.has(e.masterId))).flatMap(t=>{let s=e.filter(e=>e.masterId===t.id);return[{task:t,branch:"none"},...s.map((e,t)=>({task:e,branch:t===s.length-1?"last":"middle"}))]}));if(i)return(0,n.jsxs)("nav",{"aria-label":"進行中的任務",className:"flex w-11 shrink-0 flex-col items-center gap-1 overflow-y-auto border-r border-border bg-card/40 py-1.5",children:[(0,n.jsx)(T.K,{"aria-label":"展開任務清單",title:"展開任務清單",className:"mb-1 size-8 rounded-md",onClick:()=>l(!1),children:(0,n.jsx)(sl.A,{className:"size-4"})}),[...t?[{task:t.task,column:t.column}]:[],...c.map(({task:e})=>({task:e,column:"in_progress"}))].map(({task:e,column:t})=>{let i=e.id===s;return(0,n.jsx)("button",{type:"button","aria-label":e.title,"aria-current":i?"page":void 0,title:e.title,onClick:()=>a(e.id),className:(0,R.cn)("flex size-8 shrink-0 items-center justify-center rounded-md outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",i?"bg-primary/15":"hover:bg-accent"),children:(0,n.jsx)(ee,{...su(r[e.id],t),className:"size-2"})},e.id)})]});let d=(e,t,i)=>{let l=e.id===s,o="master"===e.role,c=(0,n.jsxs)("button",{type:"button","aria-current":l?"page":void 0,title:e.title,onClick:()=>a(e.id),className:(0,R.cn)("flex w-full min-w-0 flex-col gap-1 rounded-md border px-2.5 py-2 text-left outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",l?"border-primary/60 bg-accent text-foreground":"border-transparent text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-sm font-medium text-foreground",children:[o?(0,n.jsx)(b.A,{className:"size-3.5 shrink-0 text-master"}):(0,n.jsx)("span",{className:"flex w-3.5 shrink-0 justify-center",children:(0,n.jsx)(ee,{...su(r[e.id],t)})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title}),(0,n.jsx)(eb,{id:e.id,className:"font-normal"})]}),(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2 pl-[22px] text-xs",children:[(0,n.jsx)("span",{className:"min-w-0 truncate",children:"in_progress"===t?o?"Master":e.projectName??"":sd[t]}),"in_progress"===t&&(0,n.jsx)(en,{progress:r[e.id],mark:o})]})]},e.id);return"none"===i?c:(0,n.jsxs)("div",{className:"relative pl-7",children:[(0,n.jsx)(sm,{branch:i}),c]},e.id)};return(0,n.jsxs)("nav",{"aria-label":"進行中的任務",className:"flex w-64 shrink-0 flex-col border-r border-border bg-card/40",children:[(0,n.jsxs)("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b border-border pl-3 pr-1.5",children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-warning"}),(0,n.jsx)("h2",{className:(0,R.cn)(P,"text-warning"),children:"In Progress"}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:e.length}),(0,n.jsx)("span",{className:"flex-1"}),(0,n.jsx)(T.K,{"aria-label":"收合任務清單",title:"收合任務清單,讓終端機更寬",className:"p-1",onClick:()=>l(!0),children:(0,n.jsx)(so.A,{className:"size-3.5"})})]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto p-1.5",children:[t&&(0,n.jsxs)("div",{className:"mb-2 space-y-1 border-b border-border pb-2",children:[(0,n.jsxs)("p",{className:"flex items-center gap-1.5 px-1 text-xs text-muted-foreground",children:[(0,n.jsx)(sc.A,{className:"size-3"}),"目前檢視"]}),d(t.task,t.column,"none")]}),c.map(({task:e,branch:t})=>d(e,"in_progress",t)),0===c.length&&(0,n.jsx)("p",{className:"px-2 py-3 text-sm text-muted-foreground",children:"目前沒有進行中的任務"})]})]})}function sh(){let e;return("boolean"==typeof(e=tj(tx))?e:null)??!window.matchMedia("(min-width: 1280px)").matches}function sf({active:e,children:t}){let s=(0,o.E)(),a=(0,c.I)()??!1,i=(0,I.n)({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:a});return(0,r.useEffect)(()=>{s.stop(),s.set("hidden"),e&&s.start("visible")},[e,s,a]),(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:s,variants:i,inert:!e,"aria-hidden":!e||void 0,className:(0,R.cn)("h-full",!e&&"hidden pointer-events-none"),children:t})}function sp({board:e,onBoardChange:t,onEditTask:s,onTaskDone:a,onDeleteTask:i,onOpenTaskTerminal:o,taskTerminals:x,onShowTaskTerminal:h,progress:f,selectedTaskId:p,onSelectTask:g,onNewTask:b,view:j,onViewChange:v,githubView:N,taskLinks:y}){let[w,k]=(0,r.useState)(new Set),[C,S]=(0,r.useState)({}),z=(0,r.useRef)(C);z.current=C;let A=(0,c.I)()??!1,$=(0,I.n)({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:A}),E=e=>k(t=>t.has(e)?t:new Set(t).add(e)),[P,T]=(0,r.useState)(null),D=async(e,t={})=>{E(e.id),S(s=>({...s,[e.id]:{launch:t,nonce:(s[e.id]?.nonce??0)+1}}))};(0,r.useEffect)(()=>{if(!p||(E(p),C[p]))return;let t=e.in_progress.find(e=>e.id===p);if(!t||null==t.launchedAt||!t.worktreePath)return;let s=!1;return(0,F.Vc)(t.id).then(e=>{s||!e||z.current[t.id]||D(t,{resume:!0})}),()=>{s=!0}},[p]);let K=s=>{let n={...s,launchedAt:Date.now()};t({backlog:e.backlog.filter(e=>e.id!==s.id),in_progress:[n,...e.in_progress],done:e.done}),D(n)},B=async e=>(await M(e),!0),M=async e=>{let s=await (0,F.WL)(e.id);if(!s)throw Error("未連線到 VibeFlow core");let n=s.state.board;t({backlog:[s.task,...n.backlog.filter(t=>t.id!==e.id)],in_progress:n.in_progress.filter(t=>t.id!==e.id),done:n.done.filter(t=>t.id!==e.id)})},_=async e=>{await D(e,{includeTaskPrompt:!1})},L=e=>T(e),[V,G]=(0,r.useState)(sh),O=e=>{G(e),tv(tx,e)},H="workspace"===j;return(0,n.jsxs)("div",{className:"flex h-full overflow-hidden bg-background text-foreground",children:[(0,n.jsx)("div",{className:(0,R.cn)("min-h-0 min-w-0 flex-1 overflow-hidden",H&&"hidden"),children:"github"===j?N:(0,n.jsx)(eC,{board:e,progress:f,selectedTaskId:p??null,onSelectTask:g,onEditTask:s,onDeleteTask:i,onOpenTaskTerminal:o,taskTerminals:x,onShowTaskTerminal:h,onNewTask:b,view:j,onViewChange:v,taskLinks:y})}),(()=>{let t=[...e.in_progress.map(e=>({task:e,column:"in_progress"})),...e.backlog.map(e=>({task:e,column:"backlog"})),...e.done.map(e=>({task:e,column:"done"}))],r=p?t.find(({task:e})=>e.id===p):null,a=new Set;for(let e of w){let s=t.find(({task:t})=>t.id===e);s?.column==="in_progress"&&a.add(e)}return r&&a.add(r.task.id),(0,n.jsxs)("div",{className:(0,R.cn)("min-h-0 min-w-0 flex-1",H?"flex":"hidden"),children:[(0,n.jsx)(sx,{running:e.in_progress,viewing:r&&"in_progress"!==r.column?r:null,selectedTaskId:p??null,progress:f,onSelect:g,collapsed:V,onCollapsedChange:O}),(0,n.jsxs)("main",{className:"min-h-0 min-w-0 flex-1",children:[Array.from(a).map(e=>{let r=t.find(({task:t})=>t.id===e);if(!r)return null;let a=e===p;return(0,n.jsx)(sf,{active:a,children:(0,n.jsx)(si,{task:r.task,column:r.column,active:a&&H,progress:f[r.task.id]??null,progressById:f,slaves:"master"===r.task.role?t.filter(({task:e})=>e.masterId===r.task.id):void 0,master:r.task.masterId?t.find(({task:e})=>e.id===r.task.masterId)?.task??null:null,onSelectTask:g,launch:C[e],onStart:K,onReturnToBacklog:B,onLaunchAgent:_,onComplete:L,onEdit:s,onDelete:i})},e)}),!r&&(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:$,className:"flex h-full items-center justify-center p-8",children:(0,n.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,n.jsx)("p",{className:"text-base text-muted-foreground",children:"從左側選一張卡片,或建立新的任務。"}),(0,n.jsxs)(eH.$,{size:"sm",onClick:b,className:"rounded-full px-4",children:[(0,n.jsx)(u.A,{}),"新增任務"]})]})})]})]})})(),(0,n.jsx)(l.N,{children:P&&(0,n.jsx)(tt.h,{title:"完成任務",onClose:()=>T(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(m.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["完成「",P.title,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除這張卡的 worktree(尚未 commit 的變更會一起消失)、本地分支",P.branch?`「${P.branch}」`:"","與 artifacts, 並把專案切回",P.baseBranch?`「${P.baseBranch}」`:"基準分支","後更新。此操作無法復原,請先確認要保留的變更都已經 commit 或 push。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eH.$,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>T(null),children:"取消"}),(0,n.jsx)(eH.$,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>{var s;let n;P&&(T(null),s="done",(n={backlog:e.backlog.filter(e=>e.id!==P.id),in_progress:e.in_progress.filter(e=>e.id!==P.id),done:e.done.filter(e=>e.id!==P.id)})[s]=[P,...n[s]],t(n),a(P.id))},children:"完成並清理"})]})]})},"confirm-done-dialog")})]})}let sg=eO()(()=>s.e(1225).then(s.bind(s,91225)).then(e=>e.TerminalFilePreview),{loadableGenerated:{webpack:()=>[91225]},ssr:!1});function sb({sessionKey:e,projectPath:t,displayPath:a,taskId:i,title:l,onStarted:o}){let[c,d]=(0,r.useState)(null),u=(0,r.useRef)(null),m=(0,r.useRef)(l);m.current=l;let x=(0,r.useRef)(o);return x.current=o,(0,r.useEffect)(()=>{let n,r,a,l,o=!1,c=null,h=new AbortController;return(async()=>{let[{Terminal:f},{FitAddon:p},{WebLinksAddon:g}]=await Promise.all([s.e(3779).then(s.bind(s,15167)),s.e(5695).then(s.bind(s,95695)),s.e(4847).then(s.bind(s,54847))]);if(o||!u.current)return;let b=new f({fontSize:12,fontFamily:'Menlo, Monaco, "Courier New", monospace',cursorBlink:!0,theme:{background:"#191919",foreground:"#e6e6e6",cursor:"#4c9bf5"},linkHandler:{activate:(e,t)=>eZ(t,d),hover:(e,t)=>e5(b,t),leave:()=>e2(b)}});c=b;let j=new p;b.loadAddon(j),e1(b,e,d),b.loadAddon(new g((e,t)=>eZ(t,d),{hover:(e,t)=>e5(b,t),leave:()=>e2(b)})),b.open(u.current);let v=()=>{if(!u.current||0===u.current.clientWidth||0===u.current.clientHeight)return;j.fit();let e=b.element?.querySelector(".xterm-screen"),t=b.element?.querySelector(".xterm-viewport");if(e&&t){let s=eU(b.cols,e.getBoundingClientRect().width,t.clientWidth);s!==b.cols&&b.resize(s,b.rows)}};if(await document.fonts.ready,await eJ(u.current,h.signal),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),o)return;v();let N=window.vibeflow;if(!N)return b.writeln("⚠️ 未連線到 VibeFlow core,無法開啟終端。");n=N.term.onData(({sessionKey:t,data:s})=>{t===e&&b.write(s)}),r=N.term.onExit(({sessionKey:t,exitCode:s,intentional:n})=>{t!==e||n||b.writeln(`\r
7
+ ⚠️ 附加檔案失敗:${e}`)}finally{C(!1)}}},Q=async()=>{v.current?.scrollToBottom(),P(!1),await (0,F.kt)(p),I(!1),v.current?.focus()};return(0,n.jsxs)("div",{onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&D.current&&(N.current+=1,w(!0)))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect=c||!D.current?"none":"copy")},onDragLeave:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!c&&D.current&&(N.current=Math.max(0,N.current-1),0===N.current&&w(!1)))},onDrop:e=>{e.preventDefault(),N.current=0,w(!1),!c&&D.current&&X(e.dataTransfer.files)},className:(0,R.cn)("flex min-h-36 w-full flex-1 flex-col overflow-hidden transition-colors",f?"bg-background":"rounded-md border border-border bg-card",y&&(f?"bg-primary/5 ring-1 ring-inset ring-primary":"border-primary bg-primary/5")),children:[(0,n.jsxs)("div",{className:(0,R.cn)("flex shrink-0 items-center border-b border-border",f?"h-10 gap-2 px-3":"justify-between bg-muted/50 px-2 py-1"),children:[f?(0,n.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:x}):(0,n.jsx)("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:a??"(no cwd)"}),k?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs text-muted-foreground",children:"附加檔案中…"}):c?(0,n.jsx)("span",{className:"shrink-0 px-2 text-xs uppercase tracking-wide text-muted-foreground",children:"唯讀"}):(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[d&&(0,n.jsxs)(ec,{className:(0,R.cn)((0,eH.r)({variant:"ghost",size:"sm"}),"h-6 shrink-0 px-2 text-xs"),onConfirm:()=>void J(),disabled:!a||S||A,title:"按住以退回 Backlog:停止 Agent,捨棄這張卡在本地的 commit、未 commit 變更與 artifacts(遠端分支不動,無法復原)。之後按「開始」才會重新啟動 Agent",children:[(0,n.jsx)(e3.A,{className:(0,R.cn)("size-3",S&&"animate-pulse")}),S?"退回中…":"按住退回 Backlog"]}),u&&(0,n.jsxs)(eH.$,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>void U(),disabled:!a||A||S,title:"只帶入 Agent 設定,不傳入任務內容",children:[(0,n.jsx)(e4.A,{className:(0,R.cn)("size-3",A&&"animate-pulse")}),A?"啟動中…":"啟動 Agent"]})]}),h]}),(0,n.jsxs)("div",{className:"relative min-h-0 w-full flex-1 overflow-hidden bg-background p-1",children:[(0,n.jsx)("div",{ref:j,className:"h-full w-full overflow-hidden"}),(E||T)&&(0,n.jsxs)(eH.$,{variant:"secondary",size:"sm",className:"absolute bottom-3 right-5 h-7 px-2 text-xs shadow-md",onClick:()=>void Q(),children:[(0,n.jsx)(e6.A,{className:"size-3"}),"回到最新"]})]}),null!==g&&(0,n.jsx)(e7,{sessionKey:p,path:g,onClose:()=>b(null)},g)]})}var tt=s(6329),ts=s(86570);let tn={claude:"Claude Code",codex:"Codex CLI"},tr={codex:["gpt-5-codex","gpt-5"]},ta={assignees:[],authors:[]},ti=":unassigned",tl=(e,t)=>e.localeCompare(t);function to(e,t){return Array.from(new Set([...e,...t])).sort(tl)}function tc(e,t){return tl(e.projectName,t.projectName)||t.item.number-e.item.number}function td(e,t,s){return e.flatMap(e=>e[t].map(t=>({item:t,projectName:e.projectName,projectPath:e.projectPath}))).filter(e=>(function(e,t){let{item:s}=e,{assignees:n,authors:r}=t;return(!n.length||!!(0===s.assignees.length?n.includes(ti):s.assignees.some(e=>n.includes(e.login))))&&(!r.length||!!(s.author&&r.includes(s.author.login)))})(e,s)).sort(tc)}let tu=["board","workspace","github","terminals"],tm=["jira","issues","prs"],tx="vibeflow:workspace-rail",th=["vibeflow:terminal-tabs","vibeflow:board-split-px"],tf="vibeflow:inbox-tab",tp="vibeflow:github-filters",tg="vibeflow:jira-scope",tb="vibeflow:diff-view";function tj(e){try{let t=window.localStorage.getItem(e);return null===t?null:JSON.parse(t)}catch{return null}}function tv(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}let tN=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);function ty(e){let t=e??{};return{assignees:tN(t.assignees)?t.assignees:ta.assignees,authors:tN(t.authors)?t.authors:ta.authors}}function tw(e,t){return e.path===t.path&&e.status===t.status&&e.additions===t.additions&&e.deletions===t.deletions&&e.revision===t.revision}var tk=s(68027),tC=s(85320);function tS({copied:e,icon:t=tC.A,className:s="size-3.5"}){let r=(0,c.I)()??!1,a=(0,I.mB)({timing:"micro",transform:{scale:.5},reducedMotion:r});return(0,n.jsx)("span",{className:(0,R.cn)("relative flex shrink-0",s),children:(0,n.jsx)(l.N,{mode:"popLayout",initial:!1,children:(0,n.jsx)(d.PY1.span,{variants:a,initial:"hidden",animate:"visible",exit:"exit",className:"flex size-full",children:e?(0,n.jsx)(S.A,{className:"size-full text-primary"}):(0,n.jsx)(t,{className:"size-full"})},e?"copied":"copy")})})}let tz=(0,r.lazy)(()=>s.e(1201).then(s.bind(s,31201)).then(e=>({default:e.default}))),tA={slaves:"Slaves",task:"任務",spec:"決策",artifacts:"Artifacts",diff:"Git diff"},t$=["task","spec","artifacts","diff"],tE=["task","spec"],tP=["task"],tT={A:"新增",M:"修改",D:"刪除",R:"更名","?":"未追蹤"},tI={image:"截圖",video:"影片",text:"文字",binary:"二進位"},tR="vibeflow:workspace-aside-px",tD="--vf-workspace-aside",tK={slaves:b.A,task:eS.A,spec:ez.A,artifacts:eA.A,diff:e$.A},tB="vibeflow:workspace-inspector",tF=new Set,tM=null;function t_(){return null===tM&&(tM="rail"===window.localStorage.getItem(tB)?"rail":"docked"),tM}function tL(e){for(let t of(tM=e,window.localStorage.setItem(tB,e),tF))t()}function tV(e){return tF.add(e),()=>{tF.delete(e)}}let tG={split:!1,fullContext:!1},tO=new Set,tH=null;function tY(){let e,t;return null===tH&&(tH={split:!0===(t=(e=tj(tb))&&"object"==typeof e?e:{}).split,fullContext:!0===t.fullContext}),tH}function tW(e){for(let t of(tv(tb,tH={...tY(),...e}),tO))t()}function tJ(e){return tO.add(e),()=>{tO.delete(e)}}function tU(){return(0,r.useSyncExternalStore)(tJ,tY,()=>tG)}let tq="(min-width: 1024px)";function tX(e){let t=window.matchMedia(tq);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}let tQ=!1;function tZ(){if(tQ)return;tQ=!0;let e=Number(window.localStorage.getItem(tR));Number.isFinite(e)&&e>=336&&document.documentElement.style.setProperty(tD,`${e}px`)}function t0(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function t1(e){return("image"===e.kind||"video"===e.kind)&&!e.scratch}function t5({title:e,icon:t,children:s,actions:r,count:a,heading:i}){return(0,n.jsxs)("section",{className:"flex min-h-0 flex-1 flex-col border-b border-border last:border-b-0",children:[(0,n.jsxs)("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[i??(0,n.jsxs)("h2",{className:(0,R.cn)(P,"flex min-w-0 items-center gap-2"),children:[t,(0,n.jsx)("span",{className:"truncate",children:e}),void 0!==a&&a>0&&(0,n.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/80",children:a})]}),r]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:s})]})}let t2={MERGED:"bg-primary/15 text-primary",OPEN:"bg-success/15 text-success",CLOSED:"bg-destructive/15 text-destructive"};function t3({outcome:e}){let[t,s]=(0,r.useState)(!1),{pr:a,commits:i,files:l}=e;return(0,n.jsxs)("div",{className:"space-y-4",children:[a&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,R.cn)(P,"flex items-center gap-1.5"),children:[(0,n.jsx)(g.A,{className:"size-3.5"}),"Pull Request"]}),(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5 text-sm",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:(0,R.cn)("shrink-0 rounded-xs px-1.5 py-0.5 text-xs font-medium",t2[a.state]??"bg-secondary text-secondary-foreground"),children:a.state}),(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words text-foreground",children:a.title})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void(0,F.kK)(a.url),className:"flex items-center gap-1.5 rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(eE.A,{className:"size-3"}),"#",a.number]}),a.body&&(0,n.jsx)("button",{type:"button",onClick:()=>s(e=>!e),className:"rounded-sm text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:t?"收合說明":"展開說明"})]}),a.body&&t&&(0,n.jsx)(eV.h,{source:a.body,compact:!0,className:"bg-transparent p-0"})]})]}),i.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,R.cn)(P,"flex items-center gap-1.5"),children:[(0,n.jsx)(eP.A,{className:"size-3.5"}),"Commits",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:i.length})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:i.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("code",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:e.sha}),(0,n.jsx)("span",{className:"min-w-0 break-words",children:e.subject})]},e.sha))})]}),l.length>0&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("h3",{className:(0,R.cn)(P,"flex items-center gap-1.5"),children:[(0,n.jsx)(e$.A,{className:"size-3.5"}),"變更檔案",(0,n.jsx)("span",{className:"tabular-nums font-normal",children:l.length}),(0,n.jsxs)("span",{className:"ml-auto font-normal tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]}),(0,n.jsx)("ul",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm",children:l.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]})]},e.path))}),e.truncated&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["只列出前 ",l.length," 個檔案。"]})]})]})}function t4({task:e,column:t,progress:s,master:r,onSelectTask:a}){let i="master"===e.role;return(0,n.jsxs)("div",{className:"space-y-4 text-base",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:[(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:"in_progress"===t?"In Progress":"done"===t?"Done":"Backlog"}),i&&(0,n.jsxs)("span",{className:"flex items-center gap-1 rounded-xs bg-master/15 px-1.5 py-0.5 text-xs font-medium text-master",children:[(0,n.jsx)(b.A,{className:"size-3"}),"Master"]})]}),(0,n.jsx)("h3",{className:"break-words text-lg font-semibold tracking-tight text-foreground",children:e.title})]}),"backlog"===t&&e.launchError&&(0,n.jsxs)("p",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2.5 text-sm",children:["上次開始執行時無法建立分支,卡片已退回 Backlog:",e.launchError,(0,n.jsx)("br",{}),(0,n.jsx)("span",{className:"text-muted-foreground",children:"可以編輯分支名稱或基準分支後再開始。"})]}),e.jevRoute?.status==="routing"&&(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",role:"status",children:[(0,n.jsx)(k.A,{className:"size-3.5 shrink-0 animate-spin"}),"Jev:",$(e.jevRoute),"(完成後才會啟動 agent)"]}),e.jevRoute&&"routing"!==e.jevRoute.status&&(0,n.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:[(0,n.jsx)("p",{children:E(e.jevRoute,e.model)}),e.jevRoute.reason&&(0,n.jsxs)("p",{children:["自動選擇未完成:",e.jevRoute.reason]}),e.jevRoute.context&&(0,n.jsxs)("details",{children:[(0,n.jsxs)("summary",{className:"cursor-pointer select-none",children:["前置分析(",e.jevRoute.scoutModel??"高思考模型",")"]}),(0,n.jsx)("div",{className:"mt-2 text-foreground",children:(0,n.jsx)(eV.h,{source:e.jevRoute.context,compact:!0})})]})]}),r&&(0,n.jsxs)("button",{type:"button",onClick:()=>a?.(r.id),title:"開啟 master 卡片",className:"flex w-full items-center gap-2 rounded-md border border-master/30 bg-master/5 p-2.5 text-left text-sm outline-none transition-colors motion-reduce:transition-none hover:bg-master/10 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(b.A,{className:"size-3.5 shrink-0 text-master"}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"屬於"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:r.title}),(0,n.jsx)(eT.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),i?(0,n.jsx)("div",{className:"space-y-1.5 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(eI.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 break-all font-mono text-xs",children:e.worktreePath??e.workDir??"開始執行時建立專屬資料夾"})]})}):(0,n.jsxs)("div",{className:"space-y-1.5 rounded-md bg-muted/30 p-2.5 text-sm text-muted-foreground",children:[e.projectName&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(j.A,{className:"size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:e.projectName})]}),(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(w.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 break-all",children:[e.branch,"done"!==t&&!e.worktreePath&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:"backlog"===t?"(開始執行時建立)":"(建立中…)"})]})]}),e.baseBranch&&(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(eR.A,{className:"mt-0.5 size-3.5 shrink-0"}),(0,n.jsxs)("span",{className:"min-w-0 break-all",children:["base: ",e.baseBranch]})]})]}),e.description&&(0,n.jsx)(eV.h,{source:e.description}),"backlog"!==t&&(0,n.jsx)(ei,{progress:"in_progress"===t?s:null,usage:e.usage}),e.outcome&&(0,n.jsx)(t3,{outcome:e.outcome})]})}function t6({specs:e}){return(0,n.jsx)("div",{className:"space-y-6",children:e.map(e=>(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.path}),(0,n.jsx)(eV.h,{source:e.markdown,className:"bg-transparent p-0"}),e.truncated&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"內容過長,僅顯示前段。"}),null!=e.updatedAt&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground tabular-nums",children:["更新於 ",new Date(e.updatedAt).toLocaleString()]})]},e.path))})}function t7({taskId:e,artifact:t}){let[s,a]=(0,r.useState)(null),[i,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let s=!0;return a(null),l(!1),(0,F.R9)(e,t.name).then(e=>{s&&a(e?.dataUrl??null)}).catch(()=>{s&&a(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]);let o="video"===t.kind;return!s||i?(0,n.jsx)("div",{className:"flex h-24 items-center justify-center rounded-md border border-border/70 bg-card",children:o?(0,n.jsx)(eD.A,{className:"size-5 text-muted-foreground"}):(0,n.jsx)(eA.A,{className:"size-5 text-muted-foreground"})}):o?(0,n.jsxs)("div",{className:"relative h-24 w-full overflow-hidden rounded-md border border-border/70 bg-card",children:[(0,n.jsx)("video",{src:s,muted:!0,playsInline:!0,preload:"metadata",onError:()=>l(!0),className:"h-full w-full object-contain"}),(0,n.jsx)("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,n.jsx)("span",{className:"flex size-7 items-center justify-center rounded-full bg-background/80 ring-1 ring-border/70",children:(0,n.jsx)(eK.A,{className:"size-3.5 fill-current text-foreground"})})})]}):(0,n.jsx)("img",{src:s,alt:t.name,className:"h-24 w-full rounded-md border border-border/70 bg-card object-contain"})}function t8({taskId:e,artifact:t,onClose:s}){var a;let[i,l]=(0,r.useState)(void 0),[o,c]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=!0;return l(void 0),c(!1),(0,F.R9)(e,t.name).then(e=>{s&&l(e)}).catch(()=>{s&&l(null)}),()=>{s=!1}},[e,t.name,t.modifiedAt]),(0,n.jsx)(tt.h,{title:t.name,description:`${tI[t.kind]} \xb7 ${t0(t.size)}${t.scratch?" \xb7 工作暫存":""}`,onClose:s,showHeader:!0,contentClassName:"max-w-5xl",bodyClassName:"p-4",children:void 0===i?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取中…"]}):null===i?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案,可能已被刪除。"}):"image"===i.kind&&i.dataUrl?(0,n.jsx)(ts.p,{src:i.dataUrl,alt:t.name}):"video"===i.kind&&i.dataUrl?o?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"這個影片的編碼無法在 app 內播放。用 Artifacts 分頁的「開啟資料夾」以系統播放器開啟。"}):(0,n.jsx)("video",{src:i.dataUrl,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,onError:()=>c(!0),className:"max-h-[70vh] w-full rounded-md bg-black"}):"binary"===i.kind?(0,n.jsxs)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:["無法內嵌預覽的檔案(",t0(t.size),")。用 Artifacts 分頁的「開啟資料夾」以系統播放器或編輯器開啟。"]}):(0,n.jsxs)(n.Fragment,{children:[(a=t.name,/\.(md|markdown|mdx)$/i.test(a))?(0,n.jsx)(eV.h,{source:i.text??""}):(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded-md bg-muted/30 p-3 font-mono text-xs",children:i.text}),i.truncated&&(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"內容過長,僅顯示開頭 256 KB。"})]})})}function t9({taskId:e,artifacts:t,artifactsDir:s}){let[a,i]=(0,r.useState)(null),[o,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)("idle"),[m,x]=(0,r.useState)(null),h=t.filter(t1),f=t.filter(e=>!t1(e)),p=(0,r.useCallback)(()=>{x(null),(0,F.lr)(e).then(e=>x(e||null)).catch(()=>x("開啟失敗"))},[e]),g=(0,r.useCallback)(()=>{s&&navigator.clipboard.writeText(s).then(()=>{u("copied"),window.setTimeout(()=>u("idle"),1600)}).catch(()=>u("error"))},[s]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-3 space-y-2 rounded-md border border-border/70 bg-muted/20 p-2.5",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Artifact 資料夾"}),(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("code",{className:"min-w-0 flex-1 select-all break-all rounded-xs bg-background px-2 py-1.5 font-mono text-xs text-foreground",title:s??"尚無可用路徑",children:s??"尚無可用路徑"}),(0,n.jsxs)(eH.$,{variant:"outline",size:"sm",onClick:g,disabled:!s,title:"複製 Artifact 資料夾路徑",className:"shrink-0 text-xs",children:[(0,n.jsx)(tS,{copied:"copied"===d}),"copied"===d?"已複製":"error"===d?"複製失敗":"複製路徑"]})]})]}),(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-end gap-2",children:[m&&(0,n.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",title:m,children:m}),(0,n.jsxs)(eH.$,{variant:"outline",size:"sm",onClick:p,title:s??"任務的 artifacts 目錄",className:"text-xs",children:[(0,n.jsx)(eI.A,{className:"size-3.5"}),"開啟資料夾"]})]}),0===t.length?(0,n.jsxs)("div",{className:"space-y-2 py-8 text-center",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"還沒有暫存產物。"}),(0,n.jsxs)("p",{className:"text-xs leading-5 text-muted-foreground/80",children:["驗證截圖、錄影與報告可放在上方資料夾,工作暫存可放在其下的 ",(0,n.jsx)("code",{className:"rounded-xs bg-muted/40 px-1 py-0.5 font-mono",children:"scratch/"}),",完成任務時會一併清除。"]})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[h.length>0?(0,n.jsx)("ul",{className:"grid grid-cols-2 gap-2",children:h.map(t=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(t),title:t.name,className:"w-full rounded-md border border-border/70 bg-muted/20 p-2 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(t7,{taskId:e,artifact:t}),(0,n.jsxs)("div",{className:"mt-1.5 flex items-baseline gap-1.5",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.name}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:t0(t.size)})]})]})},t.name))}):(0,n.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"還沒有驗證截圖或錄影。"}),f.length>0&&(0,n.jsxs)("div",{className:"rounded-md border border-border/70",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>c(e=>!e),"aria-expanded":o,className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)(eT.A,{className:(0,R.cn)("size-3.5 shrink-0 transition-transform motion-reduce:transition-none",o&&"rotate-90")}),"其他 ",f.length," 個檔案(報告、script、log)"]}),o&&(0,n.jsx)("ul",{className:"border-t border-border/70",children:f.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e),title:e.name,className:"flex w-full items-center gap-2 px-2 py-1 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:["image"===e.kind?(0,n.jsx)(eA.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):"video"===e.kind?(0,n.jsx)(eD.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,n.jsx)(ez.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:e.name}),(0,n.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/80",children:[function(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return"剛剛";if(t<60)return`${t} 分前`;let s=Math.floor(t/60);return s<24?`${s} 小時前`:`${Math.floor(s/24)} 天前`}(e.modifiedAt)," \xb7 ",t0(e.size)]})]})},e.name))})]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(t8,{taskId:e,artifact:a,onClose:()=>i(null)},`artifact-${e}-${a.name}`)})]})}function se({slaves:e,progressById:t,onSelectTask:s}){if(0===e.length)return(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"Master 還沒有建立任何 slave 卡片。"});let r=e.filter(e=>"done"===e.column).length;return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[e.length," 張卡片 \xb7 ",r," 完成"]}),(0,n.jsx)("ul",{className:"space-y-1.5",children:e.map(({task:e,column:r})=>{let a=t[e.id],i=ej(r,e,a),l="in_progress"===r?ev(a):null,o="in_progress"===r?a?.todos?.find(e=>"in_progress"===e.status):void 0,c=e.outcome?.pr;return(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>s?.(e.id),title:`開啟:${e.title}`,className:"w-full rounded-md border border-border/70 bg-muted/20 px-2.5 py-2 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(ee,{...i}),(0,n.jsx)(eb,{id:e.id}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:i.label}),l&&(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:l})]}),(0,n.jsxs)("div",{className:"mt-1 flex items-center gap-2 pl-3.5 text-xs text-muted-foreground",children:[(0,n.jsx)(j.A,{className:"size-3 shrink-0"}),(0,n.jsx)("span",{className:"max-w-[45%] shrink-0 truncate",children:ex(e)}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"backlog"===r&&e.launchError?e.launchError:o?o.activeForm??o.content:e.branch}),c&&(0,n.jsxs)("span",{className:"shrink-0",children:["PR #",c.number]})]})]})},e.id)})})]})}let st=(0,r.memo)(function({file:e,showHeader:t=!0}){let{split:s,fullContext:a}=tU();return(0,n.jsxs)("div",{className:(0,R.cn)("overflow-hidden",t&&"rounded-md border border-border/70"),children:[t&&(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/70 bg-muted/30 px-2 py-1.5",children:[(0,n.jsx)("span",{className:"rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:tT[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),e.truncated&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:"已截斷"})]}),(0,n.jsx)("div",{className:"min-w-0 max-w-full overflow-x-auto text-xs [&_.diff-content]:whitespace-pre-wrap [&_.diff-content]:break-words [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_table]:min-w-full [&_table]:table-fixed [&_td]:min-w-0 [&_td]:align-top",children:(0,n.jsx)(r.Suspense,{fallback:null,children:(0,n.jsx)(tz,{oldValue:e.oldValue,newValue:e.newValue,splitView:s,showDiffOnly:!a,useDarkTheme:!0,compareMethod:"diffLines",renderContent:e=>(0,n.jsx)("span",{className:"block min-w-0 max-w-full whitespace-pre-wrap break-words",children:e}),styles:{variables:{dark:{diffViewerBackground:"var(--card)",diffViewerColor:"var(--card-foreground)",addedBackground:"rgba(78, 201, 138, 0.15)",addedColor:"var(--foreground)",removedBackground:"rgba(229, 72, 77, 0.15)",removedColor:"var(--foreground)",wordAddedBackground:"rgba(78, 201, 138, 0.32)",wordRemovedBackground:"rgba(229, 72, 77, 0.32)",addedGutterBackground:"rgba(78, 201, 138, 0.20)",removedGutterBackground:"rgba(229, 72, 77, 0.20)",gutterBackground:"var(--muted)",gutterBackgroundDark:"var(--muted)",gutterColor:"var(--muted-foreground)",addedGutterColor:"var(--foreground)",removedGutterColor:"var(--foreground)",highlightBackground:"rgba(76, 155, 245, 0.15)",highlightGutterBackground:"rgba(76, 155, 245, 0.20)",codeFoldGutterBackground:"var(--muted)",codeFoldBackground:"var(--secondary)",codeFoldContentColor:"var(--muted-foreground)",emptyLineBackground:"var(--card)"}},diffContainer:{width:"100%",maxWidth:"100%",overflowX:"visible"},line:{width:"100%"},content:{width:"100%",maxWidth:"100%",overflowX:"visible"},contentText:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},lineContent:{display:"block",width:"100%",maxWidth:"100%",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},gutter:{maxWidth:"2.5rem",minWidth:"2.5rem",width:"2.5rem",paddingLeft:"0.25rem",paddingRight:"0.25rem",whiteSpace:"nowrap"}}})})})]})});function ss(){let{split:e,fullContext:t}=tU(),s=e=>(0,R.cn)("rounded-sm px-2 py-1 text-xs outline-none transition-colors motion-reduce:transition-none",e?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground");return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("div",{role:"group","aria-label":"Diff 版面",className:"flex rounded-md border border-border/70 p-0.5",children:[(0,n.jsx)("button",{type:"button","aria-pressed":!e,onClick:()=>tW({split:!1}),className:(0,R.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",s(!e)),children:"整合"}),(0,n.jsx)("button",{type:"button","aria-pressed":e,onClick:()=>tW({split:!0}),className:(0,R.cn)("focus-visible:ring-[3px] focus-visible:ring-ring/50",s(e)),children:"左右對照"})]}),(0,n.jsx)("button",{type:"button","aria-pressed":t,onClick:()=>tW({fullContext:!t}),title:t?"只顯示變更附近的行":"顯示檔案的所有行",className:(0,R.cn)("border border-border/70 focus-visible:ring-[3px] focus-visible:ring-ring/50",s(t)),children:t?"收合未變更":"全部展開"})]})}function sn({entry:e,file:t,onClose:s}){return(0,n.jsx)(tt.h,{title:e.path,description:(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{children:tT[e.status]??e.status}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"font-mono tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),t?.truncated&&(0,n.jsx)("span",{children:"\xb7 已截斷"})]}),onClose:s,showHeader:!0,contentClassName:"max-w-6xl",bodyClassName:"p-4",children:void 0===t?(0,n.jsxs)("div",{className:"flex h-40 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取內容中…"]}):null===t?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"讀不到這個檔案的內容。"}):(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)(ss,{}),(0,n.jsx)(st,{file:t,showHeader:!1})]})})}function sr({diff:e}){return(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(T.K,{"aria-label":"重新整理 Git diff",title:"重新整理(含 fetch origin)",className:"p-1",disabled:e.loading,onClick:e.manualRefresh,children:(0,n.jsx)(eB.A,{className:(0,R.cn)("size-3.5",e.loading&&"animate-spin")})}),e.entries.length>0&&(0,n.jsx)(T.K,{"aria-label":"放大檢視 Git diff",title:"放大檢視(全部展開)",className:"p-1",onClick:e.expand,children:(0,n.jsx)(eF.A,{className:"size-3.5"})})]})}function sa({taskId:e,diff:t}){let{entries:s,contents:r,selectedEntry:a,setSelectedPath:i,loading:o,error:c,expanded:d,fullFiles:u,closeExpanded:m}=t;return(0,n.jsxs)(n.Fragment,{children:[o&&0===s.length?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取 diff 中…"]}):c?(0,n.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm",children:c}):0===s.length?(0,n.jsx)("p",{className:"py-10 text-center text-sm text-muted-foreground",children:"與基準分支相比沒有變更。"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("ul",{className:"space-y-1",children:s.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>i(e.path),title:`檢視 ${e.path} 的 diff`,className:"flex w-full items-center gap-2 rounded-md border border-border/70 bg-muted/30 px-2 py-1.5 text-left outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,n.jsx)("span",{className:"shrink-0 rounded-xs bg-secondary px-1.5 py-0.5 text-xs font-medium text-secondary-foreground",children:tT[e.status]??e.status}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e.path,children:e.path}),(e.additions>0||e.deletions>0)&&(0,n.jsxs)("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[(0,n.jsxs)("span",{className:"text-success",children:["+",e.additions]}),(0,n.jsxs)("span",{className:"ml-1 text-destructive",children:["−",e.deletions]})]}),(0,n.jsx)(eT.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]})},e.path))}),s.length>=80&&(0,n.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["變更檔案超過 ",80," 個,僅顯示前 ",80," 個。"]})]}),(0,n.jsx)(l.N,{children:a&&(0,n.jsx)(sn,{entry:a,file:a.path in r?r[a.path]:void 0,onClose:()=>i(null)},`diff-${e}-${a.path}`)}),d&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex bg-background/95 text-foreground",children:(0,n.jsxs)("div",{className:"flex min-h-0 w-full flex-col",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border px-5",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Git diff"}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[s.length," changed ",1===s.length?"file":"files"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(ss,{}),(0,n.jsx)(T.K,{"aria-label":"關閉 diff 放大檢視",title:"關閉",onClick:m,children:(0,n.jsx)(eM.A,{className:"size-4"})})]})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:(0,n.jsx)("div",{className:"mx-auto w-full max-w-6xl space-y-4",children:null===u?(0,n.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3.5 animate-spin"}),"讀取全部 diff 內容中…"]}):u.map(e=>(0,n.jsx)(st,{file:e},e.path))})})]})})]})}function si({task:e,column:t,progress:s,launch:a,onStart:i,onReturnToBacklog:l,onLaunchAgent:o,onComplete:c,onEdit:d,onDelete:u,active:m=!0,slaves:f=[],progressById:p={},master:g=null,onSelectTask:j}){var v;let N="master"===e.role,[y,k]=(0,r.useState)(null),[C,A]=(0,r.useState)([]),$=(0,r.useId)(),E=(0,r.useId)(),P=`${$}-panel`,I=e=>`${$}-tab-${e}`,K=e.worktreePath??e.projectPath??(N?e.workDir??e.workspacePath:void 0)??null,B="in_progress"!==t||e.worktreePath?null:N?"正在準備 master 的工作資料夾,完成後 agent 會自動啟動…":`正在準備工作環境:從最新的 ${e.baseBranch??"基準分支"} 建立分支 ${e.branch} 與 worktree,有 remote 時會一併推送到 origin。第一次開始執行需要幾秒鐘,完成後 agent 會自動啟動…`,M=function(e,t){let s,n;if(!e||!t)return null;let r=t.replace(/\\/g,"/"),a=(n=(s=e.replace(/\\/g,"/").replace(/\/+$/,"")).lastIndexOf("/"))>=0?s.slice(n+1):s;return`${r}/${a}.artifacts`}(e.worktreePath,e.workspacePath),_=function(e,t){let[s,n]=(0,r.useState)([]),[a,i]=(0,r.useState)({}),[l,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),[x,h]=(0,r.useState)(0),[f,p]=(0,r.useState)(!1),[g,b]=(0,r.useState)(null),j=(0,r.useRef)(new Map),v=(0,r.useCallback)(e=>{let t=new Set(e.map(e=>e.path));for(let e of j.current.keys())t.has(e)||j.current.delete(e);n(t=>(function(e,t){if(e.length!==t.length)return t;let s=!1,n=t.map((t,n)=>{let r=e[n];return tw(r,t)?r:(s=!0,t)});return s?n:e})(t,e)),i(t=>{let s;return s=new Set(e.map(e=>e.path)),Object.keys(t).every(e=>s.has(e))?t:Object.fromEntries(Object.entries(t).filter(([e])=>s.has(e)))})},[]),N=s.find(e=>e.path===l)??null;(0,r.useEffect)(()=>{if(!N)return;let t=N.path,s=j.current.get(t);if(t in a&&s&&tw(s,N))return;let n=!0;return(0,F.sQ)(e,t).then(e=>{n&&(j.current.set(t,N),i(s=>{var n;return(n=s[t])===e||n&&e&&n.path===e.path&&n.status===e.status&&n.additions===e.additions&&n.deletions===e.deletions&&n.oldValue===e.oldValue&&n.newValue===e.newValue&&n.truncated===e.truncated?s:{...s,[t]:e}}))}).catch(()=>{n&&(j.current.set(t,N),i(e=>null===e[t]?e:{...e,[t]:null}))}),()=>{n=!1}},[e,N,a]),(0,r.useEffect)(()=>{let s;if(!t)return;let n=!0,r=!1,a=async t=>{if(r&&(0,tk.o)()){n&&(s=setTimeout(()=>void a(!1),3e3));return}r=!0;try{let s=await (0,F.Wc)(e,{fetch:t});if(!n)return;v(s),m(null)}catch(e){n&&m(e instanceof Error?e.message:String(e))}finally{n&&(d(!1),s=setTimeout(()=>void a(!1),3e3))}};return d(!0),a(!0),()=>{n=!1,s&&clearTimeout(s)}},[e,t,x,v]),(0,r.useEffect)(()=>{l&&!s.some(e=>e.path===l)&&o(null)},[s,l]),(0,r.useEffect)(()=>{if(!f)return;let t=!0;return(0,F.Gw)(e).then(e=>{t&&b(e)}).catch(e=>{t&&m(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[f,e]);let y=(0,r.useCallback)(()=>{p(!1),b(null)},[]);return{entries:s,contents:a,selectedEntry:N,setSelectedPath:o,loading:c,error:u,expanded:f,fullFiles:g,expand:(0,r.useCallback)(()=>p(!0),[]),closeExpanded:y,manualRefresh:(0,r.useCallback)(()=>{i({}),j.current.clear(),h(e=>e+1)},[])}}(e.id,"in_progress"===t&&!N),L=function(e,t,s){let[n,a]=(0,r.useState)([]);return(0,r.useEffect)(()=>{let n;if(a([]),!t)return;let r=!0,i=!1,l=async()=>{if(i&&(0,tk.o)()){r&&s&&(n=setTimeout(()=>void l(),3e3));return}i=!0;try{let t=await (0,F.ly)(e);r&&a(t)}catch{}finally{r&&s&&(n=setTimeout(()=>void l(),3e3))}};return l(),()=>{r=!1,n&&clearTimeout(n)}},[e,t,s]),n}(e.id,"backlog"!==t&&!N,"in_progress"===t&&!N),V=C.filter(t1).length;(0,r.useEffect)(()=>{let s;if("in_progress"!==t)return void A([]);let n=!0,r=!1,a=async()=>{if(r&&(0,tk.o)()){n&&(s=setTimeout(()=>void a(),3e3));return}r=!0;try{let t=await (0,F.wn)(e.id);n&&A(t)}catch{}finally{n&&(s=setTimeout(()=>void a(),3e3))}};return a(),()=>{n=!1,s&&clearTimeout(s)}},[e.id,t]);let G="backlog"===t,O=a?.launch,H=a?.nonce??0,Y=(N?(v=f.length>0,"in_progress"===t?["slaves","task","artifacts"]:v?["slaves","task"]:["task"]):"done"===t?tE:"backlog"===t?tP:t$).filter(e=>"spec"!==e||L.length>0),W="done"===t&&Y.includes("spec")?"spec":Y[0],J=y&&Y.includes(y)?y:W,U=e=>"artifacts"===e?V:"diff"===e?_.entries.length:"slaves"===e?f.length:0,q=(0,n.jsx)(z.o,{id:`${E}-strip`,children:(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視",className:"flex min-w-0 rounded-md border border-border/70 p-0.5",children:Y.map(e=>{let t=U(e);return(0,n.jsxs)("button",{type:"button",role:"tab",id:I(e),"aria-selected":J===e,"aria-controls":P,onClick:()=>{k(e)},className:(0,R.cn)("relative isolate shrink-0 rounded-sm px-2 py-0.5 text-xs outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",J===e?"text-primary":"text-muted-foreground hover:text-foreground"),children:[J===e&&(0,n.jsx)(D,{layoutId:"task-tab",className:"inset-0 -z-10 rounded-sm bg-primary/15"}),tA[e],t>0&&(0,n.jsx)("span",{className:"ml-1 tabular-nums text-muted-foreground/80",children:t})]},e)})})}),X="slaves"===J?(0,n.jsx)(se,{slaves:f,progressById:p,onSelectTask:j}):"task"===J?(0,n.jsx)(t4,{task:e,column:t,progress:s,master:g,onSelectTask:j}):"spec"===J?(0,n.jsx)(t6,{specs:L}):"artifacts"===J?(0,n.jsx)(t9,{taskId:e.id,artifacts:C,artifactsDir:M}):(0,n.jsx)(sa,{taskId:e.id,diff:_}),Q=(0,n.jsx)("div",{role:"tabpanel",id:P,"aria-labelledby":I(J),className:"h-full",children:X}),Z=(0,r.useSyncExternalStore)(tV,t_,()=>"docked"),ee=(0,r.useSyncExternalStore)(tX,()=>window.matchMedia(tq).matches,()=>!0),et=ee&&"docked"===Z,[es,er]=(0,r.useState)(!1),ea=et||es,ei=(0,n.jsx)(t5,{title:tA[J],count:U(J),actions:(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:["diff"===J&&(0,n.jsx)(sr,{diff:_}),et?(0,n.jsx)(T.K,{"aria-label":"收合側欄",title:"收合成圖示列,讓終端機佔滿寬度",className:"p-1",onClick:()=>tL("rail"),children:(0,n.jsx)(e_.A,{className:"size-3.5"})}):(0,n.jsxs)(n.Fragment,{children:[ee&&(0,n.jsx)(T.K,{"aria-label":"固定側欄",title:"固定在終端機旁",className:"p-1",onClick:()=>{er(!1),tL("docked")},children:(0,n.jsx)(eL.A,{className:"size-3.5"})}),(0,n.jsx)(T.K,{"aria-label":"關閉側欄",className:"p-1",onClick:()=>er(!1),children:(0,n.jsx)(eM.A,{className:"size-3.5"})})]})]}),children:Q}),el=(0,n.jsx)(z.o,{id:`${E}-rail`,children:(0,n.jsx)("div",{role:"tablist","aria-label":"任務檢視","aria-orientation":"vertical",className:"flex w-11 shrink-0 flex-col items-center gap-1 border-l border-border bg-card/40 py-1.5",children:Y.map(e=>{let t=tK[e],s=U(e),r=ea&&J===e;return(0,n.jsxs)("button",{type:"button",role:"tab",id:I(e),"aria-selected":r,"aria-controls":P,"aria-label":s>0?`${tA[e]}(${s})`:tA[e],title:tA[e],onClick:()=>{var t;return t=e,void(ea&&t===J?et?tL("rail"):er(!1):(k(t),et||er(!0)))},className:(0,R.cn)("relative isolate flex size-8 items-center justify-center rounded-md outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",r?"text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[r&&(0,n.jsx)(D,{layoutId:"task-rail-tab",className:"inset-0 -z-10 rounded-md bg-primary/15"}),(0,n.jsx)(t,{className:"size-4"}),s>0&&(0,n.jsx)("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-semibold tabular-nums text-primary-foreground",children:s})]},e)})})}),[eo,ed]=(0,r.useState)("idle"),eu=(0,r.useRef)(null),em=(0,r.useRef)(null),ex=(0,r.useRef)(null);(0,r.useLayoutEffect)(tZ,[]);let eh=(e,t)=>{let s,n=Math.round(Math.max(336,Math.min(e,Math.max(336,(s=eu.current?.clientWidth??0)>0?s-320-10-44:e))));document.documentElement.style.setProperty(tD,`${n}px`),t&&window.localStorage.setItem(tR,String(n))},ef=()=>{if(!ex.current)return;ex.current=null;let e=em.current?.getBoundingClientRect().width??0;e>0&&eh(e,!0)},ep=e=>{let t=em.current?.getBoundingClientRect().width??0;t<=0||eh(t+e,!0)},eg=(0,n.jsx)(ec,{"aria-label":"按住刪除任務",title:"按住以刪除任務(清理 worktree)",onConfirm:()=>u(e.id),className:"inline-flex shrink-0 items-center justify-center rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-destructive/15 hover:text-destructive",children:(0,n.jsx)(h.A,{className:"size-4"})});return"in_progress"===t?(0,n.jsx)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden bg-background text-foreground",children:(0,n.jsxs)("main",{ref:eu,className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,n.jsxs)("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",onPointerDown:()=>er(!1),children:(0,n.jsx)(te,{taskId:e.id,cwd:K,launchCommand:O,launchNonce:H,provisionNotice:B,readOnly:!1,onReturnToBacklog:()=>l(e),onLaunchAgent:()=>o(e),active:m,toolbarStart:(0,n.jsxs)(n.Fragment,{children:[N?(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 rounded-xs bg-master/15 px-1.5 py-0.5 text-xs font-medium text-master",children:[(0,n.jsx)(b.A,{className:"size-3 shrink-0"}),"Master"]}):(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 rounded-xs bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",title:e.branch,children:[(0,n.jsx)(w.A,{className:"size-3 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"truncate",children:e.branch})]}),e.baseBranch&&(0,n.jsxs)("span",{className:"min-w-0 shrink truncate font-mono text-xs text-muted-foreground",title:`基準分支:${e.baseBranch}`,children:["← ",e.baseBranch]}),(0,n.jsx)(T.K,{"aria-label":"copied"===eo?"已複製 worktree 路徑":"error"===eo?"複製 worktree 路徑失敗":"複製 worktree 路徑",title:K??void 0,className:"p-1",disabled:!K,onClick:()=>{K&&navigator.clipboard.writeText(K).then(()=>ed("copied")).catch(()=>ed("error")).finally(()=>window.setTimeout(()=>ed("idle"),1600))},children:(0,n.jsx)(tS,{copied:"copied"===eo})}),(0,n.jsx)(en,{progress:s})]}),toolbarEnd:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-4 w-px shrink-0 bg-border"}),(0,n.jsxs)(eH.$,{size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:()=>{c(e)},title:"標記完成後會清理 PTY 與 worktree",children:[(0,n.jsx)(S.A,{className:"size-3.5"}),"完成"]}),eg]})})}),!et&&es&&(0,n.jsx)("aside",{"aria-label":tA[J],onKeyDown:e=>{"Escape"!==e.key||(0,tk.o)()||er(!1)},className:"absolute bottom-0 right-0 top-10 z-20 flex w-[min(var(--vf-workspace-aside,24rem),calc(100%-2rem))] flex-col border-l border-border bg-card shadow-xl xl:w-[min(var(--vf-workspace-aside,27rem),calc(100%-2rem))]",children:ei})]}),et&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"調整終端機與側邊面板的寬度",tabIndex:0,onPointerDown:e=>{let t=em.current?.getBoundingClientRect().width??0;t<=0||(ex.current={x:e.clientX,width:t},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=ex.current;t&&eh(t.width-(e.clientX-t.x),!1)},onPointerUp:ef,onPointerCancel:ef,onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),ep(24)):"ArrowRight"===e.key&&(e.preventDefault(),ep(-24))},className:"flex w-2.5 shrink-0 cursor-col-resize items-center justify-center border-x border-border bg-card outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,n.jsx)("span",{className:"h-12 w-0.5 rounded-full bg-input"})}),(0,n.jsx)("aside",{ref:em,className:"flex min-h-0 w-[var(--vf-workspace-aside,24rem)] min-w-0 max-w-[calc(100%-23.375rem)] shrink-0 flex-col bg-card/40 xl:w-[var(--vf-workspace-aside,27rem)]",children:ei})]}),el]})}):(0,n.jsxs)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden bg-background text-foreground",children:[(0,n.jsxs)("header",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[N?(0,n.jsx)(b.A,{className:"size-3.5 shrink-0 text-master"}):(0,n.jsx)(w.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"min-w-0 truncate text-base font-semibold",children:e.title})]})}),G&&(0,n.jsxs)(eH.$,{size:"sm",variant:"outline",onClick:()=>{i(e)},disabled:!K,children:[(0,n.jsx)(eK.A,{className:"size-3.5"}),"開始"]}),"backlog"===t&&(0,n.jsx)(T.K,{"aria-label":"編輯任務",title:"編輯任務",onClick:()=>{d(e.id)},children:(0,n.jsx)(x.A,{className:"size-4"})}),eg]}),(0,n.jsx)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-card/40",children:"backlog"===t&&1===Y.length?(0,n.jsx)(t5,{title:tA.task,children:(0,n.jsx)(t4,{task:e,column:t,progress:s,master:g,onSelectTask:j})}):(0,n.jsx)(t5,{heading:q,children:Q})})]})}var sl=s(26814),so=s(6684),sc=s(37744);let sd={backlog:"Backlog",in_progress:"In Progress",done:"Done"};function su(e,t){return"backlog"===t?{dot:"bg-muted-foreground/60",label:sd.backlog}:"done"===t?{dot:"bg-success",label:sd.done}:et(e?.activity)}function sm({branch:e}){return(0,n.jsx)("span",{"aria-hidden":"true",className:(0,R.cn)("pointer-events-none absolute -top-1 left-[18px] w-2.5 border-l border-master/50","last"===e?"h-6":"-bottom-1"),children:(0,n.jsx)("span",{className:"absolute left-0 top-[23px] w-full border-t border-master/50"})})}function sx({running:e,viewing:t,selectedTaskId:s,progress:r,onSelect:a,collapsed:i,onCollapsedChange:l}){let o,c=(o=new Set(e.map(e=>e.id)),e.filter(e=>!(e.masterId&&o.has(e.masterId))).flatMap(t=>{let s=e.filter(e=>e.masterId===t.id);return[{task:t,branch:"none"},...s.map((e,t)=>({task:e,branch:t===s.length-1?"last":"middle"}))]}));if(i)return(0,n.jsxs)("nav",{"aria-label":"進行中的任務",className:"flex w-11 shrink-0 flex-col items-center gap-1 overflow-y-auto border-r border-border bg-card/40 py-1.5",children:[(0,n.jsx)(T.K,{"aria-label":"展開任務清單",title:"展開任務清單",className:"mb-1 size-8 rounded-md",onClick:()=>l(!1),children:(0,n.jsx)(sl.A,{className:"size-4"})}),[...t?[{task:t.task,column:t.column}]:[],...c.map(({task:e})=>({task:e,column:"in_progress"}))].map(({task:e,column:t})=>{let i=e.id===s;return(0,n.jsx)("button",{type:"button","aria-label":e.title,"aria-current":i?"page":void 0,title:e.title,onClick:()=>a(e.id),className:(0,R.cn)("flex size-8 shrink-0 items-center justify-center rounded-md outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",i?"bg-primary/15":"hover:bg-accent"),children:(0,n.jsx)(ee,{...su(r[e.id],t),className:"size-2"})},e.id)})]});let d=(e,t,i)=>{let l=e.id===s,o="master"===e.role,c=(0,n.jsxs)("button",{type:"button","aria-current":l?"page":void 0,title:e.title,onClick:()=>a(e.id),className:(0,R.cn)("flex w-full min-w-0 flex-col gap-1 rounded-md border px-2.5 py-2 text-left outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",l?"border-primary/60 bg-accent text-foreground":"border-transparent text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-sm font-medium text-foreground",children:[o?(0,n.jsx)(b.A,{className:"size-3.5 shrink-0 text-master"}):(0,n.jsx)("span",{className:"flex w-3.5 shrink-0 justify-center",children:(0,n.jsx)(ee,{...su(r[e.id],t)})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title}),(0,n.jsx)(eb,{id:e.id,className:"font-normal"})]}),(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2 pl-[22px] text-xs",children:[(0,n.jsx)("span",{className:"min-w-0 truncate",children:"in_progress"===t?o?"Master":e.projectName??"":sd[t]}),"in_progress"===t&&(0,n.jsx)(en,{progress:r[e.id],mark:o})]})]},e.id);return"none"===i?c:(0,n.jsxs)("div",{className:"relative pl-7",children:[(0,n.jsx)(sm,{branch:i}),c]},e.id)};return(0,n.jsxs)("nav",{"aria-label":"進行中的任務",className:"flex w-64 shrink-0 flex-col border-r border-border bg-card/40",children:[(0,n.jsxs)("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b border-border pl-3 pr-1.5",children:[(0,n.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-warning"}),(0,n.jsx)("h2",{className:(0,R.cn)(P,"text-warning"),children:"In Progress"}),(0,n.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground/80",children:e.length}),(0,n.jsx)("span",{className:"flex-1"}),(0,n.jsx)(T.K,{"aria-label":"收合任務清單",title:"收合任務清單,讓終端機更寬",className:"p-1",onClick:()=>l(!0),children:(0,n.jsx)(so.A,{className:"size-3.5"})})]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto p-1.5",children:[t&&(0,n.jsxs)("div",{className:"mb-2 space-y-1 border-b border-border pb-2",children:[(0,n.jsxs)("p",{className:"flex items-center gap-1.5 px-1 text-xs text-muted-foreground",children:[(0,n.jsx)(sc.A,{className:"size-3"}),"目前檢視"]}),d(t.task,t.column,"none")]}),c.map(({task:e,branch:t})=>d(e,"in_progress",t)),0===c.length&&(0,n.jsx)("p",{className:"px-2 py-3 text-sm text-muted-foreground",children:"目前沒有進行中的任務"})]})]})}function sh(){let e;return("boolean"==typeof(e=tj(tx))?e:null)??!window.matchMedia("(min-width: 1280px)").matches}function sf({active:e,children:t}){let s=(0,o.E)(),a=(0,c.I)()??!1,i=(0,I.n)({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:a});return(0,r.useEffect)(()=>{s.stop(),s.set("hidden"),e&&s.start("visible")},[e,s,a]),(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:s,variants:i,inert:!e,"aria-hidden":!e||void 0,className:(0,R.cn)("h-full",!e&&"hidden pointer-events-none"),children:t})}function sp({board:e,onBoardChange:t,onEditTask:s,onTaskDone:a,onDeleteTask:i,onOpenTaskTerminal:o,taskTerminals:x,onShowTaskTerminal:h,progress:f,selectedTaskId:p,onSelectTask:g,onNewTask:b,view:j,onViewChange:v,githubView:N,taskLinks:y}){let[w,k]=(0,r.useState)(new Set),[C,S]=(0,r.useState)({}),z=(0,r.useRef)(C);z.current=C;let A=(0,c.I)()??!1,$=(0,I.n)({timing:"standard",initialOpacity:.96,transform:{x:4},reducedMotion:A}),E=e=>k(t=>t.has(e)?t:new Set(t).add(e)),[P,T]=(0,r.useState)(null),D=async(e,t={})=>{E(e.id),S(s=>({...s,[e.id]:{launch:t,nonce:(s[e.id]?.nonce??0)+1}}))};(0,r.useEffect)(()=>{if(!p||(E(p),C[p]))return;let t=e.in_progress.find(e=>e.id===p);if(!t||null==t.launchedAt||!t.worktreePath)return;let s=!1;return(0,F.Vc)(t.id).then(e=>{s||!e||z.current[t.id]||D(t,{resume:!0})}),()=>{s=!0}},[p]);let K=s=>{let n={...s,launchedAt:Date.now()};t({backlog:e.backlog.filter(e=>e.id!==s.id),in_progress:[n,...e.in_progress],done:e.done}),D(n)},M=async e=>(await _(e),!0),_=async e=>{let s=await (0,F.WL)(e.id);if(!s)throw Error("未連線到 VibeFlow core");let n=s.state.board;t({backlog:[s.task,...n.backlog.filter(t=>t.id!==e.id)],in_progress:n.in_progress.filter(t=>t.id!==e.id),done:n.done.filter(t=>t.id!==e.id)})},L=async e=>{await D(e,{includeTaskPrompt:!1})},V=e=>T(e),[G,O]=(0,r.useState)(sh),H=e=>{O(e),tv(tx,e)},Y="workspace"===j;return(0,n.jsxs)("div",{className:"flex h-full overflow-hidden bg-background text-foreground",children:[(0,n.jsx)("div",{className:(0,R.cn)("min-h-0 min-w-0 flex-1 overflow-hidden",Y&&"hidden"),children:"github"===j?N:(0,n.jsx)(eC,{board:e,progress:f,selectedTaskId:p??null,onSelectTask:g,onEditTask:s,onDeleteTask:i,onOpenTaskTerminal:o,taskTerminals:x,onShowTaskTerminal:h,onNewTask:b,view:j,onViewChange:v,taskLinks:y})}),(()=>{let t=[...e.in_progress.map(e=>({task:e,column:"in_progress"})),...e.backlog.map(e=>({task:e,column:"backlog"})),...e.done.map(e=>({task:e,column:"done"}))],r=p?t.find(({task:e})=>e.id===p):null,a=new Set;for(let e of w){let s=t.find(({task:t})=>t.id===e);s?.column==="in_progress"&&a.add(e)}return r&&a.add(r.task.id),(0,n.jsxs)("div",{className:(0,R.cn)("min-h-0 min-w-0 flex-1 flex-col",Y?"flex":"hidden"),children:[(0,n.jsx)("div",{className:"flex h-12 shrink-0 items-center border-b border-border px-5",children:(0,n.jsx)(B,{value:j,onChange:v})}),(0,n.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1",children:[(0,n.jsx)(sx,{running:e.in_progress,viewing:r&&"in_progress"!==r.column?r:null,selectedTaskId:p??null,progress:f,onSelect:g,collapsed:G,onCollapsedChange:H}),(0,n.jsxs)("main",{className:"min-h-0 min-w-0 flex-1",children:[Array.from(a).map(e=>{let r=t.find(({task:t})=>t.id===e);if(!r)return null;let a=e===p;return(0,n.jsx)(sf,{active:a,children:(0,n.jsx)(si,{task:r.task,column:r.column,active:a&&Y,progress:f[r.task.id]??null,progressById:f,slaves:"master"===r.task.role?t.filter(({task:e})=>e.masterId===r.task.id):void 0,master:r.task.masterId?t.find(({task:e})=>e.id===r.task.masterId)?.task??null:null,onSelectTask:g,launch:C[e],onStart:K,onReturnToBacklog:M,onLaunchAgent:L,onComplete:V,onEdit:s,onDelete:i})},e)}),!r&&(0,n.jsx)(d.PY1.div,{initial:"hidden",animate:"visible",variants:$,className:"flex h-full items-center justify-center p-8",children:(0,n.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,n.jsx)("p",{className:"text-base text-muted-foreground",children:"從左側選一張卡片,或建立新的任務。"}),(0,n.jsxs)(eH.$,{size:"sm",onClick:b,className:"rounded-full px-4",children:[(0,n.jsx)(u.A,{}),"新增任務"]})]})})]})]})]})})(),(0,n.jsx)(l.N,{children:P&&(0,n.jsx)(tt.h,{title:"完成任務",onClose:()=>T(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:(0,n.jsx)(m.A,{className:"size-5"})}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold tracking-tight",children:["完成「",P.title,"」?"]}),(0,n.jsxs)("p",{className:"text-base leading-6 text-muted-foreground",children:["這會刪除這張卡的 worktree(尚未 commit 的變更會一起消失)、本地分支",P.branch?`「${P.branch}」`:"","與 artifacts, 並把專案切回",P.baseBranch?`「${P.baseBranch}」`:"基準分支","後更新。此操作無法復原,請先確認要保留的變更都已經 commit 或 push。"]})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eH.$,{variant:"ghost",size:"sm",className:"rounded-full",onClick:()=>T(null),children:"取消"}),(0,n.jsx)(eH.$,{variant:"destructive",size:"sm",className:"rounded-full active:scale-95 motion-reduce:transform-none",onClick:()=>{var s;let n;P&&(T(null),s="done",(n={backlog:e.backlog.filter(e=>e.id!==P.id),in_progress:e.in_progress.filter(e=>e.id!==P.id),done:e.done.filter(e=>e.id!==P.id)})[s]=[P,...n[s]],t(n),a(P.id))},children:"完成並清理"})]})]})},"confirm-done-dialog")})]})}let sg=eO()(()=>s.e(1225).then(s.bind(s,91225)).then(e=>e.TerminalFilePreview),{loadableGenerated:{webpack:()=>[91225]},ssr:!1});function sb({sessionKey:e,projectPath:t,displayPath:a,taskId:i,title:l,onStarted:o}){let[c,d]=(0,r.useState)(null),u=(0,r.useRef)(null),m=(0,r.useRef)(l);m.current=l;let x=(0,r.useRef)(o);return x.current=o,(0,r.useEffect)(()=>{let n,r,a,l,o=!1,c=null,h=new AbortController;return(async()=>{let[{Terminal:f},{FitAddon:p},{WebLinksAddon:g}]=await Promise.all([s.e(3779).then(s.bind(s,15167)),s.e(5695).then(s.bind(s,95695)),s.e(4847).then(s.bind(s,54847))]);if(o||!u.current)return;let b=new f({fontSize:12,fontFamily:'Menlo, Monaco, "Courier New", monospace',cursorBlink:!0,theme:{background:"#191919",foreground:"#e6e6e6",cursor:"#4c9bf5"},linkHandler:{activate:(e,t)=>eZ(t,d),hover:(e,t)=>e5(b,t),leave:()=>e2(b)}});c=b;let j=new p;b.loadAddon(j),e1(b,e,d),b.loadAddon(new g((e,t)=>eZ(t,d),{hover:(e,t)=>e5(b,t),leave:()=>e2(b)})),b.open(u.current);let v=()=>{if(!u.current||0===u.current.clientWidth||0===u.current.clientHeight)return;j.fit();let e=b.element?.querySelector(".xterm-screen"),t=b.element?.querySelector(".xterm-viewport");if(e&&t){let s=eU(b.cols,e.getBoundingClientRect().width,t.clientWidth);s!==b.cols&&b.resize(s,b.rows)}};if(await document.fonts.ready,await eJ(u.current,h.signal),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),o)return;v();let N=window.vibeflow;if(!N)return b.writeln("⚠️ 未連線到 VibeFlow core,無法開啟終端。");n=N.term.onData(({sessionKey:t,data:s})=>{t===e&&b.write(s)}),r=N.term.onExit(({sessionKey:t,exitCode:s,intentional:n})=>{t!==e||n||b.writeln(`\r
8
8
  ℹ️ 終端已結束(exit code: ${s})`)});try{let s=await (0,F.AD)({sessionKey:e,...i?{taskId:i}:t?{projectPath:t}:{},title:m.current,cols:b.cols,rows:b.rows});if(!s)throw Error("未連線到 VibeFlow core");if(o)return void(0,F.Vz)(e);x.current?.(),s.scrollback&&b.write(s.scrollback),b.onData(t=>(0,F.zj)(e,t)),b.focus()}catch(e){o||b.writeln(`⚠️ 無法開啟終端:${e instanceof Error?e.message:String(e)}`)}a=new ResizeObserver(()=>{clearTimeout(l),l=setTimeout(()=>{if(o)return;let t=b.cols,s=b.rows;v(),(t!==b.cols||s!==b.rows)&&(0,F.t3)(e,b.cols,b.rows)},100)}),u.current&&a.observe(u.current)})(),()=>{o=!0,h.abort(),n?.(),r?.(),a?.disconnect(),clearTimeout(l),c?.dispose()}},[e,t,i]),(0,n.jsxs)("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden p-2",children:[(0,n.jsx)("div",{ref:u,className:"h-full w-full overflow-hidden","aria-label":`終端機:${a??t??"~"}`}),null!==c&&(0,n.jsx)(sg,{sessionKey:e,path:c,onClose:()=>d(null)},c)]})}var sj=s(28333);let sv="w-full rounded-md border bg-background px-3 py-2 text-base outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 transition-shadow motion-reduce:transition-none";function sN(e){let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}function sy(e,t){return!!(t&&e.find(e=>e.path===t)?.missing)}function sw({projectPath:e,recentProjects:t,disabled:s,onSelect:a,onBrowse:i,compact:l=!1}){let o=l?"h-8 px-2 py-1 text-sm":void 0,c=l?"rounded-md border border-border p-1.5":"rounded-md border border-border p-2",d=e?sN(e):null,u=t.filter(t=>!(t.missing&&t.name===d&&t.path!==e));e&&!u.some(t=>t.path===e)&&u.unshift({path:e,name:d??e,lastUsedAt:0,missing:!1});let x=new Map;for(let e of u)x.set(e.name,(x.get(e.name)??0)+1);let h=sy(t,e),[f,p]=(0,r.useState)(""),g=()=>{let e=f.trim();e&&(a(e),p(""))};return(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("select",{name:"project-folder","aria-label":"專案資料夾",title:e??void 0,value:e??"",onChange:e=>e.target.value&&a(e.target.value),disabled:s||0===u.length,className:(0,R.cn)(sv,"min-w-0 flex-1",o,h&&"border-destructive/60"),children:[(0,n.jsx)("option",{value:"",disabled:!0,children:u.length>0?"選擇使用過的專案…":"尚無使用過的專案,請點右側按鈕選取"}),u.map(e=>{let t,s;return(0,n.jsxs)("option",{value:e.path,title:e.path,children:[e.name,(x.get(e.name)??0)>1?` — ${(s=Math.max((t=e.path.replace(/[\\/]+$/,"")).lastIndexOf("/"),t.lastIndexOf("\\")))>0?t.slice(0,s):t}`:"",e.missing?"(路徑遺失)":""]},e.path)})]}),(0,n.jsx)(T.K,{"aria-label":"從資料夾選擇專案",title:"從資料夾選擇專案",onClick:i,disabled:s,tone:"primary",className:c,children:(0,n.jsx)(eI.A,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{type:"text",name:"project-path","aria-label":"輸入專案資料夾路徑",placeholder:l?"或輸入絕對路徑後按 Enter":"或輸入資料夾的絕對路徑,按 Enter 套用",value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),g())},disabled:s,spellCheck:!1,className:(0,R.cn)(sv,"min-w-0 flex-1 font-mono text-sm",o)}),(0,n.jsx)(T.K,{"aria-label":"套用輸入的路徑",title:"套用輸入的路徑",onClick:g,disabled:s||""===f.trim(),className:c,children:(0,n.jsx)(sj.A,{className:"size-4"})})]}),e&&!h&&!l&&(0,n.jsx)("p",{className:"truncate text-sm text-muted-foreground",title:e,children:e}),h&&(0,n.jsxs)("p",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm",children:[(0,n.jsx)(m.A,{className:"mt-0.5 size-3.5 shrink-0 text-destructive"}),(0,n.jsxs)("span",{children:["找不到 ",(0,n.jsx)("code",{className:"break-all text-foreground",children:e}),",專案可能已被移動或刪除。請點右側資料夾按鈕重新選取,之後選單會改用新的路徑。"]})]})]})}function sk({view:e,onViewChange:t,terminals:s,taskWorktreePaths:a,focusedSessionKey:i,recentProjects:l,onCreate:o,onRename:c,onStarted:d,onClose:m,onBrowse:x}){let[h,f]=(0,r.useState)(!1),[p,g]=(0,r.useState)(null),[b,j]=(0,r.useState)(null),v=s.find(e=>e.sessionKey===b),N=(0,r.useRef)(new Map);return(0,r.useEffect)(()=>{if("terminals"!==e||!i)return;let t=N.current.get(i);t?.scrollIntoView({block:"center"}),t?.focus({preventScroll:!0})},[i,e]),(0,n.jsxs)("div",{className:"@container flex h-full min-h-0 flex-col bg-background",children:[(0,n.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border px-5",children:[(0,n.jsx)(B,{value:e,onChange:t}),(0,n.jsxs)(eH.$,{size:"sm","aria-label":"新增 Terminal",onClick:()=>f(!0),children:[(0,n.jsx)(u.A,{className:"size-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"新增 Terminal"})]})]}),0===s.length?(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 text-center text-muted-foreground",children:[(0,n.jsx)("p",{children:"尚未開啟 Terminal"}),(0,n.jsx)("p",{className:"text-sm",children:"選擇專案或資料夾,即可在該目錄開啟獨立終端機;不選則在家目錄開啟。"})]}):(0,n.jsx)("div",{className:"terminal-grid-scroll grid min-h-0 w-full flex-1 auto-rows-[480px] grid-cols-1 content-start gap-4 overflow-y-auto p-4 @min-[728px]:grid-cols-2 @min-[1084px]:grid-cols-3",children:s.map(e=>{let t=e.taskId?a[e.taskId]??e.projectPath:e.projectPath??"~";return(0,n.jsxs)("section",{ref:t=>{t?N.current.set(e.sessionKey,t):N.current.delete(e.sessionKey)},tabIndex:-1,"aria-label":`Terminal:${e.title}`,className:(0,R.cn)("flex h-[480px] w-full min-w-0 flex-col overflow-hidden rounded-md border bg-card outline-none",i===e.sessionKey?"border-primary ring-2 ring-primary/30":"border-border"),children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[(0,n.jsx)(sC,{title:e.title,fallback:e.projectPath?sN(e.projectPath):"~",onCommit:t=>c(e.sessionKey,t)}),(0,n.jsx)(T.K,{"aria-label":`關閉 Terminal:${e.title}`,title:"關閉並釋放 Terminal",onClick:()=>j(e.sessionKey),className:"size-7 shrink-0",children:(0,n.jsx)(eM.A,{className:"size-4"})})]}),(0,n.jsx)("div",{className:"truncate border-b border-border px-3 py-1 font-mono text-xs text-muted-foreground",title:t,children:t}),(0,n.jsx)(sb,{sessionKey:e.sessionKey,title:e.title,onStarted:()=>d(e.sessionKey),projectPath:e.projectPath,displayPath:t,taskId:e.taskId})]},e.sessionKey)})}),h&&(0,n.jsx)(tt.h,{title:"新增 Terminal",onClose:()=>f(!1),contentClassName:"max-w-lg rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"選擇專案或資料夾"}),(0,n.jsx)(sw,{projectPath:p,recentProjects:l,disabled:!1,onSelect:g,onBrowse:()=>{x().then(e=>{e&&g(e)})}}),(0,n.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(eH.$,{variant:"ghost",size:"sm",onClick:()=>f(!1),children:"取消"}),(0,n.jsx)(eH.$,{variant:"outline",size:"sm",onClick:()=>{o(),g(null),f(!1)},children:"不選專案(家目錄)"}),(0,n.jsx)(eH.$,{size:"sm",disabled:!p||sy(l,p),onClick:()=>{p&&(o(p),g(null),f(!1))},children:"開啟 Terminal"})]})]})}),v&&(0,n.jsx)(tt.h,{title:"關閉 Terminal",onClose:()=>j(null),contentClassName:"max-w-md rounded-lg p-5",children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold",children:["關閉「",v.title,"」?"]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"關閉 Terminal 會結束這個 session,正在執行的指令也會中止。"}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(eH.$,{variant:"ghost",size:"sm",onClick:()=>j(null),children:"取消"}),(0,n.jsx)(eH.$,{variant:"destructive",size:"sm",onClick:()=>{m(v.sessionKey),j(null)},children:"確認關閉"})]})]})})]})}function sC({title:e,fallback:t,onCommit:s}){let[a,i]=(0,r.useState)(e),[l,o]=(0,r.useState)(!1),c=l?a:e;return(0,n.jsx)("input",{"aria-label":`編輯 Terminal 標題:${e}`,title:"點擊編輯標題",value:c,onFocus:()=>{i(e),o(!0)},onChange:e=>i(e.target.value),onBlur:()=>{o(!1);let n=a.trim()||t;n!==e&&s(n)},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"min-w-0 flex-1 rounded-sm bg-transparent px-1 text-sm font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"})}let sS=["low","medium","high","xhigh","max","ultra"];[...sS];let sz=["low","medium","high","xhigh"];function sA(e,t){return t?e?.find(e=>e.id===t):e?.find(e=>e.isDefault)}function s$(e,t){if(0===t.length||void 0===e||"auto"===e)return;if(t.includes(e))return e;let s=sS.indexOf(e),n=sS.filter(e=>t.includes(e)),r=n.filter(e=>sS.indexOf(e)<=s);return r.length>0?r[r.length-1]:n[0]}let sE=[{value:"auto",label:"自動",description:"Jev 會依任務與目前模型選擇合適的推理強度。"},{value:"low",label:"快速",description:"適合範圍明確、低風險的小任務。"},{value:"medium",label:"標準",description:"兼顧速度與推理深度,適合一般開發任務。"},{value:"high",label:"深入",description:"適合跨檔案、除錯或需要較多判斷的任務。"},{value:"xhigh",label:"極致",description:"適合高複雜度、長鏈推理或高風險變更。"},{value:"max",label:"最大",description:"最深的推理,適合最困難的問題。"},{value:"ultra",label:"委派",description:"最深推理並自動委派子任務,耗時與用量可能明顯增加。"}],sP="auto";function sT({value:e,onChange:t,levels:s,disabled:r=!1,className:a}){let i=sE.filter(e=>"auto"===e.value||s.includes(e.value)),l="auto"===e?e:s$(e,s)??"auto",o=i.find(e=>e.value===l)??i[0];return(0,n.jsx)("select",{name:"task-effort",value:o.value,disabled:r||1===i.length,title:0===s.length?"這個 model 不支援調整推理強度,啟動時使用模型預設值。":o.description,onChange:e=>t(e.target.value),className:(0,R.cn)(sv,a),children:i.map(e=>(0,n.jsxs)("option",{value:e.value,children:[e.label," \xb7 ",e.value]},e.value))})}var sI=s(37614);function sR({value:e,onChange:t,disabled:s=!1}){return(0,n.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-label":"Auto Mode",disabled:s,onClick:()=>t(!e),className:"rounded-full p-1 outline-none transition-opacity motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",children:(0,n.jsx)("span",{className:(0,R.cn)("relative inline-block h-4 w-7 shrink-0 rounded-full transition-colors motion-reduce:transition-none",e?"bg-primary":"bg-border"),children:(0,n.jsx)("span",{className:(0,R.cn)("absolute left-0 top-0.5 size-3 rounded-full bg-foreground ring-1 ring-border transition-transform motion-reduce:transform-none motion-reduce:transition-none",e?"translate-x-3.5":"translate-x-0.5")})})})}function sD({value:e,onChange:t,disabled:s=!1}){return(0,n.jsxs)("div",{className:"space-y-2.5 rounded-lg border border-border/50 p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-base font-medium",children:[(0,n.jsx)(sI.A,{className:"size-4 text-muted-foreground"}),"Auto Mode"]}),(0,n.jsx)(sR,{value:e,onChange:t,disabled:s})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:e?"開啟:Agent 會直接修改檔案、執行指令,不會逐次向你確認。":"關閉:Agent 每次要動作前,都會在終端機裡等你允許。"})]})}let sK=(0,R.cn)(sv,"h-8 px-2 py-1 text-sm");function sB({title:e,header:t,saving:s,onClose:r,content:a,sidebar:i,actions:l}){return(0,n.jsxs)(tt.h,{title:e,saving:s,onClose:r,contentClassName:"max-w-[880px] overflow-hidden",children:[(0,n.jsx)(T.K,{"aria-label":`關閉${e}`,onClick:r,disabled:s,className:"absolute right-3 top-3 z-10 p-1",children:(0,n.jsx)(eM.A,{className:"size-4"})}),(0,n.jsxs)("div",{className:"flex max-h-[90vh] flex-col overflow-y-auto md:h-[min(90vh,720px)] md:flex-row md:overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex min-h-[360px] min-w-0 flex-1 flex-col gap-3 p-5 pr-12 md:min-h-0 md:pr-5",children:[(0,n.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:t}),a]}),(0,n.jsxs)("aside",{className:"flex w-full shrink-0 flex-col border-t border-border/70 bg-muted/20 md:w-[300px] md:border-l md:border-t-0",children:[(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col gap-4 px-3 pb-3 pt-4 md:overflow-y-auto md:pt-12",children:i}),(0,n.jsx)("div",{className:"flex shrink-0 gap-2 border-t border-border/70 px-3 py-3",children:l})]})]})]})}function sF({label:e,children:t}){return(0,n.jsxs)("section",{"aria-label":e,className:"space-y-1.5",children:[(0,n.jsx)("h3",{className:(0,R.cn)(P,"px-1"),children:e}),t]})}function sM({label:e,children:t}){return(0,n.jsxs)("label",{className:"grid grid-cols-[76px_minmax(0,1fr)] items-center gap-2 px-1",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:e}),(0,n.jsx)("span",{className:"min-w-0",children:t})]})}function s_({children:e,tone:t}){return(0,n.jsx)("div",{className:(0,R.cn)("px-1 text-sm leading-5","warning"===t?"text-warning":"danger"===t?"text-destructive":"text-muted-foreground"),children:e})}function sL(e){let[t,s]=(0,r.useState)(null);return(0,r.useEffect)(()=>{let t=!1;return(0,F.qw)(e).then(n=>{t||s({agentCli:e,models:n?.models??[]})}).catch(()=>{t||s({agentCli:e,models:[]})}),()=>{t=!0}},[e]),t?.agentCli===e?t.models:null}function sV(e,t,s,n,a){var i;let l=(i=sA(e,function(e){let t,s=e.model?.trim();if(!(!s||tr[(t=e.agentCli)&&t in tn?t:"claude"]?.includes(s)))return s}({agentCli:t,model:s})),i?.efforts??null??sz);return(0,r.useEffect)(()=>{if(null===e)return;let t=s$(n,l);"auto"!==n&&t&&t!==n&&a(t)},[e,l,n,a]),l}let sG="__custom__";function sO({agents:e,detectTimedOut:t,onRetry:s,agentCli:a,onAgentChange:i,model:l,onModelChange:o,models:c,effort:d,onEffortChange:u,effortLevels:m,autoMode:x,onAutoModeChange:h,disabled:f}){let[p,g]=(0,r.useState)(!1);(0,r.useEffect)(()=>{g(!1)},[a]);let b=c??[],j=p?void 0:sA(b,l||void 0)?.description,v=!l||p||b.some(e=>e.id===l)?b:[{id:l,label:l},...b];return(0,n.jsxs)(sF,{label:"執行",children:[null===e?(0,n.jsx)(s_,{tone:t?"danger":void 0,children:t?(0,n.jsxs)(n.Fragment,{children:["偵測逾時,請確認 Agent CLI 已安裝。",(0,n.jsx)("button",{type:"button",onClick:s,className:"ml-1 rounded-sm text-primary underline outline-none hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"重新偵測"})]}):(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(k.A,{className:"size-3 animate-spin"}),"偵測 Agent CLI…"]})}):0===e.length?(0,n.jsx)(s_,{tone:"danger",children:"未偵測到 Agent CLI(claude / codex)。"}):(0,n.jsx)(sM,{label:"Agent",children:(0,n.jsx)("select",{name:"agent-agent-cli",value:a,disabled:f,onChange:e=>i(e.target.value),className:sK,children:e.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))})}),(0,n.jsx)(sM,{label:"Model",children:(0,n.jsxs)("select",{name:"agent-model",value:p?sG:l,disabled:f,title:j,onChange:e=>{e.target.value===sG?g(!0):(g(!1),o(e.target.value))},className:sK,children:[(0,n.jsx)("option",{value:"",children:"未指定(由 Jev 選擇,沒有金鑰時用 CLI 預設模型)"}),v.map(e=>(0,n.jsx)("option",{value:e.id,children:e.label},e.id)),(0,n.jsx)("option",{value:sG,children:"自訂…"})]})}),p&&(0,n.jsx)(sM,{label:"Model id",children:(0,n.jsx)("input",{name:"agent-custom-model",value:l,onChange:e=>o(e.target.value.trim()),placeholder:"例如 claude-opus-5-5",autoFocus:!0,className:sK})}),null===c&&(0,n.jsx)(s_,{children:(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(k.A,{className:"size-3 animate-spin"}),"讀取 model list…"]})}),(0,n.jsx)(sM,{label:"推理強度",children:(0,n.jsx)(sT,{value:d,onChange:u,levels:m,disabled:f,className:"h-8 px-2 py-1 text-sm"})}),(0,n.jsxs)("div",{className:"grid grid-cols-[76px_minmax(0,1fr)] items-center gap-2 px-1",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"Auto Mode"}),(0,n.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:x?"不逐次確認":"每步等你允許"}),(0,n.jsx)(sR,{value:x,onChange:h,disabled:f})]})]})]})}function sH({task:e,detectAgents:t,pickFolder:s,loadRecentProjects:a,loadGitInfo:i,saving:o,error:c,defaultAutoMode:d=!0,masters:u=[],onSubmit:m,onClose:x}){let[h,f]=(0,r.useState)(""),[p,g]=(0,r.useState)(""),[j,v]=(0,r.useState)(""),[N,y]=(0,r.useState)("claude"),[C,S]=(0,r.useState)(""),[z,A]=(0,r.useState)(sP),$=sL(N),E=sV($,N,C,z,A),[P,T]=(0,r.useState)(!0),[I,D]=(0,r.useState)(null),[K,B]=(0,r.useState)(""),[F,M]=(0,r.useState)(""),[_,L]=(0,r.useState)(null),[V,G]=(0,r.useState)(!1),[O,H]=(0,r.useState)(!1),[Y,W]=(0,r.useState)([]),[J,U]=(0,r.useState)(null),[q,X]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)(0),[ee,et]=(0,r.useState)(!1),es=(0,r.useRef)(null),en=e??es.current;if((0,r.useEffect)(()=>{e&&(es.current=e)},[e]),(0,r.useEffect)(()=>{e&&(g(e.title),v(e.description??""),y(e.agentCli??"claude"),S(e.model??""),A(e.effort??sP),T(e.autoMode??d),D(e.projectPath??null),B(e.baseBranch??""),M(e.branch),f(e.masterId??""),L(null),G(!1),H(!1),et(!1))},[e,d]),(0,r.useEffect)(()=>{if(!e)return;let t=!0;return a().then(e=>{t&&W(e)}),()=>{t=!1}},[e,a]),(0,r.useEffect)(()=>{if(!e?.projectPath)return;let t=!0;return G(!0),i(e.projectPath).then(e=>{t&&L(e)}).finally(()=>{t&&G(!1)}),()=>{t=!1}},[e,i]),(0,r.useEffect)(()=>{if(!e)return;let s=!0;X(!1),U(null);let n=setTimeout(()=>{s&&X(!0)},6e3);return t().then(e=>{s&&(clearTimeout(n),U(e))}),()=>{s=!1,clearTimeout(n)}},[e,t,Q]),!en)return null;let er=!!en.worktreePath,ea=p!==en.title||j!==(en.description??"")||N!==(en.agentCli??"claude")||C!==(en.model??"")||z!==(en.effort??sP)||P!==(en.autoMode??d)||O||K!==(en.baseBranch??"")||F.trim()!==en.branch,ei=()=>{o||(ea?et(!0):x())},el=sy(Y,I),eo=async(e,t=!1)=>{if(D(e),H(e!==en.projectPath),L(null),!(!t&&sy(Y,e))){G(!0);try{let t=await i(e);L(t),B(t?.defaultBase??"")}finally{G(!1)}}},ec=async()=>{let e=await s();e&&(W(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await eo(e,!0))},ed=_?.isRepo??!0,eu=_?.hasRemote??!1,em=O||K!==(en.baseBranch??"")||""!==F.trim()&&F.trim()!==en.branch,ex=p.trim().length>0&&!o&&!V&&(!O||ed&&!el),eh=en?.role==="master",ef=()=>{if(!ex)return;let e={title:p.trim(),description:j.trim(),agentCli:N,model:C,effort:z,autoMode:P};eh?m(e):m({...e,...I?{projectPath:I,baseBranch:K||null}:{},branch:F.trim(),...h!==(en?.masterId??"")?{masterId:h||null}:{}})},ep=(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[ee&&(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{className:"text-warning",children:"有未儲存的變更,確定要離開?"}),(0,n.jsxs)("div",{className:"flex gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>et(!1),className:"rounded-md px-2 py-0.5 text-sm text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"繼續編輯"}),(0,n.jsx)("button",{type:"button",onClick:x,className:"rounded-md px-2 py-0.5 text-sm text-destructive outline-none transition-colors motion-reduce:transition-none hover:bg-destructive/15 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"放棄離開"})]})]}),(0,n.jsx)("input",{autoFocus:!0,name:"edit-task-title","aria-label":"任務標題",autoComplete:"off",value:p,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ef()},placeholder:"任務標題,例如:實作登入頁面",className:"w-full rounded-sm bg-transparent text-2xl font-semibold tracking-tight outline-none placeholder:text-muted-foreground/60 focus-visible:ring-[3px] focus-visible:ring-ring/50"}),(0,n.jsx)("textarea",{name:"edit-task-description","aria-label":"詳細描述",autoComplete:"off",value:j,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ef()},placeholder:"描述這個任務的目標、需求或背景脈絡…",className:(0,R.cn)(sv,"min-h-32 flex-1 resize-none text-sm leading-6")}),c&&(0,n.jsx)("p",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm",children:c})]}),eg=!eh&&(0,n.jsxs)(sF,{label:"位置",children:[(0,n.jsxs)("div",{className:"space-y-1 px-1",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"專案"}),(0,n.jsx)(sw,{compact:!0,projectPath:I,recentProjects:Y,disabled:o||V,onSelect:e=>void eo(e),onBrowse:()=>void ec()})]}),V&&(0,n.jsx)(s_,{children:(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(k.A,{className:"size-3 animate-spin"}),"偵測 Git 狀態中…"]})}),O&&!el&&!V&&!ed&&(0,n.jsx)(s_,{tone:"danger",children:"這個資料夾不是 Git repository,請改選一個 Git 專案。"}),ed&&eu&&(0,n.jsx)(sM,{label:"基準分支",children:(0,n.jsxs)("select",{name:"edit-base-branch",value:K,onChange:e=>B(e.target.value),disabled:o||V,className:sK,children:[K&&!(_?.branches??[]).includes(K)&&(0,n.jsx)("option",{value:K,children:K}),(_?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})}),(0,n.jsx)(sM,{label:"分支",children:(0,n.jsx)("input",{name:"edit-branch",autoComplete:"off",value:F,onChange:e=>M(e.target.value),placeholder:"例如 feature/login-fix",disabled:o,className:sK})}),er&&em?(0,n.jsx)(s_,{tone:"warning",children:"這張卡已經有 worktree。儲存後會移除它與本地分支,下次開始執行時再重新建立;有未完成的變更時無法儲存。origin 上已推送的分支不會被刪除。"}):(0,n.jsx)(s_,{children:"分支在卡片開始執行時才建立並推到 origin。"}),u.length>0&&(0,n.jsx)(sM,{label:"隸屬於",children:(0,n.jsxs)("select",{name:"edit-master-id",value:h,onChange:e=>f(e.target.value),disabled:o,className:sK,children:[(0,n.jsx)("option",{value:"",children:"無"}),u.map(e=>(0,n.jsx)("option",{value:e.id,children:e.title},e.id))]})})]});return(0,n.jsx)(l.N,{children:e&&(0,n.jsx)(sB,{title:"編輯任務",header:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"編輯任務 \xb7 Backlog"}),(0,n.jsxs)("span",{title:"建立後不能更改角色",className:(0,R.cn)("flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-sm",eh?"border-master/40 text-master":"border-border text-muted-foreground"),children:[eh?(0,n.jsx)(b.A,{className:"size-3.5"}):(0,n.jsx)(w.A,{className:"size-3.5"}),eh?"Master":"一般任務"]})]}),saving:o,onClose:ei,content:ep,sidebar:(0,n.jsxs)(n.Fragment,{children:[eg,(0,n.jsx)(sO,{agents:J,detectTimedOut:q,onRetry:()=>Z(e=>e+1),agentCli:N,onAgentChange:e=>{y(e),S("")},model:C,onModelChange:S,models:$,effort:z,onEffortChange:A,effortLevels:E,autoMode:P,onAutoModeChange:T,disabled:o})]}),actions:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eH.$,{variant:"ghost",size:"sm",onClick:ei,disabled:o,className:"flex-1 rounded-full",children:"取消"}),(0,n.jsxs)(eH.$,{size:"sm",onClick:ef,disabled:!ex,className:(0,R.cn)("flex-[2] rounded-full",o&&"opacity-80"),children:[o&&(0,n.jsx)(k.A,{className:"animate-spin"}),o?"儲存中…":"儲存變更"]})]})},en.id)})}var sY=s(85499),sW=s(93659);function sJ({creating:e,error:t,pickFolder:s,loadRecentProjects:a,loadGitInfo:i,initRepository:l,detectAgents:o,onSubmit:c,onClose:d,masters:u=[],defaultAutoMode:m=!0,workstationPath:x}){let[h,f]=(0,r.useState)("task"),[p,g]=(0,r.useState)(""),[j,v]=(0,r.useState)(""),[N,y]=(0,r.useState)(""),[C,S]=(0,r.useState)(""),[z,A]=(0,r.useState)(null),[$,E]=(0,r.useState)([]),[P,I]=(0,r.useState)(null),[D,K]=(0,r.useState)(!1),[B,F]=(0,r.useState)(!1),[M,_]=(0,r.useState)(""),[L,V]=(0,r.useState)(""),[G,O]=(0,r.useState)(null),[H,Y]=(0,r.useState)(!1),[W,J]=(0,r.useState)(0),[U,q]=(0,r.useState)("claude"),[X,Q]=(0,r.useState)(""),[Z,ee]=(0,r.useState)(sP),et=sL(U),es=sV(et,U,X,Z,ee),[en,er]=(0,r.useState)(m),[ea,ei]=(0,r.useState)([]),[el,eo]=(0,r.useState)(null),[ec,ed]=(0,r.useState)(!1),[eu,em]=(0,r.useState)(!1),ex=(0,r.useRef)(0),eh=(0,r.useRef)(null),ef=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!0;Y(!1),O(null);let t=setTimeout(()=>{e&&Y(!0)},6e3);return o().then(s=>{e&&(clearTimeout(t),O(s),!s.some(e=>"claude"===e.id)&&s.length>0&&q(s[0].id))}),()=>{e=!1,clearTimeout(t)}},[o,W]),(0,r.useEffect)(()=>{eh.current?.focus()},[]),(0,r.useEffect)(()=>{let e=!0;return a().then(t=>{e&&E(t)}),()=>{e=!1}},[a]);let ep=sy($,z),eg=async e=>{A(e),I(null),_(""),K(!0);try{let t=await i(e);I(t),_(t?.defaultBase??"")}finally{K(!1)}},eb=async e=>{if(sy($,e)){A(e),I(null),_("");return}await eg(e)},ej=async()=>{let e=await s();e&&(E(t=>t.map(t=>t.path===e?{...t,missing:!1}:t)),await eg(e))},ev=async()=>{if(z){F(!0);try{let e=await l(z);I(e),_(e?.defaultBase??"")}finally{F(!1)}}},eN=async()=>{let e=await s();e&&g(e)},ey=async e=>{eo(null),em(!0);try{let t=(await eW(e)).map(e=>({id:ex.current++,input:e}));ei(e=>[...e,...t])}catch(e){eo(e instanceof Error?e.message:String(e))}finally{em(!1)}},ew=P?.isRepo??!1,ek=P?.hasRemote??!1,eC=`${x?.trim()||"~/Desktop"}/${z?sN(z):"<專案名>"}`,eS="master"===h,ez=eS||!!z&&!ep&&ew&&!D&&!B,eA=N.trim().length>0&&!e&&!eu&&ez,e$=e||eu,eE=()=>{if(!eA||!eS&&!z)return;let e={title:N.trim(),description:C.trim(),agentCli:U,model:X,effort:Z,autoMode:en,attachments:ea.map(({input:e})=>e)};c(eS?{...e,role:"master",baseBranch:null,branch:"",workDir:p.trim()||void 0}:{...e,projectPath:z??void 0,baseBranch:ek&&M||null,branch:L.trim(),masterId:j||void 0})},eP=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"新增任務"}),(0,n.jsx)("div",{role:"radiogroup","aria-label":"卡片角色",className:"inline-flex rounded-full border border-border bg-muted/40 p-0.5",children:["task","master"].map(t=>(0,n.jsxs)("button",{type:"button",role:"radio","aria-checked":h===t,disabled:e,onClick:()=>f(t),className:(0,R.cn)("flex items-center gap-1.5 rounded-full px-3 py-1 text-sm outline-none transition-colors motion-reduce:transition-none focus-visible:ring-[3px] focus-visible:ring-ring/50",h===t?"master"===t?"bg-master/15 text-master":"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:["master"===t?(0,n.jsx)(b.A,{className:"size-3.5"}):(0,n.jsx)(w.A,{className:"size-3.5"}),"master"===t?"Master":"一般任務"]},t))})]}),eT=(0,n.jsxs)("div",{onDragEnter:e=>{e.preventDefault(),e$||ed(!0)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||ed(!1)},onDrop:e=>{e.preventDefault(),ed(!1),!e$&&e.dataTransfer.files.length>0&&ey(e.dataTransfer.files)},className:(0,R.cn)("flex min-h-0 flex-1 flex-col gap-3 rounded-lg",ec&&"outline-2 outline-offset-4 outline-dashed outline-primary/70"),children:[(0,n.jsx)("input",{ref:eh,name:"task-title","aria-label":"任務標題",autoComplete:"off",value:N,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&eE()},placeholder:"任務標題,例如:實作登入頁面",className:"w-full rounded-sm bg-transparent text-2xl font-semibold tracking-tight outline-none placeholder:text-muted-foreground/60 focus-visible:ring-[3px] focus-visible:ring-ring/50"}),(0,n.jsx)("textarea",{name:"task-description","aria-label":"詳細描述",autoComplete:"off",value:C,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&eE()},placeholder:eS?"描述整體目標、涉及的 repo 與限制。Master 會先判斷要不要拆成多張卡…":"描述這個任務的目標、需求或背景脈絡…(可以直接把檔案拖進來當附件)",className:(0,R.cn)(sv,"min-h-32 flex-1 resize-none text-sm leading-6")}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsxs)(eH.$,{variant:"outline",size:"sm",onClick:()=>ef.current?.click(),disabled:e$,className:"rounded-full",children:[(0,n.jsx)(sY.A,{}),"附件"]}),(0,n.jsx)("input",{ref:ef,type:"file",multiple:!0,disabled:e$,className:"hidden",onChange:e=>{e.target.files&&ey(e.target.files),e.target.value=""}}),ea.map(({id:t,input:s})=>(0,n.jsxs)("span",{className:"flex max-w-56 items-center gap-1.5 rounded-full border border-border/60 bg-muted/40 py-0.5 pl-2.5 pr-1 text-sm",children:[(0,n.jsx)(sW.A,{className:"size-3.5 shrink-0 text-primary"}),(0,n.jsx)("span",{className:"min-w-0 truncate",title:s.name,children:s.name}),(0,n.jsx)(T.K,{"aria-label":`移除附件 ${s.name}`,onClick:()=>ei(e=>e.filter(e=>e.id!==t)),disabled:e,className:"p-0.5",children:(0,n.jsx)(eM.A,{className:"size-3.5"})})]},t)),eu&&(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,n.jsx)(k.A,{className:"size-3 animate-spin"}),"讀取附件中…"]})]}),el&&(0,n.jsx)("p",{className:"text-sm text-destructive",children:el}),t&&(0,n.jsx)("p",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm",children:t})]}),eR=eS?(0,n.jsxs)(sF,{label:"位置",children:[(0,n.jsxs)("div",{className:"space-y-1 px-1",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"工作目錄"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{name:"master-work-dir","aria-label":"工作目錄",autoComplete:"off",value:p,onChange:e=>g(e.target.value),placeholder:"留空則由 VibeFlow 建立",className:(0,R.cn)(sK,"min-w-0 flex-1 font-mono")}),(0,n.jsx)(T.K,{"aria-label":"選擇工作目錄",title:"選擇工作目錄",onClick:()=>void eN(),disabled:e,tone:"primary",className:"rounded-md border border-border p-1.5",children:(0,n.jsx)(eI.A,{className:"size-4"})})]})]}),(0,n.jsx)(s_,{children:(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{className:"cursor-pointer rounded-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"任何資料夾都可以,不建立分支或 worktree。"}),(0,n.jsxs)("ul",{className:"mt-1 list-disc space-y-1 pl-4",children:[(0,n.jsx)("li",{children:"先判斷任務要不要拆卡,再為每個 repo 建立卡片,掛在這張 Master 底下。"}),(0,n.jsx)("li",{children:en?"Auto Mode 開啟:沒有前置依賴的卡片會直接開始執行。":"Auto Mode 關閉:派出的卡片留在 Backlog,由你決定何時開始。"}),(0,n.jsx)("li",{children:"追蹤進度並回報;不會自己合併 PR 或把卡片移到 Done。"})]})]})})]}):(0,n.jsxs)(sF,{label:"位置",children:[(0,n.jsxs)("div",{className:"space-y-1 px-1",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"專案"}),(0,n.jsx)(sw,{compact:!0,projectPath:z,recentProjects:$,disabled:e||B||D,onSelect:e=>void eb(e),onBrowse:()=>void ej()})]}),(D||B)&&(0,n.jsx)(s_,{children:(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(k.A,{className:"size-3 animate-spin"}),B?"初始化 Git…":"偵測 Git 狀態中…"]})}),!z&&(0,n.jsx)(s_,{children:"選擇專案後才能建立任務。"}),P&&!ep&&!D&&!B&&!ew&&(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-destructive/40 bg-destructive/10 p-2.5 text-sm",children:[(0,n.jsxs)("p",{children:["這個資料夾不是 Git repository。可以在這裡初始化:會執行",(0,n.jsx)("code",{className:"text-foreground",children:" git init "}),"並建立一個空的初始 commit。"]}),(0,n.jsx)(eH.$,{size:"sm",variant:"outline",onClick:()=>void ev(),disabled:e,className:"rounded-full",children:"初始化 Git"})]}),ew&&ek&&(0,n.jsx)(sM,{label:"基準分支",children:(0,n.jsx)("select",{name:"base-branch",value:M,onChange:e=>_(e.target.value),className:sK,children:(P?.branches??[]).map(e=>(0,n.jsx)("option",{value:e,children:e},e))})}),ew&&(0,n.jsx)(sM,{label:"分支",children:(0,n.jsx)("input",{name:"branch",autoComplete:"off",value:L,onChange:e=>V(e.target.value),placeholder:"留空則自動命名",className:sK})}),u.length>0&&(0,n.jsx)(sM,{label:"隸屬於",children:(0,n.jsxs)("select",{name:"master-id",value:j,onChange:e=>v(e.target.value),className:sK,children:[(0,n.jsx)("option",{value:"",children:"無"}),u.map(e=>(0,n.jsx)("option",{value:e.id,children:e.title},e.id))]})}),ew&&(0,n.jsx)(s_,{children:(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{className:"cursor-pointer rounded-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:ek?"開始執行時才建立分支與 worktree 並 push。":`沒有 remote,開始執行時從 ${P?.currentBranch??"HEAD"} 建立本地 worktree。`}),(0,n.jsxs)("ul",{className:"mt-1 list-disc space-y-1 pl-4",children:[(0,n.jsxs)("li",{children:[ek?"從當下最新的 origin 基準分支":"從基準分支",",在"," ",(0,n.jsx)("code",{className:"break-all text-foreground",children:eC})," ","底下建立這張卡專用的 worktree 與分支;專案資料夾本身不會被切換。"]}),ek&&(0,n.jsx)("li",{children:"把新分支 push 到 origin;若 remote 已有同名分支,則取回並接續那條分支的工作。"}),(0,n.jsx)("li",{children:"把被 git 忽略的檔案(例如 .env)複製進 worktree,相依套件資料夾在背景複製。"}),(0,n.jsx)("li",{children:"VibeFlow 的執行期檔案寫進 .git/info/exclude,不動專案的 .gitignore。"})]})]})})]});return(0,n.jsx)(sB,{title:"新增任務",header:eP,saving:e,onClose:d,content:eT,sidebar:(0,n.jsxs)(n.Fragment,{children:[eR,(0,n.jsx)(sO,{agents:G,detectTimedOut:H,onRetry:()=>J(e=>e+1),agentCli:U,onAgentChange:e=>{q(e),Q("")},model:X,onModelChange:Q,models:et,effort:Z,onEffortChange:ee,effortLevels:es,autoMode:en,onAutoModeChange:er,disabled:e})]}),actions:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eH.$,{variant:"ghost",size:"sm",onClick:d,disabled:e,className:"flex-1 rounded-full",children:"取消"}),(0,n.jsxs)(eH.$,{size:"sm",onClick:eE,disabled:!eA,className:(0,R.cn)("flex-[2] rounded-full",e&&"opacity-80"),children:[e&&(0,n.jsx)(k.A,{className:"animate-spin"}),e?"建立中…":eS?"建立 Master":"建立任務"]})]})})}var sU=s(1896),sq=s(69758),sX=s(87617),sQ=s(80802),sZ=s(21684),s0=s(37156),s1=s(43812),s5=s(53150);let s2=[{id:"skill",label:"Skills",hint:"儲存可重複使用的 skill;啟動任務時不會自動載入。import 需選擇含 SKILL.md 的目錄。"},{id:"prompt",label:"Prompts",hint:"儲存可重複使用的文字片段;啟動任務時不會自動加入 prompt。"},{id:"script",label:"Scripts",hint:"儲存可重複使用的腳本;啟動任務時不會把清單寫進 prompt。"}],s3={skill:sZ.A,prompt:ez.A,script:v.A};function s4(e,t){return"skill"!==e?"":`---
9
9
  name: ${t}
10
10
  description:
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},__routerFilterDynamic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-8f65b0f8749f42d2.js"],"/home":["static/chunks/9511-583f6646d41ca80c.js","static/chunks/pages/home-67d0b5d90f4c63a9.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},__routerFilterDynamic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-8f65b0f8749f42d2.js"],"/home":["static/chunks/9511-583f6646d41ca80c.js","static/chunks/pages/home-3a67529f14bfbf5f.js"],sortedPages:["/_app","/_error","/home"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/9187d5806b3a122c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/9187d5806b3a122c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8c96fd26290e204.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-ba514e8a4a55baf5.js" defer=""></script><script src="/_next/static/chunks/9511-583f6646d41ca80c.js" defer=""></script><script src="/_next/static/chunks/pages/home-67d0b5d90f4c63a9.js" defer=""></script><script src="/_next/static/gmICTBYpLixZfn2Jxgcoy/_buildManifest.js" defer=""></script><script src="/_next/static/gmICTBYpLixZfn2Jxgcoy/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div class="bg-background text-foreground"><div class="flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground">載入中…</div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/home","query":{},"buildId":"gmICTBYpLixZfn2Jxgcoy","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><link rel="icon" href="/favicon.ico" sizes="any" data-next-head=""/><link rel="icon" href="/logo.svg" type="image/svg+xml" data-next-head=""/><link rel="apple-touch-icon" href="/apple-touch-icon.png" data-next-head=""/><link rel="manifest" href="/manifest.webmanifest" data-next-head=""/><meta name="theme-color" content="#0d1117" data-next-head=""/><title data-next-head="">VibeFlow</title><link rel="preload" href="/_next/static/css/9187d5806b3a122c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/9187d5806b3a122c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c8c96fd26290e204.js" defer=""></script><script src="/_next/static/chunks/framework-b92a367cf1ad4bf7.js" defer=""></script><script src="/_next/static/chunks/main-ec7fd4c371d06729.js" defer=""></script><script src="/_next/static/chunks/pages/_app-ba514e8a4a55baf5.js" defer=""></script><script src="/_next/static/chunks/9511-583f6646d41ca80c.js" defer=""></script><script src="/_next/static/chunks/pages/home-3a67529f14bfbf5f.js" defer=""></script><script src="/_next/static/m8Qx5CrsoNWKGv6xecckf/_buildManifest.js" defer=""></script><script src="/_next/static/m8Qx5CrsoNWKGv6xecckf/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div class="bg-background text-foreground"><div class="flex min-h-screen items-center justify-center bg-background text-base text-muted-foreground">載入中…</div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/home","query":{},"buildId":"m8Qx5CrsoNWKGv6xecckf","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kw-yeh/vibeflow",
3
- "version": "4.11.40",
3
+ "version": "4.11.41",
4
4
  "description": "Intent-driven local kanban for coding agents: git worktree per card, Web UI and TUI.",
5
5
  "license": "MIT",
6
6
  "author": "KW-Yeh",