import{u,r as p,j as l}from"./index-gnHkq9KV.js";function m(t){var o;return(o=navigator.clipboard)!=null&&o.writeText?navigator.clipboard.writeText(t).catch(()=>i(t)):i(t)}function i(t){return new Promise((o,r)=>{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="-9999px",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();try{const a=document.execCommand("copy");document.body.removeChild(e),a?o():r(new Error("execCommand copy failed"))}catch(a){document.body.removeChild(e),r(a)}})}function f({text:t,className:o="copy-btn",title:r="Copy to clipboard",onClick:e}){const{t:a}=u(),[c,n]=p.useState(!1),d=p.useCallback(s=>{e==null||e(s),s.stopPropagation(),m(t).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})},[e,t]);return l.jsx("button",{className:`${o}${c?" copied":""}`,onClick:d,title:a(c?"Copied!":r),type:"button"})}export{f as C,m as c};
