var e,r;function t(){if(r)return e;r=1;const t={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:"    ",semicolon:!1};class n{constructor(e){this.builder=e}atrule(e,r){let t="@"+e.name,n=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?t+=e.raws.afterName:n&&(t+=" "),e.nodes)this.block(e,t+n);else{let o=(e.raws.between||"")+(r?";":"");this.builder(t+n+o,e)}}beforeAfter(e,r){let t;t="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===r?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");let n=e.parent,o=0;for(;n&&"root"!==n.type;)o+=1,n=n.parent;if(t.includes("\n")){let r=this.raw(e,null,"indent");if(r.length)for(let e=0;e<o;e++)t+=r}return t}block(e,r){let t,n=this.raw(e,"between","beforeOpen");this.builder(r+n+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),t=this.raw(e,"after")):t=this.raw(e,"after","emptyBody"),t&&this.builder(t),this.builder("}",e,"end")}body(e){let r=e.nodes.length-1;for(;r>0&&"comment"===e.nodes[r].type;)r-=1;let t=this.raw(e,"semicolon");for(let n=0;n<e.nodes.length;n++){let o=e.nodes[n],a=this.raw(o,"before");a&&this.builder(a),this.stringify(o,r!==n||t)}}comment(e){let r=this.raw(e,"left","commentLeft"),t=this.raw(e,"right","commentRight");this.builder("/*"+r+e.text+t+"*/",e)}decl(e,r){let t=this.raw(e,"between","colon"),n=e.prop+t+this.rawValue(e,"value");e.important&&(n+=e.raws.important||" !important"),r&&(n+=";"),this.builder(n,e)}document(e){this.body(e)}raw(e,r,n){let o;if(n||(n=r),r&&(o=e.raws[r],void 0!==o))return o;let a=e.parent;if("before"===n){if(!a||"root"===a.type&&a.first===e)return"";if(a&&"document"===a.type)return""}if(!a)return t[n];let l=e.root();if(l.rawCache||(l.rawCache={}),void 0!==l.rawCache[n])return l.rawCache[n];if("before"===n||"after"===n)return this.beforeAfter(e,n);{let t="raw"+((i=n)[0].toUpperCase()+i.slice(1));this[t]?o=this[t](l,e):l.walk(e=>{if(o=e.raws[r],void 0!==o)return!1})}var i;return void 0===o&&(o=t[n]),l.rawCache[n]=o,o}rawBeforeClose(e){let r;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return r=e.raws.after,r.includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),r&&(r=r.replace(/\S/g,"")),r}rawBeforeComment(e,r){let t;return e.walkComments(e=>{if(void 0!==e.raws.before)return t=e.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),void 0===t?t=this.raw(r,null,"beforeDecl"):t&&(t=t.replace(/\S/g,"")),t}rawBeforeDecl(e,r){let t;return e.walkDecls(e=>{if(void 0!==e.raws.before)return t=e.raws.before,t.includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),void 0===t?t=this.raw(r,null,"beforeRule"):t&&(t=t.replace(/\S/g,"")),t}rawBeforeOpen(e){let r;return e.walk(e=>{if("decl"!==e.type&&(r=e.raws.between,void 0!==r))return!1}),r}rawBeforeRule(e){let r;return e.walk(t=>{if(t.nodes&&(t.parent!==e||e.first!==t)&&void 0!==t.raws.before)return r=t.raws.before,r.includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),r&&(r=r.replace(/\S/g,"")),r}rawColon(e){let r;return e.walkDecls(e=>{if(void 0!==e.raws.between)return r=e.raws.between.replace(/[^\s:]/g,""),!1}),r}rawEmptyBody(e){let r;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&(r=e.raws.after,void 0!==r))return!1}),r}rawIndent(e){if(e.raws.indent)return e.raws.indent;let r;return e.walk(t=>{let n=t.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==t.raws.before){let e=t.raws.before.split("\n");return r=e[e.length-1],r=r.replace(/\S/g,""),!1}}),r}rawSemicolon(e){let r;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&(r=e.raws.semicolon,void 0!==r))return!1}),r}rawValue(e,r){let t=e[r],n=e.raws[r];return n&&n.value===t?n.raw:t}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,r){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,r)}}return e=n,n.default=n,e}export{t as __require};