import e from"../../../_virtual/postcss.mjs";import{__require as t}from"../../postcss/lib/parser.mjs";import{__require as r}from"./nested-declaration.mjs";import{__require as s}from"./scss-tokenize.mjs";var i,o;function n(){if(o)return i;o=1;let{Comment:n}=e,l=t(),a=r(),f=s();return i=class extends l{atrule(e){let t=e[1],r=e;for(;!this.tokenizer.endOfFile();){let e=this.tokenizer.nextToken();if("word"!==e[0]||e[2]!==r[3]+1){this.tokenizer.back(e);break}t+=e[1],r=e}super.atrule(["at-word",t,e[2],r[3]])}comment(e){if("inline"===e[4]){let t=new n;this.init(t,e[2]),t.raws.inline=!0;let r=this.input.fromOffset(e[3]);t.source.end={column:r.col,line:r.line,offset:e[3]+1};let s=e[1].slice(2);if(/^\s*$/.test(s))t.text="",t.raws.left=s,t.raws.right="";else{let e=s.match(/^(\s*)([^]*\S)(\s*)$/),r=e[2].replace(/(\*\/|\/\*)/g,"*//*");t.text=r,t.raws.left=e[1],t.raws.right=e[3],t.raws.text=e[2]}}else super.comment(e)}createTokenizer(){this.tokenizer=f(this.input)}raw(e,t,r,s){if(super.raw(e,t,r,s),e.raws[t]){let s=e.raws[t].raw;e.raws[t].raw=r.reduce((e,t)=>{if("comment"===t[0]&&"inline"===t[4]){return e+"/*"+t[1].slice(2).replace(/(\*\/|\/\*)/g,"*//*")+"*/"}return e+t[1]},""),s!==e.raws[t].raw&&(e.raws[t].scss=s)}}rule(e){let t=!1,r=0,s="";for(let i of e)if(t)"comment"!==i[0]&&"{"!==i[0]&&(s+=i[1]);else{if("space"===i[0]&&i[1].includes("\n"))break;"("===i[0]?r+=1:")"===i[0]?r-=1:0===r&&":"===i[0]&&(t=!0)}if(!t||""===s.trim()||/^[#:A-Za-z-]/.test(s))super.rule(e);else{e.pop();let t,r,s=new a;this.init(s,e[0][2]);for(let r=e.length-1;r>=0;r--)if("space"!==e[r][0]){t=e[r];break}if(t[3]){let e=this.input.fromOffset(t[3]);s.source.end={column:e.col,line:e.line,offset:t[3]+1}}else{let e=this.input.fromOffset(t[2]);s.source.end={column:e.col,line:e.line,offset:t[2]+1}}for(;"word"!==e[0][0];)s.raws.before+=e.shift()[1];if(e[0][2]){let t=this.input.fromOffset(e[0][2]);s.source.start={column:t.col,line:t.line,offset:e[0][2]}}for(s.prop="";e.length;){let t=e[0][0];if(":"===t||"space"===t||"comment"===t)break;s.prop+=e.shift()[1]}for(s.raws.between="";e.length;){if(r=e.shift(),":"===r[0]){s.raws.between+=r[1];break}s.raws.between+=r[1]}"_"!==s.prop[0]&&"*"!==s.prop[0]||(s.raws.before+=s.prop[0],s.prop=s.prop.slice(1)),s.raws.between+=this.spacesAndCommentsFromStart(e),this.precheckMissedSemicolon(e);for(let t=e.length-1;t>0;t--){if(r=e[t],"!important"===r[1]){s.important=!0;let r=this.stringFrom(e,t);r=this.spacesFromEnd(e)+r," !important"!==r&&(s.raws.important=r);break}if("important"===r[1]){let r=e.slice(0),i="";for(let e=t;e>0;e--){let t=r[e][0];if(0===i.trim().indexOf("!")&&"space"!==t)break;i=r.pop()[1]+i}0===i.trim().indexOf("!")&&(s.important=!0,s.raws.important=i,e=r)}if("space"!==r[0]&&"comment"!==r[0])break}this.raw(s,"value",e),s.value.includes(":")&&this.checkMissedSemicolon(e),this.current=s}}}}export{n as __require};