"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("./Enum.js"),a=require("./Utility.js"),e=require("./Tokenizer.js");function S(c){return e.dealloc(y("",null,null,null,[""],c=e.alloc(c),0,[0],c))}function y(c,d,o,i,b,h,M,u,g){for(var w=0,p=0,s=M,E=0,T=0,m=0,n=1,j=1,f=1,t=0,v="",q=b,k=h,l=i,r=v;j;)switch(m=t,t=e.next()){case 40:if(m!=108&&r.charCodeAt(s-1)==58){a.indexof(r+=a.replace(e.delimit(t),"&","&\f"),"&\f")!=-1&&(f=-1);break}case 34:case 39:case 91:r+=e.delimit(t);break;case 9:case 10:case 13:case 32:r+=e.whitespace(m);break;case 92:r+=e.escaping(e.caret()-1,7);continue;case 47:switch(e.peek()){case 42:case 47:a.append(O(e.commenter(e.next(),e.caret()),d,o),g);break;default:r+="/"}break;case 123*n:u[w++]=a.strlen(r)*f;case 125*n:case 59:case 0:switch(t){case 0:case 125:j=0;case 59+p:T>0&&a.strlen(r)-s&&a.append(T>32?A(r+";",i,o,s-1):A(a.replace(r," ","")+";",i,o,s-2),g);break;case 59:r+=";";default:if(a.append(l=z(r,d,o,w,p,b,u,v,q=[],k=[],s),h),t===123)if(p===0)y(r,d,l,l,q,h,s,u,k);else switch(E){case 100:case 109:case 115:y(c,l,l,i&&a.append(z(c,l,l,0,0,b,u,v,b,q=[],s),k),b,k,s,u,i?q:k);break;default:y(r,l,l,l,[""],k,0,u,k)}}w=p=T=0,n=f=1,v=r="",s=M;break;case 58:s=1+a.strlen(r),T=m;default:if(n<1){if(t==123)--n;else if(t==125&&n++==0&&e.prev()==125)continue}switch(r+=a.from(t),t*n){case 38:f=p>0?1:(r+="\f",-1);break;case 44:u[w++]=(a.strlen(r)-1)*f,f=1;break;case 64:e.peek()===45&&(r+=e.delimit(e.next())),E=e.peek(),p=s=a.strlen(v=r+=e.identifier(e.caret())),t++;break;case 45:m===45&&a.strlen(r)==2&&(n=0)}}return h}function z(c,d,o,i,b,h,M,u,g,w,p){for(var s=b-1,E=b===0?h:[""],T=a.sizeof(E),m=0,n=0,j=0;m<i;++m)for(var f=0,t=a.substr(c,s+1,s=a.abs(n=M[m])),v=c;f<T;++f)(v=a.trim(n>0?E[f]+" "+t:a.replace(t,/&\f/g,E[f])))&&(g[j++]=v);return e.node(c,d,o,b===0?C.RULESET:u,g,w,p)}function O(c,d,o){return e.node(c,d,o,C.COMMENT,a.from(e.char()),a.substr(c,2,-2),0)}function A(c,d,o,i){return e.node(c,d,o,C.DECLARATION,a.substr(c,0,i),a.substr(c,i+1,-1),i)}exports.comment=O;exports.compile=S;exports.declaration=A;exports.parse=y;exports.ruleset=z;
//# sourceMappingURL=Parser.js.map
