@spencerboucher/switchyard 0.9.0 → 0.10.0
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.
- package/README.md +2 -2
- package/dist/switchyard.mjs +7073 -5396
- package/dist/terminal/holder.js +30 -4
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-BsTwLnMp.js +2 -0
- package/web-dist/assets/{AutomationView-D7Syv1En.js.map → AutomationView-BsTwLnMp.js.map} +1 -1
- package/web-dist/assets/Card-CAFxHoHd.js +2 -0
- package/web-dist/assets/Card-CAFxHoHd.js.map +1 -0
- package/web-dist/assets/Checkbox-rDvnQnxc.js +2 -0
- package/web-dist/assets/Checkbox-rDvnQnxc.js.map +1 -0
- package/web-dist/assets/Copy-D8xhl7eJ.js +2 -0
- package/web-dist/assets/{Copy-B6XSAIUd.js.map → Copy-D8xhl7eJ.js.map} +1 -1
- package/web-dist/assets/DangerZone-og55TRug.js +2 -0
- package/web-dist/assets/DangerZone-og55TRug.js.map +1 -0
- package/web-dist/assets/{Field-D-Ty7fKT.js → Field-Dbg_8KTt.js} +2 -2
- package/web-dist/assets/{Field-D-Ty7fKT.js.map → Field-Dbg_8KTt.js.map} +1 -1
- package/web-dist/assets/{InteractionCard-DF1EcSpm.js → InteractionCard-Yu5wgLC3.js} +4 -4
- package/web-dist/assets/{InteractionCard-DF1EcSpm.js.map → InteractionCard-Yu5wgLC3.js.map} +1 -1
- package/web-dist/assets/Menu-euseM8yR.js +2 -0
- package/web-dist/assets/Menu-euseM8yR.js.map +1 -0
- package/web-dist/assets/Overlay-BNPvMjLX.js +2 -0
- package/web-dist/assets/{Overlay-DUQwh6_b.js.map → Overlay-BNPvMjLX.js.map} +1 -1
- package/web-dist/assets/Priority-Ca1B2yFr.js +2 -0
- package/web-dist/assets/{Priority-CHmzfoHg.js.map → Priority-Ca1B2yFr.js.map} +1 -1
- package/web-dist/assets/{SegmentedControl-C_hEVQMB.js → SegmentedControl-D2d-NEr-.js} +2 -2
- package/web-dist/assets/{SegmentedControl-C_hEVQMB.js.map → SegmentedControl-D2d-NEr-.js.map} +1 -1
- package/web-dist/assets/{Select-Cfql4Nwu.js → Select-C9L1HKMm.js} +2 -2
- package/web-dist/assets/{Select-Cfql4Nwu.js.map → Select-C9L1HKMm.js.map} +1 -1
- package/web-dist/assets/StatusChip-BYuVxYS7.js +2 -0
- package/web-dist/assets/StatusChip-BYuVxYS7.js.map +1 -0
- package/web-dist/assets/{Switch-DBfzmqkm.js → Switch-DAcUcSbH.js} +2 -2
- package/web-dist/assets/{Switch-DBfzmqkm.js.map → Switch-DAcUcSbH.js.map} +1 -1
- package/web-dist/assets/{Tabs-BNuL3_Et.js → Tabs-xtagjtA5.js} +2 -2
- package/web-dist/assets/{Tabs-BNuL3_Et.js.map → Tabs-xtagjtA5.js.map} +1 -1
- package/web-dist/assets/{TextArea-CKybrQyn.js → TextArea-CKGHwURx.js} +2 -2
- package/web-dist/assets/{TextArea-CKybrQyn.js.map → TextArea-CKGHwURx.js.map} +1 -1
- package/web-dist/assets/{TextLink-OzzyP2-p.js → TextLink-Bub7sMxr.js} +2 -2
- package/web-dist/assets/{TextLink-OzzyP2-p.js.map → TextLink-Bub7sMxr.js.map} +1 -1
- package/web-dist/assets/attention-CI4dHY81.js +2 -0
- package/web-dist/assets/{attention-V86Gye3I.js.map → attention-CI4dHY81.js.map} +1 -1
- package/web-dist/assets/auth-308hUVgi.js +2 -0
- package/web-dist/assets/auth-308hUVgi.js.map +1 -0
- package/web-dist/assets/automations-BzpsJoa3.js +2 -0
- package/web-dist/assets/{automations-Cw5Gacgm.js.map → automations-BzpsJoa3.js.map} +1 -1
- package/web-dist/assets/bell-DSwa2PAb.js +2 -0
- package/web-dist/assets/bell-DSwa2PAb.js.map +1 -0
- package/web-dist/assets/board-CeJxBVHC.js +10 -0
- package/web-dist/assets/board-CeJxBVHC.js.map +1 -0
- package/web-dist/assets/code-DkNQvMI9.js +12 -0
- package/web-dist/assets/code-DkNQvMI9.js.map +1 -0
- package/web-dist/assets/describe-CVXeUClF.js +5 -0
- package/web-dist/assets/{describe-D6KLGKWa.js.map → describe-CVXeUClF.js.map} +1 -1
- package/web-dist/assets/enroll-jnKygG4L.js +2 -0
- package/web-dist/assets/{enroll-DwT7AcuS.js.map → enroll-jnKygG4L.js.map} +1 -1
- package/web-dist/assets/index-BHGZTS2e.js +16 -0
- package/web-dist/assets/index-BHGZTS2e.js.map +1 -0
- package/web-dist/assets/index-D2ml031z.css +2 -0
- package/web-dist/assets/{more-DQR5uu1c.js → more-DvKHMdBk.js} +2 -2
- package/web-dist/assets/{more-DQR5uu1c.js.map → more-DvKHMdBk.js.map} +1 -1
- package/web-dist/assets/queue-B2Vl0uSh.js +2 -0
- package/web-dist/assets/{queue-DUg1rS8t.js.map → queue-B2Vl0uSh.js.map} +1 -1
- package/web-dist/assets/repo-BDS8RBxq.js +2 -0
- package/web-dist/assets/repo-BDS8RBxq.js.map +1 -0
- package/web-dist/assets/settings-CLt7x9u8.js +8 -0
- package/web-dist/assets/settings-CLt7x9u8.js.map +1 -0
- package/web-dist/assets/states-C773NlHo.js +56 -0
- package/web-dist/assets/states-C773NlHo.js.map +1 -0
- package/web-dist/assets/{terminal-login-S5CAd5xA.js → terminal-login-BK5UjUir.js} +2 -2
- package/web-dist/assets/{terminal-login-S5CAd5xA.js.map → terminal-login-BK5UjUir.js.map} +1 -1
- package/web-dist/assets/useBreakpoint-BphHBrzF.js +2 -0
- package/web-dist/assets/useBreakpoint-BphHBrzF.js.map +1 -0
- package/web-dist/assets/useNow-Cm-tdyod.js +2 -0
- package/web-dist/assets/{useNow-Dj7oEiwn.js.map → useNow-Cm-tdyod.js.map} +1 -1
- package/web-dist/assets/{useResource-CDGSq2At.js → useResource-BBqCoY2q.js} +2 -2
- package/web-dist/assets/{useResource-CDGSq2At.js.map → useResource-BBqCoY2q.js.map} +1 -1
- package/web-dist/index.html +7 -3
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-D7Syv1En.js +0 -2
- package/web-dist/assets/Checkbox-D6tRfEeI.js +0 -2
- package/web-dist/assets/Checkbox-D6tRfEeI.js.map +0 -1
- package/web-dist/assets/Copy-B6XSAIUd.js +0 -2
- package/web-dist/assets/DangerZone-DfYlxDC1.js +0 -2
- package/web-dist/assets/DangerZone-DfYlxDC1.js.map +0 -1
- package/web-dist/assets/Menu-BfOszNC4.js +0 -2
- package/web-dist/assets/Menu-BfOszNC4.js.map +0 -1
- package/web-dist/assets/Overlay-DUQwh6_b.js +0 -2
- package/web-dist/assets/Priority-CHmzfoHg.js +0 -2
- package/web-dist/assets/attention-V86Gye3I.js +0 -2
- package/web-dist/assets/automations-Cw5Gacgm.js +0 -2
- package/web-dist/assets/board-B8X7TYYR.js +0 -10
- package/web-dist/assets/board-B8X7TYYR.js.map +0 -1
- package/web-dist/assets/code-BKroYJmR.js +0 -12
- package/web-dist/assets/code-BKroYJmR.js.map +0 -1
- package/web-dist/assets/describe-D6KLGKWa.js +0 -5
- package/web-dist/assets/enroll-DwT7AcuS.js +0 -2
- package/web-dist/assets/index-B3F7WcYf.css +0 -2
- package/web-dist/assets/index-hxvDvCS7.js +0 -12
- package/web-dist/assets/index-hxvDvCS7.js.map +0 -1
- package/web-dist/assets/queue-DUg1rS8t.js +0 -2
- package/web-dist/assets/repo-XzzzEI0d.js +0 -2
- package/web-dist/assets/repo-XzzzEI0d.js.map +0 -1
- package/web-dist/assets/search-C6cn5WOo.js +0 -2
- package/web-dist/assets/search-C6cn5WOo.js.map +0 -1
- package/web-dist/assets/settings-DyUu0tJM.js +0 -8
- package/web-dist/assets/settings-DyUu0tJM.js.map +0 -1
- package/web-dist/assets/states-ZhrxQa3K.js +0 -56
- package/web-dist/assets/states-ZhrxQa3K.js.map +0 -1
- package/web-dist/assets/useNow-Dj7oEiwn.js +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,n as r,t as i}from"./jsx-runtime-D13aM9HY.js";import{bt as a,c as o,f as s,h as c,i as l,lt as u,n as d,p as f,r as p,s as m,t as h,u as g,v as _,w as v,yt as y,z as b}from"./states-ZhrxQa3K.js";import{t as x}from"./calendar-clock-B8zE4JsX.js";import{r as S}from"./Priority-CHmzfoHg.js";import{t as C}from"./external-link-3jjTxo92.js";import{I as w,a as T,m as E,t as D,v as O}from"./useNow-Dj7oEiwn.js";import{t as k}from"./link-2-CaMlUDRG.js";import{N as A,P as j,R as M,T as N,X as P,b as F,c as I,q as L}from"./index-hxvDvCS7.js";var R={name:`folder-lock`,size:24,node:[[`rect`,{width:`8`,height:`5`,x:`14`,y:`17`,rx:`1`,key:`19aais`}],[`path`,{d:`M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5`,key:`1w6v7t`}],[`path`,{d:`M20 17v-2a2 2 0 1 0-4 0v2`,key:`pwaxnr`}]]};R.node;var z=r(R),B={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};B.node;var V=r(B),H={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};H.node;var U=r(H),W={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};W.node;var G=r(W),K=e(n(),1),q=i(),J={dependency:k,host_offline:A,project_limit:V,workspace_occupied:z,scheduled_time:x,invalid_configuration:_,dispatch_paused:L,project_automation_disabled:U,not_ready:v,already_dispatched:M,retry_backoff:G};function Y(){let e=D(),t=b(e=>e.tasks),n=b(e=>e.runs),r=b(e=>e.hydrated),i=a(e.error)&&e.error.status===404,s=!!e.data&&(!Array.isArray(e.data.running)||!Array.isArray(e.data.queued)),c=(0,K.useMemo)(()=>e.data&&!s?e.data.running.map(e=>({taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})):Object.values(n).filter(e=>O(e)&&e.state!==`queued`).map(e=>({taskId:e.taskId,runId:e.id,sessionId:e.sessionId})),[e.data,n,s]),l=(0,K.useMemo)(()=>e.data&&!s?e.data.queued.map(e=>({taskId:e.taskId,eligibility:e.eligibility})):Object.values(t).filter(e=>e.state===`ready`&&!e.hiddenFromBoard).sort((e,t)=>e.priority-t.priority||e.position-t.position).map(e=>({taskId:e.id,eligibility:void 0})),[e.data,t,s]),u=!e.data&&e.loading&&!e.error||!r,f=!!e.error&&!i&&!e.data;return s?(0,q.jsx)(p,{title:`The coordinator sent a queue this version cannot read`,error:`GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.`}):(0,q.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6`,children:[(0,q.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,q.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Queue`}),(0,q.jsx)(T,{})]}),(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`Pausing stops new work from starting. Runs already in progress keep going.`}),(0,q.jsx)(m,{subject:`queue`,show:!!e.data}),i&&(0,q.jsx)(g,{capability:`Queue explanations`,reason:`This coordinator does not report why queued tasks are waiting. The list below comes from local data.`}),e.error!=null&&!i&&(0,q.jsx)(d,{compact:!0,title:`Could not refresh running and queued work`,error:y(e.error),onRetry:e.reload}),u?(0,q.jsx)(o,{label:`Loading running and queued work…`}):f&&c.length===0&&l.length===0?null:c.length===0&&l.length===0?(0,q.jsx)(h,{icon:(0,q.jsx)(j,{className:`size-8`}),title:`Nothing running or queued`,description:`Move a task to Ready on the board and the dispatcher starts it when it is eligible.`,action:{label:`Go to Board`,to:I.board}}):(0,q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 xl:grid-cols-2 xl:items-start`,children:[(0,q.jsxs)(`section`,{"aria-labelledby":`now-running`,className:`flex min-w-0 flex-col gap-2`,children:[(0,q.jsxs)(`h2`,{id:`now-running`,className:`text-base font-semibold`,children:[`Running `,(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,c.length,`)`]})]}),c.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`Nothing is running.`}):(0,q.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:c.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(X,{taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})},e.runId))})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`now-queued`,className:`flex min-w-0 flex-col gap-2`,children:[(0,q.jsxs)(`h2`,{id:`now-queued`,className:`text-base font-semibold`,children:[`Queued `,(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,l.length,`)`]})]}),l.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`No Ready tasks are waiting.`}):(0,q.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:l.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Z,{task:t[e.taskId],taskId:e.taskId,eligibility:e.eligibility})},e.taskId))})]})]})]})}function X({taskId:e,runId:n,sessionId:r}){let i=b(t=>t.tasks[e]),a=b(e=>e.runs[n]),o=b(e=>a?.hostId?e.hosts[a.hostId]:void 0),u=b(e=>i?e.projects[i.projectId]:void 0),d=!!o&&o.connectivity!==`connected`;return(0,q.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[a?(0,q.jsx)(N,{kind:`run`,value:a.state,size:`sm`}):(0,q.jsx)(N,{kind:`task`,value:`in_progress`,size:`sm`}),(0,q.jsx)(t,{to:I.task(e),className:`min-w-0 flex-1 basis-48 font-medium break-words hover:underline`,children:i?.title??`Task`}),(r??i?.sessionId)&&(0,q.jsxs)(t,{to:I.session(r??i?.sessionId),className:s(`secondary`,`sm`),children:[(0,q.jsx)(C,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted`,children:[u?.name,o?`on ${o.name}`:null,a?.attempt&&a.attempt>1?`attempt ${a.attempt}`:null,a?.startedAt?`started ${c(a.startedAt)}`:null,a?.controlMode===`human`?`you have control`:`automation`].filter(Boolean).join(` · `)}),a?.state===`uncertain`&&o&&(0,q.jsx)(`p`,{className:`text-sm text-warning`,children:(0,q.jsxs)(`span`,{className:`text-text`,children:[`Waiting for host `,o.name,` to confirm launch. It is never started elsewhere.`]})}),d&&o&&(0,q.jsx)(l,{compact:!0,hostName:o.name,connectivity:o.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:o.lastSeenAt})]})}function Z({task:e,taskId:n,eligibility:r}){let i=b(t=>e?t.projects[e.projectId]:void 0),[a,o]=(0,K.useState)(!1),s=(0,K.useId)(),c=r?r.eligible?P:J[r.wait]:j,l=r?r.eligible?`Starting on ${r.hostName}`:E[r.wait]:`Waiting for dispatch`,d=r&&!r.eligible?r.message:null;return(0,q.jsxs)(`article`,{"data-testid":`now-queued-row`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,q.jsx)(t,{to:I.task(n),className:`min-w-0 font-medium break-words hover:underline`,children:e?.title??`Task`}),i&&(0,q.jsx)(`span`,{className:`text-xs text-muted`,children:i.name}),(0,q.jsxs)(`p`,{className:`flex min-w-0 items-start gap-1.5 text-sm`,children:[(0,q.jsx)(c,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 ${r?.eligible?`text-success`:`text-warning`}`}),(0,q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:l}),d&&d!==l?(0,q.jsxs)(`span`,{className:`text-muted`,children:[`: `,d]}):null]})]})]}),e&&(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,q.jsx)(`label`,{htmlFor:s,className:`text-sm text-muted`,children:`Priority`}),(0,q.jsx)(S,{id:s,width:`auto`,value:e.priority,disabled:a,onChange:async t=>{o(!0);try{await w(e.id,{priority:t}),F.success(`"${e.title}" is now ${u[t]} priority`)}catch(e){F.error(`Could not change priority: ${y(e)}`)}finally{o(!1)}}}),a&&(0,q.jsx)(f,{label:`Saving priority`})]})]})}export{Y as default};
|
|
2
|
-
//# sourceMappingURL=queue-DUg1rS8t.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./jsx-runtime-D13aM9HY.js";var t={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};t.node;var n=e(t),r={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};r.node;var i=e(r),a={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};a.node;var o=e(a),s={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};s.node;var c=e(s);function l(e){return e.startsWith(`local:`)?`Local only`:e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``)}function u(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.repoIdentity.toLowerCase().includes(n)}export{i as a,o as i,l as n,n as o,c as r,u as t};
|
|
2
|
-
//# sourceMappingURL=repo-XzzzEI0d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo-XzzzEI0d.js","names":["__iconData","__iconData","__iconData","createLucideIcon","__iconData$3","ChevronLeft","__iconData$2","FolderGit2","__iconData$1","Send","__iconData","SlidersHorizontal","repoLabel","identity","matchesProject","q","query","p"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/chevron-left.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/folder-git-2.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/send.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/sliders-horizontal.mjs","../../src/lib/repo.ts"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"chevron-left\",\n size: 24,\n node: [[\"path\", { d: \"m15 18-6-6 6-6\", key: \"1wnfg3\" }]]\n};\n__iconData.node;\nconst ChevronLeft = createLucideIcon(__iconData);\n\nexport { __iconData, ChevronLeft as default };\n//# sourceMappingURL=chevron-left.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"folder-git-2\",\n size: 24,\n node: [\n [\"path\", { d: \"M18 19a5 5 0 0 1-5-5v8\", key: \"sz5oeg\" }],\n [\n \"path\",\n {\n d: \"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5\",\n key: \"1w6njk\"\n }\n ],\n [\"circle\", { cx: \"13\", cy: \"12\", r: \"2\", key: \"1j92g6\" }],\n [\"circle\", { cx: \"20\", cy: \"19\", r: \"2\", key: \"1obnsp\" }]\n ]\n};\n__iconData.node;\nconst FolderGit2 = createLucideIcon(__iconData);\n\nexport { __iconData, FolderGit2 as default };\n//# sourceMappingURL=folder-git-2.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"send\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z\",\n key: \"1ffxy3\"\n }\n ],\n [\"path\", { d: \"m21.854 2.147-10.94 10.939\", key: \"12cjpa\" }]\n ]\n};\n__iconData.node;\nconst Send = createLucideIcon(__iconData);\n\nexport { __iconData, Send as default };\n//# sourceMappingURL=send.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"sliders-horizontal\",\n size: 24,\n node: [\n [\"path\", { d: \"M10 5H3\", key: \"1qgfaw\" }],\n [\"path\", { d: \"M12 19H3\", key: \"yhmn1j\" }],\n [\"path\", { d: \"M14 3v4\", key: \"1sua03\" }],\n [\"path\", { d: \"M16 17v4\", key: \"1q0r14\" }],\n [\"path\", { d: \"M21 12h-9\", key: \"1o4lsq\" }],\n [\"path\", { d: \"M21 19h-5\", key: \"1rlt1p\" }],\n [\"path\", { d: \"M21 5h-7\", key: \"1oszz2\" }],\n [\"path\", { d: \"M8 10v4\", key: \"tgpxqk\" }],\n [\"path\", { d: \"M8 12H3\", key: \"a7s4jb\" }]\n ]\n};\n__iconData.node;\nconst SlidersHorizontal = createLucideIcon(__iconData);\n\nexport { __iconData, SlidersHorizontal as default };\n//# sourceMappingURL=sliders-horizontal.mjs.map\n","import type { Project } from \"@switchyard/protocol\";\n\n/** \"Local only\" for repositories without a remote (`local:<sha|path>`), else the remote without its scheme. */\nexport function repoLabel(identity: string): string {\n if (identity.startsWith(\"local:\")) return \"Local only\";\n return identity.replace(/^[a-z][a-z0-9+.-]*:\\/\\//i, \"\");\n}\n\n/** Case-insensitive match on project name or remote. */\nexport function matchesProject(p: Pick<Project, \"name\" | \"repoIdentity\">, query: string): boolean {\n const q = query.trim().toLowerCase();\n if (!q) return true;\n return p.name.toLowerCase().includes(q) || p.repoIdentity.toLowerCase().includes(q);\n}\n"],"ignoreList":[0,1,2,3],"mappings":"A,8CASA,IAAMA,EAAa,CACjB,KAAM,eACN,KAAM,GACN,KAAM,CAAC,CAAC,OAAQ,CAAE,EAAG,iBAAkB,IAAK,QAAS,CAAC,CAAC,CACzD,EACAA,EAAW,KACX,IAAMK,EAAcF,EAAiBH,CAAU,ECNzCC,EAAa,CACjB,KAAM,eACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,yBAA0B,IAAK,QAAS,CAAC,EACvD,CACE,OACA,CACE,EAAG,yGACH,IAAK,QACP,CACF,EACA,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,EACxD,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,CAC1D,CACF,EACAA,EAAW,KACX,IAAMM,EAAaJ,EAAiBF,CAAU,ECjBxCC,EAAa,CACjB,KAAM,OACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,kIACH,IAAK,QACP,CACF,EACA,CAAC,OAAQ,CAAE,EAAG,6BAA8B,IAAK,QAAS,CAAC,CAC7D,CACF,EACAA,EAAW,KACX,IAAMO,EAAON,EAAiBD,CAAU,ECflCQ,EAAa,CACjB,KAAM,qBACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,YAAa,IAAK,QAAS,CAAC,EAC1C,CAAC,OAAQ,CAAE,EAAG,YAAa,IAAK,QAAS,CAAC,EAC1C,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,CAC1C,CACF,EACAA,EAAW,KACX,IAAMC,EAAoBR,EAAiBO,CAAU,ECtBrD,SAAgBE,EAAU,EAA0B,CAElD,OADIC,EAAS,WAAW,QAAQ,EAAU,aACnCA,EAAS,QAAQ,2BAA4B,EAAE,CACxD,CAGA,SAAgBC,EAAe,EAA2C,EAAwB,CAChG,IAAMC,EAAIC,EAAM,KAAK,CAAC,CAAC,YAAY,EAEnC,MADA,CAAKD,GACEE,EAAE,KAAK,YAAY,CAAC,CAAC,SAASF,CAAC,GAAKE,EAAE,aAAa,YAAY,CAAC,CAAC,SAASF,CAAC,CACpF,C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-C6cn5WOo.js","names":["createLucideIcon","__iconData","Search"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/search.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"search\",\n size: 24,\n node: [\n [\"path\", { d: \"m21 21-4.34-4.34\", key: \"14j7rj\" }],\n [\"circle\", { cx: \"11\", cy: \"11\", r: \"8\", key: \"4ej97u\" }]\n ]\n};\n__iconData.node;\nconst Search = createLucideIcon(__iconData);\n\nexport { __iconData, Search as default };\n//# sourceMappingURL=search.mjs.map\n"],"ignoreList":[0],"mappings":"A,8CASA,IAAMC,EAAa,CACjB,KAAM,SACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,mBAAoB,IAAK,QAAS,CAAC,EACjD,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,CAC1D,CACF,EACAA,EAAW,KACX,IAAMC,EAASF,EAAiBC,CAAU,E"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{_ as e,c as t,f as n,i as r,l as i,m as a,n as o,o as s,p as c,t as l,u}from"./jsx-runtime-D13aM9HY.js";import{A as d,P as f,S as p,X as m,_ as h,_t as g,a as _,at as v,bt as y,c as b,d as x,dt as S,f as C,g as w,h as T,ht as E,i as D,n as O,ot as ee,p as k,pt as A,r as j,rt as M,s as N,st as te,t as P,u as ne,ut as re,v as F,vt as I,x as ie,y as ae,yt as oe,z as L}from"./states-ZhrxQa3K.js";import{a as se,i as ce,r as R,t as z}from"./Field-D-Ty7fKT.js";import{n as le,r as ue,t as de}from"./Copy-B6XSAIUd.js";import{a as fe,i as pe,n as me,o as he,r as ge,t as _e}from"./repo-XzzzEI0d.js";import{t as ve}from"./chevron-right-evVLS6hq.js";import{n as ye,t as be}from"./pencil-DI8QbCN8.js";import{t as xe}from"./key-round-VDbE9E4X.js";import{i as Se,n as Ce,r as we,t as Te}from"./useBackTo-BIrCq3W2.js";import{n as B,r as Ee,t as De}from"./DangerZone-DfYlxDC1.js";import{t as Oe}from"./search-C6cn5WOo.js";import{t as ke}from"./server-BqZ-w6M8.js";import{t as Ae}from"./terminal-BOV_MXPZ.js";import{$ as je,B as Me,G as Ne,R as Pe,S as V,T as Fe,U as Ie,W as Le,X as H,Y as Re,Z as ze,a as Be,b as U,et as Ve,h as He,i as Ue,m as We,n as Ge,nt as Ke,o as qe,r as Je,s as Ye,t as Xe,y as Ze}from"./index-hxvDvCS7.js";import{n as Qe,t as W}from"./Overlay-DUQwh6_b.js";import{n as $e,r as G}from"./TextArea-CKybrQyn.js";import{t as et}from"./TextLink-OzzyP2-p.js";import{n as tt,t as K}from"./useResource-CDGSq2At.js";import{t as q}from"./Select-Cfql4Nwu.js";import{n as nt}from"./Switch-DBfzmqkm.js";import{t as rt}from"./Checkbox-D6tRfEeI.js";import{d as it,f as at,l as ot,r as st}from"./logic-B46fwD-8.js";var ct={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};ct.node;var lt=o(ct),ut={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};ut.node;var dt=o(ut),ft={name:`database-backup`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]};ft.node;var pt=o(ft),mt={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};mt.node;var ht=o(mt),gt={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};gt.node;var _t=o(gt),vt={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};vt.node;var yt=o(vt),bt={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};bt.node;var xt=o(bt),St={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};St.node;var Ct=o(St),wt={name:`monitor-smartphone`,size:24,node:[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]};wt.node;var Tt=o(wt),Et={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};Et.node;var Dt=o(Et),Ot={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ot.node;var kt=o(Ot),At={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};At.node;var jt=o(At),Mt={name:`stethoscope`,size:24,node:[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]};Mt.node;var Nt=o(Mt),J=e(a(),1),Y=l(),Pt=[{path:`projects`,label:`Projects`,description:`Repositories, checkouts and workspaces`,icon:fe,group:`Workspace`},{path:`profiles`,label:`Pi profiles`,description:`Provider, model and thinking presets`,icon:ge,group:`Workspace`},{path:`hosts`,label:`Hosts`,description:`Execution hosts, capabilities and versions`,icon:ke,group:`Infrastructure`},{path:`adapters`,label:`Adapters`,description:`Extension adapters on each host`,icon:p,group:`Infrastructure`},{path:`backups`,label:`Backups`,description:`Back up and restore the coordinator`,icon:pt,group:`Infrastructure`},{path:`diagnostics`,label:`Diagnostics`,description:`Versions, migrations, events and recent problems`,icon:Nt,group:`Infrastructure`},{path:`sign-in`,label:`Sign-in`,description:`Passkeys, single sign-on and signing out`,icon:xe,group:`Access`},{path:`devices`,label:`Devices`,description:`Signed-in browsers, apps and terminals`,icon:Tt,group:`Access`},{path:`notifications`,label:`Notifications`,description:`Push, quiet hours and previews`,icon:ze,group:`This device`},{path:`device`,label:`This device`,description:`Preferences stored on this device`,icon:yt,group:`This device`}],Ft=[`Workspace`,`Infrastructure`,`Access`,`This device`].map(e=>({label:e,sections:Pt.filter(t=>t.group===e)})),X=e=>e?`/settings/${e}`:`/settings`;function Z({title:e,description:t,actions:n,back:i,testId:a,children:o}){let s=We()===`mobile`,c=i??(s?{to:X(),label:`Settings`}:null),l=we(c?.to??X()),u=s&&!!c;return(0,Y.jsxs)(`section`,{"data-testid":a,className:`flex w-full min-w-0 flex-col gap-4 px-4 py-4 md:px-6`,children:[u&&c?(0,Y.jsxs)(`header`,{className:`sticky top-0 z-20 -mx-4 -mt-4 flex min-w-0 items-center gap-1 border-b border-border bg-surface px-1 pb-1 safe-pt-1`,children:[(0,Y.jsx)(r,{to:c.to,onClick:Ce(l),"aria-label":`Back to ${c.label}`,title:`Back to ${c.label}`,className:C(`ghost`,`md`,`size-11 px-0`),children:(0,Y.jsx)(se,{"aria-hidden":!0,className:`size-5`})}),(0,Y.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-base font-semibold`,children:e})]}):c&&(0,Y.jsxs)(r,{to:c.to,onClick:Ce(l),className:`tap -ml-2 inline-flex w-fit items-center gap-1 rounded-md px-2 py-1 text-sm font-medium text-accent hover:bg-surface-2`,children:[(0,Y.jsx)(he,{"aria-hidden":!0,className:`size-4`}),`Back to `,c.label]}),(!u||t||n)&&(0,Y.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-[1_1_15rem]`,children:[!u&&(0,Y.jsx)(`h1`,{className:`break-words text-lg font-semibold`,children:e}),t&&(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),o]})}function It({items:e}){return(0,Y.jsx)(`dl`,{className:`grid min-w-0 gap-x-4 gap-y-1 text-sm sm:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)]`,children:e.map(([e,t],n)=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`mb-1 min-w-0 break-words sm:mb-0`,children:t})]},n))})}function Q(){return L(e=>e.hydrated)}var Lt={darwin:`macOS`,linux:`Linux`};function Rt({host:e}){return e.piVersion?e.piCompatible?(0,Y.jsx)(V,{icon:H,tone:`success`,label:`Pi ${e.piVersion} (compatible)`}):(0,Y.jsx)(V,{icon:F,tone:`danger`,label:`Pi ${e.piVersion} (incompatible, needs ${m})`}):(0,Y.jsx)(V,{icon:F,tone:`warning`,label:`Pi not detected (incompatible)`})}function zt(e){let t=e.trim();return t?t.startsWith(`/`)?null:`Use an absolute path that starts with /, e.g. /Users/me/src/app.`:`Enter the path of the checkout on the host.`}function Bt(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.passkeys)&&typeof t.passkeyAvailability==`object`}function Vt(e){return e.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean)}function Ht(e){let[t,n]=(0,J.useState)(()=>Date.now());if((0,J.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Date.parse(e);return Number.isNaN(r)?null:Math.max(0,r-t)}function Ut(e){let t=Math.ceil(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var Wt={active:{icon:H,label:`Active`,tone:`success`},disabled:{icon:Ne,label:`Disabled`,tone:`neutral`},error:{icon:Le,label:`Error`,tone:`danger`}};function Gt({status:e}){let t=Wt[e]??Wt.error;return(0,Y.jsx)(V,{icon:t.icon,label:t.label,tone:t.tone})}var Kt={project:`Project`,owner:`Owner`,plugin:`Plugin`,bundled:`Bundled`},qt={info:{icon:Me,label:`Info`,tone:`info`},warning:{icon:F,label:`Warning`,tone:`warning`},error:{icon:Le,label:`Error`,tone:`danger`}};function Jt({level:e}){let t=qt[e]??qt.info;return(0,Y.jsx)(V,{icon:t.icon,label:t.label,tone:t.tone})}function Yt(e){let t=L(e=>e.diagnostics);return(0,J.useMemo)(()=>{let n=new Set,r=[];for(let i of[...e??[],...t]){let e=`${i.at}|${i.adapterId??``}|${i.sessionId??``}|${i.message}`;n.has(e)||(n.add(e),r.push(i))}return r.sort((e,t)=>t.at.localeCompare(e.at))},[e,t])}function Xt(){let e=Q(),t=L(e=>e.adapters),n=L(e=>e.hosts),i=tt(`/api/diagnostics`,K),a=Yt(Array.isArray(i.data?.diagnostics)?i.data.diagnostics:void 0),o=(0,J.useMemo)(()=>Object.entries(t).filter(([,e])=>e.length>0).map(([e,t])=>({hostId:e,hostName:n[e]?.name??`Removed host`,adapters:[...t].sort((e,t)=>e.id.localeCompare(t.id))})).sort((e,t)=>e.hostName.localeCompare(t.hostName)),[t,n]);return(0,Y.jsxs)(Z,{title:`Adapters`,description:`Adapters translate Pi extensions into Switchyard cards, panels and interactions. Each host reports its own.`,children:[(0,Y.jsx)(N,{}),i.error!==null&&!i.loading&&!i.fatal&&(0,Y.jsx)(O,{compact:!0,title:`Could not load adapter diagnostics history`,error:i.error,onRetry:i.reload}),e?o.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(p,{className:`size-8`}),title:`No adapters reported`,description:`Hosts report adapters when their agent connects. Check that your hosts are connected.`,action:{label:`Open hosts`,to:X(`hosts`)}}):o.map(e=>(0,Y.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,Y.jsx)(r,{to:X(`hosts/${encodeURIComponent(e.hostId)}`),className:`hover:underline`,children:e.hostName})}),e.adapters.map(e=>(0,Y.jsx)(Zt,{adapter:e,diagnostics:a.filter(t=>t.adapterId===e.id)},e.id))]},e.hostId)):(0,Y.jsx)(b,{label:`Loading adapters…`})]})}function Zt({adapter:e,diagnostics:t}){return(0,Y.jsxs)(B,{title:(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),actions:(0,Y.jsx)(Gt,{status:e.status}),children:[(0,Y.jsx)(It,{items:[[`Version`,e.version],[`Tier`,Kt[e.tier]??e.tier],[`Target extension`,(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.target.extension},`t`)],[`Version range`,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.target.versionRange},`r`)],[`Tested versions`,e.target.testedVersions.length?e.target.testedVersions.join(`, `):`None recorded`],[`Capabilities`,e.capabilities.length?e.capabilities.join(`, `):`None`],[`Web renderer`,e.webRenderer?`Yes (runs in a sandboxed frame; mobile uses a fallback)`:`No (native cards only)`],...e.detail?[[`Detail`,e.detail]]:[]]}),(0,Y.jsx)(`h3`,{className:`mt-3 mb-1 text-sm font-semibold`,children:`Recent diagnostics`}),t.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics for this adapter.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:t.slice(0,10).map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Y.jsx)(Jt,{level:e.level}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,Y.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:w(e.at)})]},`${e.at}-${e.message}`))})]})}function Qt(e){return K(e)&&K(e.versions)}var $t=`/api/diagnostics`,en=`switchyard coordinator backup <file>`,tn=`switchyard coordinator restore <file>`;function nn(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function rn(e,t){return t==null?`None`:typeof t==`string`&&/At$|time|date/i.test(e)?w(t):typeof t==`object`?JSON.stringify(t):String(t)}function an(){let e=tt($t,Qt),t=e.data&&K(e.data.backup)?e.data.backup:null;return(0,Y.jsxs)(Z,{title:`Backups`,description:`The coordinator keeps all state in one SQLite database. Back it up from the machine that runs the coordinator.`,children:[(0,Y.jsxs)(B,{title:`Back up`,children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm`,children:`Writes a consistent copy of the database to a file while the coordinator keeps running.`}),(0,Y.jsx)(de,{text:en,label:`Backup command`,copyLabel:`Copy command`})]}),(0,Y.jsxs)(B,{title:`Restore`,children:[(0,Y.jsxs)(`p`,{className:`mb-2 text-sm`,children:[`Restore refuses to run while the coordinator is running: stop it first. The current database is kept next to it as`,` `,(0,Y.jsx)(`code`,{className:`break-all`,children:`coordinator.db.bak-<ts>`}),`.`]}),(0,Y.jsx)(de,{text:tn,label:`Restore command`,copyLabel:`Copy command`}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:`Hosts keep running sessions during a coordinator restart and replay their events when it comes back.`})]}),(0,Y.jsx)(B,{title:`Last backup`,children:e.fatal?(0,Y.jsx)(j,{error:e.error}):e.error&&!e.loading&&!e.data?(0,Y.jsx)(O,{compact:!0,title:`Could not load backup info`,error:e.error,onRetry:e.reload}):e.data?t&&Object.keys(t).length>0?(0,Y.jsx)(It,{items:Object.entries(t).map(([e,t])=>[nn(e),rn(e,t)])}):(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No backup info is recorded by the coordinator. Keep track of your backup files yourself, or schedule the backup command with cron or launchd.`}):(0,Y.jsx)(b,{label:`Loading backup info…`})})]})}var on={browser:`Browser`,pwa:`Home Screen app`,terminal:`Terminal`,cli:`CLI`},sn={granted:`allowed`,denied:`blocked`,default:`not requested`,unknown:`unknown`};function cn({kind:e}){return(0,Y.jsx)(e===`pwa`?kt:e===`browser`?xt:Ae,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`})}function ln(){let e=Q(),t=L(e=>e.devices);Ke(e=>e.me);let n=je(),r=(0,J.useMemo)(()=>Object.values(t).filter(e=>e.revokedAt===null).sort((e,t)=>Number(t.id===n)-Number(e.id===n)||(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``)),[t,n]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[_,v]=(0,J.useState)(null),[y,S]=(0,J.useState)(null),C=async()=>{if(f){h(!0),v(null);try{await I(`/api/devices/${encodeURIComponent(f.id)}/revoke`),U.success(`${f.name} revoked`),p(null)}catch(e){v(e)}finally{h(!1)}}},w=async e=>{S(e.id);try{await g(`/api/devices/${encodeURIComponent(e.id)}`,{preferredMobile:!0}),U.success(`${e.name} is now the preferred mobile device`)}catch(e){U.error(`Could not set the preferred device: ${oe(e)}`)}finally{S(null)}},E=async()=>{if(!i)return;let e=o.trim();if(e){l(!0),d(null);try{await g(`/api/devices/${encodeURIComponent(i.id)}`,{name:e}),U.success(`Renamed to ${e}`),a(null)}catch(e){d(e)}finally{l(!1)}}};return(0,Y.jsxs)(Z,{testId:`settings-devices`,title:`Devices`,description:`Browsers, Home Screen apps and terminals signed in to this coordinator. Revoke one to sign it out.`,children:[(0,Y.jsx)(N,{}),e?r.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(Tt,{className:`size-8`}),title:`No devices`,description:`Browsers and terminals appear here once they sign in.`}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=e.id===n;return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Y.jsx)(cn,{kind:e.kind}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),t&&(0,Y.jsx)(V,{icon:xt,tone:`info`,label:`This device`}),e.preferredMobile&&(0,Y.jsx)(V,{icon:jt,tone:`success`,label:`Preferred mobile`})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted`,children:[(0,Y.jsx)(`span`,{children:on[e.kind]}),(0,Y.jsxs)(`span`,{children:[`Last seen `,T(e.lastSeenAt)]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.push.subscribed?(0,Y.jsx)(dt,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,Y.jsx)(lt,{"aria-hidden":!0,className:`size-4 shrink-0`}),e.push.subscribed?`Push subscribed`:`No push subscription`,`, permission`,` `,sn[e.push.permission]]})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!e.preferredMobile&&(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(jt,{className:`size-4`}),busy:y===e.id,onClick:()=>w(e),children:`Set as preferred mobile device`}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,"data-testid":`device-rename`,icon:(0,Y.jsx)(be,{className:`size-4`}),onClick:()=>{d(null),s(e.name),a(e)},children:`Rename`}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(Dt,{className:`size-4`}),onClick:()=>{v(null),p(e)},children:`Revoke`})]})]},e.id)})}):(0,Y.jsx)(b,{label:`Loading devices…`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`The preferred mobile device receives push notifications when no desktop was recently active.`}),(0,Y.jsx)(W,{open:i!==null,onClose:()=>a(null),title:`Rename device`,confirmLabel:`Save`,danger:!1,busy:c,error:u,confirmDisabled:!o.trim(),onConfirm:E,children:(0,Y.jsx)(G,{"aria-label":`Device name`,maxLength:80,value:o,autoComplete:`off`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()&&!c&&E()}})}),(0,Y.jsxs)(W,{open:f!==null,onClose:()=>p(null),title:f?`Revoke ${f.name}?`:`Revoke device`,confirmLabel:`Revoke device`,busy:m,error:_,onConfirm:C,children:[(0,Y.jsx)(`p`,{className:`text-sm`,children:`Its credential stops working immediately and its push subscription is removed. To use it again, sign in on it again.`}),f?.id===n&&(0,Y.jsx)(`p`,{className:`text-sm font-medium text-danger`,children:`This is the device you are using now. Revoking it signs you out here.`})]})]})}function un(){let e=Ze(e=>e.sendWithEnter),t=Ze(e=>e.set),n=We(),r=He();Ke(e=>e.me);let i=je(),a=L(e=>i?e.devices[i]:void 0);return(0,Y.jsxs)(Z,{title:`This device`,description:`These preferences are stored in this browser only; your other devices keep their own.`,children:[(0,Y.jsx)(B,{title:`Composer`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(nt,{label:`Send with Enter`,description:`On desktop, Enter sends the message and Shift+Enter inserts a newline. When off, Enter inserts a newline; send with the Send button.`,checked:e,onChange:e=>t(`sendWithEnter`,e)}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On mobile, Return always inserts a newline and messages are sent with the Send button.`,n===`mobile`||r?` That applies on this device now.`:``]})]})}),(0,Y.jsx)(B,{title:`Identity`,children:(0,Y.jsx)(It,{items:[[`Name`,a?.name??`Unknown`],[`Kind`,a?on[a.kind]:`Unknown`],[`Device ID`,(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:i??`Unknown`},`id`)]]})})]})}var $=e=>e==null||e===``?`Unknown`:String(e);function dn(){let e=tt($t,Qt),t=e.data,n=Yt(Array.isArray(t?.diagnostics)?t.diagnostics:void 0),r=L(e=>e.hosts),i=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{icon:(0,Y.jsx)(ue,{className:`size-4`}),disabled:!t,onClick:()=>t&&le(JSON.stringify(t,null,2),`Diagnostics JSON copied`),children:`Copy diagnostics JSON`}),(0,Y.jsx)(x,{busy:e.loading&&!!t,icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:e.reload,children:`Refresh`})]}),a;if(e.fatal)a=(0,Y.jsx)(j,{error:e.error,diagnosticsHref:`/settings/diagnostics`});else if(e.error&&!e.loading&&!t)a=(0,Y.jsx)(O,{title:`Could not load diagnostics`,error:e.error,onRetry:e.reload});else if(!t)a=(0,Y.jsx)(b,{label:`Loading diagnostics…`});else{let i=t.migrationLevel!==void 0&&t.latestMigration!==void 0&&t.migrationLevel>=t.latestMigration,o=(t.hosts??[]).filter(e=>!e.revokedAt);a=(0,Y.jsxs)(Y.Fragment,{children:[e.error&&!e.loading?(0,Y.jsx)(O,{compact:!0,title:`Refresh failed`,error:e.error,onRetry:e.reload}):null,(0,Y.jsx)(B,{title:`Versions`,children:(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-0 text-left text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-border text-muted`,children:[(0,Y.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Component`}),(0,Y.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:`Version`})]})}),(0,Y.jsxs)(`tbody`,{children:[Object.entries(t.versions).map(([e,t])=>(0,Y.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,Y.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal capitalize`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 font-mono break-all`,children:$(t)})]},e)),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal`,children:`Supported Pi`}),(0,Y.jsx)(`td`,{className:`py-1 font-mono`,children:m})]})]})]})})}),(0,Y.jsx)(B,{title:`Coordinator`,children:(0,Y.jsx)(It,{items:[[`Database migration`,(0,Y.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{children:[`Level `,$(t.migrationLevel),` of `,$(t.latestMigration)]}),i?(0,Y.jsx)(V,{icon:H,tone:`success`,label:`Up to date`}):(0,Y.jsx)(V,{icon:F,tone:`warning`,label:`Behind latest`})]},`m`)],[`Public URL`,(0,Y.jsx)(`span`,{className:`break-all`,children:$(t.publicUrl)},`u`)],[`Events`,t.events?`Seq ${$(t.events.minSeq)} to ${$(t.events.maxSeq)} stored (current ${$(t.events.currentSeq)}, oldest retained ${$(t.events.minRetainedSeq)})`:`Unknown`],[`Event retention`,t.events?.retentionDays==null?`Unknown`:`${t.events.retentionDays} days`],[`Push`,t.push?`${t.push.vapidConfigured?`VAPID keys configured`:`VAPID keys not configured`}, ${$(t.push.subscriptions)} subscription(s)`:`Unknown`],[`Connected clients`,`${$(t.clients?.connectedDevices)} device(s)`]]})}),(0,Y.jsx)(B,{title:`Hosts`,children:o.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No hosts enrolled.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:o.map(e=>{let t=r[e.id];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Y.jsx)(Fe,{kind:`host`,value:t?.connectivity??e.connectivity}),(0,Y.jsx)(Rt,{host:e})]}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Agent `,$(e.agentVersion),` · Last seen `,T(e.lastSeenAt)]}),e.unsupported&&e.unsupported.length>0&&(0,Y.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-muted`,children:e.unsupported.map(e=>(0,Y.jsxs)(`li`,{className:`break-words`,children:[e.capability,`: `,e.reason]},e.capability))})]},e.id)})})}),(0,Y.jsx)(B,{title:`Recent diagnostics`,children:n.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics recorded.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:n.slice(0,100).map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Y.jsx)(Jt,{level:e.level}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.message,e.adapterId&&(0,Y.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Adapter `,e.adapterId]})]}),(0,Y.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:w(e.at)})]},`${e.at}-${t}`))})})]})}return(0,Y.jsxs)(Z,{title:`Diagnostics`,description:`Versions, database state, hosts and recent problems. Copy the JSON when reporting a problem.`,actions:i,children:[(0,Y.jsx)(N,{}),a]})}function fn(e){return I(`/api/enrollments`,{kind:e})}function pn({expiresAt:e,onRenew:t,busy:n}){let r=Ht(e);return r!==null&&r<=0?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,role:`status`,children:[(0,Y.jsx)(F,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:`Expired: create a new link`}),(0,Y.jsx)(x,{size:`sm`,busy:n,icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:t,children:`Create new link`})]}):(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(Ie,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Y.jsxs)(`span`,{children:[`Expires in`,` `,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:r===null?`unknown`:Ut(r)}),`. Single use.`]})]})}function mn({busy:e,error:t,onRetry:n}){return e?(0,Y.jsx)(b,{label:`Creating a single-use link…`}):t?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(_,{error:t}),(0,Y.jsx)(x,{icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:n,children:`Retry`})]}):null}function hn(e){let t=Vt(e),n=t.find(e=>!M(e));return n?{folders:t,problem:`"${n}" is not an absolute path or a ~/ path.`}:t.length>20?{folders:t,problem:`Use at most 20 folders.`}:{folders:t,problem:null}}function gn(e,t=Date.now()){return e?e.state===`running`?`Scanning…`:e.state===`failed`?`Last scan failed ${T(e.finishedAt??e.startedAt,t)}: ${e.errors.at(-1)??`unknown error`}`:`Last scanned ${T(e.finishedAt,t)}: ${e.repositories} repositories, ${e.checkoutsAdded} new checkouts, ${e.projectsCreated} new projects.`:`Not scanned yet.`}function _n({host:e}){let t=(0,J.useId)(),n=(e.projectFolders??[]).join(`
|
|
3
|
-
`),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),d=r??n,f=r!==null&&r!==n,{folders:p,problem:m}=hn(d),h=e.projectScan,v=s||h?.state===`running`,y=e.connectivity===`connected`,b=n?y?v?`A scan is running`:null:`${e.name} is offline`:`Save a folder first`,S=async()=>{o(!0),u(null);try{await g(`/api/hosts/${encodeURIComponent(e.id)}`,{projectFolders:p}),U.success(`Project folders saved`),i(null)}catch(e){u(e)}finally{o(!1)}},C=async()=>{c(!0),u(null);try{let t=await I(`/api/hosts/${encodeURIComponent(e.id)}/scan-projects`);U.success(`Found ${t.repositories} repositories; ${t.projectsCreated} new projects`)}catch(e){u(e)}finally{c(!1)}},w=f?m:null;return(0,Y.jsx)(B,{title:`Project folders`,description:`Every Git repository directly inside these folders becomes a project, or another checkout of the project with the same remote. Folders are rescanned when the host connects and every 10 minutes; nothing is removed automatically.`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(z,{id:`${t}-folders`,label:`Folders on this host`,hint:`One per line: an absolute path or ~/..., e.g. ~/Projects.`,error:w,children:(0,Y.jsx)($e,{id:`${t}-folders`,value:d,onChange:e=>i(e.target.value),minRows:3,placeholder:`~/Projects`,className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,...R(`${t}-folders`,{hint:!0,error:w})})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(Ee,{className:`size-4`}),busy:a,disabled:!f||!!m,onClick:S,children:`Save folders`}),(0,Y.jsx)(x,{icon:(0,Y.jsx)(_t,{className:`size-4`}),busy:s,disabled:!!b,title:b??void 0,onClick:C,children:`Scan now`})]}),(0,Y.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-muted`,children:s?`Scanning…`:gn(h)}),h&&h.state!==`running`&&h.errors.length>0&&(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-0.5 text-xs text-muted`,children:h.errors.map(e=>(0,Y.jsx)(`li`,{className:`break-words`,children:e},e))}),(0,Y.jsx)(_,{error:l})]})})}var vn={prompt:`Prompt`,steer:`Steer a running turn`,followUp:`Queue follow-up`,abort:`Abort`,resume:`Resume`,rename:`Rename session`,importInactive:`Import inactive sessions`,extensionDialogs:`Extension dialogs`,customUi:`Custom extension UI`,widgetsText:`Text widgets`,widgetsComponent:`Component widgets`,tokenAccounting:`Token accounting`,costAccounting:`Cost accounting`};function yn(){let e=Q(),t=d(),[n,r]=(0,J.useState)(!1),i=t.filter(e=>e.connectivity!==`connected`);return(0,Y.jsxs)(Z,{testId:`settings-hosts`,title:`Hosts`,description:`Machines that run Pi sessions through the Switchyard host agent.`,actions:(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(Se,{className:`size-4`}),onClick:()=>r(!0),children:`Add host`}),children:[(0,Y.jsx)(N,{}),e?t.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(ke,{className:`size-8`}),title:`No hosts yet`,description:`Add a host to run Pi sessions. You will get a command to run on that machine.`,action:{label:`Add host`,onClick:()=>r(!0)}}):(0,Y.jsxs)(Y.Fragment,{children:[i.length===1&&(0,Y.jsx)(D,{compact:!0,hostName:i[0].name,connectivity:i[0].connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i[0].lastSeenAt}),i.length>1&&(0,Y.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Y.jsx)(ae,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:bn(i.map(e=>e.name))}),(0,Y.jsx)(`div`,{className:`text-muted`,children:`Work on them keeps its last known state; nothing is restarted elsewhere.`})]})]}),(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,Y.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Y.jsx)(xn,{host:e})},e.id))})]}):(0,Y.jsx)(b,{label:`Loading hosts…`}),(0,Y.jsx)(wn,{open:n,onClose:()=>r(!1)})]})}function bn(e){return`${e.length} hosts are not connected: ${e.join(`, `)}`}function xn({host:e}){return(0,Y.jsxs)(r,{to:X(`hosts/${encodeURIComponent(e.id)}`),state:Te,className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,Y.jsx)(ke,{"aria-hidden":!0,className:`size-5 shrink-0 self-center text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`text-sm text-muted`,children:Lt[e.platform]})]}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Fe,{kind:`host`,value:e.connectivity}),(0,Y.jsx)(Rt,{host:e}),e.connectivity!==`connected`&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Last seen `,T(e.lastSeenAt)]})]})]}),(0,Y.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 self-center text-subtle`})]})}var Sn=`@spencerboucher/switchyard`;function Cn(e){return[`npm install -g ${Sn}`,e,`switchyard host install-service`].join(`
|
|
4
|
-
`)}function wn({open:e,onClose:t}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(null),c=async()=>{a(!0),s(null);try{r(await fn(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,Y.jsx)(Qe,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,Y.jsx)(x,{onClick:l,children:`Done`}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm`,children:`Create a single-use enrollment, then run the command it shows on the new host. The host appears here once its agent connects.`}),(0,Y.jsx)(x,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,Y.jsx)(mn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm`,children:`Run this on the host, as the user that should run Pi (it needs Node 24 or newer, git and Pi):`}),(0,Y.jsx)(de,{text:n.command?Cn(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,Y.jsx)(pn,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function Tn(){let{hostId:e=``}=c(),t=Q(),r=L(t=>t.hosts[e]),i=L(t=>t.adapters[e]),a=L(e=>e.checkouts),o=L(e=>e.projects),s=n(),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null),h=(0,J.useMemo)(()=>Object.values(a).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[a,e]),g={to:X(`hosts`),label:`Hosts`};if(!t)return(0,Y.jsx)(Z,{title:`Host`,back:g,children:(0,Y.jsx)(b,{label:`Loading host…`})});if(!r||r.revokedAt)return(0,Y.jsx)(Z,{title:`Host`,back:g,children:(0,Y.jsx)(P,{icon:(0,Y.jsx)(ke,{className:`size-8`}),title:r?`This host was revoked`:`Host not found`,description:r?`${r.name} was revoked ${T(r.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:X(`hosts`)}})});let _=async()=>{f(!0),m(null);try{await I(`/api/hosts/${encodeURIComponent(r.id)}/revoke`),U.success(`Host ${r.name} revoked`),u(!1),s(X(`hosts`))}catch(e){m(e)}finally{f(!1)}},y=r.capabilities,S=e=>y?.unsupported.find(t=>t.capability===e)?.reason,C=y?.unsupported.filter(e=>!v.includes(e.capability))??[];return(0,Y.jsxs)(Z,{title:r.name,description:`${Lt[r.platform]} host`,back:g,children:[(0,Y.jsx)(N,{}),r.connectivity!==`connected`&&(0,Y.jsx)(D,{compact:!0,hostName:r.name,connectivity:r.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:r.lastSeenAt}),(0,Y.jsx)(B,{title:`Connectivity and versions`,children:(0,Y.jsx)(It,{items:[[`Status`,(0,Y.jsx)(Fe,{kind:`host`,value:r.connectivity},`s`)],[`Last seen`,r.lastSeenAt?`${T(r.lastSeenAt)} (${w(r.lastSeenAt)})`:`Never`],[`Platform`,Lt[r.platform]],[`Agent version`,(0,Y.jsx)(`span`,{className:`font-mono`,children:r.agentVersion},`a`)],[`Pi`,(0,Y.jsx)(Rt,{host:r},`p`)],[`Enrolled`,w(r.createdAt)]]})}),(0,Y.jsx)(B,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:y?(0,Y.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[v.map(e=>{let t=y[e],n=S(e);return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,Y.jsx)(H,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,Y.jsx)(Ne,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:vn[e]}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,Y.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),C.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,Y.jsx)(Ne,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,Y.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,Y.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,Y.jsx)(ne,{capability:`Capability report`,reason:`This host has not reported its Pi capabilities yet. It may be offline, or Pi may be missing or incompatible.`})}),(0,Y.jsx)(_n,{host:r}),(0,Y.jsx)(B,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:h.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No checkouts on this host`,description:`Create a project or add a checkout to an existing project.`,action:{label:`Open projects`,to:X(`projects`)}}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:h.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Y.jsx)(et,{to:X(`projects/${encodeURIComponent(e.projectId)}`),variant:`action`,children:o[e.projectId]?.name??`Unknown project`}),(0,Y.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,Y.jsx)(B,{title:`Adapters`,actions:(0,Y.jsx)(et,{to:X(`adapters`),size:`sm`,variant:`action`,children:`All adapters`}),children:!i||i.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:i.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,Y.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,Y.jsx)(Gt,{status:e.status})]},e.id))})}),(0,Y.jsx)(De,{description:`Revoking disconnects the host agent and invalidates its credential. Sessions on it are not moved elsewhere.`,children:(0,Y.jsx)(x,{variant:`danger`,icon:(0,Y.jsx)(Dt,{className:`size-4`}),onClick:()=>{m(null),u(!0)},children:`Revoke host`})}),(0,Y.jsx)(W,{open:l,onClose:()=>u(!1),title:`Revoke ${r.name}?`,confirmLabel:`Revoke host`,busy:d,error:p,onConfirm:_,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:`The host agent is disconnected and its credential stops working. Sessions on it are not moved or restarted elsewhere. To use this machine again, add it as a new host.`})})]})}var En={granted:{icon:dt,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:lt,label:`Blocked`,tone:`danger`,guidance:`Notifications are blocked for this site. Allow them in your browser's site settings (or the system notification settings for the Home Screen app), then reload.`},default:{icon:ze,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:ze,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:Ne,label:`Not supported`,tone:`warning`,guidance:`This browser cannot receive web push here. On iPhone and iPad, add Switchyard to the Home Screen first.`}};function Dn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function On(e){let t=K(e)&&K(e.settings)?e.settings:e;return!K(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:K(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function kn(){let[e,t]=(0,J.useState)(()=>Ue()),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),c=Ge()&&!Je();(0,J.useEffect)(()=>{let e=!0;Xe().then(t=>e&&r(t!==null)).catch(()=>e&&r(!1));let n=()=>{document.visibilityState===`visible`&&t(Ue())};return document.addEventListener(`visibilitychange`,n),()=>{e=!1,document.removeEventListener(`visibilitychange`,n)}},[]);let l=()=>{a(`enable`),s(null),qe().then(e=>{t(e),e===`granted`?(r(!0),U.success(`Notifications enabled on this device`)):e===`denied`&&U.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{s(e),t(Ue())}).finally(()=>a(null))},u=async()=>{a(`disable`),s(null);try{await Ye(),r(!1),U.success(`Notifications disabled on this device`)}catch(e){s(e)}finally{a(null)}},d=async()=>{a(`test`),s(null);try{await Be(),U.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(e){s(e),U.error(`Test notification failed: ${oe(e)}`)}finally{a(null)}},f=En[e]??En.unknown;return(0,Y.jsxs)(Z,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,Y.jsx)(B,{title:`This device`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,Y.jsx)(V,{icon:f.icon,label:f.label,tone:f.tone}),n!==null&&e===`granted`&&(0,Y.jsx)(`span`,{className:`text-muted`,children:n?`Subscribed to push`:`Not subscribed to push`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:f.guidance}),c&&(0,Y.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,Y.jsx)(kt,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,Y.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,Y.jsx)(`li`,{children:`Tap Share`}),(0,Y.jsx)(`li`,{children:`Add to Home Screen`}),(0,Y.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,Y.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e!==`unsupported`&&!(e===`granted`&&n)&&(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(dt,{className:`size-4`}),busy:i===`enable`,disabled:i!==null&&i!==`enable`,onClick:l,children:`Enable notifications`}),n&&(0,Y.jsx)(x,{icon:(0,Y.jsx)(lt,{className:`size-4`}),busy:i===`disable`,disabled:i!==null&&i!==`disable`,onClick:u,children:`Disable on this device`}),(0,Y.jsx)(x,{icon:(0,Y.jsx)(pe,{className:`size-4`}),busy:i===`test`,disabled:i!==null&&i!==`test`,onClick:d,children:`Send test notification`})]}),e===`unsupported`&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Enabling is not possible in this browser. A test notification still goes to your other subscribed devices.`}),(0,Y.jsx)(_,{error:o}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Delivery and clearing are best effort: browsers and operating systems may delay, group or keep notifications even after you answer elsewhere.`})]})}),(0,Y.jsx)(An,{})]})}function An(){let e=tt(`/api/me/notification-settings`,e=>!!On(e)),t=(0,J.useMemo)(()=>e.data?On(e.data):null,[e.data]),n=e.error instanceof A&&e.error.status===404;return(0,Y.jsx)(B,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,Y.jsx)(ne,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,Y.jsx)(j,{error:e.error}):e.error&&!e.loading&&!t?(0,Y.jsx)(O,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,Y.jsx)(Mn,{settings:t,onSaved:t=>e.setData(t)}):(0,Y.jsx)(b,{label:`Loading notification settings…`})})}var jn=/^\d{2}:\d{2}$/;function Mn({settings:e,onSaved:t}){let n=(0,J.useId)(),r=L(e=>e.devices),i=(0,J.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,J.useState)(e.quietHours!==null),[s,c]=(0,J.useState)(e.quietHours?.start??`22:00`),[l,u]=(0,J.useState)(e.quietHours?.end??`07:00`),[d,f]=(0,J.useState)(e.quietHours?.timezone??Dn()),[p,m]=(0,J.useState)(e.privatePreviews),[h,v]=(0,J.useState)(e.preferredDeviceId??``),[y,b]=(0,J.useState)(!1),[S,C]=(0,J.useState)(null),w=a&&!jn.test(s)?`Use a time like 22:00.`:null,T=a&&!jn.test(l)?`Use a time like 07:00.`:null,E=a&&!d.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,D=!h||i.some(e=>e.id===h);return(0,Y.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:async e=>{if(e.preventDefault(),w||T||E)return;let n={quietHours:a?{start:s,end:l,timezone:d.trim()}:null,privatePreviews:p,preferredDeviceId:h||null};b(!0),C(null);try{t(On(await g(`/api/me/notification-settings`,n))??n),U.success(`Notification preferences saved`)}catch(e){C(e)}finally{b(!1)}},noValidate:!0,children:[(0,Y.jsx)(nt,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,Y.jsx)(z,{id:`${n}-start`,label:`From`,error:w,children:(0,Y.jsx)(G,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...R(`${n}-start`,{error:w})})}),(0,Y.jsx)(z,{id:`${n}-end`,label:`Until`,error:T,children:(0,Y.jsx)(G,{id:`${n}-end`,type:`time`,value:l,onChange:e=>u(e.target.value),...R(`${n}-end`,{error:T})})}),(0,Y.jsx)(z,{id:`${n}-tz`,label:`Time zone`,error:E,children:(0,Y.jsx)(G,{id:`${n}-tz`,value:d,onChange:e=>f(e.target.value),autoCapitalize:`off`,spellCheck:!1,...R(`${n}-tz`,{error:E})})})]}),(0,Y.jsx)(nt,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:p,onChange:m}),(0,Y.jsx)(z,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,Y.jsxs)(q,{id:`${n}-device`,value:h,onChange:e=>v(e.target.value),...R(`${n}-device`,{hint:!0}),children:[(0,Y.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!D&&(0,Y.jsxs)(`option`,{value:h,children:[`Unknown device (`,h,`)`]})]})}),(0,Y.jsx)(_,{error:S}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(x,{type:`submit`,variant:`primary`,busy:y,icon:(0,Y.jsx)(Ee,{className:`size-4`}),children:`Save preferences`})})]})}var Nn={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},Pn={ask:`Ask before trusting project-local Pi settings and extensions.`,approve:`Trust project-local Pi settings and extensions automatically.`,ignore:`Never load project-local Pi settings or extensions.`},Fn=re.options,In={all:`Loads your extensions, skills and prompt templates.`,vanilla:`Starts Pi with --no-extensions --no-skills --no-prompt-templates (also no built-in MCP). Your logins, default model and AGENTS.md still apply, and Switchyard's model, effort, context and command controls keep working.`};function Ln(e){let t=[];return e.forEach((e,n)=>{let r=te.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function Rn(){let e=Q(),t=L(e=>e.profiles),n=L(e=>e.projects),r=(0,J.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),f=async()=>{if(o){l(!0),d(null);try{await E(`/api/profiles/${encodeURIComponent(o.id)}`),U.success(`Profile ${o.name} deleted`),s(null)}catch(e){d(e)}finally{l(!1)}}},p=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,Y.jsxs)(Z,{title:`Pi profiles`,description:`Presets for provider, model, thinking level and Pi flags. Sessions keep a snapshot of the profile they started with.`,actions:(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(Se,{className:`size-4`}),onClick:()=>a(`new`),children:`New profile`}),children:[(0,Y.jsx)(N,{}),e?r.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(ge,{className:`size-8`}),title:`No profiles`,description:`Create a profile to choose a provider and model for sessions.`,action:{label:`New profile`,onClick:()=>a(`new`)}}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=p(e.id);return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,Y.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Y.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,Nn[e.projectTrust],e.resources===`vanilla`&&` · Vanilla Pi`]}),e.extraArgs.length>0&&(0,Y.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(be,{className:`size-4`}),onClick:()=>a(e),children:`Edit`}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(ce,{className:`size-4`}),onClick:()=>{d(null),s(e)},children:`Delete`})]})]},e.id)})}):(0,Y.jsx)(b,{label:`Loading profiles…`}),i&&(0,Y.jsx)(zn,{profile:i===`new`?null:i,onClose:()=>a(null)},i===`new`?`new`:i.id),(0,Y.jsx)(W,{open:o!==null,onClose:()=>s(null),title:o?`Delete ${o.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:c,error:u,onConfirm:f,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:`Existing sessions keep their snapshot of this profile. Projects that use it as their default must be changed first.`})})]})}function zn({profile:e,onClose:t}){let n=(0,J.useId)(),[r,i]=(0,J.useState)(e?.name??``),[a,o]=(0,J.useState)(e?.provider??``),[s,c]=(0,J.useState)(e?.model??``),[l,u]=(0,J.useState)(e?.thinking??``),[d,f]=(0,J.useState)(e?.projectTrust??`ask`),[p,m]=(0,J.useState)(e?.resources??`all`),[h,v]=(0,J.useState)((e?.extraArgs??[]).join(`
|
|
5
|
-
`)),[y,b]=(0,J.useState)(!1),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(null),E=Vt(h),D=Ln(E),O=y&&!r.trim()?`Enter a profile name.`:null,ee=D.length?D.join(`
|
|
6
|
-
`):null,k=async n=>{if(n.preventDefault(),b(!0),!r.trim()||D.length)return;let i={name:r.trim(),provider:a.trim()||null,model:s.trim()||null,thinking:l||null,projectTrust:d,resources:p,extraArgs:E};C(!0),T(null);try{e?(await g(`/api/profiles/${encodeURIComponent(e.id)}`,i),U.success(`Profile ${i.name} saved`)):(await I(`/api/profiles`,i),U.success(`Profile ${i.name} created`)),t()}catch(e){T(e)}finally{C(!1)}},A=`${n}-form`;return(0,Y.jsx)(Qe,{open:!0,onClose:S?()=>void 0:t,dismissOnBackdrop:!S,title:e?`Edit ${e.name}`:`New profile`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{onClick:t,disabled:S,children:`Cancel`}),(0,Y.jsx)(x,{type:`submit`,form:A,variant:`primary`,busy:S,children:e?`Save profile`:`Create profile`})]}),children:(0,Y.jsxs)(`form`,{id:A,className:`flex min-w-0 flex-col gap-4`,onSubmit:k,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${n}-name`,label:`Name`,error:O,children:(0,Y.jsx)(G,{id:`${n}-name`,value:r,onChange:e=>i(e.target.value),...R(`${n}-name`,{error:O})})}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(z,{id:`${n}-provider`,label:`Provider`,hint:`Empty uses Pi's default.`,children:(0,Y.jsx)(G,{id:`${n}-provider`,value:a,onChange:e=>o(e.target.value),placeholder:`anthropic`,autoCapitalize:`off`,spellCheck:!1,...R(`${n}-provider`,{hint:!0})})}),(0,Y.jsx)(z,{id:`${n}-model`,label:`Model`,hint:`Empty uses Pi's default.`,children:(0,Y.jsx)(G,{id:`${n}-model`,value:s,onChange:e=>c(e.target.value),autoCapitalize:`off`,spellCheck:!1,...R(`${n}-model`,{hint:!0})})})]}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(z,{id:`${n}-thinking`,label:`Thinking`,children:(0,Y.jsxs)(q,{id:`${n}-thinking`,value:l,onChange:e=>u(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`Default (none)`}),Fn.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]})}),(0,Y.jsx)(z,{id:`${n}-trust`,label:`Project trust`,hint:Pn[d],children:(0,Y.jsx)(q,{id:`${n}-trust`,value:d,onChange:e=>f(e.target.value),...R(`${n}-trust`,{hint:!0}),children:Object.keys(Nn).map(e=>(0,Y.jsx)(`option`,{value:e,children:Nn[e]},e))})})]}),(0,Y.jsx)(z,{id:`${n}-resources`,label:`Resources`,hint:In[p],children:(0,Y.jsxs)(q,{id:`${n}-resources`,value:p,onChange:e=>m(e.target.value),...R(`${n}-resources`,{hint:!0}),children:[(0,Y.jsx)(`option`,{value:`all`,children:`Your Pi setup`}),(0,Y.jsx)(`option`,{value:`vanilla`,children:`Vanilla Pi`})]})}),(0,Y.jsx)(z,{id:`${n}-extra`,label:`Extra Pi arguments`,hint:`One long flag per line, e.g. --max-turns=40. Session, mode and extension flags are managed by Switchyard.`,error:ee,children:(0,Y.jsx)($e,{id:`${n}-extra`,value:h,minRows:3,onChange:e=>v(e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1,...R(`${n}-extra`,{hint:!0,error:ee})})}),(0,Y.jsx)(_,{error:w})]})})}var Bn={managed:`Managed by Switchyard`,discovered:`Discovered worktree`,main:`Main checkout`},Vn={none:{icon:Re,label:`No setup`,tone:`neutral`},running:{icon:Pe,label:`Setup running`,tone:`info`},succeeded:{icon:H,label:`Setup succeeded`,tone:`success`},failed:{icon:Le,label:`Setup failed`,tone:`danger`}};function Hn(e){let t=[e.dirty?`Uncommitted changes (${e.changedFiles} file${e.changedFiles===1?``:`s`})`:`Clean`];return(e.ahead||e.behind)&&t.push(`${e.ahead} ahead, ${e.behind} behind`),t.push(e.unmerged?`Not merged into base`:`Merged`),t.join(` · `)}function Un({project:e}){let t=L(e=>e.workspaces),n=L(e=>e.hosts),r=(0,J.useMemo)(()=>Object.values(t).filter(t=>t.projectId===e.id&&t.archivedAt===null).sort((e,t)=>Number(t.provenance===`main`)-Number(e.provenance===`main`)||(e.branch??``).localeCompare(t.branch??``)),[t,e.id]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),c=async e=>{s(e.id);try{await I(`/api/workspaces/${encodeURIComponent(e.id)}/refresh`),U.success(`Workspace status refreshed`)}catch(e){U.error(`Could not refresh: ${oe(e)}`)}finally{s(null)}};return(0,Y.jsxs)(B,{title:`Workspaces`,description:`Worktrees where sessions and runs work. Removing one never deletes its branch.`,children:[r.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No workspaces`,description:`Workspaces appear after a checkout is discovered. Use Refresh to discover them again.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:r.map(e=>{let t=n[e.hostId],r=t?.connectivity!==`connected`,i=Vn[e.setup.state]??Vn.none;return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(ye,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`min-w-0 break-all font-mono font-medium`,children:e.branch??`(detached HEAD)`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:Bn[e.provenance]})]}),(0,Y.jsxs)(`div`,{className:`break-all font-mono text-xs text-muted`,children:[t?.name?`${t.name}: `:``,e.path]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:Hn(e.git)}),(0,Y.jsx)(V,{icon:i.icon,label:i.label,tone:i.tone,spin:e.setup.state===`running`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(ie,{className:`size-4`}),busy:o===e.id,disabled:r,onClick:()=>c(e),children:`Refresh status`}),e.provenance!==`main`&&(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(ce,{className:`size-4`}),disabled:r,onClick:()=>a(e),children:`Remove`}),e.provenance===`main`&&(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:`The main checkout cannot be removed; remove the project's checkout instead.`}),r&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Host `,t?.name??`unknown`,` is `,t?.connectivity??`unknown`,`: refresh and removal need it online.`]})]})]},e.id)})}),i&&(0,Y.jsx)(Wn,{workspace:t[i.id]??i,onClose:()=>a(null)},i.id)]})}function Wn({workspace:e,onClose:t}){let[n,r]=(0,J.useState)(e.git.dirty),[i,a]=(0,J.useState)(e.git.unmerged),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=n&&!o||i&&!c;return(0,Y.jsxs)(W,{open:!0,onClose:t,title:`Remove workspace?`,description:(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.branch??e.path}),confirmLabel:`Remove workspace`,busy:u,error:f,onConfirm:async()=>{d(!0),p(null);try{await I(`/api/workspaces/${encodeURIComponent(e.id)}/remove`,{force:{dirty:o,unmerged:c}}),U.success(`Workspace ${e.branch??e.path} removed`),t()}catch(e){y(e,`workspace_dirty`)&&r(!0),y(e,`workspace_unmerged`)&&a(!0),p(e)}finally{d(!1)}},confirmDisabled:m,disabledReason:`Check the boxes above to confirm what will be lost.`,children:[(0,Y.jsxs)(`p`,{className:`text-sm`,children:[`The worktree at `,(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.path}),` is deleted from the host. The branch is kept.`]}),n&&(0,Y.jsx)(rt,{label:`Discard uncommitted changes`,description:e.git.dirty?`${e.git.changedFiles} changed file${e.git.changedFiles===1?``:`s`} will be lost.`:`The host reported uncommitted changes; they will be lost.`,checked:o,onChange:s}),i&&(0,Y.jsx)(rt,{label:`Remove although the branch is not merged`,description:`Commits stay on the branch, but the workspace is gone.`,checked:c,onChange:l})]})}var Gn=`Inside the repository, for example .worktrees or .git/worktrees-switchyard`;function Kn(e){let t=e.trim();return t?t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.includes(`\\`)?`Use a relative path inside the repository, e.g. .worktrees.`:t.split(`/`).includes(`..`)?`The folder must stay inside the repository (no ..).`:S.safeParse(t).success?null:`Use a plain relative path such as .worktrees (no empty or . segments).`:`Enter a folder inside the repository, e.g. .worktrees.`}function qn(){let{projectId:e=``}=c(),t=Q(),n=L(t=>t.projects[e]),r=L(e=>e.hosts),i=L(e=>e.profiles),[a,o]=(0,J.useState)(!1),[s,l]=(0,J.useState)([]),u=d(),f=(0,J.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),p={to:X(`projects`),label:`Projects`};return t?n?(0,Y.jsxs)(Z,{title:n.name,description:(0,Y.jsx)(`span`,{className:`break-all`,title:n.repoIdentity,children:me(n.repoIdentity)}),back:p,actions:(0,Y.jsx)(x,{busy:a,icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:async()=>{o(!0);try{let e=await I(`/api/projects/${encodeURIComponent(n.id)}/refresh`),t=Array.isArray(e?.errors)?e.errors:[];l(t),t.length?U.error(`Refreshed with ${t.length} checkout error(s)`):U.success(`Workspaces refreshed`)}catch(e){U.error(`Refresh failed: ${oe(e)}`)}finally{o(!1)}},children:`Refresh`}),children:[(0,Y.jsx)(N,{}),s&&s.length>0&&(0,Y.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:`Some checkouts could not be refreshed`}),(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:s.map(e=>(0,Y.jsx)(`li`,{className:`break-words`,children:e.message},e.checkoutId))})]}),(0,Y.jsx)(Jn,{project:n,hosts:u,profiles:f},n.id),(0,Y.jsx)(Yn,{project:n,hosts:u,hostsById:r}),(0,Y.jsx)(Un,{project:n})]}):(0,Y.jsx)(Z,{title:`Project`,back:p,children:(0,Y.jsx)(P,{icon:(0,Y.jsx)(fe,{className:`size-8`}),title:`Project not found`,description:`It may have been removed, or this link is from another coordinator.`,action:{label:`Back to projects`,to:X(`projects`)}})}):(0,Y.jsx)(Z,{title:`Project`,back:p,children:(0,Y.jsx)(b,{label:`Loading project…`})})}function Jn({project:e,hosts:t,profiles:n}){let r=(0,J.useId)(),[i,a]=(0,J.useState)(e.name),[o,s]=(0,J.useState)(e.setupCommand??``),[c,l]=(0,J.useState)(e.checks.join(`
|
|
7
|
-
`)),[u,d]=(0,J.useState)(String(e.maxConcurrentRuns)),[f,p]=(0,J.useState)(e.automationEnabled),[m,h]=(0,J.useState)(e.workspaceSharing),[v,y]=(0,J.useState)(e.defaultProfileId??``),[b,S]=(0,J.useState)(e.defaultHostId??``),[C,w]=(0,J.useState)(e.worktreeDir??`.worktrees`),[T,E]=(0,J.useState)(!1),[D,O]=(0,J.useState)(null),k=Number(u),A=i.trim()?null:`Enter a project name.`,j=Number.isInteger(k)&&k>=1&&k<=32?null:`Use a whole number from 1 to 32.`,M=Kn(C),N=async t=>{if(t.preventDefault(),!(A||j||M)){E(!0),O(null);try{await g(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:Vt(c),maxConcurrentRuns:k,automationEnabled:f,workspaceSharing:m,defaultProfileId:v||null,defaultHostId:b||null,worktreeDir:C.trim()}),U.success(`Project settings saved`)}catch(e){O(e)}finally{E(!1)}}},te=!b||t.some(e=>e.id===b),P=!v||n.some(e=>e.id===v);return(0,Y.jsx)(B,{title:`Project settings`,children:(0,Y.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:N,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${r}-name`,label:`Name`,error:A,children:(0,Y.jsx)(G,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...R(`${r}-name`,{error:A})})}),(0,Y.jsx)(z,{id:`${r}-setup`,label:`Setup command`,hint:`Runs in each new workspace before the first session, e.g. pnpm install. Leave empty for none.`,children:(0,Y.jsx)(G,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...R(`${r}-setup`,{hint:!0})})}),(0,Y.jsx)(z,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,Y.jsx)($e,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...R(`${r}-checks`,{hint:!0})})}),(0,Y.jsx)(z,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:j,children:(0,Y.jsx)(G,{id:`${r}-runs`,type:`number`,inputMode:`numeric`,min:1,max:32,step:1,value:u,onChange:e=>d(e.target.value),className:`max-w-32`,...R(`${r}-runs`,{hint:!0,error:j})})}),(0,Y.jsx)(z,{id:`${r}-worktree`,label:`Worktree folder`,hint:Gn,error:M,children:(0,Y.jsx)(G,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:C,onChange:e=>w(e.target.value),placeholder:ee,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...R(`${r}-worktree`,{hint:!0,error:M})})}),(0,Y.jsx)(nt,{label:`Auto-start Ready tasks`,description:`When off, Ready tasks in this project wait instead of starting automatically.`,checked:f,onChange:p}),(0,Y.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace sharing`}),[[`single_writer`,`Single writer`,`Only one run or session writes in a workspace at a time; others wait. Safest.`],[`shared`,`Shared`,`Several sessions may write in the same workspace at once. Their changes can interleave.`]].map(([e,t,n])=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:m===e,onChange:()=>h(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,Y.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:t}),(0,Y.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(z,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,Y.jsxs)(q,{id:`${r}-profile`,value:v,onChange:e=>y(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id)),!P&&(0,Y.jsx)(`option`,{value:v,children:`Removed profile`})]})}),(0,Y.jsx)(z,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,Y.jsxs)(q,{id:`${r}-host`,value:b,onChange:e=>S(e.target.value),...R(`${r}-host`,{hint:!0}),children:[(0,Y.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!te&&(0,Y.jsx)(`option`,{value:b,children:`Removed host`})]})})]}),(0,Y.jsx)(_,{error:D}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(x,{type:`submit`,variant:`primary`,busy:T,icon:(0,Y.jsx)(Ee,{className:`size-4`}),children:`Save project`})})]})})}function Yn({project:e,hosts:t,hostsById:n}){let r=L(e=>e.checkouts),i=(0,J.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,J.useState)(!1);return(0,Y.jsxs)(B,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(Se,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No checkouts`,description:`Add a checkout so sessions and runs have somewhere to work.`,action:{label:`Add checkout`,onClick:()=>o(!0)}}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,Y.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,Y.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,Y.jsx)(Xn,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Xn({open:e,onClose:t,project:n,hosts:r}){let i=(0,J.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),g=o||a[0]?.id||``,v=u||c?zt(c):null,y=()=>{f||(d(!1),h(null),t())},b=async e=>{if(e.preventDefault(),d(!0),g&&!zt(c)){p(!0),h(null);try{await I(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:g,path:c.trim()}),U.success(`Checkout added`),l(``),d(!1),t()}catch(e){h(e)}finally{p(!1)}}},S=`${i}-form`;return(0,Y.jsx)(Qe,{open:e,onClose:y,dismissOnBackdrop:!f,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{onClick:y,disabled:f,children:`Cancel`}),(0,Y.jsx)(x,{type:`submit`,form:S,variant:`primary`,busy:f,disabled:a.length===0,children:`Add checkout`})]}),children:(0,Y.jsxs)(`form`,{id:S,className:`flex min-w-0 flex-col gap-4`,onSubmit:b,noValidate:!0,children:[a.length===0&&(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No host is connected. The checkout is inspected on its host, so the host must be online.`}),(0,Y.jsx)(z,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,Y.jsxs)(q,{id:`${i}-host`,value:g,onChange:e=>s(e.target.value),disabled:a.length===0,...R(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,Y.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Y.jsx)(z,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:v,children:(0,Y.jsx)(G,{id:`${i}-path`,value:c,onChange:e=>l(e.target.value),placeholder:`/Users/me/src/app`,className:`font-mono`,autoCapitalize:`off`,autoComplete:`off`,spellCheck:!1,...R(`${i}-path`,{hint:!0,error:v})})}),(0,Y.jsx)(_,{error:m})]})})}var Zn=e=>X(`projects/${encodeURIComponent(e)}`);function Qn(){let e=Q(),t=f(),[n,i]=(0,J.useState)(``),a=t.filter(e=>_e(e,n)),o=L(e=>e.checkouts),s=L(e=>e.workspaces),c=(0,J.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(o))t(e.projectId).checkouts++;for(let e of Object.values(s))e.archivedAt||t(e.projectId).workspaces++;return e},[o,s]);return(0,Y.jsxs)(Z,{testId:`settings-projects`,title:`Projects`,description:`A project is one repository. It can have checkouts on several hosts. Repositories in a host's project folders are added automatically.`,actions:(0,Y.jsxs)(r,{to:X(`projects/new`),state:Te,className:C(`primary`),children:[(0,Y.jsx)(Se,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,Y.jsx)(N,{}),e?t.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(fe,{className:`size-8`}),title:`No projects yet`,description:`Create a project from a Git checkout on one of your hosts.`,action:{label:`New project`,to:X(`projects/new`)}}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`relative max-w-md`,children:[(0,Y.jsx)(Oe,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,Y.jsx)(G,{type:`search`,"aria-label":`Search projects`,placeholder:`Search projects by name or remote`,value:n,onChange:e=>i(e.target.value),className:`pl-8`})]}),a.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No matches`,description:`No project matches "${n.trim()}".`,action:{label:`Clear search`,onClick:()=>i(``)}}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:a.map(e=>(0,Y.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Y.jsx)($n,{project:e,counts:c[e.id]})},e.id))})]}):(0,Y.jsx)(b,{label:`Loading projects…`})]})}function $n({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,Y.jsxs)(r,{to:Zn(e.id),state:Te,className:`tap flex min-w-0 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Y.jsx)(fe,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`truncate text-xs text-muted`,title:e.repoIdentity,children:me(e.repoIdentity)}),(0,Y.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-subtle`,children:[(0,Y.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,Y.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),!e.automationEnabled&&(0,Y.jsx)(`span`,{children:`Auto-start off`})]})]}),(0,Y.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function er(){let e=Q(),t=d(),r=L(e=>e.profiles),i=(0,J.useMemo)(()=>Object.values(r).sort((e,t)=>e.name.localeCompare(t.name)),[r]),a=t.filter(e=>e.connectivity===`connected`),o=n(),s=(0,J.useId)(),[c,l]=(0,J.useState)(``),[u,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[v,y]=(0,J.useState)(ee),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)(null),O=u||a[0]?.id||``,k=S&&!c.trim()?`Enter a project name.`:null,A=S&&!O?`Choose a connected host.`:null,j=S||p?zt(p):null,M=Kn(v),N=async e=>{if(e.preventDefault(),C(!0),c.trim()&&O&&!zt(p)&&!M){T(!0),D(null);try{let e=await I(`/api/projects`,{name:c.trim(),hostId:O,path:p.trim(),defaultProfileId:h||null,worktreeDir:v.trim()});U.success(`Project ${c.trim()} created`),o(e?.id?Zn(e.id):X(`projects`),{replace:!0})}catch(e){D(e)}finally{T(!1)}}},te={to:X(`projects`),label:`Projects`};return e?(0,Y.jsxs)(Z,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:te,children:[a.length===0&&(0,Y.jsx)(ne,{capability:`Creating a project`,reason:t.length===0?`No hosts are enrolled. Add a host first.`:`No host is connected. The checkout is inspected on its host, so the host must be online.`,fallback:(0,Y.jsx)(et,{to:X(`hosts`),variant:`action`,children:`Open hosts`})}),(0,Y.jsx)(B,{children:(0,Y.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:N,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${s}-name`,label:`Name`,error:k,children:(0,Y.jsx)(G,{id:`${s}-name`,value:c,onChange:e=>l(e.target.value),autoComplete:`off`,...R(`${s}-name`,{error:k})})}),(0,Y.jsx)(z,{id:`${s}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:A,children:(0,Y.jsxs)(q,{id:`${s}-host`,value:O,onChange:e=>f(e.target.value),disabled:a.length===0,...R(`${s}-host`,{hint:!0,error:A}),children:[a.length===0&&(0,Y.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Y.jsx)(z,{id:`${s}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:j,children:(0,Y.jsx)(G,{id:`${s}-path`,value:p,onChange:e=>m(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...R(`${s}-path`,{hint:!0,error:j})})}),(0,Y.jsx)(z,{id:`${s}-worktree`,label:`Worktree folder`,hint:Gn,error:M,children:(0,Y.jsx)(G,{id:`${s}-worktree`,value:v,onChange:e=>y(e.target.value),placeholder:ee,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...R(`${s}-worktree`,{hint:!0,error:M})})}),(0,Y.jsx)(z,{id:`${s}-profile`,label:`Default Pi profile (optional)`,children:(0,Y.jsxs)(q,{id:`${s}-profile`,value:h,onChange:e=>g(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`None`}),i.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Y.jsx)(_,{error:E}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(x,{type:`submit`,variant:`primary`,busy:w,icon:(0,Y.jsx)(ht,{className:`size-4`}),disabled:a.length===0,children:`Create project`}),a.length===0&&(0,Y.jsx)(V,{icon:ht,label:`Needs a connected host`})]})]})})]}):(0,Y.jsx)(Z,{title:`New project`,back:te,children:(0,Y.jsx)(b,{})})}function tr(){let e=tt(`/api/auth/methods`,Bt),[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null),h=async()=>{if(r){o(!0),c(null);try{await E(`/api/auth/passkeys/${encodeURIComponent(r.id)}`),U.success(`Passkey ${r.name} removed`),i(null),e.reload()}catch(e){c(e)}finally{o(!1)}}},g=async()=>{f(!0),m(null);try{await I(`/api/logout`),u(!1),Ve(null)}catch(e){m(e)}finally{f(!1)}},_=e.data,v=_?.passkeyAvailability,y=at(),S=_?v?.available?y?null:`This browser does not support passkeys.`:v?.reason??`Passkeys are not available on this server.`:null;return(0,Y.jsxs)(Z,{testId:`settings-signin`,title:`Sign-in`,description:`How you sign in to Switchyard on new devices. Each signed-in device keeps its own revocable credential.`,children:[(0,Y.jsx)(N,{}),e.loading&&!_?(0,Y.jsx)(b,{label:`Loading sign-in methods…`}):e.error&&!_?(0,Y.jsx)(O,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{title:`Passkeys`,description:`Sign in on any device with its fingerprint, face or screen lock. Passkeys are stored on this server only as public keys.`,actions:(0,Y.jsx)(x,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,Y.jsx)(Se,{className:`size-4`}),disabled:S!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[S&&(0,Y.jsxs)(`p`,{role:`status`,className:`mb-3 flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-sm`,children:[(0,Y.jsx)(F,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,S]})]}),_.passkeys.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No passkeys yet. Add one as a backup to single sign-on, or to sign in without it.`}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:_.passkeys.map(e=>(0,Y.jsxs)(`li`,{"data-testid":`passkey-row`,className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2 last:border-b-0`,children:[(0,Y.jsx)(xe,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,Y.jsxs)(`span`,{children:[`Added `,T(e.createdAt)]}),(0,Y.jsxs)(`span`,{children:[`Last used `,T(e.lastUsedAt)]})]})]}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(ce,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{c(null),i(e)},children:`Remove`})]},e.id))})]}),(0,Y.jsx)(B,{title:`Single sign-on`,description:`Configured on the server`,children:_.oidc?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(It,{items:[[`Button label`,_.oidc.label],[`Provider`,(0,Y.jsx)(`span`,{className:`break-all`,children:_.oidc.issuer},`i`)],[`Allowed account`,_.oidc.ownerMatch],[`Status`,_.oidc.status===`ready`?(0,Y.jsx)(V,{icon:H,tone:`success`,label:`Ready`},`s`):(0,Y.jsx)(V,{icon:F,tone:`danger`,label:`Error`},`s`)]]}),_.oidc.status===`error`&&_.oidc.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:_.oidc.error})]}):(0,Y.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,Y.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,Y.jsx)(B,{title:`This device`,description:`Signing out removes this device's credential here. Other devices stay signed in; revoke a device in Settings › Devices to cut it off.`,children:(0,Y.jsx)(x,{icon:(0,Y.jsx)(Ct,{className:`size-4`}),onClick:()=>{m(null),u(!0)},children:`Sign out of this device`})}),(0,Y.jsx)(nr,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,Y.jsx)(W,{open:r!==null,onClose:()=>i(null),title:r?`Remove passkey ${r.name}?`:`Remove passkey`,confirmLabel:`Remove passkey`,busy:a,error:s,onConfirm:h,children:(0,Y.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,_&&_.passkeys.length===1&&!_.oidc?` It is your only passkey and no single sign-on is set up: afterwards new browsers need switchyard pair run on the server.`:``]})}),(0,Y.jsx)(W,{open:l,onClose:()=>u(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:d,error:p,onConfirm:g,children:(0,Y.jsxs)(`p`,{className:`text-sm`,children:[`You will need single sign-on, a passkey or `,(0,Y.jsx)(`code`,{children:`switchyard pair`}),` on the server to sign in here again.`]})})]})}function nr({open:e,onClose:t,onAdded:n}){let r=(0,J.useId)(),[i,a]=(0,J.useState)(()=>st()),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),u=ot(),d=i.trim()?null:`Enter a name for this passkey.`,f=()=>{if(u.waiting)u.cancel();else if(o)return;l(null),t()},p=async e=>{if(e.preventDefault(),!d){s(!0),l(null);try{let{challengeId:e,options:t}=await I(`/api/auth/passkeys/register/options`),r=await u.run(()=>it({optionsJSON:t}));if(!r.ok){s(!1);return}let a=r.value;await I(`/api/auth/passkeys/register/verify`,{challengeId:e,name:i.trim().slice(0,80),response:a}),U.success(`Passkey added`),n()}catch(e){l(e instanceof Error&&e.name===`NotAllowedError`?Error(`The passkey prompt was canceled or timed out. Try again.`):e instanceof Error?e:Error(oe(e)))}finally{s(!1)}}},m=`${r}-form`;return(0,Y.jsx)(Qe,{open:e,onClose:f,dismissOnBackdrop:!o||u.waiting,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{onClick:f,disabled:o&&!u.waiting,children:`Cancel`}),(0,Y.jsx)(x,{type:`submit`,form:m,variant:`primary`,busy:o,children:`Create passkey`})]}),children:(0,Y.jsxs)(`form`,{id:m,className:`flex min-w-0 flex-col gap-4`,onSubmit:p,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${r}-name`,label:`Passkey name`,error:d,children:(0,Y.jsx)(G,{id:`${r}-name`,value:i,maxLength:80,autoComplete:`off`,onChange:e=>a(e.target.value),...R(`${r}-name`,{error:d})})}),u.waiting&&(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(k,{}),` Waiting for your passkey… Cancel stops it.`]}),(0,Y.jsx)(_,{error:c})]})})}function rr(){let e=We(),n=e===`mobile`,r=(0,Y.jsxs)(i,{children:[(0,Y.jsx)(t,{index:!0,element:n?(0,Y.jsx)(sr,{}):(0,Y.jsx)(s,{to:X(`hosts`),replace:!0})}),(0,Y.jsx)(t,{path:`hosts`,element:(0,Y.jsx)(yn,{})}),(0,Y.jsx)(t,{path:`hosts/:hostId`,element:(0,Y.jsx)(Tn,{})}),(0,Y.jsx)(t,{path:`devices`,element:(0,Y.jsx)(ln,{})}),(0,Y.jsx)(t,{path:`sign-in`,element:(0,Y.jsx)(tr,{})}),(0,Y.jsx)(t,{path:`projects`,element:(0,Y.jsx)(Qn,{})}),(0,Y.jsx)(t,{path:`projects/new`,element:(0,Y.jsx)(er,{})}),(0,Y.jsx)(t,{path:`projects/:projectId`,element:(0,Y.jsx)(qn,{})}),(0,Y.jsx)(t,{path:`profiles`,element:(0,Y.jsx)(Rn,{})}),(0,Y.jsx)(t,{path:`adapters`,element:(0,Y.jsx)(Xt,{})}),(0,Y.jsx)(t,{path:`notifications`,element:(0,Y.jsx)(kn,{})}),(0,Y.jsx)(t,{path:`backups`,element:(0,Y.jsx)(an,{})}),(0,Y.jsx)(t,{path:`diagnostics`,element:(0,Y.jsx)(dn,{})}),(0,Y.jsx)(t,{path:`device`,element:(0,Y.jsx)(un,{})}),(0,Y.jsx)(t,{path:`*`,element:(0,Y.jsx)(cr,{})})]});return n?(0,Y.jsx)(`div`,{className:`min-w-0`,children:r}):(0,Y.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,Y.jsx)(ar,{compact:e===`compact`}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:r})]})}function ir(){let{pathname:e}=u(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function ar({compact:e}){let t=ir();return(0,Y.jsx)(`div`,{className:h(`shrink-0 border-r border-border`,e?`w-52`:`w-60`),children:(0,Y.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,className:`sticky top-0 flex max-h-dvh flex-col gap-1 overflow-y-auto px-2 py-4`,children:[(0,Y.jsx)(`h2`,{className:`mb-1 px-3 py-1 text-base font-semibold`,children:`Settings`}),Ft.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`h3`,{className:`px-3 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:e.label}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sections.map(({path:e,label:n,icon:i})=>{let a=t===e;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{to:X(e),"aria-current":a?`page`:void 0,className:h(`tap flex h-10 items-center gap-3 rounded-md px-3 text-sm font-medium`,a?`bg-accent-soft text-text`:`text-muted hover:bg-surface-2 hover:text-text`),children:[(0,Y.jsx)(i,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})},e)})})]},e.label))]})})}function or(){let e=L(e=>e.hosts),t=L(e=>e.devices),n=L(e=>e.projects),r=L(e=>e.profiles),i=L(e=>e.adapters),a=L(e=>e.hydrated);return(0,J.useMemo)(()=>{if(!a)return{};let o=Object.values(e).filter(e=>e.revokedAt===null),s=o.filter(e=>e.connectivity===`connected`).length,c=Object.values(i).reduce((e,t)=>e+t.length,0),l=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return{hosts:`${l(o.length,`host`)}, ${s} connected`,devices:l(Object.values(t).filter(e=>e.revokedAt===null).length,`device`),projects:l(Object.keys(n).length,`project`),profiles:l(Object.keys(r).length,`profile`),adapters:l(c,`adapter`)}},[e,t,n,r,i,a])}function sr(){let e=or();return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,Y.jsx)(N,{}),(0,Y.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,children:Ft.map(t=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`px-1 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:t.label}),(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.sections.map(({path:t,label:n,description:i,icon:a})=>(0,Y.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Y.jsxs)(r,{to:X(t),state:Te,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Y.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:n}),(0,Y.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??i})]}),(0,Y.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})]},t.label))})]})}function cr(){return(0,Y.jsx)(P,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:X()}})}export{rr as default};
|
|
8
|
-
//# sourceMappingURL=settings-DyUu0tJM.js.map
|