import{r as p,j as e}from"./vendor-react-wBh_31cN.js";import{D as y,z as E,B as k,C as I,E as w,F as B,G as x}from"./index-BKr2rJhV.js";import{I as F}from"./input-H6_qmzms.js";import{L as K}from"./label-Dnebucx5.js";import{u as N}from"./useCopyToClipboard-3DFwhniW.js";const o="confirm";function _({open:i,onOpenChange:n,title:m,description:a,children:v,confirmLabel:D="Confirm",cancelLabel:b="Cancel",confirmVariant:r="default",requireTypedConfirm:s,isLoading:c,disabled:d,onConfirm:u,className:g}){const[l,f]=p.useState(""),{copyToClipboard:h,copied:j}=N();p.useEffect(()=>{i||f("")},[i]);const C=!!s&&l!==o;return e.jsx(y,{open:i,onOpenChange:n,children:e.jsxs(E,{className:g,showCloseButton:!1,variant:r==="destructive"?"destructive":"default",onInteractOutside:s?t=>t.preventDefault():void 0,onEscapeKeyDown:s?t=>t.preventDefault():void 0,children:[e.jsxs(k,{children:[e.jsx(I,{children:m}),a&&e.jsx(w,{children:a})]}),s&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(K,{children:["Type"," ",e.jsx("button",{type:"button",onClick:()=>h(o,{silent:!0}),title:"Click to copy",className:"inline-flex cursor-pointer items-center rounded-md border border-input bg-muted px-1.5 py-0.5 font-mono text-xs font-semibold hover:bg-accent focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none",children:j?"copied":o})," ","to delete."]}),e.jsx(F,{value:l,onChange:t=>f(t.target.value),onKeyDown:t=>{t.key==="Enter"&&l===o&&!d&&!c&&(t.preventDefault(),u())},placeholder:o,autoComplete:"off"})]}),v,e.jsxs(B,{children:[e.jsx(x,{variant:"outline",onClick:()=>n(!1),children:b}),e.jsx(x,{variant:r,loading:c,disabled:d||C,onClick:u,children:D})]})]})})}export{_ as C};
