export function isCashOfferTrigger({
  href = "",
  text = "",
  isDialogSubmit = false,
}: {
  href?: string;
  text?: string;
  isDialogSubmit?: boolean;
}) {
  if (isDialogSubmit) return false;
  const source = `${text} ${href}`.toLowerCase();
  return href.includes("#offer-form") || href.includes("#cash-offer-form") || source.includes("cash offer");
}

export function handleCashOfferClick(
  event: { preventDefault: () => void },
  onOpen: () => void,
) {
  event.preventDefault();
  onOpen();
}

export function openCashOfferDialog() {
  if (typeof window === "undefined") return;
  window.dispatchEvent(new CustomEvent("open-cash-offer"));
}
