'use strict';

var utils_types_bytes = require('../../utils/types/bytes.cjs');
var types_generic_typedBytes = require('./typed-bytes.cjs');
var types_generic_withCatchNull = require('./with-catch-null.cjs');
require('crypto');
require('../../utils/interfaces.cjs');
require('../../utils/assert.cjs');
require('../../utils/error.cjs');
require('../../utils/types/string.cjs');
require('../../utils/types/iterable.cjs');
require('../../utils/types/object.cjs');
require('../../utils/inheritance.cjs');
require('../../utils/types/set.cjs');
require('../../utils/types/array.cjs');
require('bs58');
require('multiformats/bases/base58');
require('varint');
require('../../utils/encoding/ss-58.cjs');
require('blake2b');
require('./with-base.cjs');
require('./with-eq.cjs');
require('./any-of.cjs');
require('./with-from.cjs');
require('./with-from-json-bytes.cjs');

let TypedString$1 = class TypedString extends types_generic_typedBytes {
  constructor(value) {
    super(utils_types_bytes.normalizeOrConvertStringToU8a(value));
  }

  get value() {
    return utils_types_bytes.u8aToString(this.bytes);
  }

  toJSON() {
    return String(this);
  }

  toString() {
    return this.value;
  }

  static fromApi(value) {
    if (
      !Array.isArray(value)
      && !(value instanceof Uint8Array)
      && typeof value !== 'string'
    ) {
      return new this(String(value));
    } else {
      return super.fromApi(value);
    }
  }

  eq(other) {
    return String(this) === String(other);
  }
};

var TypedString = types_generic_withCatchNull(TypedString$1);

module.exports = TypedString;
//# sourceMappingURL=typed-string.cjs.map
