import{s as p}from"./chunk-LvLJmgfZ.js";import{t as E}from"./react-Bj1aDYRI.js";import{t as M}from"./compiler-runtime-B3qBwwSJ.js";import{m as N,n as C,t as K}from"./useEventListener-C0195JsF.js";import{n as P,t as o}from"./cn-DYvqRARy.js";import{t as I}from"./jsx-runtime-Blw4afVn.js";const n={stopPropagation:e=>r=>{r.stopPropagation(),e&&e(r)},onEnter:e=>r=>{r.key==="Enter"&&e&&e(r)},preventFocus:e=>{e.preventDefault()},fromInput:e=>{let r=n.composedTarget(e);return r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.tagName.startsWith("MARIMO")||r.isContentEditable||n.fromCodeMirror(r)},fromCodeMirror:e=>e.closest(".cm-editor")!==null,shouldIgnoreKeyboardEvent(e){let r=n.composedTarget(e);return r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement||r instanceof HTMLElement&&(r.isContentEditable||r.tagName==="BUTTON"||r.closest("[role='textbox']")!==null||r.closest("[contenteditable='true']")!==null||n.fromCodeMirror(r))},composedTarget(e){return"composedPath"in e&&typeof e.composedPath=="function"?e.composedPath()[0]??e.target:e.target},hasModifier:e=>e.ctrlKey||e.metaKey||e.altKey||e.shiftKey,isMetaOrCtrl:e=>e.metaKey||e.ctrlKey};var H=M(),f=p(E(),1),S=p(I(),1),a="active:shadow-none",x=P(o("disabled:opacity-50 disabled:pointer-events-none","inline-flex items-center justify-center rounded-md text-sm font-medium focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background"),{variants:{variant:{default:o("bg-primary text-primary-foreground hover:bg-primary/90 shadow-xs border border-primary",a),destructive:o("border shadow-xs","bg-(--red-9) hover:bg-(--red-10) dark:bg-(--red-6) dark:hover:bg-(--red-7)","text-(--red-1) dark:text-(--red-12)","border-(--red-11)",a),success:o("border shadow-xs","bg-(--grass-9) hover:bg-(--grass-10) dark:bg-(--grass-6) dark:hover:bg-(--grass-7)","text-(--grass-1) dark:text-(--grass-12)","border-(--grass-11)",a),warn:o("border shadow-xs","bg-(--yellow-9) hover:bg-(--yellow-10) dark:bg-(--yellow-6) dark:hover:bg-(--yellow-7)","text-(--yellow-12)","border-(--yellow-11)",a),action:o("bg-action text-action-foreground shadow-xs","hover:bg-action-hover border border-action",a),outline:o("border border-slate-300 shadow-xs","hover:bg-accent hover:text-accent-foreground","hover:border-primary","aria-selected:text-accent-foreground aria-selected:border-primary",a),secondary:o("bg-secondary text-secondary-foreground hover:bg-secondary/80","border border-input shadow-xs",a),text:o("opacity-80 hover:opacity-100","active:opacity-100"),ghost:o("border border-transparent","hover:bg-accent hover:text-accent-foreground hover:shadow-xs",a,"active:text-accent-foreground"),link:"underline-offset-4 hover:underline text-link",linkDestructive:"underline-offset-4 hover:underline text-destructive underline-destructive",outlineDestructive:"border border-destructive text-destructive hover:bg-destructive/10"},size:{default:"h-10 py-2 px-4",xs:"h-7 px-2 rounded-md text-xs",sm:"h-9 px-3 rounded-md",lg:"h-11 px-8 rounded-md",icon:"h-6 w-6 mb-0"},disabled:{true:"opacity-50 pointer-events-none"}},defaultVariants:{variant:"default",size:"sm"}}),y=f.forwardRef((e,r)=>{let t=(0,H.c)(7),{className:v,variant:w,size:k,asChild:h,keyboardShortcut:i,...l}=e,T=h===void 0?!1:h,s=f.useRef(null),c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>s.current,t[0]=c):c=t[0],f.useImperativeHandle(r,c);let u;t[1]===i?u=t[2]:(u=d=>{!i||d.defaultPrevented||n.shouldIgnoreKeyboardEvent(d)||N(i)(d)&&(d.preventDefault(),d.stopPropagation(),s!=null&&s.current&&!s.current.disabled&&s.current.click())},t[1]=i,t[2]=u),K(document,"keydown",u);let m=T?C:"button",g=o(x({variant:w,size:k,className:v,disabled:l.disabled}),v),b;return t[3]!==m||t[4]!==l||t[5]!==g?(b=(0,S.jsx)(m,{className:g,ref:s,...l}),t[3]=m,t[4]=l,t[5]=g,t[6]=b):b=t[6],b});y.displayName="Button";export{x as n,n as r,y as t};
