"use strict";
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const bn_js_1 = __importDefault(require("bn.js"));
const util_1 = require("@polkadot/util");
const Set_1 = __importDefault(require("../codec/Set"));
const createType_1 = require("../codec/create/createType");
function decodeFields(registry, value) {
    if (util_1.isString(value)) {
        return decodeFields(registry, util_1.u8aToU8a(value.toString()));
    }
    else if (util_1.isU8a(value)) {
        return createType_1.createType(registry, 'u64', value);
    }
    return value;
}
class IdentityFields extends Set_1.default {
    constructor(registry, value) {
        super(registry, {
            Display: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000000000001),
            Legal: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000000000010),
            Web: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000000000100),
            Riot: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000000001000),
            Email: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000000010000),
            PgpFingerprint: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000000100000),
            Image: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000001000000),
            Twitter: new bn_js_1.default(0b0000000000000000000000000000000000000000000000000000000010000000)
        }, decodeFields(registry, value));
    }
    /**
     * @description The length of the value when encoded as a Uint8Array
     */
    get encodedLength() {
        return 8;
    }
    /**
     * @description Encodes the value as a Uint8Array as per the SCALE specifications
     */
    toU8a() {
        return createType_1.createType(this.registry, 'u64', this.valueEncoded).toU8a();
    }
}
exports.default = IdentityFields;
