'use strict';

var index = require('./index.js');
var schedule = require('./schedule.js');

function transition_transition() {
  var name = this._name,
      id0 = this._id,
      id1 = index.newId();

  for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
    for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
      if (node = group[i]) {
        var inherit = schedule.get(node, id0);
        schedule.default(node, name, id1, i, group, {
          time: inherit.time + inherit.delay + inherit.duration,
          delay: 0,
          duration: inherit.duration,
          ease: inherit.ease
        });
      }
    }
  }

  return new index.Transition(groups, this._parents, name, id1);
}

module.exports = transition_transition;
