"use client";
const entityIconRegistry = /* @__PURE__ */ new Map();
function registerEntityIcon(slug, icon) {
  if (icon) {
    entityIconRegistry.set(slug, icon);
  }
}
class ClientEntityRegistry {
  entities = /* @__PURE__ */ new Map();
  /**
   * Register a new entity configuration
   */
  register(config) {
    this.entities.set(config.slug, config);
  }
  /**
   * Get entity configuration by name
   */
  get(name) {
    return this.entities.get(name);
  }
  /**
   * Get all registered entities
   */
  getAll() {
    return Array.from(this.entities.values());
  }
  /**
   * Get only enabled entities
   */
  getEnabled() {
    return this.getAll().filter((entity) => entity.enabled);
  }
  /**
   * Clear all registered entities
   */
  clear() {
    this.entities.clear();
  }
}
const clientEntityRegistry = new ClientEntityRegistry();
function setServerEntities(entities) {
  for (const entity of entities) {
    const registeredIcon = entityIconRegistry.get(entity.slug);
    if (registeredIcon) {
      entity.icon = registeredIcon;
    }
    clientEntityRegistry.register(entity);
  }
  console.log(`[EntityRegistry] Client-side: registered ${entities.length} entities from server (${entityIconRegistry.size} icons from registry)`);
}
function getAllEntityConfigs() {
  const clientEntities = clientEntityRegistry.getAll();
  if (clientEntities.length === 0) {
    console.log("[EntityRegistry] Client registry empty - waiting for hydration from DashboardShell");
  }
  return clientEntities;
}
function getEnabledEntities() {
  return clientEntityRegistry.getEnabled();
}
function registerEntity(config) {
  clientEntityRegistry.register(config);
}
function getEntityConfig(name) {
  return clientEntityRegistry.get(name);
}
export {
  clientEntityRegistry,
  getAllEntityConfigs,
  getEnabledEntities,
  getEntityConfig,
  registerEntity,
  registerEntityIcon,
  setServerEntities
};
