import { __require as requireDraftEditorDecoratedLeaves_react } from './DraftEditorDecoratedLeaves.react.js';
import { __require as requireDraftEditorLeaf_react } from './DraftEditorLeaf.react.js';
import { __require as requireDraftOffsetKey } from './DraftOffsetKey.js';
import { __require as requireImmutable } from '../../../../immutable@3.7.6/node_modules/immutable/dist/immutable.js';
import React__default from 'react';
import { __require as requireCx } from '../../../../fbjs@2.0.0/node_modules/fbjs/lib/cx.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
 *
 * This is unstable and not part of the public API and should not be used by
 * production systems. This file may be update/removed without notice.
 */

var DraftEditorNode_react;
var hasRequiredDraftEditorNode_react;

function requireDraftEditorNode_react () {
	if (hasRequiredDraftEditorNode_react) return DraftEditorNode_react;
	hasRequiredDraftEditorNode_react = 1;

	function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }

	var DraftEditorDecoratedLeaves = requireDraftEditorDecoratedLeaves_react();

	var DraftEditorLeaf = requireDraftEditorLeaf_react();

	var DraftOffsetKey = requireDraftOffsetKey();

	var Immutable = requireImmutable();

	var React = React__default;

	var cx = requireCx();

	Immutable.List;

	var DraftEditorNode = /*#__PURE__*/function (_React$Component) {
	  _inheritsLoose(DraftEditorNode, _React$Component);

	  function DraftEditorNode() {
	    return _React$Component.apply(this, arguments) || this;
	  }

	  var _proto = DraftEditorNode.prototype;

	  _proto.render = function render() {
	    var _this$props = this.props,
	        block = _this$props.block,
	        contentState = _this$props.contentState,
	        customStyleFn = _this$props.customStyleFn,
	        customStyleMap = _this$props.customStyleMap,
	        decorator = _this$props.decorator,
	        direction = _this$props.direction,
	        forceSelection = _this$props.forceSelection,
	        hasSelection = _this$props.hasSelection,
	        selection = _this$props.selection,
	        tree = _this$props.tree;
	    var blockKey = block.getKey();
	    var text = block.getText();
	    var lastLeafSet = tree.size - 1;
	    var children = this.props.children || tree.map(function (leafSet, ii) {
	      var decoratorKey = leafSet.get('decoratorKey');
	      var leavesForLeafSet = leafSet.get('leaves');
	      var lastLeaf = leavesForLeafSet.size - 1;
	      var Leaves = leavesForLeafSet.map(function (leaf, jj) {
	        var offsetKey = DraftOffsetKey.encode(blockKey, ii, jj);
	        var start = leaf.get('start');
	        var end = leaf.get('end');
	        return React.createElement(DraftEditorLeaf, {
	          key: offsetKey,
	          offsetKey: offsetKey,
	          block: block,
	          start: start,
	          selection: hasSelection ? selection : null,
	          forceSelection: forceSelection,
	          text: text.slice(start, end),
	          styleSet: block.getInlineStyleAt(start),
	          customStyleMap: customStyleMap,
	          customStyleFn: customStyleFn,
	          isLast: decoratorKey === lastLeafSet && jj === lastLeaf
	        });
	      }).toArray();

	      if (!decoratorKey || !decorator) {
	        return Leaves;
	      }

	      return React.createElement(DraftEditorDecoratedLeaves, {
	        block: block,
	        children: Leaves,
	        contentState: contentState,
	        decorator: decorator,
	        decoratorKey: decoratorKey,
	        direction: direction,
	        leafSet: leafSet,
	        text: text,
	        key: ii
	      });
	    }).toArray();
	    return React.createElement("div", {
	      "data-offset-key": DraftOffsetKey.encode(blockKey, 0, 0),
	      className: cx({
	        'public/DraftStyleDefault/block': true,
	        'public/DraftStyleDefault/ltr': direction === 'LTR',
	        'public/DraftStyleDefault/rtl': direction === 'RTL'
	      })
	    }, children);
	  };

	  return DraftEditorNode;
	}(React.Component);

	DraftEditorNode_react = DraftEditorNode;
	return DraftEditorNode_react;
}

export { requireDraftEditorNode_react as __require };
//# sourceMappingURL=DraftEditorNode.react.js.map
