"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tile = void 0;
const constants_1 = require("@scrabble-solver/constants");
class Tile {
    constructor({ character, isBlank = false }) {
        this.character = character;
        this.isBlank = isBlank;
    }
    clone() {
        return new Tile({
            character: this.character,
            isBlank: this.isBlank,
        });
    }
    equals(other) {
        return this.character === other.character && this.isBlank === other.isBlank;
    }
    toJson() {
        return {
            character: this.character,
            isBlank: this.isBlank,
        };
    }
    toString() {
        return this.character;
    }
}
exports.Tile = Tile;
Tile.fromJson = (json) => {
    if (!json) {
        return Tile.Null;
    }
    return new Tile({
        character: json.character,
        isBlank: json.isBlank,
    });
};
Tile.Null = Object.freeze({
    character: constants_1.EMPTY_CELL,
    isBlank: false,
    clone: () => Tile.Null,
    equals: (other) => other === Tile.Null,
    toJson: () => null,
    toString: () => constants_1.EMPTY_CELL,
});
