"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.CookieConsent = void 0;

var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _lib = require("@sentecacommerce-theme/lib");

var _Common = require("../Common");

var _Components = require("./Components");

var _templateObject;

var CookieConsent = function CookieConsent(_ref) {
  var _contentMap, _labelsMap;

  var isEnabled = _ref.isEnabled,
      basic = _ref.basic,
      advanced = _ref.advanced,
      details = _ref.details;

  var _useCookies = (0, _lib.useCookies)(),
      cookiesMap = _useCookies.cookiesMap,
      consentTab = _useCookies.consentTab,
      returnToBasic = _useCookies.returnToBasic,
      openAdvanced = _useCookies.openAdvanced,
      handleDetails = _useCookies.handleDetails,
      cookie = _useCookies.cookie,
      cookiesConsent = _useCookies.cookiesConsent,
      onSave = _useCookies.onSave,
      onAcceptAll = _useCookies.onAcceptAll,
      isChecked = _useCookies.isChecked,
      handleToggle = _useCookies.handleToggle;

  var contentMap = (_contentMap = {}, _contentMap[_lib.CookiesConsentEnum.basic] = /*#__PURE__*/_react["default"].createElement(_Components.BasicConsent, (0, _extends2["default"])({}, basic, {
    setAdvanced: openAdvanced,
    giveConsent: onAcceptAll
  })), _contentMap[_lib.CookiesConsentEnum.advancedProperties] = /*#__PURE__*/_react["default"].createElement(_Components.AdvancedConsent, (0, _extends2["default"])({}, advanced, {
    cookiesMap: cookiesMap,
    setDetails: handleDetails,
    handleToggle: handleToggle,
    onSave: onSave,
    onAcceptAll: onAcceptAll,
    isChecked: isChecked
  })), _contentMap[_lib.CookiesConsentEnum.details] = /*#__PURE__*/_react["default"].createElement(_Components.Details, {
    cookie: cookie,
    cookiesMap: cookiesMap,
    labels: details.table,
    goBack: details.goBack,
    handleBack: openAdvanced
  }), _contentMap);
  var labelsMap = (_labelsMap = {}, _labelsMap[_lib.CookiesConsentEnum.basic] = 'Cookies', _labelsMap[_lib.CookiesConsentEnum.advancedProperties] = 'Advanced Settings', _labelsMap); // TODO: make FixedElement component (portal) to handle the fixed position

  return /*#__PURE__*/_react["default"].createElement(_Common.Modal, {
    isCookies: true,
    open: !!isEnabled && !cookiesConsent,
    title: consentTab === _lib.CookiesConsentEnum.details ? cookie : labelsMap[consentTab],
    handleClose: returnToBasic
  }, /*#__PURE__*/_react["default"].createElement(Container, null, contentMap[consentTab]));
};

exports.CookieConsent = CookieConsent;

var Container = _styledComponents["default"].div.attrs({
  className: 'd-flex flex-column container-fluid '
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  line-height: 1.8rem;\n  transition: all 0.3s ease-in-out;\n  @media (min-width: ", ") {\n    position: relative;\n  }\n"])), function (_ref2) {
  var theme = _ref2.theme;
  return theme.breakpoints.lg.min;
});
//# sourceMappingURL=cookieConsent.component.js.map