import { __require as requireUnicodeBidi } from './UnicodeBidi.js';
import { __require as requireUnicodeBidiDirection } from './UnicodeBidiDirection.js';
import { __require as requireInvariant } from './invariant.js';

/**
 * Copyright (c) 2013-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @typechecks
 * 
 */

var UnicodeBidiService_1;
var hasRequiredUnicodeBidiService;

function requireUnicodeBidiService () {
	if (hasRequiredUnicodeBidiService) return UnicodeBidiService_1;
	hasRequiredUnicodeBidiService = 1;

	function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

	var UnicodeBidi = requireUnicodeBidi();

	var UnicodeBidiDirection = requireUnicodeBidiDirection();

	var invariant = requireInvariant();

	var UnicodeBidiService =
	/*#__PURE__*/
	function () {
	  /**
	   * Stateful class for paragraph direction detection
	   *
	   * @param defaultDir  Default direction of the service
	   */
	  function UnicodeBidiService(defaultDir) {
	    _defineProperty(this, "_defaultDir", void 0);

	    _defineProperty(this, "_lastDir", void 0);

	    if (!defaultDir) {
	      defaultDir = UnicodeBidiDirection.getGlobalDir();
	    } else {
	      !UnicodeBidiDirection.isStrong(defaultDir) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Default direction must be a strong direction (LTR or RTL)') : invariant(false) : void 0;
	    }

	    this._defaultDir = defaultDir;
	    this.reset();
	  }
	  /**
	   * Reset the internal state
	   *
	   * Instead of creating a new instance, you can just reset() your instance
	   * everytime you start a new loop.
	   */


	  var _proto = UnicodeBidiService.prototype;

	  _proto.reset = function reset() {
	    this._lastDir = this._defaultDir;
	  };
	  /**
	   * Returns the direction of a block of text, and remembers it as the
	   * fall-back direction for the next paragraph.
	   *
	   * @param str  A text block, e.g. paragraph, table cell, tag
	   * @return     The resolved direction
	   */


	  _proto.getDirection = function getDirection(str) {
	    this._lastDir = UnicodeBidi.getDirection(str, this._lastDir);
	    return this._lastDir;
	  };

	  return UnicodeBidiService;
	}();

	UnicodeBidiService_1 = UnicodeBidiService;
	return UnicodeBidiService_1;
}

export { requireUnicodeBidiService as __require };
//# sourceMappingURL=UnicodeBidiService.js.map
