import { NonTerminal as u, Terminal as a } from "../../../../../../../@chevrotain_gast@11.0.3/node_modules/@chevrotain/gast/lib/src/model.js";
import { isSequenceProd as c, isBranchingProd as m, isOptionalProd as h } from "../../../../../../../@chevrotain_gast@11.0.3/node_modules/@chevrotain/gast/lib/src/helpers.js";
import l from "../../../../../../../lodash-es@4.17.21/node_modules/lodash-es/uniq.js";
import P from "../../../../../../../lodash-es@4.17.21/node_modules/lodash-es/map.js";
import g from "../../../../../../../lodash-es@4.17.21/node_modules/lodash-es/flatten.js";
function o(e) {
  if (e instanceof u)
    return o(e.referencedRule);
  if (e instanceof a)
    return q(e);
  if (c(e))
    return S(e);
  if (m(e))
    return d(e);
  throw Error("non exhaustive match");
}
function S(e) {
  let n = [];
  const r = e.definition;
  let t = 0, s = r.length > t, i, f = !0;
  for (; s && f; )
    i = r[t], f = h(i), n = n.concat(o(i)), t = t + 1, s = r.length > t;
  return l(n);
}
function d(e) {
  const n = P(e.definition, (r) => o(r));
  return l(g(n));
}
function q(e) {
  return [e.terminalType];
}
export {
  o as first,
  d as firstForBranching,
  S as firstForSequence,
  q as firstForTerminal
};
