"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useCopyToClipboard = void 0;
const toast_1 = require("../toast");
const useCopyToClipboard = (copyText) => {
    var _a, _b;
    const { showSuccess, showError } = (0, toast_1.useToast)();
    const isCopyDisabled = !((_b = (_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.clipboard) === null || _b === void 0 ? void 0 : _b.writeText);
    const copy = () => {
        var _a, _b, _c;
        if (!isCopyDisabled) {
            (_c = (_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : (_b = _a.clipboard).writeText) === null || _c === void 0 ? void 0 : _c.call(_b, copyText).then(() => showSuccess(`Copied to clipboard: ${copyText}`)).catch(() => showError('Copy failed'));
        }
    };
    return { copy, isCopyDisabled };
};
exports.useCopyToClipboard = useCopyToClipboard;
//# sourceMappingURL=useCopyToClipboard.js.map