import TypedBytes from './typed-bytes.js';
import TypedArray from './typed-array.js';
import TypedBytesArray from './typed-bytes-array.js';
import '../../utils/types/bytes.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-catch-null.js';
import './with-eq.js';
import './any-of.js';
import './with-from.js';
import './with-from-json-bytes.js';

class TypedArrayOfTypedBytes extends TypedArray {
  static Class = TypedBytes;
}

class TypedArrayOfBytesArrays extends TypedArray {
  static Class = 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);
};

export { TypedArrayOfBytesArrays, TypedArrayOfTypedBytes, createConverter };
//# sourceMappingURL=utils.js.map
