import{Ident as t,Number as e,Dimension as r,Delim as n}from"../tokenizer/types.mjs";import{isHexDigit as u}from"../tokenizer/char-code-definitions.mjs";import{cmpChar as o}from"../tokenizer/utils.mjs";import"../tokenizer/TokenStream.mjs";function i(t,e){return null!==t&&t.type===n&&t.value.charCodeAt(0)===e}function f(t,e,r){let n=0;for(let o=e;o<t.value.length;o++){const i=t.value.charCodeAt(o);if(45===i&&r&&0!==n)return f(t,e+n+1,!1),6;if(!u(i))return 0;if(++n>6)return 0}return n}function l(t,e,r){if(!t)return 0;for(;i(r(e),63);){if(++t>6)return 0;e++}return e}function p(n,u){let p=0;if(null===n||n.type!==t||!o(n.value,0,117))return 0;if(null===(n=u(++p)))return 0;if(i(n,43))return null===(n=u(++p))?0:n.type===t?l(f(n,0,!0),++p,u):i(n,63)?l(1,++p,u):0;if(n.type===e){const t=f(n,1,!0);return 0===t?0:null===(n=u(++p))?p:n.type===r||n.type===e?function(t,e){return t.value.charCodeAt(0)===e}(n,45)&&f(n,1,!1)?p+1:0:l(t,p,u)}return n.type===r?l(f(n,1,!0),++p,u):0}export{p as default};