import { __require as requireDraftStringKey } from './DraftStringKey.js';
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 encodeEntityRanges_1;
var hasRequiredEncodeEntityRanges;

function requireEncodeEntityRanges () {
	if (hasRequiredEncodeEntityRanges) return encodeEntityRanges_1;
	hasRequiredEncodeEntityRanges = 1;

	var DraftStringKey = requireDraftStringKey();

	var UnicodeUtils = requireUnicodeUtils();

	var strlen = UnicodeUtils.strlen;
	/**
	 * Convert to UTF-8 character counts for storage.
	 */

	function encodeEntityRanges(block, storageMap) {
	  var encoded = [];
	  block.findEntityRanges(function (character) {
	    return !!character.getEntity();
	  }, function (
	  /*number*/
	  start,
	  /*number*/
	  end) {
	    var text = block.getText();
	    var key = block.getEntityAt(start);
	    encoded.push({
	      offset: strlen(text.slice(0, start)),
	      length: strlen(text.slice(start, end)),
	      // Encode the key as a number for range storage.
	      key: Number(storageMap[DraftStringKey.stringify(key)])
	    });
	  });
	  return encoded;
	}

	encodeEntityRanges_1 = encodeEntityRanges;
	return encodeEntityRanges_1;
}

export { requireEncodeEntityRanges as __require };
//# sourceMappingURL=encodeEntityRanges.js.map
