"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("../../../../core");
var HexStringConverter = /** @class */ (function () {
    function HexStringConverter() {
    }
    HexStringConverter.prototype.decode = function (value) {
        return core_1.FormatHelper.toHexString(value);
    };
    HexStringConverter.prototype.encode = function (value) {
        if (!value || value.length == 0) {
            return new Uint8Array(0);
        }
        if (value.length % 2 > 0) {
            // Prefix with 0
            value = "0" + value;
        }
        var result = [];
        for (var i = 0, len = value.length; i < len; i += 2) {
            result.push(parseInt(value.substr(i, 2), 16));
        }
        return new Uint8Array(result);
    };
    HexStringConverter.instance = function () {
        if (!HexStringConverter._instance) {
            HexStringConverter._instance = new HexStringConverter();
        }
        return HexStringConverter._instance;
    };
    return HexStringConverter;
}());
exports.HexStringConverter = HexStringConverter;
