"use client";

import { cn } from "@/lib/utils/ui";
import { money_font } from "@/public/fonts/font_index";
import { usePrivacyMode } from "./privacy-provider";

type Props = {
  amount: number;
  className?: string;
};

function MoneyValues({ amount, className }: Props) {
  const { privacyMode } = usePrivacyMode();

  const formattedValue = amount.toLocaleString("pt-BR", {
    style: "currency",
    currency: "BRL",
    maximumFractionDigits: 2,
  });

  return (
    <span
      className={cn(
        money_font.className,
        "inline-flex items-baseline font-medium transition-all duration-200",
        privacyMode &&
          "blur-[6px] select-none hover:blur-none focus-within:blur-none",
        className
      )}
      aria-label={privacyMode ? "Valor oculto" : formattedValue}
      data-privacy={privacyMode ? "hidden" : undefined}
      title={
        privacyMode ? "Valor oculto - passe o mouse para revelar" : undefined
      }
    >
      {formattedValue}
    </span>
  );
}

export default MoneyValues;
