//#region src/shared/clipboard.ts
var e = "text/plain", t = "text/markdown", n = "text/html";
function r(e) {
	if (typeof document > "u") return !1;
	try {
		let t = document.createElement("textarea");
		t.value = e, t.setAttribute("readonly", "true"), t.style.position = "fixed", t.style.top = "-1000px", t.style.left = "-1000px", document.body.appendChild(t), t.select();
		let n = document.execCommand("copy");
		return document.body.removeChild(t), n;
	} catch {
		return !1;
	}
}
function i() {
	if (typeof navigator > "u") return null;
	let { clipboard: e } = navigator;
	return e ?? null;
}
function a(t) {
	return typeof ClipboardItem > "u" ? !1 : t === e ? !0 : typeof ClipboardItem.supports == "function" ? ClipboardItem.supports(t) : t === n;
}
function o(e, t) {
	return new Blob([e], { type: t });
}
async function s(r) {
	let s = i();
	if (s == null || typeof s.write != "function" || typeof ClipboardItem > "u") return !1;
	let c = { [e]: o(r.plainText, e) }, l = r.markdownText?.trim();
	l != null && l !== "" && a(t) && (c[t] = o(l, t));
	let u = r.htmlText?.trim();
	u != null && u !== "" && a(n) && (c[n] = o(u, n));
	try {
		return await s.write([new ClipboardItem(c)]), !0;
	} catch {
		return !1;
	}
}
async function c(e) {
	let t = i();
	if (t != null && typeof t.writeText == "function") try {
		return await t.writeText(e), !0;
	} catch {}
	return r(e);
}
async function l(e) {
	let { plainText: t } = e;
	return await s({
		...e,
		plainText: t
	}) ? !0 : c(t);
}
//#endregion
export { l as copyRichClipboard, c as copyTextToClipboard, r as copyWithExecCommand };

//# sourceMappingURL=clipboard.js.map