'use strict';

var types_generic_typedBytes = require('./typed-bytes.cjs');
var types_generic_typedArray = require('./typed-array.cjs');
var types_generic_typedBytesArray = require('./typed-bytes-array.cjs');
require('../../utils/types/bytes.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-catch-null.cjs');
require('./with-eq.cjs');
require('./any-of.cjs');
require('./with-from.cjs');
require('./with-from-json-bytes.cjs');

class TypedArrayOfTypedBytes extends types_generic_typedArray {
  static Class = types_generic_typedBytes;
}

class TypedArrayOfBytesArrays extends types_generic_typedArray {
  static Class = types_generic_typedBytesArray;
}

/**
 * Creates a converter function that processes an item through multiple parsers.
 *
 * @param {Function} finalize - Function to apply to each processed item
 * @param {Class} parserClass - Primary parser class used to parse the initial item
 * @param {...Function} parsers - Additional parser functions to apply
 * @returns {Function} A function that takes an item and returns processed results
 */
const createConverter = (finalize, parserClass, ...parsers) => (item) => {
  // Initialize result array with original item
  const res = [item];

  try {
    // First parse the item using primary parser
    const parsedDid = parserClass.from(item);

    // Then pass the parsed result through additional parsers
    for (const parser of parsers) {
      try {
        res.push(parser.from(parsedDid));
      } catch {
        // Error is intentionally ignored
      }
    }
  } catch {
    // Initial parsing error is intentionally ignored
  }

  // Apply finalization to all processed results
  return res.map(finalize);
};

exports.TypedArrayOfBytesArrays = TypedArrayOfBytesArrays;
exports.TypedArrayOfTypedBytes = TypedArrayOfTypedBytes;
exports.createConverter = createConverter;
//# sourceMappingURL=utils.cjs.map
