import { __require as requireUnicodeUtils } from '../../../../fbjs@2.0.0/node_modules/fbjs/lib/UnicodeUtils.js';

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * 
 * @emails oncall+draft_js
 */

var decodeEntityRanges_1;
var hasRequiredDecodeEntityRanges;

function requireDecodeEntityRanges () {
	if (hasRequiredDecodeEntityRanges) return decodeEntityRanges_1;
	hasRequiredDecodeEntityRanges = 1;

	var UnicodeUtils = requireUnicodeUtils();

	var substr = UnicodeUtils.substr;
	/**
	 * Convert to native JavaScript string lengths to determine ranges.
	 */

	function decodeEntityRanges(text, ranges) {
	  var entities = Array(text.length).fill(null);

	  if (ranges) {
	    ranges.forEach(function (range) {
	      // Using Unicode-enabled substrings converted to JavaScript lengths,
	      // fill the output array with entity keys.
	      var start = substr(text, 0, range.offset).length;
	      var end = start + substr(text, range.offset, range.length).length;

	      for (var ii = start; ii < end; ii++) {
	        entities[ii] = range.key;
	      }
	    });
	  }

	  return entities;
	}

	decodeEntityRanges_1 = decodeEntityRanges;
	return decodeEntityRanges_1;
}

export { requireDecodeEntityRanges as __require };
//# sourceMappingURL=decodeEntityRanges.js.map
