import type { InteractiveGraphAction } from "./reducer/interactive-graph-action"; import type { Coord } from "../../interactive2/types"; import type { WidgetProps } from "../../types"; import type { QuadraticCoords } from "@khanacademy/kmath"; import type { PerseusInteractiveGraphUserInput, PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core"; import type { Interval, vec } from "mafs"; import type { ReactNode } from "react"; export type InteractiveGraphProps = WidgetProps; export type Dispatch = (action: InteractiveGraphAction) => unknown; export type MafsGraphProps = { graphState: T; dispatch: Dispatch; }; export type InteractiveGraphElementSuite = { graph: ReactNode; interactiveElementsDescription: ReactNode; }; export type InteractiveGraphState = AngleGraphState | SegmentGraphState | LinearSystemGraphState | LinearGraphState | RayGraphState | NoneGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState | SinusoidGraphState; export type UnlimitedGraphState = PointGraphState | PolygonGraphState; export interface InteractiveGraphStateCommon { hasBeenInteractedWith: boolean; range: [xRange: Interval, yRange: Interval]; snapStep: vec.Vector2; } export interface SegmentGraphState extends InteractiveGraphStateCommon { type: "segment"; coords: PairOfPoints[]; } export interface LinearGraphState extends InteractiveGraphStateCommon { type: "linear"; coords: PairOfPoints; } export interface LinearSystemGraphState extends InteractiveGraphStateCommon { type: "linear-system"; coords: PairOfPoints[]; } export type InteractionMode = "mouse" | "keyboard"; export interface NoneGraphState extends InteractiveGraphStateCommon { type: "none"; } export interface PointGraphState extends InteractiveGraphStateCommon { type: "point"; coords: Coord[]; numPoints?: number | "unlimited"; focusedPointIndex: number | null; showRemovePointButton: boolean; interactionMode: InteractionMode; showKeyboardInteractionInvitation: boolean; } export interface RayGraphState extends InteractiveGraphStateCommon { type: "ray"; coords: PairOfPoints; } export interface PolygonGraphState extends InteractiveGraphStateCommon { type: "polygon"; showAngles: boolean; showSides: boolean; snapTo: SnapTo; coords: Coord[]; numSides?: number | "unlimited"; focusedPointIndex: number | null; showRemovePointButton: boolean; interactionMode: InteractionMode; showKeyboardInteractionInvitation: boolean; closedPolygon: boolean; } export interface CircleGraphState extends InteractiveGraphStateCommon { type: "circle"; center: Coord; radiusPoint: Coord; } export interface QuadraticGraphState extends InteractiveGraphStateCommon { type: "quadratic"; coords: QuadraticCoords; } export interface SinusoidGraphState extends InteractiveGraphStateCommon { type: "sinusoid"; coords: [vec.Vector2, vec.Vector2]; } export interface AngleGraphState extends InteractiveGraphStateCommon { type: "angle"; showAngles?: boolean; allowReflexAngles?: boolean; angleOffsetDeg?: number; snapDegrees?: number; coords: [Coord, Coord, Coord]; } export type PairOfPoints = [Coord, Coord]; export type GraphDimensions = { range: [Interval, Interval]; width: number; height: number; }; export type AriaLive = "off" | "assertive" | "polite" | undefined; export type SnapTo = "grid" | "angles" | "sides";