Liferay.Loader.define("layout-content-page-editor-web@2.0.166/page_editor/core/openImageSelector", ['module', 'exports', 'require', 'frontend-js-web', '../app/config/index'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.openImageSelector = openImageSelector;

    var _frontendJsWeb = require("frontend-js-web");

    var _index = require("../app/config/index");

    /**
     * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
     * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
     */
    function openImageSelector(callback) {
      var destroyedCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
      (0, _frontendJsWeb.openSelectionModal)({
        onClose: destroyedCallback,
        onSelect: function onSelect(selectedItem) {
          var returnType = selectedItem.returnType,
              value = selectedItem.value;
          var selectedImage = {};

          if (returnType === 'URL') {
            selectedImage.title = '';
            selectedImage.url = value;
          } else {
            var fileEntry = JSON.parse(value);
            selectedImage.fileEntryId = fileEntry.fileEntryId;
            selectedImage.title = fileEntry.title;
            selectedImage.url = fileEntry.url;
          }

          callback(selectedImage);
        },
        selectEventName: "".concat(_index.config.portletNamespace, "selectImage"),
        title: Liferay.Language.get('select'),
        url: _index.config.imageSelectorURL
      });
    }
    //# sourceMappingURL=openImageSelector.js.map
  }
});
//# sourceMappingURL=openImageSelector.js.map