const levelBased = require('./levelBased');
const flowBased = require('./flowBased');
const manual = require('./manual');

const strategies = {
  [levelBased.name]: levelBased,
  [flowBased.name]: flowBased,
  [manual.name]: manual,
};

function dispatch(mode, ctx, controlState, direction) {
  const s = strategies[mode];
  if (!s) {
    ctx.logger?.warn?.(`Unsupported control mode: ${mode}`);
    return Promise.resolve();
  }
  return s.run(ctx, controlState, direction);
}

module.exports = { strategies, dispatch, manual };
