import{RULESET as e,DECLARATION as a,COMMENT as c}from"./Enum.js";import{strlen as s,append as r,substr as t,replace as n,from as i,sizeof as f,abs as u,trim as o}from"./Utility.js";import{dealloc as l,alloc as k,next as b,peek as m,delimit as h,identifier as w,node as d,commenter as p,char as j,escaping as v,whitespace as g,prev as x,caret as y}from"./Tokenizer.js";function z(e){return l(E("",null,null,null,[""],e=k(e),0,[0],e))}function E(e,a,c,t,f,u,o,l,k){for(var d=0,j=0,z=o,A=0,B=0,C=0,D=1,F=1,G=1,H=0,I="",J=f,K=u,L=t,M=I;F;)switch(C=H,H=b()){case 34:case 39:case 91:case 40:M+=h(H);break;case 9:case 10:case 13:case 32:M+=g(C);break;case 92:M+=v(y()-1,7);continue;case 47:switch(m()){case 42:case 47:r(U(p(b(),y()),a,c),k);break;default:M+="/"}break;case 123*D:l[d++]=s(M)*G;case 125*D:case 59:case 0:switch(H){case 0:case 125:F=0;case 59+j:B>0&&s(M)-z&&r(B>32?q(M+";",t,c,z-1):q(n(M," ","")+";",t,c,z-2),k);break;case 59:M+=";";default:if(r(L=T(M,a,c,d,j,f,l,I,J=[],K=[],z),u),123===H)if(0===j)E(M,a,L,L,J,u,z,l,K);else switch(A){case 100:case 109:case 115:E(e,L,L,t&&r(T(e,L,L,0,0,f,l,I,f,J=[],z),K),f,K,z,l,t?J:K);break;default:E(M,L,L,L,[""],K,z,l,K)}}d=j=B=0,D=G=1,I=M="",z=o;break;case 58:z=1+s(M),B=C;default:if(D<1)if(123==H)--D;else if(125==H&&0==D++&&125==x())continue;switch(M+=i(H),H*D){case 38:G=j>0?1:(M+="\f",-1);break;case 44:l[d++]=(s(M)-1)*G,G=1;break;case 64:45===m()&&(M+=h(b())),A=m(),j=s(I=M+=w(y())),H++;break;case 45:45===C&&2==s(M)&&(D=0)}}return u}function T(a,c,s,r,i,l,k,b,m,h,w){for(var p=i-1,j=0===i?l:[""],v=f(j),g=0,x=0,y=0;g<r;++g)for(var z=0,E=t(a,p+1,p=u(x=k[g])),T=a;z<v;++z)(T=o(x>0?j[z]+" "+E:n(E,/&\f/g,j[z])))&&(m[y++]=T);return d(a,c,s,0===i?e:b,m,h,w)}function U(e,a,s){return d(e,a,s,c,i(j()),t(e,2,-2),0)}function q(e,c,s,r){return d(e,c,s,a,t(e,0,r),t(e,r+1,-1),r)}export{U as comment,z as compile,q as declaration,E as parse,T as ruleset};
//# sourceMappingURL=Parser.js.map
