// snippets/Loading/CSS-Complexity.js | sha256:fc55cf3c60df42e8 | https://github.com/nucliweb/webperf-snippets/blob/main/snippets/Loading/CSS-Complexity.js (async()=>{function e(e){if(null==e||Number.isNaN(e))return"-";if(0===e)return"0 B";const t=["B","KB","MB","GB"],o=Math.max(0,Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1));return(e/Math.pow(1024,o)).toFixed(1)+" "+t[o]}const t=(e,t,o=`${t}s`)=>`${e} ${1===e?t:o}`;function o(e,t){const o=[];let s=0,n=null,r=0;for(let l=0;le.trim()).filter(Boolean)}const s=e=>o(e.cssText,";"),n=/^(font\/|application\/(x-)?font-|application\/vnd\.ms-fontobject)/;function r(e,t){const o=[];for(const[,s]of e.matchAll(/url\("((?:[^"\\]|\\.)*)"\)/g)){const e=s.replace(/\\(["\\])/g,"$1");if(!/^data:/i.test(e))continue;const r=e.slice(5).split(/[;,]/)[0].toLowerCase()||"text/plain";o.push({type:r,bytes:e.length,font:t||n.test(r)})}return o}const l=new Set(["is","where","not","has","matches","-webkit-any","-moz-any"]),a=e=>e.reduce((e,t)=>e+t,0),c=e=>o(e,",").flatMap(e=>{const{complexity:t,nested:o}=u(e);return[t,...o]}),i=e=>u(e).complexity;function u(e){const t=e.trim();let s=0;const n=[];let r=0,u=!1;const d=()=>{const e=r;for(;r127))break;r++}return t.slice(e,r)},f=(e,o)=>{const s=r+1;let n=0,l=null;for(;r+~".includes(t[r])&&s>0&&!u&&(s++,u=!0)}else if(">+~".includes(e))s++,r++,u=!0;else if(u=!1,"*"===e||"&"===e)s++,r++;else if("#"===e||"."===e)r++,d(),s++;else if("["===e){const e=f("[","]");s+=/=/.test(e)?2:1}else if(":"===e){r+=":"===t[r+1]?2:1;const e=d().toLowerCase();if(s+=e.startsWith("-")?2:1,"("===t[r]){const t=f("(",")").trim(),r="nth-child"===e||"nth-last-child"===e?t.match(/\sof\s([\s\S]+)$/i):null;if(l.has(e)||r){const e=c(r?r[1]:t);s+=a(e),n.push(...e)}else if("nth-child"===e||"nth-last-child"===e||"nth-of-type"===e||"nth-last-of-type"===e||"lang"===e)s+=t?1:0;else{const e=c(t),r=o(t,",").map(i);s+=1+a(r),n.push(...e)}}}else/[\w-\\]/.test(e)||t.charCodeAt(r)>127?(d(),s++):r++}return{complexity:s,nested:n}}const d=e=>e.localName+(e.id?`#${e.id}`:e.classList[0]?`.${e.classList[0]}`:""),f=[],h=new Set,m=/^(chrome|moz|safari-web)-extension:/i;let p=0;const y=(e,t)=>{e&&!h.has(e)&&(h.add(e),e.href&&m.test(e.href)?p++:f.push({sheet:e,source:t}))},C=e=>{if(!h.has(e)){if(m.test(e))return h.add(e),void p++;h.add(e),f.push({href:e,source:e})}};async function g(e){try{const t=await fetch(function(e){try{const t=new URL(e,location.href);return/^https?:$/.test(t.protocol)?(t.hash="webperf-snippets",t.href):e}catch{return e}}(e));if(!t.ok)return null;const o=(await t.text()).replace(/\/\*[\s\S]*?\*\//g,""),s=o.match(/@import\s[^;]*;/gi)??[],n=s.map(e=>e.match(/@import\s+(?:url\(\s*)?(["']?)([^"')\s;]+)\1/i)?.[2]).filter(Boolean).map(t=>new URL(t,e).href),r=new window.CSSStyleSheet({baseURL:e});return r.replaceSync(s.reduce((e,t)=>e.replace(t,""),o)),{rules:r.cssRules,imports:n}}catch{return null}}let w=0,S=0;for(const e of document.styleSheets)y(e,e.href||"