import { getAnalyticsModuleConfigs } from "@open-mercato/shared/modules/analytics";
class DefaultAnalyticsRegistry {
  constructor(configs) {
    this.configs = configs ?? getAnalyticsModuleConfigs();
    this.entityConfigMap = /* @__PURE__ */ new Map();
    this.buildEntityConfigMap();
  }
  buildEntityConfigMap() {
    for (const moduleConfig of this.configs) {
      for (const entityConfig of moduleConfig.entities) {
        this.entityConfigMap.set(entityConfig.entityId, entityConfig);
      }
    }
  }
  getAllEntityConfigs() {
    return Array.from(this.entityConfigMap.values());
  }
  getEntityConfig(entityId) {
    return this.entityConfigMap.get(entityId) ?? null;
  }
  isValidEntityType(entityId) {
    return this.entityConfigMap.has(entityId);
  }
  getEntityTypeConfig(entityId) {
    const config = this.getEntityConfig(entityId);
    return config?.entityConfig ?? null;
  }
  getFieldMapping(entityId, field) {
    const config = this.getEntityConfig(entityId);
    return config?.fieldMappings[field] ?? null;
  }
  getRequiredFeatures(entityId) {
    const config = this.getEntityConfig(entityId);
    return config?.requiredFeatures ?? null;
  }
  getLabelResolverConfig(entityId, field) {
    const config = this.getEntityConfig(entityId);
    return config?.labelResolvers?.[field] ?? null;
  }
  getAllFieldMappings(entityId) {
    const config = this.getEntityConfig(entityId);
    return config?.fieldMappings ?? null;
  }
}
function createAnalyticsRegistry(configs) {
  return new DefaultAnalyticsRegistry(configs);
}
export {
  DefaultAnalyticsRegistry,
  createAnalyticsRegistry
};
//# sourceMappingURL=analyticsRegistry.js.map
