'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var index = require('./index.js');
var schedule = require('./schedule.js');
var selector = require('../../../../../d3-selection@3.0.0/node_modules/d3-selection/src/selector.js');

function transition_select(select) {
  var name = this._name,
      id = this._id;

  if (typeof select !== "function") select = selector.default(select);

  for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
    for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
      if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
        if ("__data__" in node) subnode.__data__ = node.__data__;
        subgroup[i] = subnode;
        schedule.default(subgroup[i], name, id, i, subgroup, schedule.get(node, id));
      }
    }
  }

  return new index.Transition(subgroups, this._parents, name, id);
}

exports.default = transition_select;
