"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("../../../../core");
var BooleanConverter = /** @class */ (function () {
    function BooleanConverter(_mask) {
        if (_mask === void 0) { _mask = 0x1; }
        this._mask = _mask;
    }
    BooleanConverter.prototype.decode = function (data) {
        var value = core_1.FormatHelper.toUnsignedInt(data, data.length, BooleanConverter.IS_LEAST_SIGNIFICANT_BIT_FIRST);
        return BooleanConverter.decodeFromNumber(this._mask, value);
    };
    BooleanConverter.prototype.encode = function (value) {
        return Uint8Array.from([value ? this._mask : ~this._mask]);
    };
    BooleanConverter.decodeFromNumber = function (mask, value) {
        return (mask == 0 && value == 0) || (value & mask) != 0;
    };
    BooleanConverter.instanceBit0 = function () {
        if (!BooleanConverter._instance) {
            BooleanConverter._instance = new BooleanConverter(1);
        }
        return BooleanConverter._instance;
    };
    BooleanConverter.IS_LEAST_SIGNIFICANT_BIT_FIRST = true;
    return BooleanConverter;
}());
exports.BooleanConverter = BooleanConverter;
