import { Hash } from "@siteimprove/alfa-hash" ; import { Parser } from "@siteimprove/alfa-parser" ; import { Slice } from "@siteimprove/alfa-slice" ; import { Token } from "../../syntax/token" ; import { Value } from "../../value" ; import { Keyword } from "../keyword" ; import { Length } from "../length" ; import { Percentage } from "../percentage" ; const { either , map , filter } = Parser ; /**
 *  https public export class Radius < R extends Length | Percentage | Radius . Side = Length | Percentage | Radius . Side > extends Value < "basic-shape" > { public static of < R extends Length | Percentage | Radius . Side > ( value ) { return new Radius ( value ) ; } private readonly _value : R ; private constructor ( value ) { super ( ) ; this . _value = value ; } public get type ( ) : "basic-shape" { return "basic-shape" ; } public get kind ( ) : "radius" { return "radius" ; } public get value ( ) : R { return this . _value ; } public equals ( value ) ; public equals ( value ) ; public equals ( value ) { return value instanceof Radius && value . _value . equals ( this . _value ) ; } public hash ( hash ) { hash . writeHashable ( this . _value ) ; } public toJSON ( ) { return { type : "basic-shape" , kind : "radius" , value : this . value . toJSON ( ) , } ; } public toString ( ) { return this . value . toString ( ) ; } } public export namespace Radius { export interface JSON extends Value . JSON < "basic-shape" > { kind : "radius" ; value : Length . JSON | Percentage . JSON | Keyword . JSON ; } export type Side = Side . Closest | Side . Farthest ; export namespace Side { /**
         *  https export type Closest = Keyword < "closest-side" > ; /**
         *  https export type Farthest = Keyword < "farthest-side" > ; } export function isRadius ( value ) { return value instanceof Radius ; } export const parse = map ( either ( filter ( either ( Length . parse , Percentage . parse ) , ( { value } ) => value >= 0 , ( ) => "Radius cannot be negative" ) , Keyword . parse ( "closest-side" , "farthest-side" ) ) , ( radius ) => Radius . of ( radius ) ) ; }