"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.moveTargetIntoList = void 0;
Object.defineProperty(exports, "wrapTaskListIntoListAbove", {
  enumerable: true,
  get: function get() {
    return _wrapTaskListIntoListAbove.wrapTaskListIntoListAbove;
  }
});
var _transform = require("@atlaskit/editor-prosemirror/transform");
var _wrapTaskListIntoListAbove = require("./wrapTaskListIntoListAbove");
var moveTargetIntoList = exports.moveTargetIntoList = function moveTargetIntoList(_ref) {
  var _$target$nodeAfter;
  var insertPosition = _ref.insertPosition,
    $target = _ref.$target;
  // take the text content of the paragraph and insert after the paragraph up until before the the cut
  var from = insertPosition;
  var to = $target.pos + (((_$target$nodeAfter = $target.nodeAfter) === null || _$target$nodeAfter === void 0 ? void 0 : _$target$nodeAfter.nodeSize) || 0); //$cut.pos + $cut.nodeAfter.nodeSize;
  var gapFrom = $target.posAtIndex(0, $target.depth + 1); // start pos of the child
  var gapTo = $target.doc.resolve(gapFrom).end(); // end pos of the paragraph

  if (gapTo - gapFrom === 0) {
    return new _transform.ReplaceStep(from, to, $target.doc.slice(insertPosition, $target.pos));
  }
  var step = new _transform.ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
  return step;
};
// eslint-disable-next-line @atlaskit/editor/no-re-export