@spencerboucher/switchyard 0.15.0 → 0.17.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 +1 -1
- package/dist/policies/worker.js +31 -1
- package/dist/switchyard.mjs +247 -28
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-BMQuTl3j.js +2 -0
- package/web-dist/assets/{AutomationView-CMDz-eFh.js.map → AutomationView-BMQuTl3j.js.map} +1 -1
- package/web-dist/assets/InteractionCard-CdBv3Sm7.js +4 -0
- package/web-dist/assets/{InteractionCard-Bhur-sU9.js.map → InteractionCard-CdBv3Sm7.js.map} +1 -1
- package/web-dist/assets/{Overlay-zQBNtPf6.js → Overlay-Cv0SIpoa.js} +2 -2
- package/web-dist/assets/{Overlay-zQBNtPf6.js.map → Overlay-Cv0SIpoa.js.map} +1 -1
- package/web-dist/assets/{Priority-CgO3ns6b.js → Priority-aNWh1i4H.js} +2 -2
- package/web-dist/assets/{Priority-CgO3ns6b.js.map → Priority-aNWh1i4H.js.map} +1 -1
- package/web-dist/assets/Select-Dv-F-HZR.js +2 -0
- package/web-dist/assets/{Select-CpWLZnId.js.map → Select-Dv-F-HZR.js.map} +1 -1
- package/web-dist/assets/{Tabs-DZ2T9VBY.js → Tabs-DPj-rKor.js} +5 -5
- package/web-dist/assets/{Tabs-DZ2T9VBY.js.map → Tabs-DPj-rKor.js.map} +1 -1
- package/web-dist/assets/{UINodeRenderer-JQy6g7ZB.js → UINodeRenderer-GbSP56mL.js} +2 -2
- package/web-dist/assets/{UINodeRenderer-JQy6g7ZB.js.map → UINodeRenderer-GbSP56mL.js.map} +1 -1
- package/web-dist/assets/ViewSelect-DTXqcHvg.js +2 -0
- package/web-dist/assets/ViewSelect-DTXqcHvg.js.map +1 -0
- package/web-dist/assets/attention-eEYmUIPZ.js +2 -0
- package/web-dist/assets/{attention-DrHtkJHs.js.map → attention-eEYmUIPZ.js.map} +1 -1
- package/web-dist/assets/auth-e3n8h2VO.js +2 -0
- package/web-dist/assets/auth-e3n8h2VO.js.map +1 -0
- package/web-dist/assets/automations-DQMWPvqT.js +2 -0
- package/web-dist/assets/{automations-TOhPm8sF.js.map → automations-DQMWPvqT.js.map} +1 -1
- package/web-dist/assets/board-CxPUJBjR.js +10 -0
- package/web-dist/assets/board-CxPUJBjR.js.map +1 -0
- package/web-dist/assets/code-BfD33VCt.js +25 -0
- package/web-dist/assets/code-BfD33VCt.js.map +1 -0
- package/web-dist/assets/{describe-CtmmeUfI.js → describe-ype6dIHS.js} +2 -2
- package/web-dist/assets/{describe-CtmmeUfI.js.map → describe-ype6dIHS.js.map} +1 -1
- package/web-dist/assets/enroll-BTNVVoWB.js +2 -0
- package/web-dist/assets/{enroll-C4m0rxHw.js.map → enroll-BTNVVoWB.js.map} +1 -1
- package/web-dist/assets/index-BE-Sxt6h.css +2 -0
- package/web-dist/assets/index-xw7YOYjs.js +23 -0
- package/web-dist/assets/index-xw7YOYjs.js.map +1 -0
- package/web-dist/assets/more-AZ4rHFG5.js +2 -0
- package/web-dist/assets/{more-BonXabXm.js.map → more-AZ4rHFG5.js.map} +1 -1
- package/web-dist/assets/{policyLogic-nqL3E08V.js → policyLogic-AZSVROoe.js} +2 -2
- package/web-dist/assets/{policyLogic-nqL3E08V.js.map → policyLogic-AZSVROoe.js.map} +1 -1
- package/web-dist/assets/{queue-p_rnOc-9.js → queue-LyV9HFK4.js} +2 -2
- package/web-dist/assets/{queue-p_rnOc-9.js.map → queue-LyV9HFK4.js.map} +1 -1
- package/web-dist/assets/{repo-3GZtN4L8.js → repo-CRmEGTNk.js} +2 -2
- package/web-dist/assets/{repo-3GZtN4L8.js.map → repo-CRmEGTNk.js.map} +1 -1
- package/web-dist/assets/selection-BgO3-HZn.js +2 -0
- package/web-dist/assets/selection-BgO3-HZn.js.map +1 -0
- package/web-dist/assets/settings-CK-9B48D.js +12 -0
- package/web-dist/assets/settings-CK-9B48D.js.map +1 -0
- package/web-dist/assets/states-D7g0-4EY.js +58 -0
- package/web-dist/assets/states-D7g0-4EY.js.map +1 -0
- package/web-dist/assets/terminal-login-B20sSCfk.js +2 -0
- package/web-dist/assets/{terminal-login-j20zSRZp.js.map → terminal-login-B20sSCfk.js.map} +1 -1
- package/web-dist/assets/useNow-DvXAU3dJ.js +2 -0
- package/web-dist/assets/useNow-DvXAU3dJ.js.map +1 -0
- package/web-dist/assets/{useResource-DhvWL_9X.js → useResource-CFaJYaSY.js} +2 -2
- package/web-dist/assets/{useResource-DhvWL_9X.js.map → useResource-CFaJYaSY.js.map} +1 -1
- package/web-dist/index.html +5 -10
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-CMDz-eFh.js +0 -2
- package/web-dist/assets/InteractionCard-Bhur-sU9.js +0 -4
- package/web-dist/assets/Menu-dT22Gwzm.js +0 -2
- package/web-dist/assets/Menu-dT22Gwzm.js.map +0 -1
- package/web-dist/assets/Select-CpWLZnId.js +0 -2
- package/web-dist/assets/TextArea-BQPdfjO_.js +0 -2
- package/web-dist/assets/TextArea-BQPdfjO_.js.map +0 -1
- package/web-dist/assets/attention-DrHtkJHs.js +0 -2
- package/web-dist/assets/automations-TOhPm8sF.js +0 -2
- package/web-dist/assets/board-BZWPMk0Z.js +0 -10
- package/web-dist/assets/board-BZWPMk0Z.js.map +0 -1
- package/web-dist/assets/code-DVA5CKfS.js +0 -25
- package/web-dist/assets/code-DVA5CKfS.js.map +0 -1
- package/web-dist/assets/drafts-BP2GMlHS.js +0 -13
- package/web-dist/assets/drafts-BP2GMlHS.js.map +0 -1
- package/web-dist/assets/enroll-C4m0rxHw.js +0 -2
- package/web-dist/assets/index-LsagdEq-.js +0 -11
- package/web-dist/assets/index-LsagdEq-.js.map +0 -1
- package/web-dist/assets/index-f4tQ91xN.css +0 -2
- package/web-dist/assets/key-round-DIA3lje5.js +0 -2
- package/web-dist/assets/key-round-DIA3lje5.js.map +0 -1
- package/web-dist/assets/more-BonXabXm.js +0 -2
- package/web-dist/assets/pencil-BtK08_f_.js +0 -2
- package/web-dist/assets/pencil-BtK08_f_.js.map +0 -1
- package/web-dist/assets/preload-helper-DOFsWE7_.js +0 -3
- package/web-dist/assets/preload-helper-DOFsWE7_.js.map +0 -1
- package/web-dist/assets/presence-BnGwJNSq.js +0 -2
- package/web-dist/assets/presence-BnGwJNSq.js.map +0 -1
- package/web-dist/assets/registry-D8Ph1G2W.js +0 -2
- package/web-dist/assets/registry-D8Ph1G2W.js.map +0 -1
- package/web-dist/assets/settings-jyGW1LsI.js +0 -9
- package/web-dist/assets/settings-jyGW1LsI.js.map +0 -1
- package/web-dist/assets/states-BXOts8eT.js +0 -58
- package/web-dist/assets/states-BXOts8eT.js.map +0 -1
- package/web-dist/assets/terminal-login-j20zSRZp.js +0 -2
- package/web-dist/assets/useNow-DfER3XvS.js +0 -2
- package/web-dist/assets/useNow-DfER3XvS.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,_ as t,a as n,h as r,i,l as a,o,t as s,v as c,y as l}from"./Button-BKQW9doW.js";import{A as u,T as d,h as f,j as ee,k as p,l as m,t as te,w as h}from"./Overlay-zQBNtPf6.js";import{At as ne,L as g,M as re,Nt as _,O as ie,Ot as ae,Pt as v,at as y,c as b,f as x,i as oe,jt as se,kt as S,m as C,n as w,r as T,s as ce,t as E,tt as D,u as O}from"./states-BXOts8eT.js";import{t as k}from"./calendar-clock-CwOgyN2z.js";import{n as le,r as A}from"./Copy-D6U5ewFc.js";import{n as ue,r as j,t as de}from"./Priority-CgO3ns6b.js";import{a as fe,c as pe,i as me,p as he,s as M,t as ge}from"./useBreakpoint-kT0J1Dnk.js";import{t as _e}from"./key-round-DIA3lje5.js";import{t as ve}from"./play-j138GLHB.js";import{t as N}from"./plus-D935l0Os.js";import{n as ye,t as be}from"./DangerZone-Ch2KNmob.js";import{c as xe,s as P,t as F,u as Se}from"./policyLogic-nqL3E08V.js";import{n as I,r as L}from"./TextArea-BQPdfjO_.js";import{u as R}from"./index-LsagdEq-.js";import{t as z}from"./TextLink-CCc3WEdm.js";import{t as B}from"./SegmentedControl-D2kj3j7u.js";import{t as V}from"./Card-WONLvqGM.js";import{t as H}from"./Select-CpWLZnId.js";import{t as U}from"./Switch-DHX-YYPr.js";import{E as W,O as Ce,S as we,T as G,a as K,b as Te,d as Ee,f as De,g as q,h as Oe,i as ke,l as Ae,m as je,n as Me,o as Ne,p as J,r as Pe,s as Fe,t as Ie,u as Le,v as Re,w as Y,x as ze,y as Be}from"./describe-CtmmeUfI.js";var Ve={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};Ve.node;var He=o(Ve),X=e(l(),1),Z=i(),Ue=e=>`/tasks/${encodeURIComponent(e)}`;function Q(e){return v(e)&&(e.status===404||e.status===405||e.status===501)}function We({summary:e,errorCount:t}){return(0,Z.jsxs)(V,{stack:!0,title:`Summary`,testId:`automation-summary`,children:[(0,Z.jsx)(`p`,{className:`text-sm break-words`,children:e}),t>0&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-danger`,children:[(0,Z.jsx)(C,{"aria-hidden":!0,className:`size-4 shrink-0`}),t===1?`1 field needs attention`:`${t} fields need attention`]})]})}async function Ge(e,t,n){return e&&!n?S(Y(e,`/preview`)):se(`/api/automations/preview`,t)}function Ke({automationId:e,dirty:t,getInput:n,currentKey:r}){let[i,a]=(0,X.useState)({status:`idle`}),o=async()=>{let r=n();if(!r)M.error(`Fix the highlighted fields to preview the task`);else{a({status:`loading`});try{let n=await Ge(e,r,t);a({status:`done`,preview:n,key:JSON.stringify(r)})}catch(e){a(Q(e)?{status:`unsupported`}:{status:`error`,error:e})}}};return(0,Z.jsxs)(V,{stack:!0,title:`Preview`,description:`See the task an occurrence would create, and when it would run next.`,testId:`automation-preview`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{icon:(0,Z.jsx)(d,{className:`size-4`}),busy:i.status===`loading`,onClick:()=>void o(),children:`Preview resulting task`})}),i.status===`unsupported`&&(0,Z.jsx)(O,{capability:`Task preview`,reason:`This coordinator does not offer automation previews.`,fallback:`Read the summary above, or save and use Run now to see a real task.`}),i.status===`error`&&(0,Z.jsx)(w,{compact:!0,title:`Could not preview`,error:i.error,onRetry:()=>void o()}),i.status===`done`&&(0,Z.jsx)(qe,{preview:i.preview,stale:i.key!==r})]})}function qe({preview:e,stale:t}){let{task:n}=e;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[t&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-warning`,role:`status`,children:[(0,Z.jsx)(C,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),`The form changed since this preview. Preview again to refresh it.`]}),(0,Z.jsx)(`p`,{className:`text-sm break-words text-muted`,children:e.summary}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border bg-surface-2 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`min-w-0 font-medium break-words`,children:n.title}),(0,Z.jsx)(ue,{priority:n.priority,muted:!0,className:`shrink-0 text-xs`})]}),n.objective?(0,Z.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:n.objective}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective.`}),n.acceptanceCriteria.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-1 text-xs font-medium text-muted`,children:[(0,Z.jsx)(h,{"aria-hidden":!0,className:`size-3.5`}),`Acceptance criteria`]}),(0,Z.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm`,children:n.acceptanceCriteria.map((e,t)=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},t))})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Next occurrences`}),e.next.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No scheduled times: this trigger fires on demand, on a webhook, or when a task is done.`}):(0,Z.jsx)(`ol`,{className:`mt-1 flex flex-col gap-0.5 text-sm`,children:e.next.slice(0,5).map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,Z.jsx)(`time`,{dateTime:e,children:J(e)}),(0,Z.jsx)(`span`,{className:`text-muted`,children:x(e)})]},e))})]})]})}function Je({label:e,value:t,mono:n=!0}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 flex-1 rounded border border-border bg-surface px-2 py-1.5 text-xs break-all select-all ${n?`font-mono`:``}`,children:t}),(0,Z.jsx)(s,{size:`sm`,icon:(0,Z.jsx)(A,{className:`size-3.5`}),onClick:()=>void le(t,`${e} copied`),"aria-label":`Copy ${e.toLowerCase()}`,children:`Copy`})]})]})}function Ye({automation:e}){let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),d=e.webhookTokenSet||a!==null,f=async()=>{i(!1),n(!0);try{let t=await se(Y(e.id,`/webhook-token`)),n=D.safeParse(t);if(!n.success)throw Error(`The coordinator returned an unexpected token response`);let r=new URL(n.data.url,window.location.origin).toString();o({token:n.data.token,url:r}),M.success(d?`Webhook token rotated`:`Webhook token created`)}catch(e){Q(e)?l(!0):M.error(`Could not issue a webhook token: ${_(e)}`)}finally{n(!1)}};return(0,Z.jsxs)(V,{stack:!0,title:`Webhook`,description:`POST JSON to the URL with the token as a Bearer header. Filters decide which payloads fire.`,testId:`webhook-token`,children:[(0,Z.jsx)(`p`,{className:`flex items-center gap-1.5 text-sm`,children:d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(he,{"aria-hidden":!0,className:`size-4 shrink-0 text-success`}),`A token is set`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),`No token yet: webhook calls are rejected until you create one`]})}),c?(0,Z.jsx)(O,{capability:`Webhook tokens`,reason:`This coordinator does not issue webhook tokens.`}):(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{icon:(0,Z.jsx)(_e,{className:`size-4`}),busy:t,onClick:()=>d?i(!0):void f(),children:d?`Rotate token`:`Create token`})}),a&&(0,Z.jsxs)(`div`,{role:`alert`,className:`flex min-w-0 flex-col gap-3 rounded-md border border-warning bg-warning-soft p-3`,children:[(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,Z.jsx)(C,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),`This token is shown once. Copy it now.`]}),(0,Z.jsx)(Je,{label:`Token`,value:a.token}),(0,Z.jsx)(Je,{label:`URL`,value:a.url}),(0,Z.jsx)(Je,{label:`Example`,value:Ne(a.token,a.url)}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{size:`sm`,onClick:()=>o(null),children:`I have copied it`})})]}),(0,Z.jsx)(te,{open:r,onClose:()=>i(!1),title:`Rotate webhook token?`,description:`The current token stops working immediately. Update every sender with the new token.`,confirmLabel:`Rotate token`,busy:t,onConfirm:()=>void f()})]})}var Xe=[];function Ze({automationId:e,refreshKey:t,onRun:n}){let r=g(t=>t.occurrences[e]??Xe),i=g(e=>e.tasks),[a,o]=(0,X.useState)({status:`loading`}),s=(0,X.useCallback)(async t=>{o(e=>e.status===`done`?e:{status:`loading`});try{let n=await S(Y(e,`/history`),{},t);o({status:`done`,items:Re(n)})}catch(e){if(t?.aborted)return;o(Q(e)?{status:`unsupported`}:{status:`error`,error:e})}},[e]);(0,X.useEffect)(()=>{let e=new AbortController;return s(e.signal),()=>e.abort()},[s,t]);let c=q(a.status===`done`?a.items:[],r);return(0,Z.jsxs)(V,{stack:!0,title:`History`,description:`Occurrences of this automation. Routine successes are hidden from the board and appear only here.`,testId:`automation-history`,children:[a.status===`unsupported`&&(0,Z.jsx)(O,{capability:`Automation history`,reason:`This coordinator does not serve stored history; only occurrences seen live in this session are shown.`}),a.status===`error`&&(0,Z.jsx)(w,{compact:!0,title:`Could not load history`,error:a.error,onRetry:()=>void s()}),a.status===`loading`&&c.length===0?(0,Z.jsx)(b,{label:`Loading history…`,className:`py-4`}):c.length===0&&a.status!==`error`?(0,Z.jsx)(E,{className:`py-4`,icon:(0,Z.jsx)(He,{className:`size-6`}),title:`No occurrences yet`,description:`Occurrences appear here when the trigger fires or you run it.`,action:{label:`Run now`,onClick:n,icon:(0,Z.jsx)(ve,{className:`size-4`})}}):(0,Z.jsx)(`ol`,{className:`flex flex-col divide-y divide-border`,children:c.map(e=>{let t=Be(e),n=e.taskId?i[e.taskId]:void 0,r=[e.reason,e.outcome].filter(Boolean).join(` · `);return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 first:pt-0 last:pb-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(f,{kind:`occurrence`,value:e.state,size:`sm`}),(0,Z.jsx)(`time`,{dateTime:t,className:`text-sm`,children:J(t)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:x(t)})]}),r&&(0,Z.jsx)(`p`,{className:`text-sm break-words text-muted`,children:r}),e.taskId&&(0,Z.jsxs)(z,{to:Ue(e.taskId),variant:`action`,size:`sm`,className:`self-start`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n?`Task: ${n.title}`:`Open task`}),n?.hiddenFromBoard&&(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:`(hidden from board)`})]})]},e.id)})})]})}var Qe=`/automations`,$e=e=>`/automations/${encodeURIComponent(e)}`,et=`sy:automation-draft`;function tt(){let{automationId:e=`new`}=c();return(0,Z.jsx)(nt,{automationId:e},e)}function nt({automationId:e}){let t=e===`new`,n=g(e=>e.hydrated),r=W(t?void 0:e),[i,a]=(0,X.useState)({status:`idle`}),o=(0,X.useCallback)(async()=>{a({status:`loading`});try{let t=await S(Y(e)),n=y.safeParse(t);if(!n.success){a({status:`fatal`,error:Error(`The coordinator returned this automation in an unexpected format.`)});return}G.getState().put(n.data),a({status:`idle`})}catch(e){v(e)&&e.status===404?a({status:`notfound`}):a({status:`error`,error:e})}},[e]),s=!t&&!r;return(0,X.useEffect)(()=>{s&&i.status===`idle`&&o()},[s,i.status,o]),t?(0,Z.jsx)(ot,{automation:null}):r?(0,Z.jsx)(ot,{automation:r}):i.status===`notfound`?(0,Z.jsx)(E,{icon:(0,Z.jsx)(R,{className:`size-8`}),title:`Automation not found`,description:`It may have been deleted, or the link is wrong.`,action:{label:`Back to automations`,to:Qe}}):i.status===`error`?(0,Z.jsx)(w,{title:`Could not load this automation`,error:i.error,onRetry:()=>void o()}):i.status===`fatal`?(0,Z.jsx)(T,{error:i.error}):(0,Z.jsx)(b,{label:n?`Loading automation…`:`Loading…`})}function rt(e){let t=Ee({projectId:e,timezone:Oe()});try{let e=sessionStorage.getItem(et);if(!e)return t;let n=JSON.parse(e);return!n||typeof n!=`object`?t:{...t,...n,filters:Array.isArray(n.filters)?n.filters:[]}}catch{return t}}function it(e){try{e?sessionStorage.setItem(et,JSON.stringify(e)):sessionStorage.removeItem(et)}catch{}}var $=e=>JSON.stringify(Le(e));function at(e){if(!v(e))return{};let t=e.details,n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.issues)?t.issues:[],r={};for(let e of n){if(!e||typeof e!=`object`)continue;let{path:t,message:n}=e;if(!Array.isArray(t)||typeof n!=`string`)continue;let i=De(t);i!==`form`&&!r[i]&&(r[i]=n)}return r}function ot({automation:e}){let i=t(),o=r(),c=fe(Qe),l=ge(),u=l===`desktop`,d=re(),f=ie(),m=g(e=>e.hosts),h=g(e=>e.profiles),v=g(e=>e.tasks),y=g(e=>e.projects),b=e===null,x=(0,X.useId)(),S=(0,X.useRef)(null),[w,T]=(0,X.useState)(()=>e?Ae(e):rt(d[0]?.id)),[E,D]=(0,X.useState)(()=>$(w)),[O,k]=(0,X.useState)(!1),[le,A]=(0,X.useState)({}),[ue,j]=(0,X.useState)(!1),[de,he]=(0,X.useState)(!1),[_e,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(0),R=(0,X.useRef)(e?.updatedAt),z=$(w),B=z!==E;(0,X.useEffect)(()=>{if(!e||e.updatedAt===R.current)return;R.current=e.updatedAt;let t=Ae(e),n=$(t);z===E?(T(t),F(!1)):n!==z&&F(!0),D(n)},[e,z,E]),(0,X.useEffect)(()=>{b&&it(w)},[b,w]),(0,X.useEffect)(()=>{b&&!w.projectId&&d[0]&&T(e=>e.projectId?e:{...e,projectId:d[0].id})},[b,w.projectId,d]);let V=(0,X.useCallback)((e,t)=>{T(n=>({...n,[e]:t})),A(e=>Object.keys(e).length?{}:e)},[]),H=(0,X.useMemo)(()=>we(w),[w]),U={...le,...O?H.errors:{}},W=e=>U[e],K=y[w.projectId],De=w.hostId||K?.defaultHostId||null,q=De?m[De]:void 0,ke=w.profileId||K?.defaultProfileId||null,je=(0,X.useCallback)(e=>v[e]?.title,[v]),Me=(0,X.useMemo)(()=>Te(Le(w),{projectName:K?.name,hostName:w.hostId?m[w.hostId]?.name??null:null,profileName:w.profileId?h[w.profileId]?.name??null:null,taskTitle:je}),[w,K?.name,m,h,je]),Ne=()=>{requestAnimationFrame(()=>{S.current?.querySelector(`[aria-invalid="true"]`)?.focus()})},J=()=>(k(!0),H.input||Ne(),H.input),Pe=async()=>{let t=J();if(!t)M.error(`Fix the highlighted fields before saving`);else{j(!0);try{if(b){let e=await se(`/api/automations`,t);if(!e||typeof e!=`object`||!e.id)throw Error(`The coordinator did not return the new automation`);G.getState().put(e),it(null),M.success(`Created ${e.name}`),i($e(e.id),{replace:!0,state:o.state});return}let n=await ne(Y(e.id),t);if(n&&typeof n==`object`&&n.id){G.getState().put(n),R.current=n.updatedAt;let e=Ae(n);T(e),D($(e))}else D(z);F(!1),k(!1),M.success(`Saved ${t.name}`)}catch(e){let t=at(e);A(t),Object.keys(t).length&&Ne(),M.error(`Could not save: ${_(e)}. Your changes are kept.`)}finally{j(!1)}}},Fe=async()=>{if(e){he(!0);try{await ae(Y(e.id)),N(!1),M.success(`Deleted ${e.name}`),c(),G.getState().remove(e.id)}catch(e){M.error(`Could not delete: ${_(e)}`)}finally{he(!1)}}},{busy:Ie,run:Re}=Ce(()=>L(e=>e+1)),ze=e?!!Ie[e.id]:!1,Be=()=>e&&void Re(e),Ve=()=>{let e=Ee({projectId:d[0]?.id,timezone:Oe()});T(e),k(!1),it(null)},He=b?`New automation`:e.name,Ue=(0,Z.jsxs)(Z.Fragment,{children:[!b&&(0,Z.jsx)(s,{icon:(0,Z.jsx)(ve,{className:`size-4`}),busy:ze,onClick:Be,title:B?`Runs the saved version`:void 0,children:`Run now`}),b&&B&&(0,Z.jsx)(s,{variant:`ghost`,icon:(0,Z.jsx)(pe,{className:`size-4`}),onClick:Ve,children:`Discard draft`})]}),Q=e=>(0,Z.jsx)(s,{type:`submit`,form:x,variant:`primary`,busy:ue,block:e,icon:(0,Z.jsx)(ye,{className:`size-4`}),children:b?`Create automation`:`Save`}),Ge=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(We,{summary:Me,errorCount:O?Object.keys(H.errors).length:0}),(0,Z.jsx)(Ke,{automationId:e?.id??null,dirty:B,getInput:J,currentKey:JSON.stringify(H.input)}),e&&e.trigger.kind===`webhook`&&(0,Z.jsx)(Ye,{automation:e}),e&&(0,Z.jsx)(Ze,{automationId:e.id,refreshKey:I,onRun:Be})]});return(0,Z.jsxs)(`div`,{"data-testid":`automation-editor`,className:`flex w-full min-w-0 flex-col gap-4 px-4 pt-4 md:px-6`,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsxs)(a,{to:Qe,onClick:me(c),className:`tap inline-flex items-center gap-1 self-start rounded text-sm text-muted hover:text-text`,children:[(0,Z.jsx)(ee,{"aria-hidden":!0,className:`size-4`}),`Automations`]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`min-w-0 text-lg font-semibold break-words`,children:He}),B&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,Z.jsx)(p,{"aria-hidden":!0,className:`size-3.5`}),`Unsaved changes`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Ue,u&&Q()]})]})]}),(0,Z.jsx)(ce,{subject:`automations`,consequence:`Changes are sent once the coordinator is reachable again.`}),q&&q.connectivity!==`connected`&&(0,Z.jsx)(oe,{compact:!0,hostName:q.name,connectivity:q.connectivity,lastSeenAt:q.lastSeenAt,detail:`Occurrences are still recorded; their tasks wait until the host is reachable.`}),P&&(0,Z.jsxs)(`p`,{role:`status`,className:`flex items-start gap-1.5 rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(C,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-warning`}),`This automation changed elsewhere. Saving overwrites those changes with yours.`]}),(0,Z.jsxs)(`div`,{className:n(`grid min-w-0 gap-4`,u?`grid-cols-[minmax(0,1fr)_minmax(320px,400px)] items-start`:`grid-cols-1`),children:[(0,Z.jsxs)(`form`,{id:x,ref:S,noValidate:!0,"aria-label":He,onSubmit:e=>{e.preventDefault(),Pe()},className:`flex min-w-0 flex-col gap-4`,children:[(0,Z.jsx)(st,{draft:w,update:V,err:W,projects:d}),(0,Z.jsx)(ut,{draft:w,update:V,err:W,tasks:v,projectsById:y,savedAutomation:e,segmented:l!==`mobile`}),(0,Z.jsx)(dt,{draft:w,setDraft:T,err:W}),(0,Z.jsx)(ft,{draft:w,update:V,err:W}),(0,Z.jsx)(mt,{draft:w,update:V,err:W,hosts:f,profiles:Object.values(h).sort((e,t)=>e.name.localeCompare(t.name)),defaultHostName:K?.defaultHostId?m[K.defaultHostId]?.name:void 0,defaultProfileName:K?.defaultProfileId?h[K.defaultProfileId]?.name:void 0,selectedProfileMissing:!!ke&&!h[ke]}),(0,Z.jsx)(ht,{draft:w,update:V}),(0,Z.jsx)(gt,{draft:w,update:V,err:W}),(0,Z.jsx)(_t,{draft:w,update:V,err:W,projectChecks:K?.checks}),U.form&&(0,Z.jsx)(xe,{children:U.form})]}),(0,Z.jsx)(`aside`,{"aria-label":`Summary, preview and history`,className:`flex min-w-0 flex-col gap-4`,children:Ge})]}),!b&&e&&(0,Z.jsx)(be,{description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,children:(0,Z.jsx)(s,{variant:`danger`,icon:(0,Z.jsx)(Se,{className:`size-4`}),onClick:()=>N(!0),children:`Delete automation`})}),u?(0,Z.jsx)(`div`,{className:`h-4`}):(0,Z.jsxs)(`div`,{className:`sticky bottom-0 z-10 -mx-4 flex items-center gap-3 border-t border-border bg-surface px-4 py-2 md:-mx-6 md:px-6`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted`,children:B?`Unsaved changes`:b?`Not saved yet`:`All changes saved`}),Q()]}),(0,Z.jsx)(te,{open:_e,onClose:()=>N(!1),title:`Delete ${e?.name??`automation`}?`,description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,confirmLabel:`Delete automation`,confirmIcon:(0,Z.jsx)(Se,{className:`size-4`}),busy:de,onConfirm:()=>void Fe()})]})}function st({draft:e,update:t,err:n,projects:r}){return(0,Z.jsxs)(V,{stack:!0,title:`Basics`,children:[(0,Z.jsx)(P,{label:`Name`,error:n(`name`),children:n=>(0,Z.jsx)(L,{...n,value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:`Daily dependency check`,autoComplete:`off`})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(P,{label:`Project`,error:n(`projectId`),hint:r.length===0?(0,Z.jsxs)(Z.Fragment,{children:[`No projects yet.`,` `,(0,Z.jsx)(z,{to:`/settings/projects`,children:`Add a project in Settings`}),`.`]}):void 0,children:n=>(0,Z.jsxs)(H,{...n,value:e.projectId,onChange:e=>t(`projectId`,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose a project`}),r.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(P,{label:`Status`,hint:`Disabled automations keep their history and can still run manually.`,children:n=>(0,Z.jsx)(U,{...n,checked:e.enabled,onChange:e=>t(`enabled`,e),label:`Enabled`,onText:`Enabled`,offText:`Disabled`,className:`self-start`})})]})]})}var ct=[`manual`,`once`,`cron`,`webhook`,`dependency`],lt={manual:`Runs only when you press Run now (or from the CLI).`,once:`Runs a single time at the chosen moment.`,cron:`Runs on a timezone-aware cron schedule.`,webhook:`Runs when an authenticated JSON POST arrives at this automation's webhook URL.`,dependency:`Runs when the chosen task is done.`};function ut({draft:e,update:t,err:n,tasks:r,projectsById:i,savedAutomation:a,segmented:o}){let s=g(e=>e.hydrated),c=e.triggerKind===`cron`?ze(e.cronExpr):null,l=e.triggerKind===`cron`&&!c?Fe(e.cronExpr,e.cronTimezone.trim()||void 0)??`Valid expression (no plain-language description available)`:null,u=(0,X.useMemo)(()=>{try{return Intl.supportedValuesOf?.(`timeZone`)}catch{return}},[]),d=(0,X.useId)(),f=Oe(),ee=(0,X.useMemo)(()=>Object.values(r).filter(t=>t.state!==`canceled`||t.id===e.dependencyTaskId).sort((e,t)=>e.title.localeCompare(t.title)),[r,e.dependencyTaskId]),p=e.triggerKind===`once`?je(e.onceAt):``;return(0,Z.jsxs)(V,{stack:!0,title:`Trigger`,description:lt[e.triggerKind],children:[o?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`text-sm font-medium`,children:`Trigger kind`}),(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsx)(B,{label:`Trigger kind`,value:e.triggerKind,onChange:e=>t(`triggerKind`,e),options:ct.map(e=>({value:e,label:K[e]}))})})]}):(0,Z.jsx)(P,{label:`Trigger kind`,children:n=>(0,Z.jsx)(H,{...n,value:e.triggerKind,onChange:e=>t(`triggerKind`,e.target.value),children:ct.map(e=>(0,Z.jsx)(`option`,{value:e,children:K[e]},e))})}),e.triggerKind===`once`&&(0,Z.jsx)(P,{label:`Run at`,error:n(`onceAt`),hint:`Local time (${f})${p?`; saved as ${p}`:``}.`,children:n=>(0,Z.jsx)(L,{...n,type:`datetime-local`,value:e.onceAt,onChange:e=>t(`onceAt`,e.target.value)})}),e.triggerKind===`cron`&&(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(P,{label:`Cron expression`,error:n(`cronExpr`)??c??void 0,hint:`minute hour day-of-month month day-of-week, e.g. 0 9 * * 1-5`,children:n=>(0,Z.jsx)(L,{...n,"aria-invalid":c?!0:n[`aria-invalid`],value:e.cronExpr,onChange:e=>t(`cronExpr`,e.target.value),className:`font-mono`,autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`})}),(0,Z.jsx)(P,{label:`Timezone`,error:n(`cronTimezone`),hint:e.cronTimezone.trim()===f?`IANA timezone name; daylight saving is handled.`:(0,Z.jsxs)(z,{onClick:()=>t(`cronTimezone`,f),children:[`Use this device's timezone (`,f,`)`]}),children:n=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{...n,list:u?d:void 0,value:e.cronTimezone,onChange:e=>t(`cronTimezone`,e.target.value),autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`}),u&&(0,Z.jsx)(`datalist`,{id:d,children:u.map(e=>(0,Z.jsx)(`option`,{value:e},e))})]})}),l&&(0,Z.jsxs)(`p`,{className:`flex items-start gap-1.5 text-sm sm:col-span-2`,"aria-live":`polite`,"data-testid":`cron-description`,children:[(0,Z.jsx)(k,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:l})]})]}),e.triggerKind===`webhook`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm text-muted`,children:[(0,Z.jsxs)(`p`,{children:[`Senders POST a JSON body (up to 256 KB) with`,` `,(0,Z.jsx)(`code`,{children:`Authorization: Bearer <token>`}),`. Use the filters below to fire only for matching payloads, and `,(0,Z.jsx)(`code`,{children:`{{payload.<path>}}`}),` to copy payload values into the task.`]}),a?a.trigger.kind===`webhook`?(0,Z.jsxs)(`p`,{children:[`Token:`,` `,a.webhookTokenSet?`set (see Webhook below to rotate)`:`not created yet`]}):(0,Z.jsx)(`p`,{children:`Save to switch this automation to a webhook trigger, then create a token.`}):(0,Z.jsx)(`p`,{children:`Save the automation to create its webhook token and URL.`})]}),e.triggerKind===`dependency`&&(0,Z.jsx)(P,{label:`When this task is done`,error:n(`dependencyTaskId`),hint:`Fires once each time the task enters Done.`,children:n=>(0,Z.jsxs)(H,{...n,value:e.dependencyTaskId,onChange:e=>t(`dependencyTaskId`,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose a task`}),e.dependencyTaskId&&!r[e.dependencyTaskId]&&(0,Z.jsx)(`option`,{value:e.dependencyTaskId,children:s?`Deleted task`:`Loading task…`}),ee.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.title,i[e.projectId]?` (${i[e.projectId].name})`:``,e.state===`done`?` - done`:``]},e.id))]})})]})}function dt({draft:e,setDraft:t,err:n}){let r=(e,n)=>t(t=>({...t,filters:t.filters.map((t,r)=>r===e?{...t,...n}:t)})),i=e.triggerKind===`webhook`;return(0,Z.jsxs)(V,{stack:!0,title:`Filters`,description:`Filters apply to webhook payloads. Each row compares a dot path (for example pull_request.base.ref) with an exact value; all rows must match. Payloads that do not match are recorded as Filtered out.`,children:[!i&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Filters are ignored unless the trigger is Webhook.`}),e.filters.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No filters: every payload fires.`}),e.filters.map((e,i)=>(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-end gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,Z.jsx)(P,{label:`Path ${i+1}`,error:n(`filters.${i}.path`),children:t=>(0,Z.jsx)(L,{...t,value:e.path,onChange:e=>r(i,{path:e.target.value}),placeholder:`action`,className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})}),(0,Z.jsx)(P,{label:`Equals ${i+1}`,error:n(`filters.${i}.equals`),className:`col-start-1 row-start-2 sm:col-start-auto sm:row-start-auto`,children:t=>(0,Z.jsx)(L,{...t,value:e.equals,onChange:e=>r(i,{equals:e.target.value}),placeholder:`opened`})}),(0,Z.jsx)(m,{label:`Remove filter ${i+1}`,icon:(0,Z.jsx)(pe,{className:`size-4`}),onClick:()=>t(e=>({...e,filters:e.filters.filter((e,t)=>t!==i)}))})]},i)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{size:`sm`,icon:(0,Z.jsx)(N,{className:`size-3.5`}),onClick:()=>t(e=>({...e,filters:[...e.filters,{path:``,equals:``}]})),children:`Add filter`})})]})}function ft({draft:e,update:t,err:n}){return(0,Z.jsxs)(V,{stack:!0,title:`Task template`,description:`Use ${ke.join(`, `)} in the title, objective, criteria and grouping key.`,children:[(0,Z.jsx)(P,{label:`Task title`,error:n(`title`),children:n=>(0,Z.jsx)(L,{...n,value:e.title,onChange:e=>t(`title`,e.target.value),placeholder:`Triage new issues for {{date}}`})}),(0,Z.jsx)(P,{label:`Objective`,error:n(`objective`),children:n=>(0,Z.jsx)(I,{...n,minRows:4,value:e.objective,onChange:e=>t(`objective`,e.target.value)})}),(0,Z.jsx)(P,{label:`Acceptance criteria`,error:n(`criteria`),hint:`One criterion per line.`,optional:!0,children:n=>(0,Z.jsx)(I,{...n,minRows:3,value:e.criteria,onChange:e=>t(`criteria`,e.target.value)})}),(0,Z.jsx)(P,{label:`Priority`,error:n(`priority`),children:n=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(de,{priority:e.priority}),(0,Z.jsx)(j,{...n,value:e.priority,onChange:e=>t(`priority`,e),className:`sm:max-w-48`})]})})]})}function pt({legend:e,value:t,options:r,onChange:i,hint:a}){let o=(0,X.useId)();return(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:e}),(0,Z.jsx)(`div`,{className:`grid min-w-0 gap-2 sm:grid-cols-3`,children:r.map(e=>(0,Z.jsxs)(`label`,{className:n(`tap flex min-w-0 cursor-pointer items-start gap-2 rounded-md border p-2.5 text-sm`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-1`,t===e.value?`border-accent bg-accent-soft`:`border-border hover:bg-surface-2`),children:[(0,Z.jsx)(`input`,{type:`radio`,name:o,value:e.value,checked:t===e.value,onChange:()=>i(e.value),className:`mt-0.5 size-4 shrink-0 accent-[var(--color-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,Z.jsx)(`span`,{className:`block text-xs text-muted`,children:e.explanation})]})]},e.value))}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:a})]})}function mt({draft:e,update:t,err:n,hosts:r,profiles:i,defaultHostName:a,defaultProfileName:o,selectedProfileMissing:s}){return(0,Z.jsxs)(V,{stack:!0,title:`Where and how it runs`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(P,{label:`Host`,error:n(`hostId`),children:n=>(0,Z.jsxs)(H,{...n,value:e.hostId,onChange:e=>t(`hostId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,a?` (${a})`:``]}),e.hostId&&!r.some(t=>t.id===e.hostId)&&(0,Z.jsx)(`option`,{value:e.hostId,children:`Unknown host`}),r.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id))]})}),(0,Z.jsx)(P,{label:`Profile`,error:n(`profileId`),hint:s?`The selected profile is no longer available.`:void 0,children:n=>(0,Z.jsxs)(H,{...n,value:e.profileId,onChange:e=>t(`profileId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,o?` (${o})`:``]}),e.profileId&&!i.some(t=>t.id===e.profileId)&&(0,Z.jsx)(`option`,{value:e.profileId,children:`Unknown profile`}),i.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,Z.jsx)(pt,{legend:`Mode`,value:e.mode,options:Me,onChange:e=>t(`mode`,e)}),(0,Z.jsx)(P,{label:`Grouping key`,optional:e.mode!==`continue`,error:n(`groupingKey`),hint:`Occurrences with the same rendered key are the same work: Continue reuses that task and overlap checks compare it. Supports template variables, e.g. pr-{{payload.number}}.`,children:n=>(0,Z.jsx)(L,{...n,value:e.groupingKey,onChange:e=>t(`groupingKey`,e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})})]})}function ht({draft:e,update:t}){let n=e.triggerKind===`cron`||e.triggerKind===`once`;return(0,Z.jsxs)(V,{stack:!0,title:`Overlap and missed runs`,children:[(0,Z.jsx)(pt,{legend:`When previous work is still open`,value:e.overlap,options:Pe,onChange:e=>t(`overlap`,e)}),(0,Z.jsx)(pt,{legend:`Missed runs`,value:e.missed,options:Ie,onChange:e=>t(`missed`,e),hint:n?`A run is missed when the coordinator was down at its scheduled time.`:`Only applies to Schedule and Once triggers.`})]})}function gt({draft:e,update:t,err:n}){return(0,Z.jsxs)(V,{stack:!0,title:`Limits`,description:`Continuation prompts the agent to keep going after a turn ends without finishing. It is off by default.`,children:[(0,Z.jsx)(P,{label:`Automatic continuation`,children:n=>(0,Z.jsx)(U,{...n,checked:e.continuationEnabled,onChange:e=>t(`continuationEnabled`,e),label:`Automatic continuation`,className:`self-start`})}),e.continuationEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{label:`Continuation objective`,error:n(`continuationObjective`),hint:`What the agent must achieve before it reports done.`,children:n=>(0,Z.jsx)(I,{...n,minRows:2,value:e.continuationObjective,onChange:e=>t(`continuationObjective`,e.target.value)})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(P,{label:`Max continuations`,error:n(`maxContinuations`),hint:`1–50`,children:n=>(0,Z.jsx)(L,{...n,type:`number`,inputMode:`numeric`,min:1,max:50,step:1,value:e.maxContinuations,onChange:e=>t(`maxContinuations`,e.target.value)})}),(0,Z.jsx)(P,{label:`Max elapsed minutes`,error:n(`maxElapsedMinutes`),hint:`1–1440`,children:n=>(0,Z.jsx)(L,{...n,type:`number`,inputMode:`numeric`,min:1,max:1440,step:1,value:e.maxElapsedMinutes,onChange:e=>t(`maxElapsedMinutes`,e.target.value)})}),(0,Z.jsx)(P,{label:`Continuation budget: tokens`,optional:!0,error:n(`maxTokens`),children:n=>(0,Z.jsx)(L,{...n,type:`number`,inputMode:`numeric`,min:1,step:1,value:e.maxTokens,onChange:e=>t(`maxTokens`,e.target.value)})}),(0,Z.jsx)(P,{label:`Continuation budget: cost (USD)`,optional:!0,error:n(`maxCostUsd`),children:n=>(0,Z.jsx)(L,{...n,type:`number`,inputMode:`decimal`,min:.01,step:.01,value:e.maxCostUsd,onChange:e=>t(`maxCostUsd`,e.target.value)})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:F})]})]})}function _t({draft:e,update:t,err:n,projectChecks:r}){let i=r&&r.length>0?`the project's checks (${r.join(`, `)})`:`the project's checks`;return(0,Z.jsxs)(V,{stack:!0,title:`Review`,children:[(0,Z.jsx)(P,{label:`Checks`,optional:!0,error:n(`checks`),hint:`One command per line. Leave empty to use ${i}.`,children:n=>(0,Z.jsx)(I,{...n,minRows:2,value:e.checks,onChange:e=>t(`checks`,e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`})}),(0,Z.jsx)(P,{label:`Human review`,hint:`When on, finished work waits in Review for you instead of completing on passing checks.`,children:n=>(0,Z.jsx)(U,{...n,checked:e.requireHumanReview,onChange:e=>t(`requireHumanReview`,e),label:`Require human review`,onText:`Required`,offText:`Not required`,className:`self-start`})})]})}export{tt as default};
|
|
2
|
-
//# sourceMappingURL=AutomationView-CMDz-eFh.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{S as e,a as t,i as n,t as r,y as i}from"./Button-BKQW9doW.js";import{h as a,i as o,l as s}from"./Overlay-zQBNtPf6.js";import{L as c,Nt as l,Pt as u,f as d,jt as f,n as p}from"./states-BXOts8eT.js";import{t as m}from"./arrow-up-Bzh112dp.js";import{t as h}from"./useBreakpoint-kT0J1Dnk.js";import{t as g}from"./UINodeRenderer-JQy6g7ZB.js";import{n as _}from"./TextArea-BQPdfjO_.js";import{t as v}from"./TextLink-CCc3WEdm.js";import{i as y,r as b}from"./Tabs-DZ2T9VBY.js";var x=e(i(),1),S=`An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.`,C=[{id:`abort`,label:`Stop the run`,tone:`danger`},{id:`message`,label:`Send a message to Pi`,tone:`primary`}];function w(e){if(e.t===`actions`)return e;if(e.t===`section`)for(let t of e.children){let e=w(t);if(e)return e}return null}function T(e){return e.state===`unsupported`||e.source.kind===`unsupported_custom`}function E(e){let t=(w(e.presentation)?.actions??[]).filter(e=>e.id===`abort`||e.id===`message`).map(e=>({id:e.id,label:e.label,tone:e.tone==="default"?`secondary`:e.tone??(e.id===`abort`?`danger`:`primary`)}));return{answerable:e.state===`unsupported`&&e.resolution===null,actions:t.length>0?t:C,copy:S}}function D(e){return e===`running`||e===`waiting_input`?`followUp`:`prompt`}var O=n();function k(e){switch(e.t){case`form`:case`confirm`:case`actions`:return!0;case`list`:return e.items.some(k);case`section`:return e.children.some(k);case`tabs`:return e.tabs.some(e=>e.children.some(k));default:return!1}}function A(e){return e===`host`?`the host`:e===`pi`?`Pi`:`a device`}function j({interaction:e,readOnlyReason:n,className:i,onAnswered:o,id:s,sticky:m,flush:_}){let v=c(e=>e.upsertInteraction),[y,b]=(0,x.useState)(!1),[S,C]=(0,x.useState)(null),[w,E]=(0,x.useState)(null),[j,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(null),I=P&&P.id===e.id&&P.revision>e.revision?P:e,R=I.state===`pending`,z=T(I),B=c(e=>e.sessions[I.sessionId]?.runtime),[H,U]=(0,x.useState)(!1),[W,G]=(0,x.useState)(``),K=async e=>{b(!0),C(null),N(e);try{let t=await f(`/api/interactions/${encodeURIComponent(I.id)}/answer`,{revision:I.revision,response:e});return t?.interaction&&(v(t.interaction),F(t.interaction),o?.(t.interaction)),!0}catch(e){if(u(e,`already_answered`)){let t=e.details?.interaction;t&&(v(t),F(t)),E(t?.resolution?.summary??`answered on another device`)}else C(e);return!1}finally{b(!1)}},q=async()=>{let e=W.trim();if(e){b(!0),C(null);try{await f(`/api/sessions/${encodeURIComponent(I.sessionId)}/prompt`,{text:e,mode:D(B)})}catch(e){C(e),b(!1);return}b(!1),await K({kind:`action`,actionId:`message`})&&(U(!1),G(``))}},J=h();return R&&!w&&!z&&L(I.presentation)?(0,O.jsx)(V,{id:s,interaction:I,node:I.presentation,onRespond:e=>void K(e),busy:y,disabled:!!n,mobile:J===`mobile`,sticky:m??!0,flush:_??!1,className:i}):(0,O.jsxs)(`article`,{id:s,"aria-label":`Question: ${I.title}`,className:t(`flex min-w-0 flex-col gap-3 border-l-2 py-1 pl-3`,R?`border-warning`:`border-border`,i),children:[(0,O.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,O.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-semibold break-words`,children:I.title}),(0,O.jsx)(a,{kind:`interaction`,value:I.state,size:`sm`})]}),w&&(0,O.jsxs)(`p`,{role:`status`,className:`rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[`Already answered: `,w]}),z?(0,O.jsx)(M,{interaction:I,readOnlyReason:n??null,busy:y,answered:w!==null,composing:H,message:W,setMessage:G,onAction:e=>{e===`message`?U(!0):K({kind:`action`,actionId:e})},onSend:()=>void q(),onCancelMessage:()=>U(!1)}):R&&!w?(0,O.jsxs)(O.Fragment,{children:[n&&(0,O.jsx)(`p`,{className:`text-sm text-muted`,children:n}),(0,O.jsx)(g,{node:I.presentation,onRespond:e=>void K(e),busy:y,disabled:!!n}),!n&&!k(I.presentation)&&(0,O.jsx)(`div`,{children:(0,O.jsx)(r,{busy:y,onClick:()=>void K({kind:`cancel`}),children:`Dismiss`})}),y&&(0,O.jsx)(`p`,{role:`status`,className:`text-sm text-muted`,children:`Sending answer… waiting for the host to confirm.`})]}):w?null:I.resolution?(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[I.state===`resolved`?`Answered`:`Closed`,` by`,` `,A(I.resolution.by),` `,d(I.resolution.at),`:`,` `,(0,O.jsx)(`span`,{className:`text-text`,children:I.resolution.summary})]}):(0,O.jsx)(`p`,{className:`text-sm text-muted`,children:I.state===`expired`?`This question expired before it was answered (Pi closed the dialog).`:`This question was canceled.`}),S!==null&&(0,O.jsx)(p,{compact:!0,title:`Answer not delivered`,error:l(S),onRetry:j?()=>void K(j):void 0})]})}function M({interaction:e,readOnlyReason:t,busy:n,answered:i,composing:a,message:o,setMessage:s,onAction:c,onSend:l,onCancelMessage:u}){let f=E(e);return(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted`,children:f.copy}),e.resolution?(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Chosen by `,A(e.resolution.by),` `,d(e.resolution.at),`: `,(0,O.jsx)(`span`,{className:`text-text`,children:e.resolution.summary})]}):!f.answerable||i?null:t?(0,O.jsx)(`p`,{className:`text-sm text-muted`,children:t}):a?(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,O.jsx)(_,{"aria-label":`Message for Pi`,value:o,onChange:e=>s(e.target.value),rows:3,autoFocus:!0,placeholder:`Tell Pi what to do instead`}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,O.jsx)(r,{variant:`primary`,busy:n,disabled:!o.trim(),onClick:l,children:`Send message`}),(0,O.jsx)(r,{disabled:n,onClick:u,children:`Cancel`})]})]}):(0,O.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.actions.map(e=>(0,O.jsx)(r,{variant:e.tone,busy:n&&e.id===`abort`,disabled:n,onClick:()=>c(e.id),children:e.label},e.id))})]})}function N(e){if(e.t!==`section`||e.children.length<2)return null;let t=e.children[e.children.length-1];if(t?.t!==`actions`)return null;let n=e.children.slice(0,-1);return n.some(k)?null:{body:{...e,children:n},actions:t}}function P(e,t){let n=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches;e?.scrollIntoView({behavior:n?`auto`:`smooth`,block:t})}function F(e){let[t,n]=(0,x.useState)(!0);return(0,x.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>n(!!e?.isIntersecting));return r.observe(t),()=>r.disconnect()},[e]),t}function I(e){if(e.t===`markdown`)return e.text;if(e.t===`section`)for(let t of e.children){let e=I(t);if(e!==null)return e}return null}function L(e){if(!N(e))return!1;let t=I(e);return t!==null&&(t.length>=400||t.split(`
|
|
2
|
-
`).length>=12)}function R(e){let t=/^\s*#{1,6}\s+(.+?)\s*(?:\n+|$)/.exec(e);return t?.[1]?{title:t[1],rest:e.slice(t[0].length)}:{title:null,rest:e}}function z(e){let t=[],n=!1;for(let r of e.split(`
|
|
3
|
-
`)){/^\s*```/.test(r)&&(n=!n);let e=n?null:/^##\s+(.+?)\s*$/.exec(r);e?.[1]&&t.push({text:e[1],id:y(e[1])})}return t}function B(e,t){let[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),o=e.join(`|`);(0,x.useEffect)(()=>{if(typeof IntersectionObserver>`u`||!e.length)return;let n=e.map(e=>t.current?.querySelector(`#${CSS.escape(e)}`)).filter(e=>!!e),i=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&r(t.target.id)},{rootMargin:`-56px 0px -70% 0px`});for(let e of n)i.observe(e);let o=()=>a(null);return window.addEventListener(`wheel`,o,{passive:!0}),window.addEventListener(`touchmove`,o,{passive:!0}),window.addEventListener(`keydown`,o),()=>{i.disconnect(),window.removeEventListener(`wheel`,o),window.removeEventListener(`touchmove`,o),window.removeEventListener(`keydown`,o)}},[o,t]);let s=i??n;return(0,x.useEffect)(()=>{let e=t.current;if(e){for(let t of e.querySelectorAll(`h2[data-active]`))delete t.dataset.active;if(s){let t=e.querySelector(`#${CSS.escape(s)}`);t&&(t.dataset.active=`true`)}}},[s,o,t]),[s,a]}function V({id:e,interaction:n,node:i,onRespond:c,busy:l,disabled:u,mobile:d,sticky:f,flush:p,className:h}){let _=(0,x.useRef)(null),y=(0,x.useRef)(null),S=(0,x.useRef)(null),C=F(S),[w,T]=(0,x.useState)(!1),E=N(i),{title:D,rest:k}=R((E?.body.t===`section`?E.body.children.find(e=>e.t===`markdown`):void 0)?.text??``),A=z(k),[j,M]=B(A.map(e=>e.id),_);if(E?.body.t!==`section`)return null;let I=E.actions.actions,L=E.body.children.find(e=>e.t===`section`),V=n.title,H=D??V,U=e=>{T(!1),c({kind:`action`,actionId:e})},W=(e,t)=>e===0||t===`primary`?`primary`:t===`danger`?`danger`:`secondary`,G=!u&&!C,K=`h-auto! min-h-9 min-w-0 py-1.5 text-left leading-tight whitespace-normal!`,q=e=>P(e,`start`);return(0,O.jsxs)(`article`,{id:e,"data-testid":`document-interaction`,"aria-label":`Question: ${V}`,className:t(`w-full min-w-0 self-stretch border-t border-border`,h),children:[(0,O.jsxs)(`header`,{className:t(`z-10 flex min-w-0 items-center gap-2 border-b border-border bg-bg px-4 py-2 md:px-6`,f&&(p?`md:sticky md:top-0`:`max-md:static md:sticky md:-top-3`)),children:[(0,O.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] leading-snug font-semibold md:text-sm`,children:H}),d&&(0,O.jsx)(a,{kind:`interaction`,value:n.state,size:`sm`,className:`[&>span]:sr-only`}),!u&&!C&&(0,O.jsx)(v,{size:`xs`,className:`shrink-0`,onClick:()=>P(S.current,`center`),children:`Jump to options ↓`})]}),L&&(0,O.jsx)(`aside`,{className:`mx-4 mt-3 rounded-md bg-warning-soft px-3 py-2 text-sm md:mx-6`,children:(0,O.jsx)(g,{node:L})}),(0,O.jsxs)(`div`,{className:`px-4 py-4 md:grid md:grid-cols-[13rem_minmax(0,1fr)] 2xl:grid-cols-[15rem_minmax(0,1fr)] md:gap-8 md:px-6`,children:[A.length>0&&(0,O.jsx)(`nav`,{"aria-label":`Plan sections`,className:`hidden md:block`,children:(0,O.jsxs)(`ol`,{className:`sticky top-16 flex flex-col gap-0.5 border-l border-border text-sm`,children:[(0,O.jsx)(`li`,{children:(0,O.jsx)(`button`,{type:`button`,className:`-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text`,onClick:()=>q(y.current),children:`Start`})}),A.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsx)(`button`,{type:`button`,"aria-current":j===e.id,className:`-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text aria-[current=true]:border-accent aria-[current=true]:text-text`,onClick:()=>{M(e.id),q(_.current?.querySelector(`#${CSS.escape(e.id)}`)??null)},children:e.text})},e.id))]})}),(0,O.jsx)(`div`,{ref:y,className:`min-w-0 scroll-mt-14`,children:(0,O.jsx)(`div`,{ref:_,className:`sy-prose-compact max-w-[80ch] min-w-0 2xl:max-w-[100ch] min-[1800px]:text-base [&_h2]:scroll-mt-14`,children:(0,O.jsx)(b,{text:k,headingIds:!0,className:`text-inherit`})})})]}),(0,O.jsxs)(`section`,{ref:S,"data-testid":`plan-options`,"aria-label":V,className:`border-t border-border px-4 py-3 md:px-6`,children:[(0,O.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:V}),!u&&(0,O.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 md:flex-row md:flex-wrap`,children:I.map((e,n)=>(0,O.jsx)(r,{variant:W(n,e.tone),size:`md`,disabled:l,className:t(K,`md:text-center`),onClick:()=>U(e.id),children:e.label},e.id))}),(0,O.jsx)(v,{size:`xs`,className:`mt-2`,icon:(0,O.jsx)(m,{"aria-hidden":!0,className:`size-3.5`}),onClick:()=>q(y.current),children:`Back to the plan start`})]}),G&&(0,O.jsx)(`div`,{"data-testid":`answer-bar`,className:t(`z-10 flex min-w-0 items-center gap-2 border-t border-border bg-bg px-4 py-2 md:gap-3 md:px-6`,f&&!p?`sticky -bottom-3`:`sticky bottom-0`),children:d?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(s,{label:`Plan start`,icon:(0,O.jsx)(m,{className:`size-4`}),variant:`secondary`,onClick:()=>q(y.current)}),I.length>2?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(r,{variant:`primary`,disabled:l,className:t(K,`flex-1`),onClick:()=>U(I[0].id),children:I[0].label}),(0,O.jsxs)(r,{variant:`secondary`,onClick:()=>T(!0),children:[`More (`,I.length-1,`)`]})]}):I.map((e,n)=>(0,O.jsx)(r,{variant:W(n,e.tone),disabled:l,className:t(K,`flex-1`),onClick:()=>U(e.id),children:e.label},e.id))]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`max-w-[16rem] min-w-0 shrink truncate text-sm font-medium`,title:V,children:V}),(0,O.jsx)(`div`,{className:`grid min-w-0 flex-1 grid-cols-[repeat(auto-fit,minmax(11rem,1fr))] gap-2`,children:I.map((e,n)=>(0,O.jsx)(r,{variant:W(n,e.tone),disabled:l,className:t(K,`w-full md:text-center`),onClick:()=>U(e.id),children:e.label},e.id))}),(0,O.jsx)(s,{label:`Plan start`,icon:(0,O.jsx)(m,{className:`size-4`}),variant:`secondary`,size:`sm`,onClick:()=>q(y.current)})]})}),(0,O.jsx)(o,{open:w,onClose:()=>T(!1),title:V,children:(0,O.jsx)(`div`,{className:`flex flex-col gap-2`,children:I.map((e,t)=>(0,O.jsx)(r,{block:!0,variant:W(t,e.tone),disabled:l,className:K,onClick:()=>U(e.id),children:e.label},e.id))})})]})}export{L as n,j as t};
|
|
4
|
-
//# sourceMappingURL=InteractionCard-Bhur-sU9.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,a as t,i as n,o as r,y as i}from"./Button-BKQW9doW.js";import{c as a,s as o}from"./Overlay-zQBNtPf6.js";import{S as s,T as c}from"./preload-helper-DOFsWE7_.js";import{i as l}from"./Copy-D6U5ewFc.js";var u={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};u.node;var d=r(u),f={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};f.node;var p=r(f),m={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};m.node;var h=r(m),g=e(i(),1),_=n();function v({trigger:e,items:n,align:r=`end`,side:i=`bottom`,label:u,className:d}){let[f,p]=(0,g.useState)(!1),m=(0,g.useId)(),h=(0,g.useRef)(null),v=(0,g.useRef)(null),b=e=>y(v.current,e);(0,g.useEffect)(()=>{if(!f)return;let e=o({root:v,onEscape:()=>{p(!1),h.current?.focus()},trapsFocus:!1});requestAnimationFrame(()=>y(v.current,`first`));let t=e=>{!v.current?.contains(e.target)&&!h.current?.contains(e.target)&&p(!1)};return document.addEventListener(`pointerdown`,t),()=>{e(),document.removeEventListener(`pointerdown`,t)}},[f]);let x=(e=!0)=>{p(!1),e&&h.current?.focus()};return(0,_.jsxs)(`div`,{className:t(`relative inline-flex`,d),children:[e({ref:h,onClick:()=>p(e=>!e),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),p(!0))},"aria-haspopup":`menu`,"aria-expanded":f,"aria-controls":m}),f&&(0,_.jsx)(`div`,{ref:v,id:m,role:`menu`,"aria-label":u,tabIndex:-1,className:t(`absolute z-40 min-w-48 max-w-[min(20rem,calc(100vw-1rem))] rounded-lg border border-border bg-surface py-1 shadow-pop`,i===`top`?`bottom-full mb-1`:`top-full mt-1`,r===`end`?`right-0`:`left-0`),onKeyDown:e=>{if(a()?.root!==v)return;let t=c.getState().vimNavigation,n=!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey?s(e.key,t):0;n?(e.preventDefault(),e.stopPropagation(),b(n)):e.key===`Home`?(e.preventDefault(),e.stopPropagation(),b(`first`)):e.key===`End`||t&&e.key===`G`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey?(e.preventDefault(),e.stopPropagation(),b(`last`)):e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),x()):e.key===`Tab`&&x(!1)},children:n.map((e,n)=>e===`separator`?(0,_.jsx)(`hr`,{className:`my-1 border-t border-border`},`sep-${n}`):`heading`in e?(0,_.jsx)(`div`,{role:`presentation`,className:`px-3 pt-1.5 pb-1 text-xs font-medium text-muted`,children:e.heading},e.id):(0,_.jsxs)(`button`,{type:`button`,role:e.kind===`radio`?`menuitemradio`:e.kind===`checkbox`?`menuitemcheckbox`:`menuitem`,"aria-checked":e.kind?!!e.checked:void 0,disabled:e.disabled,className:t(`tap flex w-full items-start gap-2 px-3 py-2 text-left text-sm hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:opacity-55`,e.danger?`text-danger`:`text-text`),onClick:()=>{x(),e.onSelect()},children:[e.kind?(0,_.jsx)(`span`,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`,children:e.checked&&(0,_.jsx)(l,{className:`size-4`})}):e.icon&&(0,_.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.icon}),(0,_.jsxs)(`span`,{className:`min-w-0`,children:[(0,_.jsx)(`span`,{className:`block`,children:e.label}),e.hint&&(0,_.jsx)(`span`,{className:`block text-xs text-muted`,children:e.hint})]})]},e.id))})]})}function y(e,t){let n=[...e?.querySelectorAll(`[role^="menuitem"]:not([disabled])`)??[]];if(n.length===0)return;let r=n.indexOf(document.activeElement),i=0;i=t===`first`?0:t===`last`?n.length-1:(r+t+n.length)%n.length,n[i].focus()}export{d as i,h as n,p as r,v as t};
|
|
2
|
-
//# sourceMappingURL=Menu-dT22Gwzm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Menu-dT22Gwzm.js","names":["__iconData","__iconData","useState","useId","useRef","__toESM","cn","require_jsx_runtime","createLucideIcon","require_react","topKeyboardLayer","registerKeyboardLayer","verticalNavigationDelta","usePrefs","Check","__iconData$2","ChevronDown","__iconData$1","PanelRightOpen","__iconData","RotateCcw","import_react","import_jsx_runtime","Menu","open","setOpen","id","btnRef","menuRef","focusItem","focusMenuItem","dir","unregister","onDoc","close","refocus","className","trigger","o","label","side","align","vim","delta","items","item","i","els","menu","idx","next"],"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-down.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/panel-right-open.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/rotate-ccw.mjs","../../src/components/ui/Menu.tsx"],"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-down\",\n size: 24,\n node: [[\"path\", { d: \"m6 9 6 6 6-6\", key: \"qrunsl\" }]]\n};\n__iconData.node;\nconst ChevronDown = createLucideIcon(__iconData);\n\nexport { __iconData, ChevronDown as default };\n//# sourceMappingURL=chevron-down.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: \"panel-right-open\",\n size: 24,\n node: [\n [\"rect\", { width: \"18\", height: \"18\", x: \"3\", y: \"3\", rx: \"2\", key: \"afitv7\" }],\n [\"path\", { d: \"M15 3v18\", key: \"14nvp0\" }],\n [\"path\", { d: \"m10 15-3-3 3-3\", key: \"1pgupc\" }]\n ]\n};\n__iconData.node;\nconst PanelRightOpen = createLucideIcon(__iconData);\n\nexport { __iconData, PanelRightOpen as default };\n//# sourceMappingURL=panel-right-open.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: \"rotate-ccw\",\n size: 24,\n node: [\n [\"path\", { d: \"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\", key: \"1357e3\" }],\n [\"path\", { d: \"M3 3v5h5\", key: \"1xhq8a\" }]\n ]\n};\n__iconData.node;\nconst RotateCcw = createLucideIcon(__iconData);\n\nexport { __iconData, RotateCcw as default };\n//# sourceMappingURL=rotate-ccw.mjs.map\n","import { Check } from \"lucide-react\";\nimport { type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport { verticalNavigationDelta } from \"../../features/palette/shortcuts\";\nimport { cn } from \"../../lib/cn\";\nimport { usePrefs } from \"../../prefs\";\nimport { registerKeyboardLayer, topKeyboardLayer } from \"./keyboardLayers\";\n\nexport interface MenuItem {\n id: string;\n label: string;\n icon?: ReactNode;\n onSelect: () => void;\n danger?: boolean;\n disabled?: boolean;\n /** Short explanation shown under the label (e.g. why it is disabled). */\n hint?: string;\n /** A radio or checkbox item shows a check mark when `checked`. */\n kind?: \"radio\" | \"checkbox\";\n checked?: boolean;\n}\n\n/** A non-interactive label above a group of items. */\nexport interface MenuHeading {\n id: string;\n heading: string;\n}\n\nexport interface MenuProps {\n /** Render the trigger; spread the given props onto a button. */\n trigger: (props: {\n ref: React.Ref<HTMLButtonElement>;\n onClick: () => void;\n onKeyDown: (e: React.KeyboardEvent) => void;\n \"aria-haspopup\": \"menu\";\n \"aria-expanded\": boolean;\n \"aria-controls\": string;\n }) => ReactNode;\n items: (MenuItem | MenuHeading | \"separator\")[];\n align?: \"start\" | \"end\";\n /** Open below (default) or above the trigger. */\n side?: \"bottom\" | \"top\";\n /** Extra classes for the wrapper (e.g. `w-full`). */\n className?: string;\n /** Accessible name of the menu. */\n label: string;\n}\n\n/** Popup menu with arrow-key navigation, Escape and outside click to close. */\nexport function Menu({\n trigger,\n items,\n align = \"end\",\n side = \"bottom\",\n label,\n className,\n}: MenuProps) {\n const [open, setOpen] = useState(false);\n const id = useId();\n const btnRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n\n const focusItem = (dir: 1 | -1 | \"first\" | \"last\") => focusMenuItem(menuRef.current, dir);\n\n useEffect(() => {\n if (!open) return;\n const layer = {\n root: menuRef,\n onEscape: () => {\n setOpen(false);\n btnRef.current?.focus();\n },\n trapsFocus: false,\n };\n const unregister = registerKeyboardLayer(layer);\n requestAnimationFrame(() => focusMenuItem(menuRef.current, \"first\"));\n const onDoc = (e: PointerEvent) => {\n if (\n !menuRef.current?.contains(e.target as Node) &&\n !btnRef.current?.contains(e.target as Node)\n ) {\n setOpen(false);\n }\n };\n document.addEventListener(\"pointerdown\", onDoc);\n return () => {\n unregister();\n document.removeEventListener(\"pointerdown\", onDoc);\n };\n }, [open]);\n\n const close = (refocus = true) => {\n setOpen(false);\n if (refocus) btnRef.current?.focus();\n };\n\n return (\n <div className={cn(\"relative inline-flex\", className)}>\n {trigger({\n ref: btnRef,\n onClick: () => setOpen((o) => !o),\n onKeyDown: (e) => {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n setOpen(true);\n }\n },\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": open,\n \"aria-controls\": id,\n })}\n {open && (\n <div\n ref={menuRef}\n id={id}\n role=\"menu\"\n aria-label={label}\n tabIndex={-1}\n className={cn(\n \"absolute z-40 min-w-48 max-w-[min(20rem,calc(100vw-1rem))] rounded-lg border border-border bg-surface py-1 shadow-pop\",\n side === \"top\" ? \"bottom-full mb-1\" : \"top-full mt-1\",\n align === \"end\" ? \"right-0\" : \"left-0\",\n )}\n onKeyDown={(e) => {\n if (topKeyboardLayer()?.root !== menuRef) return;\n const vim = usePrefs.getState().vimNavigation;\n const delta =\n !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey\n ? verticalNavigationDelta(e.key, vim)\n : 0;\n if (delta) {\n e.preventDefault();\n e.stopPropagation();\n focusItem(delta as 1 | -1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n e.stopPropagation();\n focusItem(\"first\");\n } else if (\n e.key === \"End\" ||\n (vim && e.key === \"G\" && e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey)\n ) {\n e.preventDefault();\n e.stopPropagation();\n focusItem(\"last\");\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n close();\n } else if (e.key === \"Tab\") {\n close(false);\n }\n }}\n >\n {items.map((item, i) =>\n item === \"separator\" ? (\n // biome-ignore lint/suspicious/noArrayIndexKey: separators have no identity\n <hr key={`sep-${i}`} className=\"my-1 border-t border-border\" />\n ) : \"heading\" in item ? (\n <div\n key={item.id}\n role=\"presentation\"\n className=\"px-3 pt-1.5 pb-1 text-xs font-medium text-muted\"\n >\n {item.heading}\n </div>\n ) : (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-checked is only set with the menuitemradio/menuitemcheckbox roles\n <button\n key={item.id}\n type=\"button\"\n role={\n item.kind === \"radio\"\n ? \"menuitemradio\"\n : item.kind === \"checkbox\"\n ? \"menuitemcheckbox\"\n : \"menuitem\"\n }\n aria-checked={item.kind ? !!item.checked : undefined}\n disabled={item.disabled}\n className={cn(\n \"tap flex w-full items-start gap-2 px-3 py-2 text-left text-sm hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:opacity-55\",\n item.danger ? \"text-danger\" : \"text-text\",\n )}\n onClick={() => {\n close();\n item.onSelect();\n }}\n >\n {item.kind ? (\n <span aria-hidden className=\"mt-0.5 size-4 shrink-0\">\n {item.checked && <Check className=\"size-4\" />}\n </span>\n ) : (\n item.icon && <span className=\"mt-0.5 shrink-0\">{item.icon}</span>\n )}\n <span className=\"min-w-0\">\n <span className=\"block\">{item.label}</span>\n {item.hint && <span className=\"block text-xs text-muted\">{item.hint}</span>}\n </span>\n </button>\n ),\n )}\n </div>\n )}\n </div>\n );\n}\n\nfunction focusMenuItem(menu: HTMLElement | null, dir: 1 | -1 | \"first\" | \"last\"): void {\n const els = [\n ...(menu?.querySelectorAll<HTMLElement>('[role^=\"menuitem\"]:not([disabled])') ?? []),\n ];\n if (els.length === 0) return;\n const idx = els.indexOf(document.activeElement as HTMLElement);\n let next = 0;\n if (dir === \"first\") next = 0;\n else if (dir === \"last\") next = els.length - 1;\n else next = (idx + dir + els.length) % els.length;\n els[next]!.focus();\n}\n"],"ignoreList":[0,1,2],"mappings":"A,qNASA,IAAMA,EAAa,CACjB,KAAM,eACN,KAAM,GACN,KAAM,CAAC,CAAC,OAAQ,CAAE,EAAG,eAAgB,IAAK,QAAS,CAAC,CAAC,CACvD,EACAA,EAAW,KACX,IAAMgB,EAAcR,EAAiBR,CAAU,ECNzCC,EAAa,CACjB,KAAM,mBACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EAC9E,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,iBAAkB,IAAK,QAAS,CAAC,CACjD,CACF,EACAA,EAAW,KACX,IAAMiB,EAAiBV,EAAiBP,CAAU,ECV5CkB,EAAa,CACjB,KAAM,aACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,oDAAqD,IAAK,QAAS,CAAC,EAClF,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,CAC3C,CACF,EACAA,EAAW,KACX,IAAMC,EAAYZ,EAAiBW,CAAU,E,iBC8B7C,SAAgBI,EAAK,CACnB,UACA,QACA,QAAQ,MACR,OAAO,SACP,QACA,aACY,CACZ,GAAM,CAACC,EAAMC,IAAA,EAAWvB,EAAAA,SAAAA,CAAS,EAAK,EAChCwB,GAAA,EAAKvB,EAAAA,MAAAA,CAAM,EACXwB,GAAA,EAASvB,EAAAA,OAAAA,CAA0B,IAAI,EACvCwB,GAAA,EAAUxB,EAAAA,OAAAA,CAAuB,IAAI,EAErCyB,EAAa,GAAmCC,EAAcF,EAAQ,QAASG,CAAG,GAExF,EAAAV,EAAA,UAAA,KAAgB,CACd,GAAI,CAACG,EAAM,OASX,IAAMQ,EAAarB,EAAsB,CAPvC,KAAMiB,EACN,aAAgB,CACdH,EAAQ,EAAK,EACbE,EAAO,SAAS,MAAM,CACxB,EACA,WAAY,EAE2B,CAAK,EAC9C,0BAA4BG,EAAcF,EAAQ,QAAS,OAAO,CAAC,EACnE,IAAMK,EAAS,GAAoB,CAE/B,CAACL,EAAQ,SAAS,SAAS,EAAE,MAAc,GAC3C,CAACD,EAAO,SAAS,SAAS,EAAE,MAAc,GAE1CF,EAAQ,EAAK,CAEjB,EAEA,OADA,SAAS,iBAAiB,cAAeQ,CAAK,MACjC,CACXD,EAAW,EACX,SAAS,oBAAoB,cAAeC,CAAK,CACnD,CACF,EAAG,CAACT,CAAI,CAAC,EAET,IAAMU,GAAS,EAAU,KAAS,CAChCT,EAAQ,EAAK,EACTU,GAASR,EAAO,SAAS,MAAM,CACrC,EAEA,OACE,EAAAL,EAAA,KAAA,CAAC,MAAD,CAAK,UAAWhB,EAAG,uBAAwB8B,CAAS,EAApD,SAAA,CACGC,EAAQ,CACP,IAAKV,EACL,YAAeF,EAAS,GAAM,CAACa,CAAC,EAChC,UAAY,GAAM,EACZ,EAAE,MAAQ,aAAe,EAAE,MAAQ,aACrC,EAAE,eAAe,EACjBb,EAAQ,EAAI,EAEhB,EACA,gBAAiB,OACjB,gBAAiBD,EACjB,gBAAiBE,CACnB,CAAC,EACAF,IACC,EAAAF,EAAA,IAAA,CAAC,MAAD,CACE,IAAKM,EACD,KACJ,KAAK,OACL,aAAYW,EACZ,SAAU,GACV,UAAWjC,EACT,wHACAkC,IAAS,MAAQ,mBAAqB,gBACtCC,IAAU,MAAQ,UAAY,QAChC,EACA,UAAY,GAAM,CAChB,GAAI/B,EAAiB,CAAC,EAAE,OAASkB,EAAS,OAC1C,IAAMc,EAAM7B,EAAS,SAAS,CAAC,CAAC,cAC1B8B,EACJ,CAAC,EAAE,SAAW,CAAC,EAAE,SAAW,CAAC,EAAE,QAAU,CAAC,EAAE,SACxC/B,EAAwB,EAAE,IAAK8B,CAAG,EAClC,EACFC,GACF,EAAE,eAAe,EACjB,EAAE,gBAAgB,EAClBd,EAAUc,CAAe,GAChB,EAAE,MAAQ,QACnB,EAAE,eAAe,EACjB,EAAE,gBAAgB,EAClBd,EAAU,OAAO,GAEjB,EAAE,MAAQ,OACTa,GAAO,EAAE,MAAQ,KAAO,EAAE,UAAY,CAAC,EAAE,SAAW,CAAC,EAAE,SAAW,CAAC,EAAE,QAEtE,EAAE,eAAe,EACjB,EAAE,gBAAgB,EAClBb,EAAU,MAAM,GACP,EAAE,MAAQ,UACnB,EAAE,eAAe,EACjB,EAAE,gBAAgB,EAClBK,EAAM,GACG,EAAE,MAAQ,OACnBA,EAAM,EAAK,CAEf,EAEC,SAAAU,EAAM,KAAK,EAAM,IAChBC,IAAS,aAEP,EAAAvB,EAAA,IAAA,CAAC,KAAD,CAAqB,UAAU,6BAA+B,EAArD,OAAOwB,GAA8C,EAC5D,YAAaD,GACf,EAAAvB,EAAA,IAAA,CAAC,MAAD,CAEE,KAAK,eACL,UAAU,kDAET,SAAAuB,EAAK,OACH,EALEA,EAAK,EAKP,GAGL,EAAAvB,EAAA,KAAA,CAAC,SAAD,CAEE,KAAK,SACL,KACEuB,EAAK,OAAS,QACV,gBACAA,EAAK,OAAS,WACZ,mBACA,WAER,eAAcA,EAAK,KAAO,CAAC,CAACA,EAAK,QAAU,IAAA,GAC3C,SAAUA,EAAK,SACf,UAAWvC,EACT,6IACAuC,EAAK,OAAS,cAAgB,WAChC,EACA,YAAe,CACbX,EAAM,EACNW,EAAK,SAAS,CAChB,EAnBF,SAAA,CAqBGA,EAAK,MACJ,EAAAvB,EAAA,IAAA,CAAC,OAAD,CAAM,cAAA,GAAY,UAAU,yBACzB,SAAAuB,EAAK,UAAW,EAAAvB,EAAA,IAAA,CAACR,EAAD,CAAO,UAAU,QAAU,CAAA,CACxC,CAAA,EAEN+B,EAAK,OAAQ,EAAAvB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,kBAAmB,SAAAuB,EAAK,IAAW,CAAA,GAElE,EAAAvB,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,UAAhB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,QAAS,SAAAuB,EAAK,KAAY,CAAA,EACzCA,EAAK,OAAQ,EAAAvB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,2BAA4B,SAAAuB,EAAK,IAAW,CAAA,CACtE,CACA,CAAA,CAAA,CA/BD,EAAAA,EAAK,EA+BJ,CAEZ,CACG,CAAA,CAEJ,C,EAET,CAEA,SAASf,EAAc,EAA0B,EAAsC,CACrF,IAAMiB,EAAM,CACV,GAAIC,GAAM,iBAA8B,oCAAoC,GAAK,CAAC,CACpF,EACA,GAAID,EAAI,SAAW,EAAG,OACtB,IAAME,EAAMF,EAAI,QAAQ,SAAS,aAA4B,EACzDG,EAAO,EACX,AAEKA,EAFDnB,IAAQ,QAAgB,EACnBA,IAAQ,OAAegB,EAAI,OAAS,GAChCE,EAAMlB,EAAMgB,EAAI,QAAUA,EAAI,OAC3CA,EAAIG,EAAK,CAAE,MAAM,CACnB,C"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,a as t,i as n,y as r}from"./Button-BKQW9doW.js";import{t as i}from"./TextArea-BQPdfjO_.js";var a=e(r(),1),o=n(),s=(0,a.forwardRef)(function({className:e,width:n=`full`,children:r,...a},s){return(0,o.jsx)(`select`,{ref:s,className:t(`tap block h-9 min-w-0 px-2.5`,n===`auto`?`w-auto`:`w-full`,i,e),...a,children:r})});export{s as t};
|
|
2
|
-
//# sourceMappingURL=Select-CpWLZnId.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,a as t,i as n,y as r}from"./Button-BKQW9doW.js";var i=e(r(),1),a=n(),o=t(`rounded-md border border-border bg-surface text-base text-text placeholder:text-subtle md:text-sm`,`outline-none focus:border-accent focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-0 focus-visible:outline-[var(--sy-focus)]`,`aria-[invalid=true]:border-danger aria-[invalid=true]:focus:border-danger`,`disabled:cursor-not-allowed disabled:opacity-55`),s=(0,i.forwardRef)(function({maxHeight:e=`33vh`,minRows:n=1,className:r,value:s,style:c,...l},u){let d=(0,i.useRef)(null),f=(0,i.useCallback)(e=>{d.current=e,typeof u==`function`?u(e):u&&(u.current=e)},[u]);return(0,i.useLayoutEffect)(()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+(e.offsetHeight-e.clientHeight)}px`)},[s]),(0,a.jsx)(`textarea`,{ref:f,rows:n,value:s,style:{maxHeight:e,...c},className:t(`block w-full resize-none overflow-y-auto px-3 py-2`,o,r),...l})}),c=(0,i.forwardRef)(function({className:e,...n},r){return(0,a.jsx)(`input`,{ref:r,className:t(`tap block h-9 w-full px-3`,o,e),...n})});export{s as n,c as r,o as t};
|
|
2
|
-
//# sourceMappingURL=TextArea-BQPdfjO_.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea-BQPdfjO_.js","names":["forwardRef","useRef","useCallback","__toESM","cn","require_jsx_runtime","require_react","import_react","import_jsx_runtime","CONTROL_CLASSES","TextArea","rest","inner","setRef","el","ref","value","minRows","style","className","TextInput"],"sources":["../../src/components/ui/TextArea.tsx"],"sourcesContent":["import {\n forwardRef,\n type TextareaHTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { cn } from \"../../lib/cn\";\n\n/** Shared look of text controls: border, focus ring, invalid and disabled states. */\nexport const CONTROL_CLASSES = cn(\n \"rounded-md border border-border bg-surface text-base text-text placeholder:text-subtle md:text-sm\",\n \"outline-none focus:border-accent focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-0 focus-visible:outline-[var(--sy-focus)]\",\n \"aria-[invalid=true]:border-danger aria-[invalid=true]:focus:border-danger\",\n \"disabled:cursor-not-allowed disabled:opacity-55\",\n);\n\nexport interface TextAreaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Max height before scrolling internally (CSS length; default \"33vh\"). */\n maxHeight?: string;\n /** Minimum rows (default 1). */\n minRows?: number;\n}\n\n/** Auto-growing textarea that scrolls internally past `maxHeight`. */\nexport const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n { maxHeight = \"33vh\", minRows = 1, className, value, style, ...rest },\n ref,\n) {\n const inner = useRef<HTMLTextAreaElement | null>(null);\n const setRef = useCallback(\n (el: HTMLTextAreaElement | null) => {\n inner.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n },\n [ref],\n );\n // biome-ignore lint/correctness/useExhaustiveDependencies: re-measure when the value changes\n useLayoutEffect(() => {\n const el = inner.current;\n if (!el) return;\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight + (el.offsetHeight - el.clientHeight)}px`;\n }, [value]);\n return (\n <textarea\n ref={setRef}\n rows={minRows}\n value={value}\n style={{ maxHeight, ...style }}\n className={cn(\n \"block w-full resize-none overflow-y-auto px-3 py-2\",\n CONTROL_CLASSES,\n className,\n )}\n {...rest}\n />\n );\n});\n\n/** Single-line input with the same styling. */\nexport const TextInput = forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(\n function TextInput({ className, ...rest }, ref) {\n return (\n <input\n ref={ref}\n className={cn(\"tap block h-9 w-full px-3\", CONTROL_CLASSES, className)}\n {...rest}\n />\n );\n },\n);\n"],"mappings":"A,mFAUaS,EAAkBL,EAC7B,oGACA,8JACA,4EACA,iDACF,EAUaM,GAAA,EAAWV,EAAAA,WAAAA,CAA+C,SACrE,CAAE,YAAY,OAAQ,UAAU,EAAG,YAAW,QAAO,QAAO,GAAGW,GAC/D,EACA,CACA,IAAMC,GAAA,EAAQX,EAAAA,OAAAA,CAAmC,IAAI,EAC/CY,GAAA,EAASX,EAAAA,YAAAA,CACZ,GAAmC,CAClC,EAAM,QAAUY,EACZ,OAAOC,GAAQ,WAAYA,EAAID,CAAE,EAC5BC,IAAK,EAAI,QAAUD,EAC9B,EACA,CAACC,CAAG,CACN,EAQA,OANA,EAAAR,EAAA,gBAAA,KAAsB,CACpB,IAAMO,EAAKF,EAAM,QACZE,IACL,EAAG,MAAM,OAAS,OAClB,EAAG,MAAM,OAAS,GAAGA,EAAG,cAAgBA,EAAG,aAAeA,EAAG,cAAc,IAC7E,EAAG,CAACE,CAAK,CAAC,GAER,EAAAR,EAAA,IAAA,CAAC,WAAD,CACE,IAAKK,EACL,KAAMI,EACC,QACP,MAAO,CAAE,YAAW,GAAGC,CAAM,EAC7B,UAAWd,EACT,qDACAK,EACAU,CACF,EACA,GAAIR,CACL,CAAA,CAEL,CAAC,EAGYS,GAAA,EAAYpB,EAAAA,WAAAA,CACvB,SAAmB,CAAE,YAAW,GAAGW,GAAQ,EAAK,CAC9C,OACE,EAAAH,EAAA,IAAA,CAAC,QAAD,CACO,MACL,UAAWJ,EAAG,4BAA6BK,EAAiBU,CAAS,EACrE,GAAIR,CACL,CAAA,CAEL,CACF,E"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,i as t,l as n,n as r,o as i,t as a,y as o}from"./Button-BKQW9doW.js";import{T as s,h as c,u as l}from"./Overlay-zQBNtPf6.js";import{L as u,Nt as d,c as f,f as p,g as m,i as h,jt as g,k as _,kt as v,n as y,s as b,t as x,u as S}from"./states-BXOts8eT.js";import{D as C,M as w,w as T}from"./preload-helper-DOFsWE7_.js";import{p as E,s as D}from"./useBreakpoint-kT0J1Dnk.js";import{t as O}from"./external-link-CI-Uzhfh.js";import{c as k}from"./index-LsagdEq-.js";import{n as A,t as j}from"./InteractionCard-Bhur-sU9.js";import{t as M}from"./SegmentedControl-D2kj3j7u.js";import{r as N}from"./useResource-DhvWL_9X.js";var P={name:`list-todo`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]};P.node;var F=i(P),I=e(o(),1),L=[`needs_input`,`failed`,`ready_for_review`,`unsupported_interaction`,`host_unreachable`,`cache_expiring`];function R(e){let t=Object.fromEntries(L.map(e=>[e,[]]));for(let n of e)t[n.reason]?.push(n);return t}function z(e){return e===`dismissed`||e===`history`?e:`open`}function B(e,t){return t===`history`?[]:e.filter(e=>t===`open`?!e.acknowledgedAt:!!e.acknowledgedAt)}function V(e,t,n){return[e?.name,t?.title,n&&n.title!==t?.title?n.title:null].filter(Boolean).join(` · `)||`Switchyard`}function H(e){let t=N(e?`attention-history`:null,e=>v(`/api/attention`,{resolvedOnly:`true`,limit:200},e),{refreshMs:3e4,check:Array.isArray}),n=u(e=>e.attention),r=(0,I.useRef)(!0),{reload:i}=t;return(0,I.useEffect)(()=>{if(r.current){r.current=!1;return}if(!e)return;let t=setTimeout(i,500);return()=>clearTimeout(t)},[n,e,i]),t}var U=t(),W={needs_input:`Questions from Pi waiting for your answer.`,failed:`Runs that failed or were blocked. Open the task to see why.`,ready_for_review:`Finished runs waiting for your review.`,unsupported_interaction:`Questions this client cannot display. Answer them in a terminal attached to the session.`,host_unreachable:`Running work on hosts that stopped responding. Nothing is restarted elsewhere.`,cache_expiring:`Idle sessions whose prompt cache is about to expire. Send a message to keep it warm.`};function G(){let e=_(),t=u(e=>e.hydrated),[n,r]=T(`attentionShow`,`open`),i=z(n),a=e=>r(e),o=(0,I.useMemo)(()=>B(e,i),[e,i]),s=(0,I.useMemo)(()=>B(e,`dismissed`).length,[e]),c=(0,I.useMemo)(()=>R(o),[o]),p=H(i===`history`);return(0,U.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,U.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,U.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Attention`}),(0,U.jsx)(M,{label:`Show`,className:`max-sm:w-full max-sm:basis-full`,value:i,onChange:a,options:[{value:`open`,label:`Open`},{value:`dismissed`,label:`Dismissed`},{value:`history`,label:`History`}]})]}),(0,U.jsx)(b,{subject:`attention items`,consequence:`Answers are sent once the connection is back.`,show:t}),(0,U.jsx)(`section`,{"aria-label":`Attention items`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`flex min-w-0 flex-col gap-4 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:i===`history`?(0,U.jsx)(`div`,{"data-testid":`attention-history`,className:`flex min-w-0 flex-col gap-2`,children:!p.data&&p.loading?(0,U.jsx)(f,{label:`Loading history…`}):!p.data&&p.error?(0,U.jsx)(y,{compact:!0,title:`Could not load history`,error:d(p.error),onRetry:p.reload}):!p.data||p.data.length===0?(0,U.jsx)(x,{icon:(0,U.jsx)(m,{className:`size-8`}),title:`No history yet`,description:`Resolved questions, failures and reviews show up here.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:p.data.map(e=>(0,U.jsx)(`li`,{className:`min-w-0`,children:(0,U.jsx)(q,{item:e})},e.id))}),p.data.length>=200&&(0,U.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Showing the `,200,` most recent.`]})]})}):t?o.length===0?i===`dismissed`?(0,U.jsx)(x,{icon:(0,U.jsx)(w,{className:`size-8`}),title:`No dismissed items`,description:`Items you dismiss stay here until their question or task is resolved.`,action:{label:`Show open`,onClick:()=>a(`open`)}}):(0,U.jsx)(x,{icon:(0,U.jsx)(w,{className:`size-8`}),title:s>0?`All caught up`:`Nothing needs your attention`,description:s>0?`${s} dismissed ${s===1?`item is`:`items are`} still open.`:`Questions, failures and finished work show up here.`,action:s>0?{label:`Show dismissed`,onClick:()=>a(`dismissed`)}:{label:`Go to Sessions`,to:k.code},secondaryAction:s>0?{label:`Go to Sessions`,to:k.code}:{label:`Go to Board`,to:k.board}}):L.filter(e=>c[e].length>0).map(e=>{let t=l[e],n=t.icon;return(0,U.jsxs)(`section`,{"data-testid":`attention-group-${e}`,"aria-labelledby":`att-${e}`,className:`flex min-w-0 flex-col gap-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{id:`att-${e}`,className:`flex items-center gap-2 text-base font-semibold`,children:[(0,U.jsx)(n,{"aria-hidden":!0,className:`size-4 text-muted`}),t.label,(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,c[e].length,`)`]})]}),(0,U.jsx)(`p`,{className:`text-sm text-muted`,children:W[e]})]}),(0,U.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:c[e].map(e=>(0,U.jsx)(`li`,{className:`min-w-0`,children:(0,U.jsx)(K,{item:e})},e.id))})]},e)}):(0,U.jsx)(f,{label:`Loading attention…`})})]})}function K({item:e}){let t=u(t=>e.projectId?t.projects[e.projectId]:void 0),i=u(t=>e.taskId?t.tasks[e.taskId]:void 0),o=u(t=>e.sessionId?t.sessions[e.sessionId]:void 0),f=u(e=>o?e.hosts[o.hostId]:void 0),m=u(t=>e.interactionId?t.interactions[e.interactionId]:void 0),[_,v]=(0,I.useState)(!1),[b,x]=(0,I.useState)(null),w=async()=>{v(!0),x(null);try{let t=await g(`/api/attention/${encodeURIComponent(e.id)}/acknowledge`),n=t&&typeof t==`object`&&`id`in t?t:{...e,acknowledgedAt:new Date().toISOString()};u.setState(t=>t.attention[e.id]?{attention:{...t.attention,[e.id]:n}}:{}),D.success(`Dismissed. It stays under All until the task or question is resolved.`)}catch(e){x(e)}finally{v(!1)}},T=e.sessionId?e.interactionId?k.interaction(e.sessionId,e.interactionId):k.session(e.sessionId):null,M=!!f&&f.connectivity!==`connected`,N=null;switch(e.reason){case`needs_input`:N=m&&m.state===`pending`?(0,U.jsx)(j,{flush:!0,interaction:m,readOnlyReason:M?`Host ${f?.name} is offline. You can answer once it reconnects.`:o?.readOnly?`This session is read-only.`:null}):m?(0,U.jsx)(j,{flush:!0,interaction:m}):T?(0,U.jsxs)(n,{to:T,className:r(`primary`,`sm`),children:[(0,U.jsx)(O,{"aria-hidden":!0,className:`size-3.5`}),`Answer in session`]}):null;break;case`failed`:N=e.taskId?(0,U.jsxs)(n,{to:k.task(e.taskId),className:r(`primary`,`sm`),children:[(0,U.jsx)(F,{"aria-hidden":!0,className:`size-3.5`}),`Open task`]}):null;break;case`ready_for_review`:N=e.sessionId?(0,U.jsxs)(n,{to:`${k.session(e.sessionId)}?tab=changes`,className:r(`primary`,`sm`),children:[(0,U.jsx)(s,{"aria-hidden":!0,className:`size-3.5`}),`Review changes`]}):e.taskId?(0,U.jsxs)(n,{to:k.task(e.taskId),className:r(`primary`,`sm`),children:[(0,U.jsx)(s,{"aria-hidden":!0,className:`size-3.5`}),`Open review`]}):null;break;case`unsupported_interaction`:N=m?(0,U.jsx)(j,{interaction:m,readOnlyReason:M?`Host ${f?.name} is offline. You can choose once it reconnects.`:o?.readOnly?`This session is read-only.`:null}):(0,U.jsx)(S,{capability:`This dialog`,reason:`An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.`});break;case`host_unreachable`:N=f?(0,U.jsx)(h,{compact:!0,hostName:f.name,connectivity:f.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:f.lastSeenAt}):null}let P=V(t,i,o),L=!!m&&(e.reason===`needs_input`||e.reason===`unsupported_interaction`);return e.reason===`needs_input`&&m?.state===`pending`&&A(m.presentation)?(0,U.jsxs)(`article`,{"aria-label":`Plan awaiting approval: ${P}`,tabIndex:-1,"data-keyboard-item":!0,className:`flex min-w-0 flex-col gap-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 basis-full truncate sm:basis-auto sm:flex-1`,children:P}),T&&(0,U.jsxs)(n,{to:T,className:r(`ghost`,`sm`),children:[(0,U.jsx)(O,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]}),(0,U.jsx)(`time`,{dateTime:e.createdAt,className:`shrink-0 text-xs text-subtle sm:ml-auto`,children:p(e.createdAt)}),!e.acknowledgedAt&&(0,U.jsx)(a,{size:`sm`,variant:`ghost`,busy:_,onClick:()=>void w(),children:`Dismiss`})]}),N,b!==null&&(0,U.jsx)(y,{compact:!0,title:`Could not dismiss`,error:d(b),onRetry:()=>void w()})]}):(0,U.jsxs)(`article`,{"aria-label":`${l[e.reason].label}: ${i?.title??o?.title??e.summary}`,tabIndex:-1,"data-keyboard-item":!0,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(c,{kind:`attention`,value:e.reason,size:`sm`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted`,children:P}),(0,U.jsx)(`time`,{dateTime:e.createdAt,className:`shrink-0 text-xs text-subtle`,children:p(e.createdAt)})]}),!L&&(0,U.jsx)(`p`,{className:`min-w-0 text-sm break-words`,children:e.summary}),N&&(0,U.jsx)(`div`,{className:`flex min-w-0 flex-col items-start`,children:N}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.reason!==`failed`&&e.taskId&&(0,U.jsxs)(n,{to:k.task(e.taskId),className:r(`ghost`,`sm`),children:[(0,U.jsx)(F,{"aria-hidden":!0,className:`size-3.5`}),`Task`]}),T&&(0,U.jsxs)(n,{to:T,className:r(`ghost`,`sm`),children:[(0,U.jsx)(O,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]}),e.reason===`host_unreachable`&&f&&(0,U.jsxs)(n,{to:`${k.settings(`hosts`)}/${encodeURIComponent(f.id)}`,className:r(`ghost`,`sm`),children:[(0,U.jsx)(C,{"aria-hidden":!0,className:`size-3.5`}),`Host details`]}),(0,U.jsx)(`span`,{className:`ml-auto`}),e.acknowledgedAt?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,U.jsx)(E,{"aria-hidden":!0,className:`size-3.5`}),`Dismissed `,p(e.acknowledgedAt)]}):(0,U.jsx)(a,{size:`sm`,busy:_,onClick:()=>void w(),children:`Dismiss`})]}),b!==null&&(0,U.jsx)(y,{compact:!0,title:`Could not dismiss`,error:d(b),onRetry:()=>void w()})]})}function q({item:e}){let t=u(t=>e.projectId?t.projects[e.projectId]:void 0),i=u(t=>e.taskId?t.tasks[e.taskId]:void 0),a=u(t=>e.sessionId?t.sessions[e.sessionId]:void 0);return(0,U.jsxs)(`article`,{"aria-label":`${l[e.reason].label}: ${i?.title??a?.title??e.summary}`,tabIndex:-1,"data-keyboard-item":!0,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(c,{kind:`attention`,value:e.reason,size:`sm`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted`,children:V(t,i,a)}),e.resolvedAt&&(0,U.jsxs)(`time`,{dateTime:e.resolvedAt,className:`shrink-0 text-xs text-subtle`,children:[`Resolved `,p(e.resolvedAt)]})]}),(0,U.jsx)(`p`,{className:`min-w-0 text-sm break-words`,children:e.summary}),(e.taskId||e.sessionId)&&(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.taskId&&(0,U.jsxs)(n,{to:k.task(e.taskId),className:r(`ghost`,`sm`),children:[(0,U.jsx)(F,{"aria-hidden":!0,className:`size-3.5`}),`Task`]}),e.sessionId&&(0,U.jsxs)(n,{to:k.session(e.sessionId),className:r(`ghost`,`sm`),children:[(0,U.jsx)(O,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})]})]})}export{G as default};
|
|
2
|
-
//# sourceMappingURL=attention-DrHtkJHs.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,a as t,i as n,l as r,n as i,o as a,t as o,y as s}from"./Button-BKQW9doW.js";import{L as c,c as l,et as u,f as d,kt as f,n as p,r as m,s as h,t as g}from"./states-BXOts8eT.js";import{t as _}from"./calendar-clock-CwOgyN2z.js";import{t as v}from"./chevron-right-aaHL5Igi.js";import{d as y,l as b,r as x,t as S}from"./useBreakpoint-kT0J1Dnk.js";import{t as C}from"./hand-HCdmhGph.js";import{t as w}from"./link-2-D6l0YZ-8.js";import{t as T}from"./play-j138GLHB.js";import{t as E}from"./plus-D935l0Os.js";import{u as D}from"./index-LsagdEq-.js";import{t as O}from"./Switch-DHX-YYPr.js";import{C as k,D as A,O as j,T as M,_ as N,c as P,k as F,p as I}from"./describe-CtmmeUfI.js";var L={name:`webhook`,size:24,node:[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]};L.node;var R=a(L),z=e(s(),1),B=n(),V=`/automations/new`,H=e=>`/automations/${encodeURIComponent(e)}`,U={manual:C,once:y,cron:_,webhook:R,dependency:w};function W(){let e=c(e=>e.hydrated),t=A(),n=c(e=>e.projects),a=c(e=>e.hosts),o=c(e=>e.tasks),s=S(),[d,_]=(0,z.useState)({status:`idle`}),v=(0,z.useCallback)(async()=>{_({status:`loading`});try{let e=await f(`/api/automations`),t=Array.isArray(e)?e:e&&typeof e==`object`&&Array.isArray(e.items)?e.items:null,n=t?u.array().safeParse(t):null;if(!n?.success){_({status:`fatal`,error:Error(`The coordinator returned automations in an unexpected format.`)});return}M.getState().putMany(n.data),_({status:`done`})}catch(e){_({status:`error`,error:e})}},[]);(0,z.useEffect)(()=>{e||v()},[e,v]);let y=(0,z.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),b=e||d.status===`done`,C;return C=b?y.length===0?(0,B.jsx)(g,{icon:(0,B.jsx)(D,{className:`size-8`}),title:`No automations yet`,description:`Automations create tasks on a schedule, from a webhook, or when another task is done.`,action:{label:`Create an automation`,to:V,icon:(0,B.jsx)(E,{className:`size-4`})}}):(0,B.jsx)(K,{automations:y,projects:n,hosts:a,tasks:o,table:s===`desktop`}):d.status===`fatal`?(0,B.jsx)(m,{error:d.error}):d.status===`error`?(0,B.jsx)(p,{title:`Could not load automations`,error:d.error,onRetry:()=>void v()}):(0,B.jsx)(l,{label:`Loading automations…`}),(0,B.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-4 px-4 py-4 md:px-6`,children:[(0,B.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Automations`}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`Scheduled, webhook and dependency automations. Routine successes stay in each automation's history.`})]}),(0,B.jsxs)(r,{to:V,state:x,className:i(`primary`),children:[(0,B.jsx)(E,{"aria-hidden":!0,className:`size-4`}),`New automation`]})]}),(0,B.jsx)(h,{subject:`automations`,consequence:`Changes are sent once the coordinator is reachable again.`}),C]})}var G=`grid grid-cols-[minmax(0,2.4fr)_minmax(0,1fr)_5.5rem_minmax(0,1.2fr)_minmax(0,1.4fr)_7.5rem_7rem_auto] items-center gap-3`;function K({automations:e,projects:n,hosts:r,tasks:i,table:a}){let{busy:o,toggle:s}=F(),{busy:c,run:l}=j(),u=(0,z.useCallback)(e=>i[e]?.title,[i]);return(0,B.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-lg border border-border bg-surface`,children:[a&&(0,B.jsxs)(`div`,{"aria-hidden":!0,className:t(G,`border-b border-border bg-surface-2 px-4 py-2 text-xs font-medium text-muted`),children:[(0,B.jsx)(`span`,{children:`Automation`}),(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsx)(`span`,{children:`Mode`}),(0,B.jsx)(`span`,{children:`Next occurrence`}),(0,B.jsx)(`span`,{children:`Last outcome`}),(0,B.jsx)(`span`,{children:`Failures`}),(0,B.jsx)(`span`,{children:`Enabled`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Actions`})]}),(0,B.jsx)(`ul`,{"data-testid":`automations-list`,"aria-label":`Automations`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`divide-y divide-border focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:e.map(e=>{let t=n[e.projectId],i=e.hostId??t?.defaultHostId??null,d=i?r[i]:void 0,f={automation:e,projectName:t?.name??`Unknown project`,host:d,trigger:P(e.trigger,{taskTitle:u}),toggling:!!o[e.id],running:!!c[e.id],onToggle:t=>void s(e,t),onRun:()=>void l(e)};return(0,B.jsx)(`li`,{"data-testid":`automation-row`,"data-automation-id":e.id,children:a?(0,B.jsx)(Z,{...f}):(0,B.jsx)(Q,{...f})},e.id)})})]})}function q({automation:e,trigger:t}){let n=U[e.trigger.kind];return(0,B.jsxs)(`span`,{className:`flex min-w-0 items-start gap-1.5 text-sm text-muted`,children:[(0,B.jsx)(n,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:t})]})}function J({automation:e}){if(!e.enabled)return(0,B.jsx)(`span`,{className:`text-sm text-muted`,children:`Disabled`});if(!e.nextAt){let t=e.trigger.kind;return(0,B.jsx)(`span`,{className:`text-sm text-muted`,children:t===`manual`?`On demand`:t===`webhook`?`On webhook`:t===`dependency`?`When the task is done`:`None scheduled`})}return(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col text-sm`,children:[(0,B.jsx)(`span`,{children:d(e.nextAt)}),(0,B.jsx)(`time`,{dateTime:e.nextAt,className:`text-xs text-muted`,children:I(e.nextAt)})]})}function Y({host:e}){return!e||e.connectivity===`connected`?null:(0,B.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-danger`,children:[(0,B.jsx)(b,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Host `,e.name,` `,e.connectivity===`reconnecting`?`reconnecting`:`unreachable`]})]})}function X({running:e,onRun:t,name:n}){return(0,B.jsx)(o,{size:`sm`,busy:e,icon:(0,B.jsx)(T,{className:`size-3.5`}),onClick:t,"aria-label":`Run ${n} now`,children:`Run now`})}function Z(e){let n=e.automation;return(0,B.jsxs)(`div`,{className:t(G,`px-4 py-3`),children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(r,{to:H(n.id),state:x,"data-keyboard-item":!0,className:`truncate font-medium text-text hover:underline focus-visible:underline`,children:n.name}),(0,B.jsx)(q,{automation:n,trigger:e.trigger})]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Project: `}),(0,B.jsx)(`span`,{className:`truncate text-sm`,children:e.projectName}),(0,B.jsx)(Y,{host:e.host})]}),(0,B.jsxs)(`span`,{className:`text-sm`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Mode: `}),N(n.mode)]}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Next occurrence: `}),(0,B.jsx)(J,{automation:n})]}),(0,B.jsxs)(`div`,{className:`min-w-0 text-sm break-words`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Last outcome: `}),n.lastOutcome??(0,B.jsx)(`span`,{className:`text-muted`,children:`No runs yet`})]}),(0,B.jsx)(k,{count:n.failureCount}),(0,B.jsx)(O,{checked:n.enabled,onChange:e.onToggle,busy:e.toggling,label:`Enable ${n.name}`,onText:`Enabled`,offText:`Disabled`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(X,{running:e.running,onRun:e.onRun,name:n.name}),(0,B.jsx)(r,{to:H(n.id),state:x,"aria-label":`Edit ${n.name}`,title:`Edit`,className:`tap inline-flex size-9 items-center justify-center rounded-md text-muted hover:bg-surface-2 hover:text-text`,children:(0,B.jsx)(v,{"aria-hidden":!0,className:`size-4`})})]})]})}function Q(e){let t=e.automation;return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(r,{to:H(t.id),state:x,"data-keyboard-item":!0,className:`font-medium break-words text-text hover:underline focus-visible:underline`,children:t.name}),(0,B.jsx)(q,{automation:t,trigger:e.trigger})]}),(0,B.jsx)(O,{checked:t.enabled,onChange:e.onToggle,busy:e.toggling,label:`Enable ${t.name}`,onText:`Enabled`,offText:`Disabled`})]}),(0,B.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm`,children:[(0,B.jsx)(`dt`,{className:`text-muted`,children:`Project`}),(0,B.jsxs)(`dd`,{className:`flex min-w-0 flex-col break-words`,children:[e.projectName,(0,B.jsx)(Y,{host:e.host})]}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Mode`}),(0,B.jsx)(`dd`,{children:N(t.mode)}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Next`}),(0,B.jsx)(`dd`,{className:`min-w-0`,children:(0,B.jsx)(J,{automation:t})}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Last outcome`}),(0,B.jsx)(`dd`,{className:`min-w-0 break-words`,children:t.lastOutcome??(0,B.jsx)(`span`,{className:`text-muted`,children:`No runs yet`})}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Failures`}),(0,B.jsx)(`dd`,{children:(0,B.jsx)(k,{count:t.failureCount})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(X,{running:e.running,onRun:e.onRun,name:t.name}),(0,B.jsxs)(r,{to:H(t.id),state:x,className:i(`ghost`,`sm`),children:[`Edit`,(0,B.jsx)(v,{"aria-hidden":!0,className:`size-3.5`})]})]})]})}export{W as default};
|
|
2
|
-
//# sourceMappingURL=automations-TOhPm8sF.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{S as e,_ as t,a as n,g as r,i,l as a,n as o,o as s,r as c,t as l,y as u}from"./Button-BKQW9doW.js";import{M as d,O as f,S as p,T as m,g as h,h as g,i as _,j as v,l as y,m as b,n as x,r as S,t as C,u as w,v as T,x as E}from"./Overlay-zQBNtPf6.js";import{G as D,L as O,M as k,Nt as A,O as ee,Pt as j,R as M,S as te,V as ne,W as N,b as re,c as ie,d as ae,f as P,i as oe,n as se,o as ce,p as F,st as le,t as I,u as ue,vt as de,x as fe,y as pe,yt as me}from"./states-BXOts8eT.js";import{bt as he,d as ge,xt as _e}from"./drafts-BP2GMlHS.js";import{D as ve,M as ye,T as L,w as be}from"./preload-helper-DOFsWE7_.js";import{i as xe,n as Se,r as Ce,t as we}from"./Menu-dT22Gwzm.js";import{t as Te}from"./chevron-right-aaHL5Igi.js";import{n as Ee,r as De}from"./Priority-CgO3ns6b.js";import{a as Oe,d as ke,p as Ae,r as je,s as R,t as Me}from"./useBreakpoint-kT0J1Dnk.js";import{t as Ne}from"./external-link-CI-Uzhfh.js";import{A as Pe,B as Fe,C as Ie,D as Le,E as Re,F as ze,H as Be,I as Ve,L as He,M as Ue,N as We,O as Ge,P as Ke,R as qe,S as Je,T as Ye,V as Xe,_ as Ze,a as Qe,b as $e,c as et,d as tt,f as nt,g as rt,h as it,i as at,j as ot,k as st,l as ct,m as lt,n as ut,o as dt,p as z,r as ft,s as pt,t as mt,u as ht,v as gt,w as _t,x as vt,y as yt,z as bt}from"./useNow-DfER3XvS.js";import{n as xt,t as St}from"./pencil-BtK08_f_.js";import{t as Ct}from"./link-2-D6l0YZ-8.js";import{t as wt}from"./play-j138GLHB.js";import{t as Tt}from"./plus-D935l0Os.js";import{n as Et,t as Dt}from"./Checkbox-D18Ch0n4.js";import{s as B,t as Ot,u as kt}from"./policyLogic-nqL3E08V.js";import{n as At,r as V}from"./TextArea-BQPdfjO_.js";import{c as H}from"./index-LsagdEq-.js";import{t as U}from"./TextLink-CCc3WEdm.js";import{n as jt,r as Mt,t as Nt}from"./Tabs-DZ2T9VBY.js";import{t as Pt}from"./SegmentedControl-D2kj3j7u.js";import{r as Ft}from"./useResource-DhvWL_9X.js";import{t as It}from"./Select-CpWLZnId.js";var Lt={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};Lt.node;var Rt=s(Lt),zt={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};zt.node;var Bt=s(zt),Vt={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};Vt.node;var Ht=s(Vt),Ut={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Ut.node;var Wt=s(Ut),Gt={name:`message-square-warning`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]};Gt.node;var Kt=s(Gt),qt=d(),W=e(u()),Jt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Yt(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Xt(e){return`nodeType`in e}function G(e){return e?Yt(e)?e:Xt(e)?e.ownerDocument?.defaultView??window:window:window}function Zt(e){let{Document:t}=G(e);return e instanceof t}function Qt(e){return!Yt(e)&&e instanceof G(e).HTMLElement}function $t(e){return e instanceof G(e).SVGElement}function en(e){return e?Yt(e)?e.document:Xt(e)?Zt(e)?e:Qt(e)||$t(e)?e.ownerDocument:document:document:document}var tn=Jt?W.useLayoutEffect:W.useEffect;function nn(e){let t=(0,W.useRef)(e);return tn(()=>{t.current=e}),(0,W.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function rn(){let e=(0,W.useRef)(null);return[(0,W.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,W.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function an(e,t){t===void 0&&(t=[e]);let n=(0,W.useRef)(e);return tn(()=>{n.current!==e&&(n.current=e)},t),n}function on(e,t){let n=(0,W.useRef)();return(0,W.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function sn(e){let t=nn(e),n=(0,W.useRef)(null);return[n,(0,W.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function cn(e){let t=(0,W.useRef)();return(0,W.useEffect)(()=>{t.current=e},[e]),t.current}var ln={};function un(e,t){return(0,W.useMemo)(()=>{if(t)return t;let n=ln[e]==null?0:ln[e]+1;return ln[e]=n,e+`-`+n},[e,t])}function dn(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var fn=dn(1),pn=dn(-1);function mn(e){return`clientX`in e&&`clientY`in e}function hn(e){if(!e)return!1;let{KeyboardEvent:t}=G(e.target);return t&&e instanceof t}function gn(e){if(!e)return!1;let{TouchEvent:t}=G(e.target);return t&&e instanceof t}function _n(e){if(gn(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return mn(e)?{x:e.clientX,y:e.clientY}:null}var vn=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[vn.Translate.toString(e),vn.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),yn=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function bn(e){return e.matches(yn)?e:e.querySelector(yn)}var xn={display:`none`};function Sn(e){let{id:t,value:n}=e;return W.createElement(`div`,{id:t,style:xn},n)}function Cn(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return W.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function wn(){let[e,t]=(0,W.useState)(``);return{announce:(0,W.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Tn=(0,W.createContext)(null);function En(e){let t=(0,W.useContext)(Tn);(0,W.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Dn(){let[e]=(0,W.useState)(()=>new Set),t=(0,W.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,W.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var On={draggable:`
|
|
2
|
-
To pick up a draggable item, press the space bar.
|
|
3
|
-
While dragging, use the arrow keys to move the item.
|
|
4
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
-
`},kn={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function An(e){let{announcements:t=kn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=On}=e,{announce:a,announcement:o}=wn(),s=un(`DndLiveRegion`),[c,l]=(0,W.useState)(!1);if((0,W.useEffect)(()=>{l(!0)},[]),En((0,W.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=W.createElement(W.Fragment,null,W.createElement(Sn,{id:r,value:i.draggable}),W.createElement(Cn,{id:s,announcement:o}));return n?(0,qt.createPortal)(u,n):u}var K;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(K||={});function jn(){}function Mn(e,t){return(0,W.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Nn(){var e=[...arguments];return(0,W.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var q=Object.freeze({x:0,y:0});function Pn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Fn(e,t){let n=_n(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function In(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Ln(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Rn(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function zn(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Bn(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var Vn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Bn(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Pn(Bn(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(In)};function Hn(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Un=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Hn(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Ln)};function Wn(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var Gn=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&Wn(r,a)){let n=Rn(a).reduce((e,t)=>e+Pn(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(In)};function Kn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function qn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:q}function Jn(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var Yn=Jn(1);function Xn(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Zn(e,t,n){let r=Xn(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Qn={ignoreTransform:!1};function $n(e,t){t===void 0&&(t=Qn);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=G(e).getComputedStyle(e);t&&(n=Zn(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function er(e){return $n(e,{ignoreTransform:!0})}function tr(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function nr(e,t){return t===void 0&&(t=G(e).getComputedStyle(e)),t.position===`fixed`}function rr(e,t){t===void 0&&(t=G(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function ir(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Zt(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Qt(i)||$t(i)||n.includes(i))return n;let a=G(e).getComputedStyle(i);return i!==e&&rr(i,a)&&n.push(i),nr(i,a)?n:r(i.parentNode)}return e?r(e):n}function ar(e){let[t]=ir(e,1);return t??null}function or(e){return!Jt||!e?null:Yt(e)?e:Xt(e)?Zt(e)||e===en(e).scrollingElement?window:Qt(e)?e:null:null}function sr(e){return Yt(e)?e.scrollX:e.scrollLeft}function cr(e){return Yt(e)?e.scrollY:e.scrollTop}function lr(e){return{x:sr(e),y:cr(e)}}var J;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(J||={});function ur(e){return!Jt||!e?!1:e===document.scrollingElement}function dr(e){let t={x:0,y:0},n=ur(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var fr={x:.2,y:.2};function pr(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=fr);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=dr(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=J.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=J.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=J.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=J.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function mr(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function hr(e){return e.reduce((e,t)=>fn(e,lr(t)),q)}function gr(e){return e.reduce((e,t)=>e+sr(t),0)}function _r(e){return e.reduce((e,t)=>e+cr(t),0)}function vr(e,t){if(t===void 0&&(t=$n),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);ar(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var yr=[[`x`,[`left`,`right`],gr],[`y`,[`top`,`bottom`],_r]],br=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=ir(t),r=hr(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of yr)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},xr=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Sr(e){let{EventTarget:t}=G(e);return e instanceof t?e:en(e)}function Cr(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var Y;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Y||={});function wr(e){e.preventDefault()}function Tr(e){e.stopPropagation()}var X;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(X||={});var Er={start:[X.Space,X.Enter],cancel:[X.Esc],end:[X.Space,X.Enter,X.Tab]},Dr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case X.Right:return{...n,x:n.x+25};case X.Left:return{...n,x:n.x-25};case X.Down:return{...n,y:n.y+25};case X.Up:return{...n,y:n.y-25}}},Or=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new xr(en(t)),this.windowListeners=new xr(G(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Y.Resize,this.handleCancel),this.windowListeners.add(Y.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Y.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&vr(n),t(q)}handleKeyDown(e){if(hn(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Er,coordinateGetter:a=Dr,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:q;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=pn(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=dr(n),p=mr(n),m={x:Math.min(i===X.Right?p.right-p.width/2:p.right,Math.max(i===X.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===X.Down?p.bottom-p.height/2:p.bottom,Math.max(i===X.Down?p.top:p.top+p.height/2,u.y))},h=i===X.Right&&!s||i===X.Left&&!c,g=i===X.Down&&!l||i===X.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===X.Right&&e<=d.x||i===X.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}r.x=a?n.scrollLeft-e:i===X.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===X.Down&&e<=d.y||i===X.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}r.y=a?n.scrollTop-e:i===X.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,fn(pn(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Or.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Er,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function kr(e){return!!(e&&`distance`in e)}function Ar(e){return!!(e&&`delay`in e)}var jr=class{constructor(e,t,n){n===void 0&&(n=Sr(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=en(i),this.documentListeners=new xr(this.document),this.listeners=new xr(n),this.windowListeners=new xr(G(i)),this.initialCoordinates=_n(r)??q,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Y.Resize,this.handleCancel),this.windowListeners.add(Y.DragStart,wr),this.windowListeners.add(Y.VisibilityChange,this.handleCancel),this.windowListeners.add(Y.ContextMenu,wr),this.documentListeners.add(Y.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ar(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(kr(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Y.Click,Tr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Y.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=_n(e)??q,s=pn(n,o);if(!t&&a){if(kr(a)){if(a.tolerance!=null&&Cr(s,a.tolerance))return this.handleCancel();if(Cr(s,a.distance))return this.handleStart()}if(Ar(a)&&Cr(s,a.tolerance))return this.handleCancel();this.handlePending(a,s)}else e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===X.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Mr={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Nr=class extends jr{constructor(e){let{event:t}=e,n=en(t.target);super(e,Mr,n)}};Nr.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Pr={move:{name:`mousemove`},end:{name:`mouseup`}},Fr;(function(e){e[e.RightClick=2]=`RightClick`})(Fr||={});var Ir=class extends jr{constructor(e){super(e,Pr,en(e.event.target))}};Ir.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==Fr.RightClick&&(r?.({event:n}),!0)}}];var Lr={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Rr=class extends jr{constructor(e){super(e,Lr)}static setup(){return window.addEventListener(Lr.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Lr.move.name,e)};function e(){}}};Rr.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var zr;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(zr||={});var Br;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Br||={});function Vr(e){let{acceleration:t,activator:n=zr.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Br.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Ur({delta:d,disabled:!a}),[m,h]=rn(),g=(0,W.useRef)({x:0,y:0}),_=(0,W.useRef)({x:0,y:0}),v=(0,W.useMemo)(()=>{switch(n){case zr.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case zr.DraggableRect:return i}},[n,i,c]),y=(0,W.useRef)(null),b=(0,W.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,W.useMemo)(()=>s===Br.TreeOrder?[...l].reverse():l,[s,l]);(0,W.useEffect)(()=>{if(!a||!l.length||!v)h();else{for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=pr(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()}},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Hr={x:{[J.Backward]:!1,[J.Forward]:!1},y:{[J.Backward]:!1,[J.Forward]:!1}};function Ur(e){let{delta:t,disabled:n}=e,r=cn(t);return on(e=>{if(n||!r||!e)return Hr;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[J.Backward]:e.x[J.Backward]||i.x===-1,[J.Forward]:e.x[J.Forward]||i.x===1},y:{[J.Backward]:e.y[J.Backward]||i.y===-1,[J.Forward]:e.y[J.Forward]||i.y===1}}},[n,t,r])}function Wr(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return on(e=>t==null?null:r??e??null,[r,t])}function Gr(e,t){return(0,W.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Kr;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Kr||={});var qr;(function(e){e.Optimized=`optimized`})(qr||={});var Jr=new Map;function Yr(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,W.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,W.useRef)(e),d=g(),f=an(d),p=(0,W.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,W.useRef)(null),h=on(t=>{if(d&&!n)return Jr;if(!t||t===Jr||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new br(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,W.useEffect)(()=>{u.current=e},[e]),(0,W.useEffect)(()=>{d||p()},[n,d]),(0,W.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,W.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Kr.Always:return!1;case Kr.BeforeDragging:return n;default:return!n}}}function Xr(e,t){return on(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Zr(e,t){return Xr(e,t)}function Qr(e){let{callback:t,disabled:n}=e,r=nn(t),i=(0,W.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,W.useEffect)(()=>()=>i?.disconnect(),[i]),i}function $r(e){let{callback:t,disabled:n}=e,r=nn(t),i=(0,W.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,W.useEffect)(()=>()=>i?.disconnect(),[i]),i}function ei(e){return new br($n(e),e)}function ti(e,t,n){t===void 0&&(t=ei);let[r,i]=(0,W.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Qr({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=$r({callback:a});return tn(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function ni(e){return qn(e,Xr(e))}var ri=[];function ii(e){let t=(0,W.useRef)(e),n=on(n=>e?n&&n!==ri&&e&&t.current&&e.parentNode===t.current.parentNode?n:ir(e):ri,[e]);return(0,W.useEffect)(()=>{t.current=e},[e]),n}function ai(e){let[t,n]=(0,W.useState)(null),r=(0,W.useRef)(e),i=(0,W.useCallback)(e=>{let t=or(e.target);t&&n(e=>e?(e.set(t,lr(t)),new Map(e)):null)},[]);return(0,W.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=or(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,lr(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{or(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,W.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>fn(e,t),q):hr(e):q,[e,t])}function oi(e,t){t===void 0&&(t=[]);let n=(0,W.useRef)(null);return(0,W.useEffect)(()=>{n.current=null},t),(0,W.useEffect)(()=>{let t=e!==q;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?pn(e,n.current):q}function si(e){(0,W.useEffect)(()=>{if(!Jt)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function ci(e,t){return(0,W.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function li(e){return(0,W.useMemo)(()=>e?tr(e):null,[e])}var ui=[];function di(e,t){t===void 0&&(t=$n);let[n]=e,r=li(n?G(n):null),[i,a]=(0,W.useState)(ui);function o(){a(()=>e.length?e.map(e=>ur(e)?r:new br(t(e),e)):ui)}let s=$r({callback:o});return tn(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function fi(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Qt(t)?t:e}function pi(e){let{measure:t}=e,[n,r]=(0,W.useState)(null),i=$r({callback:(0,W.useCallback)(e=>{for(let{target:n}of e)if(Qt(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=sn((0,W.useCallback)(e=>{let n=fi(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,W.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var mi=[{sensor:Nr,options:{}},{sensor:Or,options:{}}],hi={current:{}},gi={draggable:{measure:er},droppable:{measure:er,strategy:Kr.WhileDragging,frequency:qr.Optimized},dragOverlay:{measure:$n}},_i=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},vi={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new _i,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:jn},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:gi,measureDroppableContainers:jn,windowRect:null,measuringScheduled:!1},yi={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:jn,draggableNodes:new Map,over:null,measureDroppableContainers:jn},bi=(0,W.createContext)(yi),xi=(0,W.createContext)(vi);function Si(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new _i}}}function Ci(e,t){switch(t.type){case K.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case K.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case K.DragEnd:case K.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case K.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new _i(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case K.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new _i(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case K.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new _i(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function wi(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,W.useContext)(bi),a=cn(r),o=cn(n?.id);return(0,W.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!hn(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=bn(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Ti(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Ei(e){return(0,W.useMemo)(()=>({draggable:{...gi.draggable,...e?.draggable},droppable:{...gi.droppable,...e?.droppable},dragOverlay:{...gi.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Di(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,W.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;tn(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=qn(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=ar(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Oi=(0,W.createContext)({...q,scaleX:1,scaleY:1}),ki;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(ki||={});var Ai=(0,W.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=mi,collisionDetection:o=Un,measuring:s,modifiers:c,...l}=e,[u,d]=(0,W.useReducer)(Ci,void 0,Si),[f,p]=Dn(),[m,h]=(0,W.useState)(ki.Uninitialized),g=m===ki.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,W.useRef)({initial:null,translated:null}),C=(0,W.useMemo)(()=>_==null?null:{id:_,data:x?.data??hi,rect:S},[_,x]),w=(0,W.useRef)(null),[T,E]=(0,W.useState)(null),[D,O]=(0,W.useState)(null),k=an(l,Object.values(l)),A=un(`DndDescribedBy`,t),ee=(0,W.useMemo)(()=>b.getEnabled(),[b]),j=Ei(s),{droppableRects:M,measureDroppableContainers:te,measuringScheduled:ne}=Yr(ee,{dragging:g,dependencies:[y.x,y.y],config:j.droppable}),N=Wr(v,_),re=(0,W.useMemo)(()=>D?_n(D):null,[D]),ie=je(),ae=Zr(N,j.draggable.measure);Di({activeNode:_==null?null:v.get(_),config:ie.layoutShiftCompensation,initialRect:ae,measure:j.draggable.measure});let P=ti(N,j.draggable.measure,ae),oe=ti(N?N.parentElement:null),se=(0,W.useRef)({activatorEvent:null,active:null,activeNode:N,collisionRect:null,collisions:null,droppableRects:M,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ce=b.getNodeFor(se.current.over?.id),F=pi({measure:j.dragOverlay.measure}),le=F.nodeRef.current??N,I=g?F.rect??P:null,ue=!!(F.nodeRef.current&&F.rect),de=ni(ue?null:P),fe=li(le?G(le):null),pe=ii(g?ce??N:null),me=di(pe),he=Ti(c,{transform:{x:y.x-de.x,y:y.y-de.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:P,containerNodeRect:oe,draggingNodeRect:I,over:se.current.over,overlayNodeRect:F.rect,scrollableAncestors:pe,scrollableAncestorRects:me,windowRect:fe}),ge=re?fn(re,y):null,_e=ai(pe),ve=oi(_e),ye=oi(_e,[P]),L=fn(he,ve),be=I?Yn(I,he):null,xe=C&&be?o({active:C,collisionRect:be,droppableRects:M,droppableContainers:ee,pointerCoordinates:ge}):null,Se=zn(xe,`id`),[Ce,we]=(0,W.useState)(null),Te=Kn(ue?he:fn(he,ye),Ce?.rect??null,P),Ee=(0,W.useRef)(null),De=(0,W.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:se,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,qt.unstable_batchedUpdates)(()=>{r?.(i),h(ki.Initializing),d({type:K.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ee.current),O(a)})},onMove(e){d({type:K.DragMove,coordinates:e})},onEnd:s(K.DragEnd),onCancel:s(K.DragCancel)});Ee.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=se.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===K.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=K.DragCancel)}w.current=null,(0,qt.unstable_batchedUpdates)(()=>{d({type:e}),h(ki.Uninitialized),we(null),E(null),O(null),Ee.current=null;let t=e===K.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Oe=Gr(a,(0,W.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,De(n,t))},[v,De]));si(a),tn(()=>{P&&m===ki.Initializing&&h(ki.Initialized)},[P,m]),(0,W.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=se.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:L.x,y:L.y},over:i};(0,qt.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[L.x,L.y]),(0,W.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=se.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(Se),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,qt.unstable_batchedUpdates)(()=>{we(s),a?.(c),f({type:`onDragOver`,event:c})})},[Se]),tn(()=>{se.current={activatorEvent:D,active:C,activeNode:N,collisionRect:be,collisions:xe,droppableRects:M,draggableNodes:v,draggingNode:le,draggingNodeRect:I,droppableContainers:b,over:Ce,scrollableAncestors:pe,scrollAdjustedTranslate:L},S.current={initial:I,translated:be}},[C,N,xe,be,v,le,I,M,b,Ce,pe,L]),Vr({...ie,delta:y,draggingRect:be,pointerCoordinates:ge,scrollableAncestors:pe,scrollableAncestorRects:me});let ke=(0,W.useMemo)(()=>({active:C,activeNode:N,activeNodeRect:P,activatorEvent:D,collisions:xe,containerNodeRect:oe,dragOverlay:F,draggableNodes:v,droppableContainers:b,droppableRects:M,over:Ce,measureDroppableContainers:te,scrollableAncestors:pe,scrollableAncestorRects:me,measuringConfiguration:j,measuringScheduled:ne,windowRect:fe}),[C,N,P,D,xe,oe,F,v,b,M,Ce,te,pe,me,j,ne,fe]),Ae=(0,W.useMemo)(()=>({activatorEvent:D,activators:Oe,active:C,activeNodeRect:P,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:Ce,measureDroppableContainers:te}),[D,Oe,C,P,d,A,v,Ce,te]);return W.createElement(Tn.Provider,{value:p},W.createElement(bi.Provider,{value:Ae},W.createElement(xi.Provider,{value:ke},W.createElement(Oi.Provider,{value:Te},i)),W.createElement(wi,{disabled:n?.restoreFocus===!1})),W.createElement(An,{...n,hiddenTextDescribedById:A}));function je(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),ji=(0,W.createContext)(null),Mi=`button`,Ni=`Draggable`;function Pi(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=un(Ni),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,W.useContext)(bi),{role:p=Mi,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,W.useContext)(g?Oi:ji),[v,y]=sn(),[b,x]=sn(),S=ci(o,t),C=an(n);return tn(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,W.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Mi?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Fi(){return(0,W.useContext)(xi)}var Ii=`Droppable`,Li={timeout:25};function Ri(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=un(Ii),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,W.useContext)(bi),u=(0,W.useRef)({disabled:n}),d=(0,W.useRef)(!1),f=(0,W.useRef)(null),p=(0,W.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Li,...i},_=an(h??r),v=$r({callback:(0,W.useCallback)(()=>{d.current?(p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)):d.current=!0},[g]),disabled:m||!o}),[y,b]=sn((0,W.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=an(t);return(0,W.useEffect)(()=>{v&&y.current&&(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,W.useEffect)(()=>(s({type:K.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:K.UnregisterDroppable,key:a,id:r})),[r]),(0,W.useEffect)(()=>{n!==u.current.disabled&&(s({type:K.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function zi(e){let{animation:t,children:n}=e,[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),s=cn(n);return!n&&!r&&s&&i(s),tn(()=>{if(!a)return;let e=r?.key,n=r?.props.id;e==null||n==null?i(null):Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),W.createElement(W.Fragment,null,n,r?(0,W.cloneElement)(r,{ref:o}):null)}var Bi={x:0,y:0,scaleX:1,scaleY:1};function Vi(e){let{children:t}=e;return W.createElement(bi.Provider,{value:yi},W.createElement(Oi.Provider,{value:Bi},t))}var Hi={position:`fixed`,touchAction:`none`},Ui=e=>hn(e)?`transform 250ms ease`:void 0,Wi=(0,W.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Ui}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Hi,width:s.width,height:s.height,top:s.top,left:s.left,transform:vn.Transform.toString(d),transformOrigin:i&&r?Fn(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return W.createElement(n,{className:o,style:f,ref:t},a)}),Gi={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:vn.Transform.toString(t)},{transform:vn.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Ki(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return nn((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=fi(a);if(!c)return;let{transform:l}=G(a).getComputedStyle(a),u=Xn(l);if(!u)return;let d=typeof t==`function`?t:qi(t);return vr(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function qi(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Gi,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Ji=0;function Yi(e){return(0,W.useMemo)(()=>{if(e!=null)return Ji++,Ji},[e])}var Xi=W.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=Fi(),S=(0,W.useContext)(Oi),C=Yi(d?.id),w=Ti(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=Xr(f),E=Ki({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return W.createElement(Vi,null,W.createElement(zi,{animation:E},d&&C?W.createElement(Wi,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),Z=i(),Zi=(0,W.createContext)(null);function Qi(){let e=(0,W.useContext)(Zi);if(!e)throw Error(`useTaskMover must be used inside <MoveProvider>`);return e}var $i=`Accepting marks the task Done. It does not merge or push.`;function ea({children:e}){let[t,n]=(0,W.useState)({}),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),s=(0,W.useCallback)(async(e,t)=>{n(t=>({...t,[e]:!0}));try{await t()}finally{n(t=>{let{[e]:n,...r}=t;return r})}},[]),c=(0,W.useCallback)(async(e,t)=>{if(t===`ready`)try{let t=await We(e.id);R.success(`Moved to Ready. ${$e(t)}.`)}catch{R.success(`Moved to Ready. The dispatcher starts it when it is eligible.`)}else R.success(`Moved "${e.title}" to ${z[t]}`)},[]),u=(0,W.useCallback)(async(e,t,n)=>{try{return await ze(e.id,{to:t,...n}),await c(e,t),!0}catch(r){return!n.onRunning&&He(r)?(i({kind:`choice`,task:e,to:t,position:n.position,reasons:[],carry:{confirm:n.confirm}}),!1):!n.confirm&&Ve(r)?(i({kind:`confirm_done`,task:e,to:t,position:n.position,reasons:[A(r)],carry:{onRunning:n.onRunning}}),!1):(R.error(`Could not move "${e.title}": ${A(r)}`),!1)}},[c]),d=(0,W.useCallback)(e=>s(e.id,async()=>{try{await Xe(e.id,`run-now`),R.info(`Dispatch requested for "${e.title}". Waiting for the host to confirm.`)}catch(t){R.error(`Cannot run "${e.title}" now: ${A(t)}`)}}),[s]),m=(0,W.useCallback)(e=>s(e.id,async()=>{try{await Xe(e.id,`new-attempt`),R.info(`New attempt requested for "${e.title}".`)}catch(t){if(j(t,`native_session_missing`)){i({kind:`fresh_attempt`,task:e,to:`in_progress`,reasons:[A(t)]});return}R.error(`Could not start a new attempt: ${A(t)}`)}}),[s]),h=(0,W.useCallback)(async(e,t,n={})=>{let r=e.currentRunId?O.getState().runs[e.currentRunId]:void 0,a=Le(e,t,r);switch(a.kind){case`noop`:return;case`invalid`:R.error(a.reason);return;case`run_now`:return d(e);case`new_attempt`:return m(e);case`choose_running`:i({kind:`choice`,task:e,to:t,position:n.position,reasons:[]});return;case`confirm_done`:i({kind:`confirm_done`,task:e,to:t,position:n.position,reasons:a.reasons});return;case`move`:await s(e.id,async()=>{await u(e,t,{position:n.position})})}},[d,m,u,s]),g=(0,W.useCallback)((e,t)=>s(e.id,async()=>{try{await Be(e.id,{position:t})}catch(e){R.error(`Could not reorder: ${A(e)}`)}}),[s]),_=async e=>{if(!r)return;let t=r;o(e);try{if(t.kind===`fresh_attempt`)try{await Xe(t.task.id,`new-attempt`,{},`?fresh=true`),R.info(`New attempt in a fresh session requested for "${t.task.title}".`)}catch(e){R.error(`Could not start a new attempt: ${A(e)}`)}else t.via===`accept`?await s(t.task.id,async()=>{try{await Xe(t.task.id,`accept`,{confirm:!0}),R.success(`Accepted "${t.task.title}". It is Done.`)}catch(e){R.error(`Could not accept: ${A(e)}`)}}):await s(t.task.id,async()=>{await u(t.task,t.to,{position:t.position,...t.carry,...e===`confirm`?{confirm:!0}:{onRunning:e}})})}finally{o(null),i(e=>e===t?null:e)}},v=(0,W.useCallback)(e=>s(e.id,async()=>{try{await Xe(e.id,`accept`,{}),R.success(`Accepted "${e.title}". It is Done.`)}catch(t){if(Ve(t)){i({kind:`confirm_done`,task:e,to:`done`,reasons:[A(t)],via:`accept`});return}R.error(`Could not accept: ${A(t)}`)}}),[s]),y=(0,W.useMemo)(()=>({move:h,runNow:d,newAttempt:m,reorder:g,accept:v,isBusy:e=>!!t[e]}),[h,d,m,g,v,t]),b=()=>{a||i(null)};return(0,Z.jsxs)(Zi.Provider,{value:y,children:[e,(0,Z.jsx)(x,{open:r?.kind===`choice`,onClose:b,title:`This task is running`,description:r?`Moving "${r.task.title}" to ${z[r.to]} needs a decision about its active run. Nothing changes until you choose.`:void 0,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(l,{onClick:b,disabled:!!a,children:`Keep running`}),(0,Z.jsx)(l,{icon:(0,Z.jsx)(f,{className:`size-4`}),busy:a===`pause`,disabled:!!a,onClick:()=>void _(`pause`),children:`Pause automation`}),(0,Z.jsx)(l,{variant:`danger`,icon:(0,Z.jsx)(p,{className:`size-4`}),busy:a===`stop`,disabled:!!a,onClick:()=>void _(`stop`),children:`Stop execution`})]}),children:(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Pause automation`}),`: you take over the session. The agent keeps its current turn, and automatic continuations, retries and successor runs stop until you return it to automation.`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Stop execution`}),`: aborts the current run. The session and its workspace are kept.`]})]})}),(0,Z.jsxs)(C,{open:r?.kind===`confirm_done`,onClose:b,title:`Accept and mark Done?`,description:$i,danger:!1,confirmLabel:`Accept and mark Done`,busy:a===`confirm`,onConfirm:()=>void _(`confirm`),children:[(0,Z.jsx)(`p`,{className:`mb-2 text-sm`,children:`These items are unresolved:`}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-sm`,children:r?.reasons.map(e=>(0,Z.jsx)(`li`,{children:e},e))}),r&&r.task.acceptanceCriteria.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mt-3 mb-1 text-sm font-medium`,children:`Acceptance criteria`}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-sm text-muted`,children:r.task.acceptanceCriteria.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]})]}),(0,Z.jsx)(C,{open:r?.kind===`fresh_attempt`,onClose:b,title:`Start a fresh session?`,description:r?.reasons[0],danger:!1,confirmLabel:`Start fresh session`,busy:a===`confirm`,onConfirm:()=>void _(`confirm`),children:(0,Z.jsx)(`p`,{className:`text-sm`,children:`The previous Pi session is no longer available on the host, so the new attempt cannot continue it. A fresh session starts with the task objective and your review feedback.`})})]})}function ta(e){let t=O(e=>e.runs),n=O(e=>e.hosts),r=O(e=>e.sessions),i=O(e=>e.workspaces),a=O(e=>e.projects),o=O(e=>e.attention),s=O(e=>e.interactions);return(0,W.useMemo)(()=>{if(!e)return{run:void 0,hostName:null,hostOffline:!1,branch:null,projectName:null,attention:[],pendingInteraction:void 0};let c=e.currentRunId?t[e.currentRunId]:void 0,l=e.sessionId?r[e.sessionId]:void 0,u=c?.hostId??l?.hostId??e.policy.hostId??null,d=u?n[u]:void 0,f=(l?.workspaceId?i[l.workspaceId]:void 0)?.branch??(e.policy.workspace.mode===`new_worktree`?e.policy.workspace.branch:null)??(e.policy.workspace.mode===`existing`?i[e.policy.workspace.workspaceId]?.branch??null:null),p=Object.values(o).filter(t=>N(t)&&(t.taskId===e.id||!!e.sessionId&&t.sessionId===e.sessionId)),m=e.sessionId?D(s,e.sessionId)[0]:void 0;return{run:c,hostName:d?.name??null,hostOffline:!!d&&d.connectivity!==`connected`,branch:f??null,projectName:a[e.projectId]?.name??null,attention:p,pendingInteraction:m}},[e,t,n,r,i,a,o,s])}function na(e,t,n){if(e.blocked)return{icon:fe,text:`Blocked: ${e.blocked.reason}`,tone:`danger`};if(e.state===`in_progress`&&t){let e=b[t.state],n=t.controlMode===`human`?` · You have control`:``;return{icon:e.icon,text:`${e.label}${n}`,tone:e.tone,spin:e.spin,pulse:e.pulse}}return e.state===`ready`?n&&!n.eligible?{icon:ke,text:n.message||lt[n.wait],tone:`warning`}:n?.eligible?{icon:ke,text:`Starting on ${n.hostName}`,tone:`info`}:{icon:ke,text:`Queued for dispatch`,tone:`neutral`}:e.state===`review`?e.review.changesRequested?{icon:fe,text:`Changes requested`,tone:`warning`}:t?.outcome?{icon:b.succeeded.icon,text:t.outcome.summary||`Ready for review`,tone:`info`}:{icon:b.succeeded.icon,text:`Ready for review`,tone:`info`}:null}var ra=`Accepting marks the task Done. It does not merge or push.`;function ia(e){return e.sessionId?`${H.session(e.sessionId)}?tab=changes`:null}function aa(e){let t=!!e&&(e.state===`ready`||e.state===`backlog`),n=t?`${e.id}:${e.state}:${e.updatedAt}`:null,r=Ft(n,t=>We(e.id,t)),i=O(e=>e.hosts),a=O(e=>e.tasks),o=O(e=>e.projects),s=O(e=>e.runs),c=O(e=>e.dispatchPaused),l=(0,W.useMemo)(()=>{if(!e)return;let t={};for(let e of Object.values(s)){if(!vt(e))continue;let n=a[e.taskId]?.projectId;n&&(t[n]=(t[n]??0)+1)}return st({project:o[e.projectId],hostId:e.policy.hostId,dependencies:e.dependencies,notBefore:e.notBefore},{hosts:i,tasks:a,dispatchPaused:c,runningByProject:t})},[e,i,a,o,s,c]),u=r.data,d;return t?u?d=!u.eligible&&u.wait===`not_ready`?l:u:r.error&&(d=l):d=void 0,{eligibility:d,loading:r.loading&&!r.data,error:r.error,estimated:!!d&&d===l}}function oa({title:e,children:t,action:n}){let r=(0,W.useId)();return(0,Z.jsxs)(`section`,{"aria-labelledby":r,className:`flex min-w-0 flex-col gap-2 border-b border-border py-4 last:border-b-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h3`,{id:r,className:`min-w-0 flex-1 text-sm font-semibold`,children:e}),n]}),t]})}function Q({label:e,children:t}){return(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(7rem,auto)_1fr] gap-x-3 text-sm`,children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]})}function sa({task:e}){let t=e.tracker,[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(null),o=async e=>{r(!0),a(null);try{await e()}catch(e){a(e)}finally{r(!1)}},s=t.pullRequest,c=t.board;return(0,Z.jsxs)(oa,{title:`Tracker`,action:t.branch===null?(0,Z.jsx)(l,{size:`sm`,variant:`secondary`,disabled:n,onClick:()=>void o(()=>Fe(e.id)),children:`Start work`}):void 0,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Issue`,children:e.githubIssue?(0,Z.jsxs)(U,{href:e.githubIssue.url,external:!0,children:[t.repository,` #`,t.number]}):`${t.repository} #${t.number}`}),(0,Z.jsx)(Q,{label:`Branch`,children:t.branch??`None yet`}),(0,Z.jsx)(Q,{label:`Pull request`,children:s?(0,Z.jsxs)(U,{href:s.url,external:!0,children:[`#`,s.number,` `,s.state.toLowerCase()]}):`None`}),(0,Z.jsx)(Q,{label:`Assignees`,children:t.assignees.join(`, `)||`None`}),c&&(0,Z.jsx)(Q,{label:`Board column`,children:(0,Z.jsxs)(It,{"aria-label":`Board column`,width:`auto`,value:c.status??``,disabled:n,onChange:t=>{let n=t.target.value;n&&o(()=>bt(e.id,n))},children:[c.status===null&&(0,Z.jsx)(`option`,{value:``,children:`No column`}),c.options.map(e=>(0,Z.jsx)(`option`,{value:e.name,children:e.name},e.id))]})})]}),i!==null&&(0,Z.jsx)(`p`,{className:`text-sm text-danger`,children:A(i)})]})}function ca({task:e,eligibility:t,block:n}){let r=Qi(),i=r.isBusy(e.id),s=t?(0,Z.jsx)(la,{e:t,prefix:e.state===`backlog`?`If made ready: `:``}):null;switch(e.state){case`backlog`:return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(l,{variant:`primary`,block:n,busy:i,icon:(0,Z.jsx)(wt,{className:`size-4`}),onClick:()=>void r.move(e,`ready`),children:`Make ready`}),s]});case`ready`:return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(l,{variant:`primary`,block:n,busy:i,icon:(0,Z.jsx)(wt,{className:`size-4`}),onClick:()=>void r.runNow(e),children:`Run now`}),s]});case`in_progress`:return e.sessionId?(0,Z.jsxs)(a,{to:H.session(e.sessionId),className:o(`primary`,`md`,n?`w-full`:void 0),children:[(0,Z.jsx)(Ne,{"aria-hidden":!0,className:`size-4`}),`Open session`]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:e.blocked?`No session is attached to this task.`:`The session is starting; Open session appears once the host confirms the launch.`});case`review`:{let t=ia(e);return t?(0,Z.jsxs)(a,{to:t,className:o(`primary`,`md`,n?`w-full`:void 0),children:[(0,Z.jsx)(m,{"aria-hidden":!0,className:`size-4`}),`Review changes`]}):(0,Z.jsxs)(`a`,{href:`#task-review`,className:o(`primary`,`md`,n?`w-full`:void 0),children:[(0,Z.jsx)(m,{"aria-hidden":!0,className:`size-4`}),`Review changes`]})}case`done`:return(0,Z.jsx)(l,{variant:`primary`,block:n,busy:i,icon:(0,Z.jsx)(Se,{className:`size-4`}),onClick:()=>void r.move(e,`backlog`),children:`Reopen to Backlog`});case`canceled`:return(0,Z.jsx)(l,{variant:`primary`,block:n,busy:i,icon:(0,Z.jsx)(Se,{className:`size-4`}),onClick:()=>void r.move(e,`backlog`),children:`Restore to Backlog`})}}function la({e,prefix:t=``}){let r=e.eligible?Ae:ke;return(0,Z.jsxs)(`p`,{role:`status`,className:n(`flex items-start gap-1.5 text-sm`,e.eligible?`text-success`:`text-warning`),children:[(0,Z.jsx)(r,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 break-words text-text`,children:[t,$e(e)]})]})}function ua(e){return(0,Z.jsx)(da,{...e},e.task.id)}function da({task:e,onDeleted:t}){let n=ta(e),{eligibility:r,error:i}=aa(e),s=O(e=>e.tasks),c=O(e=>e.hosts),u=O(e=>e.profiles),d=O(e=>e.projects),f=O(e=>e.workspaces),p=O(e=>e.runs),m=Ft(`${e.id}:${e.currentRunId??``}`,t=>Ke(e.id,t)),h=(0,W.useMemo)(()=>{let t=new Map;for(let e of m.data??[])t.set(e.id,e);for(let n of te(p,e.id)){let e=t.get(n.id);(!e||e.updatedAt<=n.updatedAt)&&t.set(n.id,n)}return[...t.values()].sort((e,t)=>t.attempt-e.attempt||t.createdAt.localeCompare(e.createdAt))},[m.data,p,e.id]),[_,v]=(0,W.useState)(!1),y=O(e=>e.sessions),b=e.parentTaskId?s[e.parentTaskId]:void 0,x=Object.values(s).filter(t=>t.parentTaskId===e.id&&t.id!==e.id&&t.projectId===e.projectId).sort((e,t)=>e.position-t.position||e.title.localeCompare(t.title)),S=d[e.projectId],C=n.run,w=na(e,C,r),T=e.policy.hostId??S?.defaultHostId??null,E=T?c[T]:void 0,D=C?.hostId?c[C.hostId]:void 0,k=D&&D.connectivity!==`connected`?D:void 0,ee=e.policy.profileId??S?.defaultProfileId??null,M=O(t=>e.sessionId?ne(t.interactions,e.sessionId):0);return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,"data-testid":`task-detail`,children:[M>0&&e.sessionId&&n.pendingInteraction&&(0,Z.jsx)(ce,{count:M,to:H.interaction(e.sessionId,n.pendingInteraction.id),className:`mt-3`}),k&&(0,Z.jsx)(oe,{compact:!0,className:`mt-3`,hostName:k.name,connectivity:k.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:k.lastSeenAt,detail:`The run keeps its last known state. Switchyard does not restart it on another host.`}),(0,Z.jsxs)(oa,{title:`Objective and acceptance criteria`,action:!_&&(0,Z.jsx)(l,{size:`sm`,variant:`ghost`,icon:(0,Z.jsx)(St,{className:`size-3.5`}),onClick:()=>v(!0),children:`Edit`}),children:[e.githubIssue&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`a`,{href:e.githubIssue.url,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent underline`,children:[e.githubIssue.repository,` #`,e.githubIssue.number]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`The first run reads the linked issue. Changes to the objective or acceptance text do not alter its saved initial prompt; later attempts use the current task details.`})]}),_?(0,Z.jsx)(ha,{task:e,onDone:()=>v(!1)}):(0,Z.jsxs)(Z.Fragment,{children:[e.objective.trim()?(0,Z.jsx)(Mt,{text:e.objective}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective yet. Edit the task to describe what done looks like.`}),(0,Z.jsx)(`h4`,{className:`pt-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:`Acceptance criteria`}),e.acceptanceCriteria.length>0?(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-sm`,children:e.acceptanceCriteria.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},e))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No acceptance criteria.`})]})]}),e.tracker&&(0,Z.jsx)(sa,{task:e}),(0,Z.jsxs)(oa,{title:`State`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(g,{kind:`task`,value:e.state}),(0,Z.jsx)(Ee,{priority:e.priority,suffix:` priority`,muted:!0,className:`text-sm`})]}),e.blocked&&(0,Z.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md bg-danger-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(fe,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Z.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Blocked:`}),` `,e.blocked.reason]})]}),w&&!e.blocked&&!(e.state===`ready`&&r)&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:w.text}),(e.state===`ready`||e.state===`backlog`)&&r&&(0,Z.jsx)(la,{e:r,prefix:e.state===`backlog`?`If made ready: `:``}),i!==null&&j(i)&&i.status===404&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Eligibility is estimated on this device; the coordinator did not report it.`}),e.notBefore&&(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Not before `,F(e.notBefore)]})]}),(0,Z.jsxs)(oa,{title:`Current run`,children:[C?(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Status`,children:(0,Z.jsx)(g,{kind:`run`,value:C.state,size:`sm`})}),(0,Z.jsx)(Q,{label:`Attempt`,children:C.attempt}),(0,Z.jsx)(Q,{label:`Control`,children:C.controlMode===`human`?`You (taken over from automation)`:`Automation`}),D&&(0,Z.jsx)(Q,{label:`Host`,children:D.name}),C.startedAt&&(0,Z.jsx)(Q,{label:`Started`,children:P(C.startedAt)}),(0,Z.jsx)(Q,{label:`Continuations`,children:C.continuationsUsed}),(0,Z.jsx)(Q,{label:`Usage`,children:C.usage.accounting===`available`?`${C.usage.tokens??0} tokens${C.usage.costUsd===null?``:` · $${C.usage.costUsd.toFixed(2)}`}`:C.usage.note??`Token/cost accounting not reported`}),C.outcome&&(0,Z.jsx)(Q,{label:`Outcome`,children:C.outcome.summary})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No run yet.`}),e.sessionId&&e.state!==`in_progress`&&e.state!==`review`&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(a,{to:H.session(e.sessionId),className:o(`secondary`,`sm`),children:[(0,Z.jsx)(Ne,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})})]}),e.state===`review`&&(0,Z.jsx)(ma,{task:e}),(0,Z.jsxs)(oa,{title:`Parent and subtasks`,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Parent`,children:b?(0,Z.jsx)(U,{to:H.task(b.id),variant:`action`,children:b.title}):e.parentTaskId?`A task that is no longer available`:`None`}),e.agentOrigin&&(0,Z.jsxs)(Q,{label:`Created by`,children:[`Agent in`,` `,(0,Z.jsx)(U,{to:H.session(e.agentOrigin.sessionId),variant:`action`,children:y[e.agentOrigin.sessionId]?.title??e.agentOrigin.sessionId}),(0,Z.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Tool call: `,e.agentOrigin.toolCallId]})]})]}),x.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No subtasks.`}):(0,Z.jsx)(`ul`,{"aria-label":`Subtasks`,className:`flex flex-col gap-1`,children:x.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,Z.jsx)(g,{kind:`task`,value:e.state,size:`sm`}),(0,Z.jsx)(U,{to:H.task(e.id),variant:`action`,className:`truncate`,children:e.title})]},e.id))}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Parent relationships do not add dependencies. Each task moves and runs independently.`})]}),(0,Z.jsx)(oa,{title:`Dependencies`,children:e.dependencies.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No dependencies.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.dependencies.map(e=>{let t=s[e];return(0,Z.jsx)(`li`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g,{kind:`task`,value:t.state,size:`sm`}),(0,Z.jsx)(U,{to:H.task(e),variant:`action`,className:`truncate`,children:t.title})]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`A task that is no longer available`})},e)})})}),(0,Z.jsxs)(oa,{title:`Host, profile and workspace`,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Project`,children:S?.name??`Unknown project`}),(0,Z.jsx)(Q,{label:`Host`,children:e.policy.hostId?E?.name??`Unknown host`:`Project default${E?` (${E.name})`:``}`}),(0,Z.jsx)(Q,{label:`Profile`,children:e.policy.profileId?u[e.policy.profileId]?.name??`Unknown profile`:`Project default${ee&&u[ee]?` (${u[ee].name})`:``}`}),(0,Z.jsx)(Q,{label:`Workspace`,children:e.policy.workspace.mode===`existing`?`Existing: ${f[e.policy.workspace.workspaceId]?.branch??f[e.policy.workspace.workspaceId]?.path??`unknown workspace`}`:`New worktree${e.policy.workspace.branch?` on ${e.policy.workspace.branch}`:``}${e.policy.workspace.base?` from ${e.policy.workspace.base}`:``}`}),S&&(0,Z.jsx)(Q,{label:`Sharing`,children:S.workspaceSharing===`single_writer`?`Single writer`:`Shared`})]}),E&&!E.piCompatible&&(0,Z.jsx)(ue,{capability:`Running on this host`,reason:`Pi ${E.piVersion??`(unknown version)`} on ${E.name} is not compatible with Switchyard.`})]}),(0,Z.jsxs)(oa,{title:`Limits and completion`,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Continuation`,children:e.policy.continuation.enabled?`Up to ${e.policy.continuation.maxContinuations} continuations within ${e.policy.continuation.maxElapsedMinutes} min${e.policy.continuation.maxTokens?`, continuation budget ${e.policy.continuation.maxTokens} tokens`:``}${e.policy.continuation.maxCostUsd?`, $${e.policy.continuation.maxCostUsd}`:``}`:`Off`}),(0,Z.jsx)(Q,{label:`Checks`,children:e.policy.completion.checks===null?`Project default${S?.checks.length?` (${S.checks.join(`, `)})`:` (none)`}`:e.policy.completion.checks.length>0?e.policy.completion.checks.join(`, `):`None`}),(0,Z.jsx)(Q,{label:`Human review`,children:e.policy.completion.requireHumanReview?`Required`:`Not required`})]}),e.policy.continuation.enabled&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:Ot}),C&&C.checks.length>0&&(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:C.checks.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5`,children:[e.exitCode===0?(0,Z.jsx)(Ae,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,Z.jsx)(fe,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-xs`,children:e.command}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:e.exitCode===0?`Passed`:`Failed (${e.exitCode??`no exit code`})`})]},e.command))})]}),(0,Z.jsxs)(oa,{title:`Run history and activity`,children:[m.error!==null&&!m.data&&h.length===0&&(0,Z.jsx)(se,{compact:!0,title:`Could not load run history`,error:A(m.error),onRetry:m.reload}),h.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:m.loading?`Loading runs…`:`No runs yet.`}):(0,Z.jsx)(`ol`,{className:`flex flex-col gap-2`,children:h.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-0.5 rounded-md border border-border px-3 py-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[`Attempt `,e.attempt]}),(0,Z.jsx)(g,{kind:`run`,value:e.state,size:`sm`})]}),e.outcome&&(0,Z.jsx)(`p`,{className:`break-words text-muted`,children:e.outcome.summary}),(0,Z.jsxs)(`p`,{className:`text-xs text-subtle`,children:[e.startedAt?`Started ${F(e.startedAt)}`:`Created ${F(e.createdAt)}`,e.startedAt&&e.endedAt?` · ${ae(Date.parse(e.endedAt)-Date.parse(e.startedAt))}`:``,e.infraRetries>0?` · ${e.infraRetries} infrastructure retries`:``]})]},e.id))}),e.review.feedback.length>0&&(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Review feedback`}),(0,Z.jsx)(`ul`,{className:`list-disc pl-5 text-muted`,children:e.review.feedback.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,Z.jsxs)(`p`,{className:`text-xs text-subtle`,children:[`Created `,F(e.createdAt),` · last activity `,P(e.lastActivityAt),e.origin.kind===`automation`?` · created by an automation`:``]})]}),(0,Z.jsx)(fa,{task:e,onDeleted:t})]})}function fa({task:e,onDeleted:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1);return e.state!==`backlog`&&e.state!==`canceled`&&e.state!==`done`?null:(0,Z.jsxs)(`div`,{className:`py-4`,children:[(0,Z.jsx)(l,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(kt,{className:`size-4`}),className:`text-danger`,onClick:()=>r(!0),children:`Delete task`}),(0,Z.jsx)(C,{open:n,onClose:()=>r(!1),title:`Delete this task?`,description:`"${e.title}" and its history are removed from the board. Sessions and workspaces are kept.`,confirmLabel:`Delete task`,busy:i,onConfirm:async()=>{a(!0);try{await Ue(e.id),R.success(`Deleted "${e.title}"`),r(!1),t?.()}catch(e){R.error(`Could not delete: ${A(e)}`)}finally{a(!1)}}})]})}var pa=e=>`sy:feedback:${e}`;function ma({task:e}){let t=Qi(),[n,r]=(0,W.useState)(()=>sessionStorage.getItem(pa(e.id))??``),[i,a]=(0,W.useState)(null),o=(0,W.useId)();(0,W.useEffect)(()=>{n?sessionStorage.setItem(pa(e.id),n):sessionStorage.removeItem(pa(e.id))},[n,e.id]);let s=n.split(`
|
|
6
|
-
`).map(e=>e.replace(/^[-*]\s*/,``).trim()).filter(Boolean);return(0,Z.jsxs)(`section`,{id:`task-review`,"aria-labelledby":`${o}-h`,className:`flex min-w-0 flex-col gap-3 border-b border-border py-4`,children:[(0,Z.jsx)(`h3`,{id:`${o}-h`,className:`text-sm font-semibold`,children:`Review`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:o,className:`text-sm font-medium`,children:`Feedback for the next attempt`}),(0,Z.jsx)(At,{id:o,minRows:3,maxHeight:`40vh`,placeholder:`One change per line`,value:n,onChange:e=>r(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(l,{icon:(0,Z.jsx)(Kt,{className:`size-4`}),busy:i===`changes`,disabled:i!==null||s.length===0,onClick:async()=>{a(`changes`);try{await qe(e.id,s),r(``),R.success(`Changes requested. Start a new attempt when ready.`)}catch(e){R.error(`Could not request changes: ${A(e)}`)}finally{a(null)}},children:`Request changes`}),(0,Z.jsx)(l,{icon:(0,Z.jsx)(Se,{className:`size-4`}),busy:t.isBusy(e.id),disabled:i!==null,onClick:()=>void t.newAttempt(e),children:`Start new attempt`})]}),s.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Write at least one line of feedback to request changes.`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(l,{variant:`primary`,icon:(0,Z.jsx)(Ae,{className:`size-4`}),busy:t.isBusy(e.id),disabled:i!==null,onClick:()=>void t.accept(e),children:`Accept task`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:ra})]})]})}function ha({task:e,onDone:t}){let n=O(e=>e.tasks),[r,i]=(0,W.useState)(e.title),[a,o]=(0,W.useState)(e.objective),[s,c]=(0,W.useState)(e.acceptanceCriteria.join(`
|
|
7
|
-
`)),[u,d]=(0,W.useState)(e.priority),[f,p]=(0,W.useState)(e.dependencies),[m,h]=(0,W.useState)(e.parentTaskId??``),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),b=(0,W.useId)(),x=Object.values(n).filter(t=>t.projectId===e.projectId&&t.id!==e.id&&t.state!==`canceled`&&!t.hiddenFromBoard).sort((e,t)=>e.title.localeCompare(t.title));return(0,Z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:async n=>{if(n.preventDefault(),!r.trim())y(`Title is required.`);else{_(!0),y(null);try{await Be(e.id,{title:r.trim(),objective:a,acceptanceCriteria:s.split(`
|
|
8
|
-
`).map(e=>e.trim()).filter(Boolean),priority:u,dependencies:f,parentTaskId:m||null}),R.success(`Task saved`),t()}catch(e){y(A(e))}finally{_(!1)}}},children:[(0,Z.jsx)(B,{id:`${b}-title`,label:`Title`,children:(0,Z.jsx)(V,{id:`${b}-title`,value:r,onChange:e=>i(e.target.value),required:!0})}),(0,Z.jsx)(B,{id:`${b}-obj`,label:`Objective`,children:(0,Z.jsx)(At,{id:`${b}-obj`,minRows:4,maxHeight:`40vh`,value:a,onChange:e=>o(e.target.value)})}),(0,Z.jsx)(B,{id:`${b}-crit`,label:`Acceptance criteria (one per line)`,children:(0,Z.jsx)(At,{id:`${b}-crit`,minRows:2,maxHeight:`30vh`,value:s,onChange:e=>c(e.target.value)})}),(0,Z.jsx)(B,{id:`${b}-prio`,label:`Priority`,children:e=>(0,Z.jsx)(De,{...e,value:u,onChange:d})}),(0,Z.jsx)(ga,{candidates:Re(e.projectId,n,e.id),value:m,onChange:h}),(0,Z.jsx)(_a,{candidates:x,value:f,onChange:p}),v&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:v}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(l,{type:`submit`,variant:`primary`,busy:g,children:`Save`}),(0,Z.jsx)(l,{onClick:t,disabled:g,children:`Cancel`})]})]})}function ga({candidates:e,value:t,onChange:n,error:r}){let i=(0,W.useId)();return(0,Z.jsx)(B,{id:i,label:`Parent task`,hint:`Optional grouping only; dependencies are selected separately.`,error:r,children:r=>(0,Z.jsxs)(It,{...r,value:t,onChange:e=>n(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None`}),t&&!e.some(e=>e.id===t)&&(0,Z.jsx)(`option`,{value:t,disabled:!0,children:`Unavailable parent — choose another or None`}),e.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.title,` (`,z[e.state],`)`]},e.id))]})})}function _a({candidates:e,value:t,onChange:n}){let[r,i]=(0,W.useState)(``),a=(0,W.useId)(),o=e.filter(e=>t.includes(e.id)||e.title.toLowerCase().includes(r.toLowerCase())).slice(0,50);return(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Dependencies`}),e.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No other tasks in this project.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{htmlFor:a,className:`sr-only`,children:`Filter tasks`}),(0,Z.jsx)(V,{id:a,placeholder:`Filter tasks`,value:r,onChange:e=>i(e.target.value)}),(0,Z.jsx)(`ul`,{className:`max-h-48 overflow-y-auto rounded-md border border-border`,children:o.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Dt,{className:`w-full px-3 py-1.5 hover:bg-surface-2`,label:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:z[e.state]})]}),checked:t.includes(e.id),onChange:r=>n(r?[...t,e.id]:t.filter(t=>t!==e.id))})},e.id))}),t.length>0&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted`,children:[t.length,` selected. The task waits until they are Done.`]})]})]})}var va=`sy:new-task-draft`;function ya(e){return{title:``,githubIssueUrl:``,objective:``,projectId:e,advanced:!1,priority:2,dependencies:[],parentTaskId:``,hostId:``,profileId:``,branch:``,criteria:``,continuation:!1,contObjective:``,maxContinuations:`3`,maxMinutes:`60`,maxTokens:``,maxCost:``,checks:``,checksMode:`default`,humanReview:!0}}function ba(e){try{let t=sessionStorage.getItem(va);if(t)return{...ya(e),...JSON.parse(t)}}catch{}return ya(e)}var xa=e=>e.split(`
|
|
9
|
-
`).map(e=>e.trim()).filter(Boolean);function Sa(e){let t={},n={},r=!!e.githubIssueUrl.trim();if(e.hostId&&(n.hostId=e.hostId),e.profileId&&(n.profileId=e.profileId),e.branch.trim()&&(n.workspace={mode:`new_worktree`,branch:e.branch.trim(),base:null}),r)n.continuation={...le.continuation,enabled:!1};else if(e.continuation){let r=Number(e.maxContinuations),i=Number(e.maxMinutes),a=e.maxTokens.trim()?Number(e.maxTokens):null,o=e.maxCost.trim()?Number(e.maxCost):null;e.contObjective.trim()||(t.contObjective=`Continuation needs an objective.`),(!Number.isInteger(r)||r<1||r>50)&&(t.maxContinuations=`Use 1 to 50.`),(!Number.isInteger(i)||i<1||i>1440)&&(t.maxMinutes=`Use 1 to 1440 minutes.`),a!==null&&(!Number.isInteger(a)||a<=0)&&(t.maxTokens=`Use a positive whole number.`),o!==null&&(!Number.isFinite(o)||o<=0)&&(t.maxCost=`Use a positive amount.`),n.continuation={enabled:!0,objective:e.contObjective.trim(),maxContinuations:r,maxElapsedMinutes:i,maxTokens:a,maxCostUsd:o}}return(r||e.checksMode===`custom`||!e.humanReview)&&(n.completion={checks:e.checksMode===`custom`?xa(e.checks):null,requireHumanReview:r||e.humanReview}),{policy:n,errors:t}}function Ca({defaultProjectId:e,onCreated:t,onCancel:n}){let r=k(),i=ee(),a=O(e=>e.profiles),o=O(e=>e.tasks),s=O(e=>e.runs),c=O(e=>e.hosts),u=O(e=>e.dispatchPaused),[d,f]=(0,W.useState)(()=>ba(e??r[0]?.id??``)),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)({}),[_,v]=(0,W.useState)(null),y=(0,W.useId)(),b=(e,t)=>f(n=>({...n,[e]:t}));(0,W.useEffect)(()=>{!d.projectId&&r[0]&&f(e=>({...e,projectId:r[0].id}))},[d.projectId,r]),(0,W.useEffect)(()=>{sessionStorage.setItem(va,JSON.stringify(d))},[d]);let x=!!d.githubIssueUrl.trim(),S=de.safeParse(d.githubIssueUrl),C=S.success?me(S.data):null,w=r.find(e=>e.id===d.projectId),T=w?.defaultHostId?c[w.defaultHostId]:void 0,E=w?.defaultProfileId?a[w.defaultProfileId]:void 0,D=Object.values(o).filter(e=>e.projectId===d.projectId&&e.state!==`canceled`&&!e.hiddenFromBoard).sort((e,t)=>e.title.localeCompare(t.title)),j=Re(d.projectId,o),M=(0,W.useMemo)(()=>{let e={};for(let t of Object.values(s)){if(!vt(t))continue;let n=o[t.taskId]?.projectId;n&&(e[n]=(e[n]??0)+1)}return st({project:w,hostId:d.hostId||null,dependencies:d.dependencies},{hosts:c,tasks:o,dispatchPaused:u,runningByProject:e})},[w,d.hostId,d.dependencies,c,o,s,u]),te=async e=>{let n={};!x&&!d.title.trim()&&(n.title=`Give the task a title.`),x&&!S.success&&(n.githubIssueUrl=`Use https://github.com/OWNER/REPO/issues/NUMBER with no query or fragment.`),w||(n.projectId=`Choose a project.`),d.parentTaskId&&!j.some(e=>e.id===d.parentTaskId)&&(n.parentTaskId=`Choose a parent in this project, or None.`);let{policy:r,errors:i}=Sa(d);if(Object.assign(n,i),g(n),Object.keys(n).length>0)Object.keys(i).length>0&&b(`advanced`,!0);else{m(e),v(null);try{let n=await ot({projectId:d.projectId,title:d.title.trim(),...x?{githubIssueUrl:d.githubIssueUrl}:{},objective:x?``:d.objective,acceptanceCriteria:x?[]:xa(d.criteria),dependencies:d.dependencies,parentTaskId:d.parentTaskId||null,priority:d.priority,state:e,...Object.keys(r).length>0?{policy:r}:{}});if(sessionStorage.removeItem(va),e===`ready`){let e=$e(M);try{e=$e(await We(n.id))}catch{}R.success(`Created "${n.title}" in Ready. ${e}.`)}else R.success(`Created "${n.title}" in Backlog.`);t(n)}catch(e){v(A(e))}finally{m(null)}}};return(0,Z.jsxs)(`form`,{"data-testid":`new-task-form`,className:`flex min-w-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),te(`backlog`)},children:[(0,Z.jsx)(B,{id:`${y}-issue`,label:`GitHub issue URL`,hint:`Optional. The first run sends only the issue link and a gh issue view instruction, with continuation off and human review required.`,error:h.githubIssueUrl,children:e=>(0,Z.jsx)(V,{...e,value:d.githubIssueUrl,onChange:e=>b(`githubIssueUrl`,e.target.value),placeholder:`https://github.com/OWNER/REPO/issues/17`})}),(0,Z.jsx)(B,{id:`${y}-title`,label:`Title`,hint:x?`Optional for issue imports; leave blank to use the issue reference.`:void 0,error:h.title,children:e=>(0,Z.jsx)(V,{...e,value:d.title,autoFocus:!0,onChange:e=>b(`title`,e.target.value),placeholder:C?`${C.repository} #${C.number}`:`What should be done?`,maxLength:300})}),!x&&(0,Z.jsx)(B,{id:`${y}-objective`,label:`Objective`,children:(0,Z.jsx)(At,{id:`${y}-objective`,minRows:3,maxHeight:`35vh`,value:d.objective,onChange:e=>b(`objective`,e.target.value),placeholder:`Context, constraints and what done looks like`})}),(0,Z.jsx)(B,{id:`${y}-project`,label:`Project`,error:h.projectId,children:e=>(0,Z.jsxs)(It,{...e,value:d.projectId,onChange:e=>f(t=>({...t,projectId:e.target.value,dependencies:[],parentTaskId:``})),children:[r.length===0&&(0,Z.jsx)(`option`,{value:``,children:`No projects yet`}),r.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(ga,{candidates:j,value:d.parentTaskId,onChange:e=>b(`parentTaskId`,e),error:h.parentTaskId}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(U,{size:`sm`,"aria-expanded":d.advanced,"aria-controls":`${y}-adv`,icon:d.advanced?(0,Z.jsx)(xe,{"aria-hidden":!0,className:`size-4`}):(0,Z.jsx)(Te,{"aria-hidden":!0,className:`size-4`}),onClick:()=>b(`advanced`,!d.advanced),children:`Advanced options`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Unset options inherit the project defaults.`})]}),d.advanced&&(0,Z.jsxs)(`div`,{id:`${y}-adv`,className:`flex flex-col gap-4 rounded-lg border border-border p-3`,children:[(0,Z.jsx)(B,{id:`${y}-prio`,label:`Priority`,children:e=>(0,Z.jsx)(De,{...e,value:d.priority,onChange:e=>b(`priority`,e)})}),!x&&(0,Z.jsx)(B,{id:`${y}-criteria`,label:`Acceptance criteria (one per line)`,children:(0,Z.jsx)(At,{id:`${y}-criteria`,minRows:2,maxHeight:`25vh`,value:d.criteria,onChange:e=>b(`criteria`,e.target.value)})}),(0,Z.jsx)(_a,{candidates:D,value:d.dependencies,onChange:e=>b(`dependencies`,e)}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(B,{id:`${y}-host`,label:`Host`,children:(0,Z.jsxs)(It,{id:`${y}-host`,value:d.hostId,onChange:e=>b(`hostId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,T?` (${T.name})`:``]}),i.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (offline)`]},e.id))]})}),(0,Z.jsx)(B,{id:`${y}-profile`,label:`Pi profile`,children:(0,Z.jsxs)(It,{id:`${y}-profile`,value:d.profileId,onChange:e=>b(`profileId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,E?` (${E.name})`:``]}),Object.values(a).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,Z.jsx)(B,{id:`${y}-branch`,label:`Branch`,hint:`Work happens in a new worktree on this branch.`,children:e=>(0,Z.jsx)(V,{...e,value:d.branch,placeholder:`Generated from the title`,onChange:e=>b(`branch`,e.target.value)})}),!x&&(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Continuation limits`}),(0,Z.jsx)(Dt,{label:`Continue automatically until done (off by default)`,checked:d.continuation,onChange:e=>b(`continuation`,e)}),d.continuation&&(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(B,{id:`${y}-cobj`,label:`Continuation objective`,error:h.contObjective,className:`sm:col-span-2`,children:e=>(0,Z.jsx)(V,{...e,value:d.contObjective,onChange:e=>b(`contObjective`,e.target.value)})}),(0,Z.jsx)(B,{id:`${y}-cmax`,label:`Max continuations`,error:h.maxContinuations,children:e=>(0,Z.jsx)(V,{...e,inputMode:`decimal`,value:d.maxContinuations,onChange:e=>b(`maxContinuations`,e.target.value)})}),(0,Z.jsx)(B,{id:`${y}-cmin`,label:`Max minutes`,error:h.maxMinutes,children:e=>(0,Z.jsx)(V,{...e,inputMode:`decimal`,value:d.maxMinutes,onChange:e=>b(`maxMinutes`,e.target.value)})}),(0,Z.jsx)(B,{id:`${y}-ctok`,label:`Continuation budget: tokens (optional)`,error:h.maxTokens,children:e=>(0,Z.jsx)(V,{...e,inputMode:`decimal`,value:d.maxTokens,onChange:e=>b(`maxTokens`,e.target.value)})}),(0,Z.jsx)(B,{id:`${y}-ccost`,label:`Continuation budget: cost USD (optional)`,error:h.maxCost,children:e=>(0,Z.jsx)(V,{...e,inputMode:`decimal`,value:d.maxCost,onChange:e=>b(`maxCost`,e.target.value)})}),(0,Z.jsx)(`p`,{className:`text-xs text-muted sm:col-span-2`,children:Ot})]})]}),(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Checks and review`}),(0,Z.jsx)(Dt,{label:(0,Z.jsxs)(Z.Fragment,{children:[`Use custom checks instead of the project's`,w?.checks.length?` (${w.checks.join(`, `)})`:` (none)`]}),checked:d.checksMode===`custom`,onChange:e=>b(`checksMode`,e?`custom`:`default`)}),d.checksMode===`custom`&&(0,Z.jsx)(B,{id:`${y}-checks`,label:`Check commands (one per line; empty means no checks)`,children:(0,Z.jsx)(At,{id:`${y}-checks`,minRows:2,className:`font-mono`,value:d.checks,onChange:e=>b(`checks`,e.target.value)})}),x?(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Issue imports require human review before Done.`}):(0,Z.jsx)(Dt,{label:`Require human review before Done`,checked:d.humanReview,onChange:e=>b(`humanReview`,e)})]})]}),_&&(0,Z.jsxs)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-sm`,children:[`Could not create the task: `,_]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-3`,children:[(0,Z.jsx)(la,{e:M,prefix:`Make ready: `}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(l,{type:`submit`,icon:(0,Z.jsx)(re,{className:`size-4`}),busy:p===`backlog`,disabled:p!==null,children:`Save to Backlog`}),(0,Z.jsx)(l,{variant:`primary`,icon:(0,Z.jsx)(wt,{className:`size-4`}),busy:p===`ready`,disabled:p!==null,onClick:()=>void te(`ready`),children:`Make ready`}),(0,Z.jsx)(l,{variant:`ghost`,onClick:n,disabled:p!==null,children:`Cancel`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Make ready authorizes dispatch. Nothing starts until the coordinator confirms.`})]})]})}function wa(){let e=L(e=>e.filters.board),t=L(e=>e.setFilter),n=L(e=>e.selectedProjectId),r=L(e=>e.set),i=(0,W.useMemo)(()=>_t(e),[e]),a=O(e=>e.tasks),o=O(e=>e.runs),s=O(e=>e.attention),c=O(e=>e.projects),l=mt(),u=n&&c[n]?n:null,d=(0,W.useMemo)(()=>{let e=new Set(Ye(s).keys());return rt(a,i,{projectId:u,runs:o,attentionTaskIds:e})},[a,i,u,o,s]),f=(0,W.useMemo)(()=>{let e=Object.fromEntries(Object.entries(a).filter(([,e])=>!u||e.projectId===u)),t={};for(let n of Object.keys(d))t[n]=it(d[n],e);let n=new Map,r=new Set(Object.values(e).map(e=>e.parentTaskId));for(let t of r)t&&n.set(t,Ze(t,e));return{trees:t,progress:n}},[a,u,d]),p=(0,W.useMemo)(()=>{let e=new Map;for(let t of l.data?.queued??[])e.set(t.taskId,t.eligibility);return e},[l.data]),m=(0,W.useMemo)(()=>l.data?l.data.queued.filter(e=>!u||a[e.taskId]?.projectId===u).length:Object.values(a).filter(e=>e.state===`ready`&&!e.hiddenFromBoard&&(!u||e.projectId===u)).length,[l.data,a,u]),h=Pe(i),g=(0,W.useMemo)(()=>Object.values(a).filter(e=>!e.hiddenFromBoard&&(!u||e.projectId===u)).length,[a,u]),_=h.reduce((e,t)=>e+d[t].length,0);return{filters:i,setFilters:e=>t(`board`,e),projectId:u,setProjectId:e=>r(`selectedProjectId`,e),columns:d,trees:f.trees,childProgress:f.progress,states:h,waits:p,queueCount:m,now:l,showProject:!u&&Object.keys(c).length>1,totalTasks:g,visibleCount:_}}var $={mainScrollTop:0,boardScrollLeft:0,columnScroll:{},focusTaskId:null};function Ta({task:e,showProject:r,wait:i,onOpen:o,drag:s,full:l,selected:u,depth:d=0,ancestors:f=[],progress:p}){let m=ta(e),h=O(e=>e.tasks),g=Qi(),_=t(),v=g.isBusy(e.id),y=na(e,m.run,i),b=yt(e,h),x=m.attention[0],S=e.parentTaskId?h[e.parentTaskId]:void 0,C=f.length?`, depth ${f.length}, under ${f.map(e=>e.title).join(` / `)}`:``,T=[{id:`open`,label:`Open details`,icon:(0,Z.jsx)(Ce,{className:`size-4`}),onSelect:()=>o(e)}];if(e.sessionId){let t=e.sessionId;T.push({id:`session`,label:`Open session`,icon:(0,Z.jsx)(Ne,{className:`size-4`}),onSelect:()=>_(H.session(t))})}T.push(`separator`);for(let t of Ie(e))T.push({id:`move-${t}`,label:Oa(e.state,t),icon:(0,Z.jsx)(Da,{state:t}),onSelect:()=>void g.move(e,t)});return(0,Z.jsxs)(`article`,{ref:s?.setNodeRef,"data-testid":`task-card`,"data-task-id":e.id,"aria-label":`${e.title}${C}`,"aria-busy":v||void 0,"data-depth":d,style:{marginInlineStart:`${Math.min(d,3)*12}px`,...s?.style},...s?.cardProps,className:n(`group relative flex min-w-0 flex-col gap-1.5 rounded-lg border bg-surface p-3 text-sm shadow-sm`,u?`border-accent`:`border-border`,s?.dragging&&`opacity-60`,l?`self-stretch`:``),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[s&&(0,Z.jsx)(`button`,{type:`button`,ref:s.setHandleRef,...s.handleProps,"data-keyboard-ignore":!0,"aria-label":`Drag ${e.title}${C}`,title:`Drag to move (Space to pick up, arrows to move, Space to drop)`,className:`tap -ml-1.5 inline-flex h-7 w-5 shrink-0 cursor-grab items-center justify-center rounded text-subtle hover:bg-surface-2 hover:text-text`,children:(0,Z.jsx)(Ht,{"aria-hidden":!0,className:`size-4`})}),(0,Z.jsx)(`button`,{type:`button`,"data-card-open":e.id,"data-keyboard-item":!0,onClick:()=>o(e),className:`tap min-w-0 flex-1 rounded text-left font-medium leading-snug`,children:(0,Z.jsx)(`span`,{className:`line-clamp-2 break-words`,children:e.title})}),v&&(0,Z.jsx)(c,{label:`Updating`,className:`mt-0.5 shrink-0`}),(0,Z.jsx)(we,{label:`Actions for ${e.title}`,items:T,trigger:t=>(0,Z.jsx)(`button`,{type:`button`,...t,"aria-label":`Move to… and other actions for ${e.title}`,title:`Move to…`,className:`tap -mr-1.5 inline-flex size-7 shrink-0 items-center justify-center rounded text-muted hover:bg-surface-2 hover:text-text`,children:(0,Z.jsx)(_e,{"aria-hidden":!0,className:`size-4`})})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted`,children:[(0,Z.jsx)(Ee,{priority:e.priority}),r&&m.projectName&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:m.projectName})]}),e.parentTaskId&&(0,Z.jsxs)(a,{to:H.task(e.parentTaskId),state:l?je:void 0,onClick:t=>{!l||t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||($.mainScrollTop=document.getElementById(`main`)?.scrollTop??0,$.focusTaskId=e.id)},className:`tap min-w-0 truncate rounded text-xs text-muted hover:underline`,children:[`Parent: `,S?.title??`Unavailable task`]}),p&&p.total>0&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted`,children:[p.done,`/`,p.total,` done`,p.canceled>0&&` · ${p.canceled} canceled`]}),y&&(0,Z.jsx)(Ea,{icon:y.spin?(0,Z.jsx)(c,{className:`size-3.5`}):(0,Z.jsx)(y.icon,{"aria-hidden":!0,className:n(`size-3.5`,y.pulse&&`animate-pulse`)}),className:E[y.tone],children:y.text}),(m.hostName||m.branch)&&(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted`,children:[m.hostName&&(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(ve,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[m.hostName,m.hostOffline?` (offline)`:``]})]}),m.branch&&(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(xt,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:m.branch})]})]}),b&&(0,Z.jsx)(Ea,{icon:(0,Z.jsx)(Ct,{"aria-hidden":!0,className:`size-3.5`}),className:`text-muted`,children:b}),m.pendingInteraction&&e.sessionId?(0,Z.jsxs)(a,{to:H.interaction(e.sessionId,m.pendingInteraction.id),className:`tap inline-flex min-w-0 items-center gap-1 rounded text-xs font-medium text-warning hover:underline`,children:[(0,Z.jsx)(pe,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[`Needs input: `,m.pendingInteraction.title]})]}):x?(0,Z.jsxs)(Ea,{icon:(0,Z.jsx)(ye,{"aria-hidden":!0,className:`size-3.5`}),className:E[w[x.reason].tone],children:[w[x.reason].label,m.attention.length>1?` (+${m.attention.length-1})`:``]}):null,(0,Z.jsxs)(`div`,{className:`text-xs text-subtle`,children:[`Updated `,(0,Z.jsx)(`time`,{dateTime:e.lastActivityAt,children:P(e.lastActivityAt)})]})]})}function Ea({icon:e,children:t,className:r}){return(0,Z.jsxs)(`div`,{className:n(`flex min-w-0 items-start gap-1 text-xs`,r),children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words line-clamp-2`,children:t})]})}function Da({state:e,className:t}){let r=h[e].icon;return(0,Z.jsx)(r,{"aria-hidden":!0,className:n(`size-4`,t)})}function Oa(e,t){return e===`ready`&&t===`in_progress`?`Run now (In progress)`:e===`review`&&t===`in_progress`?`Start new attempt (In progress)`:e===`backlog`&&t===`ready`?`Make ready`:(e===`done`||e===`canceled`)&&t!==`canceled`?`Reopen to ${z[t]}`:t===`canceled`?`Cancel task`:t===`done`?`Accept (Done)`:`Move to ${z[t]}`}var ka=`col:`,Aa=`card:`,ja=`task:`,Ma=(e,{currentCoordinates:t,context:n})=>{if(e.code===`ArrowDown`)return{...t,y:t.y+72};if(e.code===`ArrowUp`)return{...t,y:t.y-72};if(e.code!==`ArrowRight`&&e.code!==`ArrowLeft`)return;e.preventDefault();let r=n.droppableContainers.toArray().filter(e=>String(e.id).startsWith(ka)).map(e=>({id:e.id,rect:n.droppableRects.get(e.id)})).filter(e=>!!e.rect).sort((e,t)=>e.rect.left-t.rect.left);if(r.length===0)return;let i=n.collisionRect?.width??0,a=t.x+i/2,o=r.findIndex(e=>a>=e.rect.left&&a<=e.rect.left+e.rect.width);o<0&&(o=0);let s=r[Math.max(0,Math.min(r.length-1,o+(e.code===`ArrowRight`?1:-1)))];return{x:s.rect.left+(s.rect.width-i)/2,y:t.y}},Na=e=>{let t=Gn(e);if(t.length>0){let e=t.find(e=>String(e.id).startsWith(Aa));return e?[e]:t}return Vn(e)};function Pa(e,t){if(e.startsWith(ka))return{state:e.slice(4),beforeId:null};if(e.startsWith(Aa)){let n=t[e.slice(5)];return n?{state:n.state,beforeId:n.id}:null}return null}function Fa({taskId:e}){let n=wa(),r=O(e=>e.hydrated),i=O(e=>e.projects),a=O(e=>e.tasks),o=Qi(),s=t(),c=Oe(H.board),u=L(e=>e.paneSizes.boardColumn),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),h=Nn(Mn(Nr,{activationConstraint:{distance:6}}),Mn(Or,{coordinateGetter:Ma,keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]}})),g=(0,W.useCallback)(e=>{e&&(e.scrollLeft=$.boardScrollLeft)},[]);(0,W.useEffect)(()=>{if(e||!$.focusTaskId)return;let t=$.focusTaskId;$.focusTaskId=null,requestAnimationFrame(()=>document.querySelector(`[data-card-open="${CSS.escape(t)}"]`)?.focus({preventScroll:!1}))},[e]);let _=e=>{$.focusTaskId=e.id,s(H.task(e.id),{state:je})},v=()=>{e&&($.focusTaskId=e),c()},y=e=>f(String(e.active.id).slice(5)),b=e=>{f(null);let t=String(e.active.id).slice(5),r=a[t];if(!r||!e.over)return;let i=Pa(String(e.over.id),a);if(!i||i.beforeId===t)return;let s=n.columns[i.state],c=Ge(s,i.beforeId,t);i.state===r.state?n.filters.sort===`priority`&&o.reorder(r,c):o.move(r,i.state,{position:c})},C={onDragStart:({active:e})=>`Picked up ${La(e.id,a)}.`,onDragOver:({active:e,over:t})=>t?`${La(e.id,a)} is over ${Ra(String(t.id),a)}.`:void 0,onDragEnd:({active:e,over:t})=>t?`Dropped ${La(e.id,a)} on ${Ra(String(t.id),a)}.`:`Dropped ${La(e.id,a)}. It did not move.`,onDragCancel:({active:e})=>`Moving ${La(e.id,a)} was canceled.`},w=d?a[d]:void 0,T=e?a[e]:void 0,E=r&&Object.keys(i).length===0,D=O(e=>e.runs),k=e=>{if(!w||e===w.state)return null;let t=w.currentRunId?D[w.currentRunId]:void 0;return Le(w,e,t).kind===`invalid`?`invalid`:`valid`};return(0,Z.jsxs)(`div`,{"data-testid":`board`,className:`absolute inset-0 flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-border px-4 py-2.5`,children:[(0,Z.jsx)(`h1`,{className:`mr-2 text-lg font-semibold`,children:`Board`}),(0,Z.jsx)(et,{board:n}),(0,Z.jsx)(ct,{board:n,className:`w-56 max-w-full`}),(0,Z.jsx)(dt,{board:n}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[E&&(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:`Add a project first`}),(0,Z.jsx)(l,{variant:`primary`,icon:(0,Z.jsx)(Tt,{className:`size-4`}),onClick:()=>m(!0),disabled:E,children:`New task`})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-5 gap-y-2 border-b border-border px-4 py-2`,children:[(0,Z.jsx)(Qe,{}),(0,Z.jsxs)(`span`,{className:`text-sm text-muted`,role:`status`,children:[n.queueCount,` queued`]}),(0,Z.jsx)(ht,{board:n}),(0,Z.jsx)(ft,{board:n}),(0,Z.jsx)(pt,{board:n})]}),(0,Z.jsx)(ut,{board:n}),r?E?(0,Z.jsx)(I,{icon:(0,Z.jsx)(he,{className:`size-8`}),title:`No projects yet`,description:`Tasks belong to a project. Add a project from a host checkout to start planning work.`,action:{label:`Add a project`,to:H.settings(`projects`)}}):n.totalTasks===0?(0,Z.jsx)(I,{icon:(0,Z.jsx)(he,{className:`size-8`}),title:`No tasks yet`,description:`Create a task in Backlog, or make it ready so the dispatcher starts it.`,action:{label:`New task`,onClick:()=>m(!0)}}):(0,Z.jsxs)(Ai,{sensors:h,collisionDetection:Na,onDragStart:y,onDragEnd:b,onDragCancel:()=>f(null),accessibility:{announcements:C,screenReaderInstructions:{draggable:`To move a task, press Space to pick it up, use the arrow keys to move between columns, then press Space to drop or Escape to cancel. The task menu offers Move to… without dragging.`}},children:[n.visibleCount===0&&(0,Z.jsxs)(`p`,{role:`status`,className:`px-4 pt-3 text-sm text-muted`,children:[`No tasks match the filters.`,` `,(0,Z.jsx)(U,{onClick:()=>n.setFilters({...nt,sort:n.filters.sort}),children:`Clear filters`})]}),(0,Z.jsx)(`section`,{ref:g,"aria-label":`Board columns`,"data-keyboard-columns":!0,"data-keyboard-default":!0,onScroll:e=>{$.boardScrollLeft=e.currentTarget.scrollLeft},className:`min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:(0,Z.jsx)(`div`,{className:`flex h-full w-max gap-3 p-4`,children:n.states.map(t=>(0,Z.jsx)(za,{state:t,board:n,width:u,onOpen:_,selectedId:e,drop:k(t),onNew:()=>m(!0)},t))})}),(0,Z.jsx)(Xi,{dropAnimation:null,children:w&&(0,Z.jsx)(`div`,{className:`rotate-1 shadow-pop`,style:{width:`clamp(272px, ${u-16}px, 344px)`},children:(0,Z.jsx)(Ta,{task:w,showProject:n.showProject,wait:n.waits.get(w.id),progress:n.childProgress.get(w.id),onOpen:()=>void 0})})})]}):(0,Z.jsx)(ie,{label:`Loading tasks…`}),(0,Z.jsx)(S,{open:!!e,onClose:v,width:520,title:T?.title??(r?`Task not found`:`Loading task…`),description:T?z[T.state]:void 0,footer:T?(0,Z.jsx)(Ia,{task:T}):void 0,children:(0,Z.jsx)(`div`,{"data-testid":`task-drawer`,className:`min-w-0`,children:T?(0,Z.jsx)(ua,{task:T,onDeleted:()=>s(H.board,{replace:!0})}):r?(0,Z.jsx)(I,{title:`Task not found`,description:`It may have been deleted, or this link is from another coordinator.`,action:{label:`Back to board`,to:H.board}}):(0,Z.jsx)(ie,{label:`Loading task…`})})}),(0,Z.jsx)(x,{open:p,onClose:()=>m(!1),title:`New task`,className:`max-w-xl`,children:(0,Z.jsx)(Ca,{defaultProjectId:n.projectId,onCancel:()=>m(!1),onCreated:e=>{m(!1),$.focusTaskId=e.id,requestAnimationFrame(()=>document.querySelector(`[data-card-open="${CSS.escape(e.id)}"]`)?.focus())}})})]})}function Ia({task:e}){let{eligibility:t}=aa(e),n=Qi(),r=O(t=>e.currentRunId?t.runs[e.currentRunId]:void 0),i=tt.filter(t=>t!==e.state).map(t=>{let i=Le(e,t,r);return{id:`move-${t}`,label:Oa(e.state,t),icon:(0,Z.jsx)(Da,{state:t}),disabled:i.kind===`invalid`,hint:Je(i)??void 0,onSelect:()=>void n.move(e,t)}});return(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(ca,{task:e,eligibility:t})}),(0,Z.jsx)(we,{label:`Move ${e.title}`,side:`top`,align:`end`,items:i,trigger:e=>(0,Z.jsx)(l,{...e,icon:(0,Z.jsx)(Rt,{className:`size-4`}),children:`Move to…`})})]})}function La(e,t){let n=t[String(e).replace(ja,``)];return n?`task ${n.title}`:`task`}function Ra(e,t){if(e.startsWith(ka))return`the ${z[e.slice(4)]} column`;let n=t[e.slice(5)];return n?`${n.title} in ${z[n.state]}`:`a task`}function za({state:e,board:t,width:r,onOpen:i,selectedId:a,drop:o,onNew:s}){let{setNodeRef:c,isOver:l}=Ri({id:`${ka}${e}`}),[u,d]=(0,W.useState)(!1),f=t.columns[e],p=h[e].icon,m=e===`done`&&!t.filters.showCompleted&&!u,g=`col-${e}-title`,_=(0,W.useCallback)(t=>{t&&(t.scrollTop=$.columnScroll[e]??0)},[e]);return(0,Z.jsx)(`section`,{ref:c,"data-testid":`column-${e}`,"aria-labelledby":g,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-column":!0,style:{width:`clamp(288px, ${r}px, 360px)`},"data-drop":o??void 0,className:n(`flex h-full shrink-0 flex-col rounded-lg border bg-surface-2`,o===`invalid`?n(`border-dashed opacity-50`,l?`border-danger`:`border-border`):l?`border-accent`:`border-border`),children:(0,Z.jsxs)(`div`,{ref:_,"data-column-scroll":e,onScroll:t=>{$.columnScroll[e]=t.currentTarget.scrollTop},className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain`,children:[(0,Z.jsxs)(`h2`,{id:g,className:`sticky top-0 z-10 flex items-center gap-2 rounded-t-lg border-b border-border bg-surface-2 px-3 py-2 text-sm font-semibold`,children:[(0,Z.jsx)(p,{"aria-hidden":!0,className:`size-4 text-muted`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:z[e]}),o===`invalid`&&(0,Z.jsx)(`span`,{className:`text-xs font-normal text-muted`,children:`Can't move here`}),(0,Z.jsxs)(`span`,{className:`rounded-full bg-surface px-2 text-xs font-medium text-muted tabular-nums`,children:[f.length,(0,Z.jsx)(`span`,{className:`sr-only`,children:` tasks`})]})]}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2 p-2`,children:m?(0,Z.jsxs)(`li`,{className:`flex flex-col items-start gap-1 px-1 py-2 text-sm text-muted`,children:[f.length,` completed `,f.length===1?`task is`:`tasks are`,` hidden.`,f.length>0&&(0,Z.jsx)(U,{onClick:()=>d(!0),children:`Show completed`})]}):f.length===0?(0,Z.jsx)(`li`,{className:`px-1 py-2 text-sm text-muted`,children:e===`backlog`?(0,Z.jsx)(U,{icon:(0,Z.jsx)(Tt,{"aria-hidden":!0,className:`size-4`}),onClick:s,children:`New task`}):`No tasks`}):gt(t.trees[e]).map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Ba,{node:e,board:t,onOpen:i,selected:e.task.id===a})},e.task.id))})]})})}function Ba({node:e,board:t,onOpen:n,selected:r}){let{task:i,depth:a,ancestors:o}=e,s=Pi({id:`${ja}${i.id}`}),c=Ri({id:`${Aa}${i.id}`,disabled:s.isDragging}),{onPointerDown:l,onKeyDown:u}=s.listeners??{},d={setNodeRef:e=>{s.setNodeRef(e),c.setNodeRef(e)},setHandleRef:s.setActivatorNodeRef,cardProps:{onPointerDown:l},handleProps:{...s.attributes,onKeyDown:u},dragging:s.isDragging,style:c.isOver?{boxShadow:`0 -3px 0 0 var(--sy-accent)`}:void 0};return(0,Z.jsx)(Ta,{task:i,depth:a,ancestors:o,progress:t.childProgress.get(i.id),showProject:t.showProject,wait:t.waits.get(i.id),onOpen:n,drag:d,selected:r})}var Va=()=>document.getElementById(`main`);function Ha(){let e=wa(),n=O(e=>e.hydrated),r=O(e=>e.projects),i=t(),[a,o]=be(`board-mobile`,{tab:`ready`,layout:`column`}),[s,c]=(0,W.useState)(!1),u=(0,W.useId)(),[d,f]=(0,W.useState)(()=>e.filters.search!==``),p=d||e.filters.search!==``,m=e.states.includes(a.tab)?a.tab:`ready`;(0,W.useLayoutEffect)(()=>{if(!n)return;let e=Va(),t=$.mainScrollTop;e&&(e.scrollTop=t);let r=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{e&&e.scrollTop<t&&(e.scrollTop=t)})}),i=$.focusTaskId;return $.focusTaskId=null,i&&requestAnimationFrame(()=>document.querySelector(`[data-card-open="${CSS.escape(i)}"]`)?.focus({preventScroll:!0})),()=>cancelAnimationFrame(r)},[n]);let g=e=>{$.mainScrollTop=Va()?.scrollTop??0,$.focusTaskId=e.id,i(H.task(e.id),{state:je})},v=n&&Object.keys(r).length===0,b=t=>e.columns[t].length===0?(0,Z.jsxs)(`p`,{className:`px-1 py-3 text-sm text-muted`,children:[`No `,z[t],` tasks.`]}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:gt(e.trees[t]).map(({task:t,depth:n,ancestors:r})=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Ta,{task:t,depth:n,ancestors:r,progress:e.childProgress.get(t.id),full:!0,showProject:e.showProject,wait:e.waits.get(t.id),onOpen:g})},t.id))});return(0,Z.jsxs)(`div`,{"data-testid":`board`,className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`header`,{"data-testid":`board-header`,className:`sticky top-0 z-20 flex min-w-0 flex-col border-b border-border bg-bg safe-pt`,children:[(0,Z.jsxs)(`div`,{className:`flex h-14 min-w-0 items-center gap-1 px-3`,children:[(0,Z.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-lg font-semibold`,children:`Board`}),(0,Z.jsx)(y,{label:p?`Hide search`:`Show search`,"aria-expanded":p,"aria-controls":u,icon:(0,Z.jsx)(Et,{className:`size-5`}),onClick:()=>{p?(e.setFilters({...e.filters,search:``}),f(!1)):f(!0)}}),(0,Z.jsx)(dt,{board:e,mobile:!0,extraCount:+!!e.projectId,extra:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(et,{board:e,labelVisible:!0}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:`Layout`}),(0,Z.jsx)(Pt,{label:`Board layout`,block:!0,value:a.layout,onChange:e=>o({...a,layout:e}),options:[{value:`column`,label:`Columns`,icon:(0,Z.jsx)(Bt,{"aria-hidden":!0,className:`size-4`})},{value:`list`,label:`List`,icon:(0,Z.jsx)(Wt,{"aria-hidden":!0,className:`size-4`})}]})]})]})}),(0,Z.jsx)(l,{variant:`primary`,size:`sm`,icon:(0,Z.jsx)(Tt,{className:`size-4`}),"aria-label":`New task`,onClick:()=>c(!0),disabled:v,children:`New`})]}),v&&(0,Z.jsx)(`p`,{className:`px-3 pb-2 text-xs text-muted`,children:`Add a project to create tasks.`}),p&&(0,Z.jsx)(`div`,{id:u,className:`px-3 pb-2`,children:(0,Z.jsx)(ct,{board:e,autoFocus:d&&!e.filters.search})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-3 pb-2`,children:[(0,Z.jsx)(at,{queueCount:e.queueCount}),(0,Z.jsx)(pt,{board:e})]}),a.layout===`column`&&(0,Z.jsx)(`div`,{"data-testid":`status-tabs`,className:`px-1`,children:(0,Z.jsx)(jt,{label:`Task status`,idPrefix:`board-tab`,scrollable:!0,className:`border-b-0`,value:m,onChange:e=>o({...a,tab:e}),tabs:e.states.map(t=>{let n=h[t].icon;return{id:t,label:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(n,{"aria-hidden":!0,className:`size-4`}),z[t]]}),badge:(0,Z.jsx)(T,{label:`${e.columns[t].length} tasks`,children:e.columns[t].length})}})})})]}),(0,Z.jsx)(ut,{board:e}),(0,Z.jsx)(`section`,{"aria-label":`Board tasks`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`flex min-w-0 flex-col gap-3 px-3 py-3`,children:n?v?(0,Z.jsx)(I,{icon:(0,Z.jsx)(he,{className:`size-8`}),title:`No projects yet`,description:`Tasks belong to a project. Add a project from a host checkout first.`,action:{label:`Add a project`,to:H.settings(`projects`)}}):e.totalTasks===0?(0,Z.jsx)(I,{icon:(0,Z.jsx)(he,{className:`size-8`}),title:`No tasks yet`,description:`Create a task in Backlog, or make it ready so the dispatcher starts it.`,action:{label:`New task`,onClick:()=>c(!0)}}):e.visibleCount===0?(0,Z.jsx)(I,{title:`No tasks match the filters`,action:{label:`Clear filters`,onClick:()=>e.setFilters({...nt,sort:e.filters.sort})}}):a.layout===`column`?(0,Z.jsx)(Nt,{idPrefix:`board-tab`,id:m,children:m===`done`&&!e.filters.showCompleted?(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Completed tasks are hidden.`,` `,(0,Z.jsx)(U,{onClick:()=>e.setFilters({...e.filters,showCompleted:!0}),children:`Show completed`})]}):b(m)}):e.states.filter(t=>t!==`done`||e.filters.showCompleted).map(t=>(0,Z.jsxs)(`section`,{"aria-labelledby":`grp-${t}`,"data-testid":`column-${t}`,className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`h2`,{id:`grp-${t}`,className:`flex items-center gap-2 pt-1 text-sm font-semibold`,children:[(0,Z.jsx)(Da,{state:t,className:`text-muted`}),z[t],(0,Z.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.columns[t].length,`)`]})]}),b(t)]},t)):(0,Z.jsx)(ie,{label:`Loading tasks…`})}),(0,Z.jsx)(_,{open:s,onClose:()=>c(!1),title:`New task`,children:(0,Z.jsx)(Ca,{defaultProjectId:e.projectId,onCancel:()=>c(!1),onCreated:e=>{c(!1),o({...a,tab:e.state})}})})]})}function Ua({taskId:e}){ge();let t=M(e),n=O(e=>e.hydrated),[r,i]=(0,W.useState)(!1),{eligibility:a}=aa(t),o=Oe(H.board);return(0,W.useLayoutEffect)(()=>{let e=Va();e&&(e.scrollTop=0)},[]),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,"data-testid":`task-page`,children:[(0,Z.jsxs)(`header`,{className:`sticky top-0 z-20 flex min-w-0 items-center gap-1 border-b border-border bg-surface px-1 pb-1 safe-pt-1`,children:[(0,Z.jsx)(y,{label:`Back to board`,icon:(0,Z.jsx)(v,{className:`size-5`}),onClick:o}),(0,Z.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-base font-semibold`,children:t?.title??`Task`}),t&&(0,Z.jsx)(l,{size:`sm`,icon:(0,Z.jsx)(Rt,{className:`size-4`}),onClick:()=>i(!0),children:`Move task`})]}),t?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col px-4 pt-3 pb-8`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(ca,{task:t,eligibility:a,block:!0})}),(0,Z.jsx)(ua,{task:t,onDeleted:o}),(0,Z.jsx)(Wa,{task:t,open:r,onClose:()=>i(!1)})]}):n?(0,Z.jsx)(I,{title:`Task not found`,description:`It may have been deleted.`,action:{label:`Back to board`,to:H.board}}):(0,Z.jsx)(ie,{label:`Loading task…`})]})}function Wa({task:e,open:t,onClose:n}){let r=Qi(),i=O(e=>e.runs),a=e.currentRunId?i[e.currentRunId]:void 0,o=new Set(Ie(e));return(0,Z.jsx)(_,{open:t,onClose:n,title:`Move task`,description:`Currently ${z[e.state]}`,children:(0,Z.jsx)(`ul`,{"data-testid":`move-sheet`,className:`flex flex-col`,children:tt.filter(t=>t!==e.state).map(t=>{let i=Le(e,t,a),s=Je(i);return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,disabled:!o.has(t),onClick:()=>{n(),r.move(e,t)},className:`tap flex w-full items-start gap-3 rounded-md px-2 py-3 text-left hover:bg-surface-2 disabled:opacity-60`,children:[(0,Z.jsx)(Da,{state:t,className:`mt-0.5 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:Oa(e.state,t)}),s&&(0,Z.jsx)(`span`,{className:`block text-sm text-muted`,children:s})]})]})},t)})})})}function Ga(){let e=Me(),t=r(`/tasks/:taskId`)?.params.taskId;return(0,Z.jsx)(ea,{children:e===`mobile`?t?(0,Z.jsx)(Ua,{taskId:t},t):(0,Z.jsx)(Ha,{}):(0,Z.jsx)(Fa,{taskId:t})})}export{Ga as default};
|
|
10
|
-
//# sourceMappingURL=board-BZWPMk0Z.js.map
|