Liferay.Loader.define("layout-content-page-editor-web@2.0.110/page_editor/app/thunks/addWidget", ['module', 'exports', 'require', '../actions/addFragmentEntryLinks', '../services/WidgetService'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = addWidget;

    var _addFragmentEntryLinks = _interopRequireDefault(require("../actions/addFragmentEntryLinks"));

    var _WidgetService = _interopRequireDefault(require("../services/WidgetService"));

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

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    function addWidget(_ref) {
      var parentItemId = _ref.parentItemId,
          portletId = _ref.portletId,
          portletItemId = _ref.portletItemId,
          position = _ref.position,
          store = _ref.store;
      return function (dispatch) {
        var segmentsExperienceId = store.segmentsExperienceId;

        _WidgetService.default.addPortlet({
          onNetworkStatus: dispatch,
          parentItemId: parentItemId,
          portletId: portletId,
          portletItemId: portletItemId,
          position: position,
          segmentsExperienceId: segmentsExperienceId
        }).then(function (_ref2) {
          var addedItemId = _ref2.addedItemId,
              fragmentEntryLink = _ref2.fragmentEntryLink,
              layoutData = _ref2.layoutData;
          dispatch((0, _addFragmentEntryLinks.default)({
            addedItemId: addedItemId,
            fragmentEntryLinks: [fragmentEntryLink],
            layoutData: layoutData
          }));
        });
      };
    }
    //# sourceMappingURL=addWidget.js.map
  }
});
//# sourceMappingURL=addWidget.js.map