import p from "../../../../../../lodash-es@4.17.22/node_modules/lodash-es/zipObject.js";
import u from "../../../../../../lodash-es@4.17.22/node_modules/lodash-es/map.js";
import v from "../../../../../../lodash-es@4.17.22/node_modules/lodash-es/flatten.js";
import w from "../../../../../../lodash-es@4.17.22/node_modules/lodash-es/sortBy.js";
import g from "../../../../../../lodash-es@4.17.22/node_modules/lodash-es/forEach.js";
function S(f, n) {
  for (var o = 0, e = 1; e < n.length; ++e)
    o += d(f, n[e - 1], n[e]);
  return o;
}
function d(f, n, o) {
  for (var e = p(
    o,
    u(o, function(t, r) {
      return r;
    })
  ), m = v(
    u(n, function(t) {
      return w(
        u(f.outEdges(t), function(r) {
          return { pos: e[r.w], weight: f.edge(r).weight };
        }),
        "pos"
      );
    })
  ), i = 1; i < o.length; ) i <<= 1;
  var s = 2 * i - 1;
  i -= 1;
  var c = u(new Array(s), function() {
    return 0;
  }), a = 0;
  return g(
    // @ts-expect-error
    m.forEach(function(t) {
      var r = t.pos + i;
      c[r] += t.weight;
      for (var h = 0; r > 0; )
        r % 2 && (h += c[r + 1]), r = r - 1 >> 1, c[r] += t.weight;
      a += t.weight * h;
    })
  ), a;
}
export {
  S as crossCount
};
