"use strict";

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

function _react() {
  const data = _interopRequireDefault(require("react"));

  _react = function _react() {
    return data;
  };

  return data;
}

function _launchEditor() {
  const data = _interopRequireDefault(require("react-dev-utils/launchEditor"));

  _launchEditor = function _launchEditor() {
    return data;
  };

  return data;
}

function _launchEditorEndpoint() {
  const data = _interopRequireDefault(require("react-dev-utils/launchEditorEndpoint"));

  _launchEditorEndpoint = function _launchEditorEndpoint() {
    return data;
  };

  return data;
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function createLaunchEditorMiddleware() {
  return function launchEditorMiddleware(req, res, next) {
    if (req.url.startsWith(_launchEditorEndpoint().default)) {
      const lineNumber = parseInt(req.query.lineNumber, 10) || 1;
      (0, _launchEditor().default)(req.query.fileName, lineNumber);
      res.end();
    } else {
      next();
    }
  };
}