import { useState as s } from "react";
import { isNil as d } from "es-toolkit/compat";
const y = (i) => {
  const { timeout: a = 2e3 } = i ?? {}, [l, o] = s(null), [c, t] = s(!1), [e, n] = s(null), p = (r) => {
    e && clearTimeout(e), n(setTimeout(() => t(!1), a)), t(r);
  };
  return { copy: (r) => {
    d(navigator.clipboard) ? o(new Error("useClipboard: navigator.clipboard is not supported")) : navigator.clipboard.writeText(r).then(() => p(!0)).catch((u) => o(u));
  }, reset: () => {
    t(!1), o(null), e && clearTimeout(e);
  }, error: l, copied: c };
};
export {
  y as default
};
//# sourceMappingURL=useClipboard.js.map
