mainflow 0.44.0-alpha.2 → 0.44.0-alpha.4

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.
@@ -79,4 +79,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
79
79
  `)[0]),9,Lj)):K(``,!0),e.dep?(B(),V(`span`,{key:1,class:k(N(eT)[e.dep].tone)},j(N(eT)[e.dep].label),3)):K(``,!0)])]),_:2},1032,[`peek`,`id`,`title`,`status`,`label`]))],64))),128))]),_:1},8,[`count`])):K(``,!0)}}),zj={class:`flex flex-col`},Bj=[`href`,`title`],Vj={key:3,class:`truncate`},Hj={key:5,class:`ml-auto shrink-0 text-xs text-muted-foreground`},Uj=I({__name:`RefSources`,props:{refs:{}},setup(e){return(t,n)=>(B(),V(`ul`,zj,[(B(!0),V(z,null,L(e.refs,e=>(B(),V(`li`,{key:e.title+(e.url??e.path),class:`-mx-2 flex min-h-8 min-w-0 items-center gap-2 rounded-md px-2 transition-colors hover:bg-accent/50`},[e.url?(B(),H(N(dd),{key:0,class:`size-3.5 shrink-0 text-muted-foreground`})):(B(),H(N(gd),{key:1,class:`size-3.5 shrink-0 text-muted-foreground`})),e.url?(B(),V(`a`,{key:2,href:e.url,target:`_blank`,rel:`noreferrer`,class:`truncate underline decoration-border underline-offset-4 hover:decoration-foreground`,title:e.url},j(e.title),9,Bj)):(B(),V(`span`,Vj,j(e.title),1)),e.path?(B(),H(DD,{key:4,text:e.path,class:`min-w-0`},null,8,[`text`])):K(``,!0),e.date?(B(),V(`span`,Hj,j(e.date),1)):K(``,!0)]))),128))]))}}),Wj=I({__name:`HoverCard`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},openDelay:{},closeDelay:{},enableTouch:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=F_(e,t);return(e,t)=>(B(),H(N(qS),q({"data-slot":`hover-card`},N(n)),{default:P(t=>[R(e.$slots,`default`,A(Cs(t)))]),_:3},16))}}),Gj=I({inheritAttrs:!1,__name:`HoverCardContent`,props:{forceMount:{type:Boolean},memoDependencies:{},side:{},sideOffset:{default:4},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=P_(Sf(t,`class`));return(e,r)=>(B(),H(N(QS),null,{default:P(()=>[W(N(ZS),q({"data-slot":`hover-card-content`},{...e.$attrs,...N(n)},{class:N(gg)(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 rounded-md border p-4 shadow-md outline-hidden`,t.class)}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`class`])]),_:3}))}}),Kj=I({__name:`HoverCardTrigger`,props:{reference:{},asChild:{type:Boolean},as:{}},setup(e){let t=e;return(e,n)=>(B(),H(N($S),q({"data-slot":`hover-card-trigger`},t),{default:P(()=>[R(e.$slots,`default`)]),_:3},16))}}),qj={class:`shrink-0 font-mono text-[11px] text-muted-foreground`},Jj={key:0,class:`truncate`},Yj={class:`font-mono text-xs text-muted-foreground`},Xj={key:0,class:`mt-1 font-semibold`},Zj={class:`mt-2 flex items-center gap-2`},Qj={key:1,class:`text-xs text-muted-foreground`},$j=I({__name:`RefLabel`,props:{id:{},title:{},status:{},context:{}},emits:[`open`],setup(e,{emit:t}){let n=t;return(t,r)=>(B(),H(N(Wj),{"open-delay":300,"close-delay":100},{default:P(()=>[W(N(Kj),{"as-child":``},{default:P(()=>[U(`button`,{type:`button`,class:`inline-flex h-6 max-w-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md border bg-background px-2 text-xs transition-colors hover:bg-accent`,onClick:r[0]||=au(t=>n(`open`,e.id),[`stop`])},[W(nT,{type:N(Vw)(e.id),status:e.status},null,8,[`type`,`status`]),U(`span`,qj,j(e.id),1),e.title?(B(),V(`span`,Jj,j(e.title),1)):K(``,!0)])]),_:1}),W(N(Gj),{class:`w-64`},{default:P(()=>[U(`p`,Yj,j(e.id),1),e.title?(B(),V(`p`,Xj,j(e.title),1)):K(``,!0),U(`div`,Zj,[e.status?(B(),H(kE,{key:0,status:e.status},null,8,[`status`])):K(``,!0),e.context?(B(),V(`span`,Qj,j(e.context),1)):K(``,!0)])]),_:1})]),_:1}))}});function eM(e){let t=tp(),n=J(()=>e?.()??String(t.params.m??``));return F(n,e=>{e&&lw(e).catch(e=>Q.error=e.message)},{immediate:!0}),{id:n,mainline:J(()=>Q.mainlines[n.value])}}var tM={key:0,class:`pb-8`},nM={key:0},rM={key:1},iM={key:2,class:`tabular-nums`},aM={key:0,class:`text-xs`},oM={class:`text-xs`},sM={class:`text-xs`},cM={key:1,class:`text-sm text-muted-foreground`},lM={key:1,class:`px-5 text-muted-foreground`},uM=I({__name:`DecisionPeek`,props:{m:{},d:{}},setup(e){let t=e,{open:n}=FC(),{mainline:r}=eM(()=>t.m),i=J(()=>r.value?.decisions.find(e=>e.id===t.d)),a=J(()=>r.value?.decisions.find(e=>e.id===i.value?.supersededBy)),o=J(()=>r.value?.decisions.filter(e=>e.supersededBy===t.d)??[]),s=e=>n(e,{chain:!0}),c=e=>Iw(e.split(`#`)[0]);return(n,l)=>i.value&&N(r)?(B(),V(`div`,tM,[W(MD,{id:`${e.m}/${i.value.id}`,title:i.value.title,type:`decision`,status:i.value.status},{notice:P(()=>[i.value.status===`proposed`?(B(),H(N(_g),{key:0,variant:`warning`},{default:P(()=>[W(N(Qu)),W(N(yg),null,{default:P(()=>[...l[0]||=[G(`還沒裁決`,-1)]]),_:1}),i.value.affects?.length?(B(),H(N(vg),{key:0,class:`text-xs text-muted-foreground`},{default:P(()=>[...l[1]||=[G(`在等它的項目列在「影響的項目」。`,-1)]]),_:1})):K(``,!0)]),_:1})):K(``,!0),a.value?(B(),H(N(_g),{key:1},{default:P(()=>[W(N(qd)),W(N(yg),null,{default:P(()=>[G(`已被 `+j(a.value.id)+` 取代`,1)]),_:1}),W(N(vg),{class:`text-xs text-muted-foreground`},{default:P(()=>[...l[2]||=[G(`以下保留當時的理由。新的決定見「取代關係」。`,-1)]]),_:1})]),_:1})):K(``,!0)]),default:P(()=>[W(kE,{status:i.value.status},null,8,[`status`]),i.value.by?(B(),V(`span`,nM,j(N(Zw)[i.value.by])+`決定`,1)):K(``,!0),i.value.basis?(B(),V(`span`,rM,j(N(Qw)[i.value.basis]),1)):K(``,!0),i.value.decidedAt?(B(),V(`span`,iM,j(N(fE)(i.value.decidedAt)),1)):K(``,!0)]),_:1},8,[`id`,`title`,`status`]),W(ID,null,{default:P(()=>[W(QD,{columns:1},{default:P(()=>[i.value.reversible===void 0?K(``,!0):(B(),H($,{key:0,label:`能否改回`,icon:N(sf)},{default:P(()=>[G(j(i.value.reversible?`可以低成本改回`:`不易改回`),1)]),_:1},8,[`icon`])),i.value.priority?(B(),H($,{key:1,label:`優先度`,icon:N(_d)},{default:P(()=>[W(TE,{priority:i.value.priority},null,8,[`priority`]),i.value.priority===`P2`?(B(),V(`span`,aM,`P2`)):K(``,!0)]),_:1},8,[`icon`])):K(``,!0),i.value.category?(B(),H($,{key:2,label:`分類`,icon:N(nf)},{default:P(()=>[G(j(i.value.category),1)]),_:1},8,[`icon`])):K(``,!0),i.value.labels?.length?(B(),H($,{key:3,label:`標籤`,icon:N(rf)},{default:P(()=>[(B(!0),V(z,null,L(i.value.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))]),_:1},8,[`icon`])):K(``,!0),W($,{label:`建立`,icon:N(Gu)},{default:P(()=>[U(`span`,oM,j(N(fE)(i.value.created)),1)]),_:1},8,[`icon`]),i.value.closedAt?(B(),H($,{key:4,label:`結束`,icon:N(Uu)},{default:P(()=>[U(`span`,sM,j(N(fE)(i.value.closedAt)),1)]),_:1},8,[`icon`])):K(``,!0),i.value.resolution?(B(),H($,{key:5,label:`結果`,icon:N($u)},{default:P(()=>[G(j(i.value.resolution),1)]),_:1},8,[`icon`])):K(``,!0),i.value.origin?(B(),H($,{key:6,label:`來源`,icon:N(cd)},{default:P(()=>[W($j,q(N(Iw)(i.value.origin),{onOpen:s}),null,16)]),_:1},8,[`icon`])):K(``,!0)]),_:1})]),_:1}),i.value.body.trim()?(B(),H(ID,{key:0,title:`內文`},{default:P(()=>[W(Cj,{source:i.value.body},null,8,[`source`])]),_:1})):K(``,!0),i.value.affects?.length?(B(),H(ID,{key:1,title:`影響的項目`,count:i.value.affects.length},{default:P(()=>[(B(!0),V(z,null,L(i.value.affects,e=>(B(),H(Oj,q({key:e,peek:e.split(`#`)[0]},{ref_for:!0},c(e),{id:e}),{default:P(()=>[G(j(e.includes(`#`)?`checklist 項目`:``),1)]),_:2},1040,[`peek`,`id`]))),128))]),_:1},8,[`count`])):K(``,!0),W(Rj,{self:N(wC)(t.m,t.d),links:i.value.links},null,8,[`self`,`links`]),i.value.refs?.length?(B(),H(ID,{key:2,title:`參考來源`,count:i.value.refs.length},{default:P(()=>[W(Uj,{refs:i.value.refs},null,8,[`refs`])]),_:1},8,[`count`])):K(``,!0),W(ID,{title:`取代關係`},{default:P(()=>[a.value?(B(),H(Oj,{key:0,peek:N(wC)(e.m,a.value.id),label:`被取代為`,id:a.value.id,title:a.value.title,status:a.value.status},null,8,[`peek`,`id`,`title`,`status`])):K(``,!0),(B(!0),V(z,null,L(o.value,t=>(B(),H(Oj,{key:t.id,peek:N(wC)(e.m,t.id),label:`取代了`,id:t.id,title:t.title,status:t.status},null,8,[`peek`,`id`,`title`,`status`]))),128)),!a.value&&o.value.length===0?(B(),V(`p`,cM,`沒有取代關係。`)):K(``,!0)]),_:1})])):(B(),V(`p`,lM,`載入 `+j(e.m)+`/`+j(e.d)+`…`,1))}}),dM=`modulepreload`,fM=function(e){return`/`+e},pM={},mM=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=fM(t,n),t=s(t),t in pM)return;pM[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:dM,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},hM=`__mainflowVue`;function gM(e){return e.replace(/import\s*\{([^}]*)\}\s*from\s*['"]vue['"];?/g,(e,t)=>`const { ${t.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>e.replace(/\s+as\s+/,`: `)).join(`, `)} } = globalThis.${hM};`)}async function _M(e){let t=URL.createObjectURL(new Blob([gM(e)],{type:`text/javascript`}));try{return await mM(()=>import(t),[])}finally{URL.revokeObjectURL(t)}}async function vM(e,t){globalThis[hM]=xu;let{parse:n,compileScript:r,compileTemplate:i}=await mM(async()=>{let{parse:e,compileScript:t,compileTemplate:n}=await import(`./index.browser-C_4gp6WJ.js`);return{parse:e,compileScript:t,compileTemplate:n}},[]),{descriptor:a,errors:o}=n(e,{filename:t});if(o.length)throw Error(o.map(e=>e.message).join(`; `));for(let e of[a.script,a.scriptSetup])if(e?.lang&&e.lang!==`js`)throw Error(`<script lang="${e.lang}"> is not supported here; write the view in plain JavaScript`);if(a.styles.some(e=>e.scoped))throw Error(`<style scoped> is not supported here; use an unscoped <style> with a class prefix`);let s=`mf-${Math.abs([...t].reduce((e,t)=>e*31+t.charCodeAt(0)|0,7)).toString(36)}`,c={};if((a.script||a.scriptSetup)&&(c={...(await _M(r(a,{id:s,inlineTemplate:!0}).content)).default}),!a.scriptSetup&&a.template){let e=i({source:a.template.content,filename:t,id:s});if(e.errors.length)throw Error(e.errors.map(String).join(`; `));c.render=(await _M(e.code)).render}let l=a.styles.map(e=>e.content).join(`
80
80
  `);if(l){let e=document.querySelector(`style[data-mainflow-view="${s}"]`);e||(e=document.createElement(`style`),e.dataset.mainflowView=s,document.head.append(e)),e.textContent=l}return c}var yM={key:0,class:`mb-2 text-sm`},bM=[`src`,`title`],xM=[`src`,`alt`],SM={key:6,class:`overflow-auto rounded-lg border bg-muted/50 p-3 font-mono text-xs leading-relaxed`},CM=I({__name:`CustomContent`,props:{path:{},ctx:{}},setup(e){let t=e,n=[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`],r=e=>e.slice(e.lastIndexOf(`.`)+1).toLowerCase(),i=M(``),a=M(``),o=M(null),s=pn(null),c;async function l(){a.value=``,c?.(),c=void 0,s.value=null;let e=r(t.path);try{if(e===`vue`)s.value=await vM(await(await fetch(ZC(t.path))).text(),t.path);else if(e===`js`||e===`mjs`){let e=await mM(()=>import(ZC(t.path)),[]);if(!e.mount)throw Error(`the module must export mount(el, ctx)`);o.value&&(c=e.mount(o.value,t.ctx)??void 0)}else e!==`html`&&!n.includes(e)&&(i.value=await(await fetch(ZC(t.path))).text())}catch(e){a.value=e.message}}return F(()=>[t.path,t.ctx],()=>void l(),{immediate:!0,flush:`post`}),na(()=>c?.()),(t,c)=>(B(),V(`div`,null,[a.value?(B(),V(`p`,yM,`無法渲染 `+j(e.path)+`:`+j(a.value),1)):K(``,!0),r(e.path)===`md`?(B(),H(Cj,{key:1,source:i.value},null,8,[`source`])):r(e.path)===`html`?(B(),V(`iframe`,{key:2,src:N(ZC)(e.path),sandbox:`allow-scripts allow-same-origin`,class:`h-[480px] w-full rounded-lg border bg-white`,title:e.path},null,8,bM)):n.includes(r(e.path))?(B(),V(`img`,{key:3,src:N(ZC)(e.path),alt:e.path,class:`max-w-full rounded-lg border`},null,8,xM)):r(e.path)===`js`||r(e.path)===`mjs`?(B(),V(`div`,{key:4,ref_key:`mountPoint`,ref:o},null,512)):r(e.path)===`vue`&&s.value?(B(),H(fa(s.value),{key:5,ctx:e.ctx},null,8,[`ctx`])):r(e.path)===`vue`?K(``,!0):(B(),V(`pre`,SM,j(i.value),1))]))}}),wM=[`主脈絡文件`,`任務文件`,`產物`,`決策`,`自訂視圖`,`參考來源`],TM=e=>e.slice(e.lastIndexOf(`/`)+1),EM=e=>TM(e).includes(`.`)?TM(e).slice(TM(e).lastIndexOf(`.`)+1).toLowerCase():``;function DM(e){let t=t=>t.slice(e.dir.length+1),n=(e,n,r,i)=>({key:e,name:TM(e),kind:n,ext:EM(e),source:r,inMainline:t(e),updated:i}),r=(t,n)=>(t??[]).map(t=>({key:`${n??e.id}:${t.url??t.path}`,name:t.title,kind:`參考來源`,ext:t.url?``:EM(t.path??``),source:n,url:t.url,path:t.path,updated:t.date}));return[n(e.file,`主脈絡文件`,void 0,e.updated),...e.artifacts.map(e=>n(e,`產物`)),...e.tasks.flatMap(e=>[n(e.file,`任務文件`,e.id,e.updated),...e.artifacts.map(t=>n(t,`產物`,e.id))]),...e.decisions.map(e=>n(e.file,`決策`,e.id,e.updated)),...e.views.map(e=>n(e,`自訂視圖`)),...(e.remoteFiles??[]).map(t=>({...n(t,`產物`,e.tasks.find(e=>t.startsWith(`${e.dir}/`))?.id),remoteOnly:!0})),...r(e.refs),...e.tasks.flatMap(e=>r(e.refs,e.id))]}var OM=(e,t)=>e.remoteFiles?.includes(t)??!1;function kM(e,t){return DM(e).find(e=>e.key===t)?.kind??``}var AM={key:0,class:`pb-8`},jM={key:0},MM=[`title`],NM=[`href`],PM={key:0,class:`text-sm text-muted-foreground`},FM={key:1,class:`space-y-2 text-sm`},IM={key:1,class:`px-5 text-muted-foreground`},LM=I({__name:`FilePeek`,props:{m:{},path:{}},setup(e){let t=e,{mainline:n}=eM(()=>t.m),r=J(()=>n.value?`${n.value.dir}/${t.path}`:``),i=J(()=>n.value?.tasks.find(e=>r.value.startsWith(`${e.dir}/`))),a=J(()=>n.value?.decisions.find(e=>e.file===r.value)),o=J(()=>n.value?kM(n.value,r.value):``),s=J(()=>({mainline:n.value,task:i.value})),c=J(()=>!!n.value&&OM(n.value,r.value)),l=M(`idle`),u=M(``),d=J(()=>c.value&&l.value!==`done`);async function f(){l.value=`loading`,u.value=``;try{let e=await XC.fetchRemote(t.m,r.value);l.value=e.fetched?`done`:`failed`,u.value=e.error??``}catch(e){l.value=`failed`,u.value=e.message}}F([r,c],()=>{c.value&&(l.value=`idle`,f())},{immediate:!0});let p=J(()=>t.path.slice(t.path.lastIndexOf(`/`)+1));return(t,c)=>N(n)?(B(),V(`div`,AM,[W(MD,{title:p.value,mono:``,type:N(Uw)(e.path,o.value||void 0)},{default:P(()=>[U(`span`,null,j(o.value),1),d.value?(B(),V(`span`,jM,`只在伺服器上`)):K(``,!0),U(`span`,{class:`truncate font-mono`,title:e.path},j(e.path),9,MM),d.value?K(``,!0):(B(),H(N(sC),{key:1,variant:`ghost`,size:`xs`,class:`ml-auto text-muted-foreground`,"as-child":``},{default:P(()=>[U(`a`,{href:N(ZC)(r.value),target:`_blank`},[W(N(ef)),c[0]||=G(`原始檔`,-1)],8,NM)]),_:1}))]),_:1},8,[`title`,`type`]),W(ID,null,{default:P(()=>[d.value&&l.value!==`failed`?(B(),V(`p`,PM,`這個檔案只在同步伺服器上,正在下載…`)):d.value?(B(),V(`div`,FM,[U(`p`,null,`無法下載這個檔案:`+j(u.value),1),W(N(sC),{variant:`outline`,size:`xs`,onClick:f},{default:P(()=>[...c[1]||=[G(`重試`,-1)]]),_:1})])):(B(),H(CM,{key:2,path:r.value,ctx:s.value},null,8,[`path`,`ctx`]))]),_:1}),W(ID,{title:`所屬`},{default:P(()=>[a.value?(B(),H(Oj,{key:0,peek:N(wC)(e.m,a.value.id),id:a.value.id,title:a.value.title,status:a.value.status},null,8,[`peek`,`id`,`title`,`status`])):i.value?(B(),H(Oj,{key:1,peek:N(CC)(e.m,i.value.id),id:i.value.id,title:i.value.title,status:i.value.status},null,8,[`peek`,`id`,`title`,`status`])):K(``,!0),W(Oj,{peek:e.m,id:e.m,title:N(n).title,status:N(n).status},null,8,[`peek`,`id`,`title`,`status`])]),_:1})])):(B(),V(`p`,IM,`載入 `+j(e.m)+`…`,1))}}),RM={key:0,class:`pb-8`},zM={class:`text-xs`},BM={class:`text-xs`},VM={class:`text-xs`},HM={key:1,class:`px-5 text-muted-foreground`},UM=I({__name:`FindingPeek`,props:{id:{}},setup(e){let t=e,{open:n}=FC(),r=J(()=>Q.findings.find(e=>e.id===t.id)),i=()=>r.value&&dw(()=>XC.archiveFinding(r.value.id,!r.value.archivedAt,r.value.version));return Rw([r.value?.origin]),(a,o)=>r.value?(B(),V(`div`,RM,[W(MD,{id:r.value.id,title:r.value.title,type:`finding`,status:r.value.status},{default:P(()=>[W(kE,{status:r.value.status},null,8,[`status`]),W(iE,{archived:!!r.value.archivedAt,onToggle:i},null,8,[`archived`])]),_:1},8,[`id`,`title`,`status`]),W(ID,null,{default:P(()=>[W(QD,{columns:1},{default:P(()=>[r.value.appliesTo?.length?(B(),H($,{key:0,label:`適用範圍`,icon:N(bd)},{default:P(()=>[(B(!0),V(z,null,L(r.value.appliesTo,e=>(B(),H(DD,{key:e,text:e},null,8,[`text`]))),128))]),_:1},8,[`icon`])):K(``,!0),r.value.reviewAfter?(B(),H($,{key:1,label:`重新確認`,icon:N(qd)},{default:P(()=>[W(_E,{day:r.value.reviewAfter,ended:r.value.status===`obsolete`},null,8,[`day`,`ended`])]),_:1},8,[`icon`])):K(``,!0),r.value.origin?(B(),H($,{key:2,label:`來源`,icon:N(cd)},{default:P(()=>[W($j,q(N(Iw)(r.value.origin),{onOpen:o[0]||=e=>N(n)(e,{chain:!0})}),null,16)]),_:1},8,[`icon`])):K(``,!0),r.value.category?(B(),H($,{key:3,label:`分類`,icon:N(nf)},{default:P(()=>[G(j(r.value.category),1)]),_:1},8,[`icon`])):K(``,!0),r.value.labels?.length?(B(),H($,{key:4,label:`標籤`,icon:N(rf)},{default:P(()=>[(B(!0),V(z,null,L(r.value.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))]),_:1},8,[`icon`])):K(``,!0),W($,{label:`建立`,icon:N(Gu)},{default:P(()=>[U(`span`,zM,j(r.value.created),1)]),_:1},8,[`icon`]),r.value.closedAt?(B(),H($,{key:5,label:`結束`,icon:N(Uu)},{default:P(()=>[U(`span`,BM,j(r.value.closedAt),1)]),_:1},8,[`icon`])):K(``,!0),r.value.resolution?(B(),H($,{key:6,label:`結果`,icon:N($u)},{default:P(()=>[G(j(r.value.resolution),1)]),_:1},8,[`icon`])):K(``,!0),r.value.archivedAt?(B(),H($,{key:7,label:`封存`,icon:N(Pu)},{default:P(()=>[U(`span`,VM,j(r.value.archivedAt),1)]),_:1},8,[`icon`])):K(``,!0)]),_:1})]),_:1}),r.value.body.trim()?(B(),H(ID,{key:0,title:`內文`},{default:P(()=>[W(Cj,{source:r.value.body},null,8,[`source`])]),_:1})):K(``,!0),W(Rj,{self:t.id,links:r.value.links},null,8,[`self`,`links`]),r.value.refs?.length?(B(),H(ID,{key:1,title:`參考來源`,count:r.value.refs.length},{default:P(()=>[W(Uj,{refs:r.value.refs},null,8,[`refs`])]),_:1},8,[`count`])):K(``,!0)])):(B(),V(`p`,HM,`找不到發現 `+j(e.id)+`。`,1))}}),WM=I({__name:`Dialog`,props:{open:{type:Boolean},defaultOpen:{type:Boolean},modal:{type:Boolean},unmountOnHide:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=F_(e,t);return(e,t)=>(B(),H(N(gv),q({"data-slot":`dialog`},N(n)),{default:P(t=>[R(e.$slots,`default`,A(Cs(t)))]),_:3},16))}}),GM=I({__name:`DialogOverlay`,props:{forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Sf(t,`class`);return(e,r)=>(B(),H(N(iy),q({"data-slot":`dialog-overlay`},N(n),{class:N(gg)(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80`,t.class)}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`class`]))}}),KM=I({inheritAttrs:!1,__name:`DialogContent`,props:{forceMount:{type:Boolean},disableOutsidePointerEvents:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},showCloseButton:{type:Boolean,default:!0}},emits:[`escapeKeyDown`,`pointerDownOutside`,`focusOutside`,`interactOutside`,`openAutoFocus`,`closeAutoFocus`],setup(e,{emit:t}){let n=e,r=t,i=F_(Sf(n,`class`),r);return(t,r)=>(B(),H(N(oy),null,{default:P(()=>[W(GM),W(N(ty),q({"data-slot":`dialog-content`},{...t.$attrs,...N(i)},{class:N(gg)(`bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg`,n.class)}),{default:P(()=>[R(t.$slots,`default`),e.showCloseButton?(B(),H(N(_v),{key:0,"data-slot":`dialog-close`,class:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`},{default:P(()=>[W(N(uf)),r[0]||=U(`span`,{class:`sr-only`},`Close`,-1)]),_:1})):K(``,!0)]),_:3},16,[`class`])]),_:3}))}}),qM=I({__name:`DialogDescription`,props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=P_(Sf(t,`class`));return(e,r)=>(B(),H(N(ny),q({"data-slot":`dialog-description`},N(n),{class:N(gg)(`text-muted-foreground text-sm`,t.class)}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`class`]))}}),JM=I({__name:`DialogFooter`,props:{class:{type:[Boolean,null,String,Object,Array]},showCloseButton:{type:Boolean,default:!1}},setup(e){let t=e;return(n,r)=>(B(),V(`div`,{"data-slot":`dialog-footer`,class:k(N(gg)(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,t.class))},[R(n.$slots,`default`),e.showCloseButton?(B(),H(N(_v),{key:0,"as-child":``},{default:P(()=>[W(N(sC),{variant:`outline`},{default:P(()=>[...r[0]||=[G(` Close `,-1)]]),_:1})]),_:1})):K(``,!0)],2))}}),YM=I({__name:`DialogHeader`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),V(`div`,{"data-slot":`dialog-header`,class:k(N(gg)(`flex flex-col gap-2 text-center sm:text-left`,t.class))},[R(e.$slots,`default`)],2))}}),XM=I({__name:`DialogTitle`,props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=P_(Sf(t,`class`));return(e,r)=>(B(),H(N(sy),q({"data-slot":`dialog-title`},N(n),{class:N(gg)(`text-lg leading-none font-semibold`,t.class)}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`class`]))}}),ZM={class:`break-words`},QM={key:2,class:`font-mono`},$M=I({__name:`EvidenceText`,props:{text:{}},setup(e){let t=e,{to:n}=FC(),r=/(\.mainflow\/mainlines\/(m\d{3})-[^/\s]+\/([^\s,、;))]+))|(\bm\d{3}\/[td]\d{3}(?:#c\d{3})?\b|\b[if]\d{3}\b)|(\b[0-9a-f]{7,40}\b)|([\w./-]+\.\w+:\d+(?:-\d+)?)/g,i=J(()=>{let e=[],n=0;for(let i of t.text.matchAll(r)){let r=i.index??0;r>n&&e.push({kind:`text`,value:t.text.slice(n,r)});let[a,o,s,c,l,u]=i;o&&!/[{}*]/.test(c)?e.push({kind:`file`,value:a,peek:EC(s,c)}):l?e.push({kind:`ref`,value:a,peek:l.split(`#`)[0]}):u&&/\d/.test(u)&&/[a-f]/.test(u)?e.push({kind:`commit`,value:a}):!o&&!u?e.push({kind:`code`,value:a}):e.push({kind:`text`,value:a}),n=r+a.length}return n<t.text.length&&e.push({kind:`text`,value:t.text.slice(n)}),e}),a=e=>e.slice(e.lastIndexOf(`/`)+1);return(e,t)=>(B(),V(`span`,ZM,[(B(!0),V(z,null,L(i.value,(e,r)=>(B(),V(z,{key:r},[e.kind===`ref`||e.kind===`file`?(B(),H(N(Am),{key:0,to:N(n)(e.peek,{chain:!0}),class:`font-mono text-foreground underline decoration-border underline-offset-4 hover:decoration-foreground`,title:e.value,onClick:t[0]||=au(()=>{},[`stop`])},{default:P(()=>[G(j(e.kind===`file`?a(e.value):e.value),1)]),_:2},1032,[`to`,`title`])):e.kind===`commit`?(B(),H(DD,{key:1,text:e.value,class:`align-baseline`},null,8,[`text`])):e.kind===`code`?(B(),V(`code`,QM,j(e.value),1)):(B(),V(z,{key:3},[G(j(e.value),1)],64))],64))),128))]))}}),eN={class:`flex flex-col`},tN={key:1,class:`mt-0.5 grid size-4 shrink-0 place-items-center rounded-[4px] border border-dashed text-[10px] text-muted-foreground`,"aria-label":`已不需要`},nN={class:`flex min-w-0 flex-1 flex-col gap-0.5`},rN={class:`flex min-w-0 items-start gap-2`},iN=[`title`],aN={key:0,class:`text-xs text-muted-foreground`},oN={key:1,class:`text-xs text-muted-foreground`},sN={key:0},cN={key:2,class:`text-xs text-muted-foreground`},lN={key:3,class:`text-xs text-muted-foreground`},uN={key:1,class:`text-sm text-muted-foreground`},dN={key:0,class:`text-xs text-muted-foreground`},fN=I({__name:`Checklist`,props:{items:{},refPrefix:{},version:{}},setup(e){let t=e,n=J(()=>t.items.filter(e=>!e.done&&!e.dropped)),r=J(()=>t.items.filter(e=>e.done||e.dropped)),i=M(!1),a=J(()=>[...n.value,...i.value?r.value:[]]),o=M(null),s=M(``);async function c(e){if(e.done){await dw(()=>XC.check(`${t.refPrefix}${e.id}`,!1,void 0,t.version));return}o.value=e,s.value=``}async function l(){let e=o.value;e&&s.value.trim()&&await dw(()=>XC.check(`${t.refPrefix}${e.id}`,!0,s.value.trim(),t.version))&&(o.value=null)}return(t,n)=>(B(),V(z,null,[U(`ul`,eN,[(B(!0),V(z,null,L(a.value,e=>(B(),V(`li`,{key:e.id,class:`-mx-2 flex gap-3 rounded-md px-2 py-1.5 transition-colors duration-[120ms] hover:bg-accent/50`},[e.dropped?(B(),V(`span`,tN,`–`)):(B(),H(N(vE),{key:0,"model-value":e.done||o.value?.id===e.id,class:`mt-0.5`,"aria-label":e.done?`取消勾選 ${e.id}`:`勾選 ${e.id}`,"onUpdate:modelValue":t=>c(e)},null,8,[`model-value`,`aria-label`,`onUpdate:modelValue`])),U(`div`,nN,[U(`div`,rN,[W(DD,{text:e.id,class:`mt-px shrink-0`},null,8,[`text`]),U(`span`,{class:k([`min-w-0 flex-1`,{"text-muted-foreground":e.done,"text-muted-foreground line-through":e.dropped}])},j(e.text),3),(B(!0),V(z,null,L(e.serves??[],e=>(B(),V(`span`,{key:e,class:`shrink-0 rounded-sm bg-secondary px-1.5 font-mono text-[11px] text-muted-foreground`,title:`推進解決條件 ${e}`},j(e),9,iN))),128))]),e.doneWhen&&!e.done&&!e.dropped?(B(),V(`p`,aN,`完成定義:`+j(e.doneWhen),1)):K(``,!0),e.done&&e.evidence?(B(),V(`p`,oN,[W($M,{text:e.evidence},null,8,[`text`]),e.doneAt?(B(),V(`span`,sN,` · `+j(e.doneAt),1)):K(``,!0)])):K(``,!0),e.dropped?(B(),V(`p`,cN,[n[6]||=G(` 不需要了`,-1),e.supersededBy?(B(),V(z,{key:0},[n[4]||=G(`,由 `,-1),W($M,{text:e.supersededBy},null,8,[`text`]),n[5]||=G(` 取代`,-1)],64)):K(``,!0),e.note?(B(),V(z,{key:1},[G(`:`+j(e.note),1)],64)):K(``,!0)])):e.note?(B(),V(`p`,lN,j(e.note),1)):K(``,!0)])]))),128))]),r.value.length?(B(),H(N(sC),{key:0,variant:`ghost`,size:`xs`,class:`-ml-2 text-muted-foreground`,"aria-expanded":i.value,onClick:n[0]||=e=>i.value=!i.value},{default:P(()=>[i.value?(B(),H(N(Ju),{key:0})):(B(),H(N(Xu),{key:1})),G(j(i.value?`收起已完成`:`已完成 ${r.value.length} 個`),1)]),_:1},8,[`aria-expanded`])):K(``,!0),e.items.length===0?(B(),V(`p`,uN,`沒有項目`)):K(``,!0),W(N(WM),{open:o.value!==null,"onUpdate:open":n[3]||=e=>!e&&(o.value=null)},{default:P(()=>[W(N(KM),{class:`sm:max-w-lg`},{default:P(()=>[W(N(YM),null,{default:P(()=>[W(N(XM),null,{default:P(()=>[G(`勾選 `+j(o.value?.id),1)]),_:1}),W(N(qM),null,{default:P(()=>[G(j(o.value?.text),1)]),_:1})]),_:1}),U(`form`,{class:`flex flex-col gap-3`,onSubmit:au(l,[`prevent`])},[o.value?.doneWhen?(B(),V(`p`,dN,`完成定義:`+j(o.value.doneWhen),1)):K(``,!0),W(N(tD),{modelValue:s.value,"onUpdate:modelValue":n[1]||=e=>s.value=e,autofocus:``,placeholder:`證據:commit、檔案:行號或指令輸出`,"aria-label":`證據`},null,8,[`modelValue`]),W(N(JM),null,{default:P(()=>[W(N(sC),{type:`button`,variant:`ghost`,onClick:n[2]||=e=>o.value=null},{default:P(()=>[...n[7]||=[G(`取消`,-1)]]),_:1}),W(N(sC),{type:`submit`,disabled:!s.value.trim()},{default:P(()=>[...n[8]||=[G(`勾選`,-1)]]),_:1},8,[`disabled`])]),_:1})],32)]),_:1})]),_:1},8,[`open`])],64))}}),pN=[`P0`,`P1`,`P2`,`P3`].map(e=>({value:e,label:e})),mN=e=>e??`P2`,hN=e=>e.map(e=>({value:e,label:Yw[e]??e,status:e})),gN=e=>Jw.has(e);function _N(e,t){let n=e.filters.flatMap(e=>e.values(t).flatMap(t=>[t,e.optionLabel?.(t)??e.options?.find(e=>e.value===t)?.label??``]));return[e.id(t),e.text(t),...n].filter(Boolean).join(` `)}var vN=e=>({doing:e.filter(e=>e.status===`doing`).length,open:e.filter(e=>!gN(e.status)).length}),yN=e=>({key:`status`,label:`狀態`,value:e=>e.status,order:e,groupLabel:e=>Yw[e]??e,status:e=>e}),bN=(e,t)=>e.values?.(t)??[e.value(t)];function xN(e,t){let n=new Map;for(let r of t)for(let t of bN(e,r))n.set(t,[...n.get(t)??[],r]);let r=t=>e.order?.includes(t)?e.order.indexOf(t):1/0,i=t=>Number(e.trailing?.includes(t)??!1);return[...n.keys()].sort((t,n)=>i(t)-i(n)||r(t)-r(n)||t.localeCompare(n)*(e.latestFirst?-1:1)).map(t=>({key:t,label:e.groupLabel?.(t)??t,status:e.status?.(t),detail:e.detail?.(t),items:n.get(t)}))}var SN=`f.`,CN=e=>(Array.isArray(e)?e[0]:e)??void 0,wN=(e,t=``)=>{if(!e.startsWith(t))return!1;let n=e.slice(t.length);return n===`q`||n===`sort`||n===`archived`||n.startsWith(SN)},TN=e=>$C(e,{}),EN=(e,t)=>ew(e,{...TN(e),...t});function DN(e,t){let n=tp(),r=ep(),i=`mainflow.list.${e.key}`,a=e.queryPrefix??``,o=TN(i),s=e=>Object.fromEntries(Object.entries(e).filter(([e])=>wN(e,a)));function c(e){let t={...n.query};for(let[n,r]of Object.entries(e))r?t[n]=r:delete t[n];r.replace({query:t})}let l=o.query??{},u=Object.keys(l).length>0&&Object.keys(s(n.query)).length===0;$i(()=>u&&void r.replace({query:{...n.query,...l}}));let d=()=>`${n.path}?${CN(n.query.view)??``}`,f=d();F(()=>s(n.query),(e,t)=>{d()!==f||u&&t===void 0||EN(i,{query:e})},{deep:!0,immediate:!0});let p=J({get:()=>CN(n.query[`${a}q`])??``,set:e=>c({[`${a}q`]:e.trim()?e:void 0})}),m=J(()=>{let t=CN(n.query[`${a}sort`])??``,r=t.replace(/^-/,``),i=e.sorts.find(e=>e.key===r),o=i??e.sorts.find(t=>t.key===e.defaultSort);return{field:o,dir:i?t.startsWith(`-`)?`desc`:`asc`:o.dir,chosen:!!i}});function h(t,n){let r=e.sorts.find(e=>e.key===t);c({[`${a}sort`]:`${(n??r.dir)===`desc`?`-`:``}${t}`})}let g=()=>c({[`${a}sort`]:void 0});function _(e){let{field:t,dir:n,chosen:r}=m.value;!r||t.key!==e?h(e,`desc`):n===`desc`?h(e,`asc`):g()}let v=J(()=>Object.fromEntries(e.filters.map(e=>[e.key,(CN(n.query[`${a}${SN}${e.key}`])??``).split(`,`).filter(Boolean)])));function y(e,t){let n=v.value[e]??[],r=n.includes(t)?n.filter(e=>e!==t):[...n,t];c({[`${a}${SN}${e}`]:r.join(`,`)||void 0})}let b=e=>c({[`${a}${SN}${e}`]:void 0}),x=()=>c({[`${a}q`]:void 0,[`${a}archived`]:void 0,...Object.fromEntries(e.filters.map(e=>[`${a}${SN}${e.key}`,void 0]))}),S=J(()=>{let e=CN(n.query[`${a}archived`]);return e===`with`||e===`only`?e:`without`}),C=e=>c({[`${a}archived`]:e===`without`?void 0:e}),w=M(o.group!==void 0&&(o.group===``||e.groups.some(e=>e.key===o.group))?o.group:e.defaultGroup);function T(e){w.value=e,EN(i,{group:e})}function ee(e){if(e.options)return e.options;let n=new Set(t().flatMap(e.values));for(let t of v.value[e.key]??[])n.add(t);return[...n].sort().map(t=>({value:t,label:e.optionLabel?.(t)??t}))}let E=J(()=>{let n=p.value.toLowerCase().split(/\s+/).filter(Boolean);return t().filter(t=>{if(e.archived){let n=e.archived(t);if(S.value===`without`&&n||S.value===`only`&&!n)return!1}for(let n of e.filters){let e=v.value[n.key]??[];if(e.length>0&&!n.values(t).some(t=>e.includes(t)))return!1}let r=_N(e,t).toLowerCase();return n.every(e=>r.includes(e))})}),te=J(()=>{let{field:t,dir:n}=m.value,r=n===`asc`?1:-1;return[...E.value].sort((n,i)=>{let a=t.value(n),o=t.value(i),s=Number(a==null||a===``)-Number(o==null||o===``);return s===0?((typeof a==`number`&&typeof o==`number`?a-o:String(a).localeCompare(String(o)))||e.id(n).localeCompare(e.id(i)))*r:s})}),ne=J(()=>{let t=e.groups.find(e=>e.key===w.value),n=S.value!==`only`&&!v.value.status?.length,r=t=>n?{items:t.filter(t=>!e.ended?.(t)),ended:t.filter(t=>e.ended?.(t))}:{items:t,ended:[]};return t?xN(t,te.value).map(({key:e,label:n,status:i,detail:a,items:o})=>{let s=t.leader?.(e);return{key:e,label:n,status:i,leader:s,detail:a,...r(o.filter(e=>e!==s))}}):te.value.length?[{key:``,label:``,...r(te.value)}]:[]}),re=Qt(new Set(o.collapsed??[])),D=Qt(new Set(o.endedFolded??[])),ie=(e,t,n)=>{e.has(t)?e.delete(t):e.add(t),EN(i,{[n]:[...e]})};return{spec:e,search:p,sort:m,setSort:h,clearSort:g,cycleSort:_,filters:v,toggleFilter:y,clearFilter:b,clearAll:x,activeFilters:J(()=>e.filters.flatMap(e=>(v.value[e.key]??[]).map(t=>({field:e,value:t,label:ee(e).find(e=>e.value===t)?.label??t})))),optionsOf:ee,archived:S,setArchived:C,group:w,setGroup:T,total:J(()=>t().length),shown:J(()=>E.value.length),sorted:te,groups:ne,collapsed:re,endedFolded:D,toggleCollapsed:e=>ie(re,e,`collapsed`),toggleEnded:e=>ie(D,e,`endedFolded`)}}var ON=`未分組`;function kN(e,t){if(!e)return!1;let n=Q.summary?.hub;return e===t||n!==void 0&&e===`${n}:${t}`}var AN=e=>e?Q.summary?.groups.find(t=>t.id===e):void 0;function jN(e=Q.summary?.groups??[]){return[...e].sort((e,t)=>Number(gN(e.status))-Number(gN(t.status))||mN(e.priority).localeCompare(mN(t.priority))||e.id.localeCompare(t.id))}var MN=e=>e===`未分組`?ON:`${e} ${AN(e)?.title??``}`.trim();function NN(e){return{key:`group`,label:`組`,value:t=>e(t)??`未分組`,get order(){return jN().map(e=>e.id)},trailing:[ON],groupLabel:MN,detail:e=>{let t=AN(e);return t&&{ref:t.id,title:t.title,status:t.status,priority:t.priority??null,trigger:t.trigger,summary:t.summary}}}}function PN(e){return{key:`group`,label:`組`,values:t=>[e(t)||`未分組`],optionLabel:MN}}var FN={key:0,class:`pb-8`},IN={key:0,class:`text-xs`},LN={class:`text-xs`},RN={class:`text-xs`},zN={class:`flex flex-col gap-1.5 text-sm`},BN={class:`shrink-0 font-mono text-xs text-muted-foreground`},VN={class:`shrink-0`},HN=[`title`],UN={key:0,class:`text-sm text-muted-foreground`},WN={key:1,class:`px-5 text-muted-foreground`},GN=I({__name:`GroupPeek`,props:{id:{}},setup(e){let t=e,{open:n}=FC(),r=J(()=>AN(t.id)),i=e=>{let t=r.value?.order.indexOf(e)??-1;return t<0?2**53-1:t},a=J(()=>(Q.summary?.mainlines??[]).filter(e=>kN(e.group,t.id)&&!e.archivedAt).sort((e,t)=>i(e.id)-i(t.id))),o=J(()=>Q.issues.filter(e=>kN(e.group,t.id)&&!e.archivedAt).sort((e,t)=>i(e.id)-i(t.id))),s=e=>Q.sessions.filter(e=>!e.archivedAt&&(e.status===`active`||e.status===`paused`)).filter(t=>t.actions.some(t=>(t.status===`doing`||t.status===`blocked`)&&t.serves.some(e))).map(e=>({session:e,name:jw(e)})),c=e=>s(t=>t.startsWith(`${e}/`)||t.startsWith(`${e}#`)),l=J(()=>s(e=>e.startsWith(`${t.id}#`))),u=J(()=>(Q.relations.groupMembers[t.id]??[]).filter(e=>!e.archived)),d=J(()=>u.value.filter(e=>e.kind===`mainline`)),f=J(()=>u.value.filter(e=>e.kind===`issue`));return(i,s)=>r.value?(B(),V(`div`,FN,[W(MD,{id:r.value.id,title:r.value.title,type:`group`,status:r.value.status},{default:P(()=>[W(kE,{status:r.value.status},null,8,[`status`])]),_:1},8,[`id`,`title`,`status`]),W(ID,null,{default:P(()=>[W(QD,{columns:1},{default:P(()=>[W($,{label:`優先度`,icon:N(_d)},{default:P(()=>[W(TE,{priority:r.value.priority},null,8,[`priority`]),!r.value.priority||r.value.priority===`P2`?(B(),V(`span`,IN,`P2`)):K(``,!0)]),_:1},8,[`icon`]),r.value.trigger?(B(),H($,{key:0,label:`時機`,icon:N(rd)},{default:P(()=>[G(j(r.value.trigger),1)]),_:1},8,[`icon`])):K(``,!0),r.value.origin?(B(),H($,{key:1,label:`來源`,icon:N(cd)},{default:P(()=>[W($j,q(N(Iw)(r.value.origin),{onOpen:s[0]||=e=>N(n)(e,{chain:!0})}),null,16)]),_:1},8,[`icon`])):K(``,!0),r.value.category?(B(),H($,{key:2,label:`分類`,icon:N(nf)},{default:P(()=>[G(j(r.value.category),1)]),_:1},8,[`icon`])):K(``,!0),r.value.labels?.length?(B(),H($,{key:3,label:`標籤`,icon:N(rf)},{default:P(()=>[(B(!0),V(z,null,L(r.value.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))]),_:1},8,[`icon`])):K(``,!0),W($,{label:`建立`,icon:N(Gu)},{default:P(()=>[U(`span`,LN,j(r.value.created),1)]),_:1},8,[`icon`]),r.value.closedAt?(B(),H($,{key:4,label:`結束`,icon:N(Uu)},{default:P(()=>[U(`span`,RN,j(r.value.closedAt),1)]),_:1},8,[`icon`])):K(``,!0),r.value.resolution?(B(),H($,{key:5,label:`結果`,icon:N($u)},{default:P(()=>[G(j(r.value.resolution),1)]),_:1},8,[`icon`])):K(``,!0)]),_:1})]),_:1}),r.value.body.trim()?(B(),H(ID,{key:0,title:`內文`},{default:P(()=>[W(Cj,{source:r.value.body},null,8,[`source`])]),_:1})):K(``,!0),W(ID,{title:`解決條件`,count:r.value.criteria?.length??0},{default:P(()=>[W(fN,{items:r.value.criteria??[],"ref-prefix":`${r.value.id}#`,version:r.value.version},null,8,[`items`,`ref-prefix`,`version`]),(B(!0),V(z,null,L(l.value,({session:e,name:t})=>(B(),H(Oj,{key:e.id,peek:N(TC)(e.id),title:t,status:e.status},{default:P(()=>[...s[1]||=[G(`在做組的條件`,-1)]]),_:1},8,[`peek`,`title`,`status`]))),128))]),_:1},8,[`count`]),r.value.grants?.length?(B(),H(ID,{key:1,title:`授權`,count:r.value.grants.length},{default:P(()=>[U(`ul`,zN,[(B(!0),V(z,null,L(r.value.grants,e=>(B(),V(`li`,{key:e.id,class:`flex min-w-0 items-baseline gap-2`},[U(`span`,BN,j(e.id),1),U(`span`,VN,j(e.action),1),U(`span`,{class:`min-w-0 truncate text-muted-foreground`,title:e.note?`${e.target}:${e.note}`:e.target},j(e.target),9,HN)]))),128))])]),_:1},8,[`count`])):K(``,!0),W(ID,{title:`主脈絡`,count:a.value.length},{default:P(()=>[(B(!0),V(z,null,L(a.value,(e,t)=>(B(),H(Oj,{key:e.id,peek:e.id,id:`${t+1}. ${e.id}`,title:e.title,status:e.status},{default:P(()=>[(B(!0),V(z,null,L(c(e.id),e=>(B(),V(`span`,{key:e.session.id,class:`mr-2`},j(e.name),1))),128)),G(j(N(Yw)[e.status]??e.status),1)]),_:2},1032,[`peek`,`id`,`title`,`status`]))),128)),a.value.length===0?(B(),V(`p`,UN,[s[2]||=G(`還沒有主脈絡在這組。用 `,-1),U(`code`,null,`mainflow mainline set <m> --group `+j(r.value.id),1),s[3]||=G(` 加入。`,-1)])):K(``,!0)]),_:1},8,[`count`]),o.value.length?(B(),H(ID,{key:2,title:`待辦事項`,count:o.value.length},{default:P(()=>[(B(!0),V(z,null,L(o.value,e=>(B(),H(Oj,{key:e.id,peek:e.id,id:e.id,title:e.title,status:e.status},{default:P(()=>[W(TE,{priority:e.priority},null,8,[`priority`])]),_:2},1032,[`peek`,`id`,`title`,`status`]))),128))]),_:1},8,[`count`])):K(``,!0),u.value.length?(B(),H(ID,{key:3,title:`其他 hub 的成員`,count:u.value.length},{default:P(()=>[(B(!0),V(z,null,L([...d.value,...f.value],e=>(B(),H(Oj,{key:e.ref,peek:e.ref,id:e.ref,title:e.title,status:e.status},{default:P(()=>[G(j(e.kind===`issue`?`待辦`:`主脈絡`)+` · `+j(N(Yw)[e.status]??e.status),1)]),_:2},1032,[`peek`,`id`,`title`,`status`]))),128))]),_:1},8,[`count`])):K(``,!0),W(Rj,{self:t.id,links:r.value.links},null,8,[`self`,`links`]),r.value.refs?.length?(B(),H(ID,{key:4,title:`參考來源`,count:r.value.refs.length},{default:P(()=>[W(Uj,{refs:r.value.refs},null,8,[`refs`])]),_:1},8,[`count`])):K(``,!0)])):(B(),V(`p`,WN,`找不到組 `+j(e.id)+`。`,1))}}),KN={key:0,class:`pb-8`},qN={key:0,class:`text-xs`},JN={class:`text-xs`},YN={class:`text-xs`},XN={class:`text-xs`},ZN={key:1,class:`px-5 text-muted-foreground`},QN=I({__name:`IssuePeek`,props:{id:{}},setup(e){let t=e,{open:n}=FC(),r=J(()=>Q.issues.find(e=>e.id===t.id)),i=e=>n(e,{chain:!0}),a=()=>r.value&&dw(()=>XC.archiveIssue(r.value.id,!r.value.archivedAt,r.value.version));return Rw([r.value?.origin,r.value?.plannedIn]),(n,o)=>r.value?(B(),V(`div`,KN,[W(MD,{id:r.value.id,title:r.value.title,type:`issue`,status:r.value.status},{default:P(()=>[W(kE,{status:r.value.status},null,8,[`status`]),W(iE,{archived:!!r.value.archivedAt,onToggle:a},null,8,[`archived`])]),_:1},8,[`id`,`title`,`status`]),W(ID,null,{default:P(()=>[W(QD,{columns:1},{default:P(()=>[r.value.priority?(B(),H($,{key:0,label:`優先度`,icon:N(_d)},{default:P(()=>[W(TE,{priority:r.value.priority},null,8,[`priority`]),r.value.priority===`P2`?(B(),V(`span`,qN,`P2`)):K(``,!0)]),_:1},8,[`icon`])):K(``,!0),r.value.group?(B(),H($,{key:1,label:`組`,icon:N(Hu)},{default:P(()=>[W($j,q(N(Iw)(r.value.group),{onOpen:i}),null,16)]),_:1},8,[`icon`])):K(``,!0),r.value.due?(B(),H($,{key:2,label:`到期`,icon:N(Wu)},{default:P(()=>[W(_E,{day:r.value.due,ended:r.value.status===`closed`},null,8,[`day`,`ended`])]),_:1},8,[`icon`])):K(``,!0),r.value.plannedIn?(B(),H($,{key:3,label:`排入`,icon:N(Ku)},{default:P(()=>[W($j,q(N(Iw)(r.value.plannedIn),{onOpen:i}),null,16)]),_:1},8,[`icon`])):K(``,!0),r.value.origin?(B(),H($,{key:4,label:`來源`,icon:N(cd)},{default:P(()=>[W($j,q(N(Iw)(r.value.origin),{onOpen:i}),null,16)]),_:1},8,[`icon`])):K(``,!0),r.value.category?(B(),H($,{key:5,label:`分類`,icon:N(nf)},{default:P(()=>[G(j(r.value.category),1)]),_:1},8,[`icon`])):K(``,!0),r.value.labels?.length?(B(),H($,{key:6,label:`標籤`,icon:N(rf)},{default:P(()=>[(B(!0),V(z,null,L(r.value.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))]),_:1},8,[`icon`])):K(``,!0),W($,{label:`建立`,icon:N(Gu)},{default:P(()=>[U(`span`,JN,j(r.value.created),1)]),_:1},8,[`icon`]),r.value.closedAt?(B(),H($,{key:7,label:`結束`,icon:N(Uu)},{default:P(()=>[U(`span`,YN,j(r.value.closedAt),1)]),_:1},8,[`icon`])):K(``,!0),r.value.resolution?(B(),H($,{key:8,label:`結果`,icon:N($u)},{default:P(()=>[G(j(r.value.resolution),1)]),_:1},8,[`icon`])):K(``,!0),r.value.archivedAt?(B(),H($,{key:9,label:`封存`,icon:N(Pu)},{default:P(()=>[U(`span`,XN,j(r.value.archivedAt),1)]),_:1},8,[`icon`])):K(``,!0)]),_:1})]),_:1}),r.value.body.trim()?(B(),H(ID,{key:0,title:`內文`},{default:P(()=>[W(Cj,{source:r.value.body},null,8,[`source`])]),_:1})):K(``,!0),W(Rj,{self:t.id,links:r.value.links},null,8,[`self`,`links`]),r.value.refs?.length?(B(),H(ID,{key:1,title:`參考來源`,count:r.value.refs.length},{default:P(()=>[W(Uj,{refs:r.value.refs},null,8,[`refs`])]),_:1},8,[`count`])):K(``,!0)])):(B(),V(`p`,ZN,`找不到待辦 `+j(e.id)+`。`,1))}}),$N=[`title`],eP={class:`h-1.5 w-14 overflow-hidden rounded-full bg-primary/20`},tP={class:`min-w-7 tabular-nums`},nP=I({__name:`ProgressBar`,props:{done:{},total:{}},setup(e){let t=e,n=J(()=>t.total===0?0:Math.round(t.done/t.total*100));return(t,r)=>(B(),V(`span`,{class:`inline-flex items-center gap-2 text-xs text-muted-foreground`,title:`${e.done}/${e.total}`},[U(`span`,eP,[U(`span`,{class:`block h-full rounded-full bg-primary`,style:he({width:`${n.value}%`})},null,4)]),U(`span`,tP,j(e.done)+`/`+j(e.total),1)],8,$N))}}),rP={key:0,class:`text-xs`},iP={class:`text-xs`},aP={class:`text-xs`},oP={class:`text-xs tabular-nums`},sP={class:`text-xs`},cP={class:`flex flex-col gap-2`},lP={class:`mr-2 font-mono text-xs text-muted-foreground`},uP={class:`w-full text-xs`},dP={class:`py-1.5 tabular-nums`},fP={class:`text-right tabular-nums`},pP={class:`text-right tabular-nums`},mP={class:`pl-3 text-muted-foreground`},hP={key:0,class:`text-sm text-muted-foreground`},gP=I({__name:`MainlineBody`,props:{mainline:{},columns:{default:1}},setup(e){let t=e,{open:n}=FC(),r=J(()=>t.mainline),i=J(()=>r.value.tasks.flatMap(e=>e.checklist).filter(e=>!e.dropped)),a=J(()=>r.value.criteria.filter(e=>!e.dropped)),o=J(()=>r.value.decisions.filter(e=>e.status===`proposed`)),s=J(()=>Math.round((r.value.costs??[]).reduce((e,t)=>e+(t.actual??0),0)*100)/100),c=J(()=>r.value.budget?.unit??r.value.costs?.[0]?.unit??``),l=J(()=>Q.issues.filter(e=>!e.archivedAt&&(e.origin?.startsWith(`${r.value.id}/`)||e.plannedIn?.startsWith(`${r.value.id}/`)))),u=J(()=>Fw(r.value.id)),d=[`done`,`dropped`];return(t,f)=>(B(),V(z,null,[W(ID,null,{default:P(()=>[W(QD,{columns:e.columns},{default:P(()=>[W($,{label:`解決條件`,icon:N(af)},{default:P(()=>[W(nP,{done:a.value.filter(e=>e.done).length,total:a.value.length},null,8,[`done`,`total`])]),_:1},8,[`icon`]),W($,{label:`checklist`,icon:N(Pd)},{default:P(()=>[W(nP,{done:i.value.filter(e=>e.done).length,total:i.value.length},null,8,[`done`,`total`])]),_:1},8,[`icon`]),r.value.group?(B(),H($,{key:0,label:`組`,icon:N(Hu)},{default:P(()=>[W($j,q(N(Iw)(r.value.group),{onOpen:f[0]||=e=>N(n)(e,{chain:!0})}),null,16)]),_:1},8,[`icon`])):K(``,!0),r.value.priority?(B(),H($,{key:1,label:`優先度`,icon:N(_d)},{default:P(()=>[W(TE,{priority:r.value.priority},null,8,[`priority`]),r.value.priority===`P2`?(B(),V(`span`,rP,`P2`)):K(``,!0)]),_:1},8,[`icon`])):K(``,!0),r.value.due?(B(),H($,{key:2,label:`到期`,icon:N(Wu)},{default:P(()=>[W(_E,{day:r.value.due,ended:d.includes(r.value.status)},null,8,[`day`,`ended`])]),_:1},8,[`icon`])):K(``,!0),r.value.category?(B(),H($,{key:3,label:`分類`,icon:N(nf)},{default:P(()=>[G(j(r.value.category),1)]),_:1},8,[`icon`])):K(``,!0),r.value.labels?.length?(B(),H($,{key:4,label:`標籤`,icon:N(rf)},{default:P(()=>[(B(!0),V(z,null,L(r.value.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))]),_:1},8,[`icon`])):K(``,!0),W($,{label:`建立`,icon:N(Gu)},{default:P(()=>[U(`span`,iP,j(r.value.created),1)]),_:1},8,[`icon`]),r.value.closedAt?(B(),H($,{key:5,label:`結束`,icon:N(Uu)},{default:P(()=>[U(`span`,aP,j(r.value.closedAt),1)]),_:1},8,[`icon`])):K(``,!0),r.value.resolution?(B(),H($,{key:6,label:`結果`,icon:N($u)},{default:P(()=>[G(j(r.value.resolution),1)]),_:1},8,[`icon`])):K(``,!0),r.value.origin?(B(),H($,{key:7,label:`來源`,icon:N(cd)},{default:P(()=>[W($j,q(N(Iw)(r.value.origin),{onOpen:f[1]||=e=>N(n)(e,{chain:!0})}),null,16)]),_:1},8,[`icon`])):K(``,!0),r.value.budget||r.value.costs?.length?(B(),H($,{key:8,label:`花費`,icon:N(cf)},{default:P(()=>[U(`span`,oP,[G(j(s.value),1),r.value.budget?(B(),V(z,{key:0},[G(` / `+j(r.value.budget.amount),1)],64)):K(``,!0),G(` `+j(c.value),1)])]),_:1},8,[`icon`])):K(``,!0),r.value.archivedAt?(B(),H($,{key:9,label:`封存`,icon:N(Pu)},{default:P(()=>[U(`span`,sP,j(r.value.archivedAt),1)]),_:1},8,[`icon`])):K(``,!0)]),_:1},8,[`columns`])]),_:1}),o.value.length?(B(),H(ID,{key:0,title:`待裁決的決策`,count:o.value.length},{default:P(()=>[U(`div`,cP,[(B(!0),V(z,null,L(o.value,e=>(B(),H(N(_g),{key:e.id,variant:`warning`,class:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:t=>N(n)(N(wC)(r.value.id,e.id),{chain:!0})},{default:P(()=>[W(N(Qu)),W(N(yg),null,{default:P(()=>[U(`span`,lP,j(e.id),1),G(j(e.title),1)]),_:2},1024),e.affects?.length?(B(),H(N(vg),{key:0,class:`text-xs text-muted-foreground`},{default:P(()=>[G(`在等它的有 `+j(e.affects.join(`、`)),1)]),_:2},1024)):K(``,!0)]),_:2},1032,[`onClick`]))),128))])]),_:1},8,[`count`])):K(``,!0),W(ID,{title:`解決條件`,count:r.value.criteria.length},{default:P(()=>[W(fN,{items:r.value.criteria,"ref-prefix":`${r.value.id}#`,version:r.value.version},null,8,[`items`,`ref-prefix`,`version`])]),_:1},8,[`count`]),r.value.body.trim()?(B(),H(ID,{key:1,title:`內文`},{default:P(()=>[W(Cj,{source:r.value.body},null,8,[`source`])]),_:1})):K(``,!0),W(Rj,{self:r.value.id,links:r.value.links,mainline:``},null,8,[`self`,`links`]),r.value.refs?.length?(B(),H(ID,{key:2,title:`參考來源`,count:r.value.refs.length},{default:P(()=>[W(Uj,{refs:r.value.refs},null,8,[`refs`])]),_:1},8,[`count`])):K(``,!0),r.value.costs?.length?(B(),H(ID,{key:3,title:`花費明細`,count:r.value.costs.length},{default:P(()=>[U(`table`,uP,[f[2]||=U(`thead`,{class:`text-muted-foreground`},[U(`tr`,{class:`border-b`},[U(`th`,{class:`py-1.5 text-left font-medium`},`日期`),U(`th`,{class:`text-left font-medium`},`項目`),U(`th`,{class:`text-right font-medium`},`預估`),U(`th`,{class:`text-right font-medium`},`實際`),U(`th`,{class:`pl-3 text-left font-medium`},`備註`)])],-1),U(`tbody`,null,[(B(!0),V(z,null,L(r.value.costs,(e,t)=>(B(),V(`tr`,{key:t,class:`border-b`},[U(`td`,dP,j(e.date),1),U(`td`,null,j(e.item),1),U(`td`,fP,j(e.estimate??``),1),U(`td`,pP,j(e.actual??``),1),U(`td`,mP,j(e.note??``),1)]))),128))])])]),_:1},8,[`count`])):K(``,!0),l.value.length?(B(),H(ID,{key:4,title:`相關的待辦`,count:l.value.length},{default:P(()=>[(B(!0),V(z,null,L(l.value,e=>(B(),H(Oj,{key:e.id,peek:e.id,id:e.id,title:e.title,status:e.status},null,8,[`peek`,`id`,`title`,`status`]))),128))]),_:1},8,[`count`])):K(``,!0),W(ID,{title:`推進過它的會話`,count:u.value.length},{default:P(()=>[(B(!0),V(z,null,L(u.value,({session:e,actions:t})=>(B(),H(Oj,{key:e.id,peek:N(TC)(e.id),title:N(jw)(e),status:e.status},{default:P(()=>[G(j(t.length)+` 個行動`,1)]),_:2},1032,[`peek`,`title`,`status`]))),128)),u.value.length===0?(B(),V(`p`,hP,`這台電腦上沒有推進它的會話。會話只記在本機。`)):K(``,!0)]),_:1},8,[`count`])],64))}}),_P={class:`inline-flex h-7 items-center gap-1.5 rounded-full border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-accent focus-within:ring-3 focus-within:ring-ring/50`},vP=[`value`],yP=[`value`],bP=I({__name:`StatusSelect`,props:{status:{},options:{}},emits:[`change`],setup(e,{emit:t}){let n=t;return(t,r)=>(B(),V(`label`,_P,[W(OE,{status:e.status},null,8,[`status`]),U(`select`,{class:`cursor-pointer bg-transparent outline-none`,value:e.status,onChange:r[0]||=e=>n(`change`,e.target.value)},[(B(!0),V(z,null,L(e.options,e=>(B(),V(`option`,{key:e,value:e},j(N(Yw)[e]??e),9,yP))),128))],40,vP)]))}}),xP={key:0,class:`pb-8`},SP={key:1,class:`px-5 text-muted-foreground`},CP=I({__name:`MainlinePeek`,props:{m:{}},setup(e){let t=e,{mainline:n}=eM(()=>t.m),r=e=>n.value&&dw(()=>XC.mainlineStatus(t.m,e,n.value.version)),i=e=>n.value&&dw(()=>XC.mainlineTitle(t.m,e,n.value.version)),a=()=>n.value&&dw(()=>XC.archive(t.m,!n.value.archivedAt,n.value.version));return(t,o)=>N(n)?(B(),V(`div`,xP,[W(MD,{id:N(n).id,title:N(n).title,type:`mainline`,status:N(n).status,editable:``,onRename:i},{default:P(()=>[W(bP,{status:N(n).status,options:N(Ww),onChange:r},null,8,[`status`,`options`]),W(iE,{archived:!!N(n).archivedAt,onToggle:a},null,8,[`archived`]),W(N(sC),{variant:`ghost`,size:`xs`,class:`ml-auto text-muted-foreground`,"as-child":``},{default:P(()=>[W(N(Am),{to:`/mainlines/${N(n).id}`},{default:P(()=>[W(N(ef)),o[0]||=G(`開啟工作區`,-1)]),_:1},8,[`to`])]),_:1})]),_:1},8,[`id`,`title`,`status`]),W(gP,{mainline:N(n)},null,8,[`mainline`])])):(B(),V(`p`,SP,`載入 `+j(e.m)+`…`,1))}}),wP=[`datetime`,`title`],TP=I({__name:`RelativeTime`,props:{at:{}},setup(e){let t=e,n=If({scheduler:e=>Cf(e,6e4)}),r=new Intl.RelativeTimeFormat(`zh-TW`,{numeric:`auto`}),i=J(()=>new Date(cE(t.at))),a=J(()=>{let e=Math.round((n.value.getTime()-i.value.getTime())/6e4);if(t.at.length===10){let n=Math.round(e/1440);return n>=0&&n<7?r.format(-n,`day`):t.at}return e<1?`剛剛`:e<60?r.format(-e,`minute`):e<1440?r.format(-Math.round(e/60),`hour`):e<10080?r.format(-Math.round(e/1440),`day`):uE(t.at)});return(t,n)=>(B(),V(`time`,{datetime:e.at,title:N(fE)(e.at)},j(a.value),9,wP))}}),EP={key:0,class:`pb-8`},DP=[`title`],OP={key:0,class:`flex flex-col gap-1 text-sm`},kP={key:0},AP={key:0,class:`text-xs text-muted-foreground`},jP={key:1,class:`text-xs text-muted-foreground`},MP={class:`font-mono text-xs`},NP={class:`flex flex-col`},PP=[`aria-expanded`,`onClick`],FP={class:`mt-px shrink-0 font-mono text-xs text-muted-foreground`},IP={class:`min-w-0 flex-1`},LP={key:2,class:`shrink-0 text-xs text-muted-foreground tabular-nums`},RP={class:`flex flex-wrap gap-1 pb-1 pl-12`},zP={key:0,class:`pb-1 pl-12 text-xs text-muted-foreground`},BP={key:1,class:`mb-2 ml-12 flex flex-col gap-1.5 rounded-md border p-3 text-xs`},VP={key:0,class:`text-muted-foreground`},HP={key:1,class:`text-muted-foreground`},UP={key:2,class:`text-muted-foreground`},WP={class:`w-20 shrink-0 text-muted-foreground`},GP={key:0,class:`text-muted-foreground`},KP={key:1,class:`text-destructive`},qP={key:0,class:`text-sm text-muted-foreground`},JP={key:0,class:`text-sm text-muted-foreground`},YP={class:`w-20 text-muted-foreground`},XP={class:`tabular-nums`},ZP={key:1,class:`px-5 text-muted-foreground`},QP=I({__name:`SessionPeek`,props:{id:{}},setup(e){let t=e,{open:n}=FC(),r=J(()=>Q.sessions.find(e=>e.id===t.id)),i=M(null),a=M(null),o=e=>Q.sessions.find(t=>t.id===e),s=J(()=>{let e=r.value;return e?[...e.delegatedFrom?[{label:`委派自`,id:e.delegatedFrom}]:[],...e.handoffFrom?[{label:`接手自`,id:e.handoffFrom}]:[],...Q.sessions.filter(t=>t.delegatedFrom===e.id).map(e=>({label:`委派給`,id:e.id})),...Q.sessions.filter(t=>t.handoffFrom===e.id).map(e=>({label:`交接給`,id:e.id}))]:[]});F(()=>[r.value?.id,r.value?.actions.length,r.value?.actions.map(e=>e.status).join()],async()=>{let e=r.value;if(e){for(let t of new Set(e.actions.flatMap(e=>e.serves.map(e=>QC(e).m))))lw(t).catch(e=>Q.error=e.message);i.value=await XC.trace(e.id).catch(()=>null)}},{immediate:!0});function c(e){let{m:t,t:n,item:r}=QC(e);if(!n){let n=Q.mainlines[t]?.criteria.find(e=>e.id===r);return{ref:e,task:t,text:n?.text,done:n?.done??!1}}let i=Q.mainlines[t]?.tasks.find(e=>e.id===n);return{ref:e,task:`${t}/${n}`,text:i?.checklist.find(e=>e.id===r)?.text,done:i?.checklist.find(e=>e.id===r)?.done??!1}}let l=J(()=>[...new Set((r.value?.actions??[]).flatMap(e=>e.serves))].map(c));function u(e){return Object.keys(Xw).map(t=>({kind:t,items:e.filter(e=>e.kind===t)})).filter(e=>e.items.length>0)}let d=e=>u(i.value?.byAction[e]??[]),f=e=>(i.value?.byAction[e]??[]).length,p=()=>r.value&&dw(()=>XC.archiveSession(r.value.id,!r.value.archivedAt));return(t,c)=>r.value?(B(),V(`div`,EP,[W(MD,{title:N(jw)(r.value),type:`session`,status:r.value.status},{notice:P(()=>[r.value.description||r.value.summary?(B(),V(`div`,OP,[r.value.description?(B(),V(`p`,kP,[G(j(r.value.description),1),r.value.depth===void 0?K(``,!0):(B(),V(`span`,AP,` · 深度 `+j(r.value.depth),1))])):K(``,!0),r.value.summary?(B(),V(`p`,jP,j(r.value.summary),1)):K(``,!0)])):K(``,!0)]),default:P(()=>[W(kE,{status:r.value.status},null,8,[`status`]),r.value.elsewhere?(B(),V(`span`,{key:0,title:`工作目錄 ${r.value.cwd} 不在這台電腦上`,"data-elsewhere":``},`其他環境`,8,DP)):K(``,!0),W(DD,{text:r.value.id,label:r.value.id.slice(-8)},null,8,[`text`,`label`]),W(iE,{archived:!!r.value.archivedAt,onToggle:p},null,8,[`archived`])]),_:1},8,[`title`,`status`]),W(ID,null,{default:P(()=>[W(QD,{columns:1},{default:P(()=>[W($,{label:`ID`,icon:N(Od)},{default:P(()=>[W(DD,{text:r.value.id},null,8,[`text`])]),_:1},8,[`icon`]),W($,{label:`agent`,icon:N(Vu)},{default:P(()=>[W(N(nE),{variant:`secondary`},{default:P(()=>[G(j(r.value.agent),1)]),_:1})]),_:1},8,[`icon`]),i.value?.model??r.value.model?(B(),H($,{key:0,label:`模型`,icon:N(ud)},{default:P(()=>[U(`span`,MP,j(i.value?.model??r.value.model),1)]),_:1},8,[`icon`])):K(``,!0),r.value.effort?(B(),H($,{key:1,label:`effort`,icon:N(wd)},{default:P(()=>[G(j(r.value.effort),1)]),_:1},8,[`icon`])):K(``,!0),W($,{label:`開始`,icon:N(rd)},{default:P(()=>[W(TP,{at:r.value.started,class:`text-xs`},null,8,[`at`])]),_:1},8,[`icon`]),r.value.branch?(B(),H($,{key:2,label:`分支`,icon:N(Td)},{default:P(()=>[W(DD,{text:r.value.branch},null,8,[`text`])]),_:1},8,[`icon`])):K(``,!0),r.value.worktree?(B(),H($,{key:3,label:`worktree`,icon:N(xd)},{default:P(()=>[W(DD,{text:r.value.worktree},null,8,[`text`])]),_:1},8,[`icon`])):K(``,!0),W($,{label:`工作目錄`,icon:N(Sd)},{default:P(()=>[W(DD,{text:r.value.cwd},null,8,[`text`])]),_:1},8,[`icon`]),r.value.transcript?(B(),H($,{key:4,label:`對話紀錄`,icon:N(Xd)},{default:P(()=>[W(DD,{text:r.value.transcript,class:`min-w-0`},null,8,[`text`]),W(N(sC),{variant:`ghost`,size:`icon-xs`,class:`text-muted-foreground`,title:`在 Finder 顯示`,"aria-label":`在 Finder 顯示`,onClick:c[0]||=e=>N(dw)(()=>N(XC).reveal(r.value.transcript))},{default:P(()=>[W(N(yd))]),_:1})]),_:1},8,[`icon`])):K(``,!0)]),_:1})]),_:1}),W(ID,{title:`行動佇列`,count:r.value.actions.length},{default:P(()=>[U(`ul`,NP,[(B(!0),V(z,null,L(r.value.actions,e=>(B(),V(`li`,{key:e.id,class:`flex flex-col`},[U(`button`,{type:`button`,class:`-mx-2 flex min-h-8 items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-[120ms] hover:bg-accent/50`,"aria-expanded":a.value===e.id,onClick:t=>a.value=a.value===e.id?null:e.id},[a.value===e.id?(B(),H(N(Ju),{key:0,class:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})):(B(),H(N(Xu),{key:1,class:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})),W(OE,{status:e.status,class:`mt-0.5 shrink-0`},null,8,[`status`]),U(`span`,FP,j(e.id),1),U(`span`,IP,j(e.do),1),e.startedAt?(B(),V(`span`,LP,j(N(dE)(e.startedAt))+j(e.doneAt?`–${N(dE)(e.doneAt)}`:``),1)):K(``,!0)],8,PP),U(`div`,RP,[(B(!0),V(z,null,L(e.serves,e=>(B(),H($j,q({key:e},{ref_for:!0},N(Iw)(e.split(`#`)[0]),{id:e,onOpen:()=>N(n)(e.split(`#`)[0],{chain:!0})}),null,16,[`id`,`onOpen`]))),128))]),e.note?(B(),V(`p`,zP,j(e.note),1)):K(``,!0),a.value===e.id?(B(),V(`div`,BP,[i.value?.available?e.startedAt?f(e.id)===0?(B(),V(`p`,UP,`這段時間沒有用到 skill、agent,也沒有載入 rule 或用 Read 讀檔。用 Bash 讀的檔不會出現在這裡。`)):K(``,!0):(B(),V(`p`,HP,`這個行動沒有開始時間,追溯不到它的時間窗。`)):(B(),V(`p`,VP,`沒有對話紀錄,無法追溯。`)),(B(!0),V(z,null,L(d(e.id),e=>(B(),V(`div`,{key:e.kind,class:`flex flex-wrap items-baseline gap-1.5`},[U(`span`,WP,j(N(Xw)[e.kind]),1),(B(!0),V(z,null,L(e.items,e=>(B(),H(N(nE),{key:e.path??e.name,variant:`secondary`,class:`font-mono font-normal`,title:e.path??e.name},{default:P(()=>[G(j(e.name),1),e.count>1?(B(),V(`span`,GP,`×`+j(e.count),1)):K(``,!0),e.detail?.startsWith(`blocked`)?(B(),V(`span`,KP,`擋下`)):K(``,!0)]),_:2},1032,[`title`]))),128))]))),128))])):K(``,!0)]))),128))]),r.value.actions.length===0?(B(),V(`p`,qP,`這個會話沒有行動。`)):K(``,!0)]),_:1},8,[`count`]),W(ID,{title:`委派與接手`,count:s.value.length},{default:P(()=>[(B(!0),V(z,null,L(s.value,e=>(B(),H(Oj,{key:e.label+e.id,peek:N(TC)(e.id),label:e.label,title:o(e.id)?N(jw)(o(e.id)):e.id,status:o(e.id)?.status},null,8,[`peek`,`label`,`title`,`status`]))),128)),s.value.length===0?(B(),V(`p`,JP,`沒有委派或交接關係。`)):K(``,!0)]),_:1},8,[`count`]),W(ID,{title:`服務的項目與條件`,count:l.value.length},{default:P(()=>[(B(!0),V(z,null,L(l.value,e=>(B(),H(Oj,{key:e.ref,peek:e.task,id:e.ref,title:e.text},{default:P(()=>[W(N(vE),{"model-value":e.done,disabled:``,class:`pointer-events-none`,"aria-label":e.done?`已完成`:`未完成`},null,8,[`model-value`,`aria-label`])]),_:2},1032,[`peek`,`id`,`title`]))),128))]),_:1},8,[`count`]),i.value?.unattributed.length?(B(),H(ID,{key:0,title:`沒有對應行動的使用`,count:i.value.unattributed.length},{default:P(()=>[(B(!0),V(z,null,L(u(i.value.unattributed),e=>(B(),V(`div`,{key:e.kind,class:`flex min-h-7 items-center gap-2 text-xs`},[U(`span`,YP,j(N(Xw)[e.kind]),1),U(`span`,XP,j(e.items.length),1)]))),128))]),_:1},8,[`count`])):K(``,!0)])):(B(),V(`p`,ZP,`這台電腦上沒有會話 `+j(e.id)+`。`,1))}}),$P={key:0,class:`pb-8`},eF={class:`truncate`},tF={key:0,class:`flex items-center gap-1.5`},nF={key:1},rF={key:2},iF={key:0,class:`text-xs`},aF={class:`text-xs`},oF={class:`text-xs`},sF={class:`text-xs`},cF={class:`shrink-0 font-mono`},lF={class:`truncate`},uF={key:0,class:`text-sm text-muted-foreground`},dF={key:1,class:`px-5 text-muted-foreground`},fF=I({__name:`TaskPeek`,props:{m:{},t:{}},setup(e){let t=e,{open:n}=FC(),{mainline:r}=eM(()=>t.m),i=J(()=>r.value?.tasks.find(e=>e.id===t.t)),a=J(()=>r.value?.tasks.filter(e=>e.parent===t.t)??[]),o=J(()=>(i.value?.checklist??[]).filter(e=>!e.dropped)),s=J(()=>Fw(t.m,t.t)),c=e=>n(e,{chain:!0}),l=J(()=>{let e=i.value?.blockedBy?.waitingFor,t=e?Vw(e):void 0;return t&&t!==`session`&&!e.startsWith(`file:`)?e:void 0});Er(()=>Rw([l.value]));let u=e=>e.slice((r.value?.dir.length??0)+1),d=e=>e.slice(e.lastIndexOf(`/`)+1),f=e=>i.value&&dw(()=>XC.taskStatus(t.m,t.t,e,i.value.version));return(n,p)=>i.value&&N(r)?(B(),V(`div`,$P,[W(MD,{id:`${e.m}/${i.value.id}`,title:i.value.title,type:N(Bw)(i.value),status:i.value.status},{notice:P(()=>[i.value.blockedBy?(B(),H(N(_g),{key:0,variant:`warning`},{default:P(()=>[W(N(ed)),W(N(yg),null,{default:P(()=>[G(`卡住:`+j(i.value.blockedBy.reason),1)]),_:1}),W(N(vg),{class:`text-xs text-muted-foreground`},{default:P(()=>[l.value?(B(),V(`p`,tF,[p[0]||=G(`等待 `,-1),W($j,q(N(Iw)(l.value),{onOpen:c}),null,16)])):i.value.blockedBy.waitingFor?(B(),V(`p`,nF,`等待 `+j(i.value.blockedBy.waitingFor),1)):K(``,!0),i.value.blockedBy.signal?(B(),V(`p`,rF,`看到「`+j(i.value.blockedBy.signal)+`」就可以繼續`,1)):K(``,!0)]),_:1})]),_:1})):K(``,!0)]),default:P(()=>[W(bP,{status:i.value.status,options:N(Gw),onChange:f},null,8,[`status`,`options`]),U(`span`,eF,j(N(r).title),1)]),_:1},8,[`id`,`title`,`type`,`status`]),W(ID,null,{default:P(()=>[W(QD,{columns:1},{default:P(()=>[W($,{label:`checklist`,icon:N(Pd)},{default:P(()=>[W(nP,{done:o.value.filter(e=>e.done).length,total:o.value.length},null,8,[`done`,`total`])]),_:1},8,[`icon`]),i.value.priority?(B(),H($,{key:0,label:`優先度`,icon:N(_d)},{default:P(()=>[W(TE,{priority:i.value.priority},null,8,[`priority`]),i.value.priority===`P2`?(B(),V(`span`,iF,`P2`)):K(``,!0)]),_:1},8,[`icon`])):K(``,!0),W($,{label:`種類`,icon:N(Ad)},{default:P(()=>[G(j(i.value.kind===`branch`?`分支`:`階段`),1)]),_:1},8,[`icon`]),i.value.parent?(B(),H($,{key:1,label:`上層任務`,icon:N(ld)},{default:P(()=>[W($j,q(N(Iw)(N(CC)(e.m,i.value.parent)),{onOpen:c}),null,16)]),_:1},8,[`icon`])):K(``,!0),i.value.repo?(B(),H($,{key:2,label:`倉庫`,icon:N(vd)},{default:P(()=>[G(j(i.value.repo),1)]),_:1},8,[`icon`])):K(``,!0),i.value.branch?(B(),H($,{key:3,label:`分支`,icon:N(Td)},{default:P(()=>[W(DD,{text:i.value.branch},null,8,[`text`])]),_:1},8,[`icon`])):K(``,!0),i.value.base?(B(),H($,{key:4,label:`基底`,icon:N(Ed)},{default:P(()=>[W(DD,{text:i.value.base},null,8,[`text`])]),_:1},8,[`icon`])):K(``,!0),i.value.worktree?(B(),H($,{key:5,label:`worktree`,icon:N(xd)},{default:P(()=>[W(DD,{text:i.value.worktree},null,8,[`text`])]),_:1},8,[`icon`])):K(``,!0),i.value.merge?(B(),H($,{key:6,label:`合併狀態`,icon:N(Dd)},{default:P(()=>[G(j(N($w)[i.value.merge]),1)]),_:1},8,[`icon`])):K(``,!0),i.value.category?(B(),H($,{key:7,label:`分類`,icon:N(nf)},{default:P(()=>[G(j(i.value.category),1)]),_:1},8,[`icon`])):K(``,!0),i.value.labels?.length?(B(),H($,{key:8,label:`標籤`,icon:N(rf)},{default:P(()=>[(B(!0),V(z,null,L(i.value.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))]),_:1},8,[`icon`])):K(``,!0),W($,{label:`建立`,icon:N(Gu)},{default:P(()=>[U(`span`,aF,j(i.value.created),1)]),_:1},8,[`icon`]),i.value.startedAt?(B(),H($,{key:9,label:`開始`,icon:N(Wd)},{default:P(()=>[U(`span`,oF,j(i.value.startedAt),1)]),_:1},8,[`icon`])):K(``,!0),i.value.closedAt?(B(),H($,{key:10,label:`結束`,icon:N(Uu)},{default:P(()=>[U(`span`,sF,j(i.value.closedAt),1)]),_:1},8,[`icon`])):K(``,!0),i.value.resolution?(B(),H($,{key:11,label:`結果`,icon:N($u)},{default:P(()=>[G(j(i.value.resolution),1)]),_:1},8,[`icon`])):K(``,!0),i.value.origin?(B(),H($,{key:12,label:`來源`,icon:N(cd)},{default:P(()=>[W($j,q(N(Iw)(i.value.origin),{onOpen:c}),null,16)]),_:1},8,[`icon`])):K(``,!0)]),_:1})]),_:1}),W(ID,{title:`checklist`,count:i.value.checklist.length},{default:P(()=>[W(fN,{items:i.value.checklist,"ref-prefix":`${e.m}/${i.value.id}#`,version:i.value.version},null,8,[`items`,`ref-prefix`,`version`])]),_:1},8,[`count`]),i.value.body.trim()?(B(),H(ID,{key:0,title:`內文`},{default:P(()=>[W(Cj,{source:i.value.body},null,8,[`source`])]),_:1})):K(``,!0),i.value.artifacts.length?(B(),H(ID,{key:1,title:`產物`,count:i.value.artifacts.length},{default:P(()=>[(B(!0),V(z,null,L(i.value.artifacts,t=>(B(),H(Oj,{key:t,peek:N(EC)(e.m,u(t)),title:d(t)},null,8,[`peek`,`title`]))),128))]),_:1},8,[`count`])):K(``,!0),a.value.length?(B(),H(ID,{key:2,title:`子任務`,count:a.value.length},{default:P(()=>[(B(!0),V(z,null,L(a.value,t=>(B(),H(Oj,{key:t.id,peek:N(CC)(e.m,t.id),id:t.id,title:t.title,status:t.status},null,8,[`peek`,`id`,`title`,`status`]))),128))]),_:1},8,[`count`])):K(``,!0),W(Rj,{self:N(CC)(t.m,t.t),links:i.value.links},null,8,[`self`,`links`]),i.value.refs?.length?(B(),H(ID,{key:3,title:`參考來源`,count:i.value.refs.length},{default:P(()=>[W(Uj,{refs:i.value.refs},null,8,[`refs`])]),_:1},8,[`count`])):K(``,!0),W(ID,{title:`服務它的行動`,count:s.value.reduce((e,t)=>e+t.actions.length,0)},{default:P(()=>[(B(!0),V(z,null,L(s.value,({session:e,actions:t})=>(B(),V(z,{key:e.id},[W(Oj,{peek:N(TC)(e.id),title:N(jw)(e),status:e.status},null,8,[`peek`,`title`,`status`]),(B(!0),V(z,null,L(t,e=>(B(),V(`div`,{key:e.id,class:`flex min-h-7 items-center gap-2 pl-6 text-xs text-muted-foreground`},[W(OE,{status:e.status,class:`shrink-0`},null,8,[`status`]),U(`span`,cF,j(e.id),1),U(`span`,lF,j(e.do),1)]))),128))],64))),128)),s.value.length===0?(B(),V(`p`,uF,`這台電腦上沒有服務這個任務的行動。`)):K(``,!0)]),_:1},8,[`count`])])):(B(),V(`p`,dF,`載入 `+j(e.m)+`/`+j(e.t)+`…`,1))}}),pF={class:`flex h-11 shrink-0 items-center gap-1 px-2`},mF={key:0,class:`truncate text-xs text-muted-foreground`},hF={key:1,class:`ml-2 text-xs text-status-done`,role:`status`},gF={class:`min-h-0 flex-1 overflow-auto`},_F=`mainflow.panelWidth`,vF=360,yF=1200,bF=lT(I({__name:`PeekPanel`,setup(e){let{current:t,trail:n,full:r,back:i,close:a,toggleFull:o}=FC(),s=Number($C(_F,880)),c=M(s>=vF&&s<=yF?s:880);function l(e){let t=e.clientX,n=c.value,r=e=>c.value=Math.min(yF,Math.max(vF,n+t-e.clientX)),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),ew(_F,c.value)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}let u=J(()=>{let e=AC(n.value.at(-1));return e?e.kind===`session`?`會話`:e.kind===`file`?e.path.split(`/`).at(-1):e.kind===`conflict`?`存檔`:e.ref:``});return(e,s)=>N(t)?(B(),V(`aside`,{key:0,class:k([`peek-panel flex min-h-0 flex-col border-l bg-background max-[1100px]:shadow-lg`,N(r)?`flex-1`:`shrink-0`]),style:he({"--panel-width":`${c.value}px`}),"aria-label":`預覽面板`},[N(r)?K(``,!0):(B(),V(`div`,{key:0,class:`absolute inset-y-0 -left-1 w-2 cursor-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`拖曳調整面板寬度`,onPointerdown:au(l,[`prevent`])},null,32)),U(`div`,pF,[W(N(sC),{variant:`ghost`,size:`icon-sm`,disabled:!N(n).length,"aria-label":`上一步`,title:`上一步`,onClick:N(i)},{default:P(()=>[W(N(Yu))]),_:1},8,[`disabled`,`onClick`]),u.value?(B(),V(`span`,mF,`回到 `+j(u.value),1)):K(``,!0),N(jC)?(B(),V(`span`,hF,j(N(jC)),1)):K(``,!0),s[0]||=U(`span`,{class:`ml-auto`},null,-1),W(N(sC),{variant:`ghost`,size:`icon-sm`,"aria-label":N(r)?`回到並排`:`開成整頁`,title:N(r)?`回到並排`:`開成整頁`,onClick:N(o)},{default:P(()=>[N(r)?(B(),H(N(Bd),{key:0})):(B(),H(N(Rd),{key:1}))]),_:1},8,[`aria-label`,`title`,`onClick`]),W(N(sC),{variant:`ghost`,size:`icon-sm`,"aria-label":`關閉(Esc)`,title:`關閉(Esc)`,onClick:N(a)},{default:P(()=>[W(N(uf))]),_:1},8,[`onClick`])]),U(`div`,gF,[N(t).kind===`task`?(B(),H(fF,{key:N(t).ref,m:N(t).m,t:N(t).t},null,8,[`m`,`t`])):N(t).kind===`decision`?(B(),H(uM,{key:N(t).ref,m:N(t).m,d:N(t).d},null,8,[`m`,`d`])):N(t).kind===`file`?(B(),H(LM,{key:N(t).ref,m:N(t).m,path:N(t).path},null,8,[`m`,`path`])):N(t).kind===`session`?(B(),H(QP,{key:N(t).ref,id:N(t).id},null,8,[`id`])):N(t).kind===`mainline`?(B(),H(CP,{key:N(t).ref,m:N(t).m},null,8,[`m`])):N(t).kind===`issue`?(B(),H(QN,{key:N(t).ref,id:N(t).id},null,8,[`id`])):N(t).kind===`conflict`?(B(),H(ZD,{key:N(t).ref,saved:N(t).saved},null,8,[`saved`])):N(t).kind===`group`?(B(),H(GN,{key:N(t).ref,id:N(t).id},null,8,[`id`])):(B(),H(UM,{key:N(t).ref,id:N(t).id},null,8,[`id`]))])],6)):K(``,!0)}}),[[`__scopeId`,`data-v-d9c80ff7`]]),xF={class:`flex h-full min-h-0 flex-col`},SF={class:`relative flex min-h-0 flex-1`},CF={class:`@container min-w-0 flex-1 overflow-auto`,"data-peek-list":``},wF=I({__name:`PageLayout`,setup(e){let{current:t,full:n}=FC();return(e,r)=>(B(),V(`div`,xF,[R(e.$slots,`header`),U(`div`,SF,[yr(U(`div`,CF,[R(e.$slots,`default`)],512),[[Vc,!(N(t)&&N(n))]]),W(bF)])]))}});function TF(e,t){let n=Qt(new Set),r=e.spec.id,i=t=>[...t.leader?[t.leader]:[],...t.items,...t.ended].flatMap(t=>[t,...(e.spec.nested?.(t)??[]).map(e=>e.item)]),a=J(()=>[...new Map(e.groups.value.flatMap(i).map(e=>[r(e),e])).values()]);F(a,e=>{let t=new Set(e.map(r));for(let e of n)t.has(e)||n.delete(e)});let o=J(()=>a.value.filter(e=>n.has(r(e)))),s=e=>{let t=e.filter(e=>n.has(r(e))).length;return t===0?!1:t===e.length||`indeterminate`},c=(e,t)=>e.forEach(e=>t?n.add(r(e)):n.delete(r(e)));async function l(e){let i=o.value.filter(n=>t.archived(n)!==e).map(r);i.length&&await dw(async()=>{let n=await XC.archiveMany(t.kind,i,e);if(n.failed.length)throw Error(`${n.failed.length} 個沒有${e?`封存`:`取消封存`}:${n.failed.map(e=>`${e.id}(${e.error})`).join(`、`)}`)})&&n.clear()}return{selected:o,active:J(()=>o.value.length>0),all:J(()=>s(a.value)),groupChecked:e=>s(i(e)),has:e=>n.has(r(e)),toggle:(e,t)=>c([e],t),setAll:e=>c(a.value,e),setGroup:(e,t)=>c(i(e),t),clear:()=>n.clear(),archivable:J(()=>o.value.filter(e=>!t.archived(e)).length),restorable:J(()=>o.value.filter(e=>t.archived(e)).length),setArchived:l}}var EF={key:0,class:`shrink-0 text-xs text-muted-foreground`},DF=[`title`],OF=I({__name:`FindingList`,setup(e){let t=[`valid`,`obsolete`],n=DN({key:`findings`,id:e=>e.id,text:e=>e.title,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(t)},{key:`category`,label:`分類`,values:e=>e.category?[e.category]:[]},{key:`label`,label:`標籤`,values:e=>e.labels??[]},{key:`applies`,label:`適用範圍`,values:e=>e.appliesTo??[]}],sorts:[{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`applies`,label:`適用範圍`,value:e=>e.appliesTo?.join(`、`),dir:`asc`},{key:`created`,label:`建立`,value:e=>e.created,dir:`desc`},{key:`review`,label:`重新確認日`,value:e=>e.reviewAfter,dir:`asc`}],groups:[yN(t),{key:`category`,label:`分類`,value:e=>e.category??`未分類`}],defaultSort:`created`,defaultGroup:`status`,ended:e=>gN(e.status),archived:e=>!!e.archivedAt},()=>Q.findings),r=TF(n,{kind:`finding`,archived:e=>!!e.archivedAt}),i=[{key:`name`,label:`名稱`,sort:`name`},{key:`applies`,label:`適用範圍`,class:`max-w-72 truncate font-mono text-xs text-muted-foreground`,sort:`applies`,value:e=>e.appliesTo,optional:!0},{key:`review`,label:`重新確認`,sort:`review`,value:e=>e.reviewAfter}],a=e=>dw(()=>XC.archiveFinding(e.id,!e.archivedAt,e.version));return(e,t)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`發現`,description:`踩過的坑與經驗。下一個任務動手前先看這裡。`}),W(uD,{view:N(n)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(n),selection:N(r),columns:i,"item-ref":e=>e.id},{name:P(({item:e})=>[W(yD,{status:e.status,id:e.id,title:e.title,muted:!!e.archivedAt},{default:P(()=>[(B(!0),V(z,null,L(e.labels??[],e=>(B(),H(N(nE),{key:e,variant:`secondary`,class:`shrink-0`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128)),e.archivedAt?(B(),V(`span`,EF,`已封存`)):K(``,!0)]),_:2},1032,[`status`,`id`,`title`,`muted`])]),applies:P(({item:e})=>[U(`span`,{title:e.appliesTo?.join(`
81
81
  `)},j(e.appliesTo?.join(`、`)),9,DF)]),review:P(({item:e})=>[W(_E,{day:e.reviewAfter,ended:e.status===`obsolete`},null,8,[`day`,`ended`])]),actions:P(({item:e})=>[W(iE,{archived:!!e.archivedAt,onToggle:t=>a(e)},null,8,[`archived`,`onToggle`])]),empty:P(()=>[...t[0]||=[G(`還沒有發現。用 `,-1),U(`code`,null,`mainflow new finding <slug> --title <title>`,-1),G(` 記下來。`,-1)]]),_:1},8,[`view`,`selection`,`item-ref`]),W(gD,{selection:N(r)},null,8,[`selection`])]),_:1}))}}),kF=e=>(e.plannedIn??e.origin??``).match(/^m\d{3}/)?.[0]??``,AF=e=>e?`${e} ${Q.summary?.mainlines.find(t=>t.id===e)?.title??``}`.trim():`不屬於主脈絡`,jF=`未分類`,MF=`沒有標籤`,NF=e=>e.labels?.length?e.labels:[MF],PF=e=>[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(e)},{key:`priority`,label:`優先度`,values:e=>[mN(e.priority)],options:pN},{key:`category`,label:`分類`,values:e=>e.category?[e.category]:[]},{key:`label`,label:`標籤`,values:e=>e.labels??[]},{key:`mainline`,label:`來源主脈絡`,values:e=>[kF(e)].filter(Boolean),optionLabel:AF},PN(e=>e.group)],FF=e=>[yN(e),{key:`category`,label:`分類`,value:e=>e.category??jF,trailing:[jF]},{key:`label`,label:`標籤`,value:e=>NF(e)[0],values:NF,trailing:[MF]},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),order:[`P0`,`P1`,`P2`,`P3`]},{key:`mainline`,label:`主脈絡`,value:kF,groupLabel:AF,trailing:[``]},NN(e=>e.group)],IF={key:0,class:`shrink-0 text-xs text-muted-foreground`},LF=I({__name:`IssueList`,setup(e){let t=[`open`,`planned`,`closed`],n=DN({key:`issues`,id:e=>e.id,text:e=>e.title,filters:PF(t),sorts:[{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`planned`,label:`排入`,value:e=>e.plannedIn,dir:`asc`},{key:`origin`,label:`來源`,value:e=>e.origin,dir:`asc`},{key:`order`,label:`手動順序`,value:e=>e.order,dir:`asc`},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),dir:`asc`},{key:`due`,label:`到期`,value:e=>e.due,dir:`asc`},{key:`created`,label:`建立`,value:e=>e.created,dir:`desc`}],groups:FF(t),defaultSort:`order`,defaultGroup:`status`,ended:e=>gN(e.status),archived:e=>!!e.archivedAt},()=>Q.issues),r=TF(n,{kind:`issue`,archived:e=>!!e.archivedAt}),i=[{key:`name`,label:`名稱`,sort:`name`},{key:`priority`,label:`優先度`,sort:`priority`},{key:`due`,label:`到期`,sort:`due`,value:e=>e.due},{key:`planned`,label:`排入`,class:`max-w-56`,sort:`planned`,value:e=>e.plannedIn},{key:`origin`,label:`來源`,class:`max-w-56`,sort:`origin`,value:e=>e.origin,optional:!0}],{open:a}=FC();Er(()=>Rw(Q.issues.flatMap(e=>[e.plannedIn,e.origin])));let o=e=>dw(()=>XC.archiveIssue(e.id,!e.archivedAt,e.version));return(e,t)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`待辦事項`,description:`跨主脈絡的後續事項。主脈絡結束或封存後仍留在這裡。`}),W(uD,{view:N(n)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(n),selection:N(r),columns:i,"item-ref":e=>e.id},{name:P(({item:e})=>[W(yD,{status:e.status,id:e.id,title:e.title,muted:!!e.archivedAt},{default:P(()=>[e.archivedAt?(B(),V(`span`,IF,`已封存`)):K(``,!0)]),_:2},1032,[`status`,`id`,`title`,`muted`])]),priority:P(({item:e})=>[W(TE,{priority:e.priority},null,8,[`priority`])]),due:P(({item:e})=>[W(_E,{day:e.due,ended:e.status===`closed`},null,8,[`day`,`ended`])]),planned:P(({item:e})=>[e.plannedIn?(B(),H($j,q({key:0},N(Iw)(e.plannedIn),{onOpen:N(a)}),null,16,[`onOpen`])):K(``,!0)]),origin:P(({item:e})=>[e.origin?(B(),H($j,q({key:0},N(Iw)(e.origin),{onOpen:N(a)}),null,16,[`onOpen`])):K(``,!0)]),actions:P(({item:e})=>[W(iE,{archived:!!e.archivedAt,onToggle:t=>o(e)},null,8,[`archived`,`onToggle`])]),empty:P(()=>[...t[0]||=[G(`沒有待辦事項。用 `,-1),U(`code`,null,`mainflow new issue <slug> --title <title>`,-1),G(` 記下主脈絡結束後還要處理的事。`,-1)]]),_:1},8,[`view`,`selection`,`item-ref`]),W(gD,{selection:N(r)},null,8,[`selection`])]),_:1}))}}),RF=I({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=F_(Sf(n,`class`),r);return(e,t)=>(B(),H(N(nC),q({"data-slot":`tabs`},N(i),{class:N(gg)(`flex flex-col gap-2`,n.class)}),{default:P(t=>[R(e.$slots,`default`,A(Cs(t)))]),_:3},16,[`class`]))}}),zF=I({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=Sf(t,`class`,`variant`);return(r,i)=>(B(),H(N(aC),q({"data-slot":`tabs-list`,"data-variant":e.variant},N(n),{class:N(gg)(`group/tabs-list text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-0.75`,e.variant===`line`?`gap-1 rounded-none bg-transparent p-0`:`bg-muted`,t.class)}),{default:P(()=>[R(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),BF=I({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=P_(Sf(t,`class`));return(e,r)=>(B(),H(N(oC),q({"data-slot":`tabs-trigger`,class:N(gg)(`data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-3 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:text-foreground/60 group-data-[variant=line]/tabs-list:hover:text-foreground group-data-[variant=line]/tabs-list:data-[state=active]:text-foreground group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent after:absolute after:inset-x-0 after:-bottom-px after:h-0.5 after:bg-foreground after:opacity-0 after:transition-opacity group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,t.class)},N(n)),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`class`]))}}),VF={class:`w-full text-body`},HF={colspan:`3`,class:`sticky top-9 z-[5] bg-background px-6 pt-4 pb-1`},UF={class:`flex items-center gap-2 text-sm`},WF={key:0,class:`grid size-4 shrink-0 place-items-center rounded-[4px] border border-dashed text-[10px] text-muted-foreground`,"aria-label":`已不需要`},GF={class:`font-mono text-xs text-muted-foreground`},KF=[`title`],qF={key:1,class:`font-medium text-muted-foreground`},JF={class:`flex min-w-0 items-center gap-2`},YF={class:`shrink-0 font-mono text-xs text-muted-foreground`},XF=[`title`],ZF={class:`flex min-w-0 items-center gap-2 text-xs`},QF={class:`truncate`},$F={key:0},eI={colspan:`3`,class:`px-6 pb-2 text-xs text-muted-foreground`},tI={key:1},nI={key:0,class:`px-6 py-16 text-center text-sm text-muted-foreground`},rI=I({__name:`CriteriaView`,props:{mainline:{}},setup(e){let t=e,{open:n,current:r}=FC(),i=J(()=>t.mainline.tasks.flatMap(e=>e.checklist.filter(e=>!e.dropped).map(t=>({task:e,item:t})))),a=J(()=>[...t.mainline.criteria.map(e=>({key:e.id,criterion:e,rows:i.value.filter(t=>t.item.serves?.includes(e.id))})),{key:``,criterion:void 0,rows:i.value.filter(e=>!e.item.serves?.length)}].filter(e=>e.criterion||e.rows.length)),o=e=>r.value?.ref===e||void 0;return(t,r)=>(B(),V(z,null,[U(`table`,VF,[W(N(CE),{class:`sticky top-0 z-10 bg-background [&_tr]:border-b`},{default:P(()=>[W(N(xE),{class:`hover:bg-transparent`},{default:P(()=>[W(N(SE),{class:`pl-6`},{default:P(()=>[...r[0]||=[G(`checklist 項目`,-1)]]),_:1}),W(N(SE),{class:`w-72`},{default:P(()=>[...r[1]||=[G(`任務`,-1)]]),_:1}),W(N(SE),{class:`w-28 pr-6`},{default:P(()=>[...r[2]||=[G(`完成`,-1)]]),_:1})]),_:1})]),_:1}),(B(!0),V(z,null,L(a.value,t=>(B(),H(N(yE),{key:t.key,class:`[&_tr:last-child]:border-b`},{default:P(()=>[U(`tr`,null,[U(`td`,HF,[U(`div`,UF,[t.criterion?(B(),V(z,{key:0},[t.criterion.dropped?(B(),V(`span`,WF,`–`)):(B(),H(N(vE),{key:1,"model-value":t.criterion.done,disabled:``,class:`pointer-events-none`,"aria-label":t.criterion.done?`已達成`:`未達成`},null,8,[`model-value`,`aria-label`])),U(`span`,GF,j(t.criterion.id),1),U(`span`,{class:k([`min-w-0 truncate font-medium`,{"text-muted-foreground line-through":t.criterion.dropped}]),title:t.criterion.text},j(t.criterion.text),11,KF),t.criterion.dropped?K(``,!0):(B(),H(nP,{key:2,class:`ml-auto shrink-0`,done:t.rows.filter(e=>e.item.done).length,total:t.rows.length},null,8,[`done`,`total`]))],64)):(B(),V(`span`,qF,`沒有推進任何解決條件`))])])]),(B(!0),V(z,null,L(t.rows,t=>(B(),H(N(xE),{key:`${t.task.id}#${t.item.id}`,class:`h-9 transition-colors duration-[120ms]`,"data-peek":N(CC)(e.mainline.id,t.task.id),"aria-current":o(N(CC)(e.mainline.id,t.task.id)),onClick:r=>N(n)(N(CC)(e.mainline.id,t.task.id))},{default:P(()=>[W(N(bE),{class:`max-w-0 pl-6`},{default:P(()=>[U(`span`,JF,[U(`span`,YF,j(t.task.id)+`#`+j(t.item.id),1),U(`span`,{class:k([`truncate`,{"text-muted-foreground":t.item.done}]),title:t.item.text},j(t.item.text),11,XF)])]),_:2},1024),W(N(bE),{class:`max-w-72`},{default:P(()=>[U(`span`,ZF,[W(nT,{type:N(Bw)(t.task),status:t.task.status},null,8,[`type`,`status`]),U(`span`,QF,j(t.task.title),1)])]),_:2},1024),W(N(bE),{class:`pr-6 text-xs text-muted-foreground`},{default:P(()=>[G(j(t.item.done?t.item.doneAt??`已完成`:``),1)]),_:2},1024)]),_:2},1032,[`data-peek`,`aria-current`,`onClick`]))),128)),t.criterion?.dropped?(B(),V(`tr`,$F,[U(`td`,eI,[r[3]||=G(`不再需要`,-1),t.criterion.note?(B(),V(z,{key:0},[G(`:`+j(t.criterion.note),1)],64)):K(``,!0)])])):t.criterion&&t.rows.length===0?(B(),V(`tr`,tI,[...r[4]||=[U(`td`,{colspan:`3`,class:`px-6 pb-2 text-xs text-muted-foreground`},`還沒有 checklist 項目推進這條條件。`,-1)]])):K(``,!0)]),_:2},1024))),128))]),a.value.length===0?(B(),V(`p`,nI,`這條主脈絡還沒有解決條件。`)):K(``,!0)],64))}}),iI={key:0,class:`shrink-0 text-xs text-muted-foreground`},aI=[`title`],oI=I({__name:`DecisionTable`,props:{mainline:{}},setup(e){let t=e,n=[`proposed`,`accepted`,`superseded`],r=DN({key:`decisions`,id:e=>e.id,text:e=>e.title,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(n)},{key:`by`,label:`決策者`,values:e=>e.by?[e.by]:[],optionLabel:e=>Zw[e]??e},{key:`basis`,label:`裁決方式`,values:e=>e.basis?[e.basis]:[],optionLabel:e=>Qw[e]??e}],sorts:[{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`by`,label:`決策者`,value:e=>e.by,dir:`asc`},{key:`reversible`,label:`能否改回`,value:e=>e.reversible===void 0?null:+!!e.reversible,dir:`desc`},{key:`created`,label:`建立`,value:e=>cE(e.created),dir:`desc`},{key:`decided`,label:`裁決時間`,value:e=>e.decidedAt?cE(e.decidedAt):void 0,dir:`desc`}],groups:[yN(n)],defaultSort:`created`,defaultGroup:`status`,ended:e=>gN(e.status)},()=>t.mainline.decisions),i=[{key:`name`,label:`名稱`,sort:`name`},{key:`by`,label:`決策者`,class:`text-xs text-muted-foreground`,sort:`by`,value:e=>e.by},{key:`basis`,label:`裁決方式`,class:`text-xs text-muted-foreground`,value:e=>e.basis},{key:`decided`,label:`裁決`,class:`font-mono text-xs text-muted-foreground tabular-nums`,sort:`decided`,value:e=>e.decidedAt},{key:`affects`,label:`影響`,class:`max-w-56 truncate font-mono text-xs text-muted-foreground`,value:e=>e.affects,optional:!0},{key:`reversible`,label:`能否改回`,class:`text-xs text-muted-foreground`,sort:`reversible`,value:e=>e.reversible,optional:!0}];return(t,n)=>(B(),V(z,null,[W(uD,{view:N(r)},null,8,[`view`]),W(eD,{view:N(r),columns:i,"item-ref":t=>N(wC)(e.mainline.id,t.id)},{name:P(({item:e})=>[W(yD,{status:e.status,id:e.id,title:e.title,muted:e.status===`superseded`},{default:P(()=>[e.supersededBy?(B(),V(`span`,iI,`由 `+j(e.supersededBy)+` 取代`,1)):K(``,!0)]),_:2},1032,[`status`,`id`,`title`,`muted`])]),by:P(({item:e})=>[G(j(e.by?N(Zw)[e.by]:``),1)]),basis:P(({item:e})=>[G(j(e.basis?N(Qw)[e.basis]:``),1)]),decided:P(({item:e})=>[G(j(e.decidedAt?N(fE)(e.decidedAt):``),1)]),affects:P(({item:e})=>[U(`span`,{title:e.affects?.join(`
82
- `)},j(e.affects?.join(`、`)),9,aI)]),reversible:P(({item:e})=>[G(j(e.reversible===void 0?``:e.reversible?`可以`:`不易改回`),1)]),empty:P(()=>[n[0]||=G(`還沒有決策。用 `,-1),U(`code`,null,`mainflow new decision `+j(e.mainline.id)+` <slug> --title <title>`,1),n[1]||=G(` 記下選擇與理由。`,-1)]),_:1},8,[`view`,`item-ref`])],64))}}),sI={class:`flex min-w-0 items-center gap-2`},cI=[`href`,`title`],lI=[`title`],uI={key:0,class:`whitespace-nowrap`},dI=[`title`],fI=`-`,pI=I({__name:`FilesView`,props:{mainline:{}},setup(e){let t=e,n=J(()=>DM(t.mainline)),r=e=>{let n=t.mainline.tasks.find(t=>t.id===e)??t.mainline.decisions.find(t=>t.id===e);return n?`${e} ${n.title}`:e===fI||!e?`主脈絡本身`:e},i=DN({key:`files`,id:e=>e.key,text:e=>`${e.name} ${e.path??``}`,filters:[{key:`kind`,label:`類型`,values:e=>[e.kind],options:wM.map(e=>({value:e,label:e}))},{key:`source`,label:`來源`,values:e=>[e.source??fI],optionLabel:r},{key:`ext`,label:`副檔名`,values:e=>e.ext?[e.ext]:[],optionLabel:e=>`.${e}`}],sorts:[{key:`kind`,label:`類型`,value:e=>wM.indexOf(e.kind),dir:`asc`},{key:`name`,label:`檔名`,value:e=>e.name,dir:`asc`},{key:`updated`,label:`更新`,value:e=>e.updated,dir:`desc`},{key:`source`,label:`來源`,value:e=>e.source,dir:`asc`}],groups:[{key:`kind`,label:`類型`,value:e=>e.kind,order:wM},{key:`source`,label:`來源`,value:e=>e.source??fI,groupLabel:r}],defaultSort:`kind`,defaultGroup:`kind`},()=>n.value),a=[{key:`name`,label:`檔名`,sort:`name`},{key:`kind`,label:`類型`,class:`text-xs text-muted-foreground`,sort:`kind`},{key:`source`,label:`來源`,class:`max-w-64 truncate text-xs text-muted-foreground`,sort:`source`,value:e=>e.source,optional:!0},{key:`updated`,label:`更新`,class:`text-xs text-muted-foreground`,sort:`updated`,value:e=>e.updated}],o=e=>e.inMainline?EC(t.mainline.id,e.inMainline):void 0;return(e,t)=>(B(),V(z,null,[W(uD,{view:N(i)},null,8,[`view`]),W(eD,{view:N(i),columns:a,"item-ref":o},{name:P(({item:e})=>[U(`span`,sI,[W(nT,{type:N(Uw)(e.url??e.key,e.kind)},null,8,[`type`]),e.url?(B(),V(`a`,{key:0,href:e.url,target:`_blank`,rel:`noreferrer`,class:`truncate underline decoration-border underline-offset-4 hover:decoration-foreground`,title:e.url,onClick:t[0]||=au(()=>{},[`stop`])},j(e.name),9,cI)):(B(),V(`span`,{key:1,class:k([`truncate`,{"font-mono text-xs":e.inMainline}]),title:e.inMainline??e.path},j(e.name),11,lI)),e.remoteOnly?(B(),H(N(ad),{key:2,class:`size-3.5 shrink-0 text-muted-foreground`,"aria-label":`只在伺服器上`,title:`只在同步伺服器上,點開時下載`})):K(``,!0),e.path?(B(),H(DD,{key:3,text:e.path,class:`min-w-0`},null,8,[`text`])):K(``,!0)])]),kind:P(({item:e})=>[G(j(e.kind),1),e.remoteOnly?(B(),V(`span`,uI,`・只在伺服器上`)):K(``,!0)]),source:P(({item:e})=>[U(`span`,{title:r(e.source??``)},j(e.source?r(e.source):``),9,dI)]),updated:P(({item:e})=>[e.updated?(B(),H(TP,{key:0,at:e.updated},null,8,[`at`])):K(``,!0)]),empty:P(()=>[...t[1]||=[G(`這條主脈絡還沒有檔案。`,-1)]]),_:1},8,[`view`])],64))}}),mI=I({__name:`Card`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),V(`div`,{"data-slot":`card`,class:k(N(gg)(`bg-card text-card-foreground flex flex-col gap-4 rounded-xl border py-4 shadow-sm`,t.class))},[R(e.$slots,`default`)],2))}}),hI={class:`inline-flex gap-1.5 font-mono text-xs`},gI=[`title`],_I=I({__name:`DepList`,props:{deps:{},within:{}},setup(e){let t=e,n=e=>t.within&&e.startsWith(`${t.within}/`)?e.slice(t.within.length+1):e;return(t,r)=>(B(),V(`span`,hI,[(B(!0),V(z,null,L(e.deps,e=>(B(),V(`span`,{key:e.to,class:k(N(eT)[e.state].tone),title:`${e.to} ${N(eT)[e.state].label}`},j(n(e.to)),11,gI))),128))]))}}),vI={class:`flex items-center rounded-md border p-0.5`,role:`group`,"aria-label":`任務排列`},yI={key:0,class:`flex min-h-0 gap-3 overflow-x-auto px-6 pt-2 pb-6`},bI=[`aria-label`],xI={class:`flex items-center gap-2 py-1`},SI={class:`text-xs text-muted-foreground tabular-nums`},CI={class:`flex items-center gap-2 text-xs`},wI={class:`font-mono text-muted-foreground`},TI={class:`line-clamp-2 [overflow-wrap:anywhere]`},EI={class:`flex items-center justify-between gap-2`},DI={key:0,class:`min-w-0 truncate text-xs text-muted-foreground`},OI={key:0,class:`py-2 text-xs text-muted-foreground`},kI=[`title`],AI=`mainflow.list.tasks.mode`,jI=I({__name:`TaskViews`,props:{mainline:{}},setup(e){let t=e,n=[{key:`table`,label:`表格`,icon:Jd},{key:`board`,label:`看板`,icon:od},{key:`tree`,label:`樹狀`,icon:Ld}],r=$C(AI,`table`),i=M(n.some(e=>e.key===r)?r:`table`);function a(e){i.value=e,ew(AI,e)}let o=()=>t.mainline.tasks,s=J(()=>new Map(t.mainline.tasks.map(e=>[e.id,e])));function c(e){let t=e;for(;t?.kind===`branch`&&t.parent;)t=s.value.get(t.parent);return t?.id??e.id}let l=e=>e.checklist.filter(e=>e.done).length,u={id:e=>e.id,text:e=>`${e.title} ${e.branch??``}`,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(Gw)},{key:`priority`,label:`優先度`,values:e=>[mN(e.priority)],options:pN},{key:`repo`,label:`倉庫`,values:e=>e.repo?[e.repo]:[]},{key:`kind`,label:`種類`,values:e=>[e.kind],options:[{value:`phase`,label:`階段`},{value:`branch`,label:`分支`}]},{key:`label`,label:`標籤`,values:e=>e.labels??[]}]},d=DN({...u,key:`tasks`,sorts:[{key:`order`,label:`手動順序`,value:e=>e.order??Number(e.id.slice(1)),dir:`asc`},{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`repo`,label:`倉庫`,value:e=>e.repo,dir:`asc`},{key:`depends`,label:`依賴`,value:e=>b(e)[0]?.to,dir:`asc`},{key:`branch`,label:`分支`,value:e=>e.branch,dir:`asc`},{key:`status`,label:`狀態`,value:e=>Gw.indexOf(e.status),dir:`asc`},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),dir:`asc`},{key:`progress`,label:`checklist 進度`,value:e=>e.checklist.length?l(e)/e.checklist.length:null,dir:`desc`}],groups:[{key:`phase`,label:`階段`,value:c,groupLabel:e=>s.value.get(e)?.title??e,status:e=>s.value.get(e)?.status,leader:e=>s.value.get(e)},yN(Gw),{key:`repo`,label:`倉庫`,value:e=>e.repo??`沒有指定倉庫`}],defaultSort:`order`,defaultGroup:`status`,ended:e=>gN(e.status)},o),f=e=>t.mainline.tasks.filter(t=>t.parent===e).sort((e,t)=>(e.order??1/0)-(t.order??1/0)||e.id.localeCompare(t.id)),p=(e,t=1)=>f(e.id).flatMap(e=>[{item:e,depth:t},...p(e,t+1)]),m=DN({...u,key:`tasks`,sorts:[{key:`order`,label:`手動順序`,value:e=>e.order??Number(e.id.slice(1)),dir:`asc`}],groups:[],defaultSort:`order`,defaultGroup:``,nested:e=>p(e)},()=>t.mainline.tasks.filter(e=>!e.parent||!s.value.has(e.parent))),h=J(()=>Gw.map(e=>({status:e,tasks:d.sorted.value.filter(t=>t.status===e)}))),g=[{key:`name`,label:`名稱`,sort:`name`},{key:`priority`,label:`優先度`,sort:`priority`},{key:`progress`,label:`checklist`,sort:`progress`,value:e=>e.checklist.length},{key:`repo`,label:`倉庫`,class:`text-xs text-muted-foreground`,sort:`repo`,value:e=>e.repo},{key:`depends`,label:`依賴`,sort:`depends`,value:e=>b(e),optional:!0},{key:`branch`,label:`分支`,class:`max-w-56 truncate font-mono text-xs text-muted-foreground`,sort:`branch`,value:e=>e.branch,optional:!0}],{open:_,current:v}=FC(),y=e=>CC(t.mainline.id,e.id);function b(e){return Q.relations.deps.filter(t=>t.from===y(e))}return(t,r)=>(B(),V(z,null,[W(uD,{view:i.value===`tree`?N(m):N(d),grouping:i.value===`table`},{views:P(()=>[U(`div`,vI,[(B(),V(z,null,L(n,e=>W(N(sC),{key:e.key,variant:i.value===e.key?`secondary`:`ghost`,size:`xs`,"aria-pressed":i.value===e.key,onClick:t=>a(e.key)},{default:P(()=>[(B(),H(fa(e.icon))),G(j(e.label),1)]),_:2},1032,[`variant`,`aria-pressed`,`onClick`])),64))])]),_:1},8,[`view`,`grouping`]),i.value===`board`?(B(),V(`div`,yI,[(B(!0),V(z,null,L(h.value,e=>(B(),V(`section`,{key:e.status,class:`flex w-64 shrink-0 flex-col gap-2`,"aria-label":N(Yw)[e.status]},[U(`div`,xI,[W(kE,{status:e.status},null,8,[`status`]),U(`span`,SI,j(e.tasks.length),1)]),(B(!0),V(z,null,L(e.tasks,e=>(B(),H(N(mI),{key:e.id,class:k([`min-w-0 cursor-pointer gap-2 p-3 shadow-xs transition-colors duration-[120ms] hover:bg-accent/50`,{"bg-muted":N(v)?.ref===y(e)}]),"data-peek":y(e),"aria-current":N(v)?.ref===y(e)||void 0,onClick:t=>N(_)(y(e))},{default:P(()=>[U(`div`,CI,[W(nT,{type:N(Bw)(e),status:e.status},null,8,[`type`,`status`]),U(`span`,wI,j(e.id),1),W(TE,{priority:e.priority},null,8,[`priority`])]),U(`p`,TI,j(e.title),1),U(`div`,EI,[W(nP,{done:l(e),total:e.checklist.length},null,8,[`done`,`total`]),e.repo?(B(),V(`span`,DI,j(e.repo),1)):K(``,!0)])]),_:2},1032,[`class`,`data-peek`,`aria-current`,`onClick`]))),128)),e.tasks.length===0?(B(),V(`p`,OI,`沒有任務`)):K(``,!0)],8,bI))),128))])):(B(),H(eD,{key:1,view:i.value===`tree`?N(m):N(d),columns:g,"item-ref":y,"item-type":N(Bw)},{name:P(({item:e,depth:t})=>[W(yD,{status:e.status,id:e.id,title:e.title,depth:t,type:N(Bw)(e)},null,8,[`status`,`id`,`title`,`depth`,`type`])]),priority:P(({item:e})=>[W(TE,{priority:e.priority},null,8,[`priority`])]),progress:P(({item:e})=>[W(nP,{done:l(e),total:e.checklist.length},null,8,[`done`,`total`])]),repo:P(({item:e})=>[G(j(e.repo),1)]),depends:P(({item:t})=>[W(_I,{deps:b(t),within:e.mainline.id},null,8,[`deps`,`within`])]),branch:P(({item:e})=>[U(`span`,{title:e.branch},j(e.branch),9,kI)]),empty:P(()=>[r[0]||=G(`還沒有任務。執行 `,-1),U(`code`,null,`mainflow new task `+j(e.mainline.id)+` <slug> --title <title>`,1),r[1]||=G(` 建立。`,-1)]),_:1},8,[`view`,`item-type`]))],64))}}),MI={class:`px-6 pt-6 pb-3`},NI={class:`mt-1 text-title font-semibold`},PI={class:`mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground`},FI={key:0},II={key:0,class:`text-xs text-muted-foreground tabular-nums`},LI={key:0,class:`max-w-5xl px-1 pt-2 pb-10`},RI={key:1,class:`px-6 py-16 text-center text-muted-foreground`},zI=`mainflow.mainlineView`,BI=I({__name:`MainlineDetail`,setup(e){let t=tp(),n=ep(),{id:r,mainline:i}=eM(),a=[{key:`overview`,label:`概覽`},{key:`tasks`,label:`任務`},{key:`criteria`,label:`條件`},{key:`decisions`,label:`決策`},{key:`files`,label:`資料`}],o=J(()=>a.find(e=>e.key===t.query.view)?.key??`overview`),s=e=>{let t=i.value;if(t)return{overview:void 0,tasks:t.tasks.length,criteria:t.criteria.length,decisions:t.decisions.length,files:DM(t).length}[e]},c=e=>n.replace({query:{view:String(e)}});F(()=>[r.value,t.query.view,t.query.tab],([e,r,i])=>{if(!e||typeof i==`string`)return;let a=$C(zI,{});typeof r==`string`?ew(zI,{...a,[e]:r}):a[e]&&a[e]!==`overview`&&n.replace({query:{...t.query,view:a[e]}})},{immediate:!0}),Er(()=>{let e=t.query.tab;if(typeof e!=`string`)return;let{tab:r,...i}=t.query,a={...i,view:e===`views`?`files`:e};n.replace({query:a})});let l=e=>i.value&&dw(()=>XC.mainlineStatus(r.value,e,i.value.version)),u=e=>i.value&&dw(()=>XC.mainlineTitle(r.value,e,i.value.version)),d=()=>i.value&&dw(()=>XC.archive(r.value,!i.value.archivedAt,i.value.version));return(e,t)=>N(i)?(B(),H(wF,{key:0},{header:P(()=>[U(`header`,MI,[W(DD,{text:N(i).id},null,8,[`text`]),U(`h1`,NI,[W(OD,{value:N(i).title,onSave:u},null,8,[`value`])]),U(`div`,PI,[W(bP,{status:N(i).status,options:N(Ww),onChange:l},null,8,[`status`,`options`]),W(TE,{priority:N(i).priority},null,8,[`priority`]),N(i).archivedAt?(B(),V(`span`,FI,`已封存 `+j(N(i).archivedAt),1)):K(``,!0),W(iE,{class:`ml-auto`,archived:!!N(i).archivedAt,onToggle:d},null,8,[`archived`])])]),W(N(RF),{"model-value":o.value,"onUpdate:modelValue":c},{default:P(()=>[W(N(zF),{variant:`line`,class:`h-9 w-full justify-start border-b px-6`},{default:P(()=>[(B(),V(z,null,L(a,e=>W(N(BF),{key:e.key,value:e.key,class:`flex-none px-2`},{default:P(()=>[G(j(e.label),1),s(e.key)===void 0?K(``,!0):(B(),V(`span`,II,j(s(e.key)),1))]),_:2},1032,[`value`])),64))]),_:1})]),_:1},8,[`model-value`])]),default:P(()=>[o.value===`overview`?(B(),V(`div`,LI,[W(gP,{mainline:N(i),columns:2},null,8,[`mainline`])])):o.value===`tasks`?(B(),H(jI,{key:1,mainline:N(i)},null,8,[`mainline`])):o.value===`criteria`?(B(),H(rI,{key:2,mainline:N(i)},null,8,[`mainline`])):o.value===`decisions`?(B(),H(oI,{key:3,mainline:N(i)},null,8,[`mainline`])):(B(),H(pI,{key:4,mainline:N(i)},null,8,[`mainline`]))]),_:1})):(B(),V(`p`,RI,`載入 `+j(N(r))+`…`,1))}}),VI={key:0,class:`shrink-0 text-xs text-muted-foreground`},HI=I({__name:`MainlineList`,setup(e){let t={key:`mainlines`,id:e=>e.id,text:e=>e.title,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(Ww)},{key:`priority`,label:`優先度`,values:e=>[mN(e.priority)],options:pN},{key:`category`,label:`分類`,values:e=>e.category?[e.category]:[]},{key:`label`,label:`標籤`,values:e=>e.labels},PN(e=>e.group)],sorts:[{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`criteria`,label:`解決條件`,value:e=>e.criteria.total?e.criteria.done/e.criteria.total:null,dir:`desc`},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),dir:`asc`},{key:`updated`,label:`更新`,value:e=>e.updated,dir:`desc`},{key:`created`,label:`建立`,value:e=>e.created,dir:`desc`},{key:`due`,label:`到期`,value:e=>e.due,dir:`asc`}],groups:[yN(Ww),{key:`priority`,label:`優先度`,value:e=>mN(e.priority),order:[`P0`,`P1`,`P2`,`P3`]},{key:`category`,label:`分類`,value:e=>e.category??`未分類`},NN(e=>e.group)],defaultSort:`updated`,defaultGroup:`status`,ended:e=>gN(e.status),archived:e=>!!e.archivedAt},n=e=>Q.relations.mainlineDeps.filter(t=>t.from===e.id),r=DN(t,()=>Q.summary?.mainlines??[]),i=TF(r,{kind:`mainline`,archived:e=>!!e.archivedAt}),a=[{key:`name`,label:`名稱`,sort:`name`},{key:`priority`,label:`優先度`,sort:`priority`},{key:`criteria`,label:`解決條件`,sort:`criteria`,value:e=>e.criteria.total},{key:`deps`,label:`依賴`,value:n,optional:!0},{key:`due`,label:`到期`,sort:`due`,value:e=>e.due},{key:`updated`,label:`更新`,class:`text-xs text-muted-foreground`,sort:`updated`,optional:!0}],o=e=>dw(()=>XC.archive(e.id,!e.archivedAt));return(e,t)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`主脈絡`,description:`一條主脈絡是一件要做完的事:意圖、解決條件,以及推進它的任務與決策。`}),W(uD,{view:N(r)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(r),selection:N(i),columns:a,"item-ref":e=>e.id},{name:P(({item:e})=>[W(yD,{status:e.status,id:e.id,title:e.title,muted:!!e.archivedAt},{default:P(()=>[(B(!0),V(z,null,L(e.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`,class:`shrink-0`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128)),e.archivedAt?(B(),V(`span`,VI,`已封存`)):K(``,!0)]),_:2},1032,[`status`,`id`,`title`,`muted`])]),priority:P(({item:e})=>[W(TE,{priority:e.priority},null,8,[`priority`])]),criteria:P(({item:e})=>[W(nP,{done:e.criteria.done,total:e.criteria.total},null,8,[`done`,`total`])]),deps:P(({item:e})=>[W(_I,{deps:n(e)},null,8,[`deps`])]),due:P(({item:e})=>[W(_E,{day:e.due,ended:N(gN)(e.status)},null,8,[`day`,`ended`])]),updated:P(({item:e})=>[W(TP,{at:e.updated},null,8,[`at`])]),actions:P(({item:e})=>[W(N(sC),{variant:`ghost`,size:`xs`,class:`text-muted-foreground`,"as-child":``},{default:P(()=>[W(N(Am),{to:`/mainlines/${e.id}`,onClick:t[0]||=au(()=>{},[`stop`])},{default:P(()=>[W(N(ef)),t[1]||=G(`開啟`,-1)]),_:1},8,[`to`])]),_:2},1024),W(iE,{archived:!!e.archivedAt,onToggle:t=>o(e)},null,8,[`archived`,`onToggle`])]),empty:P(()=>[...t[2]||=[G(`沒有主脈絡。在 hub 內執行 `,-1),U(`code`,null,`mainflow new mainline <slug> --title <title>`,-1),G(` 建立第一個。`,-1)]]),_:1},8,[`view`,`selection`,`item-ref`]),W(gD,{selection:N(i)},null,8,[`selection`])]),_:1}))}}),UI=[`title`],WI=[`title`],GI=[`title`],KI=I({__name:`OpsLog`,setup(e){let t=e=>!/fail|error|denied|reject|abort|失敗|錯誤|拒絕|中止/i.test(e.result),n=e=>e.ref?.match(/^m\d{3}/)?.[0]??``,r=DN({key:`ops`,id:e=>`${e.at}|${e.target}|${e.operation}`,text:e=>`${e.operation} ${e.target} ${e.ref??``}`,filters:[{key:`result`,label:`結果`,values:e=>[t(e)?`success`:`failed`],options:[{value:`success`,label:`成功`},{value:`failed`,label:`沒有成功`}]},{key:`target`,label:`目標系統`,values:e=>[e.target]},{key:`mainline`,label:`主脈絡`,values:e=>[n(e)].filter(Boolean),optionLabel:e=>`${e} ${Q.summary?.mainlines.find(t=>t.id===e)?.title??``}`.trim()}],sorts:[{key:`at`,label:`時間`,value:e=>cE(e.at),dir:`desc`},{key:`operation`,label:`操作`,value:e=>e.operation,dir:`asc`},{key:`target`,label:`目標系統`,value:e=>e.target,dir:`asc`},{key:`result`,label:`結果`,value:e=>+!!t(e),dir:`asc`},{key:`ref`,label:`關聯`,value:e=>e.ref,dir:`asc`}],groups:[{key:`month`,label:`月份`,value:e=>uE(e.at).slice(0,7),latestFirst:!0},{key:`day`,label:`日期`,value:e=>uE(e.at),latestFirst:!0}],defaultSort:`at`,defaultGroup:`month`},()=>Q.ops),i=[{key:`operation`,label:`操作`,sort:`operation`},{key:`target`,label:`目標系統`,class:`max-w-64 truncate font-mono text-xs text-muted-foreground`,sort:`target`,optional:!0},{key:`result`,label:`結果`,class:`max-w-40 truncate text-xs`,sort:`result`},{key:`ref`,label:`關聯`,class:`max-w-56`,sort:`ref`,value:e=>e.ref,optional:!0},{key:`at`,label:`時間`,class:`font-mono text-xs text-muted-foreground tabular-nums`,sort:`at`}],{open:a}=FC();return Er(()=>Rw(Q.ops.map(e=>e.ref))),(e,n)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`操作紀錄`,description:`對外部系統執行過的操作,只追加不改寫。`}),W(uD,{view:N(r)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(r),columns:i},{operation:P(({item:e})=>[U(`span`,{class:`block truncate`,title:e.operation},j(e.operation),9,UI)]),target:P(({item:e})=>[U(`span`,{title:e.target},j(e.target),9,WI)]),result:P(({item:e})=>[U(`span`,{class:k(t(e)?`text-muted-foreground`:`text-foreground`),title:e.result},[t(e)?K(``,!0):(B(),H(N(Qu),{key:0,class:`mr-1 inline size-3.5 align-[-2px] text-destructive`})),G(j(e.result),1)],10,GI)]),ref:P(({item:e})=>[e.ref?(B(),H($j,q({key:0},N(Iw)(e.ref),{onOpen:N(a)}),null,16,[`onOpen`])):K(``,!0)]),at:P(({item:e})=>[G(j(N(fE)(e.at).slice(5)),1)]),empty:P(()=>[...n[0]||=[G(`還沒有紀錄。用 `,-1),U(`code`,null,`mainflow ops add --target <系統> --op <操作> --result <結果>`,-1),G(` 記錄 push、發布、合併這類對外操作。`,-1)]]),_:1},8,[`view`])]),_:1}))}}),qI={key:0,class:`overflow-x-auto px-6 pb-2`},JI=[`aria-colcount`],YI=[`title`],XI={class:`text-xs text-muted-foreground tabular-nums`},ZI={key:0,class:`col-span-full flex min-w-0 items-center gap-2 pt-4 pb-2 text-sm`,role:`rowheader`},QI=[`aria-label`,`aria-expanded`,`onClick`],$I={key:1,class:`truncate font-medium`},eL={class:`text-xs text-muted-foreground tabular-nums`},tL={key:1,class:`px-6 py-16 text-center text-sm text-muted-foreground`},nL=I({__name:`BoardView`,props:{view:{},axis:{}},setup(e){let t=e,n=J(()=>t.view.spec.groups.find(e=>e.key===t.axis)??t.view.spec.groups[0]),r=J(()=>xN(n.value,t.view.sorted.value)),i=J(()=>t.view.group.value!==``),a=(e,t)=>e.filter(e=>bN(n.value,e).includes(t)),o=e=>[...e.items,...e.ended];return(t,n)=>e.view.groups.value.length?(B(),V(`div`,qI,[U(`div`,{class:`grid gap-x-3`,style:he({gridTemplateColumns:`repeat(${r.value.length}, minmax(20rem, 1fr))`}),role:`table`,"aria-colcount":r.value.length},[(B(!0),V(z,null,L(r.value,e=>(B(),V(`div`,{key:e.key,class:`flex min-w-0 items-center gap-2 border-b py-2`,role:`columnheader`},[e.status?(B(),H(kE,{key:0,status:e.status},null,8,[`status`])):(B(),V(`span`,{key:1,class:`truncate text-sm font-medium`,title:e.label},j(e.label),9,YI)),U(`span`,XI,j(e.items.length),1)]))),128)),(B(!0),V(z,null,L(e.view.groups.value,n=>(B(),V(z,{key:n.key},[i.value?(B(),V(`div`,ZI,[U(`button`,{type:`button`,class:`-ml-1 grid size-5 shrink-0 place-items-center rounded-sm hover:bg-accent`,"aria-label":e.view.collapsed.has(n.key)?`展開分組`:`收合分組`,"aria-expanded":!e.view.collapsed.has(n.key),onClick:t=>e.view.toggleCollapsed(n.key)},[e.view.collapsed.has(n.key)?(B(),H(N(Xu),{key:1,class:`size-4 text-muted-foreground`})):(B(),H(N(Ju),{key:0,class:`size-4 text-muted-foreground`}))],8,QI),n.status?(B(),H(kE,{key:0,status:n.status},null,8,[`status`])):(B(),V(`span`,$I,j(n.label),1)),U(`span`,eL,j(o(n).length),1)])):K(``,!0),!e.view.collapsed.has(n.key)||!i.value?(B(!0),V(z,{key:1},L(r.value,r=>(B(),V(`div`,{key:r.key,class:`flex min-w-0 flex-col gap-2 py-2`,role:`cell`},[(B(!0),V(z,null,L(a(o(n),r.key),n=>R(t.$slots,`card`,{item:n},void 0,void 0,e.view.spec.id(n))),128))]))),128)):K(``,!0)],64))),128))],12,JI)])):(B(),V(`div`,tL,[e.view.total.value>0?(B(),V(z,{key:0},[n[1]||=G(` 沒有符合條件的項目。`,-1),W(N(sC),{variant:`link`,size:`xs`,class:`px-0`,onClick:e.view.clearAll},{default:P(()=>[...n[0]||=[G(`清除篩選與搜尋`,-1)]]),_:1},8,[`onClick`])],64)):R(t.$slots,`empty`,{},void 0,void 0,1)]))}}),rL=.01,iL=e=>Math.min(2,Math.max(rL,e));function aL(e,t,n,r){let i=iL(t),a=(n-e.x)/e.zoom,o=(r-e.y)/e.zoom;return{zoom:i,x:n-a*i,y:r-o*i}}function oL(e,t,n=.9){if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{x:0,y:0,zoom:1};let r=iL(Math.min(1,t.width*n/e.width,t.height*n/e.height));return{zoom:r,x:(t.width-e.width*r)/2,y:(t.height-e.height*r)/2}}function sL(e){if(e.deltaMode!==0)return!0;let t=e.wheelDeltaY;return typeof t==`number`&&t!==0&&t%120==0&&e.deltaX===0}var cL=.5;function lL(e){return[{point:{x:e.x+e.width/2,y:e.y},axis:`y`,normal:{x:0,y:-1}},{point:{x:e.x+e.width/2,y:e.y+e.height},axis:`y`,normal:{x:0,y:1}},{point:{x:e.x,y:e.y+e.height/2},axis:`x`,normal:{x:-1,y:0}},{point:{x:e.x+e.width,y:e.y+e.height/2},axis:`x`,normal:{x:1,y:0}}]}var uL=e=>({x:e.y,y:e.x}),dL=e=>({x:e.y,y:e.x,width:e.height,height:e.width});function fL(e,t,n){return Math.min(t.x,n.x)<e.x+e.width&&Math.max(t.x,n.x)>e.x&&Math.min(t.y,n.y)<e.y+e.height&&Math.max(t.y,n.y)>e.y}var pL=(e,t)=>e.slice(1).every((n,r)=>!t.some(t=>fL(t,e[r],n))),mL=(e,t)=>e.slice(1).reduce((n,r,i)=>n+t.filter(t=>fL(t,e[i],r)).length,0);function hL(e){let t=0;for(let n=1;n<e.length-1;n++){let r=e[n-1],i=e[n],a=e[n+1];Math.abs(r.x-i.x)<cL&&Math.abs(i.x-a.x)<cL||Math.abs(r.y-i.y)<cL&&Math.abs(i.y-a.y)<cL||t++}return t}var gL=e=>e.slice(1).reduce((t,n,r)=>t+Math.abs(n.x-e[r].x)+Math.abs(n.y-e[r].y),0);function _L(e,t){let n=e=>e.slice(1).map((t,n)=>[e[n],t]),r=0;for(let i of n(e)){let e=Math.abs(i[0].x-i[1].x)<cL;for(let a of t)for(let t of n(a)){if(Math.abs(t[0].x-t[1].x)<cL===e)continue;let n=e?i:t,a=e?t:i,o=Math.min(n[0].y,n[1].y),s=Math.max(n[0].y,n[1].y),c=Math.min(a[0].x,a[1].x),l=Math.max(a[0].x,a[1].x);n[0].x>c&&n[0].x<l&&a[0].y>o&&a[0].y<s&&r++}}return r}function vL(e,t,n){if(e.length<2)return!1;let[r,i]=[e[0],e[1]],[a,o]=[e[e.length-1],e[e.length-2]];return(i.x-r.x)*t.normal.x+(i.y-r.y)*t.normal.y>cL&&(o.x-a.x)*n.normal.x+(o.y-a.y)*n.normal.y>cL}function yL(e){let t=[];for(let n of e){let e=t[t.length-1];if(!(e&&Math.abs(n.x-e.x)<cL&&Math.abs(n.y-e.y)<cL)){if(t.length>=2){let r=t[t.length-2];(Math.abs(r.x-e.x)<cL&&Math.abs(e.x-n.x)<cL||Math.abs(r.y-e.y)<cL&&Math.abs(e.y-n.y)<cL)&&t.pop()}t.push(n)}}return t}function bL(e,t,n){let r=yL(e),i=(e,t)=>Math.abs(e.x-t.x)<cL;if(r.length>=2){let e=r[r.length-1],t=r[r.length-2];i(t,e)!==(n.axis===`y`)&&r.splice(r.length-1,0,n.axis===`y`?{x:e.x,y:t.y}:{x:t.x,y:e.y})}if(r.length>=2){let e=r[0],n=r[1];i(e,n)!==(t.axis===`y`)&&r.splice(1,0,t.axis===`y`?{x:e.x,y:n.y}:{x:n.x,y:e.y})}return yL(r)}function xL(e,t,n){let r=(e.x+t.x)/2,i=[e,{x:r,y:e.y},{x:r,y:t.y},t];if(Math.abs(e.y-t.y)<cL&&pL([e,t],n))return[e,t];for(let i of[r,e.x+18,t.x-18]){let r=[e,{x:i,y:e.y},{x:i,y:t.y},t];if(pL(r,n))return r}let a=n.flatMap(e=>[e.y-18,e.y+e.height+18]).sort((t,n)=>Math.abs(t-e.y)-Math.abs(n-e.y));for(let r of a){let i=[e,{x:e.x+18,y:e.y},{x:e.x+18,y:r},{x:t.x-18,y:r},{x:t.x-18,y:t.y},t];if(pL(i,n))return i}return i}function SL(e,t,n,r){return r===`x`?xL(e,t,n):xL(uL(e),uL(t),n.map(dL)).map(uL)}function CL(e,t,n){let r=[];if(e.axis===t.axis){let n=e.axis===`y`;Math.abs(n?e.point.x-t.point.x:e.point.y-t.point.y)<cL&&r.push([e.point,t.point]);let i=n?[(e.point.y+t.point.y)/2,e.point.y+e.normal.y*18]:[(e.point.x+t.point.x)/2,e.point.x+e.normal.x*18];for(let a of i)r.push(n?[e.point,{x:e.point.x,y:a},{x:t.point.x,y:a},t.point]:[e.point,{x:a,y:e.point.y},{x:a,y:t.point.y},t.point])}else r.push(e.axis===`y`?[e.point,{x:e.point.x,y:t.point.y},t.point]:[e.point,{x:t.point.x,y:e.point.y},t.point]);let i=r.map(n=>bL(n,e,t)).filter(e=>pL(e,n));return i.length?i:[bL(SL(e.point,t.point,n,e.axis),e,t)]}function wL(e,t,n,r=[]){let i;for(let a of lL(e))for(let e of lL(t))for(let t of CL(a,e,n)){let o=[mL(t,n),+!vL(t,a,e),_L(t,r),hL(t),gL(t)];(!i||TL(o,i.score))&&(i={path:t,score:o})}return i?.path??[lL(e)[3].point,lL(t)[2].point]}function TL(e,t){for(let[n,r]of e.entries())if(r!==t[n])return r<t[n];return!1}function EL(e){return e.length<=2?e:e.filter((t,n)=>{if(n===0||n===e.length-1)return!0;let r=e[n-1],i=e[n+1];return!(r.x===t.x&&t.x===i.x||r.y===t.y&&t.y===i.y)})}var DL=e=>String(Math.round(e*100)/100);function OL(e,t=8){let n=EL(e);if(n.length<2)return``;let r=`M${DL(n[0].x)},${DL(n[0].y)}`,i=n[0];for(let e=1;e<n.length-1;e++){let a=n[e],o=n[e+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y),l=Math.min(t,s/2,c/2),u={x:a.x-(a.x-i.x)/(s||1)*l,y:a.y-(a.y-i.y)/(s||1)*l},d={x:a.x+(o.x-a.x)/(c||1)*l,y:a.y+(o.y-a.y)/(c||1)*l};r+=` L${DL(u.x)},${DL(u.y)} Q${DL(a.x)},${DL(a.y)} ${DL(d.x)},${DL(d.y)}`,i=d}let a=n[n.length-1];return`${r} L${DL(a.x)},${DL(a.y)}`}function kL(e,t){if(e.length<2)return e;let n=e[e.length-1],r=e[e.length-2],i=Math.hypot(n.x-r.x,n.y-r.y);return i<=t*2?e:[...e.slice(0,-1),{x:n.x-(n.x-r.x)/i*t,y:n.y-(n.y-r.y)/i*t}]}var AL={width:260,height:72};function jL(e,t){let n=new Set(e),r=t.filter(e=>e.from!==e.to&&n.has(e.from)&&n.has(e.to)),i=new Set(r.flatMap(e=>[e.from,e.to])),a=new Map;for(let e of r)a.set(e.from,[...a.get(e.from)??[],e.to]);let o=new Map,s=new Set;function c(e){let t=o.get(e);if(t!==void 0)return t;if(s.has(e))return 0;s.add(e);let n=Math.max(0,...(a.get(e)??[]).map(e=>c(e)+1));return s.delete(e),o.set(e,n),n}let l=[];for(let t of e){if(!i.has(t))continue;let e=c(t);for(;l.length<=e;)l.push([]);l[e].push(t)}let u=e.filter(e=>!i.has(e));if(u.length){let e=Math.ceil(u.length/7),t=Math.ceil(u.length/e);for(let n=0;n<e;n++)l.push(u.slice(n*t,(n+1)*t))}return l.filter(e=>e.length>0)}function ML(e,t,n){let r=e.id!==void 0,i=r?12:0,a=r?26:0,o=[],s=i,c=0,l=jL(e.ids,t);for(let[e,t]of l.entries()){let r=Math.max(...t.map(e=>n(e).width)),u=i+a;for(let e of t){let t=n(e);o.push([e,{x:s,y:u,width:t.width,height:t.height}]),u+=t.height+16}c=Math.max(c,u-16-i-a),s+=r+(e<l.length-1?48:0)}return{id:e.id,framed:r,width:s+i,height:c+2*i+a,cards:o}}function NL(e,t,n,r={}){let i=r.wrapWidth??1600,a=e=>t.get(e)??AL,o={groups:[],cards:new Map,width:0,height:0},s=0,c=0,l=0;for(let t of e){if(!t.ids.length)continue;let e=ML(t,n,a);s>0&&s+e.width>i&&(s=0,c+=l+28,l=0),o.groups.push({id:e.id,framed:e.framed,x:s,y:c,width:e.width,height:e.height});for(let[t,n]of e.cards)o.cards.set(t,{...n,x:n.x+s,y:n.y+c});l=Math.max(l,e.height),o.width=Math.max(o.width,s+e.width),s+=e.width+28}return o.height=c+l,o}var PL=[`data-node`,`aria-pressed`,`title`],FL={class:`flex min-w-0 items-center gap-2`},IL={class:`truncate`},LL={class:`shrink-0 font-mono text-xs text-muted-foreground`},RL=[`title`],zL={class:`h-1 w-12 overflow-hidden rounded-full bg-muted`},BL={class:`flex min-w-0 items-center gap-2`},VL=[`title`],HL=I({__name:`MainlineNode`,props:{id:{},picked:{type:Boolean}},emits:[`pick`],setup(e){let t=e,n=J(()=>Q.summary?.mainlines.find(e=>e.id===t.id)),r=J(()=>n.value?.title??Iw(t.id).title??``),i=J(()=>n.value?.status??Iw(t.id).status),a=J(()=>n.value?.items),o=J(()=>gN(i.value??``)),s=J(()=>OC(t.id)),c=J(()=>{let e=Q.mainlines[t.id]?.tasks;return e?vN(e):void 0}),l=J(()=>a.value?.total?Math.round(100*a.value.done/a.value.total):0);return(t,n)=>(B(),V(`button`,{type:`button`,class:k([`relative z-[1] flex w-full min-w-0 flex-col gap-1.5 rounded-xl border px-3 py-2.5 text-left transition-[background-color,border-color] duration-[120ms] focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none`,[s.value?`border-dashed border-muted-foreground/60 bg-background hover:bg-[color-mix(in_oklab,var(--accent)_50%,var(--background))]`:`bg-card shadow-xs hover:bg-[color-mix(in_oklab,var(--accent)_50%,var(--card))]`,{"border-ring":e.picked}]]),"data-node":e.id,"aria-pressed":e.picked,title:s.value?`${e.id}:在新分頁開啟另一個 hub`:void 0,onClick:n[0]||=n=>t.$emit(`pick`,e.id,n)},[U(`span`,FL,[W(nT,{type:`mainline`,status:i.value},null,8,[`status`]),s.value?(B(),H(N(nE),{key:0,variant:`outline`,class:`min-w-0 shrink font-mono text-[11px] text-muted-foreground`},{default:P(()=>[U(`span`,IL,j(s.value.hub),1)]),_:1})):K(``,!0),U(`span`,LL,j(s.value?.local??e.id),1),s.value?(B(),H(N(zu),{key:1,class:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})):K(``,!0),a.value?(B(),V(`span`,{key:2,class:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,title:`checklist ${a.value.done}/${a.value.total}`},[U(`span`,zL,[U(`span`,{class:`block h-full bg-foreground`,style:he({width:`${l.value}%`})},null,4)]),G(` `+j(a.value.done)+`/`+j(a.value.total),1)],8,RL)):K(``,!0)]),U(`span`,BL,[U(`span`,{class:k([`truncate font-medium`,{"text-muted-foreground":o.value}])},j(r.value),3),!o.value&&c.value?(B(),V(`span`,{key:0,class:k([`ml-auto inline-flex shrink-0 items-center gap-1 text-xs tabular-nums`,{"text-muted-foreground":!c.value.doing}]),title:`進行中 ${c.value.doing}/未完成 ${c.value.open} 個任務`},[W(nT,{type:`phase`,status:c.value.doing?`doing`:void 0},null,8,[`status`]),G(j(c.value.doing)+`/`+j(c.value.open),1)],10,VL)):K(``,!0)])],10,PL))}}),UL=[`data-serves`,`data-session`,`aria-pressed`],WL={"data-session-icon":``,class:`relative row-span-2 grid size-6 place-items-center rounded-md bg-muted text-foreground`},GL={class:`flex min-w-0 items-baseline gap-1`},KL={class:`truncate font-medium`},qL=[`title`],JL=[`title`],YL={class:`truncate leading-4 text-muted-foreground`},XL=I({__name:`SessionNode`,props:{session:{},serves:{},picked:{type:Boolean}},emits:[`pick`],setup(e){let t=e,n=J(()=>t.session.actions.find(e=>e.status===`doing`)??t.session.actions.find(e=>e.status===`todo`)),r=J(()=>vN(t.session.actions)),i=zw.session.icon;return(t,a)=>(B(),V(`button`,{type:`button`,class:k([`relative z-[1] grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-2 rounded-md border py-1 pr-2 pl-1 text-left text-xs transition-colors duration-[120ms] hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none`,e.picked?`border-ring`:`border-transparent`]),"data-serves":e.serves,"data-session":e.session.id,"aria-pressed":e.picked,onClick:a[0]||=e=>t.$emit(`pick`,e)},[U(`span`,WL,[(B(),H(fa(N(i)),{class:`size-3.5`})),U(`span`,{class:k([`absolute -right-0.5 -bottom-0.5 size-2 rounded-full border-[1.5px] border-background`,n.value?`bg-status-done`:`bg-status-todo`])},null,2)]),U(`span`,GL,[U(`span`,KL,j(N(jw)(e.session)),1),e.session.elsewhere?(B(),V(`span`,{key:0,class:`shrink-0 text-muted-foreground`,title:`其他環境:工作目錄 ${e.session.cwd} 不在這台電腦上`,"data-elsewhere":``},`其他環境`,8,qL)):K(``,!0),r.value.open?(B(),V(`span`,{key:1,class:k([`shrink-0 tabular-nums`,{"text-muted-foreground":!r.value.doing}]),title:`進行中 ${r.value.doing}/未處理 ${r.value.open} 個行動`},`(`+j(r.value.doing)+`/`+j(r.value.open)+`)`,11,JL)):K(``,!0)]),U(`span`,YL,j(n.value?.do??`沒有待做的行動`),1)],10,UL))}}),ZL={class:`rounded-xl border bg-card text-body shadow-xs`},QL={class:`flex h-10 items-center gap-2 px-4`},$L={class:`font-mono text-xs text-muted-foreground`},eR={class:`flex flex-col gap-4 px-4 pb-4`},tR={class:`text-base font-semibold [overflow-wrap:anywhere]`},nR={class:`grid grid-cols-[72px_1fr] items-center gap-x-3 gap-y-1.5 text-xs`},rR={class:`flex flex-col gap-0.5`},iR=[`onClick`],aR={class:`shrink-0 font-mono text-muted-foreground`},oR={class:`truncate`},sR={class:`ml-auto shrink-0 text-muted-foreground`},cR={key:0,class:`px-1.5 text-xs text-muted-foreground`},lR={class:`flex flex-col gap-0.5`},uR={key:0,class:`px-1.5 text-xs text-muted-foreground`},dR={class:`flex h-10 items-center gap-2 px-4`},fR={class:`flex flex-col gap-4 px-4 pb-4`},pR={class:`text-base font-semibold [overflow-wrap:anywhere]`},mR={class:`grid grid-cols-[72px_1fr] items-center gap-x-3 gap-y-1.5 text-xs`},hR={class:`flex flex-col gap-0.5`},gR={class:`flex flex-col gap-0.5`},_R={class:`shrink-0 font-mono text-muted-foreground`},vR={class:`truncate`},yR={key:1,class:`px-1.5 text-xs text-muted-foreground`},bR={key:2,class:`px-4 py-6 text-sm text-muted-foreground`},xR=I({__name:`RunningPreview`,props:{picked:{}},emits:[`pickMainline`,`pickSession`],setup(e,{emit:t}){let n=e,r=t,{open:i}=FC(),a=[`doing`,`blocked`,`todo`],o=Aw,s=J(()=>{if(n.picked?.kind!==`mainline`)return;let e=n.picked.id,t=Q.summary?.mainlines.find(t=>t.id===e),r=(Q.mainlines[e]?.tasks??[]).filter(e=>a.includes(e.status)).sort((e,t)=>a.indexOf(e.status)-a.indexOf(t.status)||(e.order??0)-(t.order??0));return{id:e,loaded:!!Q.mainlines[e],title:t?.title??Iw(e).title??e,status:t?.status,criteria:t?.criteria,items:t?.items,tasks:r,sessions:Nw().filter(t=>Mw(t)===e)}}),c=J(()=>n.picked?.kind===`session`?Q.sessions.find(e=>e.id===n.picked.id):void 0),l=e=>{let t=e=>Q.sessions.filter(t=>t.delegatedFrom===e).flatMap(e=>[e,...t(e.id)]),n=t(e.id);return n.length?`${n.filter(e=>e.status===`active`).length} 個進行中,共 ${n.length} 個`:`沒有`};return(e,t)=>(B(),V(`div`,ZL,[s.value?(B(),V(z,{key:0},[U(`div`,QL,[W(nT,{type:`mainline`,status:s.value.status},null,8,[`status`]),U(`span`,$L,j(s.value.id),1),t[2]||=U(`span`,{class:`text-xs text-muted-foreground`},`主脈絡`,-1)]),U(`div`,eR,[U(`h3`,tR,j(s.value.title),1),U(`dl`,nR,[t[5]||=U(`dt`,{class:`text-muted-foreground`},`狀態`,-1),U(`dd`,null,[s.value.status?(B(),H(kE,{key:0,status:s.value.status},null,8,[`status`])):K(``,!0)]),s.value.criteria?(B(),V(z,{key:0},[t[3]||=U(`dt`,{class:`text-muted-foreground`},`解決條件`,-1),U(`dd`,null,[W(nP,{done:s.value.criteria.done,total:s.value.criteria.total},null,8,[`done`,`total`])])],64)):K(``,!0),s.value.items?(B(),V(z,{key:1},[t[4]||=U(`dt`,{class:`text-muted-foreground`},`checklist`,-1),U(`dd`,null,[W(nP,{done:s.value.items.done,total:s.value.items.total},null,8,[`done`,`total`])])],64)):K(``,!0)]),U(`section`,rR,[t[6]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`未完成的任務`,-1),(B(!0),V(z,null,L(s.value.tasks,e=>(B(),V(`button`,{key:e.id,type:`button`,class:`flex h-7 min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-xs hover:bg-accent`,onClick:t=>N(i)(N(CC)(s.value.id,e.id))},[W(nT,{type:N(Bw)(e),status:e.status},null,8,[`type`,`status`]),U(`span`,aR,j(e.id),1),U(`span`,oR,j(e.title),1),U(`span`,sR,j(N(Yw)[e.status]),1)],8,iR))),128)),s.value.tasks.length?K(``,!0):(B(),V(`p`,cR,j(s.value.loaded?`沒有`:`載入中…`),1))]),U(`section`,lR,[t[7]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`會話`,-1),(B(!0),V(z,null,L(s.value.sessions,e=>(B(),H(XL,{key:e.id,session:e,onPick:t=>r(`pickSession`,e.id)},null,8,[`session`,`onPick`]))),128)),s.value.sessions.length?K(``,!0):(B(),V(`p`,uR,`沒有`))]),U(`div`,null,[W(N(sC),{variant:`outline`,size:`sm`,"as-child":``},{default:P(()=>[W(N(Am),{to:`/mainlines/${s.value.id}`},{default:P(()=>[...t[8]||=[G(`開啟主脈絡`,-1)]]),_:1},8,[`to`])]),_:1})])])],64)):c.value?(B(),V(z,{key:1},[U(`div`,dR,[W(nT,{type:`session`,status:c.value.status},null,8,[`status`]),t[9]||=U(`span`,{class:`text-xs text-muted-foreground`},`會話`,-1)]),U(`div`,fR,[U(`h3`,pR,j(N(jw)(c.value)),1),U(`dl`,mR,[t[10]||=U(`dt`,{class:`text-muted-foreground`},`狀態`,-1),U(`dd`,null,[W(kE,{status:c.value.status},null,8,[`status`])]),t[11]||=U(`dt`,{class:`text-muted-foreground`},`子代理`,-1),U(`dd`,null,j(l(c.value)),1)]),U(`section`,hR,[t[12]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`目前行動`,-1),U(`p`,{class:k([`text-xs [overflow-wrap:anywhere]`,{"text-muted-foreground":!N(o)(c.value)}])},j(N(o)(c.value)?.do??`沒有待做的行動`),3)]),U(`section`,gR,[t[13]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`服務的主脈絡`,-1),N(Mw)(c.value)?(B(),V(`button`,{key:0,type:`button`,class:`flex h-7 min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-xs hover:bg-accent`,onClick:t[0]||=e=>r(`pickMainline`,N(Mw)(c.value))},[W(nT,{type:`mainline`,status:N(Iw)(N(Mw)(c.value)).status},null,8,[`status`]),U(`span`,_R,j(N(Mw)(c.value)),1),U(`span`,vR,j(N(Iw)(N(Mw)(c.value)).title),1)])):(B(),V(`p`,yR,`沒有`))]),U(`div`,null,[W(N(sC),{variant:`outline`,size:`sm`,onClick:t[1]||=e=>N(i)(N(TC)(c.value.id))},{default:P(()=>[...t[14]||=[G(`開啟會話`,-1)]]),_:1})])])],64)):(B(),V(`p`,bR,`點關係圖裡的主脈絡或會話看詳情。`))]))}}),SR=[`width`,`height`],CR=[`id`],wR=[`fill`],TR=[`d`,`stroke`,`stroke-dasharray`,`marker-end`],ER=[`onClick`],DR={class:`shrink-0 font-mono`},OR={class:`truncate`},kR=[`data-card`],AR={key:0,class:`flex flex-col gap-1.5 px-[9px]`},jR={class:`flex flex-wrap gap-x-6 gap-y-1`},MR={key:2,class:`absolute bottom-3 left-1/2 z-20 -translate-x-1/2 cursor-auto`,role:`toolbar`,"aria-label":`批次操作`,"data-canvas-overlay":``},NR={class:`flex items-center gap-1 rounded-lg border bg-popover py-1 pr-1 pl-3 text-sm shadow-md`},PR={class:`mr-2 tabular-nums`},FR={class:`text-muted-foreground tabular-nums`},IR={class:`absolute right-3 bottom-3 z-20 flex cursor-auto items-center rounded-full border bg-popover p-0.5 text-xs shadow-sm`,role:`toolbar`,"aria-label":`縮放`,"data-canvas-overlay":``},LR={key:1,class:`text-sm text-muted-foreground`},RR=1,zR=260,BR=4,VR=4,HR=`mainflow.overview.canvasHeight`,UR=240,WR=`mainflow.overview.previewWidth`,GR=260,KR=560,qR=I({__name:`RunningMap`,setup(e){let t=e=>`${e.kind}:${e.id}`,n=[`active`,`planning`,`paused`],r=e=>e&&!gN(e)?Math.max(0,n.indexOf(e)):n.length,i=(e,t)=>e.map((e,t)=>({item:e,i:t})).sort((e,n)=>r(t(e.item))-r(t(n.item))||e.i-n.i).map(e=>e.item),a=J(()=>(Q.summary?.mainlines??[]).filter(e=>!e.archivedAt)),o=e=>Iw(e).status,s=J(()=>a.value.map(e=>e.id)),c=J(()=>new Set((Q.summary?.mainlines??[]).filter(e=>e.archivedAt).map(e=>e.id))),l=J(()=>Q.relations.mainlineDeps.filter(e=>![e.from,e.to].some(e=>c.value.has(e)))),u=J(()=>new Map(Object.entries(Q.relations.groupMembers).flatMap(([e,t])=>t.filter(e=>e.kind===`mainline`&&!e.archived).map(t=>[t.ref,e])))),d=J(()=>i([...new Set([...s.value,...u.value.keys(),...l.value.flatMap(e=>[e.to,e.from])])],o)),f=J(()=>new Set(d.value)),p=e=>OC(e)?u.value.get(e):(Q.summary?.mainlines??[]).find(t=>t.id===e)?.group??void 0,m=J(()=>{let e=jN().map(e=>e.id),t=t=>t===void 0?1/0:e.includes(t)?e.indexOf(t):e.length,n=new Map;for(let e of d.value)n.set(p(e),[...n.get(p(e))??[],e]);return[...n].sort(([e],[n])=>t(e)-t(n)||(e??``).localeCompare(n??``)).map(([e,t])=>({id:e,ids:t}))}),h=M(new Map),g=J(()=>NL(m.value,h.value,l.value)),_=e=>g.value.cards.get(e),v=(e,t)=>{let n=_(e),r=t.framed?RR:0;return{left:`${n.x-t.x-r}px`,top:`${n.y-t.y-r}px`,width:`${zR}px`}},{open:y}=FC(),b=J(()=>i(Nw(),e=>e.status)),x=e=>b.value.filter(t=>Mw(t)===e),S=J(()=>b.value.filter(e=>!f.value.has(Mw(e)??``))),C=e=>e.kind===`mainline`?f.value.has(e.id):b.value.some(t=>t.id===e.id),w=Qt(new Map),T=J(()=>[...w.values()].filter(C)),ee=M(),E=J(()=>ee.value&&w.has(t(ee.value))&&C(ee.value)?ee.value:void 0),te=(e,n)=>w.has(t({kind:e,id:n})),ne=e=>!!e?.shiftKey;function re(){w.clear(),ee.value=void 0}function D(e,n){let r=t(e);if(ne(n)){w.has(r)?w.delete(r):w.set(r,e);return}w.clear(),w.set(r,e),ee.value=e}function ie(e,t){if(OC(e)){ne(t)||window.open(kC(e)??void 0,`_blank`,`noopener`);return}D({kind:`mainline`,id:e},t)}let ae=(e,t)=>D({kind:`session`,id:e},t);async function oe(){let e=new Map;for(let t of T.value)e.set(t.kind,[...e.get(t.kind)??[],t.id]);await dw(async()=>{let t=[];for(let[n,r]of e){let e=await XC.archiveMany(n,r,!0);t.push(...e.failed.map(e=>`${e.id}(${e.error})`))}if(t.length)throw Error(`${t.length} 個沒有封存:${t.join(`、`)}`)})&&re()}let se=M(),O=J(()=>{let e=se.value;return e&&{left:`${Math.min(e.x1,e.x2)}px`,top:`${Math.min(e.y1,e.y2)}px`,width:`${Math.abs(e.x2-e.x1)}px`,height:`${Math.abs(e.y2-e.y1)}px`}});function ce(e){let t=[],n=t=>{let n=t.getBoundingClientRect();return n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top};for(let e of ue.value?.querySelectorAll(`[data-node], [data-session]`)??[])n(e)&&(e.dataset.node?OC(e.dataset.node)||t.push({kind:`mainline`,id:e.dataset.node}):t.push({kind:`session`,id:e.dataset.session}));return t}let{current:le}=FC();Df(window,`keydown`,e=>{e.key!==`Escape`||le.value||Q.paletteOpen||!w.size||(E.value&&T.value.length>1?ee.value=void 0:re())},{capture:!0});let ue=M(),de=M([]),fe=M({width:0,height:0});function pe(e,t){let n=0,r=0;for(let i=e;i&&i!==t;i=i.offsetParent)n+=i.offsetLeft,r+=i.offsetTop;return{left:n,top:r,right:n+e.offsetWidth,bottom:r+e.offsetHeight,height:e.offsetHeight}}function me(){let e=ue.value;if(!e)return;let t=new Map,n=new Map;for(let n of e.querySelectorAll(`[data-card]`))t.set(n.dataset.card,n.offsetHeight);for(let t of e.querySelectorAll(`[data-node]`))n.set(t.dataset.node,t.offsetHeight);if([...t].some(([e,t])=>h.value.get(e)?.height!==t)){h.value=new Map([...t].map(([e,t])=>[e,{width:zR,height:t}]));return}let r=t=>{let n=e.querySelector(`[data-node="${CSS.escape(t)}"]`);return n?pe(n,e):void 0},i=e=>({x:e.x-6,y:e.y-6,width:e.width+12,height:e.height+12}),a=g.value.groups.filter(e=>e.framed).map(e=>({x:e.x,y:e.y,width:e.width,height:38})),o=[],s=[];for(let e of l.value){let t=_(e.to),r=_(e.from);if(!t||!r)continue;let c=(e,t)=>({x:t.x,y:t.y,width:t.width,height:n.get(e)??t.height}),l=c(e.to,t),u=c(e.from,r),d=[...a];for(let[t,n]of g.value.cards)if(t===e.to||t===e.from){let r=t===e.to?l:u;n.height>r.height&&d.push({x:n.x-6,y:r.y+r.height,width:n.width+12,height:n.height-r.height})}else d.push(i(n));let f=wL(l,u,d,s);s.push(f),o.push({key:`${e.to}>${e.from}`,d:OL(kL(f,2)),kind:e.state===`pending`?`pending`:`other`})}for(let t of e.querySelectorAll(`[data-serves]`)){let n=r(t.dataset.serves),i=t.querySelector(`[data-session-icon]`);if(!n||!i)continue;let a=pe(i,e);o.push({key:`s:${t.dataset.session}`,d:`M${n.left+12},${n.bottom} V${a.top+a.height/2} H${a.left}`,kind:`session`})}de.value=o,fe.value={width:e.offsetWidth,height:e.offsetHeight},Te||Ee()}Ff(ue,me),F([g,b,()=>Q.mainlines],()=>void tr(me),{deep:!0});let ge={pending:`var(--muted-foreground)`,other:`var(--status-off)`,session:`var(--status-off)`},_e={pending:void 0,other:`4 3`,session:`2 2`},ve=J(()=>Math.max(zR,g.value.width,Math.min(S.value.length,BR)*284-24)),ye=M(),A=M({x:0,y:0,zoom:1}),be=M({width:0,height:0});function xe(){let e=ye.value;e&&(be.value={width:e.clientWidth,height:e.clientHeight})}Ff(ye,()=>{xe(),Te||Ee()});let Se=M(!1),Ce;function we(e){Se.value=!0,A.value=e,clearTimeout(Ce),Ce=setTimeout(()=>Se.value=!1,320)}let Te=!1;function Ee(){xe(),fe.value.width&&fe.value.height&&be.value.width&&be.value.height&&(A.value=oL(fe.value,be.value),Te=!0)}let De=()=>(xe(),we(oL(fe.value,be.value))),Oe=e=>(xe(),we(aL(A.value,A.value.zoom*e,be.value.width/2,be.value.height/2))),ke=J(()=>`${Math.round(A.value.zoom*100)}%`),Ae=0;function je(e){let t=ye.value.getBoundingClientRect();if(e.ctrlKey||e.metaKey){e.preventDefault(),A.value=aL(A.value,iL(A.value.zoom*Math.exp(-e.deltaY*.01)),e.clientX-t.left,e.clientY-t.top);return}let n=performance.now()<Ae||!sL(e);if(e.preventDefault(),!n){Me(ye.value).scrollBy({top:Ne(e,e.deltaY),left:Ne(e,e.deltaX)});return}Ae=performance.now()+120,A.value={...A.value,x:A.value.x-e.deltaX,y:A.value.y-e.deltaY}}function Me(e){for(let t=e.parentElement;t;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return document.scrollingElement??document.documentElement}let Ne=(e,t)=>e.deltaMode===1?t*16:e.deltaMode===2?t*window.innerHeight:t;function Pe(e){let n=ye.value,r=n.getBoundingClientRect(),i=new Map(w),a=e.clientX-r.left,o=e.clientY-r.top;try{n.setPointerCapture(e.pointerId)}catch{}let s=e=>{let n=e.clientX-r.left,s=e.clientY-r.top;if(!se.value&&Math.hypot(n-a,s-o)<VR)return;se.value={x1:a,y1:o,x2:n,y2:s};let c=ce({left:r.left+Math.min(a,n),top:r.top+Math.min(o,s),right:r.left+Math.max(a,n),bottom:r.top+Math.max(o,s)});w.clear();for(let[e,t]of i)w.set(e,t);for(let e of c)w.set(t(e),e)},c=()=>{n.removeEventListener(`pointermove`,s),n.removeEventListener(`pointerup`,c),n.removeEventListener(`pointercancel`,c),se.value=void 0};n.addEventListener(`pointermove`,s),n.addEventListener(`pointerup`,c),n.addEventListener(`pointercancel`,c)}let Fe=M(!1);function Ie(e){if(e.button!==0||e.target.closest(`button, a, [data-canvas-overlay]`))return;if(e.shiftKey)return Pe(e);let t={x:e.clientX,y:e.clientY,vx:A.value.x,vy:A.value.y},n=!1,r=ye.value;try{r.setPointerCapture(e.pointerId)}catch{}let i=e=>{let r=e.clientX-t.x,i=e.clientY-t.y;!n&&Math.hypot(r,i)<VR||(n=!0,Fe.value=!0,A.value={...A.value,x:t.vx+r,y:t.vy+i})},a=()=>{r.removeEventListener(`pointermove`,i),r.removeEventListener(`pointerup`,a),r.removeEventListener(`pointercancel`,a),Fe.value=!1,n||re()};r.addEventListener(`pointermove`,i),r.addEventListener(`pointerup`,a),r.addEventListener(`pointercancel`,a)}let Le=e=>Math.round(Math.min(Math.max(UR,window.innerHeight),Math.max(UR,e))),Re=Number($C(HR,null)),ze=M(Re>0?Le(Re):null);function Be(e){let t=e.clientY,n=ye.value.offsetHeight,r=e=>ze.value=Le(n+e.clientY-t),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),ew(HR,ze.value)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}function Ve(){ze.value=null,ew(HR,null)}let He=e=>Math.min(KR,Math.max(GR,e)),Ue=M(He(Number($C(WR,340))||340)),We=J(()=>be.value.width?Math.min(Ue.value,be.value.width*.6):Ue.value);function Ge(e){let t=e.clientX,n=We.value,r=e=>Ue.value=He(n+t-e.clientX),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),ew(WR,Ue.value)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return(e,t)=>d.value.length||b.value.length?(B(),V(`div`,{key:0,ref_key:`viewport`,ref:ye,class:k([`relative w-full touch-none overflow-hidden rounded-xl border bg-background select-none`,[Fe.value?`cursor-grabbing`:`cursor-grab`,ze.value===null&&`h-[60vh]`]]),style:he(ze.value===null?void 0:{height:`${ze.value}px`}),"data-canvas":``,onPointerdown:Ie,onWheel:je},[U(`div`,{ref_key:`canvas`,ref:ue,class:k([`absolute top-0 left-0 flex origin-top-left flex-col gap-6`,{"transition-transform duration-300 ease-out":Se.value}]),style:he({width:`${ve.value}px`,transform:`translate(${A.value.x}px, ${A.value.y}px) scale(${A.value.zoom})`})},[(B(),V(`svg`,{class:`pointer-events-none absolute inset-0 overflow-visible`,width:fe.value.width,height:fe.value.height,"aria-hidden":`true`},[U(`defs`,null,[(B(),V(z,null,L([`pending`,`other`],e=>U(`marker`,{id:`run-arrow-${e}`,key:e,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto`},[U(`path`,{d:`M0,0 L8,4 L0,8 z`,fill:ge[e]},null,8,wR)],8,CR)),64))]),(B(!0),V(z,null,L(de.value,e=>(B(),V(`path`,{key:e.key,d:e.d,fill:`none`,"stroke-width":`1.5`,stroke:ge[e.kind],"stroke-dasharray":_e[e.kind],"marker-end":e.kind===`session`?void 0:`url(#run-arrow-${e.kind})`},null,8,TR))),128))],8,SR)),U(`div`,{class:`relative shrink-0`,style:he({width:`${g.value.width}px`,height:`${g.value.height}px`})},[(B(!0),V(z,null,L(g.value.groups,e=>(B(),H(fa(e.framed?`section`:`div`),{key:e.id??`ungrouped`,class:k([`absolute flex flex-col rounded-xl p-2`,e.framed?`border border-dashed`:`border-0`]),style:he({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`}),"data-map-group":e.id},{default:P(()=>[e.id?(B(),V(`button`,{key:0,type:`button`,class:`relative z-[1] flex max-w-full min-w-0 items-center gap-1.5 self-start rounded-sm bg-background px-1 text-left text-xs text-muted-foreground hover:bg-accent`,onClick:t=>N(y)(e.id)},[W(nT,{type:`group`,status:N(AN)(e.id)?.status},null,8,[`status`]),U(`span`,DR,j(e.id),1),U(`span`,OR,j(N(AN)(e.id)?.title),1),W(TE,{priority:N(AN)(e.id)?.priority,class:`shrink-0`},null,8,[`priority`])],8,ER)):K(``,!0),(B(!0),V(z,null,L(m.value.find(t=>t.id===e.id)?.ids??[],t=>(B(),V(`div`,{key:t,class:`absolute flex flex-col gap-1.5`,style:he(v(t,e)),"data-card":t},[W(HL,{id:t,picked:te(`mainline`,t),onPick:ie},null,8,[`id`,`picked`]),(B(!0),V(z,null,L(x(t),e=>(B(),H(XL,{key:e.id,session:e,serves:t,picked:te(`session`,e.id),class:`ml-5`,onPick:t=>ae(e.id,t)},null,8,[`session`,`serves`,`picked`,`onPick`]))),128))],12,kR))),128))]),_:2},1032,[`class`,`style`,`data-map-group`]))),128))],4),S.value.length?(B(),V(`div`,AR,[U(`div`,jR,[(B(!0),V(z,null,L(S.value,e=>(B(),H(XL,{key:e.id,session:e,picked:te(`session`,e.id),class:`max-w-full`,style:he({width:`${zR}px`}),onPick:t=>ae(e.id,t)},null,8,[`session`,`picked`,`style`,`onPick`]))),128))])])):K(``,!0)],6),E.value?(B(),V(`aside`,{key:0,class:`absolute top-3 right-3 z-20 flex max-h-[calc(100%-1.5rem)] cursor-auto flex-col overflow-y-auto overscroll-contain rounded-xl shadow-lg`,style:he({width:`${We.value}px`}),"aria-label":`預覽`,"data-canvas-overlay":``,onWheel:t[0]||=au(()=>{},[`stop`])},[U(`div`,{class:`absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`拖曳調整預覽寬度`,onPointerdown:au(Ge,[`prevent`,`stop`])},null,32),W(xR,{picked:E.value,onPickMainline:ie,onPickSession:ae},null,8,[`picked`])],36)):K(``,!0),se.value?(B(),V(`div`,{key:1,class:`pointer-events-none absolute z-20 rounded-sm border border-ring bg-ring/10`,style:he(O.value),"aria-hidden":`true`},null,4)):K(``,!0),T.value.length>=1?(B(),V(`div`,MR,[U(`div`,NR,[U(`span`,PR,`已選 `+j(T.value.length)+` 個`,1),W(N(sC),{variant:`ghost`,size:`sm`,onClick:oe},{default:P(()=>[W(N(Pu)),t[4]||=G(`封存`,-1),U(`span`,FR,j(T.value.length),1)]),_:1}),W(N(sC),{variant:`ghost`,size:`icon-sm`,"aria-label":`清除選取`,onClick:t[1]||=e=>re()},{default:P(()=>[W(N(uf))]),_:1})])])):K(``,!0),U(`div`,{class:`absolute inset-x-0 bottom-0 z-10 h-2 cursor-row-resize`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`拖曳調整畫布高度,雙擊回到預設高度`,"data-canvas-overlay":``,onPointerdown:au(Be,[`prevent`,`stop`]),onDblclick:Ve},null,32),U(`div`,IR,[W(N(sC),{variant:`ghost`,size:`icon-sm`,class:`rounded-full`,"aria-label":`縮小`,onClick:t[2]||=e=>Oe(1/N(1.2))},{default:P(()=>[W(N(Vd))]),_:1}),U(`button`,{type:`button`,class:`h-7 min-w-12 rounded-full px-1.5 tabular-nums hover:bg-accent`,title:`全部置入畫面`,"aria-label":`全部置入畫面`,onClick:De},j(ke.value),1),W(N(sC),{variant:`ghost`,size:`icon-sm`,class:`rounded-full`,"aria-label":`放大`,onClick:t[3]||=e=>Oe(N(1.2))},{default:P(()=>[W(N(Gd))]),_:1})])],38)):(B(),V(`p`,LR,[...t[5]||=[G(`沒有主脈絡。在 hub 內執行 `,-1),U(`code`,null,`mainflow new mainline <slug> --title <title>`,-1),G(` 建立。`,-1)]]))}}),JR={class:`flex flex-col gap-8 px-6 pt-2 pb-10`},YR={key:0,"aria-labelledby":`attention`,class:`-mb-4 rounded-lg border bg-card`},XR={id:`attention`,class:`text-sm font-medium`},ZR=[`aria-expanded`],QR={class:`text-xs text-muted-foreground tabular-nums`},$R={key:2,class:`ml-2 flex min-w-0 items-center gap-3 overflow-hidden text-xs font-normal text-muted-foreground`},ez={class:`tabular-nums`},tz={id:`attention-list`,class:`border-t`},nz=[`data-peek`,`aria-current`,`onClick`],rz={class:`shrink-0 font-mono text-xs text-muted-foreground`},iz={class:`min-w-0 truncate`},az=[`title`],oz={class:`truncate`},sz={key:0,class:`hidden max-w-48 shrink-0 truncate text-xs text-muted-foreground xl:inline`},cz={"aria-labelledby":`running`},lz={id:`running`,class:`mb-2 flex items-center gap-1.5 text-sm font-medium`},uz={class:`text-xs font-normal text-muted-foreground tabular-nums`},dz={type:`button`,class:`grid size-5 place-items-center rounded-sm text-muted-foreground hover:text-foreground`,"aria-label":`依賴線的說明`},fz={"aria-labelledby":`issues`,class:`-mx-6 min-w-0`},pz={id:`issues`,class:`px-6 text-sm font-medium`},mz={class:`ml-1 text-xs text-muted-foreground tabular-nums`},hz={class:`flex min-w-0 items-center gap-2`},gz={class:`shrink-0 font-mono text-xs text-muted-foreground`},_z=[`title`],vz={key:0,class:`flex min-w-0 items-center gap-1.5 overflow-hidden text-xs`},yz=`mainflow.overview.attentionOpen`,bz=`mainflow.list.overview.issues.axis`,xz=`箭頭由要先完成的主脈絡指向等待它的主脈絡;實線是還沒完成的依賴,虛線是已完成或無法確認的依賴。`,Sz=I({__name:`Overview`,setup(e){let{open:t,current:n}=FC(),r=e=>n.value?.ref===e||void 0,i=J(()=>(Q.summary?.mainlines??[]).filter(e=>!e.archivedAt)),a=J(()=>i.value.filter(e=>e.status===`active`||e.status===`planning`||e.status===`paused`)),o=J(()=>[...new Set([...a.value.map(e=>e.id),...Q.relations.mainlineDeps.flatMap(e=>[e.from,e.to]).filter(e=>/^m\d{3}$/.test(e))])]);Er(()=>void uw(o.value));let s=J(()=>a.value.flatMap(e=>Q.mainlines[e.id]?[Q.mainlines[e.id]]:[])),c={overdue:{label:`逾期`,icon:Wu,tone:`text-destructive`},blocked:{label:`卡住`,icon:ed,tone:`text-status-waiting`},proposed:{label:`待裁決`,icon:Qu,tone:`text-warning`},due:{label:`即將到期`,icon:Wu,tone:`text-warning`},review:{label:`待重新確認`,icon:qd,tone:`text-warning`}},l=J(()=>[...s.value.flatMap(e=>e.tasks.filter(e=>e.status===`blocked`).map(t=>({ref:CC(e.id,t.id),type:Bw(t),status:t.status,id:`${e.id}/${t.id}`,title:t.title,kind:`blocked`,reason:`卡住:${t.blockedBy?.reason??`沒有寫原因`}`,context:e.title}))),...s.value.flatMap(e=>e.decisions.filter(e=>e.status===`proposed`).map(t=>({ref:wC(e.id,t.id),type:`decision`,status:t.status,id:`${e.id}/${t.id}`,title:t.title,kind:`proposed`,reason:t.affects?.length?`待裁決,影響 ${t.affects.join(`、`)}`:`待裁決`,context:e.title}))),...Q.issues.filter(e=>e.status!==`closed`&&!e.archivedAt&&hE(e.due)).map(e=>{let t=mE(e.due);return{ref:e.id,type:`issue`,status:e.status,id:e.id,title:e.title,kind:t<0?`overdue`:`due`,reason:t<0?`已逾期 ${-t} 天`:t===0?`今天到期`:`${t} 天後到期`}}),...Q.findings.filter(e=>e.status===`valid`&&!e.archivedAt&&e.reviewAfter&&mE(e.reviewAfter)<0).map(e=>({ref:e.id,type:`finding`,status:e.status,id:e.id,title:e.title,kind:`review`,reason:`${e.reviewAfter} 起該重新確認是否仍成立`}))]),u=J(()=>Object.keys(c).flatMap(e=>{let t=l.value.filter(t=>t.kind===e).length;return t?[{kind:e,n:t,...c[e]}]:[]})),d=M($C(yz,!1)===!0);function f(){d.value=!d.value,ew(yz,d.value)}let p=[`open`,`planned`],m=DN({key:`overview.issues`,queryPrefix:`i.`,id:e=>e.id,text:e=>e.title,filters:PF(p),sorts:[{key:`order`,label:`手動順序`,value:e=>e.order,dir:`asc`},{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),dir:`asc`},{key:`planned`,label:`排入`,value:e=>e.plannedIn??e.due,dir:`asc`}],groups:FF(p),defaultSort:`order`,defaultGroup:`priority`},()=>Q.issues.filter(e=>!e.archivedAt&&e.status!==`closed`)),h=$C(bz,`group`),g=M(m.spec.groups.some(e=>e.key===h)?h:`group`);function _(e){g.value=e,ew(bz,e)}let v=J(()=>m.spec.groups.find(e=>e.key===g.value)?.label),y=e=>mN(e.priority)!==`P2`||g.value!==`category`&&!!e.category||!!e.labels?.length,b=J(()=>a.value.length),x=J(()=>Pw().length);return(e,n)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`總覽`,description:`現在要注意什麼、進行中的主脈絡與會話怎麼串在一起、還有哪些待辦。`})]),default:P(()=>[U(`div`,JR,[l.value.length?(B(),V(`section`,YR,[U(`h2`,XR,[U(`button`,{type:`button`,class:`flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2 text-left hover:bg-accent/50`,"aria-expanded":d.value,"aria-controls":`attention-list`,onClick:f},[d.value?(B(),H(N(Ju),{key:0,class:`size-4 shrink-0 text-muted-foreground`})):(B(),H(N(Xu),{key:1,class:`size-4 shrink-0 text-muted-foreground`})),n[1]||=G(` 需要注意 `,-1),U(`span`,QR,j(l.value.length),1),d.value?K(``,!0):(B(),V(`span`,$R,[(B(!0),V(z,null,L(u.value,e=>(B(),V(`span`,{key:e.kind,class:`flex shrink-0 items-center gap-1`},[(B(),H(fa(e.icon),{class:k([`size-3.5`,e.tone])},null,8,[`class`])),G(j(e.label)+` `,1),U(`span`,ez,j(e.n),1)]))),128))]))],8,ZR)]),yr(U(`ul`,tz,[(B(!0),V(z,null,L(l.value,e=>(B(),V(`li`,{key:e.ref+e.reason,class:`flex h-9 cursor-pointer items-center gap-2 border-b px-3 transition-colors duration-[120ms] last:border-b-0 hover:bg-muted/50`,"data-peek":e.ref,"aria-current":r(e.ref),onClick:n=>N(t)(e.ref)},[W(nT,{type:e.type,status:e.status},null,8,[`type`,`status`]),U(`span`,rz,j(e.id),1),U(`span`,iz,j(e.title),1),U(`span`,{class:`ml-auto flex min-w-0 shrink items-center gap-1 text-xs text-muted-foreground`,title:e.reason},[(B(),H(fa(c[e.kind].icon),{class:k([`size-3.5 shrink-0`,c[e.kind].tone])},null,8,[`class`])),U(`span`,oz,j(e.reason),1)],8,az),e.context?(B(),V(`span`,sz,j(e.context),1)):K(``,!0)],8,nz))),128))],512),[[Vc,d.value]])])):K(``,!0),U(`section`,cz,[U(`h2`,lz,[n[2]||=G(` 進行中 `,-1),U(`span`,uz,j(b.value)+` 條主脈絡 · `+j(x.value)+` 個會話`,1),W(N(Wj),{"open-delay":150,"close-delay":100},{default:P(()=>[W(N(Kj),{"as-child":``},{default:P(()=>[U(`button`,dz,[W(N(td),{class:`size-3.5`})])]),_:1}),W(N(Gj),{class:`w-72 text-xs`},{default:P(()=>[G(j(xz))]),_:1})]),_:1})]),W(qR)]),U(`section`,fz,[U(`h2`,pz,[n[3]||=G(`待辦事項 `,-1),U(`span`,mz,j(N(m).total.value),1)]),W(uD,{view:N(m)},{views:P(()=>[W(N(lC),null,{default:P(()=>[W(N(SC),{"as-child":``},{default:P(()=>[W(N(sC),{variant:`outline`,size:`sm`,"aria-label":`橫軸:${v.value}`},{default:P(()=>[W(N(od)),G(j(v.value),1)]),_:1},8,[`aria-label`])]),_:1}),W(N(fC),{align:`end`,class:`w-40`},{default:P(()=>[W(N(mC),{class:`text-xs text-muted-foreground`},{default:P(()=>[...n[4]||=[G(`橫軸`,-1)]]),_:1}),W(N(hC),{"model-value":g.value,"onUpdate:modelValue":n[0]||=e=>_(String(e))},{default:P(()=>[(B(!0),V(z,null,L(N(m).spec.groups,e=>(B(),H(N(_C),{key:e.key,value:e.key},{default:P(()=>[G(j(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1},8,[`model-value`])]),_:1})]),_:1})]),_:1},8,[`view`]),W(nL,{view:N(m),axis:g.value},{card:P(({item:e})=>[W(N(mI),{class:k([`min-w-0 cursor-pointer gap-1 px-3 py-2 shadow-xs transition-colors duration-[120ms] hover:bg-accent/50`,{"bg-muted":r(e.id)}]),"data-peek":e.id,"aria-current":r(e.id),onClick:n=>N(t)(e.id)},{default:P(()=>[U(`div`,hz,[W(nT,{type:`issue`,status:e.status},null,8,[`status`]),U(`span`,gz,j(e.id),1),U(`span`,{class:`truncate`,title:e.title},j(e.title),9,_z)]),y(e)?(B(),V(`div`,vz,[W(TE,{priority:e.priority,class:`shrink-0`},null,8,[`priority`]),g.value!==`category`&&e.category?(B(),H(N(nE),{key:0,variant:`outline`},{default:P(()=>[G(j(e.category),1)]),_:2},1024)):K(``,!0),(B(!0),V(z,null,L(e.labels??[],e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))])):K(``,!0)]),_:2},1032,[`class`,`data-peek`,`aria-current`,`onClick`])]),empty:P(()=>[...n[5]||=[G(`沒有未處理或已排入的待辦。`,-1)]]),_:1},8,[`view`,`axis`])])])]),_:1}))}}),Cz=[`title`],wz={key:1,class:`shrink-0 text-xs text-muted-foreground`},Tz=I({__name:`SessionList`,setup(e){let t=[`active`,`paused`,`handed-off`,`ended`],n=e=>e.actions.find(e=>e.status===`doing`)??e.actions.find(e=>e.status===`todo`),r=e=>[...new Set(e.actions.flatMap(e=>e.serves.map(e=>e.slice(0,4))))],i=e=>e?`${e} ${Q.summary?.mainlines.find(t=>t.id===e)?.title??``}`.trim():`沒有服務的主脈絡`,a=e=>Math.max(...[e.started,...e.actions.flatMap(e=>[e.startedAt,e.doneAt])].filter(e=>!!e).map(cE)),o=e=>Q.sessions.filter(t=>t.delegatedFrom===e).sort((e,t)=>cE(e.started)-cE(t.started)),s=(e,t=1)=>o(e.id).flatMap(e=>[{item:e,depth:t},...s(e,t+1)]),c=J(()=>{let e=new Set(Q.sessions.map(e=>e.id));return Q.sessions.filter(t=>!t.delegatedFrom||!e.has(t.delegatedFrom))}),l=DN({key:`sessions`,id:e=>e.id,text:e=>`${jw(e)} ${e.branch??``}`,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(t)},{key:`agent`,label:`agent`,values:e=>[e.agent]},{key:`branch`,label:`分支`,values:e=>e.branch?[e.branch]:[]},{key:`mainline`,label:`主脈絡`,values:r,optionLabel:i}],sorts:[{key:`name`,label:`名稱`,value:e=>jw(e),dir:`asc`},{key:`serves`,label:`服務的任務`,value:e=>p(e),dir:`asc`},{key:`subagents`,label:`子代理數`,value:e=>o(e.id).length,dir:`desc`},{key:`started`,label:`開始時間`,value:e=>cE(e.started),dir:`desc`},{key:`active`,label:`最後活動`,value:a,dir:`desc`}],groups:[yN(t),{key:`mainline`,label:`主脈絡`,value:e=>r(e)[0]??``,groupLabel:i},{key:`day`,label:`日期`,value:e=>uE(e.started),latestFirst:!0}],defaultSort:`started`,defaultGroup:`status`,ended:e=>gN(e.status),archived:e=>!!e.archivedAt,nested:e=>s(e)},()=>c.value),u=TF(l,{kind:`session`,archived:e=>!!e.archivedAt}),d=[{key:`name`,label:`會話`,sort:`name`},{key:`serves`,label:`服務的任務`,class:`max-w-56`,sort:`serves`,value:e=>p(e),optional:!0},{key:`subagents`,label:`子代理`,class:`text-xs text-muted-foreground tabular-nums`,sort:`subagents`,value:e=>o(e.id).length||void 0,optional:!0},{key:`started`,label:`開始`,class:`text-xs text-muted-foreground`,sort:`started`}],{open:f}=FC();Er(()=>Rw(Q.sessions.flatMap(e=>e.actions.flatMap(e=>e.serves))));let p=e=>(n(e)??e.actions[0])?.serves[0]?.split(`#`)[0],m=e=>dw(()=>XC.archiveSession(e.id,!e.archivedAt));return(e,t)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`會話`,description:`推進過 hub 的 AI 會話,含同步程式從其他環境帶來的會話。存在資料目錄的 local/sessions/。`}),W(uD,{view:N(l)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(l),selection:N(u),columns:d,"item-ref":e=>N(TC)(e.id)},{name:P(({item:e,depth:t})=>[W(yD,{status:e.status,title:N(jw)(e),muted:t>0||!!e.archivedAt,depth:t},{default:P(()=>[e.elsewhere?(B(),V(`span`,{key:0,class:`shrink-0 text-xs text-muted-foreground`,title:`工作目錄 ${e.cwd} 不在這台電腦上`,"data-elsewhere":``},`其他環境`,8,Cz)):K(``,!0),e.archivedAt?(B(),V(`span`,wz,`已封存`)):K(``,!0)]),_:2},1032,[`status`,`title`,`muted`,`depth`])]),serves:P(({item:e})=>[p(e)?(B(),H($j,q({key:0},N(Iw)(p(e)),{onOpen:N(f)}),null,16,[`onOpen`])):K(``,!0)]),subagents:P(({item:e,depth:t})=>[G(j(t===0&&o(e.id).length?o(e.id).length:``),1)]),started:P(({item:e})=>[W(TP,{at:e.started},null,8,[`at`])]),actions:P(({item:e})=>[W(iE,{archived:!!e.archivedAt,onToggle:t=>m(e)},null,8,[`archived`,`onToggle`])]),empty:P(()=>[...t[0]||=[G(`沒有會話資料。會話存在資料目錄的 `,-1),U(`code`,null,`local/sessions/`,-1),G(`;有同步時,其他環境的會話也會出現在這裡。`,-1)]]),_:1},8,[`view`,`selection`,`item-ref`]),W(gD,{selection:N(u)},null,8,[`selection`])]),_:1}))}}),Ez={class:`flex items-center gap-2 px-6 pb-2`,"data-notice-controls":``},Dz={class:`flex min-w-0 items-center gap-2`},Oz={key:0,class:`size-1.5 shrink-0 rounded-full bg-warning`,title:`新提醒`},kz=[`title`],Az=[`title`],jz={key:0,class:`text-xs text-muted-foreground`,title:`存檔已刪,或檔案已是同步確認的版本`},Mz={key:1,class:`text-xs text-muted-foreground`},Nz=[`title`],Pz=I({__name:`SyncNotices`,setup(e){let t=vw,n={key:`sync`,id:t,text:e=>`${zC(e)} ${e.path} ${e.message}`,filters:[{key:`kind`,label:`種類`,values:e=>[e.kind],options:Object.entries(IC).map(([e,t])=>({value:e,label:t}))},{key:`path`,label:`檔案`,values:e=>e.path?[e.path]:[]}],sorts:[{key:`at`,label:`時間`,value:e=>e.at,dir:`desc`},{key:`kind`,label:`種類`,value:e=>e.kind,dir:`asc`},{key:`path`,label:`檔案`,value:e=>e.path,dir:`asc`}],groups:[{key:`day`,label:`日期`,value:e=>e.at.slice(0,10),latestFirst:!0}],defaultSort:`at`,defaultGroup:`day`},r=M(!1),i=J(()=>hw().length),a=DN(n,()=>r.value?Q.sync.notices:hw()),o=[{key:`message`,label:`提醒`},{key:`kind`,label:`種類`,class:`text-xs`},{key:`path`,label:`檔案`,class:`max-w-72 truncate font-mono text-xs text-muted-foreground`,value:e=>e.path,optional:!0},{key:`at`,label:`時間`,class:`font-mono text-xs text-muted-foreground tabular-nums`},{key:`handled`,label:`處理`}],s=e=>new Date(e).toLocaleString(`sv-SE`).slice(5);return $i(async()=>{await xw(),bw()}),(e,n)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`同步提醒`,description:`同步程式找到的、寫入者的內容可能沒有照原樣進入 hub 的改動。被拒的內容存在 .mainflow/local/sync/conflicts/,點開可以和 hub 的版本並排比對。`}),W(uD,{view:N(a)},null,8,[`view`]),U(`div`,Ez,[W(N(sC),{variant:`outline`,size:`xs`,"data-show-all":``,"aria-pressed":r.value,onClick:n[0]||=e=>r.value=!r.value},{default:P(()=>[G(j(r.value?`只看未處理`:`看全部`),1)]),_:1},8,[`aria-pressed`]),W(N(sC),{variant:`outline`,size:`xs`,"data-mark-all":``,disabled:i.value===0,onClick:n[1]||=e=>N(yw)()},{default:P(()=>[G(`全部標為已處理(`+j(i.value)+`)`,1)]),_:1},8,[`disabled`])])]),default:P(()=>[W(eD,{view:N(a),columns:o,"item-ref":e=>e.saved?N(DC)(e.saved):void 0},{message:P(({item:e})=>[U(`span`,Dz,[N(mw)(e)?K(``,!0):(B(),V(`span`,Oz)),e.saved?(B(),H(N(pd),{key:1,class:`size-3.5 shrink-0 text-muted-foreground`,"aria-label":`有存檔,可並排比對`})):K(``,!0),U(`span`,{class:`truncate`,title:`原文:${e.message}`},j(N(zC)(e,!1)),9,kz)])]),kind:P(({item:e})=>[G(j(N(IC)[e.kind]??e.kind),1)]),path:P(({item:e})=>[U(`span`,{title:e.path},j(e.path),9,Az)]),handled:P(({item:e})=>[e.handled===`auto`?(B(),V(`span`,jz,`已自動處理`)):e.handled?(B(),V(`span`,Mz,`已處理`)):(B(),H(N(sC),{key:2,variant:`ghost`,size:`xs`,"data-mark-one":``,onClick:au(n=>N(yw)(N(t)(e)),[`stop`])},{default:P(()=>[...n[2]||=[G(`標為已處理`,-1)]]),_:1},8,[`onClick`]))]),at:P(({item:e})=>[U(`span`,{title:e.at},j(s(e.at)),9,Nz)]),empty:P(()=>[!r.value&&N(Q).sync.notices.length>0?(B(),V(z,{key:0},[G(`沒有未處理的提醒。切換「看全部」可看已處理的。`)],64)):N(Q).sync.remote?(B(),V(z,{key:1},[G(`沒有提醒。同步程式只在寫入者的內容可能遺失時提醒,只多了別人改動的合併不列在這裡。`)],64)):(B(),V(z,{key:2},[n[3]||=G(`這個 hub 沒有設定同步伺服器。設定方式見 mainflow 的 `,-1),n[4]||=U(`code`,null,`docs/sync.md`,-1),n[5]||=G(`。`,-1)],64))]),_:1},8,[`view`,`item-ref`])]),_:1}))}}),Fz=e=>Array.isArray(e)?e.join(`/`):e??``,Iz=Rm({history:om(WC),routes:[{path:`/`,component:Sz},{path:`/mainlines`,component:HI},{path:`/mainlines/:m`,component:BI},{path:`/issues`,component:LF},{path:`/findings`,component:OF},{path:`/ops`,component:KI},{path:`/sessions`,component:Tz},{path:`/sync`,component:Pz},{path:`/mainlines/:m/tasks/:t`,redirect:e=>({path:`/mainlines/${Fz(e.params.m)}`,query:{view:`tasks`,peek:CC(Fz(e.params.m),Fz(e.params.t))}})},{path:`/mainlines/:m/decisions/:d`,redirect:e=>({path:`/mainlines/${Fz(e.params.m)}`,query:{view:`decisions`,peek:wC(Fz(e.params.m),Fz(e.params.d))}})},{path:`/mainlines/:m/files/:path(.*)`,redirect:e=>({path:`/mainlines/${Fz(e.params.m)}`,query:{peek:EC(Fz(e.params.m),Fz(e.params.path))}})},{path:`/sessions/:s`,redirect:e=>({path:`/sessions`,query:{peek:TC(Fz(e.params.s))}})}]}),Lz=hu(tE);Lz.config.errorHandler=Cw,Lz.use(Iz).mount(`#app`);
82
+ `)},j(e.affects?.join(`、`)),9,aI)]),reversible:P(({item:e})=>[G(j(e.reversible===void 0?``:e.reversible?`可以`:`不易改回`),1)]),empty:P(()=>[n[0]||=G(`還沒有決策。用 `,-1),U(`code`,null,`mainflow new decision `+j(e.mainline.id)+` <slug> --title <title>`,1),n[1]||=G(` 記下選擇與理由。`,-1)]),_:1},8,[`view`,`item-ref`])],64))}}),sI={class:`flex min-w-0 items-center gap-2`},cI=[`href`,`title`],lI=[`title`],uI={key:0,class:`whitespace-nowrap`},dI=[`title`],fI=`-`,pI=I({__name:`FilesView`,props:{mainline:{}},setup(e){let t=e,n=J(()=>DM(t.mainline)),r=e=>{let n=t.mainline.tasks.find(t=>t.id===e)??t.mainline.decisions.find(t=>t.id===e);return n?`${e} ${n.title}`:e===fI||!e?`主脈絡本身`:e},i=DN({key:`files`,id:e=>e.key,text:e=>`${e.name} ${e.path??``}`,filters:[{key:`kind`,label:`類型`,values:e=>[e.kind],options:wM.map(e=>({value:e,label:e}))},{key:`source`,label:`來源`,values:e=>[e.source??fI],optionLabel:r},{key:`ext`,label:`副檔名`,values:e=>e.ext?[e.ext]:[],optionLabel:e=>`.${e}`}],sorts:[{key:`kind`,label:`類型`,value:e=>wM.indexOf(e.kind),dir:`asc`},{key:`name`,label:`檔名`,value:e=>e.name,dir:`asc`},{key:`updated`,label:`更新`,value:e=>e.updated,dir:`desc`},{key:`source`,label:`來源`,value:e=>e.source,dir:`asc`}],groups:[{key:`kind`,label:`類型`,value:e=>e.kind,order:wM},{key:`source`,label:`來源`,value:e=>e.source??fI,groupLabel:r}],defaultSort:`kind`,defaultGroup:`kind`},()=>n.value),a=[{key:`name`,label:`檔名`,sort:`name`},{key:`kind`,label:`類型`,class:`text-xs text-muted-foreground`,sort:`kind`},{key:`source`,label:`來源`,class:`max-w-64 truncate text-xs text-muted-foreground`,sort:`source`,value:e=>e.source,optional:!0},{key:`updated`,label:`更新`,class:`text-xs text-muted-foreground`,sort:`updated`,value:e=>e.updated}],o=e=>e.inMainline?EC(t.mainline.id,e.inMainline):void 0;return(e,t)=>(B(),V(z,null,[W(uD,{view:N(i)},null,8,[`view`]),W(eD,{view:N(i),columns:a,"item-ref":o},{name:P(({item:e})=>[U(`span`,sI,[W(nT,{type:N(Uw)(e.url??e.key,e.kind)},null,8,[`type`]),e.url?(B(),V(`a`,{key:0,href:e.url,target:`_blank`,rel:`noreferrer`,class:`truncate underline decoration-border underline-offset-4 hover:decoration-foreground`,title:e.url,onClick:t[0]||=au(()=>{},[`stop`])},j(e.name),9,cI)):(B(),V(`span`,{key:1,class:k([`truncate`,{"font-mono text-xs":e.inMainline}]),title:e.inMainline??e.path},j(e.name),11,lI)),e.remoteOnly?(B(),H(N(ad),{key:2,class:`size-3.5 shrink-0 text-muted-foreground`,"aria-label":`只在伺服器上`,title:`只在同步伺服器上,點開時下載`})):K(``,!0),e.path?(B(),H(DD,{key:3,text:e.path,class:`min-w-0`},null,8,[`text`])):K(``,!0)])]),kind:P(({item:e})=>[G(j(e.kind),1),e.remoteOnly?(B(),V(`span`,uI,`・只在伺服器上`)):K(``,!0)]),source:P(({item:e})=>[U(`span`,{title:r(e.source??``)},j(e.source?r(e.source):``),9,dI)]),updated:P(({item:e})=>[e.updated?(B(),H(TP,{key:0,at:e.updated},null,8,[`at`])):K(``,!0)]),empty:P(()=>[...t[1]||=[G(`這條主脈絡還沒有檔案。`,-1)]]),_:1},8,[`view`])],64))}}),mI=I({__name:`Card`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),V(`div`,{"data-slot":`card`,class:k(N(gg)(`bg-card text-card-foreground flex flex-col gap-4 rounded-xl border py-4 shadow-sm`,t.class))},[R(e.$slots,`default`)],2))}}),hI={class:`inline-flex gap-1.5 font-mono text-xs`},gI=[`title`],_I=I({__name:`DepList`,props:{deps:{},within:{}},setup(e){let t=e,n=e=>t.within&&e.startsWith(`${t.within}/`)?e.slice(t.within.length+1):e;return(t,r)=>(B(),V(`span`,hI,[(B(!0),V(z,null,L(e.deps,e=>(B(),V(`span`,{key:e.to,class:k(N(eT)[e.state].tone),title:`${e.to} ${N(eT)[e.state].label}`},j(n(e.to)),11,gI))),128))]))}}),vI={class:`flex items-center rounded-md border p-0.5`,role:`group`,"aria-label":`任務排列`},yI={key:0,class:`flex min-h-0 gap-3 overflow-x-auto px-6 pt-2 pb-6`},bI=[`aria-label`],xI={class:`flex items-center gap-2 py-1`},SI={class:`text-xs text-muted-foreground tabular-nums`},CI={class:`flex items-center gap-2 text-xs`},wI={class:`font-mono text-muted-foreground`},TI={class:`line-clamp-2 [overflow-wrap:anywhere]`},EI={class:`flex items-center justify-between gap-2`},DI={key:0,class:`min-w-0 truncate text-xs text-muted-foreground`},OI={key:0,class:`py-2 text-xs text-muted-foreground`},kI=[`title`],AI=`mainflow.list.tasks.mode`,jI=I({__name:`TaskViews`,props:{mainline:{}},setup(e){let t=e,n=[{key:`table`,label:`表格`,icon:Jd},{key:`board`,label:`看板`,icon:od},{key:`tree`,label:`樹狀`,icon:Ld}],r=$C(AI,`table`),i=M(n.some(e=>e.key===r)?r:`table`);function a(e){i.value=e,ew(AI,e)}let o=()=>t.mainline.tasks,s=J(()=>new Map(t.mainline.tasks.map(e=>[e.id,e])));function c(e){let t=e;for(;t?.kind===`branch`&&t.parent;)t=s.value.get(t.parent);return t?.id??e.id}let l=e=>e.checklist.filter(e=>e.done).length,u={id:e=>e.id,text:e=>`${e.title} ${e.branch??``}`,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(Gw)},{key:`priority`,label:`優先度`,values:e=>[mN(e.priority)],options:pN},{key:`repo`,label:`倉庫`,values:e=>e.repo?[e.repo]:[]},{key:`kind`,label:`種類`,values:e=>[e.kind],options:[{value:`phase`,label:`階段`},{value:`branch`,label:`分支`}]},{key:`label`,label:`標籤`,values:e=>e.labels??[]}]},d=DN({...u,key:`tasks`,sorts:[{key:`order`,label:`手動順序`,value:e=>e.order??Number(e.id.slice(1)),dir:`asc`},{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`repo`,label:`倉庫`,value:e=>e.repo,dir:`asc`},{key:`depends`,label:`依賴`,value:e=>b(e)[0]?.to,dir:`asc`},{key:`branch`,label:`分支`,value:e=>e.branch,dir:`asc`},{key:`status`,label:`狀態`,value:e=>Gw.indexOf(e.status),dir:`asc`},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),dir:`asc`},{key:`progress`,label:`checklist 進度`,value:e=>e.checklist.length?l(e)/e.checklist.length:null,dir:`desc`}],groups:[{key:`phase`,label:`階段`,value:c,groupLabel:e=>s.value.get(e)?.title??e,status:e=>s.value.get(e)?.status,leader:e=>s.value.get(e)},yN(Gw),{key:`repo`,label:`倉庫`,value:e=>e.repo??`沒有指定倉庫`}],defaultSort:`order`,defaultGroup:`status`,ended:e=>gN(e.status)},o),f=e=>t.mainline.tasks.filter(t=>t.parent===e).sort((e,t)=>(e.order??1/0)-(t.order??1/0)||e.id.localeCompare(t.id)),p=(e,t=1)=>f(e.id).flatMap(e=>[{item:e,depth:t},...p(e,t+1)]),m=DN({...u,key:`tasks`,sorts:[{key:`order`,label:`手動順序`,value:e=>e.order??Number(e.id.slice(1)),dir:`asc`}],groups:[],defaultSort:`order`,defaultGroup:``,nested:e=>p(e)},()=>t.mainline.tasks.filter(e=>!e.parent||!s.value.has(e.parent))),h=J(()=>Gw.map(e=>({status:e,tasks:d.sorted.value.filter(t=>t.status===e)}))),g=[{key:`name`,label:`名稱`,sort:`name`},{key:`priority`,label:`優先度`,sort:`priority`},{key:`progress`,label:`checklist`,sort:`progress`,value:e=>e.checklist.length},{key:`repo`,label:`倉庫`,class:`text-xs text-muted-foreground`,sort:`repo`,value:e=>e.repo},{key:`depends`,label:`依賴`,sort:`depends`,value:e=>b(e),optional:!0},{key:`branch`,label:`分支`,class:`max-w-56 truncate font-mono text-xs text-muted-foreground`,sort:`branch`,value:e=>e.branch,optional:!0}],{open:_,current:v}=FC(),y=e=>CC(t.mainline.id,e.id);function b(e){return Q.relations.deps.filter(t=>t.from===y(e))}return(t,r)=>(B(),V(z,null,[W(uD,{view:i.value===`tree`?N(m):N(d),grouping:i.value===`table`},{views:P(()=>[U(`div`,vI,[(B(),V(z,null,L(n,e=>W(N(sC),{key:e.key,variant:i.value===e.key?`secondary`:`ghost`,size:`xs`,"aria-pressed":i.value===e.key,onClick:t=>a(e.key)},{default:P(()=>[(B(),H(fa(e.icon))),G(j(e.label),1)]),_:2},1032,[`variant`,`aria-pressed`,`onClick`])),64))])]),_:1},8,[`view`,`grouping`]),i.value===`board`?(B(),V(`div`,yI,[(B(!0),V(z,null,L(h.value,e=>(B(),V(`section`,{key:e.status,class:`flex w-64 shrink-0 flex-col gap-2`,"aria-label":N(Yw)[e.status]},[U(`div`,xI,[W(kE,{status:e.status},null,8,[`status`]),U(`span`,SI,j(e.tasks.length),1)]),(B(!0),V(z,null,L(e.tasks,e=>(B(),H(N(mI),{key:e.id,class:k([`min-w-0 cursor-pointer gap-2 p-3 shadow-xs transition-colors duration-[120ms] hover:bg-accent/50`,{"bg-muted":N(v)?.ref===y(e)}]),"data-peek":y(e),"aria-current":N(v)?.ref===y(e)||void 0,onClick:t=>N(_)(y(e))},{default:P(()=>[U(`div`,CI,[W(nT,{type:N(Bw)(e),status:e.status},null,8,[`type`,`status`]),U(`span`,wI,j(e.id),1),W(TE,{priority:e.priority},null,8,[`priority`])]),U(`p`,TI,j(e.title),1),U(`div`,EI,[W(nP,{done:l(e),total:e.checklist.length},null,8,[`done`,`total`]),e.repo?(B(),V(`span`,DI,j(e.repo),1)):K(``,!0)])]),_:2},1032,[`class`,`data-peek`,`aria-current`,`onClick`]))),128)),e.tasks.length===0?(B(),V(`p`,OI,`沒有任務`)):K(``,!0)],8,bI))),128))])):(B(),H(eD,{key:1,view:i.value===`tree`?N(m):N(d),columns:g,"item-ref":y,"item-type":N(Bw)},{name:P(({item:e,depth:t})=>[W(yD,{status:e.status,id:e.id,title:e.title,depth:t,type:N(Bw)(e)},null,8,[`status`,`id`,`title`,`depth`,`type`])]),priority:P(({item:e})=>[W(TE,{priority:e.priority},null,8,[`priority`])]),progress:P(({item:e})=>[W(nP,{done:l(e),total:e.checklist.length},null,8,[`done`,`total`])]),repo:P(({item:e})=>[G(j(e.repo),1)]),depends:P(({item:t})=>[W(_I,{deps:b(t),within:e.mainline.id},null,8,[`deps`,`within`])]),branch:P(({item:e})=>[U(`span`,{title:e.branch},j(e.branch),9,kI)]),empty:P(()=>[r[0]||=G(`還沒有任務。執行 `,-1),U(`code`,null,`mainflow new task `+j(e.mainline.id)+` <slug> --title <title>`,1),r[1]||=G(` 建立。`,-1)]),_:1},8,[`view`,`item-type`]))],64))}}),MI={class:`px-6 pt-6 pb-3`},NI={class:`mt-1 text-title font-semibold`},PI={class:`mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground`},FI={key:0},II={key:0,class:`text-xs text-muted-foreground tabular-nums`},LI={key:0,class:`max-w-5xl px-1 pt-2 pb-10`},RI={key:1,class:`px-6 py-16 text-center text-muted-foreground`},zI=`mainflow.mainlineView`,BI=I({__name:`MainlineDetail`,setup(e){let t=tp(),n=ep(),{id:r,mainline:i}=eM(),a=[{key:`overview`,label:`概覽`},{key:`tasks`,label:`任務`},{key:`criteria`,label:`條件`},{key:`decisions`,label:`決策`},{key:`files`,label:`資料`}],o=J(()=>a.find(e=>e.key===t.query.view)?.key??`overview`),s=e=>{let t=i.value;if(t)return{overview:void 0,tasks:t.tasks.length,criteria:t.criteria.length,decisions:t.decisions.length,files:DM(t).length}[e]},c=e=>n.replace({query:{view:String(e)}});F(()=>[r.value,t.query.view,t.query.tab],([e,r,i])=>{if(!e||typeof i==`string`)return;let a=$C(zI,{});typeof r==`string`?ew(zI,{...a,[e]:r}):a[e]&&a[e]!==`overview`&&n.replace({query:{...t.query,view:a[e]}})},{immediate:!0}),Er(()=>{let e=t.query.tab;if(typeof e!=`string`)return;let{tab:r,...i}=t.query,a={...i,view:e===`views`?`files`:e};n.replace({query:a})});let l=e=>i.value&&dw(()=>XC.mainlineStatus(r.value,e,i.value.version)),u=e=>i.value&&dw(()=>XC.mainlineTitle(r.value,e,i.value.version)),d=()=>i.value&&dw(()=>XC.archive(r.value,!i.value.archivedAt,i.value.version));return(e,t)=>N(i)?(B(),H(wF,{key:0},{header:P(()=>[U(`header`,MI,[W(DD,{text:N(i).id},null,8,[`text`]),U(`h1`,NI,[W(OD,{value:N(i).title,onSave:u},null,8,[`value`])]),U(`div`,PI,[W(bP,{status:N(i).status,options:N(Ww),onChange:l},null,8,[`status`,`options`]),W(TE,{priority:N(i).priority},null,8,[`priority`]),N(i).archivedAt?(B(),V(`span`,FI,`已封存 `+j(N(i).archivedAt),1)):K(``,!0),W(iE,{class:`ml-auto`,archived:!!N(i).archivedAt,onToggle:d},null,8,[`archived`])])]),W(N(RF),{"model-value":o.value,"onUpdate:modelValue":c},{default:P(()=>[W(N(zF),{variant:`line`,class:`h-9 w-full justify-start border-b px-6`},{default:P(()=>[(B(),V(z,null,L(a,e=>W(N(BF),{key:e.key,value:e.key,class:`flex-none px-2`},{default:P(()=>[G(j(e.label),1),s(e.key)===void 0?K(``,!0):(B(),V(`span`,II,j(s(e.key)),1))]),_:2},1032,[`value`])),64))]),_:1})]),_:1},8,[`model-value`])]),default:P(()=>[o.value===`overview`?(B(),V(`div`,LI,[W(gP,{mainline:N(i),columns:2},null,8,[`mainline`])])):o.value===`tasks`?(B(),H(jI,{key:1,mainline:N(i)},null,8,[`mainline`])):o.value===`criteria`?(B(),H(rI,{key:2,mainline:N(i)},null,8,[`mainline`])):o.value===`decisions`?(B(),H(oI,{key:3,mainline:N(i)},null,8,[`mainline`])):(B(),H(pI,{key:4,mainline:N(i)},null,8,[`mainline`]))]),_:1})):(B(),V(`p`,RI,`載入 `+j(N(r))+`…`,1))}}),VI={key:0,class:`shrink-0 text-xs text-muted-foreground`},HI=I({__name:`MainlineList`,setup(e){let t={key:`mainlines`,id:e=>e.id,text:e=>e.title,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(Ww)},{key:`priority`,label:`優先度`,values:e=>[mN(e.priority)],options:pN},{key:`category`,label:`分類`,values:e=>e.category?[e.category]:[]},{key:`label`,label:`標籤`,values:e=>e.labels},PN(e=>e.group)],sorts:[{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`criteria`,label:`解決條件`,value:e=>e.criteria.total?e.criteria.done/e.criteria.total:null,dir:`desc`},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),dir:`asc`},{key:`updated`,label:`更新`,value:e=>e.updated,dir:`desc`},{key:`created`,label:`建立`,value:e=>e.created,dir:`desc`},{key:`due`,label:`到期`,value:e=>e.due,dir:`asc`}],groups:[yN(Ww),{key:`priority`,label:`優先度`,value:e=>mN(e.priority),order:[`P0`,`P1`,`P2`,`P3`]},{key:`category`,label:`分類`,value:e=>e.category??`未分類`},NN(e=>e.group)],defaultSort:`updated`,defaultGroup:`status`,ended:e=>gN(e.status),archived:e=>!!e.archivedAt},n=e=>Q.relations.mainlineDeps.filter(t=>t.from===e.id),r=DN(t,()=>Q.summary?.mainlines??[]),i=TF(r,{kind:`mainline`,archived:e=>!!e.archivedAt}),a=[{key:`name`,label:`名稱`,sort:`name`},{key:`priority`,label:`優先度`,sort:`priority`},{key:`criteria`,label:`解決條件`,sort:`criteria`,value:e=>e.criteria.total},{key:`deps`,label:`依賴`,value:n,optional:!0},{key:`due`,label:`到期`,sort:`due`,value:e=>e.due},{key:`updated`,label:`更新`,class:`text-xs text-muted-foreground`,sort:`updated`,optional:!0}],o=e=>dw(()=>XC.archive(e.id,!e.archivedAt));return(e,t)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`主脈絡`,description:`一條主脈絡是一件要做完的事:意圖、解決條件,以及推進它的任務與決策。`}),W(uD,{view:N(r)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(r),selection:N(i),columns:a,"item-ref":e=>e.id},{name:P(({item:e})=>[W(yD,{status:e.status,id:e.id,title:e.title,muted:!!e.archivedAt},{default:P(()=>[(B(!0),V(z,null,L(e.labels,e=>(B(),H(N(nE),{key:e,variant:`secondary`,class:`shrink-0`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128)),e.archivedAt?(B(),V(`span`,VI,`已封存`)):K(``,!0)]),_:2},1032,[`status`,`id`,`title`,`muted`])]),priority:P(({item:e})=>[W(TE,{priority:e.priority},null,8,[`priority`])]),criteria:P(({item:e})=>[W(nP,{done:e.criteria.done,total:e.criteria.total},null,8,[`done`,`total`])]),deps:P(({item:e})=>[W(_I,{deps:n(e)},null,8,[`deps`])]),due:P(({item:e})=>[W(_E,{day:e.due,ended:N(gN)(e.status)},null,8,[`day`,`ended`])]),updated:P(({item:e})=>[W(TP,{at:e.updated},null,8,[`at`])]),actions:P(({item:e})=>[W(N(sC),{variant:`ghost`,size:`xs`,class:`text-muted-foreground`,"as-child":``},{default:P(()=>[W(N(Am),{to:`/mainlines/${e.id}`,onClick:t[0]||=au(()=>{},[`stop`])},{default:P(()=>[W(N(ef)),t[1]||=G(`開啟`,-1)]),_:1},8,[`to`])]),_:2},1024),W(iE,{archived:!!e.archivedAt,onToggle:t=>o(e)},null,8,[`archived`,`onToggle`])]),empty:P(()=>[...t[2]||=[G(`沒有主脈絡。在 hub 內執行 `,-1),U(`code`,null,`mainflow new mainline <slug> --title <title>`,-1),G(` 建立第一個。`,-1)]]),_:1},8,[`view`,`selection`,`item-ref`]),W(gD,{selection:N(i)},null,8,[`selection`])]),_:1}))}}),UI=[`title`],WI=[`title`],GI=[`title`],KI=I({__name:`OpsLog`,setup(e){let t=e=>!/fail|error|denied|reject|abort|失敗|錯誤|拒絕|中止/i.test(e.result),n=e=>e.ref?.match(/^m\d{3}/)?.[0]??``,r=DN({key:`ops`,id:e=>`${e.at}|${e.target}|${e.operation}`,text:e=>`${e.operation} ${e.target} ${e.ref??``}`,filters:[{key:`result`,label:`結果`,values:e=>[t(e)?`success`:`failed`],options:[{value:`success`,label:`成功`},{value:`failed`,label:`沒有成功`}]},{key:`target`,label:`目標系統`,values:e=>[e.target]},{key:`mainline`,label:`主脈絡`,values:e=>[n(e)].filter(Boolean),optionLabel:e=>`${e} ${Q.summary?.mainlines.find(t=>t.id===e)?.title??``}`.trim()}],sorts:[{key:`at`,label:`時間`,value:e=>cE(e.at),dir:`desc`},{key:`operation`,label:`操作`,value:e=>e.operation,dir:`asc`},{key:`target`,label:`目標系統`,value:e=>e.target,dir:`asc`},{key:`result`,label:`結果`,value:e=>+!!t(e),dir:`asc`},{key:`ref`,label:`關聯`,value:e=>e.ref,dir:`asc`}],groups:[{key:`month`,label:`月份`,value:e=>uE(e.at).slice(0,7),latestFirst:!0},{key:`day`,label:`日期`,value:e=>uE(e.at),latestFirst:!0}],defaultSort:`at`,defaultGroup:`month`},()=>Q.ops),i=[{key:`operation`,label:`操作`,sort:`operation`},{key:`target`,label:`目標系統`,class:`max-w-64 truncate font-mono text-xs text-muted-foreground`,sort:`target`,optional:!0},{key:`result`,label:`結果`,class:`max-w-40 truncate text-xs`,sort:`result`},{key:`ref`,label:`關聯`,class:`max-w-56`,sort:`ref`,value:e=>e.ref,optional:!0},{key:`at`,label:`時間`,class:`font-mono text-xs text-muted-foreground tabular-nums`,sort:`at`}],{open:a}=FC();return Er(()=>Rw(Q.ops.map(e=>e.ref))),(e,n)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`操作紀錄`,description:`對外部系統執行過的操作,只追加不改寫。`}),W(uD,{view:N(r)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(r),columns:i},{operation:P(({item:e})=>[U(`span`,{class:`block truncate`,title:e.operation},j(e.operation),9,UI)]),target:P(({item:e})=>[U(`span`,{title:e.target},j(e.target),9,WI)]),result:P(({item:e})=>[U(`span`,{class:k(t(e)?`text-muted-foreground`:`text-foreground`),title:e.result},[t(e)?K(``,!0):(B(),H(N(Qu),{key:0,class:`mr-1 inline size-3.5 align-[-2px] text-destructive`})),G(j(e.result),1)],10,GI)]),ref:P(({item:e})=>[e.ref?(B(),H($j,q({key:0},N(Iw)(e.ref),{onOpen:N(a)}),null,16,[`onOpen`])):K(``,!0)]),at:P(({item:e})=>[G(j(N(fE)(e.at).slice(5)),1)]),empty:P(()=>[...n[0]||=[G(`還沒有紀錄。用 `,-1),U(`code`,null,`mainflow ops add --target <系統> --op <操作> --result <結果>`,-1),G(` 記錄 push、發布、合併這類對外操作。`,-1)]]),_:1},8,[`view`])]),_:1}))}}),qI={key:0,class:`overflow-x-auto px-6 pb-2`},JI=[`aria-colcount`],YI=[`title`],XI={class:`text-xs text-muted-foreground tabular-nums`},ZI={key:0,class:`col-span-full flex min-w-0 items-center gap-2 pt-4 pb-2 text-sm`,role:`rowheader`},QI=[`aria-label`,`aria-expanded`,`onClick`],$I={key:1,class:`truncate font-medium`},eL={class:`text-xs text-muted-foreground tabular-nums`},tL={key:1,class:`px-6 py-16 text-center text-sm text-muted-foreground`},nL=I({__name:`BoardView`,props:{view:{},axis:{}},setup(e){let t=e,n=J(()=>t.view.spec.groups.find(e=>e.key===t.axis)??t.view.spec.groups[0]),r=J(()=>xN(n.value,t.view.sorted.value)),i=J(()=>t.view.group.value!==``),a=(e,t)=>e.filter(e=>bN(n.value,e).includes(t)),o=e=>[...e.items,...e.ended];return(t,n)=>e.view.groups.value.length?(B(),V(`div`,qI,[U(`div`,{class:`grid gap-x-3`,style:he({gridTemplateColumns:`repeat(${r.value.length}, minmax(20rem, 1fr))`}),role:`table`,"aria-colcount":r.value.length},[(B(!0),V(z,null,L(r.value,e=>(B(),V(`div`,{key:e.key,class:`flex min-w-0 items-center gap-2 border-b py-2`,role:`columnheader`},[e.status?(B(),H(kE,{key:0,status:e.status},null,8,[`status`])):(B(),V(`span`,{key:1,class:`truncate text-sm font-medium`,title:e.label},j(e.label),9,YI)),U(`span`,XI,j(e.items.length),1)]))),128)),(B(!0),V(z,null,L(e.view.groups.value,n=>(B(),V(z,{key:n.key},[i.value?(B(),V(`div`,ZI,[U(`button`,{type:`button`,class:`-ml-1 grid size-5 shrink-0 place-items-center rounded-sm hover:bg-accent`,"aria-label":e.view.collapsed.has(n.key)?`展開分組`:`收合分組`,"aria-expanded":!e.view.collapsed.has(n.key),onClick:t=>e.view.toggleCollapsed(n.key)},[e.view.collapsed.has(n.key)?(B(),H(N(Xu),{key:1,class:`size-4 text-muted-foreground`})):(B(),H(N(Ju),{key:0,class:`size-4 text-muted-foreground`}))],8,QI),n.status?(B(),H(kE,{key:0,status:n.status},null,8,[`status`])):(B(),V(`span`,$I,j(n.label),1)),U(`span`,eL,j(o(n).length),1)])):K(``,!0),!e.view.collapsed.has(n.key)||!i.value?(B(!0),V(z,{key:1},L(r.value,r=>(B(),V(`div`,{key:r.key,class:`flex min-w-0 flex-col gap-2 py-2`,role:`cell`},[(B(!0),V(z,null,L(a(o(n),r.key),n=>R(t.$slots,`card`,{item:n},void 0,void 0,e.view.spec.id(n))),128))]))),128)):K(``,!0)],64))),128))],12,JI)])):(B(),V(`div`,tL,[e.view.total.value>0?(B(),V(z,{key:0},[n[1]||=G(` 沒有符合條件的項目。`,-1),W(N(sC),{variant:`link`,size:`xs`,class:`px-0`,onClick:e.view.clearAll},{default:P(()=>[...n[0]||=[G(`清除篩選與搜尋`,-1)]]),_:1},8,[`onClick`])],64)):R(t.$slots,`empty`,{},void 0,void 0,1)]))}}),rL=.01,iL=e=>Math.min(2,Math.max(rL,e));function aL(e,t,n,r){let i=iL(t),a=(n-e.x)/e.zoom,o=(r-e.y)/e.zoom;return{zoom:i,x:n-a*i,y:r-o*i}}function oL(e,t,n=.9){if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{x:0,y:0,zoom:1};let r=iL(Math.min(1,t.width*n/e.width,t.height*n/e.height));return{zoom:r,x:(t.width-e.width*r)/2,y:(t.height-e.height*r)/2}}function sL(e){if(e.deltaMode!==0)return!0;let t=e.wheelDeltaY;return typeof t==`number`&&t!==0&&t%120==0&&e.deltaX===0}var cL=.5;function lL(e){return[{point:{x:e.x+e.width/2,y:e.y},axis:`y`,normal:{x:0,y:-1}},{point:{x:e.x+e.width/2,y:e.y+e.height},axis:`y`,normal:{x:0,y:1}},{point:{x:e.x,y:e.y+e.height/2},axis:`x`,normal:{x:-1,y:0}},{point:{x:e.x+e.width,y:e.y+e.height/2},axis:`x`,normal:{x:1,y:0}}]}var uL=e=>({x:e.y,y:e.x}),dL=e=>({x:e.y,y:e.x,width:e.height,height:e.width});function fL(e,t,n){return Math.min(t.x,n.x)<e.x+e.width&&Math.max(t.x,n.x)>e.x&&Math.min(t.y,n.y)<e.y+e.height&&Math.max(t.y,n.y)>e.y}var pL=(e,t)=>e.slice(1).every((n,r)=>!t.some(t=>fL(t,e[r],n))),mL=(e,t)=>e.slice(1).reduce((n,r,i)=>n+t.filter(t=>fL(t,e[i],r)).length,0);function hL(e){let t=0;for(let n=1;n<e.length-1;n++){let r=e[n-1],i=e[n],a=e[n+1];Math.abs(r.x-i.x)<cL&&Math.abs(i.x-a.x)<cL||Math.abs(r.y-i.y)<cL&&Math.abs(i.y-a.y)<cL||t++}return t}var gL=e=>e.slice(1).reduce((t,n,r)=>t+Math.abs(n.x-e[r].x)+Math.abs(n.y-e[r].y),0);function _L(e,t){let n=e=>e.slice(1).map((t,n)=>[e[n],t]),r=0;for(let i of n(e)){let e=Math.abs(i[0].x-i[1].x)<cL;for(let a of t)for(let t of n(a)){if(Math.abs(t[0].x-t[1].x)<cL===e)continue;let n=e?i:t,a=e?t:i,o=Math.min(n[0].y,n[1].y),s=Math.max(n[0].y,n[1].y),c=Math.min(a[0].x,a[1].x),l=Math.max(a[0].x,a[1].x);n[0].x>c&&n[0].x<l&&a[0].y>o&&a[0].y<s&&r++}}return r}function vL(e,t,n){if(e.length<2)return!1;let[r,i]=[e[0],e[1]],[a,o]=[e[e.length-1],e[e.length-2]];return(i.x-r.x)*t.normal.x+(i.y-r.y)*t.normal.y>cL&&(o.x-a.x)*n.normal.x+(o.y-a.y)*n.normal.y>cL}function yL(e){let t=[];for(let n of e){let e=t[t.length-1];if(!(e&&Math.abs(n.x-e.x)<cL&&Math.abs(n.y-e.y)<cL)){if(t.length>=2){let r=t[t.length-2];(Math.abs(r.x-e.x)<cL&&Math.abs(e.x-n.x)<cL||Math.abs(r.y-e.y)<cL&&Math.abs(e.y-n.y)<cL)&&t.pop()}t.push(n)}}return t}function bL(e,t,n){let r=yL(e),i=(e,t)=>Math.abs(e.x-t.x)<cL;if(r.length>=2){let e=r[r.length-1],t=r[r.length-2];i(t,e)!==(n.axis===`y`)&&r.splice(r.length-1,0,n.axis===`y`?{x:e.x,y:t.y}:{x:t.x,y:e.y})}if(r.length>=2){let e=r[0],n=r[1];i(e,n)!==(t.axis===`y`)&&r.splice(1,0,t.axis===`y`?{x:e.x,y:n.y}:{x:n.x,y:e.y})}return yL(r)}function xL(e,t,n){let r=(e.x+t.x)/2,i=[e,{x:r,y:e.y},{x:r,y:t.y},t];if(Math.abs(e.y-t.y)<cL&&pL([e,t],n))return[e,t];for(let i of[r,e.x+18,t.x-18]){let r=[e,{x:i,y:e.y},{x:i,y:t.y},t];if(pL(r,n))return r}let a=n.flatMap(e=>[e.y-18,e.y+e.height+18]).sort((t,n)=>Math.abs(t-e.y)-Math.abs(n-e.y));for(let r of a){let i=[e,{x:e.x+18,y:e.y},{x:e.x+18,y:r},{x:t.x-18,y:r},{x:t.x-18,y:t.y},t];if(pL(i,n))return i}return i}function SL(e,t,n,r){return r===`x`?xL(e,t,n):xL(uL(e),uL(t),n.map(dL)).map(uL)}function CL(e,t,n){let r=[];if(e.axis===t.axis){let n=e.axis===`y`;Math.abs(n?e.point.x-t.point.x:e.point.y-t.point.y)<cL&&r.push([e.point,t.point]);let i=n?[(e.point.y+t.point.y)/2,e.point.y+e.normal.y*18]:[(e.point.x+t.point.x)/2,e.point.x+e.normal.x*18];for(let a of i)r.push(n?[e.point,{x:e.point.x,y:a},{x:t.point.x,y:a},t.point]:[e.point,{x:a,y:e.point.y},{x:a,y:t.point.y},t.point])}else r.push(e.axis===`y`?[e.point,{x:e.point.x,y:t.point.y},t.point]:[e.point,{x:t.point.x,y:e.point.y},t.point]);let i=r.map(n=>bL(n,e,t)).filter(e=>pL(e,n));return i.length?i:[bL(SL(e.point,t.point,n,e.axis),e,t)]}function wL(e,t,n,r=[]){let i;for(let a of lL(e))for(let e of lL(t))for(let t of CL(a,e,n)){let o=[mL(t,n),+!vL(t,a,e),_L(t,r),hL(t),gL(t)];(!i||TL(o,i.score))&&(i={path:t,score:o})}return i?.path??[lL(e)[3].point,lL(t)[2].point]}function TL(e,t){for(let[n,r]of e.entries())if(r!==t[n])return r<t[n];return!1}function EL(e){return e.length<=2?e:e.filter((t,n)=>{if(n===0||n===e.length-1)return!0;let r=e[n-1],i=e[n+1];return!(r.x===t.x&&t.x===i.x||r.y===t.y&&t.y===i.y)})}var DL=e=>String(Math.round(e*100)/100);function OL(e,t=8){let n=EL(e);if(n.length<2)return``;let r=`M${DL(n[0].x)},${DL(n[0].y)}`,i=n[0];for(let e=1;e<n.length-1;e++){let a=n[e],o=n[e+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y),l=Math.min(t,s/2,c/2),u={x:a.x-(a.x-i.x)/(s||1)*l,y:a.y-(a.y-i.y)/(s||1)*l},d={x:a.x+(o.x-a.x)/(c||1)*l,y:a.y+(o.y-a.y)/(c||1)*l};r+=` L${DL(u.x)},${DL(u.y)} Q${DL(a.x)},${DL(a.y)} ${DL(d.x)},${DL(d.y)}`,i=d}let a=n[n.length-1];return`${r} L${DL(a.x)},${DL(a.y)}`}function kL(e,t){if(e.length<2)return e;let n=e[e.length-1],r=e[e.length-2],i=Math.hypot(n.x-r.x,n.y-r.y);return i<=t*2?e:[...e.slice(0,-1),{x:n.x-(n.x-r.x)/i*t,y:n.y-(n.y-r.y)/i*t}]}var AL={width:260,height:72};function jL(e,t){let n=new Set(e),r=t.filter(e=>e.from!==e.to&&n.has(e.from)&&n.has(e.to)),i=new Set(r.flatMap(e=>[e.from,e.to])),a=new Map;for(let e of r)a.set(e.from,[...a.get(e.from)??[],e.to]);let o=new Map,s=new Set;function c(e){let t=o.get(e);if(t!==void 0)return t;if(s.has(e))return 0;s.add(e);let n=Math.max(0,...(a.get(e)??[]).map(e=>c(e)+1));return s.delete(e),o.set(e,n),n}let l=[];for(let t of e){if(!i.has(t))continue;let e=c(t);for(;l.length<=e;)l.push([]);l[e].push(t)}let u=e.filter(e=>!i.has(e));if(u.length){let e=Math.ceil(u.length/7),t=Math.ceil(u.length/e);for(let n=0;n<e;n++)l.push(u.slice(n*t,(n+1)*t))}return l.filter(e=>e.length>0)}function ML(e,t,n){let r=e.id!==void 0,i=r?12:0,a=r?26:0,o=[],s=i,c=0,l=jL(e.ids,t);for(let[e,t]of l.entries()){let r=Math.max(...t.map(e=>n(e).width)),u=i+a;for(let e of t){let t=n(e);o.push([e,{x:s,y:u,width:t.width,height:t.height}]),u+=t.height+16}c=Math.max(c,u-16-i-a),s+=r+(e<l.length-1?48:0)}return{id:e.id,framed:r,width:s+i,height:c+2*i+a,cards:o}}function NL(e,t,n,r={}){let i=r.wrapWidth??1600,a=e=>t.get(e)??AL,o={groups:[],cards:new Map,width:0,height:0},s=0,c=0,l=0;for(let t of e){if(!t.ids.length)continue;let e=ML(t,n,a);s>0&&s+e.width>i&&(s=0,c+=l+28,l=0),o.groups.push({id:e.id,framed:e.framed,x:s,y:c,width:e.width,height:e.height});for(let[t,n]of e.cards)o.cards.set(t,{...n,x:n.x+s,y:n.y+c});l=Math.max(l,e.height),o.width=Math.max(o.width,s+e.width),s+=e.width+28}return o.height=c+l,o}var PL=[`data-node`,`aria-pressed`,`title`],FL={class:`flex min-w-0 items-center gap-2`},IL={class:`truncate`},LL={class:`shrink-0 font-mono text-xs text-muted-foreground`},RL=[`title`],zL={class:`h-1 w-12 overflow-hidden rounded-full bg-muted`},BL={class:`flex min-w-0 items-center gap-2`},VL=[`title`],HL=I({__name:`MainlineNode`,props:{id:{},picked:{type:Boolean}},emits:[`pick`],setup(e){let t=e,n=J(()=>Q.summary?.mainlines.find(e=>e.id===t.id)),r=J(()=>n.value?.title??Iw(t.id).title??``),i=J(()=>n.value?.status??Iw(t.id).status),a=J(()=>n.value?.items),o=J(()=>gN(i.value??``)),s=J(()=>OC(t.id)),c=J(()=>{let e=Q.mainlines[t.id]?.tasks;return e?vN(e):void 0}),l=J(()=>a.value?.total?Math.round(100*a.value.done/a.value.total):0);return(t,n)=>(B(),V(`button`,{type:`button`,class:k([`relative z-[1] flex w-full min-w-0 flex-col gap-1.5 rounded-xl border px-3 py-2.5 text-left transition-[background-color,border-color] duration-[120ms] focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none`,[s.value?`border-dashed border-muted-foreground/60 bg-background hover:bg-[color-mix(in_oklab,var(--accent)_50%,var(--background))]`:`bg-card shadow-xs hover:bg-[color-mix(in_oklab,var(--accent)_50%,var(--card))]`,{"border-ring":e.picked}]]),"data-node":e.id,"aria-pressed":e.picked,title:s.value?`${e.id}:在新分頁開啟另一個 hub`:void 0,onClick:n[0]||=n=>t.$emit(`pick`,e.id,n)},[U(`span`,FL,[W(nT,{type:`mainline`,status:i.value},null,8,[`status`]),s.value?(B(),H(N(nE),{key:0,variant:`outline`,class:`min-w-0 shrink font-mono text-[11px] text-muted-foreground`},{default:P(()=>[U(`span`,IL,j(s.value.hub),1)]),_:1})):K(``,!0),U(`span`,LL,j(s.value?.local??e.id),1),s.value?(B(),H(N(zu),{key:1,class:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})):K(``,!0),a.value?(B(),V(`span`,{key:2,class:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,title:`checklist ${a.value.done}/${a.value.total}`},[U(`span`,zL,[U(`span`,{class:`block h-full bg-foreground`,style:he({width:`${l.value}%`})},null,4)]),G(` `+j(a.value.done)+`/`+j(a.value.total),1)],8,RL)):K(``,!0)]),U(`span`,BL,[U(`span`,{class:k([`truncate font-medium`,{"text-muted-foreground":o.value}])},j(r.value),3),!o.value&&c.value?(B(),V(`span`,{key:0,class:k([`ml-auto inline-flex shrink-0 items-center gap-1 text-xs tabular-nums`,{"text-muted-foreground":!c.value.doing}]),title:`進行中 ${c.value.doing}/未完成 ${c.value.open} 個任務`},[W(nT,{type:`phase`,status:c.value.doing?`doing`:void 0},null,8,[`status`]),G(j(c.value.doing)+`/`+j(c.value.open),1)],10,VL)):K(``,!0)])],10,PL))}}),UL=[`data-serves`,`data-session`,`aria-pressed`],WL={"data-session-icon":``,class:`relative row-span-2 grid size-6 place-items-center rounded-md bg-muted text-foreground`},GL={class:`flex min-w-0 items-baseline gap-1`},KL={class:`truncate font-medium`},qL=[`title`],JL=[`title`],YL={class:`truncate leading-4 text-muted-foreground`},XL=I({__name:`SessionNode`,props:{session:{},serves:{},picked:{type:Boolean}},emits:[`pick`],setup(e){let t=e,n=J(()=>t.session.actions.find(e=>e.status===`doing`)??t.session.actions.find(e=>e.status===`todo`)),r=J(()=>vN(t.session.actions)),i=zw.session.icon;return(t,a)=>(B(),V(`button`,{type:`button`,class:k([`relative z-[1] grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-2 rounded-md border py-1 pr-2 pl-1 text-left text-xs transition-colors duration-[120ms] hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none`,e.picked?`border-ring`:`border-transparent`]),"data-serves":e.serves,"data-session":e.session.id,"aria-pressed":e.picked,onClick:a[0]||=e=>t.$emit(`pick`,e)},[U(`span`,WL,[(B(),H(fa(N(i)),{class:`size-3.5`})),U(`span`,{class:k([`absolute -right-0.5 -bottom-0.5 size-2 rounded-full border-[1.5px] border-background`,n.value?`bg-status-done`:`bg-status-todo`])},null,2)]),U(`span`,GL,[U(`span`,KL,j(N(jw)(e.session)),1),e.session.elsewhere?(B(),V(`span`,{key:0,class:`shrink-0 text-muted-foreground`,title:`其他環境:工作目錄 ${e.session.cwd} 不在這台電腦上`,"data-elsewhere":``},`其他環境`,8,qL)):K(``,!0),r.value.open?(B(),V(`span`,{key:1,class:k([`shrink-0 tabular-nums`,{"text-muted-foreground":!r.value.doing}]),title:`進行中 ${r.value.doing}/未處理 ${r.value.open} 個行動`},`(`+j(r.value.doing)+`/`+j(r.value.open)+`)`,11,JL)):K(``,!0)]),U(`span`,YL,j(n.value?.do??`沒有待做的行動`),1)],10,UL))}}),ZL={class:`rounded-xl border bg-card text-body shadow-xs`},QL={class:`flex h-10 items-center gap-2 px-4`},$L={class:`font-mono text-xs text-muted-foreground`},eR={class:`flex flex-col gap-4 px-4 pb-4`},tR={class:`text-base font-semibold [overflow-wrap:anywhere]`},nR={class:`grid grid-cols-[72px_1fr] items-center gap-x-3 gap-y-1.5 text-xs`},rR={class:`flex flex-col gap-0.5`},iR=[`onClick`],aR={class:`shrink-0 font-mono text-muted-foreground`},oR={class:`truncate`},sR={class:`ml-auto shrink-0 text-muted-foreground`},cR={key:0,class:`px-1.5 text-xs text-muted-foreground`},lR={class:`flex flex-col gap-0.5`},uR={key:0,class:`px-1.5 text-xs text-muted-foreground`},dR={class:`flex h-10 items-center gap-2 px-4`},fR={class:`flex flex-col gap-4 px-4 pb-4`},pR={class:`text-base font-semibold [overflow-wrap:anywhere]`},mR={class:`grid grid-cols-[72px_1fr] items-center gap-x-3 gap-y-1.5 text-xs`},hR={class:`flex flex-col gap-0.5`},gR={class:`flex flex-col gap-0.5`},_R={class:`shrink-0 font-mono text-muted-foreground`},vR={class:`truncate`},yR={key:1,class:`px-1.5 text-xs text-muted-foreground`},bR={key:2,class:`px-4 py-6 text-sm text-muted-foreground`},xR=I({__name:`RunningPreview`,props:{picked:{}},emits:[`pickMainline`,`pickSession`],setup(e,{emit:t}){let n=e,r=t,{open:i}=FC(),a=[`doing`,`blocked`,`todo`],o=Aw,s=J(()=>{if(n.picked?.kind!==`mainline`)return;let e=n.picked.id,t=Q.summary?.mainlines.find(t=>t.id===e),r=(Q.mainlines[e]?.tasks??[]).filter(e=>a.includes(e.status)).sort((e,t)=>a.indexOf(e.status)-a.indexOf(t.status)||(e.order??0)-(t.order??0));return{id:e,loaded:!!Q.mainlines[e],title:t?.title??Iw(e).title??e,status:t?.status,criteria:t?.criteria,items:t?.items,tasks:r,sessions:Nw().filter(t=>Mw(t)===e)}}),c=J(()=>n.picked?.kind===`session`?Q.sessions.find(e=>e.id===n.picked.id):void 0),l=e=>{let t=e=>Q.sessions.filter(t=>t.delegatedFrom===e).flatMap(e=>[e,...t(e.id)]),n=t(e.id);return n.length?`${n.filter(e=>e.status===`active`).length} 個進行中,共 ${n.length} 個`:`沒有`};return(e,t)=>(B(),V(`div`,ZL,[s.value?(B(),V(z,{key:0},[U(`div`,QL,[W(nT,{type:`mainline`,status:s.value.status},null,8,[`status`]),U(`span`,$L,j(s.value.id),1),t[2]||=U(`span`,{class:`text-xs text-muted-foreground`},`主脈絡`,-1)]),U(`div`,eR,[U(`h3`,tR,j(s.value.title),1),U(`dl`,nR,[t[5]||=U(`dt`,{class:`text-muted-foreground`},`狀態`,-1),U(`dd`,null,[s.value.status?(B(),H(kE,{key:0,status:s.value.status},null,8,[`status`])):K(``,!0)]),s.value.criteria?(B(),V(z,{key:0},[t[3]||=U(`dt`,{class:`text-muted-foreground`},`解決條件`,-1),U(`dd`,null,[W(nP,{done:s.value.criteria.done,total:s.value.criteria.total},null,8,[`done`,`total`])])],64)):K(``,!0),s.value.items?(B(),V(z,{key:1},[t[4]||=U(`dt`,{class:`text-muted-foreground`},`checklist`,-1),U(`dd`,null,[W(nP,{done:s.value.items.done,total:s.value.items.total},null,8,[`done`,`total`])])],64)):K(``,!0)]),U(`section`,rR,[t[6]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`未完成的任務`,-1),(B(!0),V(z,null,L(s.value.tasks,e=>(B(),V(`button`,{key:e.id,type:`button`,class:`flex h-7 min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-xs hover:bg-accent`,onClick:t=>N(i)(N(CC)(s.value.id,e.id))},[W(nT,{type:N(Bw)(e),status:e.status},null,8,[`type`,`status`]),U(`span`,aR,j(e.id),1),U(`span`,oR,j(e.title),1),U(`span`,sR,j(N(Yw)[e.status]),1)],8,iR))),128)),s.value.tasks.length?K(``,!0):(B(),V(`p`,cR,j(s.value.loaded?`沒有`:`載入中…`),1))]),U(`section`,lR,[t[7]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`會話`,-1),(B(!0),V(z,null,L(s.value.sessions,e=>(B(),H(XL,{key:e.id,session:e,onPick:t=>r(`pickSession`,e.id)},null,8,[`session`,`onPick`]))),128)),s.value.sessions.length?K(``,!0):(B(),V(`p`,uR,`沒有`))]),U(`div`,null,[W(N(sC),{variant:`outline`,size:`sm`,"as-child":``},{default:P(()=>[W(N(Am),{to:`/mainlines/${s.value.id}`},{default:P(()=>[...t[8]||=[G(`開啟主脈絡`,-1)]]),_:1},8,[`to`])]),_:1})])])],64)):c.value?(B(),V(z,{key:1},[U(`div`,dR,[W(nT,{type:`session`,status:c.value.status},null,8,[`status`]),t[9]||=U(`span`,{class:`text-xs text-muted-foreground`},`會話`,-1)]),U(`div`,fR,[U(`h3`,pR,j(N(jw)(c.value)),1),U(`dl`,mR,[t[10]||=U(`dt`,{class:`text-muted-foreground`},`狀態`,-1),U(`dd`,null,[W(kE,{status:c.value.status},null,8,[`status`])]),t[11]||=U(`dt`,{class:`text-muted-foreground`},`子代理`,-1),U(`dd`,null,j(l(c.value)),1)]),U(`section`,hR,[t[12]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`目前行動`,-1),U(`p`,{class:k([`text-xs [overflow-wrap:anywhere]`,{"text-muted-foreground":!N(o)(c.value)}])},j(N(o)(c.value)?.do??`沒有待做的行動`),3)]),U(`section`,gR,[t[13]||=U(`h4`,{class:`mb-0.5 text-xs font-medium text-muted-foreground`},`服務的主脈絡`,-1),N(Mw)(c.value)?(B(),V(`button`,{key:0,type:`button`,class:`flex h-7 min-w-0 items-center gap-2 rounded-md px-1.5 text-left text-xs hover:bg-accent`,onClick:t[0]||=e=>r(`pickMainline`,N(Mw)(c.value))},[W(nT,{type:`mainline`,status:N(Iw)(N(Mw)(c.value)).status},null,8,[`status`]),U(`span`,_R,j(N(Mw)(c.value)),1),U(`span`,vR,j(N(Iw)(N(Mw)(c.value)).title),1)])):(B(),V(`p`,yR,`沒有`))]),U(`div`,null,[W(N(sC),{variant:`outline`,size:`sm`,onClick:t[1]||=e=>N(i)(N(TC)(c.value.id))},{default:P(()=>[...t[14]||=[G(`開啟會話`,-1)]]),_:1})])])],64)):(B(),V(`p`,bR,`點關係圖裡的主脈絡或會話看詳情。`))]))}}),SR=[`width`,`height`],CR=[`id`],wR=[`fill`],TR=[`d`,`stroke`,`stroke-dasharray`,`marker-end`],ER=[`onClick`],DR={class:`shrink-0 font-mono`},OR={class:`truncate`},kR=[`data-card`],AR={key:0,class:`flex flex-col gap-1.5 px-[9px]`},jR={class:`flex flex-wrap gap-x-6 gap-y-1`},MR={key:2,class:`absolute bottom-3 left-1/2 z-20 -translate-x-1/2 cursor-auto`,role:`toolbar`,"aria-label":`批次操作`,"data-canvas-overlay":``},NR={class:`flex items-center gap-1 rounded-lg border bg-popover py-1 pr-1 pl-3 text-sm shadow-md`},PR={class:`mr-2 tabular-nums`},FR={class:`text-muted-foreground tabular-nums`},IR={class:`absolute right-3 bottom-3 z-20 flex cursor-auto items-center rounded-full border bg-popover p-0.5 text-xs shadow-sm`,role:`toolbar`,"aria-label":`縮放`,"data-canvas-overlay":``},LR={key:1,class:`text-sm text-muted-foreground`},RR=1,zR=260,BR=4,VR=4,HR=`mainflow.overview.canvasHeight`,UR=240,WR=`mainflow.overview.previewWidth`,GR=260,KR=560,qR=I({__name:`RunningMap`,setup(e){let t=e=>`${e.kind}:${e.id}`,n=[`active`,`planning`,`paused`],r=e=>e&&!gN(e)?Math.max(0,n.indexOf(e)):n.length,i=(e,t)=>e.map((e,t)=>({item:e,i:t})).sort((e,n)=>r(t(e.item))-r(t(n.item))||e.i-n.i).map(e=>e.item),a=J(()=>(Q.summary?.mainlines??[]).filter(e=>!e.archivedAt)),o=e=>Iw(e).status,s=J(()=>a.value.map(e=>e.id)),c=J(()=>new Set((Q.summary?.mainlines??[]).filter(e=>e.archivedAt).map(e=>e.id))),l=J(()=>Q.relations.mainlineDeps.filter(e=>![e.from,e.to].some(e=>c.value.has(e)))),u=J(()=>new Map(Object.entries(Q.relations.groupMembers).flatMap(([e,t])=>t.filter(e=>e.kind===`mainline`&&!e.archived).map(t=>[t.ref,e])))),d=J(()=>i([...new Set([...s.value,...u.value.keys(),...l.value.flatMap(e=>[e.to,e.from])])],o)),f=J(()=>new Set(d.value)),p=e=>OC(e)?u.value.get(e):(Q.summary?.mainlines??[]).find(t=>t.id===e)?.group??void 0,m=J(()=>{let e=jN().map(e=>e.id),t=t=>t===void 0?1/0:e.includes(t)?e.indexOf(t):e.length,n=new Map;for(let e of d.value)n.set(p(e),[...n.get(p(e))??[],e]);return[...n].sort(([e],[n])=>t(e)-t(n)||(e??``).localeCompare(n??``)).map(([e,t])=>({id:e,ids:t}))}),h=M(new Map),g=J(()=>NL(m.value,h.value,l.value)),_=e=>g.value.cards.get(e),v=(e,t)=>{let n=_(e),r=t.framed?RR:0;return{left:`${n.x-t.x-r}px`,top:`${n.y-t.y-r}px`,width:`${zR}px`}},{open:y}=FC(),b=J(()=>i(Nw(),e=>e.status)),x=e=>b.value.filter(t=>Mw(t)===e),S=J(()=>b.value.filter(e=>!f.value.has(Mw(e)??``))),C=e=>e.kind===`mainline`?f.value.has(e.id):b.value.some(t=>t.id===e.id),w=Qt(new Map),T=J(()=>[...w.values()].filter(C)),ee=M(),E=J(()=>ee.value&&w.has(t(ee.value))&&C(ee.value)?ee.value:void 0),te=(e,n)=>w.has(t({kind:e,id:n})),ne=e=>!!e?.shiftKey;function re(){w.clear(),ee.value=void 0}function D(e,n){let r=t(e);if(ne(n)){w.has(r)?w.delete(r):w.set(r,e);return}w.clear(),w.set(r,e),ee.value=e}function ie(e,t){if(OC(e)){ne(t)||window.open(kC(e)??void 0,`_blank`,`noopener`);return}D({kind:`mainline`,id:e},t)}let ae=(e,t)=>D({kind:`session`,id:e},t);async function oe(){let e=new Map;for(let t of T.value)e.set(t.kind,[...e.get(t.kind)??[],t.id]);await dw(async()=>{let t=[];for(let[n,r]of e){let e=await XC.archiveMany(n,r,!0);t.push(...e.failed.map(e=>`${e.id}(${e.error})`))}if(t.length)throw Error(`${t.length} 個沒有封存:${t.join(`、`)}`)})&&re()}let se=M(),O=J(()=>{let e=se.value;return e&&{left:`${Math.min(e.x1,e.x2)}px`,top:`${Math.min(e.y1,e.y2)}px`,width:`${Math.abs(e.x2-e.x1)}px`,height:`${Math.abs(e.y2-e.y1)}px`}});function ce(e){let t=[],n=t=>{let n=t.getBoundingClientRect();return n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top};for(let e of ue.value?.querySelectorAll(`[data-node], [data-session]`)??[])n(e)&&(e.dataset.node?OC(e.dataset.node)||t.push({kind:`mainline`,id:e.dataset.node}):t.push({kind:`session`,id:e.dataset.session}));return t}let{current:le}=FC();Df(window,`keydown`,e=>{e.key!==`Escape`||le.value||Q.paletteOpen||!w.size||(E.value&&T.value.length>1?ee.value=void 0:re())},{capture:!0});let ue=M(),de=M([]),fe=M({width:0,height:0});function pe(e,t){let n=0,r=0;for(let i=e;i&&i!==t;i=i.offsetParent)n+=i.offsetLeft,r+=i.offsetTop;return{left:n,top:r,right:n+e.offsetWidth,bottom:r+e.offsetHeight,height:e.offsetHeight}}function me(){let e=ue.value;if(!e)return;let t=new Map,n=new Map;for(let n of e.querySelectorAll(`[data-card]`))t.set(n.dataset.card,n.offsetHeight);for(let t of e.querySelectorAll(`[data-node]`))n.set(t.dataset.node,t.offsetHeight);if([...t].some(([e,t])=>h.value.get(e)?.height!==t)){h.value=new Map([...t].map(([e,t])=>[e,{width:zR,height:t}]));return}let r=t=>{let n=e.querySelector(`[data-node="${CSS.escape(t)}"]`);return n?pe(n,e):void 0},i=e=>({x:e.x-6,y:e.y-6,width:e.width+12,height:e.height+12}),a=g.value.groups.filter(e=>e.framed).map(e=>({x:e.x,y:e.y,width:e.width,height:38})),o=[],s=[];for(let e of l.value){let t=_(e.to),r=_(e.from);if(!t||!r)continue;let c=(e,t)=>({x:t.x,y:t.y,width:t.width,height:n.get(e)??t.height}),l=c(e.to,t),u=c(e.from,r),d=[...a];for(let[t,n]of g.value.cards)if(t===e.to||t===e.from){let r=t===e.to?l:u;n.height>r.height&&d.push({x:n.x-6,y:r.y+r.height,width:n.width+12,height:n.height-r.height})}else d.push(i(n));let f=wL(l,u,d,s);s.push(f),o.push({key:`${e.to}>${e.from}`,d:OL(kL(f,2)),kind:e.state===`pending`?`pending`:`other`})}for(let t of e.querySelectorAll(`[data-serves]`)){let n=r(t.dataset.serves),i=t.querySelector(`[data-session-icon]`);if(!n||!i)continue;let a=pe(i,e);o.push({key:`s:${t.dataset.session}`,d:`M${n.left+12},${n.bottom} V${a.top+a.height/2} H${a.left}`,kind:`session`})}de.value=o,fe.value={width:e.offsetWidth,height:e.offsetHeight},Te||Ee()}Ff(ue,me),F([g,b,()=>Q.mainlines],()=>void tr(me),{deep:!0});let ge={pending:`var(--muted-foreground)`,other:`var(--status-off)`,session:`var(--status-off)`},_e={pending:void 0,other:`4 3`,session:`2 2`},ve=J(()=>Math.max(zR,g.value.width,Math.min(S.value.length,BR)*284-24)),ye=M(),A=M({x:0,y:0,zoom:1}),be=M({width:0,height:0});function xe(){let e=ye.value;e&&(be.value={width:e.clientWidth,height:e.clientHeight})}Ff(ye,()=>{xe(),Te||Ee()});let Se=M(!1),Ce;function we(e){Se.value=!0,A.value=e,clearTimeout(Ce),Ce=setTimeout(()=>Se.value=!1,320)}let Te=!1;function Ee(){xe(),fe.value.width&&fe.value.height&&be.value.width&&be.value.height&&(A.value=oL(fe.value,be.value),Te=!0)}let De=()=>(xe(),we(oL(fe.value,be.value))),Oe=e=>(xe(),we(aL(A.value,A.value.zoom*e,be.value.width/2,be.value.height/2))),ke=J(()=>`${Math.round(A.value.zoom*100)}%`),Ae=0;function je(e){let t=ye.value.getBoundingClientRect();if(e.ctrlKey||e.metaKey){e.preventDefault(),A.value=aL(A.value,iL(A.value.zoom*Math.exp(-e.deltaY*.01)),e.clientX-t.left,e.clientY-t.top);return}let n=performance.now()<Ae||!sL(e);if(e.preventDefault(),!n){Me(ye.value).scrollBy({top:Ne(e,e.deltaY),left:Ne(e,e.deltaX)});return}Ae=performance.now()+120,A.value={...A.value,x:A.value.x-e.deltaX,y:A.value.y-e.deltaY}}function Me(e){for(let t=e.parentElement;t;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return document.scrollingElement??document.documentElement}let Ne=(e,t)=>e.deltaMode===1?t*16:e.deltaMode===2?t*window.innerHeight:t;function Pe(e){let n=ye.value,r=n.getBoundingClientRect(),i=new Map(w),a=e.clientX-r.left,o=e.clientY-r.top;try{n.setPointerCapture(e.pointerId)}catch{}let s=e=>{let n=e.clientX-r.left,s=e.clientY-r.top;if(!se.value&&Math.hypot(n-a,s-o)<VR)return;se.value={x1:a,y1:o,x2:n,y2:s};let c=ce({left:r.left+Math.min(a,n),top:r.top+Math.min(o,s),right:r.left+Math.max(a,n),bottom:r.top+Math.max(o,s)});w.clear();for(let[e,t]of i)w.set(e,t);for(let e of c)w.set(t(e),e)},c=()=>{n.removeEventListener(`pointermove`,s),n.removeEventListener(`pointerup`,c),n.removeEventListener(`pointercancel`,c),se.value=void 0};n.addEventListener(`pointermove`,s),n.addEventListener(`pointerup`,c),n.addEventListener(`pointercancel`,c)}let Fe=M(!1);function Ie(e){if(e.button!==0||e.target.closest(`button, a, [data-canvas-overlay]`))return;if(e.shiftKey)return Pe(e);let t={x:e.clientX,y:e.clientY,vx:A.value.x,vy:A.value.y},n=!1,r=ye.value;try{r.setPointerCapture(e.pointerId)}catch{}let i=e=>{let r=e.clientX-t.x,i=e.clientY-t.y;!n&&Math.hypot(r,i)<VR||(n=!0,Fe.value=!0,A.value={...A.value,x:t.vx+r,y:t.vy+i})},a=()=>{r.removeEventListener(`pointermove`,i),r.removeEventListener(`pointerup`,a),r.removeEventListener(`pointercancel`,a),Fe.value=!1,n||re()};r.addEventListener(`pointermove`,i),r.addEventListener(`pointerup`,a),r.addEventListener(`pointercancel`,a)}let Le=e=>Math.round(Math.min(Math.max(UR,window.innerHeight),Math.max(UR,e))),Re=Number($C(HR,null)),ze=M(Re>0?Le(Re):null);function Be(e){let t=e.clientY,n=ye.value.offsetHeight,r=e=>ze.value=Le(n+e.clientY-t),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),ew(HR,ze.value)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}function Ve(){ze.value=null,ew(HR,null)}let He=e=>Math.min(KR,Math.max(GR,e)),Ue=M(He(Number($C(WR,340))||340)),We=J(()=>be.value.width?Math.min(Ue.value,be.value.width*.6):Ue.value);function Ge(e){let t=e.clientX,n=We.value,r=e=>Ue.value=He(n+t-e.clientX),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),ew(WR,Ue.value)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return(e,t)=>d.value.length||b.value.length?(B(),V(`div`,{key:0,ref_key:`viewport`,ref:ye,class:k([`relative w-full touch-none overflow-hidden rounded-xl border bg-background select-none`,[Fe.value?`cursor-grabbing`:`cursor-grab`,ze.value===null&&`h-[60vh]`]]),style:he(ze.value===null?void 0:{height:`${ze.value}px`}),"data-canvas":``,onPointerdown:Ie,onWheel:je},[U(`div`,{ref_key:`canvas`,ref:ue,class:k([`absolute top-0 left-0 flex origin-top-left flex-col gap-6`,{"transition-transform duration-300 ease-out":Se.value}]),style:he({width:`${ve.value}px`,transform:`translate(${A.value.x}px, ${A.value.y}px) scale(${A.value.zoom})`})},[(B(),V(`svg`,{class:`pointer-events-none absolute inset-0 overflow-visible`,width:fe.value.width,height:fe.value.height,"aria-hidden":`true`},[U(`defs`,null,[(B(),V(z,null,L([`pending`,`other`],e=>U(`marker`,{id:`run-arrow-${e}`,key:e,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto`},[U(`path`,{d:`M0,0 L8,4 L0,8 z`,fill:ge[e]},null,8,wR)],8,CR)),64))]),(B(!0),V(z,null,L(de.value,e=>(B(),V(`path`,{key:e.key,d:e.d,fill:`none`,"stroke-width":`1.5`,stroke:ge[e.kind],"stroke-dasharray":_e[e.kind],"marker-end":e.kind===`session`?void 0:`url(#run-arrow-${e.kind})`},null,8,TR))),128))],8,SR)),U(`div`,{class:`relative shrink-0`,style:he({width:`${g.value.width}px`,height:`${g.value.height}px`})},[(B(!0),V(z,null,L(g.value.groups,e=>(B(),H(fa(e.framed?`section`:`div`),{key:e.id??`ungrouped`,class:k([`absolute flex flex-col rounded-xl p-2`,e.framed?`border border-dashed`:`border-0`]),style:he({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`}),"data-map-group":e.id},{default:P(()=>[e.id?(B(),V(`button`,{key:0,type:`button`,class:`relative z-[1] flex max-w-full min-w-0 items-center gap-1.5 self-start rounded-sm bg-background px-1 text-left text-xs text-muted-foreground hover:bg-accent`,onClick:t=>N(y)(e.id)},[W(nT,{type:`group`,status:N(AN)(e.id)?.status},null,8,[`status`]),U(`span`,DR,j(e.id),1),U(`span`,OR,j(N(AN)(e.id)?.title),1),W(TE,{priority:N(AN)(e.id)?.priority,class:`shrink-0`},null,8,[`priority`])],8,ER)):K(``,!0),(B(!0),V(z,null,L(m.value.find(t=>t.id===e.id)?.ids??[],t=>(B(),V(`div`,{key:t,class:`absolute flex flex-col gap-1.5`,style:he(v(t,e)),"data-card":t},[W(HL,{id:t,picked:te(`mainline`,t),onPick:ie},null,8,[`id`,`picked`]),(B(!0),V(z,null,L(x(t),e=>(B(),H(XL,{key:e.id,session:e,serves:t,picked:te(`session`,e.id),class:`ml-5`,onPick:t=>ae(e.id,t)},null,8,[`session`,`serves`,`picked`,`onPick`]))),128))],12,kR))),128))]),_:2},1032,[`class`,`style`,`data-map-group`]))),128))],4),S.value.length?(B(),V(`div`,AR,[U(`div`,jR,[(B(!0),V(z,null,L(S.value,e=>(B(),H(XL,{key:e.id,session:e,picked:te(`session`,e.id),class:`max-w-full`,style:he({width:`${zR}px`}),onPick:t=>ae(e.id,t)},null,8,[`session`,`picked`,`style`,`onPick`]))),128))])])):K(``,!0)],6),E.value?(B(),V(`aside`,{key:0,class:`absolute top-3 right-3 z-20 flex max-h-[calc(100%-1.5rem)] cursor-auto flex-col overflow-y-auto overscroll-contain rounded-xl shadow-lg`,style:he({width:`${We.value}px`}),"aria-label":`預覽`,"data-canvas-overlay":``,onWheel:t[0]||=au(()=>{},[`stop`])},[U(`div`,{class:`absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`拖曳調整預覽寬度`,onPointerdown:au(Ge,[`prevent`,`stop`])},null,32),W(xR,{picked:E.value,onPickMainline:ie,onPickSession:ae},null,8,[`picked`])],36)):K(``,!0),se.value?(B(),V(`div`,{key:1,class:`pointer-events-none absolute z-20 rounded-sm border border-ring bg-ring/10`,style:he(O.value),"aria-hidden":`true`},null,4)):K(``,!0),T.value.length>=1?(B(),V(`div`,MR,[U(`div`,NR,[U(`span`,PR,`已選 `+j(T.value.length)+` 個`,1),W(N(sC),{variant:`ghost`,size:`sm`,onClick:oe},{default:P(()=>[W(N(Pu)),t[4]||=G(`封存`,-1),U(`span`,FR,j(T.value.length),1)]),_:1}),W(N(sC),{variant:`ghost`,size:`icon-sm`,"aria-label":`清除選取`,onClick:t[1]||=e=>re()},{default:P(()=>[W(N(uf))]),_:1})])])):K(``,!0),U(`div`,{class:`absolute inset-x-0 bottom-0 z-10 h-2 cursor-row-resize`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`拖曳調整畫布高度,雙擊回到預設高度`,"data-canvas-overlay":``,onPointerdown:au(Be,[`prevent`,`stop`]),onDblclick:Ve},null,32),U(`div`,IR,[W(N(sC),{variant:`ghost`,size:`icon-sm`,class:`rounded-full`,"aria-label":`縮小`,onClick:t[2]||=e=>Oe(1/N(1.2))},{default:P(()=>[W(N(Vd))]),_:1}),U(`button`,{type:`button`,class:`h-7 min-w-12 rounded-full px-1.5 tabular-nums hover:bg-accent`,title:`全部置入畫面`,"aria-label":`全部置入畫面`,onClick:De},j(ke.value),1),W(N(sC),{variant:`ghost`,size:`icon-sm`,class:`rounded-full`,"aria-label":`放大`,onClick:t[3]||=e=>Oe(N(1.2))},{default:P(()=>[W(N(Gd))]),_:1})])],38)):(B(),V(`p`,LR,[...t[5]||=[G(`沒有主脈絡。在 hub 內執行 `,-1),U(`code`,null,`mainflow new mainline <slug> --title <title>`,-1),G(` 建立。`,-1)]]))}}),JR={class:`flex flex-col gap-8 px-6 pt-2 pb-10`},YR={key:0,"aria-labelledby":`attention`,class:`-mb-4 rounded-lg border bg-card`},XR={id:`attention`,class:`text-sm font-medium`},ZR=[`aria-expanded`],QR={class:`text-xs text-muted-foreground tabular-nums`},$R={key:2,class:`ml-2 flex min-w-0 items-center gap-3 overflow-hidden text-xs font-normal text-muted-foreground`},ez={class:`tabular-nums`},tz={id:`attention-list`,class:`border-t`},nz=[`data-peek`,`aria-current`,`onClick`],rz={class:`shrink-0 font-mono text-xs text-muted-foreground`},iz={class:`min-w-0 truncate`},az=[`title`],oz={class:`truncate`},sz={key:0,class:`hidden max-w-48 shrink-0 truncate text-xs text-muted-foreground xl:inline`},cz={"aria-labelledby":`running`},lz={id:`running`,class:`mb-2 flex items-center gap-1.5 text-sm font-medium`},uz={class:`text-xs font-normal text-muted-foreground tabular-nums`},dz={type:`button`,class:`grid size-5 place-items-center rounded-sm text-muted-foreground hover:text-foreground`,"aria-label":`依賴線的說明`},fz={"aria-labelledby":`issues`,class:`-mx-6 min-w-0`},pz={id:`issues`,class:`px-6 text-sm font-medium`},mz={class:`ml-1 text-xs text-muted-foreground tabular-nums`},hz={class:`flex min-w-0 items-center gap-2`},gz={class:`shrink-0 font-mono text-xs text-muted-foreground`},_z=[`title`],vz={key:0,class:`flex min-w-0 items-center gap-1.5 overflow-hidden text-xs`},yz=`mainflow.overview.attentionOpen`,bz=`mainflow.list.overview.issues.axis`,xz=`箭頭由要先完成的主脈絡指向等待它的主脈絡;實線是還沒完成的依賴,虛線是已完成或無法確認的依賴。`,Sz=I({__name:`Overview`,setup(e){let{open:t,current:n}=FC(),r=e=>n.value?.ref===e||void 0,i=J(()=>(Q.summary?.mainlines??[]).filter(e=>!e.archivedAt)),a=J(()=>i.value.filter(e=>e.status===`active`||e.status===`planning`||e.status===`paused`)),o=J(()=>[...new Set([...a.value.map(e=>e.id),...Q.relations.mainlineDeps.flatMap(e=>[e.from,e.to]).filter(e=>/^m\d{3}$/.test(e))])]);Er(()=>void uw(o.value));let s=J(()=>a.value.flatMap(e=>Q.mainlines[e.id]?[Q.mainlines[e.id]]:[])),c={overdue:{label:`逾期`,icon:Wu,tone:`text-destructive`},blocked:{label:`卡住`,icon:ed,tone:`text-status-waiting`},proposed:{label:`待裁決`,icon:Qu,tone:`text-warning`},due:{label:`即將到期`,icon:Wu,tone:`text-warning`},review:{label:`待重新確認`,icon:qd,tone:`text-warning`}},l=J(()=>[...s.value.flatMap(e=>e.tasks.filter(e=>e.status===`blocked`).map(t=>({ref:CC(e.id,t.id),type:Bw(t),status:t.status,id:`${e.id}/${t.id}`,title:t.title,kind:`blocked`,reason:`卡住:${t.blockedBy?.reason??`沒有寫原因`}`,context:e.title}))),...s.value.flatMap(e=>e.decisions.filter(e=>e.status===`proposed`).map(t=>({ref:wC(e.id,t.id),type:`decision`,status:t.status,id:`${e.id}/${t.id}`,title:t.title,kind:`proposed`,reason:t.affects?.length?`待裁決,影響 ${t.affects.join(`、`)}`:`待裁決`,context:e.title}))),...Q.issues.filter(e=>e.status!==`closed`&&!e.archivedAt&&hE(e.due)).map(e=>{let t=mE(e.due);return{ref:e.id,type:`issue`,status:e.status,id:e.id,title:e.title,kind:t<0?`overdue`:`due`,reason:t<0?`已逾期 ${-t} 天`:t===0?`今天到期`:`${t} 天後到期`}}),...Q.findings.filter(e=>e.status===`valid`&&!e.archivedAt&&e.reviewAfter&&mE(e.reviewAfter)<0).map(e=>({ref:e.id,type:`finding`,status:e.status,id:e.id,title:e.title,kind:`review`,reason:`${e.reviewAfter} 起該重新確認是否仍成立`}))]),u=J(()=>Object.keys(c).flatMap(e=>{let t=l.value.filter(t=>t.kind===e).length;return t?[{kind:e,n:t,...c[e]}]:[]})),d=M($C(yz,!1)===!0);function f(){d.value=!d.value,ew(yz,d.value)}let p=[`open`,`planned`],m=DN({key:`overview.issues`,queryPrefix:`i.`,id:e=>e.id,text:e=>e.title,filters:PF(p),sorts:[{key:`order`,label:`手動順序`,value:e=>e.order,dir:`asc`},{key:`name`,label:`名稱`,value:e=>e.title,dir:`asc`},{key:`priority`,label:`優先度`,value:e=>mN(e.priority),dir:`asc`},{key:`planned`,label:`排入`,value:e=>e.plannedIn??e.due,dir:`asc`}],groups:FF(p),defaultSort:`order`,defaultGroup:`priority`},()=>Q.issues.filter(e=>!e.archivedAt&&e.status!==`closed`)),h=$C(bz,`group`),g=M(m.spec.groups.some(e=>e.key===h)?h:`group`);function _(e){g.value=e,ew(bz,e)}let v=J(()=>m.spec.groups.find(e=>e.key===g.value)?.label),y=e=>mN(e.priority)!==`P2`||g.value!==`category`&&!!e.category||!!e.labels?.length,b=J(()=>a.value.length),x=J(()=>Pw().length);return(e,n)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`總覽`,description:`現在要注意什麼、進行中的主脈絡與會話怎麼串在一起、還有哪些待辦。`})]),default:P(()=>[U(`div`,JR,[l.value.length?(B(),V(`section`,YR,[U(`h2`,XR,[U(`button`,{type:`button`,class:`flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2 text-left hover:bg-accent/50`,"aria-expanded":d.value,"aria-controls":`attention-list`,onClick:f},[d.value?(B(),H(N(Ju),{key:0,class:`size-4 shrink-0 text-muted-foreground`})):(B(),H(N(Xu),{key:1,class:`size-4 shrink-0 text-muted-foreground`})),n[1]||=G(` 需要注意 `,-1),U(`span`,QR,j(l.value.length),1),d.value?K(``,!0):(B(),V(`span`,$R,[(B(!0),V(z,null,L(u.value,e=>(B(),V(`span`,{key:e.kind,class:`flex shrink-0 items-center gap-1`},[(B(),H(fa(e.icon),{class:k([`size-3.5`,e.tone])},null,8,[`class`])),G(j(e.label)+` `,1),U(`span`,ez,j(e.n),1)]))),128))]))],8,ZR)]),yr(U(`ul`,tz,[(B(!0),V(z,null,L(l.value,e=>(B(),V(`li`,{key:e.ref+e.reason,class:`flex h-9 cursor-pointer items-center gap-2 border-b px-3 transition-colors duration-[120ms] last:border-b-0 hover:bg-muted/50`,"data-peek":e.ref,"aria-current":r(e.ref),onClick:n=>N(t)(e.ref)},[W(nT,{type:e.type,status:e.status},null,8,[`type`,`status`]),U(`span`,rz,j(e.id),1),U(`span`,iz,j(e.title),1),U(`span`,{class:`ml-auto flex min-w-0 shrink items-center gap-1 text-xs text-muted-foreground`,title:e.reason},[(B(),H(fa(c[e.kind].icon),{class:k([`size-3.5 shrink-0`,c[e.kind].tone])},null,8,[`class`])),U(`span`,oz,j(e.reason),1)],8,az),e.context?(B(),V(`span`,sz,j(e.context),1)):K(``,!0)],8,nz))),128))],512),[[Vc,d.value]])])):K(``,!0),U(`section`,cz,[U(`h2`,lz,[n[2]||=G(` 進行中 `,-1),U(`span`,uz,j(b.value)+` 條主脈絡 · `+j(x.value)+` 個會話`,1),W(N(Wj),{"open-delay":150,"close-delay":100},{default:P(()=>[W(N(Kj),{"as-child":``},{default:P(()=>[U(`button`,dz,[W(N(td),{class:`size-3.5`})])]),_:1}),W(N(Gj),{class:`w-72 text-xs`},{default:P(()=>[G(j(xz))]),_:1})]),_:1})]),W(qR)]),U(`section`,fz,[U(`h2`,pz,[n[3]||=G(`待辦事項 `,-1),U(`span`,mz,j(N(m).total.value),1)]),W(uD,{view:N(m)},{views:P(()=>[W(N(lC),null,{default:P(()=>[W(N(SC),{"as-child":``},{default:P(()=>[W(N(sC),{variant:`outline`,size:`sm`,"aria-label":`橫軸:${v.value}`},{default:P(()=>[W(N(od)),G(j(v.value),1)]),_:1},8,[`aria-label`])]),_:1}),W(N(fC),{align:`end`,class:`w-40`},{default:P(()=>[W(N(mC),{class:`text-xs text-muted-foreground`},{default:P(()=>[...n[4]||=[G(`橫軸`,-1)]]),_:1}),W(N(hC),{"model-value":g.value,"onUpdate:modelValue":n[0]||=e=>_(String(e))},{default:P(()=>[(B(!0),V(z,null,L(N(m).spec.groups,e=>(B(),H(N(_C),{key:e.key,value:e.key},{default:P(()=>[G(j(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1},8,[`model-value`])]),_:1})]),_:1})]),_:1},8,[`view`]),W(nL,{view:N(m),axis:g.value},{card:P(({item:e})=>[W(N(mI),{class:k([`min-w-0 cursor-pointer gap-1 px-3 py-2 shadow-xs transition-colors duration-[120ms] hover:bg-accent/50`,{"bg-muted":r(e.id)}]),"data-peek":e.id,"aria-current":r(e.id),onClick:n=>N(t)(e.id)},{default:P(()=>[U(`div`,hz,[W(nT,{type:`issue`,status:e.status},null,8,[`status`]),U(`span`,gz,j(e.id),1),U(`span`,{class:`truncate`,title:e.title},j(e.title),9,_z)]),y(e)?(B(),V(`div`,vz,[W(TE,{priority:e.priority,class:`shrink-0`},null,8,[`priority`]),g.value!==`category`&&e.category?(B(),H(N(nE),{key:0,variant:`outline`},{default:P(()=>[G(j(e.category),1)]),_:2},1024)):K(``,!0),(B(!0),V(z,null,L(e.labels??[],e=>(B(),H(N(nE),{key:e,variant:`secondary`},{default:P(()=>[G(j(e),1)]),_:2},1024))),128))])):K(``,!0)]),_:2},1032,[`class`,`data-peek`,`aria-current`,`onClick`])]),empty:P(()=>[...n[5]||=[G(`沒有未處理或已排入的待辦。`,-1)]]),_:1},8,[`view`,`axis`])])])]),_:1}))}}),Cz=[`title`],wz={key:1,class:`shrink-0 text-xs text-muted-foreground`},Tz=I({__name:`SessionList`,setup(e){let t=[`active`,`paused`,`handed-off`,`ended`],n=e=>e.actions.find(e=>e.status===`doing`)??e.actions.find(e=>e.status===`todo`),r=e=>[...new Set(e.actions.flatMap(e=>e.serves.map(e=>e.slice(0,4))))],i=e=>e?`${e} ${Q.summary?.mainlines.find(t=>t.id===e)?.title??``}`.trim():`沒有服務的主脈絡`,a=e=>Math.max(...[e.started,...e.actions.flatMap(e=>[e.startedAt,e.doneAt])].filter(e=>!!e).map(cE)),o=e=>Q.sessions.filter(t=>t.delegatedFrom===e).sort((e,t)=>cE(e.started)-cE(t.started)),s=(e,t=1)=>o(e.id).flatMap(e=>[{item:e,depth:t},...s(e,t+1)]),c=J(()=>{let e=new Set(Q.sessions.map(e=>e.id));return Q.sessions.filter(t=>!t.delegatedFrom||!e.has(t.delegatedFrom))}),l=DN({key:`sessions`,id:e=>e.id,text:e=>`${jw(e)} ${e.branch??``}`,filters:[{key:`status`,label:`狀態`,values:e=>[e.status],options:hN(t)},{key:`agent`,label:`agent`,values:e=>[e.agent]},{key:`branch`,label:`分支`,values:e=>e.branch?[e.branch]:[]},{key:`mainline`,label:`主脈絡`,values:r,optionLabel:i}],sorts:[{key:`name`,label:`名稱`,value:e=>jw(e),dir:`asc`},{key:`serves`,label:`服務的任務`,value:e=>p(e),dir:`asc`},{key:`subagents`,label:`子代理數`,value:e=>o(e.id).length,dir:`desc`},{key:`started`,label:`開始時間`,value:e=>cE(e.started),dir:`desc`},{key:`active`,label:`最後活動`,value:a,dir:`desc`}],groups:[yN(t),{key:`mainline`,label:`主脈絡`,value:e=>r(e)[0]??``,groupLabel:i},{key:`day`,label:`日期`,value:e=>uE(e.started),latestFirst:!0}],defaultSort:`started`,defaultGroup:`status`,ended:e=>gN(e.status),archived:e=>!!e.archivedAt,nested:e=>s(e)},()=>c.value),u=TF(l,{kind:`session`,archived:e=>!!e.archivedAt}),d=[{key:`name`,label:`會話`,sort:`name`},{key:`serves`,label:`服務的任務`,class:`max-w-56`,sort:`serves`,value:e=>p(e),optional:!0},{key:`subagents`,label:`子代理`,class:`text-xs text-muted-foreground tabular-nums`,sort:`subagents`,value:e=>o(e.id).length||void 0,optional:!0},{key:`started`,label:`開始`,class:`text-xs text-muted-foreground`,sort:`started`}],{open:f}=FC();Er(()=>Rw(Q.sessions.flatMap(e=>e.actions.flatMap(e=>e.serves))));let p=e=>(n(e)??e.actions[0])?.serves[0]?.split(`#`)[0],m=e=>dw(()=>XC.archiveSession(e.id,!e.archivedAt));return(e,t)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`會話`,description:`推進過 hub 的 AI 會話,含同步程式從其他環境帶來的會話。存在資料目錄的 local/sessions/,已結束的在 local/sessions/ended/。`}),W(uD,{view:N(l)},null,8,[`view`])]),default:P(()=>[W(eD,{view:N(l),selection:N(u),columns:d,"item-ref":e=>N(TC)(e.id)},{name:P(({item:e,depth:t})=>[W(yD,{status:e.status,title:N(jw)(e),muted:t>0||!!e.archivedAt,depth:t},{default:P(()=>[e.elsewhere?(B(),V(`span`,{key:0,class:`shrink-0 text-xs text-muted-foreground`,title:`工作目錄 ${e.cwd} 不在這台電腦上`,"data-elsewhere":``},`其他環境`,8,Cz)):K(``,!0),e.archivedAt?(B(),V(`span`,wz,`已封存`)):K(``,!0)]),_:2},1032,[`status`,`title`,`muted`,`depth`])]),serves:P(({item:e})=>[p(e)?(B(),H($j,q({key:0},N(Iw)(p(e)),{onOpen:N(f)}),null,16,[`onOpen`])):K(``,!0)]),subagents:P(({item:e,depth:t})=>[G(j(t===0&&o(e.id).length?o(e.id).length:``),1)]),started:P(({item:e})=>[W(TP,{at:e.started},null,8,[`at`])]),actions:P(({item:e})=>[W(iE,{archived:!!e.archivedAt,onToggle:t=>m(e)},null,8,[`archived`,`onToggle`])]),empty:P(()=>[...t[0]||=[G(`沒有會話資料。會話存在資料目錄的 `,-1),U(`code`,null,`local/sessions/`,-1),G(`,已結束的在 `,-1),U(`code`,null,`local/sessions/ended/`,-1),G(`。有同步時,其他環境的會話也會出現在這裡。`,-1)]]),_:1},8,[`view`,`selection`,`item-ref`]),W(gD,{selection:N(u)},null,8,[`selection`])]),_:1}))}}),Ez={class:`flex items-center gap-2 px-6 pb-2`,"data-notice-controls":``},Dz={class:`flex min-w-0 items-center gap-2`},Oz={key:0,class:`size-1.5 shrink-0 rounded-full bg-warning`,title:`新提醒`},kz=[`title`],Az=[`title`],jz={key:0,class:`text-xs text-muted-foreground`,title:`存檔已刪,或檔案已是同步確認的版本`},Mz={key:1,class:`text-xs text-muted-foreground`},Nz=[`title`],Pz=I({__name:`SyncNotices`,setup(e){let t=vw,n={key:`sync`,id:t,text:e=>`${zC(e)} ${e.path} ${e.message}`,filters:[{key:`kind`,label:`種類`,values:e=>[e.kind],options:Object.entries(IC).map(([e,t])=>({value:e,label:t}))},{key:`path`,label:`檔案`,values:e=>e.path?[e.path]:[]}],sorts:[{key:`at`,label:`時間`,value:e=>e.at,dir:`desc`},{key:`kind`,label:`種類`,value:e=>e.kind,dir:`asc`},{key:`path`,label:`檔案`,value:e=>e.path,dir:`asc`}],groups:[{key:`day`,label:`日期`,value:e=>e.at.slice(0,10),latestFirst:!0}],defaultSort:`at`,defaultGroup:`day`},r=M(!1),i=J(()=>hw().length),a=DN(n,()=>r.value?Q.sync.notices:hw()),o=[{key:`message`,label:`提醒`},{key:`kind`,label:`種類`,class:`text-xs`},{key:`path`,label:`檔案`,class:`max-w-72 truncate font-mono text-xs text-muted-foreground`,value:e=>e.path,optional:!0},{key:`at`,label:`時間`,class:`font-mono text-xs text-muted-foreground tabular-nums`},{key:`handled`,label:`處理`}],s=e=>new Date(e).toLocaleString(`sv-SE`).slice(5);return $i(async()=>{await xw(),bw()}),(e,n)=>(B(),H(wF,null,{header:P(()=>[W(CD,{title:`同步提醒`,description:`同步程式找到的、寫入者的內容可能沒有照原樣進入 hub 的改動。被拒的內容存在 .mainflow/local/sync/conflicts/,點開可以和 hub 的版本並排比對。`}),W(uD,{view:N(a)},null,8,[`view`]),U(`div`,Ez,[W(N(sC),{variant:`outline`,size:`xs`,"data-show-all":``,"aria-pressed":r.value,onClick:n[0]||=e=>r.value=!r.value},{default:P(()=>[G(j(r.value?`只看未處理`:`看全部`),1)]),_:1},8,[`aria-pressed`]),W(N(sC),{variant:`outline`,size:`xs`,"data-mark-all":``,disabled:i.value===0,onClick:n[1]||=e=>N(yw)()},{default:P(()=>[G(`全部標為已處理(`+j(i.value)+`)`,1)]),_:1},8,[`disabled`])])]),default:P(()=>[W(eD,{view:N(a),columns:o,"item-ref":e=>e.saved?N(DC)(e.saved):void 0},{message:P(({item:e})=>[U(`span`,Dz,[N(mw)(e)?K(``,!0):(B(),V(`span`,Oz)),e.saved?(B(),H(N(pd),{key:1,class:`size-3.5 shrink-0 text-muted-foreground`,"aria-label":`有存檔,可並排比對`})):K(``,!0),U(`span`,{class:`truncate`,title:`原文:${e.message}`},j(N(zC)(e,!1)),9,kz)])]),kind:P(({item:e})=>[G(j(N(IC)[e.kind]??e.kind),1)]),path:P(({item:e})=>[U(`span`,{title:e.path},j(e.path),9,Az)]),handled:P(({item:e})=>[e.handled===`auto`?(B(),V(`span`,jz,`已自動處理`)):e.handled?(B(),V(`span`,Mz,`已處理`)):(B(),H(N(sC),{key:2,variant:`ghost`,size:`xs`,"data-mark-one":``,onClick:au(n=>N(yw)(N(t)(e)),[`stop`])},{default:P(()=>[...n[2]||=[G(`標為已處理`,-1)]]),_:1},8,[`onClick`]))]),at:P(({item:e})=>[U(`span`,{title:e.at},j(s(e.at)),9,Nz)]),empty:P(()=>[!r.value&&N(Q).sync.notices.length>0?(B(),V(z,{key:0},[G(`沒有未處理的提醒。切換「看全部」可看已處理的。`)],64)):N(Q).sync.remote?(B(),V(z,{key:1},[G(`沒有提醒。同步程式只在寫入者的內容可能遺失時提醒,只多了別人改動的合併不列在這裡。`)],64)):(B(),V(z,{key:2},[n[3]||=G(`這個 hub 沒有設定同步伺服器。設定方式見 mainflow 的 `,-1),n[4]||=U(`code`,null,`docs/sync.md`,-1),n[5]||=G(`。`,-1)],64))]),_:1},8,[`view`,`item-ref`])]),_:1}))}}),Fz=e=>Array.isArray(e)?e.join(`/`):e??``,Iz=Rm({history:om(WC),routes:[{path:`/`,component:Sz},{path:`/mainlines`,component:HI},{path:`/mainlines/:m`,component:BI},{path:`/issues`,component:LF},{path:`/findings`,component:OF},{path:`/ops`,component:KI},{path:`/sessions`,component:Tz},{path:`/sync`,component:Pz},{path:`/mainlines/:m/tasks/:t`,redirect:e=>({path:`/mainlines/${Fz(e.params.m)}`,query:{view:`tasks`,peek:CC(Fz(e.params.m),Fz(e.params.t))}})},{path:`/mainlines/:m/decisions/:d`,redirect:e=>({path:`/mainlines/${Fz(e.params.m)}`,query:{view:`decisions`,peek:wC(Fz(e.params.m),Fz(e.params.d))}})},{path:`/mainlines/:m/files/:path(.*)`,redirect:e=>({path:`/mainlines/${Fz(e.params.m)}`,query:{peek:EC(Fz(e.params.m),Fz(e.params.path))}})},{path:`/sessions/:s`,redirect:e=>({path:`/sessions`,query:{peek:TC(Fz(e.params.s))}})}]}),Lz=hu(tE);Lz.config.errorHandler=Cw,Lz.use(Iz).mount(`#app`);
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>mainflow</title>
7
- <script type="module" crossorigin src="/assets/index-B4w2iRCQ.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-BX_V5mK5.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-D3P-pLas.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mainflow",
3
- "version": "0.44.0-alpha.2",
3
+ "version": "0.44.0-alpha.4",
4
4
  "description": "本機多 AI 協作的主脈絡任務管理:CLI 與介面",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,10 +0,0 @@
1
- //#region ../core/dist/progress.js
2
- function listProgress(items) {
3
- const counted = items.filter((item) => !item.dropped);
4
- return {
5
- done: counted.filter((item) => item.done).length,
6
- total: counted.length
7
- };
8
- }
9
- //#endregion
10
- export { listProgress as t };