

// Note: this file is written using commonjs instead of import/export to
// simplify consumption by those less familiar with the current state of
// JavaScript modularization

/* eslint camelcase: [0] */

import {MemoryStoreAdapter} from '@webex/webex-core';

require('@webex/plugin-authorization');
require('@webex/internal-plugin-wdm');
require('@webex/internal-plugin-calendar');
require('@webex/plugin-logger');
require('@webex/plugin-meetings');
require('@webex/plugin-device-manager');

const merge = require('lodash/merge');
const WebexCore = require('@webex/webex-core').default;

const config = {
  hydraServiceUrl: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',
  credentials: {
    clientType: 'confidential'
  },
  device: {
    validateDomains: true,
    ephemeral: true
  },
  storage: {
    boundedAdapter: MemoryStoreAdapter,
    unboundedAdapter: MemoryStoreAdapter
  }
};

const Webex = WebexCore.extend({
  webex: true,
  version: PACKAGE_VERSION
});

Webex.init = function init(attrs = {}) {
  attrs.config = merge({}, config, attrs.config); // eslint-disable-line no-param-reassign

  return new Webex(attrs);
};

module.exports = Webex;
