import { factorySpace as h } from "../../../../micromark-factory-space@2.0.1/node_modules/micromark-factory-space/index.es.js";
import { markdownLineEnding as a } from "../../../../micromark-util-character@2.1.1/node_modules/micromark-util-character/index.es.js";
const A = {
  tokenize: v,
  concrete: !0,
  name: "mathFlow"
}, q = {
  tokenize: N,
  partial: !0
};
function v(t, l, o) {
  const i = this, u = i.events[i.events.length - 1], m = u && u[1].type === "linePrefix" ? u[2].sliceSerialize(u[1], !0).length : 0;
  let r = 0;
  return k;
  function k(n) {
    return t.enter("mathFlow"), t.enter("mathFlowFence"), t.enter("mathFlowFenceSequence"), p(n);
  }
  function p(n) {
    return n === 36 ? (t.consume(n), r++, p) : r < 2 ? o(n) : (t.exit("mathFlowFenceSequence"), h(t, y, "whitespace")(n));
  }
  function y(n) {
    return n === null || a(n) ? x(n) : (t.enter("mathFlowFenceMeta"), t.enter("chunkString", {
      contentType: "string"
    }), z(n));
  }
  function z(n) {
    return n === null || a(n) ? (t.exit("chunkString"), t.exit("mathFlowFenceMeta"), x(n)) : n === 36 ? o(n) : (t.consume(n), z);
  }
  function x(n) {
    return t.exit("mathFlowFence"), i.interrupt ? l(n) : t.attempt(q, S, F)(n);
  }
  function S(n) {
    return t.attempt({
      tokenize: L,
      partial: !0
    }, F, b)(n);
  }
  function b(n) {
    return (m ? h(t, w, "linePrefix", m + 1) : w)(n);
  }
  function w(n) {
    return n === null ? F(n) : a(n) ? t.attempt(q, S, F)(n) : (t.enter("mathFlowValue"), c(n));
  }
  function c(n) {
    return n === null || a(n) ? (t.exit("mathFlowValue"), w(n)) : (t.consume(n), c);
  }
  function F(n) {
    return t.exit("mathFlow"), l(n);
  }
  function L(n, E, s) {
    let C = 0;
    return h(n, M, "linePrefix", i.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
    function M(e) {
      return n.enter("mathFlowFence"), n.enter("mathFlowFenceSequence"), g(e);
    }
    function g(e) {
      return e === 36 ? (C++, n.consume(e), g) : C < r ? s(e) : (n.exit("mathFlowFenceSequence"), h(n, P, "whitespace")(e));
    }
    function P(e) {
      return e === null || a(e) ? (n.exit("mathFlowFence"), E(e)) : s(e);
    }
  }
}
function N(t, l, o) {
  const i = this;
  return u;
  function u(r) {
    return r === null ? l(r) : (t.enter("lineEnding"), t.consume(r), t.exit("lineEnding"), m);
  }
  function m(r) {
    return i.parser.lazy[i.now().line] ? o(r) : l(r);
  }
}
export {
  A as mathFlow
};
//# sourceMappingURL=math-flow.es.js.map
