"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 _urlConcat = require("../../shared/server/urlConcat");

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

function optionsProcessor(options) {
  const {
    server,
    context,
    mode,
    noPublicPath
  } = options;
  const {
    isCdnEnabled
  } = options.cdnMapping;
  const {
    disableContextURL
  } = server;
  const serverExtras = (0, _decidePublicPath.modifiedServerOptions)(options);
  const publicPath = noPublicPath ? '' : (0, _decidePublicPath.decidePublicPath)(serverExtras);
  const contextURL = disableContextURL ? '' : `/${context}`;
  const serverURL = (0, _urlConcat.urlConcat)(publicPath, contextURL); // console.log({ publicPath, serverURL });

  const contextFolderPath = (0, _constants.joinWithAppPath)(context);
  const defaultAppliedOptions = { ...options,
    serverExtras,
    mode: mode === null ? 'prod' : mode,
    publicPath: (0, _modeUtils.isDevelopmentMode)(mode) || isCdnEnabled ? '' : publicPath,
    contextURL,
    serverURL,
    contextFolderPath,
    httpsOptions: serverExtras.httpsOptions
  };
  return defaultAppliedOptions;
}