import n from "./declaration.js";
import i from "./previous-map.js";
import m from "./comment.js";
import f from "./at-rule.js";
import a from "./input.js";
import s from "./root.js";
import d from "./rule.js";
let y = n, c = i, w = m, _ = f, R = a, v = s, A = d;
function p(o, l) {
  if (Array.isArray(o))
    return o.map((t) => p(t));
  let { inputs: u, ...e } = o;
  if (u) {
    l = [];
    for (let t of u) {
      let r = { ...t, __proto__: R.prototype };
      r.map && (r.map = {
        ...r.map,
        __proto__: c.prototype
      }), l.push(r);
    }
  }
  if (e.nodes && (e.nodes = o.nodes.map((t) => p(t, l))), e.source) {
    let { inputId: t, ...r } = e.source;
    e.source = r, t != null && (e.source.input = l[t]);
  }
  if (e.type === "root")
    return new v(e);
  if (e.type === "decl")
    return new y(e);
  if (e.type === "rule")
    return new A(e);
  if (e.type === "comment")
    return new w(e);
  if (e.type === "atrule")
    return new _(e);
  throw new Error("Unknown node type: " + o.type);
}
var k = p;
p.default = p;
export {
  k as default
};
//# sourceMappingURL=fromJSON.js.map
