import type { ParseMode } from '../public/core' ; import type { Mathfield , Offset , Range , Selection } from '../public/mathfield' ; import { ModelPrivate } from './model-private' ; import type { Atom } from '../core/atom' ; import { NormalizedMacroDictionary } from '../core-definitions/definitions-utils' ; export type ModelOptions = { mode : ParseMode ; macros : NormalizedMacroDictionary ; removeExtraneousParentheses : boolean ; } ; export type AnnounceVerb = 'plonk' | 'focus' | 'replacement' | 'line' | 'move' | 'move up' | 'move down' | 'delete' | 'delete: numerator' | 'delete: denominator' | 'delete: root' | 'delete: superscript' ; export type ModelHooks = { announce ? : ( target : Mathfield , verb : AnnounceVerb , previousPosition : number | undefined , object : Atom [ ] ) => void ; moveOut ? : ( sender : ModelPrivate , direction : 'forward' | 'backward' | 'upward' | 'downward' ) => boolean ; tabOut ? : ( sender : ModelPrivate , direction : 'forward' | 'backward' ) => boolean ; } ; export function isOffset ( value ) { return typeof value === 'number' && ! Number . isNaN ( value ) ; } export function isRange ( value ) { return Array . isArray ( value ) && value . length === 2 ; } export function isSelection ( value ) { return ( value !== undefined && value !== null && typeof value === 'object' && 'ranges' in value ! && Array . isArray ( ( value as Selection ) . ranges ) ) ; }