import t from"../../@babel/runtime/helpers/esm/extends.js";import{RuleList as e}from"../../jss/dist/jss.esm.js";var s="@global",r=function(){function r(r,n,i){for(var o in this.type="global",this.at=s,this.rules=void 0,this.options=void 0,this.key=void 0,this.isProcessed=!1,this.key=r,this.options=i,this.rules=new e(t({},i,{parent:this})),n)this.rules.add(o,n[o]);this.rules.process()}var n=r.prototype;return n.getRule=function(t){return this.rules.get(t)},n.addRule=function(t,e,s){var r=this.rules.add(t,e,s);return r&&this.options.jss.plugins.onProcessRule(r),r},n.indexOf=function(t){return this.rules.indexOf(t)},n.toString=function(){return this.rules.toString()},r}(),n=function(){function e(e,r,n){this.type="global",this.at=s,this.options=void 0,this.rule=void 0,this.isProcessed=!1,this.key=void 0,this.key=e,this.options=n;var i=e.substr("@global ".length);this.rule=n.jss.createRule(i,r,t({},n,{parent:this}))}return e.prototype.toString=function(t){return this.rule?this.rule.toString(t):""},e}(),i=/\s*,\s*/g;function o(t,e){for(var s=t.split(i),r="",n=0;n<s.length;n++)r+=e+" "+s[n].trim(),s[n+1]&&(r+=", ");return r}function l(){return{onCreateRule:function(t,e,i){if(!t)return null;if(t===s)return new r(t,e,i);if("@"===t[0]&&"@global "===t.substr(0,"@global ".length))return new n(t,e,i);var o=i.parent;return o&&("global"===o.type||o.options.parent&&"global"===o.options.parent.type)&&(i.scoped=!1),!1===i.scoped&&(i.selector=t),null},onProcessRule:function(e,r){"style"===e.type&&r&&(function(e,r){var n=e.options,i=e.style,l=i?i[s]:null;if(l){for(var u in l)r.addRule(u,l[u],t({},n,{selector:o(u,e.selector)}));delete i[s]}}(e,r),function(e,r){var n=e.options,i=e.style;for(var l in i)if("@"===l[0]&&l.substr(0,s.length)===s){var u=o(l.substr(s.length),e.selector);r.addRule(u,i[l],t({},n,{selector:u})),delete i[l]}}(e,r))}}}export default l;
//# sourceMappingURL=jss-plugin-global.esm.js.map
