/**
   * Expand the target shape if the bounding box of the moved elements is near or on an edge,
   * considering the position of the bounding box in relation to the parent's edge plus padding.
   * The amount to expand can be defined for each edge in the OFFSET object.
   *
   * @param  {Array<Shape>} elements
   * @param  {Shape|String} target|targetId
   */
  function expand(elements, target) {

    if (typeof target === 'string') {
      target = elementRegistry.get(target);
    }

    var bbox = getBoundingBox(elements),
        canExpand = true;

    if (!is(target, 'bpmn:Participant') && !is(target, 'bpmn:Lane') && !(is(target, 'bpmn:SubProcess'))) {
      return;
    }

    forEach(elements, function(element) {

      if (is(element, 'bpmn:Lane') || element.labelTarget) {
        canExpand = false;
        return;
      }
    });

    if (!canExpand) {
      return;
    }

    var inbounds = isInbounds(bbox, target, PADDING);

    var newBounds = pick(target, [ 'x', 'y', 'width', 'height' ]);

    if (inbounds.top) {
      var topPosition = bbox.y - OFFSET.top;
      assign(newBounds, { y: topPosition, height: newBounds.height + newBounds.y - topPosition });
    }

    if (inbounds.bottom) {
      assign(newBounds, { height: bbox.y + bbox.height + OFFSET.bottom - newBounds.y });
    }

    if (inbounds.left) {
      var leftPosition = bbox.x - OFFSET.left;
      assign(newBounds, { x: leftPosition, width: newBounds.width + newBounds.x - leftPosition });
    }

    if (inbounds.right) {
      assign(newBounds, { width: bbox.x + bbox.width + OFFSET.right - newBounds.x });
    }

    if (is(target, 'bpmn:Participant')) {
      modeling.resizeLane(target, newBounds);
    } else {
      modeling.resizeShape(target, newBounds);
    }

    var parent = target.parent;

    // recursively expand parent elements
    if (parent) {
      expand([ target ], parent);
    }
  }
        it('should move to origin', inject(function(editorActions) {
          // given
          var elements = editorActions.trigger('selectElements'),
              boundingBox;

          // when
          editorActions.trigger('moveToOrigin');

          boundingBox = getBBox(elements);

          // then
          expect(pick(boundingBox, [ 'x', 'y' ])).to.eql({ x: 0, y: 0 });
        }));
    moveToOrigin: function() {
      var rootElement = canvas.getRootElement(),
          boundingBox,
          elements;

      if (is(rootElement, 'bpmn:Collaboration')) {
        elements = elementRegistry.filter(function(element) {
          return is(element.parent, 'bpmn:Collaboration');
        });
      } else {
        elements = elementRegistry.filter(function(element) {
          return element !== rootElement && !is(element.parent, 'bpmn:SubProcess');
        });
      }

      boundingBox = getBBox(elements);

      modeling.moveElements(elements, { x: -boundingBox.x, y: -boundingBox.y }, rootElement);
    }
function initParticipantSnapping(context, shape, elements) {

  if (!elements.length) {
    return;
  }

  var snapBox = getBoundingBox(elements.filter(function(e) {
    return !e.labelTarget && !e.waypoints;
  }));

  snapBox.x -= 50;
  snapBox.y -= 20;
  snapBox.width += 70;
  snapBox.height += 40;

  // adjust shape height to include bounding box
  shape.width = Math.max(shape.width, snapBox.width);
  shape.height = Math.max(shape.height, snapBox.height);

  context.participantSnapBox = snapBox;
}