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