"use strict";
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.HederaId = exports.HEDERA_FORMAT_ID_REGEX = void 0;
const sdk_1 = require("@hiero-ledger/sdk");
const InvalidIdFormat_1 = require("./error/InvalidIdFormat");
exports.HEDERA_FORMAT_ID_REGEX = /^(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))(?:-([a-z]{5}))?$/;
class HederaId {
    static NULL = new HederaId("0.0.0");
    value;
    constructor(value) {
        if (!exports.HEDERA_FORMAT_ID_REGEX.exec(value)) {
            throw new InvalidIdFormat_1.InvalidIdFormat(value);
        }
        this.value = value;
    }
    static from(value) {
        return new HederaId(value ?? "");
    }
    toHederaAddress() {
        return sdk_1.AccountId.fromString(this.value);
    }
    toString() {
        return this.value;
    }
    isNull() {
        return this.value == "0.0.0";
    }
}
exports.HederaId = HederaId;
