import{o as e}from"./rolldown-runtime.C0FnF6B9.js";import{r as t}from"./emotion-is-prop-valid.esm.CuYlOKOk.js";import{t as n}from"./loglevel.xXLtmX_e.js";import{t as r}from"./useTimeout.DgWF0Nme.js";var i=e(t(),1),a=(0,e(n(),1).getLogger)(`useCopyToClipboard`),o=({timeout:e=2e3}={})=>{let[t,n]=(0,i.useState)(!1),{restart:o}=r((0,i.useCallback)(()=>{n(!1)},[]),t?e:null);return{isCopied:t,copyToClipboard:(0,i.useCallback)(e=>{(async()=>{try{await navigator.clipboard.writeText(e),n(!0),o()}catch(e){a.error(`Failed to copy text to clipboard:`,e),n(!1)}})()},[o]),label:t?`Copied`:`Copy to clipboard`}};export{o as t};