import { AttributeList } from '../attribute.js';
import { Token, Type, REPLACEMENT_CHARACTER } from '../token.js';

export class StartTagToken extends Token {
    public name: NonNullable<string>;
    public readonly attributes: AttributeList;

    public constructor(name: NonNullable<string>, attributes: AttributeList) {
        super(Type.StartTag);

        this.name = name;
        this.attributes = attributes;
    }

    public appendToName(characters: string): void {
        this.name += characters;
    }

    public appendReplacementCharacterToName(): void {
        this.appendToName(REPLACEMENT_CHARACTER);
    }

    public static createEmpty(): StartTagToken {
        return new StartTagToken('', new AttributeList());
    }

    public override inspect(indent: number): string {
        return `StartTagToken { '${this.name}' }`;
    }
}
