import{Ident as t,Dimension as e,Number as i}from"../../tokenizer/types.mjs";import{isHexDigit as s}from"../../tokenizer/char-code-definitions.mjs";import"../../tokenizer/TokenStream.mjs";function n(t,e){let i=0;for(let o=this.tokenStart+t;o<this.tokenEnd;o++){const r=this.charCodeAt(o);if(45===r&&e&&0!==i)return n.call(this,t+i+1,!1),-1;s(r)||this.error(e&&0!==i?"Hyphen minus"+(i<6?" or hex digit":"")+" is expected":i<6?"Hex digit is expected":"Unexpected input",o),++i>6&&this.error("Too many hex digits",o)}return this.next(),i}function o(t){let e=0;for(;this.isDelim(63);)++e>t&&this.error("Too many question marks"),this.next()}function r(t){this.charCodeAt(this.tokenStart)!==t&&this.error((43===t?"Plus sign":"Hyphen minus")+" is expected")}function h(){let s=0;switch(this.tokenType){case i:if(s=n.call(this,1,!0),this.isDelim(63)){o.call(this,6-s);break}if(this.tokenType===e||this.tokenType===i){r.call(this,45),n.call(this,1,!1);break}break;case e:s=n.call(this,1,!0),s>0&&o.call(this,6-s);break;default:if(this.eatDelim(43),this.tokenType===t){s=n.call(this,0,!0),s>0&&o.call(this,6-s);break}if(this.isDelim(63)){this.next(),o.call(this,5);break}this.error("Hex digit or question mark is expected")}}const a="UnicodeRange",c={value:String};function l(){const t=this.tokenStart;return this.eatIdent("u"),h.call(this),{type:"UnicodeRange",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t)}}function k(t){this.tokenize(t.value)}export{k as generate,a as name,l as parse,c as structure};