import{__exports as e}from"../../../_virtual/parsers.mjs";import{__require as r}from"./nodes/Node.mjs";import{__require as t}from"./nodes/Container.mjs";var a;function n(){if(a)return e;a=1,Object.defineProperty(e,"__esModule",{value:!0}),e.parseMediaFeature=u,e.parseMediaQuery=s,e.parseMediaList=function(e){var r=[],t=0,a=0,i=/^(\s*)url\s*\(/.exec(e);if(null!==i){for(var u=i[0].length,f=1;f>0;){var p=e[u];"("===p&&f++,")"===p&&f--,u++}r.unshift(new n.default({type:"url",value:e.substring(0,u).trim(),sourceIndex:i[1].length,before:i[1],after:/^(\s*)/.exec(e.substring(u))[1]})),t=u}for(var d=t;d<e.length;d++){var l=e[d];if("("===l&&a++,")"===l&&a--,0===a&&","===l){var y=e.substring(t,d),c=/^(\s*)/.exec(y)[1];r.push(new o.default({type:"media-query",value:y.trim(),sourceIndex:t+c.length,nodes:s(y,t),before:c,after:/(\s*)$/.exec(y)[1]})),t=d+1}}var m=e.substring(t),v=/^(\s*)/.exec(m)[1];return r.push(new o.default({type:"media-query",value:m.trim(),sourceIndex:t+v.length,nodes:s(m,t),before:v,after:/(\s*)$/.exec(m)[1]})),r};var n=i(r()),o=i(t());function i(e){return e&&e.__esModule?e:{default:e}}function u(e){var r=[{mode:"normal",character:null}],t=[],a=0,n="",o=null,i=null,u=arguments.length<=1||void 0===arguments[1]?0:arguments[1],s=e;"("===e[0]&&")"===e[e.length-1]&&(s=e.substring(1,e.length-1),u++);for(var f=0;f<s.length;f++){var p=s[f];if("'"!==p&&'"'!==p||(!0===r[a].isCalculationEnabled?(r.push({mode:"string",isCalculationEnabled:!1,character:p}),a++):"string"===r[a].mode&&r[a].character===p&&"\\"!==s[f-1]&&(r.pop(),a--)),"{"===p?(r.push({mode:"interpolation",isCalculationEnabled:!0}),a++):"}"===p&&(r.pop(),a--),"normal"===r[a].mode&&":"===p){var d=s.substring(f+1);(i={type:"value",before:/^(\s*)/.exec(d)[1],after:/(\s*)$/.exec(d)[1],value:d.trim()}).sourceIndex=i.before.length+f+1+u,o={type:"colon",sourceIndex:f+u,after:i.before,value:":"};break}n+=p}return(n={type:"media-feature",before:/^(\s*)/.exec(n)[1],after:/(\s*)$/.exec(n)[1],value:n.trim()}).sourceIndex=n.before.length+u,t.push(n),null!==o&&(o.before=n.after,t.push(o)),null!==i&&t.push(i),t}function s(e){var r=arguments.length<=1||void 0===arguments[1]?0:arguments[1],t=[],a=0,i=!1,s=void 0;function f(){return{before:"",after:"",value:""}}s={before:"",after:"",value:""};for(var p=0;p<e.length;p++){var d=e[p];i?(s.value+=d,"{"!==d&&"("!==d||a++,")"!==d&&"}"!==d||a--):-1!==d.search(/\s/)?s.before+=d:("("===d&&(s.type="media-feature-expression",a++),s.value=d,s.sourceIndex=r+p,i=!0),!i||0!==a||")"!==d&&p!==e.length-1&&-1===e[p+1].search(/\s/)||(-1!==["not","only","and"].indexOf(s.value)&&(s.type="keyword"),"media-feature-expression"===s.type&&(s.nodes=u(s.value,s.sourceIndex)),t.push(Array.isArray(s.nodes)?new o.default(s):new n.default(s)),s=f(),i=!1)}for(var l=0;l<t.length;l++)if(s=t[l],l>0&&(t[l-1].after=s.before),void 0===s.type){if(l>0){if("media-feature-expression"===t[l-1].type){s.type="keyword";continue}if("not"===t[l-1].value||"only"===t[l-1].value){s.type="media-type";continue}if("and"===t[l-1].value){s.type="media-feature-expression";continue}"media-type"===t[l-1].type&&(t[l+1]?s.type="media-feature-expression"===t[l+1].type?"keyword":"media-feature-expression":s.type="media-feature-expression")}if(0===l){if(!t[l+1]){s.type="media-type";continue}if(t[l+1]&&("media-feature-expression"===t[l+1].type||"keyword"===t[l+1].type)){s.type="media-type";continue}if(t[l+2]){if("media-feature-expression"===t[l+2].type){s.type="media-type",t[l+1].type="keyword";continue}if("keyword"===t[l+2].type){s.type="keyword",t[l+1].type="media-type";continue}}if(t[l+3]&&"media-feature-expression"===t[l+3].type){s.type="keyword",t[l+1].type="media-type",t[l+2].type="keyword";continue}}}return t}return e}export{n as __require};