import{r as l,j as e}from"./@radix-3bj3otF9.js";import{O as C,Q as w,B as h,R as b,U as y,L as O,M as v,N as m}from"./index-Cs2FY84s.js";import{S as p}from"./trash-B0fyghWi.js";import{A}from"./AlertDialogDropdownItem-WCI5zz6Q.js";import{D as f,a as x}from"./DeleteAlertDialog-8-J1PO_I.js";import{c as S}from"./helper-BXlR2ZLp.js";import{u as T}from"./delete-run-BUeBPA7e.js";import{u as I}from"./bulk-delete-2w7wPalO.js";const{ContextProvider:H,useContext:c}=S();function D(){const{setRowSelection:n}=c(),{mutateAsync:t}=T();async function s(r){await t({runId:r})}return I({deleteFn:s,queryKeyToInvalidate:["runs"],setRowSelection:n})}function P({id:n}){const[t,s]=l.useState(!1),[r,a]=l.useState(!1),i=l.useRef(null),u=l.useRef(null),{bulkDelete:g}=D();async function j(){await g([n]),d(!1)}function R(){u.current=i.current}function d(o){if(o===!1){a(!1),setTimeout(()=>{s(o)},200);return}s(o)}return e.jsxs(C,{onOpenChange:a,open:r,children:[e.jsx(w,{ref:i,asChild:!0,children:e.jsx(h,{intent:"secondary",emphasis:"minimal",className:"flex aspect-square items-center justify-center p-0",children:e.jsx(b,{className:"h-4 w-4 shrink-0 fill-theme-text-tertiary"})})}),e.jsx(y,{hidden:t,onCloseAutoFocus:o=>{u.current&&(u.current.focus(),u.current=null,o.preventDefault())},align:"end",sideOffset:7,children:e.jsx(A,{onSelect:R,open:t,onOpenChange:d,triggerChildren:"Delete",icon:e.jsx(p,{fill:"red"}),children:e.jsx(f,{title:"Delete Run",handleDelete:j,children:e.jsxs(x,{children:[e.jsx("p",{children:"Are you sure?"}),e.jsx("p",{children:"This action cannot be undone."})]})})})})]})}function N(){const[n,t]=l.useState(!1),{selectedRowCount:s,selectedRowIDs:r}=c(),{bulkDelete:a}=D();async function i(){await a(r),t(!1)}return e.jsxs(O,{open:n,onOpenChange:t,children:[e.jsx(v,{asChild:!0,children:e.jsxs(h,{className:"rounded-sharp border-y-0 bg-white",size:"md",emphasis:"subtle",intent:"secondary",children:[e.jsx(p,{className:"h-5 w-5 shrink-0 gap-1 fill-neutral-400"}),"Delete"]})}),e.jsx(f,{title:`Delete ${m(s,"Run")}`,handleDelete:i,children:e.jsxs(x,{children:[e.jsx("p",{children:"Are you sure?"}),e.jsx("p",{children:"This action cannot be undone."})]})})]})}function G(){const{selectedRowCount:n}=c();return e.jsxs("div",{className:"flex items-center divide-x divide-theme-border-moderate overflow-hidden rounded-md border border-theme-border-moderate",children:[e.jsx("div",{className:"bg-primary-25 px-2 py-1 font-semibold text-theme-text-brand",children:`${n} ${m(n,"Run")} selected`}),e.jsx(N,{})]})}export{H as R,P as a,G as b,c as u};
