import e from"../../@babel/runtime/helpers/esm/extends.js";import n from"../../tiny-warning/dist/tiny-warning.esm.js";var r=/\s*,\s*/g,t=/&/g,i=/\$([\w-]+)/g;function o(){function o(e,r){return function(t,i){var o=e.getRule(i)||r&&r.getRule(i);return o?(o=o).selector:("production"!==process.env.NODE_ENV&&n(!1,'[JSS] Could not find the referenced rule "'+i+'" in "'+(e.options.meta||e.toString())+'".'),i)}}function l(e,n){for(var i=n.split(r),o=e.split(r),l="",s=0;s<i.length;s++)for(var u=i[s],a=0;a<o.length;a++){var d=o[a];l&&(l+=", "),l+=-1!==d.indexOf("&")?d.replace(t,u):u+" "+d}return l}function s(n,r,t){if(t)return e({},t,{index:t.index+1});var i=n.options.nestingLevel;i=void 0===i?1:i+1;var o=e({},n.options,{nestingLevel:i,index:r.indexOf(n)+1});return delete o.name,o}return{onProcessStyle:function(n,r,t){if("style"!==r.type)return n;var u,a,d=r,f=d.options.parent;for(var c in n){var p=-1!==c.indexOf("&"),v="@"===c[0];if(p||v){if(u=s(d,f,u),p){var g=l(c,d.selector);a||(a=o(f,t)),g=g.replace(i,a),f.addRule(g,n[c],e({},u,{selector:g}))}else v&&f.addRule(c,{},u).addRule(d.key,n[c],{selector:d.selector});delete n[c]}}return n}}}export default o;
//# sourceMappingURL=jss-plugin-nested.esm.js.map
