import { noop } from './utils';

function withInstall(main, extra, directives) {
  const _main = main;
  _main.install = app => {
    for (const comp of [main, ...Object.values(extra !== null && extra !== void 0 ? extra : {})]) {
      app.component(comp.name, comp);
    }
    if (directives) {
      for (const directive of directives) {
        app.directive(directive.name, directive);
      }
    }
  };
  if (extra) {
    for (const [key, comp] of Object.entries(extra)) {
      _main[key] = comp;
    }
  }
  return _main;
}
function withNoopInstall(component) {
  const _main = component;
  _main.install = noop;
  return _main;
}

export { withInstall, withNoopInstall };
