import { p as g } from "../../../../../_virtual/index31.js";
import "../../../postcss-selector-parser@6.0.10/node_modules/postcss-selector-parser/dist/index.js";
import { d as C } from "../../../../../_virtual/index30.js";
let k = C.exports;
function v(n, r) {
  let s, a = k((f) => {
    s = f;
  });
  try {
    a.processSync(n);
  } catch (f) {
    throw n.includes(":") ? r ? r.error("Missed semicolon") : f : r ? r.error(f.message) : f;
  }
  return s.at(0);
}
function x(n, r) {
  let s = !1;
  return n.each((a) => {
    if (a.type === "nesting") {
      let f = r.clone();
      a.value !== "&" ? a.replaceWith(v(a.value.replace("&", f.toString()))) : a.replaceWith(f), s = !0;
    } else
      a.nodes && x(a, r) && (s = !0);
  }), s;
}
function b(n, r) {
  let s = [];
  return n.selectors.forEach((a) => {
    let f = v(a, n);
    r.selectors.forEach((o) => {
      if (o.length) {
        let t = v(o, r);
        x(t, f) || (t.prepend(k.combinator({ value: " " })), t.prepend(f.clone())), s.push(t.toString());
      }
    });
  }), s;
}
function c(n, r) {
  return n && n.type === "comment" ? (r.after(n), n) : r;
}
function E(n) {
  return function r(s, a, f) {
    let o = [];
    if (a.each((t) => {
      t.type === "comment" || t.type === "decl" ? o.push(t) : t.type === "rule" && f ? t.selectors = b(s, t) : t.type === "atrule" && (t.nodes && n[t.name] ? r(s, t, !0) : o.push(t));
    }), f && o.length) {
      let t = s.clone({ nodes: [] });
      for (let u of o)
        t.append(u);
      a.prepend(t);
    }
  };
}
function y(n, r, s, a) {
  let f = new a({
    selector: n,
    nodes: []
  });
  for (let o of r)
    f.append(o);
  return s.after(f), f;
}
function w(n, r) {
  let s = {};
  for (let a of n)
    s[a] = !0;
  if (r)
    for (let a of r) {
      let f = a.replace(/^@/, "");
      s[f] = !0;
    }
  return s;
}
g.exports = (n = {}) => {
  let r = w(["media", "supports"], n.bubble), s = E(r), a = w(
    [
      "document",
      "font-face",
      "keyframes",
      "-webkit-keyframes",
      "-moz-keyframes"
    ],
    n.unwrap
  ), f = n.preserveEmpty;
  return {
    postcssPlugin: "postcss-nested",
    Rule(o, { Rule: t }) {
      let u = !1, p = o, m = !1, l = [];
      o.each((e) => {
        if (e.type === "rule")
          l.length && (p = y(o.selector, l, p, t), l = []), m = !0, u = !0, e.selectors = b(o, e), p = c(e.prev(), p), p.after(e), p = e;
        else if (e.type === "atrule")
          if (l.length && (p = y(o.selector, l, p, t), l = []), e.name === "at-root") {
            u = !0, s(o, e, !1);
            let i = e.nodes;
            e.params && (i = new t({ selector: e.params, nodes: i })), p.after(i), p = i, e.remove();
          } else
            r[e.name] ? (m = !0, u = !0, s(o, e, !0), p = c(e.prev(), p), p.after(e), p = e) : a[e.name] ? (m = !0, u = !0, s(o, e, !1), p = c(e.prev(), p), p.after(e), p = e) : m && l.push(e);
        else
          e.type === "decl" && m && l.push(e);
      }), l.length && (p = y(o.selector, l, p, t)), u && f !== !0 && (o.raws.semicolon = !0, o.nodes.length === 0 && o.remove());
    }
  };
};
g.exports.postcss = !0;
const P = g.exports;
export {
  P as default
};
//# sourceMappingURL=index.js.map
