var e=require("css-tree/parser"),t=require("css-tree/walker"),r=require("@bramus/specificity/core");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(e),a=/*#__PURE__*/n(t);function o(e,t){return t>=65&&t<=90&&(t|=32),e===t}function s(e,t){var r=e.length;if(r!==t.length)return!1;for(var n=0;n=n;i--)if(!1===o(e.charCodeAt(i-n),t.charCodeAt(i)))return!1;return!0}function l(e,t){var r=e.length;if(t.lengthe.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function w(e){return 45===e.charCodeAt(0)&&45!==e.charCodeAt(1)&&-1!==e.indexOf("-",2)}var p=/*#__PURE__*/function(){function e(e){this.set=e}return e.prototype.has=function(e){for(var t=this.set.length,r=0;r1||0===r)return!1;var n=t.first;return"Identifier"===n.type&&I.has(n.name)}var j=new p(["caption","icon","menu","message-box","small-caption","status-bar"]),_=new p(["xx-small","x-small","small","medium","large","x-large","xx-large","xxx-large","smaller","larger"]);function A(e){var t=e.children.first;return null!==t&&"Identifier"===t.type&&j.has(t.name)}var D=new p(["linear","ease","ease-in","ease-out","ease-in-out","step-start","step-end"]),M=new p(["cubic-bezier","steps"]);function P(e){var t=e.children;if(!t)return!1;for(var r,n=v(t);!(r=n()).done;){var i=r.value,a=i.type,o=i.name;if("Identifier"===a&&w(o))return!0;if(a===f&&(w(o)||P(i)))return!0}return!1}var U=/*#__PURE__*/function(){function e(e){void 0===e&&(e=!1),this.t=new Map,this.i=0,e&&(this.o=[]),this.u=e}var t=e.prototype;return t.p=function(e,t){var r=this.i;if(this.u){var n=t.start,i=n.offset,a=4*r;this.o[a]=n.line,this.o[a+1]=n.column,this.o[a+2]=i,this.o[a+3]=t.end.offset-i}if(this.t.has(e))return this.t.get(e).push(r),void this.i++;this.t.set(e,[r]),this.i++},t.size=function(){return this.i},t.c=function(){var e=new Map,t={},r=this.u,n=this.t,i=this.o,a=n.size;n.forEach(function(n,a){if(r){var o=n.map(function(e){var t=4*e;return{line:i[t],column:i[t+1],offset:i[t+2],length:i[t+3]}});e.set(a,o)}else t[a]=n.length});var o=this.i,s={total:o,totalUnique:a,unique:t,uniquenessRatio:0===o?0:a/o};return r&&(s.__unstable__uniqueWithLocations=Object.fromEntries(e)),s},e}(),R=/*#__PURE__*/function(){function e(e){this.l=new U(e),this.h=new Map,this.u=e}var t=e.prototype;return t.push=function(e,t,r){this.l.p(e,r),this.h.has(t)||this.h.set(t,new U(this.u)),this.h.get(t).p(e,r)},t.count=function(){for(var e,t=new Map,r=v(this.h.entries());!(e=r()).done;){var n=e.value;t.set(n[0],n[1].c())}return Object.assign(this.l.c(),{itemsPerContext:Object.fromEntries(t)})},e}(),T=/*#__PURE__*/function(){function e(){this.t=[],this.m=0}var t=e.prototype;return t.push=function(e){this.t.push(e),this.m+=e},t.size=function(){return this.t.length},t.aggregate=function(){var e=this.t.length;if(0===e)return{min:0,max:0,mean:0,mode:0,median:0,range:0,sum:0};var t,r,n,i=this.t.slice().sort(function(e,t){return e-t}),a=i[0],o=i[e-1],s=function(e){for(var t=new Map,r=-1,n=0,i=0,a=e.length,o=0;or&&(r=u,n=0,i=0),u>=r&&(n++,i+=s)}return i/n}(i),u=(r=(t=i).length/2)!==(n=Math.floor(r))?t[n]:(t[n]+t[n-1])/2,l=this.m;return{min:a,max:o,mean:l/e,mode:s,median:u,range:o-a,sum:l}},t.toArray=function(){return this.t},e}();function F(e){if(E(e)||w(e))return!1;var t=e.charCodeAt(0);return 47===t||42===t||95===t||43===t||38===t||36===t||35===t}function E(e){return!(e.length<3)&&45===e.charCodeAt(0)&&45===e.charCodeAt(1)}function L(e,t){return!E(t)&&u(e,t)}function H(e){var t=e.children;if(t){var r=t.last;return r&&"Identifier"===r.type&&u("\\9",r.name)}return!1}var N=new p(["border-radius","border-top-left-radius","border-top-right-radius","border-bottom-right-radius","border-bottom-left-radius","border-start-start-radius","border-start-end-radius","border-end-end-radius","border-end-start-radius"]);function K(e,t){return 0===t?0:e/t}var Q={useUnstableLocations:!1};function V(e,t){return e[0]===t[0]?e[1]===t[1]?t[2]-e[2]:t[1]-e[1]:t[0]-e[0]}exports.analyze=function(e,t){void 0===t&&(t={});var n=!0===Object.assign({},Q,t).useUnstableLocations,o=Date.now();function c(e){return m(e).trim()}function m(t){var r=t.loc;return e.substring(r.start.offset,r.end.offset)}var p,b,g=0,j=0,W=new U(!1),$=0,B={total:0,unique:new Map},G=Date.now(),J=i.default(e,{parseCustomProperty:!0,positions:!0,onComment:function(e){g++,j+=e.length}}),X=Date.now(),Y=J.loc.end.line-J.loc.start.line+1,Z=0,ee=new T,te=[],re=new U(n),ne=new U(n),ie=new U(n),ae=new U(n),oe=new U(n),se=new U(n),ue=new U(n),le=new U(n),fe=new U(n),ce=new U(n),de=new U(n),he=new U(n),me=0,ve=0,we=new T,pe=new T,be=new T,ge=new U(n),ye=new U(n),ke=new U(n),xe=new U(n),qe=new Set,Se=new U(n),ze=new T,Oe=new T,Ie=new T,Ce=new U(n),je=new T,_e=new U(n),Ae=[],De=new U(n),Me=new U(n),Pe=new U(n),Ue=new Set,Re=0,Te=new T,Fe=0,Ee=0,Le=new U(n),He=new U(n),Ne=new U(n),Ke=new U(n),Qe=new U(n),Ve=new T,We=new T,$e=new U(n),Be=new U(n),Ge=new U(n),Je=new U(n),Xe=new U(n),Ye=new U(n),Ze=new U(n),et=new U(n),tt=new U(n),rt=new U(n),nt=new R(n),it=new U(n),at=new R(n),ot=new U(n),st=new U(n),ut=new R(n);a.default(J,function(e){switch(e.type){case"Atrule":Z++;var t=e.name;if("font-face"===t){var i={};n&&re.p(e.loc.start.offset,e.loc),e.block.children.forEach(function(e){"Declaration"===e.type&&(i[e.property]=c(e.value))}),te.push(i),ee.push(1);break}var o=1;if(null!==e.prelude){var g=e.prelude,j=g&&c(e.prelude),U=g.loc;if("media"===t)ae.p(j,U),h(g)&&(oe.p(j,U),o++);else if("supports"===t)ue.p(j,U),d(g)&&(le.p(j,U),o++);else if(u("keyframes",t)){var R="@"+t+" "+j;w(t)&&(ce.p(R,U),o++),fe.p(R,U)}else"import"===t?ie.p(j,U):"charset"===t?se.p(j,U):"container"===t?de.p(j,U):"layer"===t?j.split(",").forEach(function(e){return ne.p(e.trim(),U)}):"property"===t&&he.p(j,U)}else"layer"===t&&(ne.p("",e.loc),o++);ee.push(o);break;case"Rule":var T=e.prelude,K=e.block,Q=T.children,G=K.children,J=Q?Q.size:0,X=G?G.size:0;we.push(J+X),ge.p(J+X,e.loc),pe.push(J),ye.p(J,T.loc),be.push(X),ke.p(X,K.loc),me++,0===X&&ve++;break;case"Selector":var Y=c(e);if(this.atrule&&u("keyframes",this.atrule.name))return xe.p(Y,e.loc),this.skip;y(e)&&Me.p(Y,e.loc);var lt=x(e);k(e)&&Se.p(Y,e.loc),qe.add(Y),je.push(lt),_e.p(lt,e.loc);var ft=r.calculate(e)[0].value,ct=ft.a,dt=ft.b,ht=ft.c,mt=[ct,dt,ht];return Ce.p(ct+","+dt+","+ht,e.loc),ze.push(ct),Oe.push(dt),Ie.push(ht),void 0===p&&(p=mt),void 0===b&&(b=mt),void 0!==b&&V(b,mt)<0&&(b=mt),void 0!==p&&V(p,mt)>0&&(p=mt),Ae.push(mt),ct>0&&De.p(Y,e.loc),function(e,t){a.default(e,function(e,r){if("Combinator"===e.type){var n=e.loc,i=e.name;if(null===n){var a=r.prev.data.loc.end,o={offset:a.offset,line:a.line,column:a.column};t({name:i,loc:{start:o,end:{offset:o.offset+1,line:o.line,column:o.column+1}}})}else t({name:i,loc:n})}})}(e,function(e){Pe.p(e.name,e.loc)}),this.skip;case"Dimension":if(!this.declaration)break;var vt=e.unit;return u("\\9",vt)?at.push(vt.substring(0,vt.length-2),this.declaration.property,e.loc):at.push(vt,this.declaration.property,e.loc),this.skip;case"Url":if(l("data:",e.value)){var wt=e.value,pt=wt.length,bt=function(e){var t=e.indexOf(";"),r=e.indexOf(",");return e.substring(5,-1===t||-1!==r&&r1?Ot.forEach(function(e){"Operator"!==e.type&&rt.p(c(e),It)}):rt.p(c(e),It);break}if(L("transition-timing-function",qt)||L("animation-timing-function",qt)){Ot&&Ot.size>1?Ot.forEach(function(e){"Operator"!==e.type&&tt.p(c(e),It)}):tt.p(c(e),It);break}if(N.has(function(e){return w(e)?e.slice(e.indexOf("-",2)+1):e}(qt))){C(e)||ut.push(c(e),qt,It);break}L("text-shadow",qt)?C(e)||Je.p(c(e),It):L("box-shadow",qt)&&(C(e)||Xe.p(c(e),It))}a.default(e,function(e){var t=e.name;switch(e.type){case"Hash":var r=e.value.length;return u("\\9",e.value)&&(r-=2),nt.push("#"+e.value,qt,It),it.p("hex"+r,It),this.skip;case"Identifier":I.has(t)&&st.p(t,It);var n=t.length;if(n>20||n<3)return this.skip;if(O.has(t)){var i=c(e);return nt.push(i,qt,It),void it.p(t.toLowerCase(),It)}if(q.has(t)){var a=c(e);return nt.push(a,qt,It),void it.p("named",It)}if(S.has(t)){var o=c(e);return nt.push(o,qt,It),void it.p("system",It)}return this.skip;case f:if(s("var",t))return this.skip;if(z.has(t))return nt.push(c(e),qt,e.loc),void it.p(t.toLowerCase(),e.loc);if(u("gradient",t))return void ot.p(c(e),e.loc)}});break;case"Declaration":if(null!==this.atrulePrelude)return this.skip;Re++;var Dt=1;Ue.add(c(e)),!0===e.important&&(Fe++,Dt++,this.atrule&&u("keyframes",this.atrule.name)&&(Ee++,Dt++)),Te.push(Dt);var Mt=e.property,Pt=e.loc.start,Ut={start:{line:Pt.line,column:Pt.column,offset:Pt.offset},end:{offset:Pt.offset+Mt.length}};He.p(Mt,Ut),w(Mt)?(Ke.p(Mt,Ut),Ve.push(2)):F(Mt)?(Ne.p(Mt,Ut),Ve.push(2)):E(Mt)?(Qe.p(Mt,Ut),Ve.push(e.important?3:2),!0===e.important&&Le.p(Mt,Ut)):Ve.push(1)}});var lt=W.c();delete lt.__unstable__uniqueWithLocations;var ft=Ue.size,ct=je.size(),dt=ze.aggregate(),ht=Oe.aggregate(),mt=Ie.aggregate(),vt=qe.size,wt=Object.assign,pt=e.length,bt=te.length,gt=ee.aggregate(),yt=je.aggregate(),kt=Te.aggregate(),xt=Ve.aggregate(),qt=We.aggregate();return{stylesheet:{sourceLinesOfCode:Z+ct+Re+xe.size(),linesOfCode:Y,size:pt,complexity:gt.sum+yt.sum+kt.sum+xt.sum+qt.sum,comments:{total:g,size:j},embeddedContent:wt(lt,{size:{total:$,ratio:K($,pt)},types:{total:B.total,totalUnique:B.unique.size,uniquenessRatio:K(B.unique.size,B.total),unique:Object.fromEntries(B.unique)}})},atrules:{fontface:wt({total:bt,totalUnique:bt,unique:te,uniquenessRatio:0===bt?0:1},n?{__unstable__uniqueWithLocations:re.c().__unstable__uniqueWithLocations}:{}),import:ie.c(),media:wt(ae.c(),{browserhacks:oe.c()}),charset:se.c(),supports:wt(ue.c(),{browserhacks:le.c()}),keyframes:wt(fe.c(),{prefixed:wt(ce.c(),{ratio:K(ce.size(),fe.size())})}),container:de.c(),layer:ne.c(),property:he.c(),total:Z,complexity:gt},rules:{total:me,empty:{total:ve,ratio:K(ve,me)},sizes:wt(we.aggregate(),{items:we.toArray()},ge.c()),selectors:wt(pe.aggregate(),{items:pe.toArray()},ye.c()),declarations:wt(be.aggregate(),{items:be.toArray()},ke.c())},selectors:{total:ct,totalUnique:vt,uniquenessRatio:K(vt,ct),specificity:wt({min:void 0===b?[0,0,0]:b,max:void 0===p?[0,0,0]:p,sum:[dt.sum,ht.sum,mt.sum],mean:[dt.mean,ht.mean,mt.mean],mode:[dt.mode,ht.mode,mt.mode],median:[dt.median,ht.median,mt.median],items:Ae},Ce.c()),complexity:wt(yt,_e.c(),{items:je.toArray()}),id:wt(De.c(),{ratio:K(De.size(),ct)}),accessibility:wt(Me.c(),{ratio:K(Me.size(),ct)}),keyframes:xe.c(),prefixed:wt(Se.c(),{ratio:K(Se.size(),ct)}),combinators:Pe.c()},declarations:{total:Re,totalUnique:ft,uniquenessRatio:K(ft,Re),unique:{total:ft,ratio:K(ft,Re)},importants:{total:Fe,ratio:K(Fe,Re),inKeyframes:{total:Ee,ratio:K(Ee,Fe)}},complexity:kt},properties:wt(He.c(),{prefixed:wt(Ke.c(),{ratio:K(Ke.size(),He.size())}),custom:wt(Qe.c(),{ratio:K(Qe.size(),He.size()),importants:wt(Le.c(),{ratio:K(Le.size(),Qe.size())})}),browserhacks:wt(Ne.c(),{ratio:K(Ne.size(),He.size())}),complexity:xt}),values:{colors:wt(nt.count(),{formats:it.c()}),gradients:ot.c(),fontFamilies:Ye.c(),fontSizes:Ze.c(),lineHeights:et.c(),zindexes:Ge.c(),textShadows:Je.c(),boxShadows:Xe.c(),borderRadiuses:ut.count(),animations:{durations:rt.c(),timingFunctions:tt.c()},prefixes:$e.c(),browserhacks:Be.c(),units:at.count(),complexity:qt,keywords:st.c()},__meta__:{parseTime:X-G,analyzeTime:Date.now()-X,total:Date.now()-o}}},exports.compareSpecificity=V,exports.hasVendorPrefix=w,exports.isAccessibilitySelector=y,exports.isMediaBrowserhack=h,exports.isPropertyHack=F,exports.isSelectorPrefixed=k,exports.isSupportsBrowserhack=d,exports.isValueBrowserhack=function(e,t){return H(e)||"string"==typeof t},exports.isValuePrefixed=P,exports.selectorComplexity=x; //# sourceMappingURL=analyzer.cjs.map