"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useCopyToClipboard = void 0;
const react_1 = require("react");
const __1 = require("../");
const useCopyToClipboard = (text) => {
    const [copied, setCopied] = (0, react_1.useState)(false);
    const copy = (0, react_1.useCallback)(() => {
        if (!copied) {
            (0, __1.copyToClipboard)(text);
            setCopied(true);
        }
    }, [text]);
    (0, react_1.useEffect)(() => () => setCopied(false), [text]);
    (0, react_1.useEffect)(() => {
        if (copied) {
            const timeout = setTimeout(() => setCopied(false), 2500);
            return () => clearTimeout(timeout);
        }
    }, [copied]);
    return [copied, copy];
};
exports.useCopyToClipboard = useCopyToClipboard;
//# sourceMappingURL=useCopyToClipboard.js.map