vibora 2.12.3 → 2.12.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.
|
@@ -109,7 +109,7 @@ ${r.map(([s,o])=>{const a=o.theme?.[n]||o.color;return a?` --color-${s}: ${a};`
|
|
|
109
109
|
`)}
|
|
110
110
|
}
|
|
111
111
|
`).join(`
|
|
112
|
-
`)}}):null},AH=ea;function RH({active:e,payload:t,className:r,indicator:n="dot",hideLabel:i=!1,hideIndicator:s=!1,label:o,labelFormatter:a,labelClassName:l,formatter:u,color:h,nameKey:d,labelKey:p}){const{config:v}=WIe(),w=T.useMemo(()=>{if(i||!t?.length)return null;const[m]=t,x=`${p||m?.dataKey||m?.name||"value"}`,b=PH(v,m,x),S=!p&&typeof o=="string"?v[o]?.label||o:b?.label;return a?y.jsx("div",{className:Le("font-medium",l),children:a(S,t)}):S?y.jsx("div",{className:Le("font-medium",l),children:S}):null},[o,a,t,i,l,v,p]);if(!e||!t?.length)return null;const _=t.length===1&&n!=="dot";return y.jsxs("div",{className:Le("border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs/relaxed shadow-xl grid min-w-[8rem] items-start",r),children:[_?null:w,y.jsx("div",{className:"grid gap-1.5",children:t.filter(m=>m.type!=="none").map((m,x)=>{const b=`${d||m.name||m.dataKey||"value"}`,S=PH(v,m,b),E=h||m.payload.fill||m.color;return y.jsx("div",{className:Le("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",n==="dot"&&"items-center"),children:u&&m?.value!==void 0&&m.name?u(m.value,m.name,m,x,m.payload):y.jsxs(y.Fragment,{children:[S?.icon?y.jsx(S.icon,{}):!s&&y.jsx("div",{className:Le("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":_&&n==="dashed"}),style:{"--color-bg":E,"--color-border":E}}),y.jsxs("div",{className:Le("flex flex-1 justify-between leading-none",_?"items-end":"items-center"),children:[y.jsxs("div",{className:"grid gap-1.5",children:[_?w:null,y.jsx("span",{className:"text-muted-foreground",children:S?.label||m.name})]}),m.value&&y.jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:m.value.toLocaleString()})]})]})},m.dataKey)})})]})}function PH(e,t,r){if(typeof t!="object"||t===null)return;const n="payload"in t&&typeof t.payload=="object"&&t.payload!==null?t.payload:void 0;let i=r;return r in t&&typeof t[r]=="string"?i=t[r]:n&&r in n&&typeof n[r]=="string"&&(i=n[r]),i in e?e[i]:e[r]}const Al="";function GIe(e="vibora"){return Dr({queryKey:["monitoring","claude-instances",e],queryFn:()=>zt(`${Al}/api/monitoring/claude-instances?filter=${e}`),refetchInterval:5e3})}function KIe(e="1h"){return Dr({queryKey:["monitoring","system-metrics",e],queryFn:()=>zt(`${Al}/api/monitoring/system-metrics?window=${e}`),refetchInterval:5e3})}function YIe(){const e=Cn();return Yr({mutationFn:({terminalId:t,pid:r})=>{if(t)return zt(`${Al}/api/monitoring/claude-instances/${t}/kill`,{method:"POST"});if(r)return zt(`${Al}/api/monitoring/claude-instances/${r}/kill-pid`,{method:"POST"});throw new Error("Either terminalId or pid must be provided")},onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","claude-instances"]})}})}function Fm(e){if(e===0)return"0 B";const t=1024,r=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,n)).toFixed(1))} ${r[n]}`}function XIe(e){return{"1m":"1 min","10m":"10 min","1h":"1 hour","3h":"3 hours","6h":"6 hours","12h":"12 hours","24h":"24 hours"}[e]}function QIe(e="memory",t=10){return Dr({queryKey:["monitoring","top-processes",e,t],queryFn:()=>zt(`${Al}/api/monitoring/top-processes?sort=${e}&limit=${t}`),refetchInterval:5e3})}function ZIe(){return Dr({queryKey:["monitoring","docker-stats"],queryFn:()=>zt(`${Al}/api/monitoring/docker-stats`),refetchInterval:5e3})}function JIe(){return Dr({queryKey:["monitoring","vibora-instances"],queryFn:()=>zt(`${Al}/api/monitoring/vibora-instances`),refetchInterval:5e3})}function eNe(){const e=Cn();return Yr({mutationFn:({backendPid:t})=>zt(`${Al}/api/monitoring/vibora-instances/${t}/kill`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","vibora-instances"]})}})}function tNe(){return Dr({queryKey:["monitoring","claude-usage"],queryFn:()=>zt(`${Al}/api/monitoring/claude-usage`),refetchInterval:5e3})}const rNe=ao("/monitoring/")({component:pNe}),nNe=["1m","10m","1h","3h","6h","12h","24h"],jH={cpu:{label:"CPU",color:"var(--chart-system)"},memoryUsed:{label:"Used",color:"var(--chart-system)"},memoryCache:{label:"Cache / Buffers",color:"var(--muted-foreground)"},disk:{label:"Disk",color:"var(--muted-foreground)"}};function iNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState("vibora"),[n,i]=T.useState(null),{data:s,isLoading:o,error:a}=GIe(t),l=YIe(),u=s?.reduce((d,p)=>d+p.ramMB,0)||0,h=d=>{i(d.pid);const p=d.isViboraManaged&&d.terminalId?{terminalId:d.terminalId}:{pid:d.pid};l.mutate(p,{onSettled:()=>i(null)})};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(ol,{id:"show-all",checked:t==="all",onCheckedChange:d=>r(d?"all":"vibora")}),y.jsx(rW,{htmlFor:"show-all",className:"text-sm text-muted-foreground",children:e("claude.showAllInstances")})]}),s&&y.jsxs("span",{className:"text-sm text-muted-foreground",children:[e("claude.instanceCount",{count:s.length}),u>0&&` · ${e("claude.totalRam",{ram:u.toFixed(0)})}`]})]}),o&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("claude.error",{message:a.message})}),s&&s.length===0&&y.jsxs("div",{className:"py-12 text-center text-muted-foreground",children:[e("claude.empty"),t==="vibora"&&e("claude.emptyVibora")]}),s&&s.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("claude.headers.pid")}),y.jsx("span",{children:e("claude.headers.terminal")}),y.jsx("span",{children:e("claude.headers.task")}),y.jsx("span",{children:e("claude.headers.workingDirectory")}),y.jsx("span",{className:"text-right",children:e("claude.headers.ram")}),y.jsx("span",{className:"text-right",children:e("claude.headers.actions")})]}),s.map(d=>y.jsxs(Qi,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"text-sm font-medium truncate",children:d.taskId?y.jsx(hi,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):y.jsx("span",{className:"text-muted-foreground",children:d.isViboraManaged?d.terminalName:e("claude.source.external")})}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>h(d),disabled:n===d.pid,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${n===d.pid?"opacity-50":""}`,children:y.jsx(he,{icon:n===d.pid?sr:Ji,className:`size-3.5 ${n===d.pid?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:d.cwd,children:d.cwd})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-xs",children:d.pid}),y.jsx("span",{className:"truncate text-sm",children:d.isViboraManaged?y.jsx("span",{children:d.terminalName||`Terminal ${d.terminalId?.slice(0,8)}`}):y.jsx("span",{className:"text-muted-foreground",children:e("claude.source.external")})}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",children:d.taskId?y.jsx(hi,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):e("claude.noTask")}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:d.cwd,children:d.cwd}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ne,{variant:"ghost",size:"xs",onClick:()=>h(d),disabled:n===d.pid,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${n===d.pid?"opacity-50":""}`,children:[y.jsx(he,{icon:n===d.pid?sr:Ji,className:`size-3.5 ${n===d.pid?"animate-spin":""}`}),n===d.pid?e("claude.killing"):e("claude.kill")]})})]})]},d.pid))]})]})}function sNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState("1h"),{data:n,isLoading:i,error:s}=KIe(t),o=n?.dataPoints.map(a=>({time:new Date(a.timestamp*1e3).toLocaleTimeString(),timestamp:a.timestamp,cpu:Math.round(a.cpuPercent*10)/10,memoryUsed:Math.round(a.memoryUsedPercent*10)/10,memoryCache:Math.round(a.memoryCachePercent*10)/10}))||[];return y.jsxs("div",{className:"space-y-6",children:[y.jsx("div",{className:"flex gap-1",children:nNe.map(a=>y.jsx(Ne,{variant:t===a?"secondary":"ghost",size:"xs",onClick:()=>r(a),children:XIe(a)},a))}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),s&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("system.error",{message:s.message})}),n&&y.jsxs("div",{className:"space-y-6",children:[y.jsxs(Qi,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.cpuUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[n.current.cpu.toFixed(1),"%"]})]}),y.jsx(TH,{config:jH,className:"h-[150px] w-full",children:y.jsxs(kH,{data:o,margin:{left:0,right:0},children:[y.jsx(iP,{strokeDasharray:"3 3",vertical:!1}),y.jsx(vv,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(yv,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:a=>`${a}%`}),y.jsx(AH,{content:y.jsx(RH,{hideLabel:!0,formatter:a=>[`${a}% `,"CPU"]})}),y.jsx(ha,{type:"monotone",dataKey:"cpu",stroke:"var(--color-cpu)",fill:"var(--color-cpu)",fillOpacity:.4,strokeWidth:2})]})})]}),y.jsxs(Qi,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.memoryUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[Fm(n.current.memory.used)," ",e("system.memoryLabels.used").toLowerCase()," + ",Fm(n.current.memory.cache)," ",e("system.memoryLabels.cache").toLowerCase()," / ",Fm(n.current.memory.total)]})]}),y.jsx(TH,{config:jH,className:"h-[150px] w-full",children:y.jsxs(kH,{data:o,margin:{left:0,right:0},children:[y.jsx(iP,{strokeDasharray:"3 3",vertical:!1}),y.jsx(vv,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(yv,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:a=>`${a}%`}),y.jsx(AH,{content:y.jsx(RH,{hideLabel:!0,formatter:(a,l)=>{const u=e(l==="memoryUsed"?"system.memoryLabels.used":"system.memoryLabels.cache");return[`${a}% `,u]}})}),y.jsx(ha,{type:"monotone",dataKey:"memoryUsed",stroke:"var(--color-memoryUsed)",fill:"var(--color-memoryUsed)",fillOpacity:.5,strokeWidth:2,stackId:"memory"}),y.jsx(ha,{type:"monotone",dataKey:"memoryCache",stroke:"var(--color-memoryCache)",fill:"var(--color-memoryCache)",fillOpacity:.4,strokeWidth:1,stackId:"memory"})]})})]}),y.jsxs(Qi,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.diskUsage",{path:n.current.disk.path})}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[n.current.disk.usedPercent.toFixed(1),"% (",Fm(n.current.disk.used)," /"," ",Fm(n.current.disk.total),")"]})]}),y.jsx("div",{className:"h-4 w-full overflow-hidden rounded-full bg-muted",children:y.jsx("div",{className:"h-full bg-chart-system transition-all",style:{width:`${Math.min(n.current.disk.usedPercent,100)}%`}})})]})]})]})}function oNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState("memory"),{data:n,isLoading:i,error:s}=QIe(t),{data:o,isLoading:a}=ZIe();return y.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start",children:[y.jsxs(Qi,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between shrink-0",children:[y.jsx("h3",{className:"font-medium",children:e("processes.topProcesses")}),y.jsxs(Ti,{value:t,onValueChange:l=>r(l),children:[y.jsx(Ri,{className:"w-32",children:y.jsx(Ai,{})}),y.jsxs(Pi,{children:[y.jsx(pr,{value:"memory",children:e("processes.sortBy.memory")}),y.jsx(pr,{value:"cpu",children:e("processes.sortBy.cpu")})]})]})]}),i&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),s&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("processes.error",{message:s.message})}),n&&n.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.pid")}),y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{children:e("processes.headers.command")}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),n.map(l=>y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:l.pid}),y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsx("span",{className:"truncate text-muted-foreground text-xs",title:l.command,children:l.command}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.pid))]})}),n&&n.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.empty")})]}),y.jsxs(Qi,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsx("div",{className:"mb-4 flex items-center justify-between shrink-0",children:y.jsxs("h3",{className:"font-medium",children:[e("processes.containers"),o?.runtime&&y.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["(",o.runtime,")"]})]})}),a&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),o&&!o.available&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersUnavailable")}),o&&o.available&&o.containers.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersEmpty")}),o&&o.available&&o.containers.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{className:"text-right",children:"CPU"}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),o.containers.map(l=>y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.cpuPercent.toFixed(1),"%"]}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," / ",l.memoryLimit.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.id))]})})]})]})}function aNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState(null),{data:n,isLoading:i,error:s}=JIe(),o=eNe(),a=l=>{l.backend&&(r(l.backend.pid),o.mutate({backendPid:l.backend.pid},{onSettled:()=>r(null)}))};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.description")}),n&&n.length>0&&y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.instanceCount",{count:n.length})})]}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),s&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("vibora.error",{message:s.message})}),n&&n.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:e("vibora.empty")}),n&&n.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("vibora.headers.port")}),y.jsx("span",{children:e("vibora.headers.mode")}),y.jsx("span",{children:e("vibora.headers.directory")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.ram")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.actions")})]}),n.map(l=>{const u=t===l.backend?.pid;return y.jsxs(Qi,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("span",{className:"text-sm font-medium",children:[y.jsxs("span",{className:"font-mono",children:[":",l.port]}),y.jsxs("span",{className:`ml-2 text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]})]}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>a(l),disabled:u||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${u?"opacity-50":""}`,children:y.jsx(he,{icon:u?sr:Ji,className:`size-3.5 ${u?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:l.viboraDir,children:l.viboraDir})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-sm",children:l.port}),y.jsxs("span",{className:`text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:l.viboraDir,children:l.viboraDir}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ne,{variant:"ghost",size:"xs",onClick:()=>a(l),disabled:u||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${u?"opacity-50":""}`,children:[y.jsx(he,{icon:u?sr:Ji,className:`size-3.5 ${u?"animate-spin":""}`}),e(u?"vibora.killing":"vibora.kill")]})})]})]},l.backend?.pid||l.port)})]})]})}function lNe(e){return e>=90?"text-destructive":e>=70?"text-muted-foreground":"text-chart-system"}function cNe(e){if(e<60)return`${e}m`;const t=Math.floor(e/60),r=e%60;return r>0?`${t}h ${r}m`:`${t}h`}function AT(e){const t=new Date(e),r=new Date,n=t.getTime()-r.getTime(),i=Math.floor(n/(1e3*60*60*24));return i===0?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):i===1?`Tomorrow ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:i<7?t.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function h0({percent:e,label:t,subtitle:r,color:n}){const i=[{value:Math.min(e,100),fill:n}],s=Math.round(96*gc),o=Math.round(48*gc),a=Math.round(32*gc),l=Math.round(44*gc),u=Math.round(10*gc),h=Math.round(5*gc);return y.jsx(Qi,{className:"p-4",children:y.jsxs("div",{className:"flex items-center gap-4",children:[y.jsxs("div",{className:"relative size-24 shrink-0",children:[y.jsxs(UIe,{width:s,height:s,cx:o,cy:o,innerRadius:a,outerRadius:l,barSize:u,data:i,startAngle:90,endAngle:-270,children:[y.jsx(oy,{type:"number",domain:[0,100],angleAxisId:0,tick:!1}),y.jsx(ay,{background:{fill:"var(--border)"},dataKey:"value",cornerRadius:h,angleAxisId:0})]}),y.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:y.jsxs("span",{className:`text-lg font-semibold tabular-nums ${lNe(e)}`,children:[e.toFixed(0),"%"]})})]}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("h3",{className:"text-sm font-medium truncate",children:t}),y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r})]})]})})}function uNe(){const{t:e}=Wt("monitoring"),{data:t,isLoading:r,error:n}=tNe(),i=s=>s>=90?"var(--destructive)":s>=70?"var(--muted-foreground)":"var(--chart-system)";return y.jsxs("div",{className:"space-y-4",children:[r&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),n&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("usage.error",{message:n.message})}),t&&!t.available&&y.jsx("div",{className:"rounded-lg border border-muted-foreground/50 bg-muted p-4 text-sm text-muted-foreground",children:t.error||e("usage.unavailable")}),t&&t.available&&y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.fiveHour&&y.jsx(h0,{percent:t.fiveHour.percentUsed,label:e("usage.fiveHourBlock"),subtitle:e("usage.resetsIn",{time:cNe(t.fiveHour.timeRemainingMinutes)}),color:i(t.fiveHour.percentUsed)}),t.sevenDay&&y.jsx(h0,{percent:t.sevenDay.percentUsed,label:e("usage.sevenDayRolling"),subtitle:`${e("usage.resetsAt",{time:AT(t.sevenDay.resetAt)})} · ${e("usage.weekProgress",{percent:t.sevenDay.weekProgressPercent})}`,color:i(t.sevenDay.percentUsed)})]}),(t.sevenDayOpus||t.sevenDaySonnet)&&y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.sevenDayOpus&&y.jsx(h0,{percent:t.sevenDayOpus.percentUsed,label:e("usage.opusWeekly"),subtitle:e("usage.resetsAt",{time:AT(t.sevenDayOpus.resetAt)}),color:i(t.sevenDayOpus.percentUsed)}),t.sevenDaySonnet&&y.jsx(h0,{percent:t.sevenDaySonnet.percentUsed,label:e("usage.sonnetWeekly"),subtitle:e("usage.resetsAt",{time:AT(t.sevenDaySonnet.resetAt)}),color:i(t.sevenDaySonnet.percentUsed)})]})]})]})}const RT={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},dNe=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function fNe(){const{t:e}=Wt("common");return t=>{const r=new Date(t),i=new Date().getTime()-r.getTime(),s=Math.floor(i/1e3),o=Math.floor(s/60),a=Math.floor(o/60),l=Math.floor(a/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):a>0?a===1?e("time.hourAgo"):e("time.hoursAgo",{count:a}):o>0?o===1?e("time.minuteAgo"):e("time.minutesAgo",{count:o}):e("time.justNow")}}function hNe(){const{t:e}=Wt("common"),{t}=Wt("worktrees"),r=fNe(),{worktrees:n,summary:i,isLoading:s,isLoadingDetails:o,error:a,refetch:l}=sq(),u=oq(),[h,d]=T.useState(new Set),[p,v]=T.useState(!1),[w,_]=T.useState(!1),[m,x]=T.useState(!1),[b,S]=T.useState(null),[E,O]=T.useState(null),[k,R]=T.useState(!1),A=$=>{d(F=>{const W=new Set(F);return W.has($)?W.delete($):W.add($),W})},j=()=>{d(new Set)},B=T.useMemo(()=>h.size===0?n:n.filter($=>!!($.isOrphaned&&h.has("ORPHANED")||$.taskStatus&&h.has($.taskStatus))),[n,h]),L=T.useMemo(()=>n.filter($=>$.taskStatus==="DONE"||$.taskStatus==="CANCELED"),[n]),z=async()=>{if(L.length!==0){_(!0);try{for(const $ of L)await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:m});v(!1),l()}catch{}finally{_(!1)}}},D=async($,F)=>{S($.path);try{await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:F}),O(null),l()}catch{}finally{S(null)}},V=$=>{$||(O(null),R(!1))},H=$=>{v($),$||x(!1)};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[y.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:(i||n.length>0)&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:t("summary.total",{count:i?.total??n.length})}),(i?.orphaned??n.filter($=>$.isOrphaned).length)>0&&y.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:i?.orphaned??n.filter($=>$.isOrphaned).length})}),o?y.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):i?y.jsx("span",{children:i.totalSizeFormatted}):null]})}),y.jsxs("div",{className:"flex items-center gap-2",children:[L.length>0&&y.jsxs(Fc,{open:p,onOpenChange:H,children:[y.jsxs(Uc,{render:y.jsx(Ne,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:o}),children:[y.jsx(he,{icon:NV,size:12,strokeWidth:2}),t("cleanup.button",{count:L.length})]}),y.jsxs(Vc,{children:[y.jsxs(Wc,{children:[y.jsx(Gc,{children:t("cleanup.title")}),y.jsxs(Kc,{children:[t("cleanup.description",{count:L.length}),m&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(ya,{checked:m,onCheckedChange:$=>x($===!0),disabled:w}),t("cleanup.alsoDeleteLinkedTasks")]}),y.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),y.jsxs(qc,{children:[y.jsx(Yc,{disabled:w,children:e("buttons.cancel")}),y.jsxs(Ne,{variant:"destructive",onClick:z,disabled:w,className:"gap-2",children:[w&&y.jsx(he,{icon:sr,size:14,strokeWidth:2,className:"animate-spin"}),w?e("status.deleting"):t("delete.button",{count:L.length})]})]})]})]}),h.size>0&&y.jsxs(Ne,{variant:"ghost",size:"sm",onClick:j,className:"gap-1.5 text-xs",children:[y.jsx(he,{icon:Ji,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),y.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:dNe.map($=>{const F=h.has($);return y.jsx("button",{onClick:()=>A($),className:Le("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",F?RT[$]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${$}`)},$)})}),s&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:t("error.failedToLoad",{message:a.message})}),!s&&!a&&B.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:h.size>0?t("empty.noMatch"):t("empty.noWorktrees")}),!s&&B.length>0&&y.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:B.map($=>{const F=$.sizeFormatted==="..."||$.branch==="...",W=!$.isOrphaned&&$.taskId,N=b===$.path;return y.jsx(Qi,{className:"transition-colors hover:border-border/80",children:y.jsxs(mp,{className:"flex items-start justify-between gap-4 py-4",children:[y.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"truncate font-medium",children:$.name}),$.isOrphaned?y.jsx(pl,{className:Le("shrink-0",RT.ORPHANED),children:e("statuses.ORPHANED")}):$.taskStatus?y.jsx(pl,{className:Le("shrink-0",RT[$.taskStatus]),children:e(`statuses.${$.taskStatus}`)}):null]}),y.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:pi,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{className:"truncate font-mono",children:$.path})]}),y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:i_,size:12,strokeWidth:2,className:"shrink-0"}),$.branch==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-16"}):y.jsx("span",{className:"font-mono",children:$.branch})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:$V,size:12,strokeWidth:2,className:"shrink-0"}),$.sizeFormatted==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-12"}):y.jsx("span",{children:$.sizeFormatted})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:IV,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{children:r($.lastModified)})]})]}),$.taskId&&$.taskTitle&&y.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:y.jsxs(hi,{to:"/tasks/$taskId",params:{taskId:$.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[y.jsx("span",{className:"truncate",children:$.taskTitle}),y.jsx(he,{icon:Iv,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),y.jsxs(Fc,{open:E?.path===$.path,onOpenChange:V,children:[y.jsx(Uc,{render:y.jsx(Ne,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:F||N,onClick:()=>O($)}),children:y.jsx(he,{icon:N?sr:hp,size:14,strokeWidth:2,className:N?"animate-spin":""})}),y.jsxs(Vc,{children:[y.jsxs(Wc,{children:[y.jsx(Gc,{children:t("delete.title")}),y.jsxs(Kc,{children:[t("delete.description")," ",y.jsx("span",{className:"font-mono",children:$.name}),".",k&&W&&y.jsxs(y.Fragment,{children:[" ",t("delete.linkedTaskWillBeDeleted",{title:$.taskTitle})]})," ",t("delete.cannotUndo")]}),W&&y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(ya,{checked:k,onCheckedChange:q=>R(q===!0),disabled:N}),t("delete.alsoDeleteLinkedTask",{title:$.taskTitle})]})]}),y.jsxs(qc,{children:[y.jsx(Yc,{disabled:N,children:e("buttons.cancel")}),y.jsxs(Ne,{variant:"destructive",onClick:()=>D($,k),disabled:N,className:"gap-2",children:[N&&y.jsx(he,{icon:sr,size:14,strokeWidth:2,className:"animate-spin"}),e(N?"status.deleting":"buttons.delete")]})]})]})]})]})},$.path)})})]})}function pNe(){const{t:e}=Wt("monitoring"),{data:t}=XW(),[r,n]=T.useState("system"),s=[{value:"system",label:e("tabs.system")},{value:"processes",label:e("tabs.processes")},{value:"claude",label:e("tabs.claude")},{value:"vibora",label:e("tabs.vibora"),devOnly:!0},{value:"worktrees",label:e("tabs.worktrees")},{value:"usage",label:e("tabs.usage")}].filter(o=>!o.devOnly||t?.enabled);return y.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[y.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-background px-4 py-2",children:[y.jsx("div",{className:"sm:hidden",children:y.jsxs(Ti,{value:r,onValueChange:o=>n(o),children:[y.jsx(Ri,{size:"sm",className:"w-auto gap-2",children:y.jsx(Ai,{})}),y.jsx(Pi,{children:s.map(o=>y.jsx(pr,{value:o.value,children:o.label},o.value))})]})}),y.jsx("div",{className:"hidden sm:block",children:y.jsx(Ic,{value:r,onValueChange:o=>n(o),children:y.jsx(Nc,{children:s.map(o=>y.jsx(ui,{value:o.value,children:o.label},o.value))})})})]}),y.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r==="system"&&y.jsx(sNe,{}),r==="processes"&&y.jsx(oNe,{}),r==="claude"&&y.jsx(iNe,{}),r==="vibora"&&t?.enabled&&y.jsx(aNe,{}),r==="worktrees"&&y.jsx(hNe,{}),r==="usage"&&y.jsx(uNe,{})]})]})}const mNe=()=>`${window.location.protocol}//${window.location.hostname}:5173`,Um={activeTab:"diff",browserUrl:mNe(),diffOptions:{wrap:!0,ignoreWhitespace:!0,includeUntracked:!1,collapsedFiles:[]},filesViewState:{selectedFile:null,expandedDirs:[]}};function vS(e){const t=Cn(),r=T.useRef(void 0),n=T.useRef({}),{data:i}=qW(e),s=T.useMemo(()=>{const p=i?.viewState;return p?{activeTab:p.activeTab??Um.activeTab,browserUrl:p.browserUrl??Um.browserUrl,diffOptions:{...Um.diffOptions,...p.diffOptions},filesViewState:{...Um.filesViewState,...p.filesViewState}}:Um},[i?.viewState]),o=Yr({mutationFn:async p=>{const v=await fetch(`/api/tasks/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({viewState:p})});if(!v.ok)throw new Error("Failed to update view state");return v.json()},onSuccess:p=>{t.setQueryData(["tasks",e],p),t.setQueryData(["tasks"],v=>v&&v.map(w=>w.id===e?p:w))}}),a=T.useCallback(p=>{const v=n.current;n.current={...v,...p,diffOptions:p.diffOptions||v.diffOptions?{...v.diffOptions,...p.diffOptions}:void 0,filesViewState:p.filesViewState||v.filesViewState?{...v.filesViewState,...p.filesViewState}:void 0};const w=n.current,_={activeTab:w.activeTab??s.activeTab,browserUrl:w.browserUrl??s.browserUrl,diffOptions:{...s.diffOptions,...w.diffOptions},filesViewState:{...s.filesViewState,...w.filesViewState}};t.setQueryData(["tasks",e],m=>m&&{...m,viewState:_}),t.setQueryData(["tasks"],m=>m&&m.map(x=>x.id===e?{...x,viewState:_}:x)),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{o.mutate(_),n.current={}},500)},[t,e,s,o]),l=T.useCallback(p=>{a({activeTab:p})},[a]),u=T.useCallback(p=>{a({browserUrl:p})},[a]),h=T.useCallback(p=>{a({diffOptions:p})},[a]),d=T.useCallback(p=>{a({filesViewState:p})},[a]);return{viewState:s,setActiveTab:l,setBrowserUrl:u,setDiffOptions:h,setFilesViewState:d}}function gNe(e){const{viewState:t,setActiveTab:r}=vS(e);return{tab:t.activeTab,setTab:r}}function vNe(e){return Dr({queryKey:["linear-ticket",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/linear/ticket/${e}`);return t.ok?t.json():null},enabled:!!e,staleTime:300*1e3})}function MH({taskName:e,cwd:t,className:r,aiMode:n,description:i,startupScript:s,serverPort:o=7777}){const a=T.useRef(null),l=T.useRef(null),u=T.useRef(null),h=T.useRef(!1),d=T.useRef(!1),[p,v]=T.useState(null),[w,_]=T.useState(!1),[m,x]=T.useState(!1),[b,S]=T.useState(!1),{resolvedTheme:E}=ip(),O=E==="dark",k=O?EG:CG;T.useEffect(()=>{xt.taskTerminal.debug("cwd changed, resetting refs",{cwd:t}),h.current=!1,d.current=!1,v(null),_(!1)},[t]);const{setTerminalFocused:R}=Nj(),{terminals:A,terminalsLoaded:j,connected:B,createTerminal:L,attachXterm:z,resizeTerminal:D,setupImagePaste:V,writeToTerminal:H,consumePendingStartup:$}=iM(),F=T.useRef(z),W=T.useRef(V),N=T.useRef(H),q=T.useRef($);T.useEffect(()=>{F.current=z},[z]),T.useEffect(()=>{W.current=V},[V]),T.useEffect(()=>{N.current=H},[H]),T.useEffect(()=>{q.current=$},[$]);const I=p?A.find(J=>J.id===p):null,U=I?.status;T.useEffect(()=>{if(!a.current||l.current)return;const J=new xG.Terminal({cursorBlink:!0,fontSize:Math.round(13*gc),fontFamily:"JetBrains Mono Variable, Menlo, Monaco, monospace",lineHeight:1.2,theme:k}),re=new SG.FitAddon,X=new wG.WebLinksAddon;J.loadAddon(re),J.loadAddon(X),J.open(a.current),l.current=J,u.current=re,S(!0),requestAnimationFrame(()=>{re.fit()});const G=setTimeout(()=>{re.fit(),J.refresh(0,J.rows-1)},100),Z=()=>R(!0),te=()=>R(!1);return J.textarea&&(J.textarea.addEventListener("focus",Z),J.textarea.addEventListener("blur",te)),()=>{clearTimeout(G),J.textarea&&(J.textarea.removeEventListener("focus",Z),J.textarea.removeEventListener("blur",te)),R(!1),J.dispose(),l.current=null,u.current=null,S(!1)}},[R]);const Y=T.useCallback(()=>{if(!u.current||!l.current)return;u.current.fit();const{cols:J,rows:re}=l.current;p&&D(p,J,re)},[p,D]);T.useEffect(()=>{if(!a.current)return;const J=()=>{requestAnimationFrame(Y)};window.addEventListener("resize",J);const re=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{Y(),l.current&&l.current.refresh(0,l.current.rows-1)})};document.addEventListener("visibilitychange",re);const X=new ResizeObserver(J);X.observe(a.current);const G=new IntersectionObserver(Z=>{Z[0]?.isIntersecting&&requestAnimationFrame(()=>{Y(),l.current&&l.current.refresh(0,l.current.rows-1)})},{threshold:.1});return G.observe(a.current),()=>{window.removeEventListener("resize",J),document.removeEventListener("visibilitychange",re),X.disconnect(),G.disconnect()}},[Y]),T.useEffect(()=>{if(!B||!t||!b||!j)return;const J=A.find(re=>re.cwd===t);if(J){v(J.id);return}if(!h.current&&l.current){h.current=!0,_(!0);const{cols:re,rows:X}=l.current;L({name:e,cols:re,rows:X,cwd:t,startup:{startupScript:s,aiMode:n,description:i,taskName:e,serverPort:o}})}},[B,t,b,j,A,e,L]),T.useEffect(()=>{if(!t)return;const J=A.find(X=>X.cwd===t);if(!J)return;const re=p&&A.some(X=>X.id===p);(!p||!re)&&(xt.taskTerminal.debug("setting terminalId",{newId:J.id,prevId:p,reason:p?"tempId replaced":"initial",cwd:t,terminalCount:A.length}),v(J.id),_(!1),p&&!re&&(d.current=!1))},[A,t,p]),T.useEffect(()=>{if(xt.taskTerminal.debug("attach effect",{terminalId:p,hasTermRef:!!l.current,hasContainerRef:!!a.current,attachedRef:d.current}),!p||!l.current||!a.current||d.current)return;xt.taskTerminal.debug("attach effect passed guards, calling attachXterm",{terminalId:p});const J=G=>{requestAnimationFrame(Y);const Z=q.current(G);if(xt.taskTerminal.debug("onAttached checking pending startup",{terminalId:G,hasPendingStartup:!!Z}),Z){xt.taskTerminal.info("onAttached: running startup commands",{terminalId:G}),x(!0);const{startupScript:te,aiMode:ne,description:ie,taskName:me,serverPort:ye}=Z;te&&setTimeout(()=>{const ge=`source /dev/stdin <<'VIBORA_STARTUP'
|
|
112
|
+
`)}}):null},AH=ea;function RH({active:e,payload:t,className:r,indicator:n="dot",hideLabel:i=!1,hideIndicator:s=!1,label:o,labelFormatter:a,labelClassName:l,formatter:u,color:h,nameKey:d,labelKey:p}){const{config:v}=WIe(),w=T.useMemo(()=>{if(i||!t?.length)return null;const[m]=t,x=`${p||m?.dataKey||m?.name||"value"}`,b=PH(v,m,x),S=!p&&typeof o=="string"?v[o]?.label||o:b?.label;return a?y.jsx("div",{className:Le("font-medium",l),children:a(S,t)}):S?y.jsx("div",{className:Le("font-medium",l),children:S}):null},[o,a,t,i,l,v,p]);if(!e||!t?.length)return null;const _=t.length===1&&n!=="dot";return y.jsxs("div",{className:Le("border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs/relaxed shadow-xl grid min-w-[8rem] items-start",r),children:[_?null:w,y.jsx("div",{className:"grid gap-1.5",children:t.filter(m=>m.type!=="none").map((m,x)=>{const b=`${d||m.name||m.dataKey||"value"}`,S=PH(v,m,b),E=h||m.payload.fill||m.color;return y.jsx("div",{className:Le("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",n==="dot"&&"items-center"),children:u&&m?.value!==void 0&&m.name?u(m.value,m.name,m,x,m.payload):y.jsxs(y.Fragment,{children:[S?.icon?y.jsx(S.icon,{}):!s&&y.jsx("div",{className:Le("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":_&&n==="dashed"}),style:{"--color-bg":E,"--color-border":E}}),y.jsxs("div",{className:Le("flex flex-1 justify-between leading-none",_?"items-end":"items-center"),children:[y.jsxs("div",{className:"grid gap-1.5",children:[_?w:null,y.jsx("span",{className:"text-muted-foreground",children:S?.label||m.name})]}),m.value&&y.jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:m.value.toLocaleString()})]})]})},m.dataKey)})})]})}function PH(e,t,r){if(typeof t!="object"||t===null)return;const n="payload"in t&&typeof t.payload=="object"&&t.payload!==null?t.payload:void 0;let i=r;return r in t&&typeof t[r]=="string"?i=t[r]:n&&r in n&&typeof n[r]=="string"&&(i=n[r]),i in e?e[i]:e[r]}const Al="";function GIe(e="vibora"){return Dr({queryKey:["monitoring","claude-instances",e],queryFn:()=>zt(`${Al}/api/monitoring/claude-instances?filter=${e}`),refetchInterval:5e3})}function KIe(e="1h"){return Dr({queryKey:["monitoring","system-metrics",e],queryFn:()=>zt(`${Al}/api/monitoring/system-metrics?window=${e}`),refetchInterval:5e3})}function YIe(){const e=Cn();return Yr({mutationFn:({terminalId:t,pid:r})=>{if(t)return zt(`${Al}/api/monitoring/claude-instances/${t}/kill`,{method:"POST"});if(r)return zt(`${Al}/api/monitoring/claude-instances/${r}/kill-pid`,{method:"POST"});throw new Error("Either terminalId or pid must be provided")},onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","claude-instances"]})}})}function Fm(e){if(e===0)return"0 B";const t=1024,r=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,n)).toFixed(1))} ${r[n]}`}function XIe(e){return{"1m":"1 min","10m":"10 min","1h":"1 hour","3h":"3 hours","6h":"6 hours","12h":"12 hours","24h":"24 hours"}[e]}function QIe(e="memory",t=10){return Dr({queryKey:["monitoring","top-processes",e,t],queryFn:()=>zt(`${Al}/api/monitoring/top-processes?sort=${e}&limit=${t}`),refetchInterval:5e3})}function ZIe(){return Dr({queryKey:["monitoring","docker-stats"],queryFn:()=>zt(`${Al}/api/monitoring/docker-stats`),refetchInterval:5e3})}function JIe(){return Dr({queryKey:["monitoring","vibora-instances"],queryFn:()=>zt(`${Al}/api/monitoring/vibora-instances`),refetchInterval:5e3})}function eNe(){const e=Cn();return Yr({mutationFn:({backendPid:t})=>zt(`${Al}/api/monitoring/vibora-instances/${t}/kill`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["monitoring","vibora-instances"]})}})}function tNe(){return Dr({queryKey:["monitoring","claude-usage"],queryFn:()=>zt(`${Al}/api/monitoring/claude-usage`),refetchInterval:5e3})}const rNe=ao("/monitoring/")({component:pNe}),nNe=["1m","10m","1h","3h","6h","12h","24h"],jH={cpu:{label:"CPU",color:"var(--chart-system)"},memoryUsed:{label:"Used",color:"var(--chart-system)"},memoryCache:{label:"Cache / Buffers",color:"var(--muted-foreground)"},disk:{label:"Disk",color:"var(--muted-foreground)"}};function iNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState("vibora"),[n,i]=T.useState(null),{data:s,isLoading:o,error:a}=GIe(t),l=YIe(),u=s?.reduce((d,p)=>d+p.ramMB,0)||0,h=d=>{i(d.pid);const p=d.isViboraManaged&&d.terminalId?{terminalId:d.terminalId}:{pid:d.pid};l.mutate(p,{onSettled:()=>i(null)})};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(ol,{id:"show-all",checked:t==="all",onCheckedChange:d=>r(d?"all":"vibora")}),y.jsx(rW,{htmlFor:"show-all",className:"text-sm text-muted-foreground",children:e("claude.showAllInstances")})]}),s&&y.jsxs("span",{className:"text-sm text-muted-foreground",children:[e("claude.instanceCount",{count:s.length}),u>0&&` · ${e("claude.totalRam",{ram:u.toFixed(0)})}`]})]}),o&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("claude.error",{message:a.message})}),s&&s.length===0&&y.jsxs("div",{className:"py-12 text-center text-muted-foreground",children:[e("claude.empty"),t==="vibora"&&e("claude.emptyVibora")]}),s&&s.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("claude.headers.pid")}),y.jsx("span",{children:e("claude.headers.terminal")}),y.jsx("span",{children:e("claude.headers.task")}),y.jsx("span",{children:e("claude.headers.workingDirectory")}),y.jsx("span",{className:"text-right",children:e("claude.headers.ram")}),y.jsx("span",{className:"text-right",children:e("claude.headers.actions")})]}),s.map(d=>y.jsxs(Qi,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"text-sm font-medium truncate",children:d.taskId?y.jsx(hi,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):y.jsx("span",{className:"text-muted-foreground",children:d.isViboraManaged?d.terminalName:e("claude.source.external")})}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>h(d),disabled:n===d.pid,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${n===d.pid?"opacity-50":""}`,children:y.jsx(he,{icon:n===d.pid?sr:Ji,className:`size-3.5 ${n===d.pid?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:d.cwd,children:d.cwd})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[60px_150px_1fr_1fr_80px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-xs",children:d.pid}),y.jsx("span",{className:"truncate text-sm",children:d.isViboraManaged?y.jsx("span",{children:d.terminalName||`Terminal ${d.terminalId?.slice(0,8)}`}):y.jsx("span",{className:"text-muted-foreground",children:e("claude.source.external")})}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",children:d.taskId?y.jsx(hi,{to:"/tasks/$taskId",params:{taskId:d.taskId},className:"hover:text-foreground hover:underline",children:d.taskTitle}):e("claude.noTask")}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:d.cwd,children:d.cwd}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[d.ramMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ne,{variant:"ghost",size:"xs",onClick:()=>h(d),disabled:n===d.pid,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${n===d.pid?"opacity-50":""}`,children:[y.jsx(he,{icon:n===d.pid?sr:Ji,className:`size-3.5 ${n===d.pid?"animate-spin":""}`}),n===d.pid?e("claude.killing"):e("claude.kill")]})})]})]},d.pid))]})]})}function sNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState("1h"),{data:n,isLoading:i,error:s}=KIe(t),o=n?.dataPoints.map(a=>({time:new Date(a.timestamp*1e3).toLocaleTimeString(),timestamp:a.timestamp,cpu:Math.round(a.cpuPercent*10)/10,memoryUsed:Math.round(a.memoryUsedPercent*10)/10,memoryCache:Math.round(a.memoryCachePercent*10)/10}))||[];return y.jsxs("div",{className:"space-y-6",children:[y.jsx("div",{className:"flex gap-1",children:nNe.map(a=>y.jsx(Ne,{variant:t===a?"secondary":"ghost",size:"xs",onClick:()=>r(a),children:XIe(a)},a))}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),s&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("system.error",{message:s.message})}),n&&y.jsxs("div",{className:"space-y-6",children:[y.jsxs(Qi,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.cpuUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[n.current.cpu.toFixed(1),"%"]})]}),y.jsx(TH,{config:jH,className:"h-[150px] w-full",children:y.jsxs(kH,{data:o,margin:{left:0,right:0},children:[y.jsx(iP,{strokeDasharray:"3 3",vertical:!1}),y.jsx(vv,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(yv,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:a=>`${a}%`}),y.jsx(AH,{content:y.jsx(RH,{hideLabel:!0,formatter:a=>[`${a}% `,"CPU"]})}),y.jsx(ha,{type:"monotone",dataKey:"cpu",stroke:"var(--color-cpu)",fill:"var(--color-cpu)",fillOpacity:.4,strokeWidth:2})]})})]}),y.jsxs(Qi,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.memoryUsage")}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[Fm(n.current.memory.used)," ",e("system.memoryLabels.used").toLowerCase()," + ",Fm(n.current.memory.cache)," ",e("system.memoryLabels.cache").toLowerCase()," / ",Fm(n.current.memory.total)]})]}),y.jsx(TH,{config:jH,className:"h-[150px] w-full",children:y.jsxs(kH,{data:o,margin:{left:0,right:0},children:[y.jsx(iP,{strokeDasharray:"3 3",vertical:!1}),y.jsx(vv,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:40}),y.jsx(yv,{domain:[0,100],tickLine:!1,axisLine:!1,tickMargin:8,tickFormatter:a=>`${a}%`}),y.jsx(AH,{content:y.jsx(RH,{hideLabel:!0,formatter:(a,l)=>{const u=e(l==="memoryUsed"?"system.memoryLabels.used":"system.memoryLabels.cache");return[`${a}% `,u]}})}),y.jsx(ha,{type:"monotone",dataKey:"memoryUsed",stroke:"var(--color-memoryUsed)",fill:"var(--color-memoryUsed)",fillOpacity:.5,strokeWidth:2,stackId:"memory"}),y.jsx(ha,{type:"monotone",dataKey:"memoryCache",stroke:"var(--color-memoryCache)",fill:"var(--color-memoryCache)",fillOpacity:.4,strokeWidth:1,stackId:"memory"})]})})]}),y.jsxs(Qi,{className:"p-4",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"font-medium",children:e("system.diskUsage",{path:n.current.disk.path})}),y.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[n.current.disk.usedPercent.toFixed(1),"% (",Fm(n.current.disk.used)," /"," ",Fm(n.current.disk.total),")"]})]}),y.jsx("div",{className:"h-4 w-full overflow-hidden rounded-full bg-muted",children:y.jsx("div",{className:"h-full bg-chart-system transition-all",style:{width:`${Math.min(n.current.disk.usedPercent,100)}%`}})})]})]})]})}function oNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState("memory"),{data:n,isLoading:i,error:s}=QIe(t),{data:o,isLoading:a}=ZIe();return y.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start",children:[y.jsxs(Qi,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between shrink-0",children:[y.jsx("h3",{className:"font-medium",children:e("processes.topProcesses")}),y.jsxs(Ti,{value:t,onValueChange:l=>r(l),children:[y.jsx(Ri,{className:"w-32",children:y.jsx(Ai,{})}),y.jsxs(Pi,{children:[y.jsx(pr,{value:"memory",children:e("processes.sortBy.memory")}),y.jsx(pr,{value:"cpu",children:e("processes.sortBy.cpu")})]})]})]}),i&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),s&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("processes.error",{message:s.message})}),n&&n.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.pid")}),y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{children:e("processes.headers.command")}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),n.map(l=>y.jsxs("div",{className:"grid grid-cols-[60px_120px_1fr_70px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:l.pid}),y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsx("span",{className:"truncate text-muted-foreground text-xs",title:l.command,children:l.command}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.pid))]})}),n&&n.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.empty")})]}),y.jsxs(Qi,{className:"p-4 lg:flex-1 lg:min-w-0 h-[400px] flex flex-col",children:[y.jsx("div",{className:"mb-4 flex items-center justify-between shrink-0",children:y.jsxs("h3",{className:"font-medium",children:[e("processes.containers"),o?.runtime&&y.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["(",o.runtime,")"]})]})}),a&&y.jsx("div",{className:"flex items-center justify-center flex-1",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),o&&!o.available&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersUnavailable")}),o&&o.available&&o.containers.length===0&&y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e("processes.containersEmpty")}),o&&o.available&&o.containers.length>0&&y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 px-2 py-1 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("processes.headers.name")}),y.jsx("span",{className:"text-right",children:"CPU"}),y.jsx("span",{className:"text-right",children:e("processes.headers.memory")}),y.jsx("span",{className:"text-right",children:"%"})]}),o.containers.map(l=>y.jsxs("div",{className:"grid grid-cols-[1fr_70px_100px_80px] gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[y.jsx("span",{className:"truncate font-medium",title:l.name,children:l.name}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.cpuPercent.toFixed(1),"%"]}),y.jsxs("span",{className:"text-right tabular-nums",children:[l.memoryMB.toFixed(0)," / ",l.memoryLimit.toFixed(0)," MB"]}),y.jsxs("span",{className:"text-right tabular-nums text-muted-foreground",children:[l.memoryPercent.toFixed(1),"%"]})]},l.id))]})})]})]})}function aNe(){const{t:e}=Wt("monitoring"),[t,r]=T.useState(null),{data:n,isLoading:i,error:s}=JIe(),o=eNe(),a=l=>{l.backend&&(r(l.backend.pid),o.mutate({backendPid:l.backend.pid},{onSettled:()=>r(null)}))};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.description")}),n&&n.length>0&&y.jsx("span",{className:"text-sm text-muted-foreground",children:e("vibora.instanceCount",{count:n.length})})]}),i&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),s&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("vibora.error",{message:s.message})}),n&&n.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:e("vibora.empty")}),n&&n.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] gap-4 px-3 py-2 text-xs font-medium text-muted-foreground",children:[y.jsx("span",{children:e("vibora.headers.port")}),y.jsx("span",{children:e("vibora.headers.mode")}),y.jsx("span",{children:e("vibora.headers.directory")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.ram")}),y.jsx("span",{className:"text-right",children:e("vibora.headers.actions")})]}),n.map(l=>{const u=t===l.backend?.pid;return y.jsxs(Qi,{className:"px-3 py-2",children:[y.jsxs("div",{className:"flex flex-col gap-1 lg:hidden",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("span",{className:"text-sm font-medium",children:[y.jsxs("span",{className:"font-mono",children:[":",l.port]}),y.jsxs("span",{className:`ml-2 text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]})]}),y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsxs("span",{className:"tabular-nums text-sm text-muted-foreground",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>a(l),disabled:u||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${u?"opacity-50":""}`,children:y.jsx(he,{icon:u?sr:Ji,className:`size-3.5 ${u?"animate-spin":""}`})})]})]}),y.jsx("span",{className:"text-xs text-muted-foreground truncate",title:l.viboraDir,children:l.viboraDir})]}),y.jsxs("div",{className:"hidden lg:grid grid-cols-[80px_100px_1fr_100px_80px] items-center gap-4",children:[y.jsx("span",{className:"font-mono text-sm",children:l.port}),y.jsxs("span",{className:`text-xs ${l.mode==="development"?"text-muted-foreground":""}`,children:[l.mode==="development"?e("vibora.mode.dev"):e("vibora.mode.prod"),l.frontend&&` + ${e("vibora.vite")}`]}),y.jsx("span",{className:"text-muted-foreground truncate text-sm",title:l.viboraDir,children:l.viboraDir}),y.jsxs("span",{className:"text-right tabular-nums text-sm",children:[l.totalMemoryMB.toFixed(0)," MB"]}),y.jsx("div",{className:"flex justify-end",children:y.jsxs(Ne,{variant:"ghost",size:"xs",onClick:()=>a(l),disabled:u||!l.backend,className:`text-destructive hover:text-destructive hover:bg-destructive/10 ${u?"opacity-50":""}`,children:[y.jsx(he,{icon:u?sr:Ji,className:`size-3.5 ${u?"animate-spin":""}`}),e(u?"vibora.killing":"vibora.kill")]})})]})]},l.backend?.pid||l.port)})]})]})}function lNe(e){return e>=90?"text-destructive":e>=70?"text-muted-foreground":"text-chart-system"}function cNe(e){if(e<60)return`${e}m`;const t=Math.floor(e/60),r=e%60;return r>0?`${t}h ${r}m`:`${t}h`}function AT(e){const t=new Date(e),r=new Date,n=t.getTime()-r.getTime(),i=Math.floor(n/(1e3*60*60*24));return i===0?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):i===1?`Tomorrow ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:i<7?t.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function h0({percent:e,label:t,subtitle:r,color:n}){const i=[{value:Math.min(e,100),fill:n}],s=Math.round(96*gc),o=Math.round(48*gc),a=Math.round(32*gc),l=Math.round(44*gc),u=Math.round(10*gc),h=Math.round(5*gc);return y.jsx(Qi,{className:"p-4",children:y.jsxs("div",{className:"flex items-center gap-4",children:[y.jsxs("div",{className:"relative size-24 shrink-0",children:[y.jsxs(UIe,{width:s,height:s,cx:o,cy:o,innerRadius:a,outerRadius:l,barSize:u,data:i,startAngle:90,endAngle:-270,children:[y.jsx(oy,{type:"number",domain:[0,100],angleAxisId:0,tick:!1}),y.jsx(ay,{background:{fill:"var(--border)"},dataKey:"value",cornerRadius:h,angleAxisId:0})]}),y.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:y.jsxs("span",{className:`text-lg font-semibold tabular-nums ${lNe(e)}`,children:[e.toFixed(0),"%"]})})]}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("h3",{className:"text-sm font-medium truncate",children:t}),y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r})]})]})})}function uNe(){const{t:e}=Wt("monitoring"),{data:t,isLoading:r,error:n}=tNe(),i=s=>s>=90?"var(--destructive)":s>=70?"var(--muted-foreground)":"var(--chart-system)";return y.jsxs("div",{className:"space-y-4",children:[r&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),n&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:e("usage.error",{message:n.message})}),t&&!t.available&&y.jsx("div",{className:"rounded-lg border border-muted-foreground/50 bg-muted p-4 text-sm text-muted-foreground",children:t.error||e("usage.unavailable")}),t&&t.available&&y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.fiveHour&&y.jsx(h0,{percent:t.fiveHour.percentUsed,label:e("usage.fiveHourBlock"),subtitle:e("usage.resetsIn",{time:cNe(t.fiveHour.timeRemainingMinutes)}),color:i(t.fiveHour.percentUsed)}),t.sevenDay&&y.jsx(h0,{percent:t.sevenDay.percentUsed,label:e("usage.sevenDayRolling"),subtitle:`${e("usage.resetsAt",{time:AT(t.sevenDay.resetAt)})} · ${e("usage.weekProgress",{percent:t.sevenDay.weekProgressPercent})}`,color:i(t.sevenDay.percentUsed)})]}),(t.sevenDayOpus||t.sevenDaySonnet)&&y.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.sevenDayOpus&&y.jsx(h0,{percent:t.sevenDayOpus.percentUsed,label:e("usage.opusWeekly"),subtitle:e("usage.resetsAt",{time:AT(t.sevenDayOpus.resetAt)}),color:i(t.sevenDayOpus.percentUsed)}),t.sevenDaySonnet&&y.jsx(h0,{percent:t.sevenDaySonnet.percentUsed,label:e("usage.sonnetWeekly"),subtitle:e("usage.resetsAt",{time:AT(t.sevenDaySonnet.resetAt)}),color:i(t.sevenDaySonnet.percentUsed)})]})]})]})}const RT={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},dNe=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function fNe(){const{t:e}=Wt("common");return t=>{const r=new Date(t),i=new Date().getTime()-r.getTime(),s=Math.floor(i/1e3),o=Math.floor(s/60),a=Math.floor(o/60),l=Math.floor(a/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):a>0?a===1?e("time.hourAgo"):e("time.hoursAgo",{count:a}):o>0?o===1?e("time.minuteAgo"):e("time.minutesAgo",{count:o}):e("time.justNow")}}function hNe(){const{t:e}=Wt("common"),{t}=Wt("worktrees"),r=fNe(),{worktrees:n,summary:i,isLoading:s,isLoadingDetails:o,error:a,refetch:l}=sq(),u=oq(),[h,d]=T.useState(new Set),[p,v]=T.useState(!1),[w,_]=T.useState(!1),[m,x]=T.useState(!1),[b,S]=T.useState(null),[E,O]=T.useState(null),[k,R]=T.useState(!1),A=$=>{d(F=>{const W=new Set(F);return W.has($)?W.delete($):W.add($),W})},j=()=>{d(new Set)},B=T.useMemo(()=>h.size===0?n:n.filter($=>!!($.isOrphaned&&h.has("ORPHANED")||$.taskStatus&&h.has($.taskStatus))),[n,h]),L=T.useMemo(()=>n.filter($=>$.taskStatus==="DONE"||$.taskStatus==="CANCELED"),[n]),z=async()=>{if(L.length!==0){_(!0);try{for(const $ of L)await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:m});v(!1),l()}catch{}finally{_(!1)}}},D=async($,F)=>{S($.path);try{await u.mutateAsync({worktreePath:$.path,repoPath:$.repoPath,deleteLinkedTask:F}),O(null),l()}catch{}finally{S(null)}},V=$=>{$||(O(null),R(!1))},H=$=>{v($),$||x(!1)};return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[y.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:(i||n.length>0)&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:t("summary.total",{count:i?.total??n.length})}),(i?.orphaned??n.filter($=>$.isOrphaned).length)>0&&y.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:i?.orphaned??n.filter($=>$.isOrphaned).length})}),o?y.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):i?y.jsx("span",{children:i.totalSizeFormatted}):null]})}),y.jsxs("div",{className:"flex items-center gap-2",children:[L.length>0&&y.jsxs(Fc,{open:p,onOpenChange:H,children:[y.jsxs(Uc,{render:y.jsx(Ne,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:o}),children:[y.jsx(he,{icon:NV,size:12,strokeWidth:2}),t("cleanup.button",{count:L.length})]}),y.jsxs(Vc,{children:[y.jsxs(Wc,{children:[y.jsx(Gc,{children:t("cleanup.title")}),y.jsxs(Kc,{children:[t("cleanup.description",{count:L.length}),m&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(ya,{checked:m,onCheckedChange:$=>x($===!0),disabled:w}),t("cleanup.alsoDeleteLinkedTasks")]}),y.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),y.jsxs(qc,{children:[y.jsx(Yc,{disabled:w,children:e("buttons.cancel")}),y.jsxs(Ne,{variant:"destructive",onClick:z,disabled:w,className:"gap-2",children:[w&&y.jsx(he,{icon:sr,size:14,strokeWidth:2,className:"animate-spin"}),w?e("status.deleting"):t("delete.button",{count:L.length})]})]})]})]}),h.size>0&&y.jsxs(Ne,{variant:"ghost",size:"sm",onClick:j,className:"gap-1.5 text-xs",children:[y.jsx(he,{icon:Ji,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),y.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:dNe.map($=>{const F=h.has($);return y.jsx("button",{onClick:()=>A($),className:Le("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",F?RT[$]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${$}`)},$)})}),s&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(he,{icon:sr,className:"size-6 animate-spin text-muted-foreground"})}),a&&y.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:t("error.failedToLoad",{message:a.message})}),!s&&!a&&B.length===0&&y.jsx("div",{className:"py-12 text-center text-muted-foreground",children:h.size>0?t("empty.noMatch"):t("empty.noWorktrees")}),!s&&B.length>0&&y.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:B.map($=>{const F=$.sizeFormatted==="..."||$.branch==="...",W=!$.isOrphaned&&$.taskId,N=b===$.path;return y.jsx(Qi,{className:"transition-colors hover:border-border/80",children:y.jsxs(mp,{className:"flex items-start justify-between gap-4 py-4",children:[y.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"truncate font-medium",children:$.name}),$.isOrphaned?y.jsx(pl,{className:Le("shrink-0",RT.ORPHANED),children:e("statuses.ORPHANED")}):$.taskStatus?y.jsx(pl,{className:Le("shrink-0",RT[$.taskStatus]),children:e(`statuses.${$.taskStatus}`)}):null]}),y.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:pi,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{className:"truncate font-mono",children:$.path})]}),y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:i_,size:12,strokeWidth:2,className:"shrink-0"}),$.branch==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-16"}):y.jsx("span",{className:"font-mono",children:$.branch})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:$V,size:12,strokeWidth:2,className:"shrink-0"}),$.sizeFormatted==="..."?y.jsx("span",{className:"inline-block animate-pulse rounded bg-muted h-3 w-12"}):y.jsx("span",{children:$.sizeFormatted})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(he,{icon:IV,size:12,strokeWidth:2,className:"shrink-0"}),y.jsx("span",{children:r($.lastModified)})]})]}),$.taskId&&$.taskTitle&&y.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:y.jsxs(hi,{to:"/tasks/$taskId",params:{taskId:$.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[y.jsx("span",{className:"truncate",children:$.taskTitle}),y.jsx(he,{icon:Iv,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),y.jsxs(Fc,{open:E?.path===$.path,onOpenChange:V,children:[y.jsx(Uc,{render:y.jsx(Ne,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:F||N,onClick:()=>O($)}),children:y.jsx(he,{icon:N?sr:hp,size:14,strokeWidth:2,className:N?"animate-spin":""})}),y.jsxs(Vc,{children:[y.jsxs(Wc,{children:[y.jsx(Gc,{children:t("delete.title")}),y.jsxs(Kc,{children:[t("delete.description")," ",y.jsx("span",{className:"font-mono",children:$.name}),".",k&&W&&y.jsxs(y.Fragment,{children:[" ",t("delete.linkedTaskWillBeDeleted",{title:$.taskTitle})]})," ",t("delete.cannotUndo")]}),W&&y.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[y.jsx(ya,{checked:k,onCheckedChange:q=>R(q===!0),disabled:N}),t("delete.alsoDeleteLinkedTask",{title:$.taskTitle})]})]}),y.jsxs(qc,{children:[y.jsx(Yc,{disabled:N,children:e("buttons.cancel")}),y.jsxs(Ne,{variant:"destructive",onClick:()=>D($,k),disabled:N,className:"gap-2",children:[N&&y.jsx(he,{icon:sr,size:14,strokeWidth:2,className:"animate-spin"}),e(N?"status.deleting":"buttons.delete")]})]})]})]})]})},$.path)})})]})}function pNe(){const{t:e}=Wt("monitoring"),{data:t}=XW(),[r,n]=T.useState("system"),s=[{value:"system",label:e("tabs.system")},{value:"processes",label:e("tabs.processes")},{value:"claude",label:e("tabs.claude")},{value:"vibora",label:e("tabs.vibora"),devOnly:!0},{value:"worktrees",label:e("tabs.worktrees")},{value:"usage",label:e("tabs.usage")}].filter(o=>!o.devOnly||t?.enabled);return y.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[y.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-background px-4 py-2",children:[y.jsx("div",{className:"sm:hidden",children:y.jsxs(Ti,{value:r,onValueChange:o=>n(o),children:[y.jsx(Ri,{size:"sm",className:"w-auto gap-2",children:y.jsx(Ai,{})}),y.jsx(Pi,{children:s.map(o=>y.jsx(pr,{value:o.value,children:o.label},o.value))})]})}),y.jsx("div",{className:"hidden sm:block",children:y.jsx(Ic,{value:r,onValueChange:o=>n(o),children:y.jsx(Nc,{variant:"line",children:s.map(o=>y.jsx(ui,{value:o.value,className:"px-3 py-1.5",children:o.label},o.value))})})})]}),y.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r==="system"&&y.jsx(sNe,{}),r==="processes"&&y.jsx(oNe,{}),r==="claude"&&y.jsx(iNe,{}),r==="vibora"&&t?.enabled&&y.jsx(aNe,{}),r==="worktrees"&&y.jsx(hNe,{}),r==="usage"&&y.jsx(uNe,{})]})]})}const mNe=()=>`${window.location.protocol}//${window.location.hostname}:5173`,Um={activeTab:"diff",browserUrl:mNe(),diffOptions:{wrap:!0,ignoreWhitespace:!0,includeUntracked:!1,collapsedFiles:[]},filesViewState:{selectedFile:null,expandedDirs:[]}};function vS(e){const t=Cn(),r=T.useRef(void 0),n=T.useRef({}),{data:i}=qW(e),s=T.useMemo(()=>{const p=i?.viewState;return p?{activeTab:p.activeTab??Um.activeTab,browserUrl:p.browserUrl??Um.browserUrl,diffOptions:{...Um.diffOptions,...p.diffOptions},filesViewState:{...Um.filesViewState,...p.filesViewState}}:Um},[i?.viewState]),o=Yr({mutationFn:async p=>{const v=await fetch(`/api/tasks/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({viewState:p})});if(!v.ok)throw new Error("Failed to update view state");return v.json()},onSuccess:p=>{t.setQueryData(["tasks",e],p),t.setQueryData(["tasks"],v=>v&&v.map(w=>w.id===e?p:w))}}),a=T.useCallback(p=>{const v=n.current;n.current={...v,...p,diffOptions:p.diffOptions||v.diffOptions?{...v.diffOptions,...p.diffOptions}:void 0,filesViewState:p.filesViewState||v.filesViewState?{...v.filesViewState,...p.filesViewState}:void 0};const w=n.current,_={activeTab:w.activeTab??s.activeTab,browserUrl:w.browserUrl??s.browserUrl,diffOptions:{...s.diffOptions,...w.diffOptions},filesViewState:{...s.filesViewState,...w.filesViewState}};t.setQueryData(["tasks",e],m=>m&&{...m,viewState:_}),t.setQueryData(["tasks"],m=>m&&m.map(x=>x.id===e?{...x,viewState:_}:x)),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{o.mutate(_),n.current={}},500)},[t,e,s,o]),l=T.useCallback(p=>{a({activeTab:p})},[a]),u=T.useCallback(p=>{a({browserUrl:p})},[a]),h=T.useCallback(p=>{a({diffOptions:p})},[a]),d=T.useCallback(p=>{a({filesViewState:p})},[a]);return{viewState:s,setActiveTab:l,setBrowserUrl:u,setDiffOptions:h,setFilesViewState:d}}function gNe(e){const{viewState:t,setActiveTab:r}=vS(e);return{tab:t.activeTab,setTab:r}}function vNe(e){return Dr({queryKey:["linear-ticket",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/linear/ticket/${e}`);return t.ok?t.json():null},enabled:!!e,staleTime:300*1e3})}function MH({taskName:e,cwd:t,className:r,aiMode:n,description:i,startupScript:s,serverPort:o=7777}){const a=T.useRef(null),l=T.useRef(null),u=T.useRef(null),h=T.useRef(!1),d=T.useRef(!1),[p,v]=T.useState(null),[w,_]=T.useState(!1),[m,x]=T.useState(!1),[b,S]=T.useState(!1),{resolvedTheme:E}=ip(),O=E==="dark",k=O?EG:CG;T.useEffect(()=>{xt.taskTerminal.debug("cwd changed, resetting refs",{cwd:t}),h.current=!1,d.current=!1,v(null),_(!1)},[t]);const{setTerminalFocused:R}=Nj(),{terminals:A,terminalsLoaded:j,connected:B,createTerminal:L,attachXterm:z,resizeTerminal:D,setupImagePaste:V,writeToTerminal:H,consumePendingStartup:$}=iM(),F=T.useRef(z),W=T.useRef(V),N=T.useRef(H),q=T.useRef($);T.useEffect(()=>{F.current=z},[z]),T.useEffect(()=>{W.current=V},[V]),T.useEffect(()=>{N.current=H},[H]),T.useEffect(()=>{q.current=$},[$]);const I=p?A.find(J=>J.id===p):null,U=I?.status;T.useEffect(()=>{if(!a.current||l.current)return;const J=new xG.Terminal({cursorBlink:!0,fontSize:Math.round(13*gc),fontFamily:"JetBrains Mono Variable, Menlo, Monaco, monospace",lineHeight:1.2,theme:k}),re=new SG.FitAddon,X=new wG.WebLinksAddon;J.loadAddon(re),J.loadAddon(X),J.open(a.current),l.current=J,u.current=re,S(!0),requestAnimationFrame(()=>{re.fit()});const G=setTimeout(()=>{re.fit(),J.refresh(0,J.rows-1)},100),Z=()=>R(!0),te=()=>R(!1);return J.textarea&&(J.textarea.addEventListener("focus",Z),J.textarea.addEventListener("blur",te)),()=>{clearTimeout(G),J.textarea&&(J.textarea.removeEventListener("focus",Z),J.textarea.removeEventListener("blur",te)),R(!1),J.dispose(),l.current=null,u.current=null,S(!1)}},[R]);const Y=T.useCallback(()=>{if(!u.current||!l.current)return;u.current.fit();const{cols:J,rows:re}=l.current;p&&D(p,J,re)},[p,D]);T.useEffect(()=>{if(!a.current)return;const J=()=>{requestAnimationFrame(Y)};window.addEventListener("resize",J);const re=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{Y(),l.current&&l.current.refresh(0,l.current.rows-1)})};document.addEventListener("visibilitychange",re);const X=new ResizeObserver(J);X.observe(a.current);const G=new IntersectionObserver(Z=>{Z[0]?.isIntersecting&&requestAnimationFrame(()=>{Y(),l.current&&l.current.refresh(0,l.current.rows-1)})},{threshold:.1});return G.observe(a.current),()=>{window.removeEventListener("resize",J),document.removeEventListener("visibilitychange",re),X.disconnect(),G.disconnect()}},[Y]),T.useEffect(()=>{if(!B||!t||!b||!j)return;const J=A.find(re=>re.cwd===t);if(J){v(J.id);return}if(!h.current&&l.current){h.current=!0,_(!0);const{cols:re,rows:X}=l.current;L({name:e,cols:re,rows:X,cwd:t,startup:{startupScript:s,aiMode:n,description:i,taskName:e,serverPort:o}})}},[B,t,b,j,A,e,L]),T.useEffect(()=>{if(!t)return;const J=A.find(X=>X.cwd===t);if(!J)return;const re=p&&A.some(X=>X.id===p);(!p||!re)&&(xt.taskTerminal.debug("setting terminalId",{newId:J.id,prevId:p,reason:p?"tempId replaced":"initial",cwd:t,terminalCount:A.length}),v(J.id),_(!1),p&&!re&&(d.current=!1))},[A,t,p]),T.useEffect(()=>{if(xt.taskTerminal.debug("attach effect",{terminalId:p,hasTermRef:!!l.current,hasContainerRef:!!a.current,attachedRef:d.current}),!p||!l.current||!a.current||d.current)return;xt.taskTerminal.debug("attach effect passed guards, calling attachXterm",{terminalId:p});const J=G=>{requestAnimationFrame(Y);const Z=q.current(G);if(xt.taskTerminal.debug("onAttached checking pending startup",{terminalId:G,hasPendingStartup:!!Z}),Z){xt.taskTerminal.info("onAttached: running startup commands",{terminalId:G}),x(!0);const{startupScript:te,aiMode:ne,description:ie,taskName:me,serverPort:ye}=Z;te&&setTimeout(()=>{const ge=`source /dev/stdin <<'VIBORA_STARTUP'
|
|
113
113
|
${te}
|
|
114
114
|
VIBORA_STARTUP`;N.current(G,ge+"\r")},100);const ue=ye??7777,fe=ue!==7777?` --port=${ue}`:"",le=`You are working in a Vibora task worktree. Commit after completing each logical unit of work (feature, fix, refactor) to preserve progress. When you finish working and need user input, run: vibora current-task review${fe}. When linking a PR: vibora current-task pr <url>${fe}. For notifications: vibora notify "Title" "Message"${fe}.`,Ee=(ie?`${me}: ${ie}`:me).replace(/"/g,'\\"'),$e=le.replace(/"/g,'\\"'),ae=ne==="plan"?`claude "${Ee}" --append-system-prompt "${$e}" --session-id "${G}" --allow-dangerously-skip-permissions --permission-mode plan`:`claude "${Ee}" --append-system-prompt "${$e}" --session-id "${G}" --dangerously-skip-permissions`;setTimeout(()=>{xt.taskTerminal.debug("writing claude command to terminal",{terminalId:G,taskCommand:ae.substring(0,50)+"..."}),N.current(G,ae+"\r"),x(!1)},te?5e3:100)}},re=F.current(p,l.current,{onAttached:J}),X=W.current(a.current,p);return d.current=!0,xt.taskTerminal.debug("attachedRef set to true",{terminalId:p}),()=>{xt.taskTerminal.debug("cleanup running, setting attachedRef to false",{terminalId:p}),re(),X(),d.current=!1}},[p,Y]),T.useEffect(()=>{l.current&&(l.current.options.theme=k)},[k]);const Q=T.useCallback(J=>{p&&N.current(p,J)},[p]);return t?y.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[!B&&y.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:"Connecting to terminal server..."}),U==="error"&&y.jsx("div",{className:"shrink-0 px-2 py-1 bg-destructive/20 text-destructive text-xs",children:"Terminal failed to start. The worktree directory may not exist."}),U==="exited"&&y.jsxs("div",{className:"shrink-0 px-2 py-1 bg-muted text-muted-foreground text-xs",children:["Terminal exited (code: ",I?.exitCode,")"]}),y.jsxs("div",{className:"relative min-h-0 flex-1",children:[y.jsx("div",{ref:a,className:Le("h-full w-full overflow-hidden p-2 bg-terminal-background",r)}),w&&!p&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-terminal-background",children:y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx(he,{icon:sr,size:24,strokeWidth:2,className:Le("animate-spin",O?"text-white/50":"text-black/50")}),y.jsx("span",{className:Le("font-mono text-sm",O?"text-white/50":"text-black/50"),children:"Initializing terminal..."})]})}),m&&y.jsx("div",{className:"pointer-events-auto absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx(he,{icon:sr,size:24,strokeWidth:2,className:Le("animate-spin",O?"text-white/60":"text-black/60")}),y.jsx("span",{className:Le("font-mono text-sm",O?"text-white/60":"text-black/60"),children:"Starting Claude Code..."})]})}),y.jsx("button",{onClick:()=>l.current?.scrollToBottom(),className:Le("absolute top-2 right-5 p-1 transition-colors",O?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:y.jsx(he,{icon:pj,size:20,strokeWidth:2})})]}),y.jsx(Jj,{onSend:Q})]}):y.jsx("div",{className:Le("flex h-full items-center justify-center text-muted-foreground text-sm bg-terminal-background",r),children:"No worktree path configured for this task"})}function yNe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),r===!1||!i.defaultPrevented)return t?.(i)}}function bNe(e,t=[]){let r=[];function n(s,o){const a=T.createContext(o),l=r.length;r=[...r,o];const u=d=>{const{scope:p,children:v,...w}=d,_=p?.[e]?.[l]||a,m=T.useMemo(()=>w,Object.values(w));return y.jsx(_.Provider,{value:m,children:v})};u.displayName=s+"Provider";function h(d,p){const v=p?.[e]?.[l]||a,w=T.useContext(v);if(w)return w;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[u,h]}const i=()=>{const s=r.map(o=>T.createContext(o));return function(a){const l=a?.[e]||s;return T.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[n,_Ne(i,...t)]}function _Ne(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=n.reduce((a,{useScope:l,scopeName:u})=>{const d=l(s)[`__scope${u}`];return{...a,...d}},{});return T.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}var xv=globalThis?.document?T.useLayoutEffect:()=>{},xNe=M1[" useInsertionEffect ".trim().toString()]||xv;function SNe({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[i,s,o]=wNe({defaultProp:t,onChange:r}),a=e!==void 0,l=a?e:i;{const h=T.useRef(e!==void 0);T.useEffect(()=>{const d=h.current;d!==a&&console.warn(`${n} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=a},[a,n])}const u=T.useCallback(h=>{if(a){const d=CNe(h)?h(e):h;d!==e&&o.current?.(d)}else s(h)},[a,e,s,o]);return[l,u]}function wNe({defaultProp:e,onChange:t}){const[r,n]=T.useState(e),i=T.useRef(r),s=T.useRef(t);return xNe(()=>{s.current=t},[t]),T.useEffect(()=>{i.current!==r&&(s.current?.(r),i.current=r)},[r,i]),[r,n,s]}function CNe(e){return typeof e=="function"}function LH(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rZ(...e){return t=>{let r=!1;const n=e.map(i=>{const s=LH(i,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let i=0;i<n.length;i++){const s=n[i];typeof s=="function"?s():LH(e[i],null)}}}}function nZ(...e){return T.useCallback(rZ(...e),e)}function ENe(e){const t=ONe(e),r=T.forwardRef((n,i)=>{const{children:s,...o}=n,a=T.Children.toArray(s),l=a.find(TNe);if(l){const u=l.props.children,h=a.map(d=>d===l?T.Children.count(u)>1?T.Children.only(null):T.isValidElement(u)?u.props.children:null:d);return y.jsx(t,{...o,ref:i,children:T.isValidElement(u)?T.cloneElement(u,void 0,h):null})}return y.jsx(t,{...o,ref:i,children:s})});return r.displayName=`${e}.Slot`,r}function ONe(e){const t=T.forwardRef((r,n)=>{const{children:i,...s}=r;if(T.isValidElement(i)){const o=RNe(i),a=ANe(s,i.props);return i.type!==T.Fragment&&(a.ref=n?rZ(n,o):o),T.cloneElement(i,a)}return T.Children.count(i)>1?T.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var kNe=Symbol("radix.slottable");function TNe(e){return T.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kNe}function ANe(e,t){const r={...t};for(const n in t){const i=e[n],s=t[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(r[n]=i):n==="style"?r[n]={...i,...s}:n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return{...e,...r}}function RNe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var PNe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],uL=PNe.reduce((e,t)=>{const r=ENe(`Primitive.${t}`),n=T.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function jNe(e,t){return T.useReducer((r,n)=>t[r][n]??r,e)}var iZ=e=>{const{present:t,children:r}=e,n=MNe(t),i=typeof r=="function"?r({present:n.isPresent}):T.Children.only(r),s=nZ(n.ref,LNe(i));return typeof r=="function"||n.isPresent?T.cloneElement(i,{ref:s}):null};iZ.displayName="Presence";function MNe(e){const[t,r]=T.useState(),n=T.useRef(null),i=T.useRef(e),s=T.useRef("none"),o=e?"mounted":"unmounted",[a,l]=jNe(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const u=p0(n.current);s.current=a==="mounted"?u:"none"},[a]),xv(()=>{const u=n.current,h=i.current;if(h!==e){const p=s.current,v=p0(u);e?l("MOUNT"):v==="none"||u?.display==="none"?l("UNMOUNT"):l(h&&p!==v?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),xv(()=>{if(t){let u;const h=t.ownerDocument.defaultView??window,d=v=>{const _=p0(n.current).includes(CSS.escape(v.animationName));if(v.target===t&&_&&(l("ANIMATION_END"),!i.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",u=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},p=v=>{v.target===t&&(s.current=p0(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{h.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:T.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function p0(e){return e?.animationName||"none"}function LNe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var DNe=M1[" useId ".trim().toString()]||(()=>{}),INe=0;function NNe(e){const[t,r]=T.useState(DNe());return xv(()=>{r(n=>n??String(INe++))},[e]),e||(t?`radix-${t}`:"")}var yS="Collapsible",[BNe]=bNe(yS),[$Ne,dL]=BNe(yS),sZ=T.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:n,defaultOpen:i,disabled:s,onOpenChange:o,...a}=e,[l,u]=SNe({prop:n,defaultProp:i??!1,onChange:o,caller:yS});return y.jsx($Ne,{scope:r,disabled:s,contentId:NNe(),open:l,onOpenToggle:T.useCallback(()=>u(h=>!h),[u]),children:y.jsx(uL.div,{"data-state":hL(l),"data-disabled":s?"":void 0,...a,ref:t})})});sZ.displayName=yS;var oZ="CollapsibleTrigger",aZ=T.forwardRef((e,t)=>{const{__scopeCollapsible:r,...n}=e,i=dL(oZ,r);return y.jsx(uL.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":hL(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...n,ref:t,onClick:yNe(e.onClick,i.onOpenToggle)})});aZ.displayName=oZ;var fL="CollapsibleContent",lZ=T.forwardRef((e,t)=>{const{forceMount:r,...n}=e,i=dL(fL,e.__scopeCollapsible);return y.jsx(iZ,{present:r||i.open,children:({present:s})=>y.jsx(zNe,{...n,ref:t,present:s})})});lZ.displayName=fL;var zNe=T.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:n,children:i,...s}=e,o=dL(fL,r),[a,l]=T.useState(n),u=T.useRef(null),h=nZ(t,u),d=T.useRef(0),p=d.current,v=T.useRef(0),w=v.current,_=o.open||a,m=T.useRef(_),x=T.useRef(void 0);return T.useEffect(()=>{const b=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(b)},[]),xv(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();d.current=S.height,v.current=S.width,m.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(n)}},[o.open,n]),y.jsx(uL.div,{"data-state":hL(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!_,...s,ref:h,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:_&&i})});function hL(e){return e?"open":"closed"}var HNe=sZ;const FNe=HNe,UNe=aZ,VNe=lZ;function WNe(e){const{viewState:t,setDiffOptions:r}=vS(e),{collapsedFiles:n}=t.diffOptions,i=T.useCallback(l=>{const u=n.includes(l);r({collapsedFiles:u?n.filter(h=>h!==l):[...n,l]})},[n,r]),s=T.useCallback(l=>{r({collapsedFiles:l})},[r]),o=T.useCallback(()=>{r({collapsedFiles:[]})},[r]),a=T.useCallback(l=>n.includes(l),[n]);return{options:t.diffOptions,setOption:(l,u)=>{r({[l]:u})},setOptions:r,toggleFileCollapse:i,collapseAll:s,expandAll:o,isFileCollapsed:a}}function qNe(e){const t=[];let r=null,n=0,i=0;for(const s of e.split(`
|
|
115
115
|
`))if(s.startsWith("diff --git"))r={path:s.match(/diff --git a\/(.+?) b\//)?.[1]??"unknown",lines:[],additions:0,deletions:0},t.push(r),r.lines.push({type:"header",content:s});else if(s.startsWith("index ")||s.startsWith("---")||s.startsWith("+++"))r?.lines.push({type:"header",content:s});else if(s.startsWith("@@")){const o=s.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);o&&(n=parseInt(o[1],10),i=parseInt(o[2],10)),r?.lines.push({type:"hunk",content:s})}else s.startsWith("+")?r&&(r.additions++,r.lines.push({type:"added",content:s.slice(1),newLineNumber:i++})):s.startsWith("-")?r&&(r.deletions++,r.lines.push({type:"removed",content:s.slice(1),oldLineNumber:n++})):s.startsWith(" ")&&r?.lines.push({type:"context",content:s.slice(1),oldLineNumber:n++,newLineNumber:i++});return t}function GNe({file:e,wrap:t,isCollapsed:r,onToggle:n}){return y.jsxs(FNe,{open:!r,onOpenChange:()=>n(),children:[y.jsx(UNe,{asChild:!0,children:y.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 bg-card border-b border-border cursor-pointer hover:bg-muted select-none",children:[y.jsx(he,{icon:r?Iv:Dv,size:12,strokeWidth:2,className:"text-muted-foreground shrink-0"}),y.jsx("span",{className:"font-mono text-xs text-foreground truncate flex-1",children:e.path}),y.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[e.additions>0&&y.jsxs("span",{className:"text-accent",children:["+",e.additions]}),e.additions>0&&e.deletions>0&&" ",e.deletions>0&&y.jsxs("span",{className:"text-destructive",children:["-",e.deletions]})]})]})}),y.jsx(VNe,{children:y.jsx("div",{className:"font-mono text-xs",children:e.lines.slice(1).map((i,s)=>y.jsxs("div",{className:Le("flex px-2 py-0.5",i.type==="added"&&"bg-accent/10",i.type==="removed"&&"bg-destructive/10",i.type==="header"&&"bg-muted/50 text-muted-foreground",i.type==="hunk"&&"bg-accent/10 text-accent"),children:[(i.type==="added"||i.type==="removed"||i.type==="context")&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.oldLineNumber??""}),y.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.newLineNumber??""})]}),y.jsxs("span",{className:Le("w-4 shrink-0 select-none text-center",i.type==="added"&&"text-accent",i.type==="removed"&&"text-destructive"),children:[i.type==="added"&&"+",i.type==="removed"&&"-"]}),y.jsx("span",{className:Le("flex-1",t?"whitespace-pre-wrap break-all":"whitespace-pre",i.type==="added"&&"text-accent",i.type==="removed"&&"text-destructive"),children:i.content})]},s))})})]})}function DH({taskId:e,worktreePath:t}){const{options:r,setOption:n,toggleFileCollapse:i,collapseAll:s,expandAll:o,isFileCollapsed:a}=WNe(e),{wrap:l,ignoreWhitespace:u,includeUntracked:h,collapsedFiles:d}=r,{data:p,isLoading:v,error:w}=rhe(t,{ignoreWhitespace:u,includeUntracked:h}),_=T.useMemo(()=>p?.diff?qNe(p.diff):[],[p?.diff]),m=T.useMemo(()=>_.map(S=>S.path),[_]),x=_.length>0&&d.length===_.length;if(T.useEffect(()=>{const S=E=>{if(E.shiftKey&&E.key==="C"&&!E.ctrlKey&&!E.metaKey&&!E.altKey){const O=E.target;if(O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.isContentEditable)return;E.preventDefault(),x?o():s(m)}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[x,m,s,o]),!t)return y.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"No worktree selected"});if(v)return y.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading diff..."});if(w)return y.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:w.message});const b=p?.files?.some(S=>S.status==="untracked")??!1;return _.length===0?y.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-muted-foreground text-sm gap-2",children:[y.jsx("p",{children:"No changes detected"}),p?.files&&p.files.length>0&&y.jsxs("div",{className:"text-xs",children:[y.jsx("p",{className:"text-center mb-2",children:"Modified files:"}),y.jsxs("div",{className:"flex flex-col gap-1",children:[p.files.map(S=>y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("span",{className:Le("w-4 text-center",S.status==="added"&&"text-accent",S.status==="deleted"&&"text-destructive",S.status==="modified"&&"text-muted-foreground",S.status==="untracked"&&"text-muted-foreground"),children:[S.status==="added"&&"A",S.status==="deleted"&&"D",S.status==="modified"&&"M",S.status==="untracked"&&"?"]}),y.jsx("span",{children:S.path})]},S.path)),b&&y.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-muted-foreground hover:text-foreground mt-1",children:[y.jsx("input",{type:"checkbox",checked:h,onChange:S=>n("includeUntracked",S.target.checked),className:"w-4 h-3"}),y.jsx("span",{children:"Show untracked files"})]})]})]})]}):y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-card border-b border-border text-xs",children:[p?.branch&&y.jsxs("span",{className:"text-muted-foreground",children:[p.branch,p.isBranchDiff&&y.jsx("span",{className:"opacity-70",children:" (vs master)"})]}),y.jsx("div",{className:"flex-1"}),y.jsxs("button",{onClick:()=>x?o():s(m),className:"flex items-center gap-1 px-1.5 py-0.5 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:x?"Expand all (Shift+C)":"Collapse all (Shift+C)",children:[y.jsx(he,{icon:x?UV:zV,size:12,strokeWidth:2}),y.jsx("span",{className:"hidden sm:inline",children:x?"Expand":"Collapse"})]}),y.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[y.jsx("input",{type:"checkbox",checked:l,onChange:S=>n("wrap",S.target.checked),className:"w-3 h-3"}),"Wrap"]}),y.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[y.jsx("input",{type:"checkbox",checked:u,onChange:S=>n("ignoreWhitespace",S.target.checked),className:"w-3 h-3"}),"Ignore whitespace"]}),y.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[y.jsx("input",{type:"checkbox",checked:h,onChange:S=>n("includeUntracked",S.target.checked),className:"w-3 h-3"}),"Untracked"]})]}),y.jsx(bh,{className:"flex-1 min-h-0",children:_.map(S=>y.jsx(GNe,{file:S,wrap:l,isCollapsed:a(S.path),onToggle:()=>i(S.path)},S.path))})]})}function KNe(e){const{viewState:t,setBrowserUrl:r}=vS(e);return{url:t.browserUrl,setUrl:r}}function IH({taskId:e}){const{url:t,setUrl:r}=KNe(e),[n,i]=T.useState(t),[s,o]=T.useState(0);T.useEffect(()=>{i(t)},[t]);const a=T.useCallback(()=>{o(u=>u+1)},[]),l=T.useCallback(u=>{u.preventDefault();let h=n.trim();!h.startsWith("http://")&&!h.startsWith("https://")&&(h=`http://${h}`),r(h),o(d=>d+1)},[n,r]);return y.jsxs("div",{className:"flex h-full flex-col bg-background",children:[y.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card px-2 py-1.5",children:[y.jsx(Ne,{variant:"ghost",size:"icon-xs",disabled:!0,children:y.jsx(he,{icon:LV,size:14,strokeWidth:2})}),y.jsx(Ne,{variant:"ghost",size:"icon-xs",disabled:!0,children:y.jsx(he,{icon:Iv,size:14,strokeWidth:2})}),y.jsx(Ne,{variant:"ghost",size:"icon-xs",onClick:a,children:y.jsx(he,{icon:Sce,size:14,strokeWidth:2})}),y.jsx("form",{onSubmit:l,className:"flex-1",children:y.jsx(qt,{value:n,onChange:u=>i(u.target.value),className:"h-7 bg-background text-xs",placeholder:"Enter URL..."})})]}),y.jsx("div",{className:"flex-1 overflow-hidden bg-card",children:y.jsx("iframe",{src:t,className:"h-full w-full border-0",title:"Browser Preview",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},s)})]})}function YNe(e){const{viewState:t,setFilesViewState:r}=vS(e),n=t.filesViewState??{selectedFile:null,expandedDirs:[]},i=T.useCallback(a=>{r({selectedFile:a})},[r]),s=T.useCallback(a=>{const u=n.expandedDirs.includes(a)?n.expandedDirs.filter(h=>h!==a):[...n.expandedDirs,a];r({expandedDirs:u})},[n.expandedDirs,r]),o=T.useCallback(()=>{r({expandedDirs:[]})},[r]);return{selectedFile:n.selectedFile,expandedDirs:n.expandedDirs,setSelectedFile:i,toggleDir:s,collapseAll:o}}function XNe(e){const t=e.split(".").pop()?.toLowerCase()||"";return["png","jpg","jpeg","gif","svg","webp","ico"].includes(t)?mce:["ts","tsx","js","jsx","json","css","html","md","yaml","yml","toml","sh","py","rs","go","sql"].includes(t)?cce:uce}function cZ({entry:e,depth:t,selectedFile:r,expandedDirs:n,onSelectFile:i,onToggleDir:s}){const o=n.includes(e.path),a=r===e.path,l=e.type==="directory",u=T.useCallback(()=>{l?s(e.path):i(e.path)},[l,e.path,i,s]);return y.jsxs("div",{children:[y.jsxs("div",{className:Le("flex items-center gap-1.5 px-2 py-0.5 cursor-pointer text-sm hover:bg-muted/50",a&&"bg-primary/10 text-primary"),style:{paddingLeft:`${t*12+8}px`},onClick:u,children:[y.jsx(he,{icon:l?o?_A:pi:XNe(e.name),size:14,strokeWidth:2,className:Le("shrink-0",l?"text-accent":"text-muted-foreground")}),y.jsx("span",{className:"break-all",children:e.name})]}),l&&o&&e.children&&y.jsx("div",{children:e.children.map(h=>y.jsx(cZ,{entry:h,depth:t+1,selectedFile:r,expandedDirs:n,onSelectFile:i,onToggleDir:s},h.path))})]})}function NH({entries:e,selectedFile:t,expandedDirs:r,onSelectFile:n,onToggleDir:i,onCollapseAll:s}){return e.length===0?y.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"No files"}):y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1 border-b border-border bg-card",children:[y.jsx("span",{className:"text-xs text-muted-foreground",children:"Files"}),y.jsx("button",{onClick:s,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Collapse all",children:y.jsx(he,{icon:zV,size:14,strokeWidth:2})})]}),y.jsx("div",{className:"py-1 flex-1 overflow-auto",children:e.map(o=>y.jsx(cZ,{entry:o,depth:0,selectedFile:t,expandedDirs:r,onSelectFile:n,onToggleDir:i},o.path))})]})}const QNe="modulepreload",ZNe=function(e){return"/"+e},BH={},oe=function(t,r,n){let i=Promise.resolve();if(r&&r.length>0){let u=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};var o=u;document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");i=u(r.map(h=>{if(h=ZNe(h),h in BH)return;BH[h]=!0;const d=h.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":QNe,d||(v.as="script"),v.crossOrigin="",v.href=h,l&&v.setAttribute("nonce",l),document.head.appendChild(v),d)return new Promise((w,_)=>{v.addEventListener("load",w),v.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&s(l.reason);return t().catch(s)})};let Sn=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function JNe(e){return pL(e)}function pL(e){return Array.isArray(e)?e3e(e):e instanceof RegExp?e:typeof e=="object"?t3e(e):e}function e3e(e){let t=[];for(let r=0,n=e.length;r<n;r++)t[r]=pL(e[r]);return t}function t3e(e){let t={};for(let r in e)t[r]=pL(e[r]);return t}function uZ(e,...t){return t.forEach(r=>{for(let n in r)e[n]=r[n]}),e}function dZ(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?dZ(e.substring(0,e.length-1)):e.substr(~t+1)}var PT=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,m0=class{static hasCaptures(e){return e===null?!1:(PT.lastIndex=0,PT.test(e))}static replaceCaptures(e,t,r){return e.replace(PT,(n,i,s,o)=>{let a=r[parseInt(i||s,10)];if(a){let l=t.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(o){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return n})}};function fZ(e,t){return e<t?-1:e>t?1:0}function hZ(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let r=e.length,n=t.length;if(r===n){for(let i=0;i<r;i++){let s=fZ(e[i],t[i]);if(s!==0)return s}return 0}return r-n}function $H(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function pZ(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var mZ=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},w1=class{constructor(e,t,r){this._colorMap=e,this._defaults=t,this._root=r}static createFromRawTheme(e,t){return this.createFromParsedTheme(i3e(e),t)}static createFromParsedTheme(e,t){return o3e(e,t)}_cachedMatchRoot=new mZ(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,n=this._cachedMatchRoot.get(t).find(i=>r3e(e.parent,i.parentScopes));return n?new gZ(n.fontStyle,n.foreground,n.background):null}},jT=class P0{constructor(t,r){this.parent=t,this.scopeName=r}static push(t,r){for(const n of r)t=new P0(t,n);return t}static from(...t){let r=null;for(let n=0;n<t.length;n++)r=new P0(r,t[n]);return r}push(t){return new P0(this,t)}getSegments(){let t=this;const r=[];for(;t;)r.push(t.scopeName),t=t.parent;return r.reverse(),r}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const r=[];let n=this;for(;n&&n!==t;)r.push(n.scopeName),n=n.parent;return n===t?r.reverse():void 0}};function r3e(e,t){if(t.length===0)return!0;for(let r=0;r<t.length;r++){let n=t[r],i=!1;if(n===">"){if(r===t.length-1)return!1;n=t[++r],i=!0}for(;e&&!n3e(e.scopeName,n);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function n3e(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var gZ=class{constructor(e,t,r){this.fontStyle=e,this.foregroundId=t,this.backgroundId=r}};function i3e(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,r=[],n=0;for(let i=0,s=t.length;i<s;i++){let o=t[i];if(!o.settings)continue;let a;if(typeof o.scope=="string"){let d=o.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),a=d.split(",")}else Array.isArray(o.scope)?a=o.scope:a=[""];let l=-1;if(typeof o.settings.fontStyle=="string"){l=0;let d=o.settings.fontStyle.split(" ");for(let p=0,v=d.length;p<v;p++)switch(d[p]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof o.settings.foreground=="string"&&$H(o.settings.foreground)&&(u=o.settings.foreground);let h=null;typeof o.settings.background=="string"&&$H(o.settings.background)&&(h=o.settings.background);for(let d=0,p=a.length;d<p;d++){let w=a[d].trim().split(" "),_=w[w.length-1],m=null;w.length>1&&(m=w.slice(0,w.length-1),m.reverse()),r[n++]=new s3e(_,m,i,l,u,h)}}return r}var s3e=class{constructor(e,t,r,n,i,s){this.scope=e,this.parentScopes=t,this.index=r,this.fontStyle=n,this.foreground=i,this.background=s}},fi=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(fi||{});function o3e(e,t){e.sort((l,u)=>{let h=fZ(l.scope,u.scope);return h!==0||(h=hZ(l.parentScopes,u.parentScopes),h!==0)?h:l.index-u.index});let r=0,n="#000000",i="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(r=l.fontStyle),l.foreground!==null&&(n=l.foreground),l.background!==null&&(i=l.background)}let s=new a3e(t),o=new gZ(r,s.getId(n),s.getId(i)),a=new c3e(new mP(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let h=e[l];a.insert(0,h.scope,h.parentScopes,h.fontStyle,s.getId(h.foreground),s.getId(h.background))}return new w1(s,o,a)}var a3e=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,r=e.length;t<r;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},l3e=Object.freeze([]),mP=class vZ{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,r,n,i,s){this.scopeDepth=t,this.parentScopes=r||l3e,this.fontStyle=n,this.foreground=i,this.background=s}clone(){return new vZ(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let r=[];for(let n=0,i=t.length;n<i;n++)r[n]=t[n].clone();return r}acceptOverwrite(t,r,n,i){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,r!==-1&&(this.fontStyle=r),n!==0&&(this.foreground=n),i!==0&&(this.background=i)}},c3e=class gP{constructor(t,r=[],n={}){this._mainRule=t,this._children=n,this._rulesWithParentScopes=r}_rulesWithParentScopes;static _cmpBySpecificity(t,r){if(t.scopeDepth!==r.scopeDepth)return r.scopeDepth-t.scopeDepth;let n=0,i=0;for(;t.parentScopes[n]===">"&&n++,r.parentScopes[i]===">"&&i++,!(n>=t.parentScopes.length||i>=r.parentScopes.length);){const s=r.parentScopes[i].length-t.parentScopes[n].length;if(s!==0)return s;n++,i++}return r.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let n=t.indexOf("."),i,s;if(n===-1?(i=t,s=""):(i=t.substring(0,n),s=t.substring(n+1)),this._children.hasOwnProperty(i))return this._children[i].match(s)}const r=this._rulesWithParentScopes.concat(this._mainRule);return r.sort(gP._cmpBySpecificity),r}insert(t,r,n,i,s,o){if(r===""){this._doInsertHere(t,n,i,s,o);return}let a=r.indexOf("."),l,u;a===-1?(l=r,u=""):(l=r.substring(0,a),u=r.substring(a+1));let h;this._children.hasOwnProperty(l)?h=this._children[l]:(h=new gP(this._mainRule.clone(),mP.cloneArr(this._rulesWithParentScopes)),this._children[l]=h),h.insert(t+1,u,n,i,s,o)}_doInsertHere(t,r,n,i,s){if(r===null){this._mainRule.acceptOverwrite(t,n,i,s);return}for(let o=0,a=this._rulesWithParentScopes.length;o<a;o++){let l=this._rulesWithParentScopes[o];if(hZ(l.parentScopes,r)===0){l.acceptOverwrite(t,n,i,s);return}}n===-1&&(n=this._mainRule.fontStyle),i===0&&(i=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new mP(t,r,n,i,s))}},rp=class Gs{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const r=Gs.getLanguageId(t),n=Gs.getTokenType(t),i=Gs.getFontStyle(t),s=Gs.getForeground(t),o=Gs.getBackground(t);console.log({languageId:r,tokenType:n,fontStyle:i,foreground:s,background:o})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,r,n,i,s,o,a){let l=Gs.getLanguageId(t),u=Gs.getTokenType(t),h=Gs.containsBalancedBrackets(t)?1:0,d=Gs.getFontStyle(t),p=Gs.getForeground(t),v=Gs.getBackground(t);return r!==0&&(l=r),n!==8&&(u=n),i!==null&&(h=i?1:0),s!==-1&&(d=s),o!==0&&(p=o),a!==0&&(v=a),(l<<0|u<<8|h<<10|d<<11|p<<15|v<<24)>>>0}};function C1(e,t){const r=[],n=u3e(e);let i=n.next();for(;i!==null;){let l=0;if(i.length===2&&i.charAt(1)===":"){switch(i.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=n.next()}let u=o();if(r.push({matcher:u,priority:l}),i!==",")break;i=n.next()}return r;function s(){if(i==="-"){i=n.next();const l=s();return u=>!!l&&!l(u)}if(i==="("){i=n.next();const l=a();return i===")"&&(i=n.next()),l}if(zH(i)){const l=[];do l.push(i),i=n.next();while(zH(i));return u=>t(l,u)}return null}function o(){const l=[];let u=s();for(;u;)l.push(u),u=s();return h=>l.every(d=>d(h))}function a(){const l=[];let u=o();for(;u&&(l.push(u),i==="|"||i===",");){do i=n.next();while(i==="|"||i===",");u=o()}return h=>l.some(d=>d(h))}}function zH(e){return!!e&&!!e.match(/[\w\.:]+/)}function u3e(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,r=t.exec(e);return{next:()=>{if(!r)return null;const n=r[0];return r=t.exec(e),n}}}function yZ(e){typeof e.dispose=="function"&&e.dispose()}var Sv=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},d3e=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},f3e=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},h3e=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Sv(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new f3e;for(const r of e)p3e(r,this.initialScopeName,this.repo,t);for(const r of t.references)if(r instanceof Sv){if(this.seenFullScopeRequests.has(r.scopeName))continue;this.seenFullScopeRequests.add(r.scopeName),this.Q.push(r)}else{if(this.seenFullScopeRequests.has(r.scopeName)||this.seenPartialScopeRequests.has(r.toKey()))continue;this.seenPartialScopeRequests.add(r.toKey()),this.Q.push(r)}}};function p3e(e,t,r,n){const i=r.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const s=r.lookup(t);e instanceof Sv?j0({baseGrammar:s,selfGrammar:i},n):vP(e.ruleName,{baseGrammar:s,selfGrammar:i,repository:i.repository},n);const o=r.injections(e.scopeName);if(o)for(const a of o)n.add(new Sv(a))}function vP(e,t,r){if(t.repository&&t.repository[e]){const n=t.repository[e];E1([n],t,r)}}function j0(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&E1(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&E1(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function E1(e,t,r){for(const n of e){if(r.visitedRule.has(n))continue;r.visitedRule.add(n);const i=n.repository?uZ({},t.repository,n.repository):t.repository;Array.isArray(n.patterns)&&E1(n.patterns,{...t,repository:i},r);const s=n.include;if(!s)continue;const o=bZ(s);switch(o.kind){case 0:j0({...t,selfGrammar:t.baseGrammar},r);break;case 1:j0(t,r);break;case 2:vP(o.ruleName,{...t,repository:i},r);break;case 3:case 4:const a=o.scopeName===t.selfGrammar.scopeName?t.selfGrammar:o.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){const l={baseGrammar:t.baseGrammar,selfGrammar:a,repository:i};o.kind===4?vP(o.ruleName,l,r):j0(l,r)}else o.kind===4?r.add(new d3e(o.scopeName,o.ruleName)):r.add(new Sv(o.scopeName));break}}}var m3e=class{kind=0},g3e=class{kind=1},v3e=class{constructor(e){this.ruleName=e}kind=2},y3e=class{constructor(e){this.scopeName=e}kind=3},b3e=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function bZ(e){if(e==="$base")return new m3e;if(e==="$self")return new g3e;const t=e.indexOf("#");if(t===-1)return new y3e(e);if(t===0)return new v3e(e.substring(1));{const r=e.substring(0,t),n=e.substring(t+1);return new b3e(r,n)}}var _3e=/\\(\d+)/,HH=/\\(\d+)/g,x3e=-1,_Z=-2;var cy=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,r,n){this.$location=e,this.id=t,this._name=r||null,this._nameIsCapturing=m0.hasCaptures(this._name),this._contentName=n||null,this._contentNameIsCapturing=m0.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${dZ(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:m0.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:m0.replaceCaptures(this._contentName,e,t)}},S3e=class extends cy{retokenizeCapturedWithRuleId;constructor(e,t,r,n,i){super(e,t,r,n),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,r,n){throw new Error("Not supported!")}},w3e=class extends cy{_match;captures;_cachedCompiledPatterns;constructor(e,t,r,n,i){super(e,t,r,null),this._match=new wv(n,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Cv,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},FH=class extends cy{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,r,n,i){super(e,t,r,n),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const r of this.patterns)e.getRule(r).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Cv,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},yP=class extends cy{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,r,n,i,s,o,a,l,u){super(e,t,r,n),this._begin=new wv(i,this.id),this.beginCaptures=s,this._end=new wv(o||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e,t).compileAG(e,r,n)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Cv;for(const r of this.patterns)e.getRule(r).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},O1=class extends cy{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,r,n,i,s,o,a,l){super(e,t,r,n),this._begin=new wv(i,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new wv(o,_Z),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Cv;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,r,n){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,r,n)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Cv,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},xZ=class li{static createCaptureRule(t,r,n,i,s){return t.registerRule(o=>new S3e(r,o,n,i,s))}static getCompiledRuleId(t,r,n){return t.id||r.registerRule(i=>{if(t.id=i,t.match)return new w3e(t.$vscodeTextmateLocation,t.id,t.name,t.match,li._compileCaptures(t.captures,r,n));if(typeof t.begin>"u"){t.repository&&(n=uZ({},n,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new FH(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,li._compilePatterns(s,r,n))}return t.while?new O1(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,li._compileCaptures(t.beginCaptures||t.captures,r,n),t.while,li._compileCaptures(t.whileCaptures||t.captures,r,n),li._compilePatterns(t.patterns,r,n)):new yP(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,li._compileCaptures(t.beginCaptures||t.captures,r,n),t.end,li._compileCaptures(t.endCaptures||t.captures,r,n),t.applyEndPatternLast,li._compilePatterns(t.patterns,r,n))}),t.id}static _compileCaptures(t,r,n){let i=[];if(t){let s=0;for(const o in t){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);a>s&&(s=a)}for(let o=0;o<=s;o++)i[o]=null;for(const o in t){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);let l=0;t[o].patterns&&(l=li.getCompiledRuleId(t[o],r,n)),i[a]=li.createCaptureRule(r,t[o].$vscodeTextmateLocation,t[o].name,t[o].contentName,l)}}return i}static _compilePatterns(t,r,n){let i=[];if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s];let l=-1;if(a.include){const u=bZ(a.include);switch(u.kind){case 0:case 1:l=li.getCompiledRuleId(n[a.include],r,n);break;case 2:let h=n[u.ruleName];h&&(l=li.getCompiledRuleId(h,r,n));break;case 3:case 4:const d=u.scopeName,p=u.kind===4?u.ruleName:null,v=r.getExternalGrammar(d,n);if(v)if(p){let w=v.repository[p];w&&(l=li.getCompiledRuleId(w,r,v.repository))}else l=li.getCompiledRuleId(v.repository.$self,r,v.repository);break}}else l=li.getCompiledRuleId(a,r,n);if(l!==-1){const u=r.getRule(l);let h=!1;if((u instanceof FH||u instanceof yP||u instanceof O1)&&u.hasMissingPatterns&&u.patterns.length===0&&(h=!0),h)continue;i.push(l)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},wv=class SZ{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,r){if(t&&typeof t=="string"){const n=t.length;let i=0,s=[],o=!1;for(let a=0;a<n;a++)if(t.charAt(a)==="\\"&&a+1<n){const u=t.charAt(a+1);u==="z"?(s.push(t.substring(i,a)),s.push("$(?!\\n)(?<!\\n)"),i=a+2):(u==="A"||u==="G")&&(o=!0),a++}this.hasAnchor=o,i===0?this.source=t:(s.push(t.substring(i,n)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=r,typeof this.source=="string"?this.hasBackReferences=_3e.test(this.source):this.hasBackReferences=!1}clone(){return new SZ(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,r){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let n=r.map(i=>t.substring(i.start,i.end));return HH.lastIndex=0,this.source.replace(HH,(i,s)=>pZ(n[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],r=[],n=[],i=[],s,o,a,l;for(s=0,o=this.source.length;s<o;s++)a=this.source.charAt(s),t[s]=a,r[s]=a,n[s]=a,i[s]=a,a==="\\"&&s+1<o&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="",r[s+1]="",n[s+1]="A",i[s+1]="A"):l==="G"?(t[s+1]="",r[s+1]="G",n[s+1]="",i[s+1]="G"):(t[s+1]=l,r[s+1]=l,n[s+1]=l,i[s+1]=l),s++);return{A0_G0:t.join(""),A0_G1:r.join(""),A1_G0:n.join(""),A1_G1:i.join("")}}resolveAnchors(t,r){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?r?this._anchorCache.A1_G1:this._anchorCache.A1_G0:r?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Cv=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(r=>r.source);this._cached=new UH(e,t,this._items.map(r=>r.ruleId))}return this._cached}compileAG(e,t,r){return this._hasAnchors?t?r?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,r)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,r)),this._anchorCache.A1_G0):r?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,r)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,r)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,r){let n=this._items.map(i=>i.resolveAnchors(t,r));return new UH(e,n,this._items.map(i=>i.ruleId))}},UH=class{constructor(e,t,r){this.regExps=t,this.rules=r,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,r=this.rules.length;t<r;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/jpeg" href="/logo-dark.jpg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Vibora</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-_20k-d6F.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-BAuZPd2w.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|