Liferay.Loader.define("commerce-bom-admin-web@4.0.30/js/components/utilities/combineReducers.es", ['module', 'exports', 'require'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.combineReducers = combineReducers;

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * The contents of this file are subject to the terms of the Liferay Enterprise
     * Subscription License ("License"). You may not use this file except in
     * compliance with the License. You can obtain a copy of the License by
     * contacting Liferay, Inc. See the License for the specific language governing
     * permissions and limitations under the License, including but not limited to
     * distribution rights of the Software.
     */
    function combineReducers(reducers) {
      var reducerKeys = Object.keys(reducers);
      return function combineReducers() {
        var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
        var action = arguments.length > 1 ? arguments[1] : undefined;
        var nextState = {};
        var hasChanged = false;
        reducerKeys.forEach(function (key) {
          var reducer = reducers[key],
              previousStateForKey = state[key],
              nextStateForKey = reducer(previousStateForKey, action);

          if (typeof nextStateForKey === 'undefined') {
            throw new Error("The reducer for \"".concat(key, "\" is undefined"));
          }

          nextState[key] = nextStateForKey;

          if (nextStateForKey !== previousStateForKey) {
            hasChanged = true;
          }
        });
        return hasChanged ? nextState : state;
      };
    }
    //# sourceMappingURL=combineReducers.es.js.map
  }
});
//# sourceMappingURL=combineReducers.es.js.map