import { PartialBlock } from "@blocknote/core";
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
 
export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

export const formatter = new Intl.NumberFormat("fr-FR", {
  style: 'currency',
  currency: 'EUR'
});

export const dateFormatter = new Intl.DateTimeFormat("fr", {
  year: "numeric",
  month: "short",
  day: "numeric",
});

export const dateTimeFormatter = new Intl.DateTimeFormat("fr", {
  year: "numeric",
  month: "short",
  day: "numeric",
  hour: "2-digit",
  minute: "2-digit",
  second: "2-digit"
});

const currentDate = new Date();
export const dateNow = currentDate.toLocaleString("fr", {
  year: "numeric",
  month: "short",
  day: "numeric",
});

export const extractTextFromHTMLPreview = (htmlString: string): string => {
  const parser = new DOMParser();
  const doc = parser.parseFromString(htmlString, "text/html");
  return doc.body.textContent || "";
};
