"use strict";

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

var _react = _interopRequireWildcard(require("react"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

// Copyright 1999-2020. Plesk International GmbH. All rights reserved.

/**
 * `Tour` component is used for introducing a new functionality in the product.
 * The component consists of several [Spots](#!/Spot), each of them highlighting a specific feature
 * or element you want to focus user attention on.
 * @since 2.7.0
 */
const Tour = ({
  current,
  children,
  onClose
}) => {
  const spots = _react.Children.toArray(children);

  if (current !== undefined && current in spots) {
    const spot = spots[current];

    if ( /*#__PURE__*/(0, _react.isValidElement)(spot)) {
      let popup;

      if (onClose && spot.props.popup) {
        popup = { ...spot.props.popup,
          onClose
        };
      }

      const props = {
        key: current,
        meta: {
          current,
          total: spots.length
        },
        popup
      };
      return /*#__PURE__*/(0, _react.cloneElement)(spot, props);
    }
  } // a workaround for Props & Methods in Styleguidist
  // eslint-disable-next-line no-constant-condition


  if (false) {
    return /*#__PURE__*/_react.default.createElement("span", null);
  }

  return null;
};

var _default = Tour;
exports.default = _default;