import { normalizeOrConvertStringToU8a, u8aToString } from '../../utils/types/bytes.js';
import TypedBytes from './typed-bytes.js';
import withCatchNull from './with-catch-null.js';
import 'crypto';
import '../../utils/interfaces.js';
import '../../utils/assert.js';
import '../../utils/error.js';
import '../../utils/types/string.js';
import '../../utils/types/iterable.js';
import '../../utils/types/object.js';
import '../../utils/inheritance.js';
import '../../utils/types/set.js';
import '../../utils/types/array.js';
import 'bs58';
import 'multiformats/bases/base58';
import 'varint';
import '../../utils/encoding/ss-58.js';
import 'blake2b';
import './with-base.js';
import './with-eq.js';
import './any-of.js';
import './with-from.js';
import './with-from-json-bytes.js';

class TypedString extends TypedBytes {
  constructor(value) {
    super(normalizeOrConvertStringToU8a(value));
  }

  get value() {
    return 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$1 = withCatchNull(TypedString);

export { TypedString$1 as default };
//# sourceMappingURL=typed-string.js.map
