import {
  SEARCH_TYPE_PRIORITIES,
  ENTITY_METADATA
} from "@nextsparkjs/registries/entity-types";
const SYSTEM_TYPES = ["task", "page", "setting", "entity"];
class EntityTypeService {
  /**
   * Check if a type is an entity type (vs system type)
   *
   * @param type - The search result type to check
   * @returns True if the type is an entity, false if it's a system type
   *
   * @example
   * ```typescript
   * EntityTypeService.isEntityType('customers') // true
   * EntityTypeService.isEntityType('page') // false
   * EntityTypeService.isEntityType('setting') // false
   * ```
   */
  static isEntityType(type) {
    return !SYSTEM_TYPES.includes(type);
  }
  /**
   * Get all available entity names
   *
   * @returns Array of all entity names from the registry
   *
   * @example
   * ```typescript
   * const names = EntityTypeService.getAllNames()
   * // ['customers', 'pages', 'posts', 'tasks']
   * ```
   */
  static getAllNames() {
    return [...ENTITY_METADATA.entityNames];
  }
  /**
   * Get search priority for a result type
   *
   * Higher numbers indicate higher priority in search results.
   * Returns 0 for unknown types.
   *
   * @param type - The search result type
   * @returns Priority number (higher = more relevant)
   *
   * @example
   * ```typescript
   * EntityTypeService.getPriority('customers') // 14
   * EntityTypeService.getPriority('page') // 5
   * EntityTypeService.getPriority('unknown') // 0
   * ```
   */
  static getPriority(type) {
    return SEARCH_TYPE_PRIORITIES[type] ?? 0;
  }
  /**
   * Get all system types (non-entity types)
   *
   * @returns Array of system search types
   *
   * @example
   * ```typescript
   * const systemTypes = EntityTypeService.getSystemTypes()
   * // ['task', 'page', 'setting', 'entity']
   * ```
   */
  static getSystemTypes() {
    return SYSTEM_TYPES;
  }
  /**
   * Get metadata about the entity types registry
   *
   * @returns Registry metadata object
   *
   * @example
   * ```typescript
   * const meta = EntityTypeService.getMetadata()
   * // { totalEntities: 4, entityNames: [...], generatedAt: '...', source: '...' }
   * ```
   */
  static getMetadata() {
    return ENTITY_METADATA;
  }
  /**
   * Get the total count of registered entities
   *
   * @returns Number of entities
   *
   * @example
   * ```typescript
   * const count = EntityTypeService.getCount() // 4
   * ```
   */
  static getCount() {
    return ENTITY_METADATA.totalEntities;
  }
}
const isEntityType = EntityTypeService.isEntityType;
const getAllEntityNames = EntityTypeService.getAllNames;
const getSearchTypePriority = EntityTypeService.getPriority;
export {
  EntityTypeService,
  getAllEntityNames,
  getSearchTypePriority,
  isEntityType
};
