{
  "version": 3,
  "sources": ["../src/index.ts"],
  "sourcesContent": ["/**\n * A set of tokens.\n *\n * @see https://dom.spec.whatwg.org/#domtokenlist\n */\nexport default class TokenList {\n\tprivate _currentValue: string;\n\tprivate _valueAsArray: string[];\n\n\t/**\n\t * Constructs a new instance of TokenList.\n\t *\n\t * @param initialValue Initial value to assign.\n\t */\n\tconstructor( initialValue: string = '' ) {\n\t\tthis._currentValue = '';\n\t\tthis._valueAsArray = [];\n\t\tthis.value = initialValue;\n\t}\n\n\tentries( ...args: Parameters< Array< string >[ 'entries' ] > ) {\n\t\treturn this._valueAsArray.entries( ...args );\n\t}\n\n\tforEach( ...args: Parameters< Array< string >[ 'forEach' ] > ) {\n\t\treturn this._valueAsArray.forEach( ...args );\n\t}\n\n\tkeys( ...args: Parameters< Array< string >[ 'keys' ] > ) {\n\t\treturn this._valueAsArray.keys( ...args );\n\t}\n\n\tvalues( ...args: Parameters< Array< string >[ 'values' ] > ) {\n\t\treturn this._valueAsArray.values( ...args );\n\t}\n\n\t/**\n\t * Returns the associated set as string.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value\n\t *\n\t * @return Token set as string.\n\t */\n\tget value(): string {\n\t\treturn this._currentValue;\n\t}\n\n\t/**\n\t * Replaces the associated set with a new string value.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value\n\t *\n\t * @param value New token set as string.\n\t */\n\tset value( value: string ) {\n\t\tvalue = String( value );\n\t\tthis._valueAsArray = [\n\t\t\t...new Set( value.split( /\\s+/g ).filter( Boolean ) ),\n\t\t];\n\t\tthis._currentValue = this._valueAsArray.join( ' ' );\n\t}\n\n\t/**\n\t * Returns the number of tokens.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-length\n\t *\n\t * @return Number of tokens.\n\t */\n\tget length(): number {\n\t\treturn this._valueAsArray.length;\n\t}\n\n\t/**\n\t * Returns the stringified form of the TokenList.\n\t *\n\t * @see https://dom.spec.whatwg.org/#DOMTokenList-stringification-behavior\n\t * @see https://www.ecma-international.org/ecma-262/9.0/index.html#sec-tostring\n\t *\n\t * @return Token set as string.\n\t */\n\ttoString(): string {\n\t\treturn this.value;\n\t}\n\n\t/**\n\t * Returns an iterator for the TokenList, iterating items of the set.\n\t *\n\t * @see https://dom.spec.whatwg.org/#domtokenlist\n\t *\n\t * @return TokenList iterator.\n\t */\n\t*[ Symbol.iterator ](): IterableIterator< string > {\n\t\treturn yield* this._valueAsArray;\n\t}\n\n\t/**\n\t * Returns the token with index `index`.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-item\n\t *\n\t * @param index Index at which to return token.\n\t *\n\t * @return Token at index.\n\t */\n\titem( index: number ): string | undefined {\n\t\treturn this._valueAsArray[ index ];\n\t}\n\n\t/**\n\t * Returns true if `token` is present, and false otherwise.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-contains\n\t *\n\t * @param item Token to test.\n\t *\n\t * @return Whether token is present.\n\t */\n\tcontains( item: string ): boolean {\n\t\treturn this._valueAsArray.indexOf( item ) !== -1;\n\t}\n\n\t/**\n\t * Adds all arguments passed, except those already present.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-add\n\t *\n\t * @param items Items to add.\n\t */\n\tadd( ...items: string[] ): void {\n\t\tthis.value += ' ' + items.join( ' ' );\n\t}\n\n\t/**\n\t * Removes arguments passed, if they are present.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-remove\n\t *\n\t * @param items Items to remove.\n\t */\n\tremove( ...items: string[] ): void {\n\t\tthis.value = this._valueAsArray\n\t\t\t.filter( ( val ) => ! items.includes( val ) )\n\t\t\t.join( ' ' );\n\t}\n\n\t/**\n\t * If `force` is not given, \"toggles\" `token`, removing it if it\u2019s present\n\t * and adding it if it\u2019s not present. If `force` is true, adds token (same\n\t * as add()). If force is false, removes token (same as remove()). Returns\n\t * true if `token` is now present, and false otherwise.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-toggle\n\t *\n\t * @param token   Token to toggle.\n\t * @param [force] Presence to force.\n\t *\n\t * @return Whether token is present after toggle.\n\t */\n\ttoggle( token: string, force?: boolean ): boolean {\n\t\tif ( undefined === force ) {\n\t\t\tforce = ! this.contains( token );\n\t\t}\n\n\t\tif ( force ) {\n\t\t\tthis.add( token );\n\t\t} else {\n\t\t\tthis.remove( token );\n\t\t}\n\n\t\treturn force;\n\t}\n\n\t/**\n\t * Replaces `token` with `newToken`. Returns true if `token` was replaced\n\t * with `newToken`, and false otherwise.\n\t *\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-replace\n\t *\n\t * @param token    Token to replace with `newToken`.\n\t * @param newToken Token to use in place of `token`.\n\t *\n\t * @return Whether replacement occurred.\n\t */\n\treplace( token: string, newToken: string ): boolean {\n\t\tif ( ! this.contains( token ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.remove( token );\n\t\tthis.add( newToken );\n\n\t\treturn true;\n\t}\n\n\t/* eslint-disable @typescript-eslint/no-unused-vars */\n\t/**\n\t * Returns true if `token` is in the associated attribute\u2019s supported\n\t * tokens. Returns false otherwise.\n\t *\n\t * Always returns `true` in this implementation.\n\t *\n\t * @param _token\n\t * @see https://dom.spec.whatwg.org/#dom-domtokenlist-supports\n\t *\n\t * @return Whether token is supported.\n\t */\n\tsupports( _token: string ): boolean {\n\t\treturn true;\n\t}\n\t/* eslint-enable @typescript-eslint/no-unused-vars */\n}\n"],
  "mappings": ";AAKA,IAAqB,YAArB,MAA+B;AAAA,EACtB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOR,YAAa,eAAuB,IAAK;AACxC,SAAK,gBAAgB;AACrB,SAAK,gBAAgB,CAAC;AACtB,SAAK,QAAQ;AAAA,EACd;AAAA,EAEA,WAAY,MAAmD;AAC9D,WAAO,KAAK,cAAc,QAAS,GAAG,IAAK;AAAA,EAC5C;AAAA,EAEA,WAAY,MAAmD;AA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