type NegotiateFn = typeof negotiate

declare namespace negotiate {
  export type CacheStore = {
    set: (key: string, value: string) => CacheStore,
    get: (key: string) => string | undefined,
    has: (key: string) => boolean
  }

  export type NegotiatorOptions<K extends string = string> = {
    supportedValues: K[];
    cache?: CacheStore
  }

  export class Negotiator<K extends string = string> {
    constructor (options: NegotiatorOptions<K>)

    negotiate (header: string): K | null
  }

  export const negotiate: NegotiateFn
  export { negotiate as default }
}

declare function negotiate<K extends string = string> (header: string, supportedValues: K[]): K | null
export = negotiate
