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 { Length } from "../length" ; const { map , left , right , filter , delimited , option } = Parser ; public export class Perspective < D extends Length = Length > extends Value < "transform" > { public static of < D extends Length > ( depth ) { return new Perspective ( depth ) ; } private readonly _depth : D ; private constructor ( depth ) { super ( ) ; this . _depth = depth ; } public get type ( ) : "transform" { return "transform" ; } public get kind ( ) : "perspective" { return "perspective" ; } public get depth ( ) : D { return this . _depth ; } public equals ( value ) { return value instanceof Perspective && value . _depth . equals ( this . _depth ) ; } public hash ( hash ) { hash . writeHashable ( this . _depth ) ; } public toJSON ( ) { return { type : "transform" , kind : "perspective" , depth : this . _depth . toJSON ( ) , } ; } public toString ( ) { return `perspective(${ this . _depth })` ; } } public export namespace Perspective { export interface JSON extends Value . JSON < "transform" > { kind : "perspective" ; depth : Length . JSON ; } export function isPerspective < D extends Length > ( value ) { return value instanceof Perspective ; } /**
     *  https export const parse = map ( right ( Token . parseFunction ( "perspective" ) , left ( delimited ( option ( Token . parseWhitespace ) , filter ( Length . parse , ( length ) => length . value >= 0 , ( ) => "Depth cannot be less than 0" ) ) , Token . parseCloseParenthesis ) ) , ( depth ) => Perspective . of ( depth ) ) ; }