Liferay.Loader.define("layout-content-page-editor-web@2.0.169/page_editor/plugins/experience/utils", ['module', 'exports', 'require', 'frontend-js-web', 'frontend-js-react-web$react'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.useDebounceCallback = useDebounceCallback;
    exports.storeModalExperienceState = storeModalExperienceState;
    exports.recoverModalExperienceState = recoverModalExperienceState;

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

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

    /**
     * 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 useDebounceCallback(callback, milliseconds) {
      var callbackRef = (0, _react.useRef)((0, _frontendJsWeb.debounce)(callback, milliseconds));
      return [callbackRef.current, function () {
        return (0, _frontendJsWeb.cancelDebounce)(callbackRef.current);
      }];
    }

    var MODAL_EXPERIENCE_STATE_KEY = 'modalExperienceState';
    /**
     * @typedef {Object} ModalExperienceState
     * @param {string} ModalExperienceState.plid
     * @param {string?} ModalExperienceState.experienceId
     * @param {string} ModalExperienceState.experienceName
     * @param {string} ModalExperienceState.segmentId
     */

    /**
     * Stores the `modalExperienceState` so it can be recovered later
     *
     * It also destroys any information previously stored for the same purpose
     *
     * @param {ModalExperienceState} modalExperienceState
     */

    function storeModalExperienceState(modalExperienceState) {
      window.sessionStorage.setItem(MODAL_EXPERIENCE_STATE_KEY, JSON.stringify(modalExperienceState));
    }
    /**
     * Rescovers the `modalExperienceState` destroying any information stored for that purpose
     *
     * @return {ModalExperienceState|null}
     */

    function recoverModalExperienceState() {
      var state = window.sessionStorage.getItem(MODAL_EXPERIENCE_STATE_KEY);

      if (state !== null) {
        window.sessionStorage.removeItem(MODAL_EXPERIENCE_STATE_KEY);
        return JSON.parse(state);
      }

      return null;
    }
    //# sourceMappingURL=utils.js.map
  }
});
//# sourceMappingURL=utils.js.map