"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.optionsProcessor = optionsProcessor;

var _decidePublicPath = require("../../shared/bundler/webpack/common/decidePublicPath");

var _modeUtils = require("../../shared/bundler/webpack/common/modeUtils");

var _constants = require("../../shared/constants");

function optionsProcessor(options) {
  const {
    context,
    mode,
    noPublicPath
  } = options;
  const {
    isCdnEnabled
  } = options.cdnMapping;
  const serverExtras = (0, _decidePublicPath.modifiedServerOptions)(options);
  const publicPath = noPublicPath ? undefined : (0, _decidePublicPath.decidePublicPath)(serverExtras);
  const contextFolderPath = (0, _constants.joinWithAppPath)(context);
  const defaultAppliedOptions = { ...options,
    serverExtras,
    // eslint-disable-next-line no-nested-ternary
    mode: mode === null ? 'prod' : mode === 'dev' ? 'dev' : 'prod',
    publicPath: (0, _modeUtils.isDevelopmentMode)(mode) || isCdnEnabled ? undefined : publicPath,
    contextFolderPath,
    httpsOptions: serverExtras.httpsOptions
  };
  return defaultAppliedOptions;
}