libre-webui 0.19.5 → 0.19.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/backend/package.json +1 -1
  2. package/electron/main.js +196 -11
  3. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  4. package/frontend/dist/assets/{index-yeE8bw17.js → index-Cd0_AoYV.js} +19 -18
  5. package/frontend/dist/index.html +8 -8
  6. package/frontend/dist/js/{ArtifactContainer-BRqFYglf.js → ArtifactContainer-Dy_1KKWg.js} +1 -1
  7. package/frontend/dist/js/{ArtifactDemoPage-CQj2XRxx.js → ArtifactDemoPage-Big00RwH.js} +1 -1
  8. package/frontend/dist/js/{ArtifactSandboxFrame-BsrybHW3.js → ArtifactSandboxFrame-C_S4j076.js} +2 -2
  9. package/frontend/dist/js/{ArtifactSlideOutPanel-BcDkHDZY.js → ArtifactSlideOutPanel-B4-D3HkB.js} +1 -1
  10. package/frontend/dist/js/{ChatPage-CtN25kO5.js → ChatPage-BkFd1iac.js} +1 -1
  11. package/frontend/dist/js/{FirstTimeSetup-CX3zIxZR.js → FirstTimeSetup-C6YxrwR7.js} +1 -1
  12. package/frontend/dist/js/{GalleryPage-Dv5IJVVY.js → GalleryPage-BtcPs7SO.js} +1 -1
  13. package/frontend/dist/js/{HomePage-C7JjQJSz.js → HomePage-5PhpAt14.js} +1 -1
  14. package/frontend/dist/js/{LibreClawPage-iEHU_8KO.js → LibreClawPage-B14Go5Mn.js} +1 -1
  15. package/frontend/dist/js/{ModelSelector-DhRVhkDT.js → ModelSelector-C1wN91tl.js} +1 -1
  16. package/frontend/dist/js/{ModelsPage-BU-VYLs1.js → ModelsPage-Cc3L0ur8.js} +1 -1
  17. package/frontend/dist/js/{NotesPage-DKXMxPjC.js → NotesPage-BwEMW-Z3.js} +1 -1
  18. package/frontend/dist/js/{PersonasPage-DnjO6raM.js → PersonasPage-e-CbTxP3.js} +1 -1
  19. package/frontend/dist/js/{PluginUsagePage-DNihHooM.js → PluginUsagePage-CvZMJJwv.js} +1 -1
  20. package/frontend/dist/js/{RichMessageContent-DDJDx7_n.js → RichMessageContent-DNl3_CIw.js} +1 -1
  21. package/frontend/dist/js/{SettingsModal-Djij7CKl.js → SettingsModal-C8KJJEud.js} +1 -1
  22. package/frontend/dist/js/{SystemPage-CDBXVff3.js → SystemPage-8kEAS71H.js} +1 -1
  23. package/frontend/dist/js/{UserManagementPage-CZJLqvwO.js → UserManagementPage-BSrZ0ucu.js} +1 -1
  24. package/frontend/dist/js/{WorkPage-EpH5lfJx.js → WorkPage-spf92PVN.js} +3 -3
  25. package/frontend/dist/js/{api-DVeiqNG9.js → api-MySpmAK8.js} +2 -2
  26. package/frontend/dist/js/{appStore-hNTtRnlO.js → appStore-BpoXhleX.js} +2 -2
  27. package/frontend/dist/js/{authStore-Cl_7F0Si.js → authStore-DmrydYuS.js} +1 -1
  28. package/frontend/dist/js/{chatStore-Bp5u1tTv.js → chatStore-CWqfsOjc.js} +2 -2
  29. package/frontend/dist/js/{config-cqTxMjWo.js → config-CuXlcWP1.js} +1 -1
  30. package/frontend/dist/js/{estree-BAxGO-Uf.js → estree-BuWOCMW0.js} +1 -1
  31. package/frontend/dist/js/{html-DL8k6nha.js → html-D7tW7UvW.js} +1 -1
  32. package/frontend/dist/js/{markdown-CKunEqMI.js → markdown-CBSxWEtK.js} +1 -1
  33. package/frontend/dist/js/{messageCodeStyles-Cva_Rdk3.js → messageCodeStyles-BlTi46wI.js} +1 -1
  34. package/frontend/dist/js/{standalone-qHCG6_XI.js → standalone-CaXys7q3.js} +1 -1
  35. package/frontend/dist/js/{typescript-ClQp1SgP.js → typescript-DQ5zi5zo.js} +1 -1
  36. package/frontend/dist/js/{ui-ChYGf2Rg.js → ui-DFQiHo_k.js} +2 -2
  37. package/package.json +4 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{d as e,f as t}from"./markdown-core-DHnR5Hw8.js";import{t as n}from"./useTranslation-CdeLZqSW.js";import{Kt as r,M as i,R as a,X as o,Zt as s,f as c,k as l,mn as u,nt as d,st as f,vt as p}from"./ui-vendor-D_pYT79f.js";import{s as m}from"./api-DVeiqNG9.js";import{t as h}from"./utils-BhpNrGnR.js";import{t as g}from"./Button-X9TT9gTD.js";import{n as _,t as v}from"./ui-ChYGf2Rg.js";import{f as y}from"../assets/index-yeE8bw17.js";t();var b=e(),x=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),S=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),C=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),w=e=>{if(!Number.isFinite(e)||e<0)return`—`;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${x.format(e/1024**n)} ${t[n]}`},T=e=>{if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:i>0?`${i}m`:`${Math.floor(e)}s`},E=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),D=e=>{switch(e.toLowerCase()){case`running`:return`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`paused`:return`bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`exited`:case`dead`:return`bg-gray-500/10 text-gray-600 dark:text-dark-600`;default:return`bg-primary-500/10 text-primary-700 dark:text-primary-300`}},O=({title:e,description:t,icon:n,className:r,action:i,children:a})=>(0,b.jsxs)(`section`,{className:h(`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,r),children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,b.jsx)(n,{className:`h-4 w-4`})}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,b.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),i]}),a]}),k=({label:e,value:t,mono:n})=>(0,b.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-5 border-b border-gray-100 py-2 last:border-0 dark:border-white/[0.05]`,children:[(0,b.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`dd`,{className:h(`min-w-0 break-words text-end text-xs font-medium text-gray-800 dark:text-dark-800`,n&&`font-mono text-[11px]`),children:t})]}),A=({value:e,tone:t=`primary`})=>(0,b.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(E(e)),children:(0,b.jsx)(`div`,{className:h(`h-full rounded-full transition-[width] duration-300`,t===`warning`?`bg-amber-500 dark:bg-amber-400`:`bg-primary-500 dark:bg-primary-400`),style:{width:`${E(e)}%`}})}),j=()=>{let{t:e}=n(),{data:t,error:r,isLoading:i,isFetching:o,refetch:s}=y({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await m.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),u=r?r instanceof Error?r.message:e(`systemPage.loadFailed`):null;return i&&!t?(0,b.jsx)(_,{width:`wide`,children:(0,b.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,b.jsx)(f,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,b.jsxs)(_,{width:`wide`,children:[(0,b.jsx)(v,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,b.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:C.format(t.generatedAt)})}),(0,b.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>void s(),disabled:o,children:[(0,b.jsx)(a,{className:h(`h-4 w-4`,o&&`animate-spin`)}),(0,b.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),u&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,b.jsx)(c,{className:`h-4 w-4 shrink-0`}),(0,b.jsx)(`span`,{children:u})]}),t&&(0,b.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,b.jsx)(M,{diagnostics:t}),(0,b.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,b.jsx)(N,{diagnostics:t}),(0,b.jsx)(P,{diagnostics:t})]}),(0,b.jsx)(F,{diagnostics:t}),(0,b.jsx)(I,{diagnostics:t}),(0,b.jsx)(R,{diagnostics:t}),(0,b.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,b.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,b.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},M=({diagnostics:e})=>{let{t}=n(),i=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0],a=[{label:t(`systemPage.cards.uptime`),value:T(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:C.format(e.host.bootedAt)}),icon:s},{label:t(`systemPage.cards.memory`),value:`${S.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:w(e.memory.usedBytes),total:w(e.memory.totalBytes)}),icon:d},{label:t(`systemPage.cards.freeSpace`),value:i?w(i.freeBytes):`—`,detail:i?t(`systemPage.cards.freeSpaceDetail`,{label:i.label,total:w(i.totalBytes)}):t(`systemPage.cards.unavailable`),icon:p},{label:t(`systemPage.cards.containers`),value:e.docker.available?String(e.docker.runningContainers):`—`,detail:e.docker.available?t(`systemPage.cards.containersDetail`,{total:e.docker.totalContainers}):t(`systemPage.cards.dockerUnavailable`),icon:r}];return(0,b.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:a.map(e=>{let t=e.icon;return(0,b.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,b.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,b.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,b.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},N=({diagnostics:e})=>{let{t}=n(),{host:r,runtime:a}=e;return(0,b.jsx)(O,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:i,action:(0,b.jsx)(`span`,{className:`rounded-full bg-primary-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em] text-primary-700 dark:text-primary-300`,children:r.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,b.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,b.jsx)(k,{label:t(`systemPage.host.hostname`),value:r.hostname}),(0,b.jsx)(k,{label:t(`systemPage.host.operatingSystem`),value:`${r.platform} ${r.release} · ${r.architecture}`}),(0,b.jsx)(k,{label:t(`systemPage.host.processor`),value:`${r.cpuModel} · ${r.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,b.jsx)(k,{label:t(`systemPage.host.loadAverage`),value:r.loadAverage.map(e=>S.format(e)).join(` · `)}),(0,b.jsx)(k,{label:t(`systemPage.host.libreVersion`),value:a.appVersion}),(0,b.jsx)(k,{label:t(`systemPage.host.nodeVersion`),value:a.nodeVersion}),(0,b.jsx)(k,{label:t(`systemPage.host.process`),value:`PID ${a.processId} · ${T(a.processUptimeSeconds)}`}),(0,b.jsx)(k,{label:t(`systemPage.host.workingDirectory`),value:a.workingDirectory,mono:!0})]})})},P=({diagnostics:e})=>{let{t}=n(),{memory:r}=e;return(0,b.jsx)(O,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:d,children:(0,b.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[S.format(r.usedPercent),`%`]}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:w(r.usedBytes),total:w(r.totalBytes)})})]}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:w(r.freeBytes)})})]}),(0,b.jsx)(A,{value:r.usedPercent,tone:r.usedPercent>=85?`warning`:`primary`})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),r.processRssBytes],[t(`systemPage.memory.heapUsed`),r.heapUsedBytes],[t(`systemPage.memory.heapTotal`),r.heapTotalBytes],[t(`systemPage.memory.external`),r.externalBytes]].map(([e,t])=>(0,b.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:w(Number(t))})]},String(e)))})]})})},F=({diagnostics:e})=>{let{t}=n();return(0,b.jsx)(O,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:p,children:e.filesystems.length===0?(0,b.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,b.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,b.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,b.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[S.format(e.usedPercent),`%`]})]}),(0,b.jsx)(`div`,{className:`mt-4`,children:(0,b.jsx)(A,{value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,b.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,b.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:w(e.usedBytes)})}),(0,b.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:w(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},I=({diagnostics:e})=>{let{t}=n(),{docker:i}=e;return(0,b.jsx)(O,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:r,action:(0,b.jsxs)(`span`,{className:h(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,i.available?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,b.jsx)(`span`,{className:h(`h-1.5 w-1.5 rounded-full`,i.available?`bg-emerald-500`:`bg-gray-400`)}),i.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:i.available?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[t(`systemPage.docker.running`),i.runningContainers],[t(`systemPage.docker.stopped`),i.stoppedContainers],[t(`systemPage.docker.paused`),i.pausedContainers],[t(`systemPage.docker.total`),i.totalContainers]].map(([e,t])=>(0,b.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[i.serverVersion&&(0,b.jsx)(L,{label:t(`systemPage.docker.version`),value:i.serverVersion}),i.operatingSystem&&(0,b.jsx)(L,{label:t(`systemPage.docker.host`),value:i.operatingSystem}),i.architecture&&(0,b.jsx)(L,{label:t(`systemPage.docker.architecture`),value:i.architecture}),i.logicalCpus!==void 0&&(0,b.jsx)(L,{label:t(`systemPage.docker.cpus`),value:String(i.logicalCpus)}),i.memoryBytes!==void 0&&(0,b.jsx)(L,{label:t(`systemPage.docker.memory`),value:w(i.memoryBytes)})]}),i.containers.length===0?(0,b.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,b.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,b.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,b.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,b.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:i.containers.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,b.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,b.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,b.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,b.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,b.jsx)(`span`,{className:h(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,D(e.state)),children:e.state}),(0,b.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,b.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?C.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,b.jsxs)(`div`,{className:`m-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:m-5`,children:[(0,b.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{children:i.reason||t(`systemPage.docker.unavailableDetail`)}),(0,b.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:i.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},L=({label:e,value:t})=>(0,b.jsxs)(`span`,{className:`rounded-full border border-gray-200 bg-white px-3 py-1.5 text-[11px] text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:[(0,b.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),R=({diagnostics:e})=>{let{t}=n();return(0,b.jsx)(O,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:o,children:e.network.interfaces.length===0?(0,b.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,b.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-3`,children:e.network.interfaces.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(u,{className:`h-4 w-4 text-primary-500`}),(0,b.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,b.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,b.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,b.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,b.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-dark-700`,children:e.cidr||e.address})]},`${e.family}:${e.address}`))}),(e.receivedBytes!==void 0||e.transmittedBytes!==void 0)&&(0,b.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,b.jsxs)(`span`,{children:[`↓ `,w(e.receivedBytes??0)]}),(0,b.jsxs)(`span`,{children:[`↑ `,w(e.transmittedBytes??0)]})]})]},e.name))})})};export{j as default};
1
+ import"./rolldown-runtime-hePW80VL.js";import{d as e,f as t}from"./markdown-core-DHnR5Hw8.js";import{t as n}from"./useTranslation-CdeLZqSW.js";import{Kt as r,M as i,R as a,X as o,Zt as s,f as c,k as l,mn as u,nt as d,st as f,vt as p}from"./ui-vendor-D_pYT79f.js";import{s as m}from"./api-MySpmAK8.js";import{t as h}from"./utils-BhpNrGnR.js";import{t as g}from"./Button-X9TT9gTD.js";import{n as _,t as v}from"./ui-DFQiHo_k.js";import{f as y}from"../assets/index-Cd0_AoYV.js";t();var b=e(),x=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),S=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),C=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),w=e=>{if(!Number.isFinite(e)||e<0)return`—`;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${x.format(e/1024**n)} ${t[n]}`},T=e=>{if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:i>0?`${i}m`:`${Math.floor(e)}s`},E=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),D=e=>{switch(e.toLowerCase()){case`running`:return`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`paused`:return`bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`exited`:case`dead`:return`bg-gray-500/10 text-gray-600 dark:text-dark-600`;default:return`bg-primary-500/10 text-primary-700 dark:text-primary-300`}},O=({title:e,description:t,icon:n,className:r,action:i,children:a})=>(0,b.jsxs)(`section`,{className:h(`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,r),children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,b.jsx)(n,{className:`h-4 w-4`})}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,b.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),i]}),a]}),k=({label:e,value:t,mono:n})=>(0,b.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-5 border-b border-gray-100 py-2 last:border-0 dark:border-white/[0.05]`,children:[(0,b.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`dd`,{className:h(`min-w-0 break-words text-end text-xs font-medium text-gray-800 dark:text-dark-800`,n&&`font-mono text-[11px]`),children:t})]}),A=({value:e,tone:t=`primary`})=>(0,b.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(E(e)),children:(0,b.jsx)(`div`,{className:h(`h-full rounded-full transition-[width] duration-300`,t===`warning`?`bg-amber-500 dark:bg-amber-400`:`bg-primary-500 dark:bg-primary-400`),style:{width:`${E(e)}%`}})}),j=()=>{let{t:e}=n(),{data:t,error:r,isLoading:i,isFetching:o,refetch:s}=y({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await m.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),u=r?r instanceof Error?r.message:e(`systemPage.loadFailed`):null;return i&&!t?(0,b.jsx)(_,{width:`wide`,children:(0,b.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,b.jsx)(f,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,b.jsxs)(_,{width:`wide`,children:[(0,b.jsx)(v,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,b.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:C.format(t.generatedAt)})}),(0,b.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>void s(),disabled:o,children:[(0,b.jsx)(a,{className:h(`h-4 w-4`,o&&`animate-spin`)}),(0,b.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),u&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,b.jsx)(c,{className:`h-4 w-4 shrink-0`}),(0,b.jsx)(`span`,{children:u})]}),t&&(0,b.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,b.jsx)(M,{diagnostics:t}),(0,b.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,b.jsx)(N,{diagnostics:t}),(0,b.jsx)(P,{diagnostics:t})]}),(0,b.jsx)(F,{diagnostics:t}),(0,b.jsx)(I,{diagnostics:t}),(0,b.jsx)(R,{diagnostics:t}),(0,b.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,b.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,b.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},M=({diagnostics:e})=>{let{t}=n(),i=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0],a=[{label:t(`systemPage.cards.uptime`),value:T(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:C.format(e.host.bootedAt)}),icon:s},{label:t(`systemPage.cards.memory`),value:`${S.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:w(e.memory.usedBytes),total:w(e.memory.totalBytes)}),icon:d},{label:t(`systemPage.cards.freeSpace`),value:i?w(i.freeBytes):`—`,detail:i?t(`systemPage.cards.freeSpaceDetail`,{label:i.label,total:w(i.totalBytes)}):t(`systemPage.cards.unavailable`),icon:p},{label:t(`systemPage.cards.containers`),value:e.docker.available?String(e.docker.runningContainers):`—`,detail:e.docker.available?t(`systemPage.cards.containersDetail`,{total:e.docker.totalContainers}):t(`systemPage.cards.dockerUnavailable`),icon:r}];return(0,b.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:a.map(e=>{let t=e.icon;return(0,b.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,b.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,b.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,b.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},N=({diagnostics:e})=>{let{t}=n(),{host:r,runtime:a}=e;return(0,b.jsx)(O,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:i,action:(0,b.jsx)(`span`,{className:`rounded-full bg-primary-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em] text-primary-700 dark:text-primary-300`,children:r.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,b.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,b.jsx)(k,{label:t(`systemPage.host.hostname`),value:r.hostname}),(0,b.jsx)(k,{label:t(`systemPage.host.operatingSystem`),value:`${r.platform} ${r.release} · ${r.architecture}`}),(0,b.jsx)(k,{label:t(`systemPage.host.processor`),value:`${r.cpuModel} · ${r.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,b.jsx)(k,{label:t(`systemPage.host.loadAverage`),value:r.loadAverage.map(e=>S.format(e)).join(` · `)}),(0,b.jsx)(k,{label:t(`systemPage.host.libreVersion`),value:a.appVersion}),(0,b.jsx)(k,{label:t(`systemPage.host.nodeVersion`),value:a.nodeVersion}),(0,b.jsx)(k,{label:t(`systemPage.host.process`),value:`PID ${a.processId} · ${T(a.processUptimeSeconds)}`}),(0,b.jsx)(k,{label:t(`systemPage.host.workingDirectory`),value:a.workingDirectory,mono:!0})]})})},P=({diagnostics:e})=>{let{t}=n(),{memory:r}=e;return(0,b.jsx)(O,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:d,children:(0,b.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[S.format(r.usedPercent),`%`]}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:w(r.usedBytes),total:w(r.totalBytes)})})]}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:w(r.freeBytes)})})]}),(0,b.jsx)(A,{value:r.usedPercent,tone:r.usedPercent>=85?`warning`:`primary`})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),r.processRssBytes],[t(`systemPage.memory.heapUsed`),r.heapUsedBytes],[t(`systemPage.memory.heapTotal`),r.heapTotalBytes],[t(`systemPage.memory.external`),r.externalBytes]].map(([e,t])=>(0,b.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:w(Number(t))})]},String(e)))})]})})},F=({diagnostics:e})=>{let{t}=n();return(0,b.jsx)(O,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:p,children:e.filesystems.length===0?(0,b.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,b.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,b.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,b.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[S.format(e.usedPercent),`%`]})]}),(0,b.jsx)(`div`,{className:`mt-4`,children:(0,b.jsx)(A,{value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,b.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,b.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:w(e.usedBytes)})}),(0,b.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:w(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},I=({diagnostics:e})=>{let{t}=n(),{docker:i}=e;return(0,b.jsx)(O,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:r,action:(0,b.jsxs)(`span`,{className:h(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,i.available?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,b.jsx)(`span`,{className:h(`h-1.5 w-1.5 rounded-full`,i.available?`bg-emerald-500`:`bg-gray-400`)}),i.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:i.available?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[t(`systemPage.docker.running`),i.runningContainers],[t(`systemPage.docker.stopped`),i.stoppedContainers],[t(`systemPage.docker.paused`),i.pausedContainers],[t(`systemPage.docker.total`),i.totalContainers]].map(([e,t])=>(0,b.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[i.serverVersion&&(0,b.jsx)(L,{label:t(`systemPage.docker.version`),value:i.serverVersion}),i.operatingSystem&&(0,b.jsx)(L,{label:t(`systemPage.docker.host`),value:i.operatingSystem}),i.architecture&&(0,b.jsx)(L,{label:t(`systemPage.docker.architecture`),value:i.architecture}),i.logicalCpus!==void 0&&(0,b.jsx)(L,{label:t(`systemPage.docker.cpus`),value:String(i.logicalCpus)}),i.memoryBytes!==void 0&&(0,b.jsx)(L,{label:t(`systemPage.docker.memory`),value:w(i.memoryBytes)})]}),i.containers.length===0?(0,b.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,b.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,b.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,b.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,b.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:i.containers.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,b.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,b.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,b.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,b.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,b.jsx)(`span`,{className:h(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,D(e.state)),children:e.state}),(0,b.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,b.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?C.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,b.jsxs)(`div`,{className:`m-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:m-5`,children:[(0,b.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{children:i.reason||t(`systemPage.docker.unavailableDetail`)}),(0,b.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:i.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},L=({label:e,value:t})=>(0,b.jsxs)(`span`,{className:`rounded-full border border-gray-200 bg-white px-3 py-1.5 text-[11px] text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:[(0,b.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),R=({diagnostics:e})=>{let{t}=n();return(0,b.jsx)(O,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:o,children:e.network.interfaces.length===0?(0,b.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,b.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-3`,children:e.network.interfaces.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(u,{className:`h-4 w-4 text-primary-500`}),(0,b.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,b.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,b.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,b.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,b.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-dark-700`,children:e.cidr||e.address})]},`${e.family}:${e.address}`))}),(e.receivedBytes!==void 0||e.transmittedBytes!==void 0)&&(0,b.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,b.jsxs)(`span`,{children:[`↓ `,w(e.receivedBytes??0)]}),(0,b.jsxs)(`span`,{children:[`↑ `,w(e.transmittedBytes??0)]})]})]},e.name))})})};export{j as default};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CdeLZqSW.js";import{B as i,O as a,Zt as o,c as s,m as c,u as l,w as u,wn as d}from"./ui-vendor-D_pYT79f.js";import{t as f}from"./logger-DSXjF4ye.js";import{w as p}from"./api-DVeiqNG9.js";import{n as m}from"./authStore-Cl_7F0Si.js";import{t as h}from"./Button-X9TT9gTD.js";import{a as g,c as _,i as v,n as y,o as b,p as x,r as S,s as C,t as w}from"./ui-ChYGf2Rg.js";import{f as T,m as E}from"../assets/index-yeE8bw17.js";var D=e(n(),1),O=t(),k=f(`components:user-manager`),A=()=>{let{t:e}=r(),t=E(),[n,f]=(0,D.useState)(!1),[y,w]=(0,D.useState)(null),[A,j]=(0,D.useState)({username:``,email:``,password:``,role:`user`}),{user:M}=m(),{data:N=[],isLoading:P}=T({queryKey:[`users`],queryFn:async()=>{let t=await p.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),F=()=>t.invalidateQueries({queryKey:[`users`]}),I=N.filter(e=>e.status===`pending`),L=N.filter(e=>e.status!==`pending`),R=async t=>{t.preventDefault();try{let t=await p.createUser(A);t.success&&t.data&&(await F(),j({username:``,email:``,password:``,role:`user`}),f(!1),d.success(e(`userManager.form.createSuccess`)))}catch(t){k.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),d.error(n)}},z=async t=>{if(t.preventDefault(),y)try{let t={username:A.username,email:A.email,role:A.role};A.password&&A.password.trim()!==``&&(t.password=A.password);let n=await p.updateUser(y.id,t);n.success&&n.data&&(await F(),w(null),j({username:``,email:``,password:``,role:`user`}),d.success(e(`userManager.form.updateSuccess`)))}catch(t){k.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),d.error(n)}},B=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await p.deleteUser(t)).success&&(await F(),d.success(e(`userManager.deleteSuccess`)))}catch(t){k.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),d.error(n)}},V=async t=>{try{let n=await p.approveUser(t.id);n.success&&n.data&&(await F(),d.success(e(`userManager.approval.approved`,{name:t.username,defaultValue:`{{name}} can now sign in.`})))}catch(t){k.error(`Error approving user:`,t);let n=t;d.error(n.response?.data?.message||e(`userManager.approval.failed`,`The account could not be approved.`))}},H=e=>{w(e),j({username:e.username,email:e.email||``,password:``,role:e.role})};return P?(0,O.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,O.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,O.jsx)(`div`,{}),(0,O.jsxs)(h,{onClick:()=>f(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,O.jsx)(i,{size:16}),(0,O.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,O.jsxs)(S,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsx)(C,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(v,{children:(0,O.jsxs)(`form`,{onSubmit:R,className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,O.jsx)(x,{id:`username`,value:A.username,onChange:e=>j({...A,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,O.jsx)(x,{id:`email`,type:`email`,value:A.email,onChange:e=>j({...A,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,O.jsx)(x,{id:`password`,type:`password`,value:A.password,onChange:e=>j({...A,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,O.jsxs)(`select`,{id:`role`,value:A.role,onChange:e=>j({...A,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,O.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,O.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,O.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>{j({username:``,email:``,password:``,role:`user`}),f(!1)},children:e(`common.cancel`)})]})]})})]}),y&&(0,O.jsxs)(S,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsxs)(C,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,y.username]}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(v,{children:(0,O.jsxs)(`form`,{onSubmit:z,className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,O.jsx)(x,{id:`edit-username`,value:A.username,onChange:e=>j({...A,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,O.jsx)(x,{id:`edit-email`,type:`email`,value:A.email,onChange:e=>j({...A,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(_,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,O.jsx)(x,{id:`edit-password`,type:`password`,value:A.password,onChange:e=>j({...A,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,O.jsxs)(`select`,{id:`edit-role`,value:A.role,onChange:e=>j({...A,role:e.target.value}),disabled:y?.id===M?.id&&M?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,O.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,O.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),y?.id===M?.id&&M?.role===`admin`&&(0,O.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,O.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>{w(null),j({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),I.length>0&&(0,O.jsxs)(S,{"data-testid":`pending-user-approvals`,className:`border border-warning-500/30 bg-warning-500/[0.06] shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsxs)(C,{className:`flex items-center gap-2 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(o,{className:`h-5 w-5 text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`,`Pending approvals`),` (`,I.length,`)`]}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.approval.description`,`Review new registrations before allowing them into this instance.`)})]}),(0,O.jsx)(v,{children:(0,O.jsx)(`div`,{className:`space-y-3`,children:I.map(t=>(0,O.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-4 rounded-xl border border-warning-500/25 bg-surface p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h3`,{className:`truncate font-medium text-ink`,children:t.username}),(0,O.jsx)(`p`,{className:`truncate text-sm text-ink-muted`,children:t.email||e(`userManager.noEmail`)}),(0,O.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(`userManager.approval.registered`,`Registered`),`:`,` `,new Date(t.createdAt).toLocaleString()]})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(h,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void V(t),className:`gap-2`,children:[(0,O.jsx)(l,{size:16}),e(`userManager.approval.activate`,`Activate account`)]}),(0,O.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e(`userManager.approval.reject`,`Reject registration`),onClick:()=>void B(t.id,t.username),className:`text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-900/20 dark:hover:text-red-300`,children:(0,O.jsx)(c,{size:16})})]})]},t.id))})})]}),(0,O.jsxs)(S,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsxs)(C,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,L.length,`)`]}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(v,{children:(0,O.jsx)(`div`,{className:`space-y-3`,children:L.map(t=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,O.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,O.jsx)(a,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,O.jsx)(s,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===M?.id&&(0,O.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,O.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>H(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,O.jsx)(u,{size:16})}),(0,O.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>B(t.id,t.username),disabled:t.id===M?.id,className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(c,{size:16})})]})]},t.id))})})]})]})},j=()=>{let{t:e}=r();return(0,O.jsxs)(y,{children:[(0,O.jsx)(w,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,O.jsx)(A,{})]})};export{j as UserManagementPage,j as default};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CdeLZqSW.js";import{B as i,O as a,Zt as o,c as s,m as c,u as l,w as u,wn as d}from"./ui-vendor-D_pYT79f.js";import{t as f}from"./logger-DSXjF4ye.js";import{w as p}from"./api-MySpmAK8.js";import{n as m}from"./authStore-DmrydYuS.js";import{t as h}from"./Button-X9TT9gTD.js";import{a as g,c as _,i as v,n as y,o as b,p as x,r as S,s as C,t as w}from"./ui-DFQiHo_k.js";import{f as T,m as E}from"../assets/index-Cd0_AoYV.js";var D=e(n(),1),O=t(),k=f(`components:user-manager`),A=()=>{let{t:e}=r(),t=E(),[n,f]=(0,D.useState)(!1),[y,w]=(0,D.useState)(null),[A,j]=(0,D.useState)({username:``,email:``,password:``,role:`user`}),{user:M}=m(),{data:N=[],isLoading:P}=T({queryKey:[`users`],queryFn:async()=>{let t=await p.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),F=()=>t.invalidateQueries({queryKey:[`users`]}),I=N.filter(e=>e.status===`pending`),L=N.filter(e=>e.status!==`pending`),R=async t=>{t.preventDefault();try{let t=await p.createUser(A);t.success&&t.data&&(await F(),j({username:``,email:``,password:``,role:`user`}),f(!1),d.success(e(`userManager.form.createSuccess`)))}catch(t){k.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),d.error(n)}},z=async t=>{if(t.preventDefault(),y)try{let t={username:A.username,email:A.email,role:A.role};A.password&&A.password.trim()!==``&&(t.password=A.password);let n=await p.updateUser(y.id,t);n.success&&n.data&&(await F(),w(null),j({username:``,email:``,password:``,role:`user`}),d.success(e(`userManager.form.updateSuccess`)))}catch(t){k.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),d.error(n)}},B=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await p.deleteUser(t)).success&&(await F(),d.success(e(`userManager.deleteSuccess`)))}catch(t){k.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),d.error(n)}},V=async t=>{try{let n=await p.approveUser(t.id);n.success&&n.data&&(await F(),d.success(e(`userManager.approval.approved`,{name:t.username,defaultValue:`{{name}} can now sign in.`})))}catch(t){k.error(`Error approving user:`,t);let n=t;d.error(n.response?.data?.message||e(`userManager.approval.failed`,`The account could not be approved.`))}},H=e=>{w(e),j({username:e.username,email:e.email||``,password:``,role:e.role})};return P?(0,O.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,O.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,O.jsx)(`div`,{}),(0,O.jsxs)(h,{onClick:()=>f(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,O.jsx)(i,{size:16}),(0,O.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,O.jsxs)(S,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsx)(C,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(v,{children:(0,O.jsxs)(`form`,{onSubmit:R,className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,O.jsx)(x,{id:`username`,value:A.username,onChange:e=>j({...A,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,O.jsx)(x,{id:`email`,type:`email`,value:A.email,onChange:e=>j({...A,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,O.jsx)(x,{id:`password`,type:`password`,value:A.password,onChange:e=>j({...A,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,O.jsxs)(`select`,{id:`role`,value:A.role,onChange:e=>j({...A,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,O.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,O.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,O.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>{j({username:``,email:``,password:``,role:`user`}),f(!1)},children:e(`common.cancel`)})]})]})})]}),y&&(0,O.jsxs)(S,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsxs)(C,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,y.username]}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(v,{children:(0,O.jsxs)(`form`,{onSubmit:z,className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,O.jsx)(x,{id:`edit-username`,value:A.username,onChange:e=>j({...A,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,O.jsx)(x,{id:`edit-email`,type:`email`,value:A.email,onChange:e=>j({...A,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(_,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,O.jsx)(x,{id:`edit-password`,type:`password`,value:A.password,onChange:e=>j({...A,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,O.jsxs)(`select`,{id:`edit-role`,value:A.role,onChange:e=>j({...A,role:e.target.value}),disabled:y?.id===M?.id&&M?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,O.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,O.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),y?.id===M?.id&&M?.role===`admin`&&(0,O.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,O.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>{w(null),j({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),I.length>0&&(0,O.jsxs)(S,{"data-testid":`pending-user-approvals`,className:`border border-warning-500/30 bg-warning-500/[0.06] shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsxs)(C,{className:`flex items-center gap-2 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(o,{className:`h-5 w-5 text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`,`Pending approvals`),` (`,I.length,`)`]}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.approval.description`,`Review new registrations before allowing them into this instance.`)})]}),(0,O.jsx)(v,{children:(0,O.jsx)(`div`,{className:`space-y-3`,children:I.map(t=>(0,O.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-4 rounded-xl border border-warning-500/25 bg-surface p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h3`,{className:`truncate font-medium text-ink`,children:t.username}),(0,O.jsx)(`p`,{className:`truncate text-sm text-ink-muted`,children:t.email||e(`userManager.noEmail`)}),(0,O.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(`userManager.approval.registered`,`Registered`),`:`,` `,new Date(t.createdAt).toLocaleString()]})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(h,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void V(t),className:`gap-2`,children:[(0,O.jsx)(l,{size:16}),e(`userManager.approval.activate`,`Activate account`)]}),(0,O.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e(`userManager.approval.reject`,`Reject registration`),onClick:()=>void B(t.id,t.username),className:`text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-900/20 dark:hover:text-red-300`,children:(0,O.jsx)(c,{size:16})})]})]},t.id))})})]}),(0,O.jsxs)(S,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(b,{children:[(0,O.jsxs)(C,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,L.length,`)`]}),(0,O.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(v,{children:(0,O.jsx)(`div`,{className:`space-y-3`,children:L.map(t=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,O.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,O.jsx)(a,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,O.jsx)(s,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===M?.id&&(0,O.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,O.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>H(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,O.jsx)(u,{size:16})}),(0,O.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>B(t.id,t.username),disabled:t.id===M?.id,className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(c,{size:16})})]})]},t.id))})})]})]})},j=()=>{let{t:e}=r();return(0,O.jsxs)(y,{children:[(0,O.jsx)(w,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,O.jsx)(A,{})]})};export{j as UserManagementPage,j as default};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-CmENXdZw.js","js/router-vendor-Ca9zqOqT.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-DHnR5Hw8.js","js/estree-BAxGO-Uf.js","assets/index-yeE8bw17.js","js/react-vendor-DPNXrO-8.js","js/useTranslation-CdeLZqSW.js","js/i18n-CLd1FZPx.js","js/i18next-DgmgtwsV.js","js/ui-vendor-D_pYT79f.js","js/utils-vendor-1zob7nK9.js","js/logger-DSXjF4ye.js","js/config-cqTxMjWo.js","js/api-DVeiqNG9.js","js/utils-BhpNrGnR.js","js/chatStore-Bp5u1tTv.js","js/authStore-Cl_7F0Si.js","js/appStore-hNTtRnlO.js","js/welcomePrompts-to5mv_gx.js","js/messageCodeStyles-Cva_Rdk3.js","js/Button-X9TT9gTD.js","js/ui-ChYGf2Rg.js","assets/index-DtkGuqvC.css","js/typescript-ClQp1SgP.js","js/postcss-B5WIGhAY.js","js/html-DL8k6nha.js","js/markdown-CKunEqMI.js","js/yaml-QD4znPfZ.js","js/standalone-qHCG6_XI.js","js/OptimizedSyntaxHighlighter-CWYUn9Oe.js","js/syntax-highlight-Ca9bHsaz.js","assets/xterm-DHcfr8qj.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{d as r,f as i,i as a,l as o,u as s}from"./router-vendor-Ca9zqOqT.js";import{t as c}from"./useTranslation-CdeLZqSW.js";import{i as l}from"./i18n-CLd1FZPx.js";import{$t as u,B as d,Bt as f,C as p,Ct as m,Dt as h,F as g,It as _,L as v,Mt as y,N as b,Nt as x,Q as S,R as C,Sn as w,St as T,T as E,Tn as D,V as O,Vt as k,an as A,c as j,dn as M,i as ee,in as te,kt as N,m as ne,n as P,on as re,pn as ie,st as F,tt as ae,vn as oe,vt as se,x as ce,yn as le}from"./ui-vendor-D_pYT79f.js";import{t as ue}from"./config-cqTxMjWo.js";import{c as de,o as I}from"./api-DVeiqNG9.js";import{t as L}from"./utils-BhpNrGnR.js";import{t as R}from"./chatStore-Bp5u1tTv.js";import{a as fe,i as pe,l as me,n as he,o as ge,s as _e}from"./authStore-Cl_7F0Si.js";import{t as ve}from"./appStore-hNTtRnlO.js";import{t as z}from"./Button-X9TT9gTD.js";import{u as ye}from"./ui-ChYGf2Rg.js";import{c as be,l as xe}from"../assets/index-yeE8bw17.js";import{t as Se}from"./RichMessageContent-DDJDx7_n.js";import{t as Ce}from"./ModelSelector-DhRVhkDT.js";import{n as we,t as B}from"./work-DVgm81bJ.js";var V=e(n(),1),H=t(),Te=e=>we({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),U=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},W=e=>{let t=`${e.model} · `;return{name:e.model,model:e.model,size:0,digest:``,modified_at:``,details:{},isPlugin:e.providerType===`plugin`,pluginId:e.providerId,pluginName:e.providerType===`plugin`?e.label.startsWith(t)?e.label.slice(t.length):e.providerId:void 0}};function Ee({models:e,selectorModels:t,modelKey:n,running:r,loading:i,variant:a=`task`,disabled:o=!1,remoteDisclosureDismissed:s,remoteDisclosureSaving:l,onModelChange:d,onDismissRemoteDisclosure:f,onModelsRefresh:p,onSubmit:m,onCancel:h}){let{t:g}=c(),[_,v]=(0,V.useState)(``),y=(0,V.useRef)(null),x=(0,V.useRef)(null),S=(0,V.useRef)(null),C=e.find(e=>e.key===n),w=C?.remote===!0,T=a===`landing`,E=(0,V.useMemo)(()=>{let n=new Set(t.map(Te)),r=e.filter(e=>!n.has(e.key)).map(W);return[...t,...r]},[e,t]);(0,V.useEffect)(()=>{let e=y.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[_]);let D=async()=>{await f()&&([x.current,S.current].find(e=>e&&e.offsetParent!==null)||x.current)?.focus()},O=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&d(n.key)},k=async()=>{let e=_.trim();!e||i||r||o||!C||await m(e)&&v(``)};return(0,H.jsxs)(`div`,{"data-testid":T?`work-landing-composer`:`work-task-composer`,"data-variant":a,className:L(`relative shrink-0`,T?`mt-10 w-full`:`border-t border-line bg-surface/95 px-3 py-3 backdrop-blur md:px-5`),children:[w&&!s&&(0,H.jsx)(`div`,{className:L(`absolute inset-x-3 z-30 mx-auto max-w-3xl md:inset-x-5`,`bottom-full mb-3`),children:(0,H.jsxs)(`aside`,{"data-testid":`work-provider-disclosure-popover`,"aria-labelledby":`work-provider-disclosure-title`,"aria-live":`polite`,className:`relative rounded-2xl border border-warning-500/40 bg-surface-overlay p-3 pe-10 shadow-overlay backdrop-blur dark:border-warning-500/45`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:l,className:`absolute end-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-warning-500/20 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-warning-500 disabled:cursor-wait disabled:opacity-50`,"aria-label":g(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-warning-500/20`,children:(0,H.jsx)(u,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:g(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:g(`work.composer.remoteHint`,{defaultValue:`Conversation and tool output are sent to the configured service. One autonomous run can make multiple provider calls and may incur charges. Workspace files stay local unless a tool returns their contents.`})}),(0,H.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,H.jsx)(z,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:l,className:`h-7 border-warning-500 bg-warning-500 px-2.5 text-xs text-[#3d120c] hover:bg-warning-500/90 hover:text-[#3d120c]`,onClick:()=>void D(),children:g(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,H.jsx)(`form`,{className:`mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),k()},children:(0,H.jsxs)(`div`,{"data-testid":`work-composer-surface`,className:L(`flex items-end gap-2 rounded-[1.6rem] border p-2.5 transition-[border-color,box-shadow,background-color] duration-200 sm:p-3`,`border-black/[0.08] bg-surface/90 dark:border-white/[0.09] dark:bg-dark-200/90`,`shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_50px_rgba(15,23,42,0.08)] backdrop-blur-xl`,`focus-within:border-primary-500/35 focus-within:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_22px_65px_rgba(15,23,42,0.12)]`),children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(`textarea`,{ref:y,"data-testid":`work-composer-input`,dir:`auto`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),k())},disabled:o||r,rows:1,className:`m-0 block max-h-[160px] min-h-10 w-full resize-none overflow-y-auto rounded-none border-0 bg-transparent p-2 text-base leading-relaxed text-ink shadow-none outline-none placeholder:text-ink-subtle focus:border-0 focus:bg-transparent focus:ring-0 disabled:cursor-not-allowed disabled:opacity-60`,placeholder:g(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})})}),(0,H.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,H.jsx)(Ce,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Te,getModelLabel:U,getModelTitle:e=>e.name,triggerRef:x,triggerTestId:`work-model-selector-trigger`,selectTestId:`work-model-select`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`min-w-[150px] max-w-[230px]`,compact:!0})}),r?(0,H.jsx)(z,{"data-testid":`work-cancel-button`,type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full bg-error-500/15 p-0 text-error-600 transition-colors duration-150 hover:bg-error-500/25 dark:text-error-400 sm:h-10 sm:w-10`,title:g(`work.composer.cancel`,{defaultValue:`Stop`}),"aria-label":g(`work.composer.cancel`,{defaultValue:`Stop`}),onClick:()=>void h(),children:i?(0,H.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(ce,{className:`h-4 w-4 fill-current`})}):(0,H.jsx)(z,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!_.trim()||!C,className:L(`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors duration-150 sm:h-10 sm:w-10`,`bg-gray-950 text-white hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,`disabled:bg-gray-100 disabled:text-gray-400 disabled:hover:bg-gray-100 dark:disabled:bg-dark-300 dark:disabled:text-dark-500 dark:disabled:hover:bg-dark-300`,_.trim()&&C&&!o&&`shadow-sm`),title:g(`work.composer.send`,{defaultValue:`Run`}),"aria-label":g(`work.composer.send`,{defaultValue:`Run`}),children:i?(0,H.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(b,{className:`h-4 w-4`})})]})}),(0,H.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,H.jsx)(Ce,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Te,getModelLabel:U,getModelTitle:e=>e.name,triggerRef:S,triggerTestId:`work-model-selector-trigger-mobile`,selectTestId:`work-model-select-mobile`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`w-full`,compact:!0})})]})}var De=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},Oe=e=>{if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}s`},ke=e=>{if(!e)return 0;let t=Array.from(e).length,n=e.trim()?e.trim().split(/\s+/u).length:0;return Math.max(n,Math.ceil(t/4))};function Ae({run:e}){let[t,n]=(0,V.useState)();if((0,V.useEffect)(()=>{if(e.terminal||!e.startedAt)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e.startedAt,e.terminal]),!e.startedAt)return null;let r=e.finishedAt||t;return r?(0,H.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:Oe(r-e.startedAt)}):null}function je({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,V.useState)(e.status),[i,a]=(0,V.useState)(null),o=(0,V.useMemo)(()=>De(e.arguments),[e.arguments]),s=e.output||null,l=!!(o||s),d=e.status===`error`,f=e.status===`running`,p=(0,V.useId)(),m=d?n(`work.activity.kinds.error`,{defaultValue:`Error`}):f?n(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}):n(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),h=i??(e.status===r?t:e.status===`error`);return(0,H.jsxs)(`div`,{"data-testid":`work-live-tool`,"data-tool-id":e.id,className:L(`overflow-hidden rounded-xl border bg-surface-raised transition-colors`,d?`border-error-500/30`:`border-line`),children:[(0,H.jsxs)(`button`,{type:`button`,disabled:!l,onClick:()=>{a(!h)},"aria-expanded":l?h:void 0,"aria-controls":l?p:void 0,"aria-label":`${m}: ${e.name}`,className:`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-start outline-none hover:bg-surface-subtle focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52] disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,H.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:d?(0,H.jsx)(u,{className:`h-3.5 w-3.5 text-error-500`}):f?(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,H.jsx)(re,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,H.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-xs text-ink`,children:e.name}),e.durationMs!==void 0&&(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:Oe(e.durationMs)}),l&&(0,H.jsx)(A,{"aria-hidden":`true`,className:L(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,h&&`rotate-180`)})]}),l&&h&&(0,H.jsxs)(`div`,{id:p,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,H.jsx)(`pre`,{dir:`ltr`,className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:o}),s&&(0,H.jsx)(`pre`,{dir:`ltr`,className:L(`max-h-64 overflow-auto whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed`,d?`text-error-600`:`text-ink-muted`),children:s})]})]})}var G=e=>{let t=e.split(`
3
- `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n)return n}return``};function K({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,V.useState)(!1),a=t&&!r?G(e):``;return(0,H.jsxs)(`details`,{"data-testid":`work-live-reasoning`,open:r,onToggle:e=>i(e.currentTarget.open),className:`group overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(M,{className:L(`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`,t&&`animate-pulse-subtle motion-reduce:animate-none`)}),t?(0,H.jsxs)(`span`,{className:`animate-shimmer truncate bg-gradient-to-r from-ink-subtle via-ink to-ink-subtle bg-[length:200%_100%] bg-clip-text text-transparent motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-ink-muted`,children:[n(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),`…`]}):(0,H.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,H.jsx)(A,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,H.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,H.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,H.jsx)(ye,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var Me=(e,t,n)=>e===`queued`||e===`preparing`?t(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):e===`using_tool`?n?.name?`${t(`work.activity.toolActivity`,{defaultValue:`Tool activity`})} · ${n.name}`:t(`work.activity.toolActivity`,{defaultValue:`Tool activity`}):e===`completed`?t(`work.statusLabels.complete`,{defaultValue:`Complete`}):e===`needs_input`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`failed`?t(`work.statusLabels.error`,{defaultValue:`Error`}):e===`cancelled`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`responding`?t(`work.status.running`,{defaultValue:`Working in the local workspace…`}):t(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),Ne=(e,t)=>{if(e===`connecting`)return t(`work.live.connecting`,{defaultValue:`Connecting to live updates…`});if(e===`reconnecting`)return t(`work.live.reconnecting`,{defaultValue:`Reconnecting to live updates…`});if(e===`error`)return t(`work.live.unavailable`,{defaultValue:`Live updates unavailable`})};function Pe({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=Ne(e.connection,n)||Me(e.phase,n,r),a=!e.terminal,o=e.usage?.outputTokens,s=e.reasoning+e.response,l=o!==void 0&&o>0?o:s?ke(s):o,d=(o===void 0||o===0)&&!!s&&l!==void 0,f=e.usage?.tokensPerSecond;return(0,H.jsxs)(`section`,{"data-testid":`work-live-run`,"data-run-id":e.runId,"data-phase":e.phase,"aria-busy":a||void 0,className:L(`min-w-0`,t===`activity`&&`rounded-2xl border border-line bg-surface p-3 shadow-subtle`),children:[(0,H.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:L(`h-2 w-2 shrink-0 rounded-full`,e.phase===`failed`?`bg-[rgb(255,61,129)]`:e.phase===`completed`?`bg-[rgb(76,212,117)]`:e.phase===`needs_input`||e.phase===`cancelled`?`bg-[rgb(255,204,0)]`:e.connection===`error`?`bg-[rgb(255,61,129)]`:`bg-[rgb(48,121,255)]`,a&&`animate-pulse motion-reduce:animate-none`)}),(0,H.jsx)(`span`,{dir:`auto`,title:e.connectionError,className:`min-w-0 flex-1 truncate font-medium text-ink-muted`,children:i}),e.round!==void 0&&(0,H.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,H.jsx)(Ae,{run:e})]}),t===`conversation`&&(0,H.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,H.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-raised px-2 py-1 text-[10px] text-ink-muted`,children:[(0,H.jsx)(E,{className:`h-3 w-3 text-[#ff7b52]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]})}),t===`conversation`?e.timeline.length>0&&(0,H.jsx)(`div`,{"data-testid":`work-live-timeline`,className:`space-y-2`,children:e.timeline.map((t,n)=>{let r=n===e.timeline.length-1;if(t.kind===`reasoning`)return(0,H.jsx)(K,{content:t.text,streaming:a&&r},`segment-${n}`);if(t.kind===`tool`){let n=e.tools.find(e=>e.id===t.toolId);return n?(0,H.jsx)(je,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,H.jsx)(ye,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,H.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,H.jsx)(je,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,H.jsxs)(`div`,{role:`alert`,dir:`auto`,className:`mt-3 flex items-start gap-2 rounded-xl border border-error-500/30 bg-error-500/10 px-3 py-2.5 text-xs leading-relaxed text-error-600`,children:[(0,H.jsx)(u,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:e.error})]}),(l!==void 0||f!==void 0)&&(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-line pt-2 text-[10px] tabular-nums text-ink-subtle`,children:[l!==void 0&&(0,H.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,H.jsxs)(`bdi`,{dir:`ltr`,children:[d&&`≈`,l.toLocaleString()]})]}),f!==void 0&&(0,H.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,H.jsxs)(`bdi`,{dir:`ltr`,children:[f.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:320ms] motion-reduce:animate-none`})]}),t===`activity`&&e.tools.length===0&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,H.jsx)(p,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}function Fe({role:e,user:t,size:n=`message`}){let[r,i]=(0,V.useState)(null);if(e===`assistant`)return(0,H.jsx)(`div`,{role:`img`,"aria-label":`Libre WebUI`,"data-testid":`work-assistant-avatar`,className:L(`flex shrink-0 items-center justify-center rounded-full border border-line bg-surface-raised text-ink shadow-subtle`,n===`empty`?`mx-auto mb-4 h-12 w-12`:`mt-0.5 h-8 w-8`),children:(0,H.jsx)(xe,{label:null,className:L(n===`empty`?`h-6 w-6`:`h-4 w-4`)})});let a=t?.username||`User`,o=t?.avatar?.trim()||``,s=!!o&&o!==r;return(0,H.jsx)(`div`,{role:s?void 0:`img`,"aria-label":s?void 0:a,"data-testid":`work-user-avatar`,className:L(`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full`,s?`border border-line bg-surface-raised`:`bg-ink text-ink-inverse`),title:a,children:s?(0,H.jsx)(`img`,{src:o,alt:a,className:`h-full w-full object-cover`,onError:()=>i(o)}):t?(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,H.jsx)(j,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Ie=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},Le=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},q=(e,t,n)=>{let r=e??t,i=t?.kind===`error`||t?.metadata?.isError===!0||!t&&r?.kind===`error`,a=t?.metadata?.durationMs;return{id:(e??t)?.id??`tool`,name:r?Ie(r,n):n,status:i?`error`:`completed`,arguments:e?.metadata,output:t?.content||(!t&&e?e.content:void 0),durationMs:typeof a==`number`?a:void 0}},Re=(e,t)=>{let n=[],r=new Map,i=(e,t)=>{let r=n[n.length-1];return r?.item.type===`tools`?(r.item.tools.push(e),r.item.tools.length-1):(n.push({key:t,item:{type:`tools`,tools:[e]}}),0)};for(let a of e){if(a.kind===`reasoning`){n.push({key:a.id,item:{type:`reasoning`,message:a}});continue}if(a.role!==`tool`&&a.kind===`message`){n.push({key:a.id,item:{type:`message`,message:a}});continue}let e=Le(a);if(a.kind===`tool_call`&&e){let o=i(q(a,void 0,t),a.id);r.set(e,{itemIndex:n.length-1,toolIndex:o,call:a});continue}if(a.kind===`tool_result`&&e){let i=r.get(e);if(i){let o=n[i.itemIndex];if(o.item.type===`tools`){o.item.tools[i.toolIndex]=q(i.call,a,t),r.delete(e);continue}}}i(q(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function ze({message:e}){let{t}=c();return(0,H.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-ink-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,H.jsx)(A,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,H.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:e.content})]})}function Be({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a}){let{t:o}=c(),s=(0,V.useRef)(null),l=(0,V.useRef)(!0),[u,d]=(0,V.useState)(!1),f=(0,V.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),p=i?.runId,m=(0,V.useMemo)(()=>Re(f.filter(e=>!(p&&e.runId===p&&e.role!==`user`)),o(`work.activity.toolActivity`,{defaultValue:`Tool activity`})),[p,f,o]),h=[...f].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,V.useEffect)(()=>{l.current=!0;let e=s.current;e&&(e.scrollTop=e.scrollHeight);let t=window.requestAnimationFrame(()=>d(!1));return()=>window.cancelAnimationFrame(t)},[e.id]),(0,V.useEffect)(()=>{let e=s.current,t;return e&&l.current?(e.scrollTop=e.scrollHeight,t=window.requestAnimationFrame(()=>d(!1))):e&&i&&(t=window.requestAnimationFrame(()=>d(!0))),()=>{t!==void 0&&window.cancelAnimationFrame(t)}},[i,f,e.status]);let g=async()=>{let e=s.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;l.current=!1;try{await a(),requestAnimationFrame(()=>{let e=s.current;e&&(e.scrollTop=n+e.scrollHeight-t)})}catch{}};return n&&f.length===0?(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,H.jsx)(F,{className:`h-6 w-6 animate-spin`})}):(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,H.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;l.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,l.current&&d(!1)},className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsx)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col px-4 py-6 md:px-6`,children:f.length===0&&!i?(0,H.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,H.jsx)(Fe,{role:`assistant`,size:`empty`}),(0,H.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:o(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,H.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-ink-muted`,children:o(`work.conversation.empty`,{defaultValue:`Continue the task below. This conversation and its files stay attached to this workspace.`})})]}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`work-load-older-messages`,disabled:r,onClick:()=>void g(),className:`inline-flex items-center gap-2 rounded-lg border border-line bg-surface-raised px-3 py-1.5 text-xs font-medium text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink disabled:cursor-not-allowed disabled:opacity-60`,children:[r&&(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),o(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),m.map(({key:n,item:r})=>{if(r.type===`reasoning`)return(0,H.jsx)(ze,{message:r.message},n);if(r.type===`tools`)return(0,H.jsx)(`div`,{className:`ms-14 space-y-1.5`,children:r.tools.map(e=>(0,H.jsx)(je,{tool:e,expandedByDefault:!1},e.id))},n);let i=r.message,a=i.role===`user`,o=!a&&e.status===`running`&&i.id===h&&i.runId===e.activeRun?.id;return(0,H.jsxs)(`article`,{className:L(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,H.jsx)(Fe,{role:a?`user`:`assistant`,user:a?t:void 0}),(0,H.jsx)(`div`,{className:L(`min-w-0 max-w-[88%]`,a&&`rounded-2xl rounded-se-md bg-ink px-4 py-2.5 text-ink-inverse`),children:a?(0,H.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content}):o?(0,H.jsx)(ye,{content:i.content,className:`text-ink`}):(0,H.jsx)(Se,{content:i.content,className:`text-sm text-ink`})})]},i.id)}),i&&(0,H.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,H.jsx)(Fe,{role:`assistant`}),(0,H.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,H.jsx)(Pe,{run:i})})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),e.status===`preparing`?o(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):o(`work.status.running`,{defaultValue:`Working in the local workspace…`})]})]})})}),u&&(0,H.jsxs)(`button`,{type:`button`,"data-testid":`work-new-activity-button`,onClick:()=>{let e=s.current;e&&(e.scrollTop=e.scrollHeight),l.current=!0,d(!1)},className:`absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-line bg-surface-overlay/95 px-3 py-2 text-xs font-medium text-ink shadow-overlay backdrop-blur transition-colors hover:bg-surface-raised`,children:[(0,H.jsx)(le,{className:`h-3.5 w-3.5`}),o(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var Ve=45,He=30,Ue=70,We=360,Ge=480,J=9,Ke=2,qe=10,Je=`libre-webui-work-split:`,Ye=(e,t,n)=>Math.min(n,Math.max(t,e)),Xe=e=>`${Je}${encodeURIComponent(e||`local`)}`,Ze=e=>{if(typeof window>`u`)return Ve;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return Ve;let n=Number(t);return Number.isFinite(n)?Ye(n,He,Ue):Ve}catch{return Ve}},Qe=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},Y=e=>{let t=Math.max(0,e-J);if(t===0)return{min:He,max:Ue};let n=Math.max(He,We/t*100),r=Math.min(Ue,(t-Ge)/t*100);if(n<=r)return{min:n,max:r};let i=Ye(We/840*100,He,Ue);return{min:i,max:i}},X=(e,t)=>Ye(e,t.min,t.max);function $e({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=l(o.language),u=Xe(n),[d,f]=(0,V.useState)(()=>({storageKey:u,percent:Ze(u)})),[p,m]=(0,V.useState)(0),[h,g]=(0,V.useState)(!1),_=(0,V.useRef)(null),v=(0,V.useRef)(null),y=(0,V.useRef)(null),b=(0,V.useRef)(u),x=(0,V.useRef)(d.percent),S=(0,V.useRef)(null),C=d.storageKey===u?d.percent:Ze(u),w=(0,V.useMemo)(()=>Y(p),[p]),T=X(C,w),E=Math.round(T),D=100-E,O=(0,V.useCallback)(e=>{f({storageKey:u,percent:e})},[u]),k=(0,V.useCallback)(e=>{let t=X(e,Y(_.current?.getBoundingClientRect().width??0));x.current=t,S.current===null&&(S.current=window.requestAnimationFrame(()=>{S.current=null,O(x.current)}))},[O]),A=(0,V.useCallback)(()=>{if(y.current===null&&!h)return;S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null);let e=_.current?.getBoundingClientRect().width??0,t=X(x.current,Y(e));x.current=t,O(t),Qe(b.current,t);let n=y.current;y.current=null,n!==null&&v.current?.hasPointerCapture(n)&&v.current.releasePointerCapture(n),g(!1)},[h,O]),j=(0,V.useCallback)(e=>{let t=_.current?.getBoundingClientRect();if(!t)return x.current;let n=Math.max(1,t.width-J);return((s?t.right-e:e-t.left)-J/2)/n*100},[s]),M=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),y.current=e.pointerId,b.current=u,x.current=T,e.currentTarget.setPointerCapture(e.pointerId),g(!0))},ee=(0,V.useCallback)(e=>{let t=X(e,w);x.current=t,O(t),Qe(u,t)},[w,O,u]),te=(0,V.useCallback)(()=>{ee(Ve)},[ee]),N=e=>{let t=e.shiftKey?qe:Ke,n=null;e.key===`ArrowLeft`?n=T+(s?t:-t):e.key===`ArrowRight`?n=T+(s?-t:t):e.key===`Home`?n=w.min:e.key===`End`?n=w.max:e.key===`Enter`&&(n=Ve),n!==null&&(e.preventDefault(),ee(n))};(0,V.useEffect)(()=>{let e=_.current;if(!e)return;if(typeof ResizeObserver>`u`){let t=()=>m(e.getBoundingClientRect().width);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}let t=new ResizeObserver(e=>{let t=e[0];t&&m(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),(0,V.useEffect)(()=>{if(!h)return;let e=document.body.style.cursor,t=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let n=e=>{e.pointerId===y.current&&(e.preventDefault(),k(j(e.clientX)))},r=e=>{e.pointerId===y.current&&A()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,A),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,A),document.body.style.cursor=e,document.body.style.userSelect=t}},[A,h,j,k]),(0,V.useEffect)(()=>()=>{S.current!==null&&window.cancelAnimationFrame(S.current),y.current!==null&&Qe(b.current,x.current)},[]);let ne={gridTemplateColumns:`minmax(0, ${T}fr) ${J}px minmax(0, ${100-T}fr)`};return(0,H.jsxs)(`div`,{ref:_,"data-testid":`work-split-pane`,"data-split-percent":T.toFixed(2),"data-resizing":h?`true`:`false`,className:L(`relative flex min-h-0 min-w-0 flex-1 overflow-hidden xl:grid`,i),style:ne,children:[(0,H.jsx)(`section`,{id:`work-conversation-panel`,"data-testid":`work-conversation-panel`,className:L(`min-h-0 min-w-0 flex-1 flex-col bg-transparent xl:flex`,r===`conversation`?`flex`:`hidden`),children:e}),(0,H.jsxs)(`div`,{ref:v,role:`separator`,"aria-orientation":`vertical`,"aria-controls":`work-conversation-panel work-workspace-panel`,"aria-label":a(`work.workspace.resize`,{defaultValue:`Resize conversation and workspace`}),"aria-valuemin":Math.round(w.min),"aria-valuemax":Math.round(w.max),"aria-valuenow":E,"aria-valuetext":a(`work.workspace.splitSize`,{conversation:E,workspace:D,defaultValue:`Conversation {{conversation}}%, workspace {{workspace}}%`}),title:a(`work.workspace.resizeHint`,{defaultValue:`Drag to resize. Use arrow keys for precise control. Double-click or press Enter to reset.`}),tabIndex:0,"data-testid":`work-split-resizer`,onPointerDown:M,onDoubleClick:te,onKeyDown:N,className:L(`group relative z-40 hidden h-full cursor-col-resize touch-none select-none items-center justify-center outline-none xl:flex`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52]`),children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:L(`pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-line transition-colors`,`group-hover:bg-[#ff7b52] group-focus-visible:bg-[#ff7b52]`,h&&`bg-[#ff7b52]`)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:L(`pointer-events-none relative h-14 w-1 rounded-full bg-ink-subtle/50 opacity-60 transition-[height,background-color,opacity]`,`group-hover:h-20 group-hover:bg-[#ff7b52] group-hover:opacity-100`,`group-focus-visible:h-20 group-focus-visible:bg-[#ff7b52] group-focus-visible:opacity-100`,h&&`h-20 bg-[#ff7b52] opacity-100`)})]}),(0,H.jsx)(`section`,{id:`work-workspace-panel`,"data-testid":`work-workspace-panel`,className:L(`min-h-0 min-w-0 flex-1 flex-col bg-surface-raised/85 backdrop-blur-xl xl:flex`,r===`workspace`?`flex`:`hidden`),children:t}),h&&(0,H.jsx)(`div`,{"data-testid":`work-split-drag-shield`,"aria-hidden":`true`,className:`absolute inset-0 z-30 hidden cursor-col-resize select-none xl:block`})]})}var Z=1e5,et=4e3,tt={bash:`bash`,c:`c`,cc:`cpp`,cjs:`javascript`,cpp:`cpp`,cs:`csharp`,csh:`bash`,css:`css`,cts:`typescript`,cxx:`cpp`,diff:`diff`,go:`go`,h:`c`,hpp:`cpp`,htm:`markup`,html:`markup`,java:`java`,js:`javascript`,json:`json`,json5:`json`,jsonc:`json`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`css`,md:`markdown`,mdx:`markdown`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,py:`python`,rb:`ruby`,rs:`rust`,scss:`css`,sh:`bash`,sql:`sql`,svg:`markup`,swift:`swift`,ts:`typescript`,tsx:`tsx`,xml:`markup`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},nt={".bashrc":`bash`,".zshrc":`bash`},rt={cjs:{family:`babel`,parser:`babel`},css:{family:`postcss`,parser:`css`},cts:{family:`typescript`,parser:`typescript`},htm:{family:`html`,parser:`html`},html:{family:`html`,parser:`html`},js:{family:`babel`,parser:`babel`},json:{family:`babel`,parser:`json`},json5:{family:`babel`,parser:`json5`},jsonc:{family:`babel`,parser:`json`},jsx:{family:`babel`,parser:`babel`},less:{family:`postcss`,parser:`less`},md:{family:`markdown`,parser:`markdown`},mdx:{family:`markdown`,parser:`mdx`},mjs:{family:`babel`,parser:`babel`},mts:{family:`typescript`,parser:`typescript`},scss:{family:`postcss`,parser:`scss`},ts:{family:`typescript`,parser:`typescript`},tsx:{family:`typescript`,parser:`typescript`},yaml:{family:`yaml`,parser:`yaml`},yml:{family:`yaml`,parser:`yaml`}},it=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,at=e=>{let t=it(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},ot=e=>nt[it(e)]??tt[at(e)]??`text`,st=e=>rt[at(e)],ct=e=>st(e)!==void 0,lt=e=>{if(e.length>1e5)return!1;let t=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&(t+=1,t>4e3))return!1;return!0},Q=async e=>(await e).default,ut=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),Q(a(()=>import(`./estree-BAxGO-Uf.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))]);case`typescript`:return Promise.all([Q(a(()=>import(`./typescript-ClQp1SgP.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),Q(a(()=>import(`./estree-BAxGO-Uf.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))]);case`postcss`:return[await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))];case`html`:{let e=[await Q(a(()=>import(`./html-DL8k6nha.js`),__vite__mapDeps([26,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))];return/<script\b/i.test(t)&&e.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BAxGO-Uf.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await Q(a(()=>import(`./typescript-ClQp1SgP.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),/<style\b/i.test(t)&&e.push(await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await Q(a(()=>import(`./markdown-CKunEqMI.js`),__vite__mapDeps([27,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))],r=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BAxGO-Uf.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),r(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BAxGO-Uf.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),r(`ts|tsx|typescript`)&&n.push(await Q(a(()=>import(`./typescript-ClQp1SgP.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./estree-BAxGO-Uf.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),r(`css|scss|less`)&&n.push(await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))),r(`html`)&&n.push(await Q(a(()=>import(`./html-DL8k6nha.js`),__vite__mapDeps([26,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BAxGO-Uf.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./typescript-ClQp1SgP.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))),r(`yaml|yml`)&&n.push(await Q(a(()=>import(`./yaml-QD4znPfZ.js`),__vite__mapDeps([28,1,2,3])))),[...new Set(n)]}case`yaml`:return[await Q(a(()=>import(`./yaml-QD4znPfZ.js`),__vite__mapDeps([28,1,2,3])))]}},dt=async(e,t)=>{let n=st(e);if(!n)throw Error(`Formatting is not supported for “${it(e)||e}”.`);if(!lt(t))throw Error(`Could not format “${it(e)||e}”: files are limited to ${Z.toLocaleString()} characters and ${et.toLocaleString()} lines.`);try{let[{format:e},r]=await Promise.all([a(()=>import(`./standalone-qHCG6_XI.js`),__vite__mapDeps([29,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),ut(n,t)]);return await e(t,{parser:n.parser,plugins:r,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${it(e)||e}”: ${n}`)}},ft=(0,V.lazy)(async()=>({default:(await a(()=>import(`./OptimizedSyntaxHighlighter-CWYUn9Oe.js`).then(e=>e.n),__vite__mapDeps([30,2,3,31]))).OptimizedSyntaxHighlighter})),pt=8e3,mt=400,ht=500;function gt({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),l=ve(e=>e.theme.mode===`dark`),u=(0,V.useRef)(null),d=(0,V.useRef)(null),[f,p]=(0,V.useState)(``),m=(0,V.useMemo)(()=>ot(e),[e]),h=(0,V.useMemo)(()=>{if(t.length>pt)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>mt));n+=1);return e},[t]),g=t.length>pt||h>mt,_=m!==`text`&&!g,v=_&&f===t;return(0,V.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>p(t),ht);return()=>window.clearTimeout(e)},[_,e,t]),(0,V.useLayoutEffect)(()=>{!v||!u.current||!d.current||(u.current.style.transform=`translate3d(${-d.current.scrollLeft}px, ${-d.current.scrollTop}px, 0)`)},[v,e]),(0,H.jsxs)(`div`,{dir:`ltr`,className:L(`relative min-h-0 flex-1 overflow-hidden bg-surface focus-within:ring-1 focus-within:ring-inset focus-within:ring-primary-500/60`,r&&`opacity-60`),"data-language":m,"data-highlighted":v?`true`:`false`,children:[v&&(0,H.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,H.jsx)(`div`,{ref:u,"data-testid":`work-file-highlight-content`,className:`min-h-full min-w-full origin-top-left will-change-transform`,children:(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`pre`,{className:`m-0 min-h-full min-w-full whitespace-pre p-4 text-left font-mono text-[12px] leading-5 text-ink`,children:t||`​`}),children:(0,H.jsx)(ft,{language:m,isDark:l,backgroundColor:`transparent`,borderRadius:0,customStyle:{margin:0,minHeight:`100%`,minWidth:`100%`,width:`max-content`,overflow:`visible`,padding:`1rem`,fontSize:`12px`,lineHeight:`20px`,tabSize:2,whiteSpace:`pre`},children:f||`​`})})})}),(0,H.jsx)(`textarea`,{ref:d,"data-testid":`work-file-editor`,"data-language":m,"aria-label":n,value:t,onChange:e=>i(e.target.value),onScroll:e=>{u.current&&(u.current.style.transform=`translate3d(${-e.currentTarget.scrollLeft}px, ${-e.currentTarget.scrollTop}px, 0)`)},onKeyDown:e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`s`){e.preventDefault(),a();return}e.altKey&&e.shiftKey&&t===`f`&&(e.preventDefault(),o())},disabled:r,spellCheck:!1,wrap:`off`,className:L(`absolute inset-0 z-10 h-full w-full resize-none overflow-auto whitespace-pre border-0 bg-transparent p-4 text-left font-mono text-[12px] leading-5 outline-none selection:bg-primary-500/25 disabled:cursor-not-allowed`,v?`text-transparent caret-ink`:`text-ink`),style:v?{WebkitTextFillColor:`transparent`,caretColor:`rgb(var(--color-ink))`,tabSize:2}:{tabSize:2}}),g&&(0,H.jsx)(`span`,{dir:`auto`,className:`pointer-events-none absolute bottom-2 end-3 z-20 rounded-md border border-line bg-surface-overlay/90 px-2 py-1 text-[10px] text-ink-muted shadow-subtle`,title:s(`work.files.highlightPaused`,{defaultValue:`Live highlighting is paused for large files to keep editing responsive.`}),children:s(`work.files.plainTextLarge`,{defaultValue:`Plain text · large file`})})]})}var _t=4e6,vt=e=>{if(e===``)return[];let t=e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-CmENXdZw.js","js/router-vendor-Ca9zqOqT.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-DHnR5Hw8.js","js/estree-BuWOCMW0.js","assets/index-Cd0_AoYV.js","js/react-vendor-DPNXrO-8.js","js/useTranslation-CdeLZqSW.js","js/i18n-CLd1FZPx.js","js/i18next-DgmgtwsV.js","js/ui-vendor-D_pYT79f.js","js/utils-vendor-1zob7nK9.js","js/logger-DSXjF4ye.js","js/config-CuXlcWP1.js","js/api-MySpmAK8.js","js/utils-BhpNrGnR.js","js/chatStore-CWqfsOjc.js","js/authStore-DmrydYuS.js","js/appStore-BpoXhleX.js","js/welcomePrompts-to5mv_gx.js","js/messageCodeStyles-BlTi46wI.js","js/Button-X9TT9gTD.js","js/ui-DFQiHo_k.js","assets/index-DtkGuqvC.css","js/typescript-DQ5zi5zo.js","js/postcss-B5WIGhAY.js","js/html-D7tW7UvW.js","js/markdown-CBSxWEtK.js","js/yaml-QD4znPfZ.js","js/standalone-CaXys7q3.js","js/OptimizedSyntaxHighlighter-CWYUn9Oe.js","js/syntax-highlight-Ca9bHsaz.js","assets/xterm-DHcfr8qj.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{d as r,f as i,i as a,l as o,u as s}from"./router-vendor-Ca9zqOqT.js";import{t as c}from"./useTranslation-CdeLZqSW.js";import{i as l}from"./i18n-CLd1FZPx.js";import{$t as u,B as d,Bt as f,C as p,Ct as m,Dt as h,F as g,It as _,L as v,Mt as y,N as b,Nt as x,Q as S,R as C,Sn as w,St as T,T as E,Tn as D,V as O,Vt as k,an as A,c as j,dn as M,i as ee,in as te,kt as N,m as ne,n as P,on as re,pn as ie,st as F,tt as ae,vn as oe,vt as se,x as ce,yn as le}from"./ui-vendor-D_pYT79f.js";import{t as ue}from"./config-CuXlcWP1.js";import{c as de,o as I}from"./api-MySpmAK8.js";import{t as L}from"./utils-BhpNrGnR.js";import{t as R}from"./chatStore-CWqfsOjc.js";import{a as fe,i as pe,l as me,n as he,o as ge,s as _e}from"./authStore-DmrydYuS.js";import{t as ve}from"./appStore-BpoXhleX.js";import{t as z}from"./Button-X9TT9gTD.js";import{u as ye}from"./ui-DFQiHo_k.js";import{c as be,l as xe}from"../assets/index-Cd0_AoYV.js";import{t as Se}from"./RichMessageContent-DNl3_CIw.js";import{t as Ce}from"./ModelSelector-C1wN91tl.js";import{n as we,t as B}from"./work-DVgm81bJ.js";var V=e(n(),1),H=t(),Te=e=>we({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),U=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},W=e=>{let t=`${e.model} · `;return{name:e.model,model:e.model,size:0,digest:``,modified_at:``,details:{},isPlugin:e.providerType===`plugin`,pluginId:e.providerId,pluginName:e.providerType===`plugin`?e.label.startsWith(t)?e.label.slice(t.length):e.providerId:void 0}};function Ee({models:e,selectorModels:t,modelKey:n,running:r,loading:i,variant:a=`task`,disabled:o=!1,remoteDisclosureDismissed:s,remoteDisclosureSaving:l,onModelChange:d,onDismissRemoteDisclosure:f,onModelsRefresh:p,onSubmit:m,onCancel:h}){let{t:g}=c(),[_,v]=(0,V.useState)(``),y=(0,V.useRef)(null),x=(0,V.useRef)(null),S=(0,V.useRef)(null),C=e.find(e=>e.key===n),w=C?.remote===!0,T=a===`landing`,E=(0,V.useMemo)(()=>{let n=new Set(t.map(Te)),r=e.filter(e=>!n.has(e.key)).map(W);return[...t,...r]},[e,t]);(0,V.useEffect)(()=>{let e=y.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[_]);let D=async()=>{await f()&&([x.current,S.current].find(e=>e&&e.offsetParent!==null)||x.current)?.focus()},O=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&d(n.key)},k=async()=>{let e=_.trim();!e||i||r||o||!C||await m(e)&&v(``)};return(0,H.jsxs)(`div`,{"data-testid":T?`work-landing-composer`:`work-task-composer`,"data-variant":a,className:L(`relative shrink-0`,T?`mt-10 w-full`:`border-t border-line bg-surface/95 px-3 py-3 backdrop-blur md:px-5`),children:[w&&!s&&(0,H.jsx)(`div`,{className:L(`absolute inset-x-3 z-30 mx-auto max-w-3xl md:inset-x-5`,`bottom-full mb-3`),children:(0,H.jsxs)(`aside`,{"data-testid":`work-provider-disclosure-popover`,"aria-labelledby":`work-provider-disclosure-title`,"aria-live":`polite`,className:`relative rounded-2xl border border-warning-500/40 bg-surface-overlay p-3 pe-10 shadow-overlay backdrop-blur dark:border-warning-500/45`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:l,className:`absolute end-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-warning-500/20 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-warning-500 disabled:cursor-wait disabled:opacity-50`,"aria-label":g(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-warning-500/20`,children:(0,H.jsx)(u,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:g(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:g(`work.composer.remoteHint`,{defaultValue:`Conversation and tool output are sent to the configured service. One autonomous run can make multiple provider calls and may incur charges. Workspace files stay local unless a tool returns their contents.`})}),(0,H.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,H.jsx)(z,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:l,className:`h-7 border-warning-500 bg-warning-500 px-2.5 text-xs text-[#3d120c] hover:bg-warning-500/90 hover:text-[#3d120c]`,onClick:()=>void D(),children:g(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,H.jsx)(`form`,{className:`mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),k()},children:(0,H.jsxs)(`div`,{"data-testid":`work-composer-surface`,className:L(`flex items-end gap-2 rounded-[1.6rem] border p-2.5 transition-[border-color,box-shadow,background-color] duration-200 sm:p-3`,`border-black/[0.08] bg-surface/90 dark:border-white/[0.09] dark:bg-dark-200/90`,`shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_50px_rgba(15,23,42,0.08)] backdrop-blur-xl`,`focus-within:border-primary-500/35 focus-within:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_22px_65px_rgba(15,23,42,0.12)]`),children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(`textarea`,{ref:y,"data-testid":`work-composer-input`,dir:`auto`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),k())},disabled:o||r,rows:1,className:`m-0 block max-h-[160px] min-h-10 w-full resize-none overflow-y-auto rounded-none border-0 bg-transparent p-2 text-base leading-relaxed text-ink shadow-none outline-none placeholder:text-ink-subtle focus:border-0 focus:bg-transparent focus:ring-0 disabled:cursor-not-allowed disabled:opacity-60`,placeholder:g(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})})}),(0,H.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,H.jsx)(Ce,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Te,getModelLabel:U,getModelTitle:e=>e.name,triggerRef:x,triggerTestId:`work-model-selector-trigger`,selectTestId:`work-model-select`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`min-w-[150px] max-w-[230px]`,compact:!0})}),r?(0,H.jsx)(z,{"data-testid":`work-cancel-button`,type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full bg-error-500/15 p-0 text-error-600 transition-colors duration-150 hover:bg-error-500/25 dark:text-error-400 sm:h-10 sm:w-10`,title:g(`work.composer.cancel`,{defaultValue:`Stop`}),"aria-label":g(`work.composer.cancel`,{defaultValue:`Stop`}),onClick:()=>void h(),children:i?(0,H.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(ce,{className:`h-4 w-4 fill-current`})}):(0,H.jsx)(z,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!_.trim()||!C,className:L(`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors duration-150 sm:h-10 sm:w-10`,`bg-gray-950 text-white hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,`disabled:bg-gray-100 disabled:text-gray-400 disabled:hover:bg-gray-100 dark:disabled:bg-dark-300 dark:disabled:text-dark-500 dark:disabled:hover:bg-dark-300`,_.trim()&&C&&!o&&`shadow-sm`),title:g(`work.composer.send`,{defaultValue:`Run`}),"aria-label":g(`work.composer.send`,{defaultValue:`Run`}),children:i?(0,H.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(b,{className:`h-4 w-4`})})]})}),(0,H.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,H.jsx)(Ce,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Te,getModelLabel:U,getModelTitle:e=>e.name,triggerRef:S,triggerTestId:`work-model-selector-trigger-mobile`,selectTestId:`work-model-select-mobile`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`w-full`,compact:!0})})]})}var De=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},Oe=e=>{if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}s`},ke=e=>{if(!e)return 0;let t=Array.from(e).length,n=e.trim()?e.trim().split(/\s+/u).length:0;return Math.max(n,Math.ceil(t/4))};function Ae({run:e}){let[t,n]=(0,V.useState)();if((0,V.useEffect)(()=>{if(e.terminal||!e.startedAt)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e.startedAt,e.terminal]),!e.startedAt)return null;let r=e.finishedAt||t;return r?(0,H.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:Oe(r-e.startedAt)}):null}function je({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,V.useState)(e.status),[i,a]=(0,V.useState)(null),o=(0,V.useMemo)(()=>De(e.arguments),[e.arguments]),s=e.output||null,l=!!(o||s),d=e.status===`error`,f=e.status===`running`,p=(0,V.useId)(),m=d?n(`work.activity.kinds.error`,{defaultValue:`Error`}):f?n(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}):n(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),h=i??(e.status===r?t:e.status===`error`);return(0,H.jsxs)(`div`,{"data-testid":`work-live-tool`,"data-tool-id":e.id,className:L(`overflow-hidden rounded-xl border bg-surface-raised transition-colors`,d?`border-error-500/30`:`border-line`),children:[(0,H.jsxs)(`button`,{type:`button`,disabled:!l,onClick:()=>{a(!h)},"aria-expanded":l?h:void 0,"aria-controls":l?p:void 0,"aria-label":`${m}: ${e.name}`,className:`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-start outline-none hover:bg-surface-subtle focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52] disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,H.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:d?(0,H.jsx)(u,{className:`h-3.5 w-3.5 text-error-500`}):f?(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,H.jsx)(re,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,H.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-xs text-ink`,children:e.name}),e.durationMs!==void 0&&(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:Oe(e.durationMs)}),l&&(0,H.jsx)(A,{"aria-hidden":`true`,className:L(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,h&&`rotate-180`)})]}),l&&h&&(0,H.jsxs)(`div`,{id:p,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,H.jsx)(`pre`,{dir:`ltr`,className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:o}),s&&(0,H.jsx)(`pre`,{dir:`ltr`,className:L(`max-h-64 overflow-auto whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed`,d?`text-error-600`:`text-ink-muted`),children:s})]})]})}var G=e=>{let t=e.split(`
3
+ `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n)return n}return``};function K({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,V.useState)(!1),a=t&&!r?G(e):``;return(0,H.jsxs)(`details`,{"data-testid":`work-live-reasoning`,open:r,onToggle:e=>i(e.currentTarget.open),className:`group overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(M,{className:L(`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`,t&&`animate-pulse-subtle motion-reduce:animate-none`)}),t?(0,H.jsxs)(`span`,{className:`animate-shimmer truncate bg-gradient-to-r from-ink-subtle via-ink to-ink-subtle bg-[length:200%_100%] bg-clip-text text-transparent motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-ink-muted`,children:[n(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),`…`]}):(0,H.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,H.jsx)(A,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,H.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,H.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,H.jsx)(ye,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var Me=(e,t,n)=>e===`queued`||e===`preparing`?t(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):e===`using_tool`?n?.name?`${t(`work.activity.toolActivity`,{defaultValue:`Tool activity`})} · ${n.name}`:t(`work.activity.toolActivity`,{defaultValue:`Tool activity`}):e===`completed`?t(`work.statusLabels.complete`,{defaultValue:`Complete`}):e===`needs_input`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`failed`?t(`work.statusLabels.error`,{defaultValue:`Error`}):e===`cancelled`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`responding`?t(`work.status.running`,{defaultValue:`Working in the local workspace…`}):t(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),Ne=(e,t)=>{if(e===`connecting`)return t(`work.live.connecting`,{defaultValue:`Connecting to live updates…`});if(e===`reconnecting`)return t(`work.live.reconnecting`,{defaultValue:`Reconnecting to live updates…`});if(e===`error`)return t(`work.live.unavailable`,{defaultValue:`Live updates unavailable`})};function Pe({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=Ne(e.connection,n)||Me(e.phase,n,r),a=!e.terminal,o=e.usage?.outputTokens,s=e.reasoning+e.response,l=o!==void 0&&o>0?o:s?ke(s):o,d=(o===void 0||o===0)&&!!s&&l!==void 0,f=e.usage?.tokensPerSecond;return(0,H.jsxs)(`section`,{"data-testid":`work-live-run`,"data-run-id":e.runId,"data-phase":e.phase,"aria-busy":a||void 0,className:L(`min-w-0`,t===`activity`&&`rounded-2xl border border-line bg-surface p-3 shadow-subtle`),children:[(0,H.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:L(`h-2 w-2 shrink-0 rounded-full`,e.phase===`failed`?`bg-[rgb(255,61,129)]`:e.phase===`completed`?`bg-[rgb(76,212,117)]`:e.phase===`needs_input`||e.phase===`cancelled`?`bg-[rgb(255,204,0)]`:e.connection===`error`?`bg-[rgb(255,61,129)]`:`bg-[rgb(48,121,255)]`,a&&`animate-pulse motion-reduce:animate-none`)}),(0,H.jsx)(`span`,{dir:`auto`,title:e.connectionError,className:`min-w-0 flex-1 truncate font-medium text-ink-muted`,children:i}),e.round!==void 0&&(0,H.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,H.jsx)(Ae,{run:e})]}),t===`conversation`&&(0,H.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,H.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-raised px-2 py-1 text-[10px] text-ink-muted`,children:[(0,H.jsx)(E,{className:`h-3 w-3 text-[#ff7b52]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]})}),t===`conversation`?e.timeline.length>0&&(0,H.jsx)(`div`,{"data-testid":`work-live-timeline`,className:`space-y-2`,children:e.timeline.map((t,n)=>{let r=n===e.timeline.length-1;if(t.kind===`reasoning`)return(0,H.jsx)(K,{content:t.text,streaming:a&&r},`segment-${n}`);if(t.kind===`tool`){let n=e.tools.find(e=>e.id===t.toolId);return n?(0,H.jsx)(je,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,H.jsx)(ye,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,H.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,H.jsx)(je,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,H.jsxs)(`div`,{role:`alert`,dir:`auto`,className:`mt-3 flex items-start gap-2 rounded-xl border border-error-500/30 bg-error-500/10 px-3 py-2.5 text-xs leading-relaxed text-error-600`,children:[(0,H.jsx)(u,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:e.error})]}),(l!==void 0||f!==void 0)&&(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-line pt-2 text-[10px] tabular-nums text-ink-subtle`,children:[l!==void 0&&(0,H.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,H.jsxs)(`bdi`,{dir:`ltr`,children:[d&&`≈`,l.toLocaleString()]})]}),f!==void 0&&(0,H.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,H.jsxs)(`bdi`,{dir:`ltr`,children:[f.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:320ms] motion-reduce:animate-none`})]}),t===`activity`&&e.tools.length===0&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,H.jsx)(p,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}function Fe({role:e,user:t,size:n=`message`}){let[r,i]=(0,V.useState)(null);if(e===`assistant`)return(0,H.jsx)(`div`,{role:`img`,"aria-label":`Libre WebUI`,"data-testid":`work-assistant-avatar`,className:L(`flex shrink-0 items-center justify-center rounded-full border border-line bg-surface-raised text-ink shadow-subtle`,n===`empty`?`mx-auto mb-4 h-12 w-12`:`mt-0.5 h-8 w-8`),children:(0,H.jsx)(xe,{label:null,className:L(n===`empty`?`h-6 w-6`:`h-4 w-4`)})});let a=t?.username||`User`,o=t?.avatar?.trim()||``,s=!!o&&o!==r;return(0,H.jsx)(`div`,{role:s?void 0:`img`,"aria-label":s?void 0:a,"data-testid":`work-user-avatar`,className:L(`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full`,s?`border border-line bg-surface-raised`:`bg-ink text-ink-inverse`),title:a,children:s?(0,H.jsx)(`img`,{src:o,alt:a,className:`h-full w-full object-cover`,onError:()=>i(o)}):t?(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,H.jsx)(j,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Ie=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},Le=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},q=(e,t,n)=>{let r=e??t,i=t?.kind===`error`||t?.metadata?.isError===!0||!t&&r?.kind===`error`,a=t?.metadata?.durationMs;return{id:(e??t)?.id??`tool`,name:r?Ie(r,n):n,status:i?`error`:`completed`,arguments:e?.metadata,output:t?.content||(!t&&e?e.content:void 0),durationMs:typeof a==`number`?a:void 0}},Re=(e,t)=>{let n=[],r=new Map,i=(e,t)=>{let r=n[n.length-1];return r?.item.type===`tools`?(r.item.tools.push(e),r.item.tools.length-1):(n.push({key:t,item:{type:`tools`,tools:[e]}}),0)};for(let a of e){if(a.kind===`reasoning`){n.push({key:a.id,item:{type:`reasoning`,message:a}});continue}if(a.role!==`tool`&&a.kind===`message`){n.push({key:a.id,item:{type:`message`,message:a}});continue}let e=Le(a);if(a.kind===`tool_call`&&e){let o=i(q(a,void 0,t),a.id);r.set(e,{itemIndex:n.length-1,toolIndex:o,call:a});continue}if(a.kind===`tool_result`&&e){let i=r.get(e);if(i){let o=n[i.itemIndex];if(o.item.type===`tools`){o.item.tools[i.toolIndex]=q(i.call,a,t),r.delete(e);continue}}}i(q(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function ze({message:e}){let{t}=c();return(0,H.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-ink-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,H.jsx)(A,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,H.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:e.content})]})}function Be({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a}){let{t:o}=c(),s=(0,V.useRef)(null),l=(0,V.useRef)(!0),[u,d]=(0,V.useState)(!1),f=(0,V.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),p=i?.runId,m=(0,V.useMemo)(()=>Re(f.filter(e=>!(p&&e.runId===p&&e.role!==`user`)),o(`work.activity.toolActivity`,{defaultValue:`Tool activity`})),[p,f,o]),h=[...f].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,V.useEffect)(()=>{l.current=!0;let e=s.current;e&&(e.scrollTop=e.scrollHeight);let t=window.requestAnimationFrame(()=>d(!1));return()=>window.cancelAnimationFrame(t)},[e.id]),(0,V.useEffect)(()=>{let e=s.current,t;return e&&l.current?(e.scrollTop=e.scrollHeight,t=window.requestAnimationFrame(()=>d(!1))):e&&i&&(t=window.requestAnimationFrame(()=>d(!0))),()=>{t!==void 0&&window.cancelAnimationFrame(t)}},[i,f,e.status]);let g=async()=>{let e=s.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;l.current=!1;try{await a(),requestAnimationFrame(()=>{let e=s.current;e&&(e.scrollTop=n+e.scrollHeight-t)})}catch{}};return n&&f.length===0?(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,H.jsx)(F,{className:`h-6 w-6 animate-spin`})}):(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,H.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;l.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,l.current&&d(!1)},className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsx)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col px-4 py-6 md:px-6`,children:f.length===0&&!i?(0,H.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,H.jsx)(Fe,{role:`assistant`,size:`empty`}),(0,H.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:o(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,H.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-ink-muted`,children:o(`work.conversation.empty`,{defaultValue:`Continue the task below. This conversation and its files stay attached to this workspace.`})})]}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`work-load-older-messages`,disabled:r,onClick:()=>void g(),className:`inline-flex items-center gap-2 rounded-lg border border-line bg-surface-raised px-3 py-1.5 text-xs font-medium text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink disabled:cursor-not-allowed disabled:opacity-60`,children:[r&&(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),o(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),m.map(({key:n,item:r})=>{if(r.type===`reasoning`)return(0,H.jsx)(ze,{message:r.message},n);if(r.type===`tools`)return(0,H.jsx)(`div`,{className:`ms-14 space-y-1.5`,children:r.tools.map(e=>(0,H.jsx)(je,{tool:e,expandedByDefault:!1},e.id))},n);let i=r.message,a=i.role===`user`,o=!a&&e.status===`running`&&i.id===h&&i.runId===e.activeRun?.id;return(0,H.jsxs)(`article`,{className:L(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,H.jsx)(Fe,{role:a?`user`:`assistant`,user:a?t:void 0}),(0,H.jsx)(`div`,{className:L(`min-w-0 max-w-[88%]`,a&&`rounded-2xl rounded-se-md bg-ink px-4 py-2.5 text-ink-inverse`),children:a?(0,H.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content}):o?(0,H.jsx)(ye,{content:i.content,className:`text-ink`}):(0,H.jsx)(Se,{content:i.content,className:`text-sm text-ink`})})]},i.id)}),i&&(0,H.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,H.jsx)(Fe,{role:`assistant`}),(0,H.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,H.jsx)(Pe,{run:i})})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),e.status===`preparing`?o(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):o(`work.status.running`,{defaultValue:`Working in the local workspace…`})]})]})})}),u&&(0,H.jsxs)(`button`,{type:`button`,"data-testid":`work-new-activity-button`,onClick:()=>{let e=s.current;e&&(e.scrollTop=e.scrollHeight),l.current=!0,d(!1)},className:`absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-line bg-surface-overlay/95 px-3 py-2 text-xs font-medium text-ink shadow-overlay backdrop-blur transition-colors hover:bg-surface-raised`,children:[(0,H.jsx)(le,{className:`h-3.5 w-3.5`}),o(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var Ve=45,He=30,Ue=70,We=360,Ge=480,J=9,Ke=2,qe=10,Je=`libre-webui-work-split:`,Ye=(e,t,n)=>Math.min(n,Math.max(t,e)),Xe=e=>`${Je}${encodeURIComponent(e||`local`)}`,Ze=e=>{if(typeof window>`u`)return Ve;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return Ve;let n=Number(t);return Number.isFinite(n)?Ye(n,He,Ue):Ve}catch{return Ve}},Qe=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},Y=e=>{let t=Math.max(0,e-J);if(t===0)return{min:He,max:Ue};let n=Math.max(He,We/t*100),r=Math.min(Ue,(t-Ge)/t*100);if(n<=r)return{min:n,max:r};let i=Ye(We/840*100,He,Ue);return{min:i,max:i}},X=(e,t)=>Ye(e,t.min,t.max);function $e({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=l(o.language),u=Xe(n),[d,f]=(0,V.useState)(()=>({storageKey:u,percent:Ze(u)})),[p,m]=(0,V.useState)(0),[h,g]=(0,V.useState)(!1),_=(0,V.useRef)(null),v=(0,V.useRef)(null),y=(0,V.useRef)(null),b=(0,V.useRef)(u),x=(0,V.useRef)(d.percent),S=(0,V.useRef)(null),C=d.storageKey===u?d.percent:Ze(u),w=(0,V.useMemo)(()=>Y(p),[p]),T=X(C,w),E=Math.round(T),D=100-E,O=(0,V.useCallback)(e=>{f({storageKey:u,percent:e})},[u]),k=(0,V.useCallback)(e=>{let t=X(e,Y(_.current?.getBoundingClientRect().width??0));x.current=t,S.current===null&&(S.current=window.requestAnimationFrame(()=>{S.current=null,O(x.current)}))},[O]),A=(0,V.useCallback)(()=>{if(y.current===null&&!h)return;S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null);let e=_.current?.getBoundingClientRect().width??0,t=X(x.current,Y(e));x.current=t,O(t),Qe(b.current,t);let n=y.current;y.current=null,n!==null&&v.current?.hasPointerCapture(n)&&v.current.releasePointerCapture(n),g(!1)},[h,O]),j=(0,V.useCallback)(e=>{let t=_.current?.getBoundingClientRect();if(!t)return x.current;let n=Math.max(1,t.width-J);return((s?t.right-e:e-t.left)-J/2)/n*100},[s]),M=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),y.current=e.pointerId,b.current=u,x.current=T,e.currentTarget.setPointerCapture(e.pointerId),g(!0))},ee=(0,V.useCallback)(e=>{let t=X(e,w);x.current=t,O(t),Qe(u,t)},[w,O,u]),te=(0,V.useCallback)(()=>{ee(Ve)},[ee]),N=e=>{let t=e.shiftKey?qe:Ke,n=null;e.key===`ArrowLeft`?n=T+(s?t:-t):e.key===`ArrowRight`?n=T+(s?-t:t):e.key===`Home`?n=w.min:e.key===`End`?n=w.max:e.key===`Enter`&&(n=Ve),n!==null&&(e.preventDefault(),ee(n))};(0,V.useEffect)(()=>{let e=_.current;if(!e)return;if(typeof ResizeObserver>`u`){let t=()=>m(e.getBoundingClientRect().width);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}let t=new ResizeObserver(e=>{let t=e[0];t&&m(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),(0,V.useEffect)(()=>{if(!h)return;let e=document.body.style.cursor,t=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let n=e=>{e.pointerId===y.current&&(e.preventDefault(),k(j(e.clientX)))},r=e=>{e.pointerId===y.current&&A()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,A),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,A),document.body.style.cursor=e,document.body.style.userSelect=t}},[A,h,j,k]),(0,V.useEffect)(()=>()=>{S.current!==null&&window.cancelAnimationFrame(S.current),y.current!==null&&Qe(b.current,x.current)},[]);let ne={gridTemplateColumns:`minmax(0, ${T}fr) ${J}px minmax(0, ${100-T}fr)`};return(0,H.jsxs)(`div`,{ref:_,"data-testid":`work-split-pane`,"data-split-percent":T.toFixed(2),"data-resizing":h?`true`:`false`,className:L(`relative flex min-h-0 min-w-0 flex-1 overflow-hidden xl:grid`,i),style:ne,children:[(0,H.jsx)(`section`,{id:`work-conversation-panel`,"data-testid":`work-conversation-panel`,className:L(`min-h-0 min-w-0 flex-1 flex-col bg-transparent xl:flex`,r===`conversation`?`flex`:`hidden`),children:e}),(0,H.jsxs)(`div`,{ref:v,role:`separator`,"aria-orientation":`vertical`,"aria-controls":`work-conversation-panel work-workspace-panel`,"aria-label":a(`work.workspace.resize`,{defaultValue:`Resize conversation and workspace`}),"aria-valuemin":Math.round(w.min),"aria-valuemax":Math.round(w.max),"aria-valuenow":E,"aria-valuetext":a(`work.workspace.splitSize`,{conversation:E,workspace:D,defaultValue:`Conversation {{conversation}}%, workspace {{workspace}}%`}),title:a(`work.workspace.resizeHint`,{defaultValue:`Drag to resize. Use arrow keys for precise control. Double-click or press Enter to reset.`}),tabIndex:0,"data-testid":`work-split-resizer`,onPointerDown:M,onDoubleClick:te,onKeyDown:N,className:L(`group relative z-40 hidden h-full cursor-col-resize touch-none select-none items-center justify-center outline-none xl:flex`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52]`),children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:L(`pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-line transition-colors`,`group-hover:bg-[#ff7b52] group-focus-visible:bg-[#ff7b52]`,h&&`bg-[#ff7b52]`)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:L(`pointer-events-none relative h-14 w-1 rounded-full bg-ink-subtle/50 opacity-60 transition-[height,background-color,opacity]`,`group-hover:h-20 group-hover:bg-[#ff7b52] group-hover:opacity-100`,`group-focus-visible:h-20 group-focus-visible:bg-[#ff7b52] group-focus-visible:opacity-100`,h&&`h-20 bg-[#ff7b52] opacity-100`)})]}),(0,H.jsx)(`section`,{id:`work-workspace-panel`,"data-testid":`work-workspace-panel`,className:L(`min-h-0 min-w-0 flex-1 flex-col bg-surface-raised/85 backdrop-blur-xl xl:flex`,r===`workspace`?`flex`:`hidden`),children:t}),h&&(0,H.jsx)(`div`,{"data-testid":`work-split-drag-shield`,"aria-hidden":`true`,className:`absolute inset-0 z-30 hidden cursor-col-resize select-none xl:block`})]})}var Z=1e5,et=4e3,tt={bash:`bash`,c:`c`,cc:`cpp`,cjs:`javascript`,cpp:`cpp`,cs:`csharp`,csh:`bash`,css:`css`,cts:`typescript`,cxx:`cpp`,diff:`diff`,go:`go`,h:`c`,hpp:`cpp`,htm:`markup`,html:`markup`,java:`java`,js:`javascript`,json:`json`,json5:`json`,jsonc:`json`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`css`,md:`markdown`,mdx:`markdown`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,py:`python`,rb:`ruby`,rs:`rust`,scss:`css`,sh:`bash`,sql:`sql`,svg:`markup`,swift:`swift`,ts:`typescript`,tsx:`tsx`,xml:`markup`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},nt={".bashrc":`bash`,".zshrc":`bash`},rt={cjs:{family:`babel`,parser:`babel`},css:{family:`postcss`,parser:`css`},cts:{family:`typescript`,parser:`typescript`},htm:{family:`html`,parser:`html`},html:{family:`html`,parser:`html`},js:{family:`babel`,parser:`babel`},json:{family:`babel`,parser:`json`},json5:{family:`babel`,parser:`json5`},jsonc:{family:`babel`,parser:`json`},jsx:{family:`babel`,parser:`babel`},less:{family:`postcss`,parser:`less`},md:{family:`markdown`,parser:`markdown`},mdx:{family:`markdown`,parser:`mdx`},mjs:{family:`babel`,parser:`babel`},mts:{family:`typescript`,parser:`typescript`},scss:{family:`postcss`,parser:`scss`},ts:{family:`typescript`,parser:`typescript`},tsx:{family:`typescript`,parser:`typescript`},yaml:{family:`yaml`,parser:`yaml`},yml:{family:`yaml`,parser:`yaml`}},it=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,at=e=>{let t=it(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},ot=e=>nt[it(e)]??tt[at(e)]??`text`,st=e=>rt[at(e)],ct=e=>st(e)!==void 0,lt=e=>{if(e.length>1e5)return!1;let t=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&(t+=1,t>4e3))return!1;return!0},Q=async e=>(await e).default,ut=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),Q(a(()=>import(`./estree-BuWOCMW0.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))]);case`typescript`:return Promise.all([Q(a(()=>import(`./typescript-DQ5zi5zo.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),Q(a(()=>import(`./estree-BuWOCMW0.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))]);case`postcss`:return[await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))];case`html`:{let e=[await Q(a(()=>import(`./html-D7tW7UvW.js`),__vite__mapDeps([26,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))];return/<script\b/i.test(t)&&e.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BuWOCMW0.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await Q(a(()=>import(`./typescript-DQ5zi5zo.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),/<style\b/i.test(t)&&e.push(await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await Q(a(()=>import(`./markdown-CBSxWEtK.js`),__vite__mapDeps([27,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))],r=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BuWOCMW0.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),r(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BuWOCMW0.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),r(`ts|tsx|typescript`)&&n.push(await Q(a(()=>import(`./typescript-DQ5zi5zo.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./estree-BuWOCMW0.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),r(`css|scss|less`)&&n.push(await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))),r(`html`)&&n.push(await Q(a(()=>import(`./html-D7tW7UvW.js`),__vite__mapDeps([26,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-BuWOCMW0.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./typescript-DQ5zi5zo.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([25,1,2,3])))),r(`yaml|yml`)&&n.push(await Q(a(()=>import(`./yaml-QD4znPfZ.js`),__vite__mapDeps([28,1,2,3])))),[...new Set(n)]}case`yaml`:return[await Q(a(()=>import(`./yaml-QD4znPfZ.js`),__vite__mapDeps([28,1,2,3])))]}},dt=async(e,t)=>{let n=st(e);if(!n)throw Error(`Formatting is not supported for “${it(e)||e}”.`);if(!lt(t))throw Error(`Could not format “${it(e)||e}”: files are limited to ${Z.toLocaleString()} characters and ${et.toLocaleString()} lines.`);try{let[{format:e},r]=await Promise.all([a(()=>import(`./standalone-CaXys7q3.js`),__vite__mapDeps([29,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),ut(n,t)]);return await e(t,{parser:n.parser,plugins:r,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${it(e)||e}”: ${n}`)}},ft=(0,V.lazy)(async()=>({default:(await a(()=>import(`./OptimizedSyntaxHighlighter-CWYUn9Oe.js`).then(e=>e.n),__vite__mapDeps([30,2,3,31]))).OptimizedSyntaxHighlighter})),pt=8e3,mt=400,ht=500;function gt({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),l=ve(e=>e.theme.mode===`dark`),u=(0,V.useRef)(null),d=(0,V.useRef)(null),[f,p]=(0,V.useState)(``),m=(0,V.useMemo)(()=>ot(e),[e]),h=(0,V.useMemo)(()=>{if(t.length>pt)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>mt));n+=1);return e},[t]),g=t.length>pt||h>mt,_=m!==`text`&&!g,v=_&&f===t;return(0,V.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>p(t),ht);return()=>window.clearTimeout(e)},[_,e,t]),(0,V.useLayoutEffect)(()=>{!v||!u.current||!d.current||(u.current.style.transform=`translate3d(${-d.current.scrollLeft}px, ${-d.current.scrollTop}px, 0)`)},[v,e]),(0,H.jsxs)(`div`,{dir:`ltr`,className:L(`relative min-h-0 flex-1 overflow-hidden bg-surface focus-within:ring-1 focus-within:ring-inset focus-within:ring-primary-500/60`,r&&`opacity-60`),"data-language":m,"data-highlighted":v?`true`:`false`,children:[v&&(0,H.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,H.jsx)(`div`,{ref:u,"data-testid":`work-file-highlight-content`,className:`min-h-full min-w-full origin-top-left will-change-transform`,children:(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`pre`,{className:`m-0 min-h-full min-w-full whitespace-pre p-4 text-left font-mono text-[12px] leading-5 text-ink`,children:t||`​`}),children:(0,H.jsx)(ft,{language:m,isDark:l,backgroundColor:`transparent`,borderRadius:0,customStyle:{margin:0,minHeight:`100%`,minWidth:`100%`,width:`max-content`,overflow:`visible`,padding:`1rem`,fontSize:`12px`,lineHeight:`20px`,tabSize:2,whiteSpace:`pre`},children:f||`​`})})})}),(0,H.jsx)(`textarea`,{ref:d,"data-testid":`work-file-editor`,"data-language":m,"aria-label":n,value:t,onChange:e=>i(e.target.value),onScroll:e=>{u.current&&(u.current.style.transform=`translate3d(${-e.currentTarget.scrollLeft}px, ${-e.currentTarget.scrollTop}px, 0)`)},onKeyDown:e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`s`){e.preventDefault(),a();return}e.altKey&&e.shiftKey&&t===`f`&&(e.preventDefault(),o())},disabled:r,spellCheck:!1,wrap:`off`,className:L(`absolute inset-0 z-10 h-full w-full resize-none overflow-auto whitespace-pre border-0 bg-transparent p-4 text-left font-mono text-[12px] leading-5 outline-none selection:bg-primary-500/25 disabled:cursor-not-allowed`,v?`text-transparent caret-ink`:`text-ink`),style:v?{WebkitTextFillColor:`transparent`,caretColor:`rgb(var(--color-ink))`,tabSize:2}:{tabSize:2}}),g&&(0,H.jsx)(`span`,{dir:`auto`,className:`pointer-events-none absolute bottom-2 end-3 z-20 rounded-md border border-line bg-surface-overlay/90 px-2 py-1 text-[10px] text-ink-muted shadow-subtle`,title:s(`work.files.highlightPaused`,{defaultValue:`Live highlighting is paused for large files to keep editing responsive.`}),children:s(`work.files.plainTextLarge`,{defaultValue:`Plain text · large file`})})]})}var _t=4e6,vt=e=>{if(e===``)return[];let t=e.split(`
4
4
  `);return t[t.length-1]===``&&t.pop(),t},$=(e,t)=>{let n=vt(e),r=vt(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=n.slice(i,n.length-a),s=r.slice(i,r.length-a),c=[];for(let e=0;e<i;e+=1)c.push({type:`context`,text:n[e],beforeLine:e+1,afterLine:e+1});let l=yt(o,s);for(let e of l){let t={type:e.type,text:e.text};e.beforeLine!==void 0&&(t.beforeLine=e.beforeLine+i),e.afterLine!==void 0&&(t.afterLine=e.afterLine+i),c.push(t)}for(let e=0;e<a;e+=1){let t=n.length-a+e,i=r.length-a+e;c.push({type:`context`,text:n[t],beforeLine:t+1,afterLine:i+1})}return c},yt=(e,t)=>{if(e.length===0&&t.length===0)return[];if(e.length>0&&t.length>0&&e.length*t.length>_t)return[...e.map((e,t)=>({type:`removed`,text:e,beforeLine:t+1})),...t.map((e,t)=>({type:`added`,text:e,afterLine:t+1}))];let n=e.length+1,r=t.length+1,i=new Uint32Array(n*r);for(let n=e.length-1;n>=0;--n)for(let a=t.length-1;a>=0;--a)i[n*r+a]=e[n]===t[a]?i[(n+1)*r+a+1]+1:Math.max(i[(n+1)*r+a],i[n*r+a+1]);let a=[],o=0,s=0;for(;o<e.length&&s<t.length;)e[o]===t[s]?(a.push({type:`context`,text:e[o],beforeLine:o+1,afterLine:s+1}),o+=1,s+=1):i[(o+1)*r+s]>=i[o*r+s+1]?(a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1):(a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1);for(;o<e.length;)a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1;for(;s<t.length;)a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1;return a},bt=e=>{let t=0,n=0;for(let r of e)r.type===`added`&&(t+=1),r.type===`removed`&&(n+=1);return{added:t,removed:n}},xt=3,St=e=>{let t=Array(e.length).fill(!1);for(let n=0;n<e.length;n+=1){if(e[n].type===`context`)continue;let r=Math.max(0,n-xt),i=Math.min(e.length-1,n+xt);for(let e=r;e<=i;e+=1)t[e]=!0}let n=[],r=0;for(let i=0;i<e.length;i+=1){if(!t[i]){r+=1;continue}r>0&&(n.push({type:`fold`,count:r}),r=0),n.push({type:`line`,line:e[i]})}return r>0&&n.push({type:`fold`,count:r}),n};function Ct({lines:e,ariaLabel:t}){let{t:n}=c(),r=(0,V.useMemo)(()=>St(e),[e]);return(0,H.jsx)(`div`,{dir:`ltr`,role:`region`,"aria-label":t,"data-testid":`work-file-diff`,className:`min-h-0 flex-1 overflow-auto bg-surface font-mono text-[12px] leading-5`,children:(0,H.jsx)(`table`,{className:`w-full border-collapse`,children:(0,H.jsx)(`tbody`,{children:r.map((e,t)=>e.type===`fold`?(0,H.jsx)(`tr`,{children:(0,H.jsx)(`td`,{colSpan:3,className:`select-none border-y border-line bg-surface-subtle/70 px-4 py-1 text-center text-[11px] text-ink-subtle`,children:n(`work.files.diffFolded`,{count:e.count,defaultValue:`{{count}} unchanged lines`})})},`fold-${t}`):(0,H.jsxs)(`tr`,{className:L(e.line.type===`added`&&`bg-[rgb(76,212,117)]/[0.12] text-ink`,e.line.type===`removed`&&`bg-[rgb(255,61,129)]/[0.10] text-ink-muted`,e.line.type===`context`&&`text-ink-muted`),children:[(0,H.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.line.beforeLine??``}),(0,H.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.line.afterLine??``}),(0,H.jsxs)(`td`,{className:`w-full whitespace-pre-wrap break-all px-3 align-top`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:L(`me-2 inline-block w-3 select-none text-center`,e.line.type===`added`&&`text-[rgb(46,164,79)]`,e.line.type===`removed`&&`text-[rgb(255,61,129)]`),children:e.line.type===`added`?`+`:e.line.type===`removed`?`−`:``}),e.line.text||`​`]})]},`line-${t}`))})})})}var wt=(e,t)=>{if(e.success&&e.data)return e.data;throw Error(e.error||t)},Tt=(e,t)=>{let n=e?.response?.data?.error;return typeof n==`string`&&n?n:e instanceof Error&&e.message?e.message:t};function Et({taskId:e,mutationsDisabled:t=!1,disabledReason:n}){let{t:r}=c(),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!0),[l,u]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[h,g]=(0,V.useState)([]),[y,b]=(0,V.useState)(``),[x,S]=(0,V.useState)(``),[w,T]=(0,V.useState)(null),[E,O]=(0,V.useState)(!1),k=(0,V.useRef)(0),A=(0,V.useCallback)(async()=>{let t=++k.current;s(!0),p(null);try{let n=wt(await I.getGitStatus(e),r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`}));if(t!==k.current)return;a(n),g([])}catch(e){if(t!==k.current)return;p(Tt(e,r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})))}finally{t===k.current&&s(!1)}},[r,e]);(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void A(),0);return()=>{window.clearTimeout(e),k.current+=1}},[A]);let j=async(e,n)=>{if(t||l)return!1;u(!0),p(null);try{let t=wt(await e(),r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return a(t),g([]),T(null),D.success(n),!0}catch(e){let t=Tt(e,r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return p(t),D.error(t),!1}finally{u(!1)}},M=async t=>{O(!0),p(null);try{T(wt(await I.getGitDiff(e,t),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}catch(e){p(Tt(e,r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}finally{O(!1)}};if(o&&!i)return(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-ink-muted`,children:(0,H.jsx)(F,{className:`h-5 w-5 animate-spin`})});if(!i)return(0,H.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,H.jsx)(m,{className:`mb-3 h-8 w-8 text-error-500`}),(0,H.jsx)(`p`,{className:`max-w-sm text-xs leading-relaxed text-error-600`,children:f||r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})}),(0,H.jsxs)(z,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>void A(),children:[(0,H.jsx)(C,{className:`h-3.5 w-3.5`}),r(`common.retry`,{defaultValue:`Retry`})]})]});if(!i.initialized)return(0,H.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,H.jsx)(m,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,H.jsx)(`h3`,{className:`text-sm font-medium text-ink`,children:r(`work.git.notInitialized`,{defaultValue:`Git is not initialized`})}),(0,H.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-relaxed text-ink-muted`,children:r(`work.git.initializeDescription`,{defaultValue:`Create a local repository for status, diffs, branches, and commits. No remote credentials are connected.`})}),f&&(0,H.jsx)(`p`,{className:`mt-3 text-xs text-error-600`,children:f}),(0,H.jsxs)(z,{"data-testid":`work-git-init-button`,size:`sm`,className:`mt-4 bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||l,onClick:()=>void j(()=>I.initializeGit(e),r(`work.git.initialized`,{defaultValue:`Git repository initialized.`})),children:[l?(0,H.jsx)(F,{className:`me-2 h-3.5 w-3.5 animate-spin`}):(0,H.jsx)(d,{className:`me-2 h-3.5 w-3.5`}),r(`work.git.initialize`,{defaultValue:`Initialize Git`})]}),t&&n&&(0,H.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-subtle`,children:n})]});let ee=i.changes.filter(e=>e.staged).length,te=i.changes.length>0;return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`work-git-panel`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-lg bg-surface-subtle px-2 py-1 font-mono text-[11px] text-ink`,children:[(0,H.jsx)(m,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:i.detached?r(`work.git.detached`,{defaultValue:`detached HEAD`}):i.branch||`main`})]}),(i.ahead>0||i.behind>0)&&(0,H.jsxs)(`span`,{className:`text-[10px] text-ink-muted`,children:[`↑`,i.ahead,` ↓`,i.behind]}),(0,H.jsxs)(`select`,{"data-testid":`work-git-branch-select`,"aria-label":r(`work.git.switchBranch`,{defaultValue:`Switch local branch`}),value:i.branch||``,disabled:t||l||te,onChange:t=>{let n=t.target.value;!n||n===i.branch||j(()=>I.switchGitBranch(e,n),r(`work.git.branchSwitched`,{name:n,defaultValue:`Switched to {{name}}.`}))},className:`h-7 max-w-44 rounded-lg border border-line bg-surface px-2 text-[11px] text-ink outline-none disabled:opacity-50`,children:[i.detached&&(0,H.jsx)(`option`,{value:``,disabled:!0,children:r(`work.git.detached`,{defaultValue:`detached HEAD`})}),i.branches.map(e=>(0,H.jsx)(`option`,{value:e,children:e},e))]}),(0,H.jsxs)(`div`,{className:`flex min-w-44 flex-1 items-center gap-1`,children:[(0,H.jsx)(`input`,{"data-testid":`work-git-branch-input`,value:x,maxLength:200,onChange:e=>S(e.target.value),placeholder:r(`work.git.newBranch`,{defaultValue:`New local branch`}),className:`h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,H.jsxs)(z,{"data-testid":`work-git-create-branch-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2`,disabled:t||l||!i.head||!x.trim(),onClick:()=>{let t=x.trim();j(()=>I.createGitBranch(e,t),r(`work.git.branchCreated`,{name:t,defaultValue:`Created {{name}}.`})).then(e=>{e&&S(``)})},children:[(0,H.jsx)(d,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:r(`work.git.createBranch`,{defaultValue:`Create`})})]})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void A(),disabled:o||l,"aria-label":r(`common.refresh`,{defaultValue:`Refresh`}),className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink disabled:opacity-50`,children:(0,H.jsx)(C,{className:L(`h-3.5 w-3.5`,o&&`animate-spin`)})})]}),f&&(0,H.jsx)(`div`,{className:`border-b border-error-200 bg-error-50 px-3 py-2 text-xs text-error-700 dark:border-error-900/60 dark:bg-error-900/30 dark:text-error-300`,children:f}),t&&n&&(0,H.jsx)(`div`,{className:`border-b border-line px-3 py-1.5 text-[11px] text-ink-subtle`,children:n}),(0,H.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[minmax(14rem,0.8fr)_minmax(18rem,1.2fr)_minmax(13rem,0.8fr)]`,children:[(0,H.jsxs)(`section`,{className:`flex min-h-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,H.jsxs)(`h3`,{className:`text-xs font-medium text-ink`,children:[r(`work.git.changes`,{defaultValue:`Changes`}),` `,(0,H.jsx)(`span`,{className:`text-ink-subtle`,children:i.changes.length})]}),(0,H.jsxs)(z,{"data-testid":`work-git-stage-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-[11px]`,disabled:t||l||h.length===0&&i.changes.length===0,onClick:()=>{let t=h.length>0?h:i.changes.map(e=>e.path);j(()=>I.stageGitPaths(e,t),r(`work.git.staged`,{defaultValue:`Changes staged.`}))},children:[(0,H.jsx)(re,{className:`h-3.5 w-3.5`}),h.length>0?r(`work.git.stageSelected`,{count:h.length,defaultValue:`Stage {{count}}`}):r(`work.git.stageAll`,{defaultValue:`Stage all`})]})]}),(0,H.jsx)(`div`,{className:`min-h-32 flex-1 overflow-y-auto px-2 pb-2`,children:i.changes.length===0?(0,H.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):i.changes.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg hover:bg-surface-subtle`,children:[(0,H.jsx)(`input`,{type:`checkbox`,"aria-label":r(`work.git.selectPath`,{path:e.path,defaultValue:`Select {{path}}`}),checked:h.includes(e.path),onChange:t=>g(n=>t.target.checked?[...n,e.path]:n.filter(t=>t!==e.path)),className:`ms-2 h-3.5 w-3.5 accent-[#ff7b52]`}),(0,H.jsxs)(`button`,{type:`button`,"data-testid":`work-git-change`,onClick:()=>void M(e.path),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-start`,children:[(0,H.jsxs)(`span`,{dir:`ltr`,className:L(`w-5 shrink-0 font-mono text-[10px] font-semibold`,e.staged?`text-emerald-600`:`text-amber-600`),children:[e.indexStatus,e.workingTreeStatus]}),(0,H.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,title:e.path,children:e.path})]})]},`${e.path}:${e.originalPath||``}`))}),(0,H.jsxs)(`div`,{className:`border-t border-line p-2`,children:[(0,H.jsx)(`textarea`,{"data-testid":`work-git-commit-input`,value:y,maxLength:4e3,rows:2,onChange:e=>b(e.target.value),placeholder:r(`work.git.commitMessage`,{defaultValue:`Commit message`}),className:`w-full resize-none rounded-lg border border-line bg-surface px-2.5 py-2 text-xs text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,H.jsxs)(z,{"data-testid":`work-git-commit-button`,size:`sm`,className:`mt-1.5 w-full bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||l||ee===0||!y.trim(),onClick:()=>{let t=y.trim();j(()=>I.commitGit(e,t),r(`work.git.committed`,{defaultValue:`Commit created.`})).then(e=>{e&&b(``)})},children:[l&&(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),r(`work.git.commit`,{defaultValue:`Commit staged changes`})]})]})]}),(0,H.jsxs)(`section`,{className:`flex min-h-48 min-w-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-medium text-ink`,children:[(0,H.jsx)(_,{className:`h-3.5 w-3.5`}),w?.path||r(`work.git.diff`,{defaultValue:`Diff preview`})]}),E?(0,H.jsx)(F,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):w?w.patch?(0,H.jsxs)(`pre`,{"data-testid":`work-git-diff`,dir:`ltr`,className:`min-h-0 flex-1 overflow-auto whitespace-pre p-3 text-left font-mono text-[11px] leading-relaxed text-ink`,children:[w.patch,w.truncated&&`
5
5
  … diff truncated …`]}):(0,H.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.noDiff`,{defaultValue:`No textual diff is available yet. Untracked files appear after staging.`})}):(0,H.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.selectChange`,{defaultValue:`Select a changed file to inspect its diff.`})})]}),(0,H.jsxs)(`section`,{className:`min-h-36 overflow-y-auto p-3`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-ink`,children:[(0,H.jsx)(v,{className:`h-3.5 w-3.5`}),r(`work.git.history`,{defaultValue:`Local history`})]}),i.commits.length===0?(0,H.jsx)(`p`,{className:`py-6 text-center text-xs text-ink-muted`,children:r(`work.git.noCommits`,{defaultValue:`No commits yet.`})}):(0,H.jsx)(`ol`,{className:`space-y-2`,children:i.commits.map(e=>(0,H.jsxs)(`li`,{className:`rounded-lg border border-line bg-surface px-2.5 py-2`,children:[(0,H.jsx)(`p`,{dir:`auto`,className:`text-xs text-ink`,children:e.subject}),(0,H.jsxs)(`p`,{className:`mt-1 flex flex-wrap gap-x-2 text-[10px] text-ink-subtle`,children:[(0,H.jsx)(`span`,{dir:`ltr`,className:`font-mono`,children:e.shortHash}),(0,H.jsx)(`span`,{dir:`auto`,children:e.author}),(0,H.jsx)(`time`,{dateTime:e.authoredAt,children:new Date(e.authoredAt).toLocaleDateString()})]})]},e.hash))}),(0,H.jsx)(`p`,{className:`mt-4 border-t border-line pt-3 text-[10px] leading-relaxed text-ink-subtle`,children:r(`work.git.localOnly`,{defaultValue:`Local Git only. Push, pull, and pull requests require a separate trusted credential broker.`})})]})]})]})}var Dt=`/ws/work-terminal`;function Ot(e,t){let n;if(t.protocol===`file:`)n=`ws://localhost:3001`;else if(t.apiBaseUrl)n=t.apiBaseUrl.replace(/\/api$/,``).replace(/^http:/,`ws:`).replace(/^https:/,`wss:`);else{let e=t.protocol===`https:`?`wss:`:`ws:`;n=t.production?`${e}//${t.host}`:`${e}//${t.hostname}:3001`}let r=new URL(`${n}${Dt}`);return r.searchParams.set(`taskId`,e),t.token&&r.searchParams.set(`token`,t.token),r.toString()}function kt(e){return Ot(e,{protocol:window.location.protocol,host:window.location.host,hostname:window.location.hostname,apiBaseUrl:void 0,production:!0,token:localStorage.getItem(`auth-token`)})}var At={background:`#ffffff`,foreground:`#1f2328`,cursor:`#1f2328`,selectionBackground:`rgba(255, 123, 82, 0.28)`},jt={background:`#0f1115`,foreground:`#e6e6e6`,cursor:`#ff7b52`,selectionBackground:`rgba(255, 123, 82, 0.32)`};function Mt({taskId:e,active:t,disabledReason:n}){let{t:r}=c(),i=ve(e=>e.theme.mode===`dark`),o=(0,V.useRef)(null),s=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(`idle`),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(0),v=(0,V.useCallback)(()=>{let e=u.current,t=l.current,n=s.current;if(!(!e||!t||!n||n.readyState!==WebSocket.OPEN)){try{e.fit()}catch{return}n.send(JSON.stringify({type:`resize`,cols:t.cols,rows:t.rows}))}},[]);(0,V.useEffect)(()=>{if(!t||n)return;let r=!1,c,d;return(async()=>{f(`connecting`),h(null);let[{Terminal:t},{FitAddon:n}]=await Promise.all([a(()=>import(`./xterm-Da5ppSVt.js`),[]),a(()=>import(`./addon-fit-DIOBYJe3.js`),[])]);if(await a(()=>Promise.resolve({}),__vite__mapDeps([32])),r||!o.current)return;c=new t({allowProposedApi:!0,convertEol:!1,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,fontSize:12,scrollback:5e3,theme:i?jt:At});let p=new n;c.loadAddon(p),c.open(o.current),l.current=c,u.current=p;try{p.fit()}catch{}d=new WebSocket(kt(e)),d.binaryType=`arraybuffer`,s.current=d;let m=new TextDecoder;d.onmessage=e=>{if(typeof e.data!=`string`){c?.write(m.decode(new Uint8Array(e.data)));return}try{let t=JSON.parse(e.data);if(t.type===`ready`){f(`connected`),v(),c?.focus();return}if(t.type===`error`){f(`error`),h(t.message||null);return}t.type===`exit`&&f(`closed`)}catch{}},d.onclose=()=>{r||f(e=>e===`error`||e===`closed`?e:`closed`)},d.onerror=()=>{r||f(`error`)},c.onData(e=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:`input`,data:e}))})})(),()=>{r=!0,d?.close(),s.current=null,c?.dispose(),l.current=null,u.current=null}},[t,n,g,i,v,e]),(0,V.useEffect)(()=>{let e=o.current;if(!e||!t)return;let n=new ResizeObserver(()=>v());return n.observe(e),()=>n.disconnect()},[t,v]);let y=()=>{s.current?.close(),_(e=>e+1)},b=n??(d===`error`?m??r(`work.terminal.failed`,{defaultValue:`The terminal session could not start.`}):d===`closed`?r(`work.terminal.closed`,{defaultValue:`Terminal session ended.`}):null);return(0,H.jsxs)(`div`,{"data-testid":`work-terminal-panel`,"data-status":n?`unavailable`:d,className:`relative flex min-h-0 flex-1 flex-col bg-surface`,children:[!n&&(0,H.jsx)(`div`,{ref:o,"data-testid":`work-terminal-surface`,dir:`ltr`,className:L(`min-h-0 flex-1 overflow-hidden p-2 text-left`,d!==`connected`&&`opacity-60`)}),d===`connecting`&&!n&&(0,H.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-xs text-ink-muted`,children:[(0,H.jsx)(F,{className:`h-4 w-4 animate-spin`}),r(`work.terminal.connecting`,{defaultValue:`Opening a shell in the sandbox…`})]}),b&&(0,H.jsxs)(`div`,{role:d===`error`?`alert`:void 0,className:`flex flex-col items-center gap-3 border-t border-line bg-surface-raised px-6 py-4 text-center`,children:[(0,H.jsx)(p,{className:`h-6 w-6 text-ink-subtle`}),(0,H.jsx)(`p`,{dir:`auto`,"data-testid":`work-terminal-status`,className:`max-w-md text-xs leading-relaxed text-ink-muted`,children:b}),!n&&(0,H.jsx)(z,{size:`sm`,"data-testid":`work-terminal-reconnect-button`,className:`h-8 rounded-lg bg-[#ff7b52] px-3 text-[#3d120c] hover:bg-[#ff7b52]/90`,onClick:y,children:r(`work.terminal.reconnect`,{defaultValue:`Reconnect`})})]})]})}var Nt=e=>{if(!e)return null;if(/^\/api\/work\/previews\/[A-Za-z0-9-]{1,100}\/\d{1,5}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\//.test(e))try{let t=new URL(ue,window.location.origin).origin;return new URL(e,`${t}/`).toString()}catch{return null}return null},Pt=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)},Ft=(e,t)=>{let n=e.metadata?.name??e.metadata?.toolName??e.metadata?.tool??e.metadata?.command;return typeof n==`string`&&n?n:t};function It({task:e,liveRun:t,files:n,selectedFile:r,loadingFiles:i,actionLoading:a,onLoadFiles:o,onLoadFile:s,onClearSelectedFile:u,onSaveFile:d,onStartPreview:_,onStopPreview:v,onDirtyChange:b,terminal:E}){let{t:k,i18n:A}=c(),j=l(A.language),[M,te]=(0,V.useState)(`files`),[N,ne]=(0,V.useState)(``),[P,re]=(0,V.useState)(``),[ie,ae]=(0,V.useState)(),[se,le]=(0,V.useState)(``),[ue,de]=(0,V.useState)(!1),[I,R]=(0,V.useState)(!1),fe=(0,V.useRef)(new Map),[me,he]=(0,V.useState)(()=>new Map),ve=Nt(e.previewUrl),ye=t?.runId,be=t?.error,xe=t?.tools,Se=(0,V.useMemo)(()=>{let t=new Set(xe?.map(e=>e.id)||[]);return(e.messages||[]).filter(e=>{if(e.kind===`reasoning`||e.role!==`tool`&&e.kind===`message`)return!1;if(!ye||e.runId!==ye)return!0;if(e.kind===`error`&&be)return!1;let n=e.metadata?.toolCallId;return typeof n!=`string`||!t.has(n)})},[be,ye,xe,e.messages]),Ce=Se.length+(xe?.length||0),we=!!r&&P!==(r?.content??``),B=e.status===`preparing`||e.status===`running`,Te=(0,V.useRef)(B),U=(0,V.useRef)(0),W=(0,V.useRef)(P),Ee=(0,V.useRef)(ie),De=(0,V.useRef)(r),Oe=(0,V.useRef)(e.id),ke=(0,V.useRef)(o),Ae=(0,V.useRef)(s),je=(0,V.useRef)(b),G=(0,V.useRef)(!0),K=r?me.get(r.path):void 0,Me=(0,V.useMemo)(()=>r&&K!==void 0&&K!==r.content?$(K,r.content):null,[K,r]),Ne=(0,V.useMemo)(()=>Me?bt(Me):null,[Me]),Fe=!!(Ne&&(Ne.added>0||Ne.removed>0)),Ie=r?ct(r.path):!1,Le=!r||lt(P),q=Ie&&Le;(0,V.useEffect)(()=>{W.current=P,Ee.current=ie,De.current=r,Oe.current=e.id,je.current=b},[ie,P,b,r,e.id]),(0,V.useEffect)(()=>{ke.current=o,Ae.current=s},[s,o]),(0,V.useEffect)(()=>(G.current=!0,()=>{G.current=!1,U.current+=1,je.current(!1)}),[]),(0,V.useEffect)(()=>{if(!Te.current&&B&&he(new Map(fe.current)),Te.current&&!B&&(ke.current(N),r&&!we)){let e=++U.current,t=r.path,n=W.current,i=Ee.current;Ae.current(t).then(r=>{if(!G.current||e!==U.current||r.path!==t||W.current!==n||Ee.current!==i)return;fe.current.set(r.path,r.content);let a=me.get(r.path);a!==void 0&&a!==r.content&&R(!0),W.current=r.content,Ee.current=r.updatedAt??r.modifiedAt,re(r.content),ae(r.updatedAt??r.modifiedAt)}).catch(()=>void 0)}Te.current=B},[N,we,r,B,me]);let Re=()=>!we||window.confirm(k(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),ze=()=>{r&&pe(e.id,r.path)},Be=async e=>{Re()&&(U.current+=1,ze(),u(),b(!1),R(!1),ne(e),await o(e).catch(()=>void 0))},Ve=async t=>{if(!Re())return;let n=++U.current;ze();let r=await s(t).catch(()=>void 0);if(!G.current||!r||n!==U.current)return;fe.current.set(r.path,r.content);let i=me.get(r.path);R(i!==void 0&&i!==r.content);let a=ge(e.id,r.path),o=a?.content??r.content,c=a?.baseUpdatedAt??r.updatedAt??r.modifiedAt;W.current=o,Ee.current=c,re(o),ae(c),b(a!==null&&a.content!==r.content)},He=()=>{Re()&&(U.current+=1,ze(),u(),b(!1),R(!1))},Ue=t=>{r&&(W.current=t,re(t),t===r.content?pe(e.id,r.path):_e(e.id,r.path,{content:t,baseUpdatedAt:ie??r.updatedAt??r.modifiedAt}),b(t!==r.content))},We=async()=>{if(!r)return;let t=e.id,n=r.path,i=P,a=U.current,o=await d(n,i,ie).catch(()=>!1);if(!G.current||o===!1||a!==U.current||Oe.current!==t||De.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;fe.current.set(n,typeof o.content==`string`?o.content:i),Ee.current=s,ae(s);let c=W.current;if(c===i){pe(t,n),b(!1);return}_e(t,n,{content:c,baseUpdatedAt:s}),b(!0)},Ge=async()=>{if(!r||B||ue||!q)return;de(!0);let e=U.current,t=r.path,n=W.current;try{let r=await dt(t,n);if(!G.current||e!==U.current||De.current?.path!==t||W.current!==n)return;Ue(r),D.success(k(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!G.current||e!==U.current||De.current?.path!==t||W.current!==n)return;D.error(r instanceof Error?r.message:k(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{G.current&&de(!1)}},J=[{id:`files`,label:k(`work.workspace.files`,{defaultValue:`Files`}),icon:x,testId:`work-files-tab`},{id:`activity`,label:k(`work.workspace.activity`,{defaultValue:`Activity`}),icon:w,testId:`work-activity-tab`},{id:`git`,label:k(`work.workspace.git`,{defaultValue:`Git`}),icon:m,testId:`work-git-tab`},{id:`terminal`,label:k(`work.workspace.terminal`,{defaultValue:`Terminal`}),icon:p,testId:`work-terminal-tab`},{id:`preview`,label:k(`work.workspace.preview`,{defaultValue:`Preview`}),icon:S,testId:`work-preview-tab`}],Ke=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(j?-1:1)+J.length)%J.length),e.key===`ArrowLeft`&&(n=(t+(j?1:-1)+J.length)%J.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=J.length-1),n===null)return;e.preventDefault();let r=J[n];te(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,H.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-transparent`,children:[(0,H.jsxs)(`div`,{"data-testid":`work-workspace-toolbar`,className:`flex h-12 shrink-0 items-center gap-2 border-b border-line bg-surface-raised/75 px-2 backdrop-blur-xl`,children:[(0,H.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":k(`work.workspace.label`,{defaultValue:`Workspace views`}),className:`flex min-w-0 items-center overflow-x-auto rounded-xl border border-line bg-surface-subtle p-0.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:J.map((e,t)=>{let n=e.icon;return(0,H.jsxs)(`button`,{type:`button`,role:`tab`,id:`work-workspace-tab-${e.id}`,"aria-selected":M===e.id,"aria-controls":M===e.id?`work-workspace-panel-${e.id}`:void 0,"aria-label":e.label,tabIndex:M===e.id?0:-1,title:e.label,"data-testid":e.testId,onClick:()=>te(e.id),onKeyDown:e=>Ke(e,t),className:L(`flex h-7 items-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow]`,M===e.id?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:text-ink`),children:[(0,H.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&Ce>0&&(0,H.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:Ce})]},e.id)})}),M===`files`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[r&&(0,H.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink sm:hidden`,onClick:He,"aria-label":k(`work.files.back`,{defaultValue:`Back to files`}),children:(0,H.jsx)(oe,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,H.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:r?.path??`/workspace${N?`/${N}`:``}`,children:[r?.path??`/workspace${N?`/${N}`:``}`,we&&` •`]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:!N,onClick:()=>void Be(Pt(N)),className:L(`hidden h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink disabled:opacity-30 sm:inline-flex`,!r&&`inline-flex`),"aria-label":k(`work.files.up`,{defaultValue:`Parent folder`}),title:k(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,H.jsx)(oe,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,H.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void o(N).catch(()=>void 0),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink`,"aria-label":k(`common.refresh`,{defaultValue:`Refresh`}),title:k(`common.refresh`,{defaultValue:`Refresh`}),children:(0,H.jsx)(C,{className:L(`h-3.5 w-3.5`,i&&`animate-spin`)})}),r&&Fe&&Ne&&(0,H.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-toggle-button`,"aria-pressed":I,onClick:()=>R(e=>!e),title:k(`work.files.changesSince`,{defaultValue:`What changed since the last turn`}),className:L(`inline-flex h-8 items-center gap-1.5 rounded-lg border px-2 text-[11px] font-medium transition-colors`,I?`border-transparent bg-ink text-ink-inverse`:`border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`),children:[(0,H.jsx)(T,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:k(`work.files.changes`,{defaultValue:`Changes`})}),(0,H.jsxs)(`span`,{dir:`ltr`,className:`tabular-nums`,children:[(0,H.jsxs)(`span`,{className:I?void 0:`text-[rgb(46,164,79)]`,children:[`+`,Ne.added]}),` `,(0,H.jsxs)(`span`,{className:I?void 0:`text-[rgb(255,61,129)]`,children:[`−`,Ne.removed]})]})]}),r&&!I&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(z,{"data-testid":`work-format-file-button`,size:`sm`,variant:`ghost`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:B||ue||!q,onClick:()=>void Ge(),"aria-busy":ue||void 0,title:q?k(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Ie?k(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):k(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":k(`work.files.format`,{defaultValue:`Format file`}),children:[ue?(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,H.jsx)(ee,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`work.files.format`,{defaultValue:`Format`})})]}),(0,H.jsxs)(z,{"data-testid":`work-save-file-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:!we||B||ue||a,onClick:()=>void We(),"aria-busy":a||void 0,title:k(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":k(`common.save`),children:[a?(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,H.jsx)(g,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`common.save`)})]})]})]})]}),(M===`activity`||M===`git`)&&(0,H.jsx)(`div`,{className:`min-w-0 flex-1`}),M===`terminal`&&(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,H.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,children:`/workspace`}),B&&(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] text-ink-subtle`,children:k(`work.terminal.taskRunning`,{defaultValue:`Model turn in progress`})})]}),M===`preview`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`input`,{dir:`auto`,value:se,onChange:e=>le(e.target.value),placeholder:k(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":k(`work.preview.command`,{defaultValue:`Optional start command`}),className:`h-8 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2.5 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,H.jsxs)(z,{"data-testid":`work-stop-preview-button`,variant:`danger`,size:`sm`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void v(),"aria-busy":a||void 0,"aria-label":k(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[a?(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,H.jsx)(ce,{className:`h-3.5 w-3.5 fill-current`}),(0,H.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,H.jsxs)(z,{"data-testid":`work-start-preview-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void _(se.trim()||void 0),"aria-busy":a||void 0,"aria-label":k(`work.preview.start`,{defaultValue:`Start preview`}),children:[a?(0,H.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,H.jsx)(O,{className:`h-3.5 w-3.5 fill-current`}),(0,H.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`work.preview.start`,{defaultValue:`Start preview`})})]}),ve&&(0,H.jsx)(`a`,{href:ve,target:`_blank`,rel:`noopener noreferrer`,"aria-label":k(`work.preview.open`,{defaultValue:`Open`}),title:k(`work.preview.open`,{defaultValue:`Open`}),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`,children:(0,H.jsx)(f,{className:`h-3.5 w-3.5`})})]})]})]}),M===`files`&&(0,H.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,H.jsx)(`div`,{className:L(`flex min-h-0 w-full flex-col border-e border-line bg-surface-raised`,r?`hidden sm:flex sm:w-52 xl:w-60`:`flex`),children:(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:i&&n.length===0?(0,H.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,H.jsx)(F,{className:`h-5 w-5 animate-spin`})}):n.length===0?(0,H.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:k(`work.files.empty`,{defaultValue:`No files in this folder yet.`})}):[...n].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(e=>(0,H.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?Be(e.path):Ve(e.path)},className:L(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-xs hover:bg-surface-subtle`,r?.path===e.path?`bg-surface-subtle text-ink`:`text-ink-muted`),children:[e.type===`directory`?(0,H.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,H.jsx)(y,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,H.jsx)(`div`,{className:L(`min-h-0 min-w-0 flex-1 flex-col`,r?`flex`:`hidden sm:flex`),children:r&&I&&Me?(0,H.jsx)(Ct,{lines:Me,ariaLabel:k(`work.files.diffLabel`,{path:r.path,defaultValue:`Changes since the last turn: {{path}}`})}):r?(0,H.jsx)(gt,{path:r.path,value:P,ariaLabel:k(`work.files.editorLabel`,{path:r.path,defaultValue:`File editor: {{path}}`}),onChange:Ue,onSaveShortcut:()=>{we&&!B&&!a&&!ue&&We()},onFormatShortcut:()=>void Ge(),disabled:B||ue}):(0,H.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,H.jsx)(y,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),k(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),M===`activity`&&(0,H.jsxs)(`div`,{id:`work-workspace-panel-activity`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-activity`,className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[t&&(0,H.jsx)(`div`,{className:`mb-3`,children:(0,H.jsx)(Pe,{run:t,variant:`activity`})}),Se.length===0&&!t?(0,H.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,H.jsx)(p,{className:`mb-3 h-7 w-7 text-ink-subtle`}),k(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,H.jsx)(`div`,{className:`space-y-2`,children:Se.map(e=>(0,H.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:Ft(e,k(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:k(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:k(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:k(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:k(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:k(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,H.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-words text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:e.content})]},e.id))})]}),M===`git`&&(0,H.jsx)(`div`,{id:`work-workspace-panel-git`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-git`,className:`min-h-0 flex-1`,children:(0,H.jsx)(Et,{taskId:e.id,mutationsDisabled:B||e.previewStatus===`starting`||e.previewStatus===`running`,disabledReason:B?k(`work.git.blockedByRun`,{defaultValue:`Git write actions unlock when the model turn finishes.`}):e.previewStatus===`starting`||e.previewStatus===`running`?k(`work.git.blockedByPreview`,{defaultValue:`Stop the preview before changing Git state.`}):void 0})}),M===`terminal`&&(0,H.jsx)(`div`,{id:`work-workspace-panel-terminal`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-terminal`,className:`flex min-h-0 flex-1 flex-col`,children:(0,H.jsx)(Mt,{taskId:e.id,active:M===`terminal`,disabledReason:E&&!E.available?E.reason??k(`work.terminal.unavailable`,{defaultValue:`The interactive terminal is not available in this deployment.`}):B?k(`work.terminal.blockedByRun`,{defaultValue:`The model is using this container. The terminal opens when the turn finishes.`}):void 0})}),M===`preview`&&(0,H.jsx)(`div`,{id:`work-workspace-panel-preview`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-preview`,className:`flex min-h-0 flex-1 flex-col`,children:e.previewStatus===`starting`?(0,H.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,H.jsx)(F,{className:`h-4 w-4 animate-spin`}),k(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):ve&&e.previewStatus===`running`?(0,H.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:k(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:ve,sandbox:`allow-scripts allow-forms allow-modals allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 flex-1 border-0 bg-white`}):(0,H.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,H.jsx)(S,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?k(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):k(`work.preview.empty`,{defaultValue:`Start the app inside this workspace to inspect it here.`})]})})]})}var Lt=e=>{let t=e.trim().toLowerCase();return!!t&&!t.includes(`embed`)},Rt=(e,t)=>e instanceof Error&&e.message?e.message:t,zt=(e,t)=>new Promise(n=>{if(t.aborted){n();return}let r,i=()=>{r!==void 0&&window.clearTimeout(r),t.removeEventListener(`abort`,i),n()};r=window.setTimeout(i,e),t.addEventListener(`abort`,i,{once:!0})});function Bt(){let{t:e}=c(),t=s(),n=r(),{taskId:a}=i(),l=ve(e=>e.preferences),d=ve(e=>e.setPreferences),f=he(e=>e.user),p=f?.id??null,[m,h]=(0,V.useState)(!1),g=R(e=>e.models),_=R(e=>e.selectedModel),v=R(e=>e.selectedProviderType),y=R(e=>e.selectedProviderId),b=R(e=>e.loadModels),{capabilities:x,tasks:C,selectedTask:w,files:T,selectedFile:E,liveRuns:O,loadingTask:A,loadingOlderMessages:j,loadingFiles:M,actionLoading:ee,error:P,loadCapabilities:re,loadTasks:F,selectTask:oe,loadTask:ce,loadOlderMessages:le,createTask:ue,updateTask:ge,deleteTask:_e,startRun:z,cancelRun:ye,beginLiveRun:xe,applyRunEvents:Se,setLiveRunConnection:Ce,clearLiveRun:Te,loadFiles:U,loadFile:W,clearSelectedFile:De,saveFile:Oe,startPreview:ke,stopPreview:Ae,clearError:je}=me(),G=(0,V.useMemo)(()=>g.filter(e=>!e.isPersona&&!e.isAgent&&Lt(e.name)&&(!e.isPlugin||!!e.pluginId)),[g]),K=(0,V.useMemo)(()=>G.flatMap(e=>{if(e.isPlugin&&!e.pluginId)return[];let t=e.isPlugin?`plugin`:`ollama`,n=e.isPlugin?e.pluginId:void 0,r=e.name.trim().toLowerCase(),i={model:e.name,providerType:t,providerId:n};return[{...i,key:we(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[G]),[Me,Ne]=(0,V.useState)(``),[Pe,Fe]=(0,V.useState)({locationKey:t.key,value:`conversation`}),Ie=Pe.locationKey===t.key?Pe.value:`conversation`,Le=e=>Fe({locationKey:t.key,value:e}),[q,Re]=(0,V.useState)(!1),[ze,Ve]=(0,V.useState)(``),He=x?.hostWorkspaces?.enabled===!0,Ue=x?.hostWorkspaces?.roots??[],[We,Ge]=(0,V.useState)({taskId:null,open:!1}),J=We.open&&We.taskId===w?.id,Ke=(0,V.useRef)(null),qe=(0,V.useRef)(null),Je=(0,V.useRef)(null),Ye=(0,V.useCallback)((e=!1)=>{Ge(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>qe.current?.focus())},[]);(0,V.useEffect)(()=>{if(!J)return;let e=window.requestAnimationFrame(()=>{Je.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!Ke.current?.contains(e.target)&&Ye()},n=e=>{e.key===`Escape`&&(e.preventDefault(),Ye(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[Ye,J]);let Xe=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Ye(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...Je.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`?(n-1+t.length)%t.length:(n+1)%t.length]?.focus()};(0,V.useEffect)(()=>{re(),F()},[re,F]),(0,V.useEffect)(()=>{if(!a){oe(null);return}oe(a),ce(a).catch(()=>void 0),U(a,``).catch(()=>void 0)},[a,U,ce,oe]);let Ze=K.find(e=>e.key===Me)||K.find(e=>e.model===_&&(v===`plugin`?e.providerType===`plugin`&&e.providerId===y:e.providerType===`ollama`))||K[0],Qe=a?C.find(e=>e.id===a):void 0,Y=Qe?.status??w?.status,X=w?.activeRun??Qe?.activeRun??null,Z=X?.id,et=X?.status===`queued`||X?.status===`preparing`||X?.status===`running`,tt=a&&O[a]?.runId===Z?O[a]:void 0,nt=Y===`preparing`||Y===`running`?1e3:4e3;(0,V.useEffect)(()=>{let e,t=!1,n=async()=>{await F(!0),t||(e=setTimeout(n,nt))};return e=setTimeout(n,nt),()=>{t=!0,e&&clearTimeout(e)}},[F,nt]);let rt=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(!a||!Y){rt.current=null;return}let e=rt.current;rt.current={taskId:a,status:Y},e?.taskId===a&&(e.status===`preparing`||e.status===`running`)&&Y!==`preparing`&&Y!==`running`&&(ce(a,!0).catch(()=>void 0),U(a,``).catch(()=>void 0))},[U,ce,Y,a]),(0,V.useEffect)(()=>{if(!a||!Z||!et)return;let e=new AbortController,t=!1,n=0,r=me.getState().liveRuns[a]?.runId===Z&&me.getState().liveRuns[a]?.lastEventId||0,i=!1,o=[],s=null,c=()=>{if(s!==null&&(window.cancelAnimationFrame(s),s=null),o.length===0)return;let e=o;o=[],Se(e)},l=e=>{if(e.type!==`snapshot`&&(n=0),r=Math.max(r,e.id),o.push(e),e.type===`done`||e.type===`error`&&e.data.terminal!==!1){i=!0,c();return}s===null&&(s=window.requestAnimationFrame(c))};return xe(a,Z,X?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!i;){Ce(a,Z,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await I.streamRunEvents({taskId:a,runId:Z,after:r,signal:e.signal,onEvent:l}),c(),i||t||e.signal.aborted)break;throw Error(`The live Work connection closed.`)}catch(r){if(c(),t||e.signal.aborted)return;Date.now()-o>=5e3&&(n=0),n+=1,Ce(a,Z,n>=3?`error`:`reconnecting`,n>=3?Rt(r,`Live updates are reconnecting in the background.`):void 0),await zt(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!i||e.signal.aborted)){Ce(a,Z,`closed`);try{await Promise.all([ce(a,!0),U(a,``),F(!0)])}catch{}finally{Te(a,Z)}}})(),()=>{t=!0,e.abort(),c()}},[Se,xe,Te,U,ce,F,X?.startedAt,et,Z,Ce,a]),(0,V.useEffect)(()=>{if(!q)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[q]);let it=(0,V.useCallback)(()=>!q||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,q]),at=(0,V.useCallback)(()=>!q||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,q]),ot=()=>{w&&E&&pe(w.id,E.path)},st=o(({currentLocation:e,nextLocation:t})=>{let n=t.state;return q&&n?.deletedWorkTaskId!==a&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,V.useEffect)(()=>{if(st.state!==`blocked`)return;if(!at()){st.reset();return}let e=st.proceed,t=window.setTimeout(()=>{Re(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[at,st]);let ct=()=>{je(),Le(`conversation`),n(`/work`)},lt=async t=>{if(w&&!it())return!1;w&&q&&(ot(),De(),Re(!1));try{if(w)await z(w.id,{message:t,model:w.model,providerType:w.providerType,providerId:w.providerId||void 0});else{if(!Ze)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));let r=await ue({message:t,model:Ze.model,providerType:Ze.providerType,providerId:Ze.providerId,networkEnabled:!0,...He&&ze.trim()?{hostPath:ze.trim()}:{}});n(`/work/${r.id}`)}return!0}catch(t){return D.error(Rt(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},Q=async t=>{let n=xt.find(e=>e.key===t);if(n){if(!w){Ne(t);return}try{await ge(w.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){D.error(Rt(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},ut=async()=>{if(w)try{await ye(w.id),D.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){D.error(Rt(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},dt=async t=>{let r=C.find(e=>e.id===t);if(!window.confirm(e(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:r?.title||e(`work.tasks.untitled`,{defaultValue:`Untitled task`})})))return;let i=a===t&&q;i&&Re(!1);try{await _e(t),fe(t),a===t&&n(`/work`)}catch(t){i&&Re(!0),D.error(Rt(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},ft=async t=>{if(!w)return!1;let n=t.trim();if(!n||n===w.title)return!!n;try{return await ge(w.id,{title:n}),!0}catch(t){return D.error(Rt(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},pt=async(e,t,n)=>{try{return await e(),n&&D.success(n),!0}catch(e){return D.error(Rt(e,t)),!1}},mt=async(t,n,r)=>{if(!w)return!1;let i=w.id;try{let a=await Oe(i,t,n,r);return me.getState().selectedTaskId===i&&D.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return me.getState().selectedTaskId===i&&D.error(Rt(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},ht=x?.available===!1,gt=x?.pluginAvailable?x.ollamaAvailable?e(`work.runtime.readyHybrid`,{defaultValue:`Docker + models ready`}):e(`work.runtime.readyPlugin`,{defaultValue:`Docker + plugin ready`}):e(`work.runtime.readyOllama`,{defaultValue:`Docker ready`}),_t=e(`work.runtime.ready`,{defaultValue:`Runtime ready`}),vt=w?B(w):!1,$=w?{model:w.model,providerType:w.providerType,providerId:w.providerId||void 0}:void 0,yt=$?we($):Ze?.key||``,bt=$&&!K.some(e=>e.key===yt)?{...$,key:yt,label:`${$.model} · ${$.providerType===`plugin`?$.providerId||`plugin`:`Ollama`}`,remote:$.providerType===`plugin`||$.model.toLowerCase().endsWith(`:cloud`)||$.model.toLowerCase().endsWith(`-cloud`)}:void 0,xt=bt?[bt,...K]:K,St=be[w?.status??`idle`],Ct=e(St.labelKey,{defaultValue:St.label}),wt=async()=>{if(l.workRemoteProviderDisclosureDismissed||m)return!1;let t=p;h(!0);try{let n=await de.updatePreferences({workRemoteProviderDisclosureDismissed:!0});if(!n.success)throw Error(n.error||e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`}));return(he.getState().user?.id??null)===t&&(d({workRemoteProviderDisclosureDismissed:!0}),!0)}catch{return D.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{h(!1)}};return(0,H.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-transparent`,children:(0,H.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,H.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3 border-b border-line bg-surface/55 px-3 backdrop-blur-xl md:px-4`,children:[w?(0,H.jsx)(`input`,{"data-testid":`work-task-title`,dir:`auto`,defaultValue:w.title,onBlur:e=>{let t=e.currentTarget;if(!t.value.trim()){t.value=w.title;return}ft(t.value).then(e=>{e||(t.value=w.title)})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=w.title,e.currentTarget.blur())},className:`min-w-0 max-w-sm flex-1 truncate rounded-lg border border-transparent bg-transparent px-2 py-1 text-sm font-semibold text-ink outline-none hover:border-line focus:border-primary-500 focus:bg-surface`,"aria-label":e(`work.tasks.rename`,{defaultValue:`Task title`})},`${w.id}:${w.title}`):(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})})}),w?.hostPath&&(0,H.jsxs)(`span`,{"data-testid":`work-host-path-chip`,title:w.hostPath,className:`hidden h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 font-mono text-[11px] text-ink-muted sm:inline-flex`,children:[(0,H.jsx)(N,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:w.hostPath})]}),w&&(0,H.jsxs)(`span`,{"data-testid":`work-compact-status`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2 text-[11px] font-medium text-ink-muted xl:hidden`,"aria-label":e(`work.tasks.status`,{status:Ct,defaultValue:`Status: {{status}}`}),title:e(`work.tasks.status`,{status:Ct,defaultValue:`Status: {{status}}`}),children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-compact-status-indicator`,className:L(`h-1.5 w-1.5 rounded-full`,St.animated&&`animate-pulse`,w.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:St.color}}),(0,H.jsx)(`span`,{className:`hidden md:inline`,children:Ct})]}),w&&(0,H.jsxs)(`div`,{className:`ms-auto inline-flex h-9 shrink-0 items-center rounded-xl border border-line bg-surface-subtle p-1 shadow-subtle xl:hidden`,role:`group`,"aria-label":e(`work.mobile.surface`,{defaultValue:`Task surface`}),children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Le(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":Ie===`conversation`,className:L(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Ie===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,H.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Le(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":Ie===`workspace`,className:L(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Ie===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,H.jsx)(S,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,H.jsxs)(`div`,{className:L(`ms-auto hidden min-w-0 items-center gap-2`,w?`xl:flex`:`sm:flex`),children:[w&&(0,H.jsxs)(`span`,{"data-testid":`work-status`,className:`inline-flex h-7 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-status-indicator`,className:L(`h-1.5 w-1.5 rounded-full`,St.animated&&`animate-pulse`,w.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:St.color}}),Ct]}),(0,H.jsxs)(`span`,{"data-testid":`work-runtime-status`,className:L(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-[11px] font-medium`,ht?`border-transparent bg-error-500 text-[#0D0D0C]`:`border-transparent bg-success-500 text-[#0D0D0C]`),title:ht?x?.reason||e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):x?.image?`${gt} · ${x.image}`:gt,children:[(0,H.jsx)(ie,{className:`h-3.5 w-3.5`}),ht?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):_t]}),w&&(0,H.jsxs)(`span`,{className:`hidden h-7 max-w-44 items-center gap-1.5 truncate rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted md:inline-flex`,children:[(0,H.jsx)(se,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:w.model})]})]}),w&&(0,H.jsxs)(`div`,{ref:Ke,className:`relative shrink-0`,children:[(0,H.jsx)(`button`,{ref:qe,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>Ge(e=>({taskId:w.id,open:e.taskId!==w.id||!e.open})),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),Ge({taskId:w.id,open:!0}))},className:`inline-flex h-9 w-9 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink`,"aria-label":e(`work.tasks.actions`,{defaultValue:`Task actions`}),"aria-haspopup":`menu`,"aria-expanded":J,"aria-controls":J?`work-task-actions-menu`:void 0,children:(0,H.jsx)(k,{className:`h-4 w-4`})}),J&&(0,H.jsx)(`div`,{ref:Je,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:Xe,className:`absolute end-0 top-10 z-40 min-w-44 rounded-xl border border-line bg-surface-overlay p-1.5 shadow-overlay`,children:(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{Ye(!0),dt(w.id)},className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-start text-xs font-medium text-error-600 transition-colors hover:bg-error-500/10`,children:[(0,H.jsx)(ne,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),(ht||P)&&(0,H.jsxs)(`div`,{className:L(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,ht?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,H.jsx)(u,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:ht?x?.reason||e(`work.runtime.reason`,{defaultValue:`Docker and an available Ollama or plugin model provider are required.`}):P}),P&&!ht&&(0,H.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:je,"aria-label":e(`common.close`),children:`×`})]}),a?w?(0,H.jsx)($e,{userId:p,mobileSurface:Ie,conversation:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Be,{task:w,user:f,liveRun:tt,loading:A,loadingOlder:j,onLoadOlder:()=>le(w.id)}),(0,H.jsx)(Ee,{models:xt,selectorModels:G,modelKey:yt,running:vt,loading:ee,disabled:ht,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:m,onModelChange:Q,onDismissRemoteDisclosure:wt,onModelsRefresh:b,onSubmit:lt,onCancel:ut},w.id)]}),workspace:(0,H.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,H.jsx)(It,{task:w,liveRun:tt,files:T,selectedFile:E,loadingFiles:M,actionLoading:ee,onLoadFiles:e=>U(w.id,e),onLoadFile:e=>W(w.id,e),onClearSelectedFile:De,onSaveFile:mt,onStartPreview:t=>pt(()=>ke(w.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>pt(()=>Ae(w.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:Re,terminal:x?.terminal},w.id)})}):(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:A?(0,H.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(u,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,H.jsxs)(`button`,{type:`button`,onClick:ct,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,H.jsx)(te,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-y-auto`,children:[(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:[(0,H.jsx)(`div`,{className:`absolute left-[12%] top-[18%] h-56 w-56 rounded-full bg-primary-500/[0.035] blur-3xl dark:bg-primary-400/[0.04]`}),(0,H.jsx)(`div`,{className:`absolute bottom-[16%] right-[10%] h-72 w-72 rounded-full bg-gray-900/[0.025] blur-3xl dark:bg-white/[0.025]`}),(0,H.jsx)(`div`,{className:`absolute left-1/2 top-0 h-16 w-px bg-gray-300/60 dark:bg-white/10`})]}),(0,H.jsxs)(`section`,{"data-testid":`work-landing`,className:`relative z-[1] mx-auto flex min-h-full w-full max-w-3xl flex-col items-center justify-center px-4 py-20 sm:px-8 sm:py-24`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,H.jsx)(`h2`,{className:`max-w-3xl text-balance text-[clamp(2.65rem,7vw,5.25rem)] font-light leading-[0.98] tracking-[-0.055em] text-ink rtl:leading-[1.12] rtl:tracking-normal`,children:e(`work.landing.title`,{defaultValue:`Start a new Work task`})}),(0,H.jsx)(`p`,{className:`mt-4 max-w-xl text-balance text-base leading-relaxed text-ink-muted sm:text-lg`,children:e(`work.landing.description`,{defaultValue:`Give a local model a durable, isolated workspace. It can inspect files, run tools, and continue where it left off when you return.`})})]}),He&&(0,H.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,H.jsx)(`label`,{htmlFor:`work-host-path`,className:`mb-1.5 block text-xs font-medium text-ink-muted`,children:e(`work.hostWorkspace.label`,{defaultValue:`Workspace folder (optional)`})}),(0,H.jsx)(`input`,{id:`work-host-path`,"data-testid":`work-host-path`,value:ze,onChange:e=>Ve(e.target.value),spellCheck:!1,placeholder:Ue[0]?`${Ue[0]}/my-project`:`/path/to/folder`,className:`w-full rounded-xl border border-line bg-surface px-3 py-2 font-mono text-[13px] text-ink outline-none transition-colors placeholder:text-ink-subtle focus:border-line-strong focus-visible:ring-2 focus-visible:ring-primary-500/30`}),(0,H.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:ze.trim()?e(`work.hostWorkspace.warning`,{defaultValue:`The task can read and write this folder directly. Leave blank to use an isolated workspace instead.`}):e(`work.hostWorkspace.hint`,{defaultValue:`Leave blank for an isolated workspace, or point the task at a folder on this machine.`})})]}),(0,H.jsx)(Ee,{variant:`landing`,models:K,selectorModels:G,modelKey:Ze?.key||``,running:!1,loading:ee,disabled:ht,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:m,onModelChange:Q,onDismissRemoteDisclosure:wt,onModelsRefresh:b,onSubmit:lt,onCancel:ut}),(0,H.jsxs)(`div`,{"data-testid":`work-workspace-note`,role:`note`,className:`mt-4 flex max-w-2xl flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[10px] leading-relaxed text-ink-subtle`,children:[(0,H.jsx)(ie,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:e(`work.composer.hint`,{defaultValue:`Each task keeps its own files and history. Review model output before using it.`})})]})]})]})]})})}export{Bt as default};