text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var dom_1 = require("./dom");
  var sessionStorage_1 = require("./sessionStorage");
  var RTL_LOCAL_STORAGE_KEY = 'isRTL';
  // Default to undefined so that we initialize on first read.
  var _isRTL;
  /**
   * Gets the rtl state of the page (returns true if in rtl.)
   */
  function getRTL() {
      if (_isRTL === undefined) {
          // Fabric supports persisting the RTL setting between page refreshes via session storage
          var savedRTL = sessionStorage_1.getItem(RTL_LOCAL_STORAGE_KEY);
          if (savedRTL !== null) {
              _isRTL = savedRTL === '1';
              setRTL(_isRTL);
          }
          var doc = dom_1.getDocument();
          if (_isRTL === undefined && doc) {
              _isRTL = doc.documentElement.getAttribute('dir') === 'rtl';
          }
      }
      return !!_isRTL;
  }
  exports.getRTL = getRTL;
  /**
   * Sets the rtl state of the page (by adjusting the dir attribute of the html element.)
   */
  function setRTL(isRTL, persistSetting) {
      if (persistSetting === void 0) { persistSetting = false; }
      var doc = dom_1.getDocument();
      if (doc) {
          doc.documentElement.setAttribute('dir', isRTL ? 'rtl' : 'ltr');
      }
      if (persistSetting) {
          sessionStorage_1.setItem(RTL_LOCAL_STORAGE_KEY, isRTL ? '1' : '0');
      }
      _isRTL = isRTL;
  }
  exports.setRTL = setRTL;
  /**
   * Returns the given key, but flips right/left arrows if necessary.
   */
  function getRTLSafeKeyCode(key) {
      if (getRTL()) {
          if (key === 37 /* left */) {
              key = 39 /* right */;
          }
          else if (key === 39 /* right */) {
              key = 37 /* left */;
          }
      }
      return key;
  }
  exports.getRTLSafeKeyCode = getRTLSafeKeyCode;
  //# sourceMappingURL=rtl.js.map