var l = Object.defineProperty;
var x = (c, n, s) => n in c ? l(c, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : c[n] = s;
var h = (c, n, s) => x(c, typeof n != "symbol" ? n + "" : n, s);
class p {
  constructor(n, s = {}) {
    h(this, "regexps");
    this.patterns = n, this.options = s;
    const {
      forgiving: g = !1,
      cache: o,
      regexConstructor: u
    } = s;
    if (!u)
      throw new Error("Option `regexConstructor` is not provided");
    this.regexps = n.map((i) => {
      if (typeof i != "string")
        return i;
      const e = o == null ? void 0 : o.get(i);
      if (e) {
        if (e instanceof RegExp)
          return e;
        if (g)
          return null;
        throw e;
      }
      try {
        const t = u(i);
        return o == null || o.set(i, t), t;
      } catch (t) {
        if (o == null || o.set(i, t), g)
          return null;
        throw t;
      }
    });
  }
  findNextMatchSync(n, s, g) {
    const o = typeof n == "string" ? n : n.content, u = [];
    function i(e, t, r = 0) {
      return {
        index: e,
        captureIndices: t.indices.map((f) => f == null ? {
          start: 4294967295,
          end: 4294967295,
          length: 0
        } : {
          start: f[0] + r,
          end: f[1] + r,
          length: f[1] - f[0]
        })
      };
    }
    for (let e = 0; e < this.regexps.length; e++) {
      const t = this.regexps[e];
      if (t)
        try {
          t.lastIndex = s;
          const r = t.exec(o);
          if (!r)
            continue;
          if (r.index === s)
            return i(e, r, 0);
          u.push([e, r, 0]);
        } catch (r) {
          if (this.options.forgiving)
            continue;
          throw r;
        }
    }
    if (u.length) {
      const e = Math.min(...u.map((t) => t[1].index));
      for (const [t, r, f] of u)
        if (r.index === e)
          return i(t, r, f);
    }
    return null;
  }
}
export {
  p as J
};
