/**
 * generalFunctions/index.js
 * -----------------------------------------------------------
 * Central barrel file for re-exporting helpers and configurations.
 * Provides both namespace exports and dynamic loading capabilities.
 * now we can load modules like this:
 * const { menuUtils, outputUtils } = require('generalFunctions');
 */

// Core helper modules
const helper = require('./src/helper/index.js');
const {
    outputUtils,
    logger,
    validation,
    configUtils,
    assertions,
    childRegistrationUtils,
    gravity,
} = helper;
const coolprop = require('./src/coolprop-node/src/index.js');
const assetApiConfig = require('./src/configs/assetApiConfig.js');

// Domain-specific modules
const { MeasurementContainer } = require('./src/measurements/index.js');
const configManager = require('./src/configs/index.js');
const { nrmse } = require('./src/nrmse/index.js');
const { state } = require('./src/state/index.js');
const convert = require('./src/convert/index.js');
const MenuManager = require('./src/menu/index.js');
const { predict, interpolation } = require('./src/predict/index.js');
const { PIDController, CascadePIDController, createPidController, createCascadePidController } = require('./src/pid/index.js');
const { AssetResolver, FileBackend, HttpBackend, assetResolver } = require('./src/registry/index.js');

// loadCurve(model) is now a thin shim over assetResolver.resolve('curves', model).
// Same contract: sync, case-insensitive, returns null on miss. New code should
// prefer `assetResolver.resolve('curves', ...)` directly; this shim is kept so
// external consumers don't have to change in one go.
function loadCurve(modelId) {
    return assetResolver.resolve('curves', modelId);
}
const { POSITIONS, POSITION_VALUES, isValidPosition } = require('./src/constants/positions.js');
const Fysics = require('./src/convert/fysics.js');

// Refactor platform infrastructure (additive — see .claude/refactor/CONTRACTS.md).
// Domain-side
const UnitPolicy = require('./src/domain/UnitPolicy.js');
const ChildRouter = require('./src/domain/ChildRouter.js');
const LatestWinsGate = require('./src/domain/LatestWinsGate.js');
const HealthStatus = require('./src/domain/HealthStatus.js');
const BaseDomain = require('./src/domain/BaseDomain.js');
// Node-RED-side
const { statusBadge } = require('./src/nodered/statusBadge.js');
const { StatusUpdater } = require('./src/nodered/statusUpdater.js');
const { createRegistry, CommandRegistry } = require('./src/nodered/commandRegistry.js');
const BaseNodeAdapter = require('./src/nodered/BaseNodeAdapter.js');
// Stats helpers
const stats = require('./src/stats/index.js');

// Export everything
module.exports = {
    predict,
    interpolation,
    configManager,
    assetApiConfig,
    outputUtils,
    configUtils,
    logger,
    validation,
    assertions,
    MeasurementContainer,
    nrmse,
    state,
    coolprop,
    convert,
    MenuManager,
    PIDController,
    CascadePIDController,
    createPidController,
    createCascadePidController,
    childRegistrationUtils,
    loadCurve,
    gravity,
    POSITIONS,
    POSITION_VALUES,
    isValidPosition,
    Fysics,
    // refactor infra (Phase 1)
    UnitPolicy,
    ChildRouter,
    LatestWinsGate,
    HealthStatus,
    BaseDomain,
    statusBadge,
    StatusUpdater,
    createRegistry,
    CommandRegistry,
    BaseNodeAdapter,
    stats,
    // Asset metadata registry (replaces loadCurve / AssetCategoryManager /
    // ad-hoc JSON readers — see src/registry/README.md). Backend-swappable;
    // sync at runtime by contract.
    AssetResolver,
    FileBackend,
    HttpBackend,
    assetResolver,
};
