text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports["default"] = void 0;
  
  /**
   * Copyright Schrodinger, LLC
   * All rights reserved.
   *
   * This source code is licensed under the BSD-style license found in the
   * LICENSE file in the root directory of this source tree. An additional grant
   * of patent rights can be found in the PATENTS file in the same directory.
   *
   * @providesModule debounceCore
   * @typechecks
   */
  
  /**
   * Invokes the given callback after a specified number of milliseconds have
   * elapsed, ignoring subsequent calls.
   *
   * For example, if you wanted to update a preview after the user stops typing
   * you could do the following:
   *
   *   elem.addEventListener('keyup', debounce(this.updatePreview, 250), false);
   *
   * The returned function has a reset method which can be called to cancel a
   * pending invocation.
   *
   *   var debouncedUpdatePreview = debounce(this.updatePreview, 250);
   *   elem.addEventListener('keyup', debouncedUpdatePreview, false);
   *
   *   // later, to cancel pending calls
   *   debouncedUpdatePreview.reset();
   *
   * @param {function} func - the function to debounce
   * @param {number} wait - how long to wait in milliseconds
   * @param {*} context - optional context to invoke the function in
   * @param {?function} setTimeoutFunc - an implementation of setTimeout
   *  if nothing is passed in the default setTimeout function is used
    * @param {?function} clearTimeoutFunc - an implementation of clearTimeout
   *  if nothing is passed in the default clearTimeout function is used
   */
  function debounce(func, wait, context, setTimeoutFunc, clearTimeoutFunc) {
    setTimeoutFunc = setTimeoutFunc || setTimeout;
    clearTimeoutFunc = clearTimeoutFunc || clearTimeout;
    var timeout;
  
    function debouncer() {
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      debouncer.reset();
  
      var callback = function callback() {
        func.apply(context, args);
      };
  
      callback.__SMmeta = func.__SMmeta;
      timeout = setTimeoutFunc(callback, wait);
    }
  
    debouncer.reset = function () {
      clearTimeoutFunc(timeout);
    };
  
    return debouncer;
  }
  
  var _default = debounce;
  exports["default"] = _default;