"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.baseModalLayoutDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _unidriver = require("../utils/test-utils/unidriver");
var _ButtonUni = require("../Button/Button.uni.driver");
var _TooltipUni = require("../Tooltip/Tooltip.uni.driver");
var _constants = require("./constants");
var _testUtils = require("../utils/test-utils");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var fDataHooks = (0, _testUtils.getFormattedDataHooks)(_constants.dataHooks);
var baseModalLayoutDriverFactory = (base, body) => {
  var getButtonDriver = dataHook => {
    return (0, _ButtonUni.buttonDriverFactory)(base.$("[data-hook-internal=\"".concat(dataHook, "\"]")));
  };
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    /**
     * Gets the modal theme
     */
    getTheme: function () {
      var _getTheme = (0, _asyncToGenerator2.default)(function* () {
        return base.attr('data-skin');
      });
      function getTheme() {
        return _getTheme.apply(this, arguments);
      }
      return getTheme;
    }(),
    /**
     * Gets the modal skin
     */
    getSkin: function () {
      var _getSkin = (0, _asyncToGenerator2.default)(function* () {
        return base.attr('data-skin');
      });
      function getSkin() {
        return _getSkin.apply(this, arguments);
      }
      return getSkin;
    }(),
    /**
     * Clicks the modal close-button
     */
    clickCloseButton: function () {
      var _clickCloseButton = (0, _asyncToGenerator2.default)(function* () {
        return base.$(fDataHooks.closeButton).click();
      });
      function clickCloseButton() {
        return _clickCloseButton.apply(this, arguments);
      }
      return clickCloseButton;
    }(),
    /**
     * Clicks the modal help-button
     */
    clickHelpButton: function () {
      var _clickHelpButton = (0, _asyncToGenerator2.default)(function* () {
        return base.$(fDataHooks.helpButton).click();
      });
      function clickHelpButton() {
        return _clickHelpButton.apply(this, arguments);
      }
      return clickHelpButton;
    }(),
    /**
     * Checks whether a node with the provided dataHook exists
     */
    childExists: function () {
      var _childExists = (0, _asyncToGenerator2.default)(function* (dataHook) {
        return base.$("[data-hook=\"".concat(dataHook, "\"]")).exists() || base.$("[data-hook-internal=\"".concat(dataHook, "\"]")).exists();
      });
      function childExists(_x) {
        return _childExists.apply(this, arguments);
      }
      return childExists;
    }(),
    /**
     * Gets the title's text
     */
    getTitleText: function () {
      var _getTitleText = (0, _asyncToGenerator2.default)(function* () {
        return base.$(fDataHooks.headerTitle).text();
      });
      function getTitleText() {
        return _getTitleText.apply(this, arguments);
      }
      return getTitleText;
    }(),
    /**
     * Gets the subtitle's text
     */
    getSubtitleText: function () {
      var _getSubtitleText = (0, _asyncToGenerator2.default)(function* () {
        return base.$(fDataHooks.headerSubtitle).text();
      });
      function getSubtitleText() {
        return _getSubtitleText.apply(this, arguments);
      }
      return getSubtitleText;
    }(),
    /**
     * Gets the secondary button driver
     */
    secondaryButtonDriver: getButtonDriver(_constants.dataHooks.footerSecondaryButton),
    /**
     * @deprecated use secondaryButtonDriver
     * Gets the secondary button driver
     */
    getSecondaryButtonDriver: function () {
      var _getSecondaryButtonDriver = (0, _asyncToGenerator2.default)(function* () {
        return getButtonDriver(_constants.dataHooks.footerSecondaryButton);
      });
      function getSecondaryButtonDriver() {
        return _getSecondaryButtonDriver.apply(this, arguments);
      }
      return getSecondaryButtonDriver;
    }(),
    /**
     * Gets the primary button driver
     */
    primaryButtonDriver: getButtonDriver(_constants.dataHooks.footerPrimaryButton),
    /**
     * @deprecated use primaryButtonDriver
     * Gets the primary button driver
     */
    getPrimaryButtonDriver: function () {
      var _getPrimaryButtonDriver = (0, _asyncToGenerator2.default)(function* () {
        return getButtonDriver(_constants.dataHooks.footerPrimaryButton);
      });
      function getPrimaryButtonDriver() {
        return _getPrimaryButtonDriver.apply(this, arguments);
      }
      return getPrimaryButtonDriver;
    }(),
    /**
     * Gets the primary button's tooltip content
     */

    getPrimaryButtonTooltipContent: function () {
      var _getPrimaryButtonTooltipContent = (0, _asyncToGenerator2.default)(function* () {
        var tooltipDriver = (0, _TooltipUni.tooltipDriverFactory)(base.$(fDataHooks.primaryButtonTooltip), body !== null && body !== void 0 ? body : base);
        return tooltipDriver.getTooltipText();
      });
      function getPrimaryButtonTooltipContent() {
        return _getPrimaryButtonTooltipContent.apply(this, arguments);
      }
      return getPrimaryButtonTooltipContent;
    }(),
    /**
     * Gets the illustration source
     */
    getIllustrationSrc: function () {
      var _getIllustrationSrc = (0, _asyncToGenerator2.default)(function* () {
        return base.$(fDataHooks.illustrationSrc).attr('src');
      });
      function getIllustrationSrc() {
        return _getIllustrationSrc.apply(this, arguments);
      }
      return getIllustrationSrc;
    }()
  });
};
exports.baseModalLayoutDriverFactory = baseModalLayoutDriverFactory;
//# sourceMappingURL=BaseModalLayout.uni.driver.js.map