import { p as h } from "../../../../../../_virtual/processor.js";
import "./parser.js";
import { p as S } from "../../../../../../_virtual/parser2.js";
(function(l, f) {
  f.__esModule = !0, f.default = void 0;
  var d = p(S.exports);
  function p(s) {
    return s && s.__esModule ? s : { default: s };
  }
  var y = /* @__PURE__ */ function() {
    function s(e, t) {
      this.func = e || function() {
      }, this.funcRes = null, this.options = t;
    }
    var o = s.prototype;
    return o._shouldUpdateSelector = function(t, r) {
      r === void 0 && (r = {});
      var n = Object.assign({}, this.options, r);
      return n.updateSelector === !1 ? !1 : typeof t != "string";
    }, o._isLossy = function(t) {
      t === void 0 && (t = {});
      var r = Object.assign({}, this.options, t);
      return r.lossless === !1;
    }, o._root = function(t, r) {
      r === void 0 && (r = {});
      var n = new d.default(t, this._parseOptions(r));
      return n.root;
    }, o._parseOptions = function(t) {
      return {
        lossy: this._isLossy(t)
      };
    }, o._run = function(t, r) {
      var n = this;
      return r === void 0 && (r = {}), new Promise(function(u, i) {
        try {
          var c = n._root(t, r);
          Promise.resolve(n.func(c)).then(function(a) {
            var _ = void 0;
            return n._shouldUpdateSelector(t, r) && (_ = c.toString(), t.selector = _), {
              transform: a,
              root: c,
              string: _
            };
          }).then(u, i);
        } catch (a) {
          i(a);
          return;
        }
      });
    }, o._runSync = function(t, r) {
      r === void 0 && (r = {});
      var n = this._root(t, r), u = this.func(n);
      if (u && typeof u.then == "function")
        throw new Error("Selector processor returned a promise to a synchronous call.");
      var i = void 0;
      return r.updateSelector && typeof t != "string" && (i = n.toString(), t.selector = i), {
        transform: u,
        root: n,
        string: i
      };
    }, o.ast = function(t, r) {
      return this._run(t, r).then(function(n) {
        return n.root;
      });
    }, o.astSync = function(t, r) {
      return this._runSync(t, r).root;
    }, o.transform = function(t, r) {
      return this._run(t, r).then(function(n) {
        return n.transform;
      });
    }, o.transformSync = function(t, r) {
      return this._runSync(t, r).transform;
    }, o.process = function(t, r) {
      return this._run(t, r).then(function(n) {
        return n.string || n.root.toString();
      });
    }, o.processSync = function(t, r) {
      var n = this._runSync(t, r);
      return n.string || n.root.toString();
    }, s;
  }();
  f.default = y, l.exports = f.default;
})(h, h.exports);
//# sourceMappingURL=processor.js.map
