import { Button } from "@domicile-desktop/component-library/Button";
import type { Point } from "@domicile-desktop/component-library/ContextMenu";
import { ContextMenu } from "@domicile-desktop/component-library/ContextMenu";
import { newTabClick } from "@domicile-desktop/component-library/new-tab-click";
import { ClockCounterClockwiseIcon } from "@phosphor-icons/react/dist/ssr/ClockCounterClockwise";
import { GlobeSimpleIcon } from "@phosphor-icons/react/dist/ssr/GlobeSimple";
import type { MouseEvent, ReactElement } from "react";
import { useState } from "react";
import { css } from "../../styled-system/css";
import type { PageHistoryChoice, PageHistoryEntry } from "./page-history";
import { useLongPress } from "./useLongPress";
/** How many pages a menu lists, as Chrome's. */
const MENU_LENGTH = 12;
type Props = {
/** The arrow. */
children: ReactElement;
disabled: boolean;
/** The history, or nothing from an engine without history entries. */
history: PageHistoryChoice | undefined;
label: "Back" | "Forward";
/** Takes one step, for a click. */
onStep: () => void;
/** Takes one step in a new window, for a middle click or a Ctrl+click. */
onStepInNewWindow: () => void;
/** Opens the History app. */
onShowAllHistory: () => void;
};
/**
* Back or Forward: a click takes one step, and a long press or a right click
* lists the pages that way to jump to, as Chrome's buttons do.
*/
export const HistoryButton = ({
children,
disabled,
history,
label,
onShowAllHistory,
onStep,
onStepInNewWindow,
}: Props) => {
const [menu, setMenu] = useState