Liferay.Loader.define("layout-content-page-editor-web@2.0.110/page_editor/app/components/layout-data-items/Row", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/layout', 'frontend-js-react-web$classnames', 'frontend-js-react-web$prop-types', 'frontend-js-react-web$react', '../../../prop-types/index', '../../config/constants/layoutDataItemTypes', '../../store/index', '../../utils/getFrontendTokenValue', '../../utils/getResponsiveConfig', '../../utils/loadBackgroundImage'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

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

    var _layout = _interopRequireDefault(require("@frontend-taglib-clay$clayui/layout"));

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _propTypes = _interopRequireDefault(require("frontend-js-react-web$prop-types"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _index = require("../../../prop-types/index");

    var _layoutDataItemTypes = require("../../config/constants/layoutDataItemTypes");

    var _index2 = require("../../store/index");

    var _getFrontendTokenValue = require("../../utils/getFrontendTokenValue");

    var _getResponsiveConfig = require("../../utils/getResponsiveConfig");

    var _loadBackgroundImage = _interopRequireDefault(require("../../utils/loadBackgroundImage"));

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (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;
    }

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

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return obj;
    }

    function _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    var Row = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
      var _classNames;

      var children = _ref.children,
          className = _ref.className,
          item = _ref.item,
          _ref$withinTopper = _ref.withinTopper,
          withinTopper = _ref$withinTopper === void 0 ? false : _ref$withinTopper;
      var selectedViewportSize = (0, _index2.useSelector)(function (state) {
        return state.selectedViewportSize;
      });
      var itemConfig = (0, _getResponsiveConfig.getResponsiveConfig)(item.config, selectedViewportSize);
      var modulesPerRow = itemConfig.modulesPerRow,
          reverseOrder = itemConfig.reverseOrder;
      var _itemConfig$styles = itemConfig.styles,
          backgroundColor = _itemConfig$styles.backgroundColor,
          backgroundImage = _itemConfig$styles.backgroundImage,
          borderColor = _itemConfig$styles.borderColor,
          borderRadius = _itemConfig$styles.borderRadius,
          borderWidth = _itemConfig$styles.borderWidth,
          fontFamily = _itemConfig$styles.fontFamily,
          fontSize = _itemConfig$styles.fontSize,
          fontWeight = _itemConfig$styles.fontWeight,
          height = _itemConfig$styles.height,
          marginBottom = _itemConfig$styles.marginBottom,
          marginLeft = _itemConfig$styles.marginLeft,
          marginRight = _itemConfig$styles.marginRight,
          marginTop = _itemConfig$styles.marginTop,
          maxHeight = _itemConfig$styles.maxHeight,
          maxWidth = _itemConfig$styles.maxWidth,
          minHeight = _itemConfig$styles.minHeight,
          minWidth = _itemConfig$styles.minWidth,
          opacity = _itemConfig$styles.opacity,
          overflow = _itemConfig$styles.overflow,
          paddingBottom = _itemConfig$styles.paddingBottom,
          paddingLeft = _itemConfig$styles.paddingLeft,
          paddingRight = _itemConfig$styles.paddingRight,
          paddingTop = _itemConfig$styles.paddingTop,
          shadow = _itemConfig$styles.shadow,
          textAlign = _itemConfig$styles.textAlign,
          textColor = _itemConfig$styles.textColor,
          width = _itemConfig$styles.width;

      var _useState = (0, _react.useState)(''),
          _useState2 = _slicedToArray(_useState, 2),
          backgroundImageValue = _useState2[0],
          setBackgroundImageValue = _useState2[1];

      (0, _react.useEffect)(function () {
        (0, _loadBackgroundImage.default)(backgroundImage).then(setBackgroundImageValue);
      }, [backgroundImage]);
      var style = {};
      style.backgroundColor = (0, _getFrontendTokenValue.getFrontendTokenValue)(backgroundColor);
      style.border = "solid ".concat(borderWidth, "px");
      style.borderColor = (0, _getFrontendTokenValue.getFrontendTokenValue)(borderColor);
      style.borderRadius = (0, _getFrontendTokenValue.getFrontendTokenValue)(borderRadius);
      style.boxShadow = (0, _getFrontendTokenValue.getFrontendTokenValue)(shadow);
      style.color = (0, _getFrontendTokenValue.getFrontendTokenValue)(textColor);
      style.fontFamily = (0, _getFrontendTokenValue.getFrontendTokenValue)(fontFamily);
      style.fontSize = (0, _getFrontendTokenValue.getFrontendTokenValue)(fontSize);
      style.fontWeight = (0, _getFrontendTokenValue.getFrontendTokenValue)(fontWeight);
      style.height = height;
      style.maxHeight = maxHeight;
      style.minHeight = minHeight;
      style.opacity = opacity ? opacity / 100 : null;
      style.overflow = overflow;

      if (!withinTopper) {
        style.maxWidth = maxWidth;
        style.minWidth = minWidth;
        style.width = width;
      }

      if (backgroundImageValue) {
        style.backgroundImage = "url(".concat(backgroundImageValue, ")");
        style.backgroundPosition = '50% 50%';
        style.backgroundRepeat = 'no-repeat';
        style.backgroundSize = 'cover';
      }

      var rowContent = /*#__PURE__*/_react.default.createElement(_layout.default.Row, {
        className: (0, _classnames.default)(className, "mb-".concat(marginBottom || 0), "mt-".concat(marginTop || 0), "pb-".concat(paddingBottom || 0), "pl-".concat(paddingLeft || 0), "pr-".concat(paddingRight || 0), "pt-".concat(paddingTop || 0), (_classNames = {
          'flex-column-reverse': item.config.numberOfColumns === 2 && modulesPerRow === 1 && reverseOrder
        }, _defineProperty(_classNames, "ml-".concat(marginLeft), marginLeft && marginLeft !== '0'), _defineProperty(_classNames, "mr-".concat(marginRight), marginRight && marginRight !== '0'), _defineProperty(_classNames, 'no-gutters', !item.config.gutters), _defineProperty(_classNames, textAlign ? textAlign.startsWith('text-') ? textAlign : "text-".concat(textAlign) : '', textAlign), _classNames)),
        ref: ref,
        style: style
      }, children);

      var masterLayoutData = (0, _index2.useSelector)(function (state) {
        var _state$masterLayout;

        return (_state$masterLayout = state.masterLayout) === null || _state$masterLayout === void 0 ? void 0 : _state$masterLayout.masterLayoutData;
      });
      var masterParent = (0, _react.useMemo)(function () {
        var dropZone = masterLayoutData && masterLayoutData.items[masterLayoutData.rootItems.dropZone];
        return dropZone ? getItemParent(dropZone, masterLayoutData) : undefined;
      }, [masterLayoutData]);
      var shouldAddContainer = (0, _index2.useSelector)(function (state) {
        return !getItemParent(item, state.layoutData) && !masterParent;
      });
      return shouldAddContainer ? /*#__PURE__*/_react.default.createElement(_layout.default.ContainerFluid, {
        className: "p-0",
        size: false
      }, rowContent) : rowContent;
    });

    function getItemParent(item, itemLayoutData) {
      var parent = itemLayoutData.items[item.parentId];
      return parent && (parent.type === _layoutDataItemTypes.LAYOUT_DATA_ITEM_TYPES.root || parent.type === _layoutDataItemTypes.LAYOUT_DATA_ITEM_TYPES.fragmentDropZone) ? getItemParent(parent, itemLayoutData) : parent;
    }

    var _default = Row;
    exports.default = _default;
    //# sourceMappingURL=Row.js.map
  }
});
//# sourceMappingURL=Row.js.map