const y="ͼ",m=typeof Symbol>"u"?"__"+y:Symbol.for(y),S=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),g=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class C{constructor(e,n){this.rules=[];let{finish:i}=n||{};function s(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function l(t,h,a,T){let f=[],r=/^@(\w+)\b/.exec(t[0]),c=r&&r[1]=="keyframes";if(r&&h==null)return a.push(t[0]+";");for(let u in h){let o=h[u];if(/&/.test(u))l(u.split(/,\s*/).map(d=>t.map(p=>d.replace(/&/,p))).reduce((d,p)=>d.concat(p)),o,a);else if(o&&typeof o=="object"){if(!r)throw new RangeError("The value of a property ("+u+") should be a primitive value.");l(s(u),o,f,c)}else o!=null&&f.push(u.replace(/_.*/,"").replace(/[A-Z]/g,d=>"-"+d.toLowerCase())+": "+o+";")}(f.length||c)&&a.push((i&&!r&&!T?t.map(i):t).join(", ")+" {"+f.join(" ")+"}")}for(let t in e)l(s(t),e[t],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=g[m]||1;return g[m]=e+1,y+e.toString(36)}static mount(e,n,i){let s=e[S],l=i&&i.nonce;s?l&&s.setNonce(l):s=new A(e,l),s.mount(Array.isArray(n)?n:[n])}}let w=new Map;class A{constructor(e,n){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let l=w.get(i);if(l)return e.adoptedStyleSheets=[l.sheet,...e.adoptedStyleSheets],e[S]=l;this.sheet=new s.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],w.set(i,this)}else{this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);let l=e.head||e;l.insertBefore(this.styleTag,l.firstChild)}this.modules=[],e[S]=this}mount(e){let n=this.sheet,i=0,s=0;for(let l=0;l<e.length;l++){let t=e[l],h=this.modules.indexOf(t);if(h<s&&h>-1&&(this.modules.splice(h,1),s--,h=-1),h==-1){if(this.modules.splice(s++,0,t),n)for(let a=0;a<t.rules.length;a++)n.insertRule(t.rules[a],i++)}else{for(;s<h;)i+=this.modules[s++].rules.length;i+=t.rules.length,s++}}if(!n){let l="";for(let t=0;t<this.modules.length;t++)l+=this.modules[t].getRules()+`
`;this.styleTag.textContent=l}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}export{C as S};
