"use strict";
/*
 *
 * Copyright 2018-present NEM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.Profile = exports.epochAdjustment = exports.CURRENT_PROFILE_VERSION = void 0;
const Table = require("cli-table3");
const symbol_sdk_1 = require("symbol-sdk");
exports.CURRENT_PROFILE_VERSION = 3;
exports.epochAdjustment = 1573430400;
/**
 * Base implementation of the Profile models
 * @export
 * @abstract
 * @class Profile
 */
class Profile {
    /**
     * Creates an instance of Profile.
     * @param {CliWallet} simpleWallet
     * @param {string} url
     * @param {string} networkGenerationHash
     * @param {number} epochAdjustment the configured epoch adjustment.
     * @param {NetworkCurrency} networkCurrency
     * @param {number} version
     * @param {ProfileType} type
     * @param {('0' | '1')} isDefault
     */
    constructor(simpleWallet, url, networkGenerationHash, epochAdjustment, networkCurrency, version, type, isDefault) {
        this.simpleWallet = simpleWallet;
        this.url = url;
        this.networkGenerationHash = networkGenerationHash;
        this.epochAdjustment = epochAdjustment;
        this.networkCurrency = networkCurrency;
        this.version = version;
        this.type = type;
        this.isDefault = isDefault;
    }
    /**
     * returns a table with the properties common to all profiles
     * @protected
     * @returns {HorizontalTable}
     */
    getBaseTable() {
        const { namespaceId, divisibility } = this.networkCurrency;
        const table = new Table({
            style: { head: ['cyan'] },
            head: ['Property', 'Value'],
        });
        table.push(['Name', this.simpleWallet.name], ['Address', this.simpleWallet.address.pretty()], ['Network', symbol_sdk_1.NetworkType[this.simpleWallet.networkType]], ['Node URL', this.url], ['Generation Hash', this.networkGenerationHash], ['Network Currency', `name: ${namespaceId.fullName}, divisibility: ${divisibility}`], ['Profile type', this.type]);
        return table;
    }
    /**
     * Gets profile address.
     * @returns {Address}
     */
    get address() {
        return this.simpleWallet.address;
    }
    /**
     * Gets profile network type.
     * @returns {NetworkType}
     */
    get networkType() {
        return this.simpleWallet.networkType;
    }
    /**
     * Gets profile name.
     * @returns {string}
     */
    get name() {
        return this.simpleWallet.name;
    }
    /**
     * Gets repository factory.
     * @returns {RepositoryFactoryHttp}
     */
    get repositoryFactory() {
        return new symbol_sdk_1.RepositoryFactoryHttp(this.url);
    }
    /**
     * Formats profile as a string.
     * @returns {string}
     */
    toString() {
        return this.getTable(undefined).toString();
    }
}
exports.Profile = Profile;
