import { Schema, Metadata, Component, Indexer } from './types.js';
import 'rxjs';
import './constants.js';
import 'type-fest';

/**
 * Create an indexed component from a given component.
 *
 * @remarks
 * An indexed component keeps a "reverse mapping" from {@link ComponentValue} to the Set of {@link createEntity Entities} with this value.
 * This adds a performance overhead to modifying component values and a memory overhead since in the worst case there is one Set per entity (if every entity has a different component value).
 * In return the performance for querying for entities with a given component value is close to O(1) (instead of O(#entities) in a regular non-indexed component).
 * As a rule of thumb only components that are added to many entities and are queried with {@link HasValue} a lot should be indexed (eg. the Position component).
 *
 * @dev This could be made more (memory) efficient by using a hash of the component value as key, but would require handling hash collisions.
 *
 * @param component {@link defineComponent Component} to index.
 * @returns Indexed version of the component.
 */
declare function createIndexer<S extends Schema, M extends Metadata, T = undefined>(component: Component<S, M, T>): Indexer<S, M, T>;

export { createIndexer };
