bb-app 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{An as e,At as t,Bn as n,Ft as r,Ki as i,Ot as a,Tt as o,Vi as s,Yr as c,_i as l,ii as u,ni as d,ri as f,t as p,vi as m}from"./page-shell-Dglk9LmR.js";import{c as h,d as g,i as _,n as v,o as y,xt as b}from"./effective-hosts-BWRuszG7.js";import{a as x,g as S,i as C,o as w,r as T,s as E,t as D}from"./dialog-CxN4lDeD.js";import{Bt as O,Rt as k,Vt as A,Xt as j,nn as M,rn as N}from"./index-D_DARDfc.js";import{i as P,n as F,r as I,t as ee}from"./settings-section-CZi6DvBs.js";var L=i(s(),1),R=`size-2 shrink-0 rounded-full ring-1 ring-inset transition-all bg-success ring-success/25 shadow-[0_0_0_4px_color-mix(in_oklch,var(--color-success)_16%,transparent)]`,z=m();function B({target:e,pending:t,onOpenChange:n,onDelete:r}){return(0,z.jsx)(D,{open:e!==null,onOpenChange:n,children:(0,z.jsx)(T,{children:e?(0,z.jsx)(V,{target:e,pending:t,onDelete:r}):null})})}function V({target:e,pending:t,onDelete:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`Remove host?`}),(0,z.jsx)(C,{children:`Remove "${e.name}" and all of its project sources? This cannot be undone.`})]}),(0,z.jsx)(x,{children:(0,z.jsx)(c,{type:`button`,variant:`destructive`,disabled:t,onClick:()=>n(e.id),children:`Remove host`})})]})}function H({target:e,pending:t,onOpenChange:n,onRename:r}){return(0,z.jsx)(D,{open:e!==null,onOpenChange:n,children:(0,z.jsx)(T,{children:e?(0,z.jsx)(U,{target:e,pending:t,onRename:r},e.id):null})})}function U({target:e,pending:t,onRename:n}){let r=(0,L.useId)(),[i,a]=(0,L.useState)(e.currentName),[o,s]=(0,L.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`Rename host`}),(0,z.jsx)(C,{children:`Choose a new name for this host.`})]}),(0,z.jsxs)(`form`,{className:`space-y-4`,onSubmit:r=>{if(r.preventDefault(),t)return;let a=i.trim();if(!a){s(`Host name cannot be empty.`);return}n(e.id,a)},children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(S,{id:r,"aria-label":`Host name`,value:i,autoFocus:!0,disabled:t,onChange:e=>{a(e.target.value),o&&s(null)}}),o?(0,z.jsx)(`p`,{className:`text-sm text-destructive`,children:o}):null]}),(0,z.jsx)(x,{children:(0,z.jsx)(c,{type:`submit`,disabled:t,children:`Rename host`})})]})]})}function W({open:e,onOpenChange:t}){return(0,z.jsx)(D,{open:e,onOpenChange:t,children:(0,z.jsx)(T,{className:`sm:max-w-2xl`,children:(0,z.jsx)(G,{})})})}function G(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`Unable to add new host`}),(0,z.jsx)(C,{children:`You need to specify the URL that allows the new host to talk to the server.`})]}),(0,z.jsxs)(`div`,{className:`min-w-0 space-y-2 text-sm text-foreground`,children:[(0,z.jsx)(`p`,{children:`Run this on the server machine, then restart bb:`}),(0,z.jsx)(`pre`,{className:`min-w-0 overflow-x-auto rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-xs leading-5`,children:(0,z.jsx)(`code`,{children:`npx bb-app config BB_APP_URL http://<your-machine>.<tailnet>.ts.net:38886`})})]})]})}function K(e){return new Date(e).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}function q({host:e,open:t,target:n,onOpenChange:r}){let i=t&&n!==null;return(0,z.jsx)(D,{open:i,onOpenChange:r,children:(0,z.jsx)(T,{className:`sm:max-w-2xl`,children:i&&n?(0,z.jsx)(J,{host:e,target:n}):null})})}function J({host:e,target:t}){let[n,r]=(0,L.useState)(()=>t.expiresAt<=Date.now()),i=e?.status===`connected`,a=!i&&!n,o=i?`Host connected`:n?`Join command expired`:`Waiting for host`;return(0,L.useEffect)(()=>{let e=t.expiresAt-Date.now();if(e<=0){r(!0);return}r(!1);let n=window.setTimeout(()=>r(!0),e);return()=>window.clearTimeout(n)},[t.expiresAt]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`New host`}),(0,z.jsx)(C,{children:`Run this command from the new host.`})]}),(0,z.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,z.jsxs)(`div`,{className:`relative min-w-0 rounded-md border border-border bg-muted/40`,children:[(0,z.jsx)(`pre`,{className:`max-h-56 min-w-0 overflow-y-auto whitespace-pre-wrap break-all px-3 py-2.5 pr-10 text-xs leading-5`,children:(0,z.jsx)(`code`,{children:t.joinCommand})}),(0,z.jsx)(A,{text:t.joinCommand,label:`Copy host command`,className:`absolute right-2 top-2`})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[i?(0,z.jsx)(d,{name:`CircleCheck`,className:`size-4 text-success`,"aria-hidden":`true`}):n?(0,z.jsx)(d,{name:`AlertCircle`,className:`size-4 text-destructive`,"aria-hidden":`true`}):null,(0,z.jsx)(`span`,{className:a?`animate-shine font-medium`:`font-medium text-foreground`,children:o}),a?(0,z.jsxs)(`span`,{children:[`· Expires at `,K(t.expiresAt)]}):null]})]})]})}var Y=[{label:`System`,value:`system`},{label:`Light`,value:`light`},{label:`Dark`,value:`dark`}],X={dark:`Dark`,light:`Light`,system:`System`};function Z(){let i=O(),{data:s=[],isLoading:m}=v(),x=l(),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(null),[E,D]=(0,L.useState)(null),[A,V]=(0,L.useState)(!1),[U,G]=(0,L.useState)(!1),K=u({meta:{errorMessage:`Failed to rename host.`},mutationFn:({id:t,name:n})=>e(t,{name:n}),onSuccess:()=>{M({queryClient:x}),C(null)}}),J=u({meta:{errorMessage:`Failed to remove host.`},mutationFn:({id:e})=>r(e),onSuccess:()=>{N({queryClient:x}),T(null)}}),Z=u({meta:{errorMessage:`Failed to create host join command.`,showErrorToast:!1},mutationFn:()=>t(),onSuccess:e=>{M({queryClient:x}),D(e),V(!0)},onError:e=>{if(e instanceof o&&e.code===`app_url_required`){G(!0);return}j({error:e,fallbackMessage:`Failed to create host join command.`})}}),Q=u({meta:{errorMessage:`Failed to cancel host join.`},mutationFn:({id:e})=>a(e),onSuccess:(e,t)=>{M({queryClient:x}),D(e=>e?.hostId===t.id?null:e),V(!1)}}),$=E===null?null:s.find(e=>e.id===E.hostId)??null,te=Z.isPending||Q.isPending;async function ne(){if(E!==null&&E.expiresAt>Date.now()&&$?.status!==`connected`){V(!0);return}if(E!==null&&$?.status!==`connected`)try{await Q.mutateAsync({id:E.hostId})}catch{return}Z.mutate()}(0,L.useEffect)(()=>{if(!A||$?.status!==`connected`)return;let e=window.setTimeout(()=>{D(null),V(!1)},1500);return()=>window.clearTimeout(e)},[A,$?.status]);function re(e){if(e){V(!0);return}E!==null&&$?.status!==`connected`&&Q.mutate({id:E.hostId}),D(null),V(!1)}return(0,z.jsxs)(p,{contentClassName:`pt-4 md:pt-5`,children:[(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-6`,children:[(0,z.jsx)(I,{title:`Appearance`,children:(0,z.jsx)(P,{label:`Theme`,children:(0,z.jsxs)(_,{children:[(0,z.jsx)(g,{asChild:!0,children:(0,z.jsxs)(c,{variant:`outline`,size:`sm`,className:`w-full justify-between sm:w-48`,"aria-label":`Theme`,children:[X[i],(0,z.jsx)(d,{name:`ChevronDown`,className:`size-3.5 text-muted-foreground`})]})}),(0,z.jsx)(y,{align:`end`,className:`w-48`,children:Y.map(e=>(0,z.jsxs)(h,{onSelect:()=>k(e.value),children:[e.label,(0,z.jsx)(d,{name:`Check`,className:f(`ml-auto`,i!==e.value&&`opacity-0`,b)})]},e.value))})]})})}),(0,z.jsx)(I,{title:`Hosts`,description:`Persistent hosts`,action:(0,z.jsxs)(c,{type:`button`,size:`sm`,variant:`ghost`,disabled:te,onClick:()=>{ne()},children:[(0,z.jsx)(d,{name:`Plus`,className:`size-3.5`}),`New host`]}),children:m?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):s.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No registered hosts.`}):(0,z.jsx)(F,{children:s.map(e=>{let t=e.status===`connected`;return(0,z.jsxs)(ee,{children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,(0,z.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:e.id})]}),t?(0,z.jsx)(`span`,{className:R,title:`Connected`}):e.lastSeenAt===null?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Never connected`}):(0,z.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[`Offline · `,n(e.lastSeenAt)]}),(0,z.jsxs)(_,{children:[(0,z.jsx)(g,{asChild:!0,children:(0,z.jsx)(c,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,"aria-label":`Host actions`,children:(0,z.jsx)(d,{name:`MoreHorizontal`,className:`size-4`})})}),(0,z.jsxs)(y,{align:`end`,className:`w-40`,children:[(0,z.jsx)(h,{onSelect:()=>C({id:e.id,currentName:e.name}),children:`Rename`}),(0,z.jsx)(h,{className:`text-destructive focus:text-destructive`,onSelect:()=>T({id:e.id,name:e.name}),children:`Remove`})]})]})]},e.id)})})})]}),(0,z.jsx)(H,{target:S,pending:K.isPending,onOpenChange:e=>{e||C(null)},onRename:(e,t)=>K.mutate({id:e,name:t})}),(0,z.jsx)(B,{target:w,pending:J.isPending,onOpenChange:e=>{e||T(null)},onDelete:e=>J.mutate({id:e})}),(0,z.jsx)(q,{open:A,target:E,host:$,onOpenChange:re}),(0,z.jsx)(W,{open:U,onOpenChange:G})]})}export{Z as AppSettingsView};
1
+ import{An as e,At as t,Bn as n,Ft as r,Ki as i,Ot as a,Tt as o,Vi as s,Yr as c,_i as l,ii as u,ni as d,ri as f,t as p,vi as m}from"./page-shell-Dglk9LmR.js";import{c as h,d as g,i as _,n as v,o as y,xt as b}from"./effective-hosts-BWRuszG7.js";import{a as x,g as S,i as C,o as w,r as T,s as E,t as D}from"./dialog-CxN4lDeD.js";import{Bt as O,Rt as k,Vt as A,Xt as j,nn as M,rn as N}from"./index-ByQGFt4l.js";import{i as P,n as F,r as I,t as ee}from"./settings-section-CZi6DvBs.js";var L=i(s(),1),R=`size-2 shrink-0 rounded-full ring-1 ring-inset transition-all bg-success ring-success/25 shadow-[0_0_0_4px_color-mix(in_oklch,var(--color-success)_16%,transparent)]`,z=m();function B({target:e,pending:t,onOpenChange:n,onDelete:r}){return(0,z.jsx)(D,{open:e!==null,onOpenChange:n,children:(0,z.jsx)(T,{children:e?(0,z.jsx)(V,{target:e,pending:t,onDelete:r}):null})})}function V({target:e,pending:t,onDelete:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`Remove host?`}),(0,z.jsx)(C,{children:`Remove "${e.name}" and all of its project sources? This cannot be undone.`})]}),(0,z.jsx)(x,{children:(0,z.jsx)(c,{type:`button`,variant:`destructive`,disabled:t,onClick:()=>n(e.id),children:`Remove host`})})]})}function H({target:e,pending:t,onOpenChange:n,onRename:r}){return(0,z.jsx)(D,{open:e!==null,onOpenChange:n,children:(0,z.jsx)(T,{children:e?(0,z.jsx)(U,{target:e,pending:t,onRename:r},e.id):null})})}function U({target:e,pending:t,onRename:n}){let r=(0,L.useId)(),[i,a]=(0,L.useState)(e.currentName),[o,s]=(0,L.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`Rename host`}),(0,z.jsx)(C,{children:`Choose a new name for this host.`})]}),(0,z.jsxs)(`form`,{className:`space-y-4`,onSubmit:r=>{if(r.preventDefault(),t)return;let a=i.trim();if(!a){s(`Host name cannot be empty.`);return}n(e.id,a)},children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(S,{id:r,"aria-label":`Host name`,value:i,autoFocus:!0,disabled:t,onChange:e=>{a(e.target.value),o&&s(null)}}),o?(0,z.jsx)(`p`,{className:`text-sm text-destructive`,children:o}):null]}),(0,z.jsx)(x,{children:(0,z.jsx)(c,{type:`submit`,disabled:t,children:`Rename host`})})]})]})}function W({open:e,onOpenChange:t}){return(0,z.jsx)(D,{open:e,onOpenChange:t,children:(0,z.jsx)(T,{className:`sm:max-w-2xl`,children:(0,z.jsx)(G,{})})})}function G(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`Unable to add new host`}),(0,z.jsx)(C,{children:`You need to specify the URL that allows the new host to talk to the server.`})]}),(0,z.jsxs)(`div`,{className:`min-w-0 space-y-2 text-sm text-foreground`,children:[(0,z.jsx)(`p`,{children:`Run this on the server machine, then restart bb:`}),(0,z.jsx)(`pre`,{className:`min-w-0 overflow-x-auto rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-xs leading-5`,children:(0,z.jsx)(`code`,{children:`npx bb-app config BB_APP_URL http://<your-machine>.<tailnet>.ts.net:38886`})})]})]})}function K(e){return new Date(e).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}function q({host:e,open:t,target:n,onOpenChange:r}){let i=t&&n!==null;return(0,z.jsx)(D,{open:i,onOpenChange:r,children:(0,z.jsx)(T,{className:`sm:max-w-2xl`,children:i&&n?(0,z.jsx)(J,{host:e,target:n}):null})})}function J({host:e,target:t}){let[n,r]=(0,L.useState)(()=>t.expiresAt<=Date.now()),i=e?.status===`connected`,a=!i&&!n,o=i?`Host connected`:n?`Join command expired`:`Waiting for host`;return(0,L.useEffect)(()=>{let e=t.expiresAt-Date.now();if(e<=0){r(!0);return}r(!1);let n=window.setTimeout(()=>r(!0),e);return()=>window.clearTimeout(n)},[t.expiresAt]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{children:[(0,z.jsx)(E,{children:`New host`}),(0,z.jsx)(C,{children:`Run this command from the new host.`})]}),(0,z.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,z.jsxs)(`div`,{className:`relative min-w-0 rounded-md border border-border bg-muted/40`,children:[(0,z.jsx)(`pre`,{className:`max-h-56 min-w-0 overflow-y-auto whitespace-pre-wrap break-all px-3 py-2.5 pr-10 text-xs leading-5`,children:(0,z.jsx)(`code`,{children:t.joinCommand})}),(0,z.jsx)(A,{text:t.joinCommand,label:`Copy host command`,className:`absolute right-2 top-2`})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[i?(0,z.jsx)(d,{name:`CircleCheck`,className:`size-4 text-success`,"aria-hidden":`true`}):n?(0,z.jsx)(d,{name:`AlertCircle`,className:`size-4 text-destructive`,"aria-hidden":`true`}):null,(0,z.jsx)(`span`,{className:a?`animate-shine font-medium`:`font-medium text-foreground`,children:o}),a?(0,z.jsxs)(`span`,{children:[`· Expires at `,K(t.expiresAt)]}):null]})]})]})}var Y=[{label:`System`,value:`system`},{label:`Light`,value:`light`},{label:`Dark`,value:`dark`}],X={dark:`Dark`,light:`Light`,system:`System`};function Z(){let i=O(),{data:s=[],isLoading:m}=v(),x=l(),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(null),[E,D]=(0,L.useState)(null),[A,V]=(0,L.useState)(!1),[U,G]=(0,L.useState)(!1),K=u({meta:{errorMessage:`Failed to rename host.`},mutationFn:({id:t,name:n})=>e(t,{name:n}),onSuccess:()=>{M({queryClient:x}),C(null)}}),J=u({meta:{errorMessage:`Failed to remove host.`},mutationFn:({id:e})=>r(e),onSuccess:()=>{N({queryClient:x}),T(null)}}),Z=u({meta:{errorMessage:`Failed to create host join command.`,showErrorToast:!1},mutationFn:()=>t(),onSuccess:e=>{M({queryClient:x}),D(e),V(!0)},onError:e=>{if(e instanceof o&&e.code===`app_url_required`){G(!0);return}j({error:e,fallbackMessage:`Failed to create host join command.`})}}),Q=u({meta:{errorMessage:`Failed to cancel host join.`},mutationFn:({id:e})=>a(e),onSuccess:(e,t)=>{M({queryClient:x}),D(e=>e?.hostId===t.id?null:e),V(!1)}}),$=E===null?null:s.find(e=>e.id===E.hostId)??null,te=Z.isPending||Q.isPending;async function ne(){if(E!==null&&E.expiresAt>Date.now()&&$?.status!==`connected`){V(!0);return}if(E!==null&&$?.status!==`connected`)try{await Q.mutateAsync({id:E.hostId})}catch{return}Z.mutate()}(0,L.useEffect)(()=>{if(!A||$?.status!==`connected`)return;let e=window.setTimeout(()=>{D(null),V(!1)},1500);return()=>window.clearTimeout(e)},[A,$?.status]);function re(e){if(e){V(!0);return}E!==null&&$?.status!==`connected`&&Q.mutate({id:E.hostId}),D(null),V(!1)}return(0,z.jsxs)(p,{contentClassName:`pt-4 md:pt-5`,children:[(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-6`,children:[(0,z.jsx)(I,{title:`Appearance`,children:(0,z.jsx)(P,{label:`Theme`,children:(0,z.jsxs)(_,{children:[(0,z.jsx)(g,{asChild:!0,children:(0,z.jsxs)(c,{variant:`outline`,size:`sm`,className:`w-full justify-between sm:w-48`,"aria-label":`Theme`,children:[X[i],(0,z.jsx)(d,{name:`ChevronDown`,className:`size-3.5 text-muted-foreground`})]})}),(0,z.jsx)(y,{align:`end`,className:`w-48`,children:Y.map(e=>(0,z.jsxs)(h,{onSelect:()=>k(e.value),children:[e.label,(0,z.jsx)(d,{name:`Check`,className:f(`ml-auto`,i!==e.value&&`opacity-0`,b)})]},e.value))})]})})}),(0,z.jsx)(I,{title:`Hosts`,description:`Persistent hosts`,action:(0,z.jsxs)(c,{type:`button`,size:`sm`,variant:`ghost`,disabled:te,onClick:()=>{ne()},children:[(0,z.jsx)(d,{name:`Plus`,className:`size-3.5`}),`New host`]}),children:m?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):s.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No registered hosts.`}):(0,z.jsx)(F,{children:s.map(e=>{let t=e.status===`connected`;return(0,z.jsxs)(ee,{children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,(0,z.jsx)(`span`,{className:`ml-1.5 text-xs text-muted-foreground`,children:e.id})]}),t?(0,z.jsx)(`span`,{className:R,title:`Connected`}):e.lastSeenAt===null?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Never connected`}):(0,z.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[`Offline · `,n(e.lastSeenAt)]}),(0,z.jsxs)(_,{children:[(0,z.jsx)(g,{asChild:!0,children:(0,z.jsx)(c,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,"aria-label":`Host actions`,children:(0,z.jsx)(d,{name:`MoreHorizontal`,className:`size-4`})})}),(0,z.jsxs)(y,{align:`end`,className:`w-40`,children:[(0,z.jsx)(h,{onSelect:()=>C({id:e.id,currentName:e.name}),children:`Rename`}),(0,z.jsx)(h,{className:`text-destructive focus:text-destructive`,onSelect:()=>T({id:e.id,name:e.name}),children:`Remove`})]})]})]},e.id)})})})]}),(0,z.jsx)(H,{target:S,pending:K.isPending,onOpenChange:e=>{e||C(null)},onRename:(e,t)=>K.mutate({id:e,name:t})}),(0,z.jsx)(B,{target:w,pending:J.isPending,onOpenChange:e=>{e||T(null)},onDelete:e=>J.mutate({id:e})}),(0,z.jsx)(q,{open:A,target:E,host:$,onOpenChange:re}),(0,z.jsx)(W,{open:U,onOpenChange:G})]})}export{Z as AppSettingsView};
@@ -1 +1 @@
1
- import{Ki as e,Lt as t,Tn as n,Vi as r,Yr as i,_i as a,ai as o,et as s,ii as c,ln as l,ni as u,ri as d,t as f,vi as p}from"./page-shell-Dglk9LmR.js";import{n as m}from"./effective-hosts-BWRuszG7.js";import{r as h,t as g}from"./pill-BHnTA2D7.js";import{C as _,M as v,in as y,j as b}from"./index-D_DARDfc.js";import{t as x}from"./split-button-CeV-MQ2f.js";var S=e(r(),1),C=p(),w=1,T=[.5,1,2,5,10],E=`block min-w-0 truncate text-foreground underline underline-offset-2 transition-colors hover:text-foreground/80`;function D(e){return`${e}×`}function O(e){return new Date(e).toLocaleString()}function k(){let e=a(),[r,p]=(0,S.useState)(()=>new Set),k=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},A=o({queryKey:s(),queryFn:()=>l()}),{data:j=[]}=m(),M=(0,S.useMemo)(()=>new Map(j.map(e=>[e.id,e.name])),[j]),N=c({mutationFn:e=>t(e),onSuccess:()=>{y({queryClient:e})}}),P=c({mutationFn:({captureId:e,speed:t})=>n(e,{speed:t}),onSuccess:e=>{window.open(`/projects/${e.projectId}/threads/${e.replayThreadId}`,`_blank`,`noopener`)}}),F=A.data?.captures??[];return(0,C.jsx)(f,{contentClassName:`pt-4 md:pt-5`,children:(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border/70 bg-muted/20 px-3 py-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(u,{name:`Info`,className:`mt-0.5 size-4 shrink-0`}),(0,C.jsxs)(`p`,{className:`m-0`,children:[`Replay previously captured conversations in a fresh thread. To record new captures, create threads with`,` `,(0,C.jsx)(`code`,{className:`font-mono text-xs`,children:`BB_DEV_REPLAY_CAPTURE=true pnpm dev`}),`.`]})]}),A.isLoading?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):A.isError?(0,C.jsx)(`p`,{className:`text-sm text-destructive`,children:`Failed to load replay captures.`}):F.length===0?(0,C.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-4 text-sm text-muted-foreground`,children:`No replay captures found on any connected host.`}):(0,C.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>{let t=e.userInputPreview||e.captureId,n=e.kind===`thread-start`,a=n?`new`:`follow-up`,o=_(e.providerId),s=o?.icon,c=r.has(e.captureId),l=N.isPending&&N.variables===e.captureId,f=P.isPending&&P.variables?.captureId===e.captureId,p=P.isError&&P.variables?.captureId===e.captureId,m=e.eventCounts.rawProviderEvents===0,y={label:`Start replay at ${D(w)}`,onSelect:()=>P.mutate({captureId:e.captureId,speed:w}),content:(0,C.jsxs)(C.Fragment,{children:[f?(0,C.jsx)(u,{name:`Spinner`,className:`size-3 animate-spin`}):null,`Replay`]})},S=T.map(t=>({label:`Start replay at ${D(t)}`,onSelect:()=>P.mutate({captureId:e.captureId,speed:t}),content:(0,C.jsx)(`span`,{children:D(t)})}));return(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex h-9 items-center gap-3 text-sm`,children:[(0,C.jsxs)(`button`,{type:`button`,onClick:()=>k(e.captureId),"aria-expanded":c,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,C.jsx)(u,{name:`ChevronRight`,className:d(`size-3 shrink-0 text-muted-foreground transition-transform`,c&&`rotate-90`)}),(0,C.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`min-w-0 max-w-xs truncate`,children:t}),e.title?(0,C.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.title}):null,(0,C.jsx)(g,{variant:n?`secondary`:`outline`,className:`shrink-0`,children:a}),s?(0,C.jsx)(s,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-label":o?.ariaLabel}):(0,C.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.providerId})]})]}),(0,C.jsx)(x,{disabled:f||m,primaryAction:y,secondaryActions:S,triggerLabel:`Choose replay speed`,mobileTitle:`Replay speed`}),(0,C.jsx)(i,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Delete replay capture`,title:`Delete replay capture`,disabled:l,onClick:()=>N.mutate(e.captureId),className:`size-6`,children:l?(0,C.jsx)(u,{name:`Spinner`,className:`size-3 animate-spin`}):(0,C.jsx)(u,{name:`Trash2`,className:`size-3`})})]}),c?(0,C.jsxs)(`div`,{className:`space-y-2 pb-3 pt-2`,children:[(0,C.jsxs)(b,{children:[(0,C.jsx)(v,{label:`Capture`,valueClassName:`min-w-0 truncate font-mono`,children:e.captureId}),(0,C.jsx)(v,{label:`Host`,valueClassName:`min-w-0 truncate`,children:M.get(e.hostId)??e.hostId}),(0,C.jsx)(v,{label:`Provider`,valueClassName:`min-w-0 truncate`,children:e.providerId}),(0,C.jsx)(v,{label:`Project`,valueClassName:`min-w-0`,children:(0,C.jsx)(h,{to:`/projects/${e.projectId}`,className:E,children:e.projectName??e.projectId})}),(0,C.jsx)(v,{label:`Thread`,valueClassName:`min-w-0`,children:(0,C.jsx)(h,{to:`/projects/${e.projectId}/threads/${e.threadId}`,className:d(E,!e.title&&`font-mono`),children:e.title??e.threadId})}),(0,C.jsx)(v,{label:`Captured`,valueClassName:`min-w-0 truncate`,children:O(e.capturedAt)}),(0,C.jsx)(v,{label:`Raw events`,valueClassName:`min-w-0 truncate`,children:e.eventCounts.rawProviderEvents})]}),p?(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:`Failed to start replay.`}):null]}):null]},`${e.hostId}:${e.captureId}`)})})]})})}export{k as InternalReplayListView};
1
+ import{Ki as e,Lt as t,Tn as n,Vi as r,Yr as i,_i as a,ai as o,et as s,ii as c,ln as l,ni as u,ri as d,t as f,vi as p}from"./page-shell-Dglk9LmR.js";import{n as m}from"./effective-hosts-BWRuszG7.js";import{r as h,t as g}from"./pill-BHnTA2D7.js";import{C as _,M as v,in as y,j as b}from"./index-ByQGFt4l.js";import{t as x}from"./split-button-CeV-MQ2f.js";var S=e(r(),1),C=p(),w=1,T=[.5,1,2,5,10],E=`block min-w-0 truncate text-foreground underline underline-offset-2 transition-colors hover:text-foreground/80`;function D(e){return`${e}×`}function O(e){return new Date(e).toLocaleString()}function k(){let e=a(),[r,p]=(0,S.useState)(()=>new Set),k=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},A=o({queryKey:s(),queryFn:()=>l()}),{data:j=[]}=m(),M=(0,S.useMemo)(()=>new Map(j.map(e=>[e.id,e.name])),[j]),N=c({mutationFn:e=>t(e),onSuccess:()=>{y({queryClient:e})}}),P=c({mutationFn:({captureId:e,speed:t})=>n(e,{speed:t}),onSuccess:e=>{window.open(`/projects/${e.projectId}/threads/${e.replayThreadId}`,`_blank`,`noopener`)}}),F=A.data?.captures??[];return(0,C.jsx)(f,{contentClassName:`pt-4 md:pt-5`,children:(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border/70 bg-muted/20 px-3 py-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(u,{name:`Info`,className:`mt-0.5 size-4 shrink-0`}),(0,C.jsxs)(`p`,{className:`m-0`,children:[`Replay previously captured conversations in a fresh thread. To record new captures, create threads with`,` `,(0,C.jsx)(`code`,{className:`font-mono text-xs`,children:`BB_DEV_REPLAY_CAPTURE=true pnpm dev`}),`.`]})]}),A.isLoading?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):A.isError?(0,C.jsx)(`p`,{className:`text-sm text-destructive`,children:`Failed to load replay captures.`}):F.length===0?(0,C.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-4 text-sm text-muted-foreground`,children:`No replay captures found on any connected host.`}):(0,C.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>{let t=e.userInputPreview||e.captureId,n=e.kind===`thread-start`,a=n?`new`:`follow-up`,o=_(e.providerId),s=o?.icon,c=r.has(e.captureId),l=N.isPending&&N.variables===e.captureId,f=P.isPending&&P.variables?.captureId===e.captureId,p=P.isError&&P.variables?.captureId===e.captureId,m=e.eventCounts.rawProviderEvents===0,y={label:`Start replay at ${D(w)}`,onSelect:()=>P.mutate({captureId:e.captureId,speed:w}),content:(0,C.jsxs)(C.Fragment,{children:[f?(0,C.jsx)(u,{name:`Spinner`,className:`size-3 animate-spin`}):null,`Replay`]})},S=T.map(t=>({label:`Start replay at ${D(t)}`,onSelect:()=>P.mutate({captureId:e.captureId,speed:t}),content:(0,C.jsx)(`span`,{children:D(t)})}));return(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex h-9 items-center gap-3 text-sm`,children:[(0,C.jsxs)(`button`,{type:`button`,onClick:()=>k(e.captureId),"aria-expanded":c,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,C.jsx)(u,{name:`ChevronRight`,className:d(`size-3 shrink-0 text-muted-foreground transition-transform`,c&&`rotate-90`)}),(0,C.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`min-w-0 max-w-xs truncate`,children:t}),e.title?(0,C.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.title}):null,(0,C.jsx)(g,{variant:n?`secondary`:`outline`,className:`shrink-0`,children:a}),s?(0,C.jsx)(s,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-label":o?.ariaLabel}):(0,C.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.providerId})]})]}),(0,C.jsx)(x,{disabled:f||m,primaryAction:y,secondaryActions:S,triggerLabel:`Choose replay speed`,mobileTitle:`Replay speed`}),(0,C.jsx)(i,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Delete replay capture`,title:`Delete replay capture`,disabled:l,onClick:()=>N.mutate(e.captureId),className:`size-6`,children:l?(0,C.jsx)(u,{name:`Spinner`,className:`size-3 animate-spin`}):(0,C.jsx)(u,{name:`Trash2`,className:`size-3`})})]}),c?(0,C.jsxs)(`div`,{className:`space-y-2 pb-3 pt-2`,children:[(0,C.jsxs)(b,{children:[(0,C.jsx)(v,{label:`Capture`,valueClassName:`min-w-0 truncate font-mono`,children:e.captureId}),(0,C.jsx)(v,{label:`Host`,valueClassName:`min-w-0 truncate`,children:M.get(e.hostId)??e.hostId}),(0,C.jsx)(v,{label:`Provider`,valueClassName:`min-w-0 truncate`,children:e.providerId}),(0,C.jsx)(v,{label:`Project`,valueClassName:`min-w-0`,children:(0,C.jsx)(h,{to:`/projects/${e.projectId}`,className:E,children:e.projectName??e.projectId})}),(0,C.jsx)(v,{label:`Thread`,valueClassName:`min-w-0`,children:(0,C.jsx)(h,{to:`/projects/${e.projectId}/threads/${e.threadId}`,className:d(E,!e.title&&`font-mono`),children:e.title??e.threadId})}),(0,C.jsx)(v,{label:`Captured`,valueClassName:`min-w-0 truncate`,children:O(e.capturedAt)}),(0,C.jsx)(v,{label:`Raw events`,valueClassName:`min-w-0 truncate`,children:e.eventCounts.rawProviderEvents})]}),p?(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:`Failed to start replay.`}):null]}):null]},`${e.hostId}:${e.captureId}`)})})]})})}export{k as InternalReplayListView};
@@ -1 +1 @@
1
- import{Ki as e,Vi as t,Yr as n,_i as r,dr as i,ii as a,ni as o,t as s,ur as c,vi as l,vn as u}from"./page-shell-Dglk9LmR.js";import{c as d,d as f,i as p,n as m,o as h}from"./effective-hosts-BWRuszG7.js";import{f as g,t as _}from"./pill-BHnTA2D7.js";import{a as v,i as y,o as b,r as x,s as S,t as C}from"./dialog-CxN4lDeD.js";import{D as w,E as T,d as E,r as D,s as O,t as k}from"./localhost-badge-BBCmn0GW.js";import{a as A}from"./mutation-cache-effects-BQHFwGL7.js";import{cn as j,en as M,sn as N,tn as P}from"./index-D_DARDfc.js";import{n as F,r as I,t as L}from"./settings-section-CZi6DvBs.js";var R=e(t(),1),z=l();function B({target:e,pending:t,onOpenChange:n,onDelete:r}){return(0,z.jsx)(C,{open:e!==null,onOpenChange:n,children:(0,z.jsx)(x,{children:e?(0,z.jsx)(V,{target:e,pending:t,onDelete:r}):null})})}function V({target:e,pending:t,onDelete:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(b,{children:[(0,z.jsx)(S,{children:`Remove source?`}),(0,z.jsx)(y,{children:`Remove "${e.label}" from this project? This cannot be undone.`})]}),(0,z.jsx)(v,{children:(0,z.jsx)(n,{type:`button`,variant:`destructive`,disabled:t,onClick:()=>r(e.id),children:`Remove source`})})]})}function H({source:e,isLocalhostSource:t,isLocalPathInvalid:r,hostName:i,isEditPending:a,isOnlySource:s,onEditLocalPath:c,onRemove:l}){return(0,z.jsxs)(L,{children:[(0,z.jsx)(o,{name:D,className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-shrink truncate`,children:e.path}),(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:i}),t?(0,z.jsx)(`span`,{className:`self-center`,children:(0,z.jsx)(k,{})}):null,r?(0,z.jsx)(_,{variant:`destructive`,children:`Invalid local path`}):null]}),(0,z.jsxs)(p,{children:[(0,z.jsx)(f,{asChild:!0,children:(0,z.jsx)(n,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,"aria-label":`Source actions`,children:(0,z.jsx)(o,{name:`MoreHorizontal`,className:`size-4`})})}),(0,z.jsxs)(h,{align:`end`,className:`w-40`,children:[t?(0,z.jsx)(d,{disabled:a,onSelect:t=>{t.preventDefault(),c(e)},children:`Edit local path`}):null,(0,z.jsx)(d,{className:`text-destructive focus:text-destructive`,disabled:s,onSelect:()=>l(e),children:`Remove`})]})]})]})}function U(e,t){return t.get(e.hostId)??e.hostId}function W(){let{projectId:e}=g(),t=w(),o=T({enabled:t.isSuccess||t.isError}),l=o.data,d=t.isFetching||o.isLoading,{data:f=[]}=m(),p=r(),[h,_]=(0,R.useState)(null),v=a({meta:{errorMessage:`Failed to remove source.`},mutationFn:({sourceId:t})=>e?u(e,t):Promise.resolve(),onSuccess:()=>{A({projectId:e,queryClient:p}),_(null)}}),y=O(),b=E(),x=l?.find(t=>t.id===e),S=x?.sources,C=(0,R.useMemo)(()=>S??[],[S]),D=(0,R.useMemo)(()=>new Map(f.map(e=>[e.id,e.name])),[f]),k=x?.name??``,L=y.isPending||b.isPending,V=P({isPending:L,submit:(0,R.useCallback)(({path:t,hostId:n,target:r,closeDialog:a})=>{if(e){if(r.kind===`add-source`)y.mutate({projectId:e,path:t,hostId:n},{onSuccess:a});else if(r.kind===`update`){let r=C.find(e=>i(e)&&e.hostId===n);if(!r)return;b.mutate({projectId:e,sourceId:r.id,path:t},{onSuccess:a})}}},[y,e,C,b])}),W=(0,R.useCallback)(()=>{e&&V.openPicker({kind:`add-source`,projectId:e,projectName:k})},[V,e,k]),G=(0,R.useCallback)(t=>{e&&V.openPicker({kind:`update`,projectId:e,projectName:k,currentPath:t.path})},[V,e,k]),K=V.localHostId,q=j((0,R.useMemo)(()=>K?C.filter(e=>i(e)&&e.hostId===K).map(e=>e.path):[],[K,C])),J=K!=null&&!c(C,K)?(0,z.jsx)(`div`,{className:`mt-2 flex gap-2`,children:(0,z.jsx)(n,{size:`sm`,variant:`outline`,disabled:y.isPending,onClick:W,children:`Add local path`})}):null;return(0,z.jsxs)(s,{contentClassName:`pt-4 md:pt-5`,children:[(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-3xl space-y-6`,children:(0,z.jsx)(I,{title:`Project Sources`,children:d?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):C.length===0?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No sources configured.`}),J]}):(0,z.jsxs)(`div`,{children:[(0,z.jsx)(F,{children:C.map(e=>{let t=i(e)&&K!=null&&e.hostId===K;return(0,z.jsx)(H,{source:e,isLocalhostSource:t,isLocalPathInvalid:t&&N(q,e.path),hostName:i(e)?D.get(e.hostId)??e.hostId:``,isEditPending:L,isOnlySource:C.length<=1,onEditLocalPath:G,onRemove:e=>_({id:e.id,label:U(e,D)})},e.id)})}),J]})})}),(0,z.jsx)(M,{target:V.projectPathDialog.target,pending:L,platform:V.platform,onOpenChange:V.projectPathDialog.onOpenChange,onSubmit:V.submitProjectPath}),(0,z.jsx)(B,{target:h,pending:v.isPending,onOpenChange:e=>{e||_(null)},onDelete:e=>v.mutate({sourceId:e})})]})}export{W as ProjectSettingsView};
1
+ import{Ki as e,Vi as t,Yr as n,_i as r,dr as i,ii as a,ni as o,t as s,ur as c,vi as l,vn as u}from"./page-shell-Dglk9LmR.js";import{c as d,d as f,i as p,n as m,o as h}from"./effective-hosts-BWRuszG7.js";import{f as g,t as _}from"./pill-BHnTA2D7.js";import{a as v,i as y,o as b,r as x,s as S,t as C}from"./dialog-CxN4lDeD.js";import{D as w,E as T,d as E,r as D,s as O,t as k}from"./localhost-badge-BBCmn0GW.js";import{a as A}from"./mutation-cache-effects-BQHFwGL7.js";import{cn as j,en as M,sn as N,tn as P}from"./index-ByQGFt4l.js";import{n as F,r as I,t as L}from"./settings-section-CZi6DvBs.js";var R=e(t(),1),z=l();function B({target:e,pending:t,onOpenChange:n,onDelete:r}){return(0,z.jsx)(C,{open:e!==null,onOpenChange:n,children:(0,z.jsx)(x,{children:e?(0,z.jsx)(V,{target:e,pending:t,onDelete:r}):null})})}function V({target:e,pending:t,onDelete:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(b,{children:[(0,z.jsx)(S,{children:`Remove source?`}),(0,z.jsx)(y,{children:`Remove "${e.label}" from this project? This cannot be undone.`})]}),(0,z.jsx)(v,{children:(0,z.jsx)(n,{type:`button`,variant:`destructive`,disabled:t,onClick:()=>r(e.id),children:`Remove source`})})]})}function H({source:e,isLocalhostSource:t,isLocalPathInvalid:r,hostName:i,isEditPending:a,isOnlySource:s,onEditLocalPath:c,onRemove:l}){return(0,z.jsxs)(L,{children:[(0,z.jsx)(o,{name:D,className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-shrink truncate`,children:e.path}),(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:i}),t?(0,z.jsx)(`span`,{className:`self-center`,children:(0,z.jsx)(k,{})}):null,r?(0,z.jsx)(_,{variant:`destructive`,children:`Invalid local path`}):null]}),(0,z.jsxs)(p,{children:[(0,z.jsx)(f,{asChild:!0,children:(0,z.jsx)(n,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,"aria-label":`Source actions`,children:(0,z.jsx)(o,{name:`MoreHorizontal`,className:`size-4`})})}),(0,z.jsxs)(h,{align:`end`,className:`w-40`,children:[t?(0,z.jsx)(d,{disabled:a,onSelect:t=>{t.preventDefault(),c(e)},children:`Edit local path`}):null,(0,z.jsx)(d,{className:`text-destructive focus:text-destructive`,disabled:s,onSelect:()=>l(e),children:`Remove`})]})]})]})}function U(e,t){return t.get(e.hostId)??e.hostId}function W(){let{projectId:e}=g(),t=w(),o=T({enabled:t.isSuccess||t.isError}),l=o.data,d=t.isFetching||o.isLoading,{data:f=[]}=m(),p=r(),[h,_]=(0,R.useState)(null),v=a({meta:{errorMessage:`Failed to remove source.`},mutationFn:({sourceId:t})=>e?u(e,t):Promise.resolve(),onSuccess:()=>{A({projectId:e,queryClient:p}),_(null)}}),y=O(),b=E(),x=l?.find(t=>t.id===e),S=x?.sources,C=(0,R.useMemo)(()=>S??[],[S]),D=(0,R.useMemo)(()=>new Map(f.map(e=>[e.id,e.name])),[f]),k=x?.name??``,L=y.isPending||b.isPending,V=P({isPending:L,submit:(0,R.useCallback)(({path:t,hostId:n,target:r,closeDialog:a})=>{if(e){if(r.kind===`add-source`)y.mutate({projectId:e,path:t,hostId:n},{onSuccess:a});else if(r.kind===`update`){let r=C.find(e=>i(e)&&e.hostId===n);if(!r)return;b.mutate({projectId:e,sourceId:r.id,path:t},{onSuccess:a})}}},[y,e,C,b])}),W=(0,R.useCallback)(()=>{e&&V.openPicker({kind:`add-source`,projectId:e,projectName:k})},[V,e,k]),G=(0,R.useCallback)(t=>{e&&V.openPicker({kind:`update`,projectId:e,projectName:k,currentPath:t.path})},[V,e,k]),K=V.localHostId,q=j((0,R.useMemo)(()=>K?C.filter(e=>i(e)&&e.hostId===K).map(e=>e.path):[],[K,C])),J=K!=null&&!c(C,K)?(0,z.jsx)(`div`,{className:`mt-2 flex gap-2`,children:(0,z.jsx)(n,{size:`sm`,variant:`outline`,disabled:y.isPending,onClick:W,children:`Add local path`})}):null;return(0,z.jsxs)(s,{contentClassName:`pt-4 md:pt-5`,children:[(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-3xl space-y-6`,children:(0,z.jsx)(I,{title:`Project Sources`,children:d?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):C.length===0?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No sources configured.`}),J]}):(0,z.jsxs)(`div`,{children:[(0,z.jsx)(F,{children:C.map(e=>{let t=i(e)&&K!=null&&e.hostId===K;return(0,z.jsx)(H,{source:e,isLocalhostSource:t,isLocalPathInvalid:t&&N(q,e.path),hostName:i(e)?D.get(e.hostId)??e.hostId:``,isEditPending:L,isOnlySource:C.length<=1,onEditLocalPath:G,onRemove:e=>_({id:e.id,label:U(e,D)})},e.id)})}),J]})})}),(0,z.jsx)(M,{target:V.projectPathDialog.target,pending:L,platform:V.platform,onOpenChange:V.projectPathDialog.onOpenChange,onSubmit:V.submitProjectPath}),(0,z.jsx)(B,{target:h,pending:v.isPending,onOpenChange:e=>{e||_(null)},onDelete:e=>v.mutate({sourceId:e})})]})}export{W as ProjectSettingsView};