"use client";
import { clsx as l } from "../node_modules/clsx/dist/clsx.js";
import { twMerge as m } from "../node_modules/tailwind-merge/dist/bundle-mjs.js";
import { guessKind as d, getOfficeEmbedUrl as p } from "./file-preview.js";
function u(...n) {
  return m(l(n));
}
const b = (n) => {
  if (!n) return "#777777";
  let e = 0;
  for (let s = 0; s < n.length; s += 1)
    e = n.charCodeAt(s) + ((e << 5) - e), e &= e;
  let t = e >> 16 & 255, o = e >> 8 & 255, r = e & 255;
  const c = 60, a = 200;
  t = Math.min(a, Math.max(c, t)), o = Math.min(a, Math.max(c, o)), r = Math.min(a, Math.max(c, r));
  const i = (s) => s.toString(16).padStart(2, "0");
  return `#${i(t)}${i(o)}${i(r)}`;
}, w = (n, e) => {
  let t = n.replace("#", "");
  t.length === 3 && (t = t.split("").map((i) => i + i).join(""));
  const o = parseInt(t, 16), r = o >> 16 & 255, c = o >> 8 & 255, a = o & 255;
  return `rgba(${r}, ${c}, ${a}, ${e})`;
}, x = (n) => {
  const e = parseInt(n.replace("#", ""), 16), t = e >> 16 & 255, o = e >> 8 & 255, r = e & 255;
  return (0.299 * t + 0.587 * o + 0.114 * r) / 255 > 0.5 ? "#000000" : "#FFFFFF";
}, y = (n, e) => {
  if (!n) return;
  const t = n.split("?")[1] || "";
  let o = "";
  try {
    const c = new URLSearchParams(t);
    o = c.get("response-content-type") || c.get("content-type") || "";
  } catch {
  }
  if (d({ mimeType: o, filename: e, url: n }) === "office") {
    const c = p(n);
    window.open(c, "_blank");
    return;
  }
  window.open(n, "_blank");
}, F = (n, e) => {
  if (!n) return;
  const t = document.createElement("a");
  t.href = n, t.download = e || "document", t.style.display = "none", document.body.appendChild(t), t.click(), document.body.removeChild(t);
};
export {
  u as cn,
  F as downloadFile,
  x as hexContrast,
  w as hexToRgba,
  y as previewFile,
  b as stringToHexColor
};
