UNPKG

@hsuna/postcss-media-query-transform

Version:

PostCSS plugin designed to automatically adjust pixel values within specified media queries. It scales the numeric values of designated units according to predefined ratios, ensuring consistent and responsive design across various devices and screen sizes

1,512 lines (1,499 loc) 208 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error('Dynamic require of "' + x + '" is not supported'); }); var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // node_modules/tsup/assets/esm_shims.js var init_esm_shims = __esm({ "node_modules/tsup/assets/esm_shims.js"() { "use strict"; } }); // node_modules/picocolors/picocolors.js var require_picocolors = __commonJS({ "node_modules/picocolors/picocolors.js"(exports, module) { "use strict"; init_esm_shims(); var p = process || {}; var argv = p.argv || []; var env = p.env || {}; var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI); var formatter = (open, close, replace = open) => (input) => { let string = "" + input, index = string.indexOf(close, open.length); return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close; }; var replaceClose = (string, close, replace, index) => { let result = "", cursor = 0; do { result += string.substring(cursor, index) + replace; cursor = index + close.length; index = string.indexOf(close, cursor); } while (~index); return result + string.substring(cursor); }; var createColors = (enabled = isColorSupported) => { let f = enabled ? formatter : () => String; return { isColorSupported: enabled, reset: f("\x1B[0m", "\x1B[0m"), bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"), dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"), italic: f("\x1B[3m", "\x1B[23m"), underline: f("\x1B[4m", "\x1B[24m"), inverse: f("\x1B[7m", "\x1B[27m"), hidden: f("\x1B[8m", "\x1B[28m"), strikethrough: f("\x1B[9m", "\x1B[29m"), black: f("\x1B[30m", "\x1B[39m"), red: f("\x1B[31m", "\x1B[39m"), green: f("\x1B[32m", "\x1B[39m"), yellow: f("\x1B[33m", "\x1B[39m"), blue: f("\x1B[34m", "\x1B[39m"), magenta: f("\x1B[35m", "\x1B[39m"), cyan: f("\x1B[36m", "\x1B[39m"), white: f("\x1B[37m", "\x1B[39m"), gray: f("\x1B[90m", "\x1B[39m"), bgBlack: f("\x1B[40m", "\x1B[49m"), bgRed: f("\x1B[41m", "\x1B[49m"), bgGreen: f("\x1B[42m", "\x1B[49m"), bgYellow: f("\x1B[43m", "\x1B[49m"), bgBlue: f("\x1B[44m", "\x1B[49m"), bgMagenta: f("\x1B[45m", "\x1B[49m"), bgCyan: f("\x1B[46m", "\x1B[49m"), bgWhite: f("\x1B[47m", "\x1B[49m"), blackBright: f("\x1B[90m", "\x1B[39m"), redBright: f("\x1B[91m", "\x1B[39m"), greenBright: f("\x1B[92m", "\x1B[39m"), yellowBright: f("\x1B[93m", "\x1B[39m"), blueBright: f("\x1B[94m", "\x1B[39m"), magentaBright: f("\x1B[95m", "\x1B[39m"), cyanBright: f("\x1B[96m", "\x1B[39m"), whiteBright: f("\x1B[97m", "\x1B[39m"), bgBlackBright: f("\x1B[100m", "\x1B[49m"), bgRedBright: f("\x1B[101m", "\x1B[49m"), bgGreenBright: f("\x1B[102m", "\x1B[49m"), bgYellowBright: f("\x1B[103m", "\x1B[49m"), bgBlueBright: f("\x1B[104m", "\x1B[49m"), bgMagentaBright: f("\x1B[105m", "\x1B[49m"), bgCyanBright: f("\x1B[106m", "\x1B[49m"), bgWhiteBright: f("\x1B[107m", "\x1B[49m") }; }; module.exports = createColors(); module.exports.createColors = createColors; } }); // node_modules/postcss/lib/tokenize.js var require_tokenize = __commonJS({ "node_modules/postcss/lib/tokenize.js"(exports, module) { "use strict"; init_esm_shims(); var SINGLE_QUOTE = "'".charCodeAt(0); var DOUBLE_QUOTE = '"'.charCodeAt(0); var BACKSLASH = "\\".charCodeAt(0); var SLASH = "/".charCodeAt(0); var NEWLINE = "\n".charCodeAt(0); var SPACE = " ".charCodeAt(0); var FEED = "\f".charCodeAt(0); var TAB = " ".charCodeAt(0); var CR = "\r".charCodeAt(0); var OPEN_SQUARE = "[".charCodeAt(0); var CLOSE_SQUARE = "]".charCodeAt(0); var OPEN_PARENTHESES = "(".charCodeAt(0); var CLOSE_PARENTHESES = ")".charCodeAt(0); var OPEN_CURLY = "{".charCodeAt(0); var CLOSE_CURLY = "}".charCodeAt(0); var SEMICOLON = ";".charCodeAt(0); var ASTERISK = "*".charCodeAt(0); var COLON = ":".charCodeAt(0); var AT = "@".charCodeAt(0); var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g; var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g; var RE_BAD_BRACKET = /.[\r\n"'(/\\]/; var RE_HEX_ESCAPE = /[\da-f]/i; module.exports = function tokenizer(input, options = {}) { let css = input.css.valueOf(); let ignore = options.ignoreErrors; let code, content, escape, next, quote; let currentToken, escaped, escapePos, n, prev; let length = css.length; let pos = 0; let buffer = []; let returned = []; function position() { return pos; } function unclosed(what) { throw input.error("Unclosed " + what, pos); } function endOfFile() { return returned.length === 0 && pos >= length; } function nextToken(opts) { if (returned.length) return returned.pop(); if (pos >= length) return; let ignoreUnclosed = opts ? opts.ignoreUnclosed : false; code = css.charCodeAt(pos); switch (code) { case NEWLINE: case SPACE: case TAB: case CR: case FEED: { next = pos; do { next += 1; code = css.charCodeAt(next); } while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED); currentToken = ["space", css.slice(pos, next)]; pos = next - 1; break; } case OPEN_SQUARE: case CLOSE_SQUARE: case OPEN_CURLY: case CLOSE_CURLY: case COLON: case SEMICOLON: case CLOSE_PARENTHESES: { let controlChar = String.fromCharCode(code); currentToken = [controlChar, controlChar, pos]; break; } case OPEN_PARENTHESES: { prev = buffer.length ? buffer.pop()[1] : ""; n = css.charCodeAt(pos + 1); if (prev === "url" && n !== SINGLE_QUOTE && n !== DOUBLE_QUOTE && n !== SPACE && n !== NEWLINE && n !== TAB && n !== FEED && n !== CR) { next = pos; do { escaped = false; next = css.indexOf(")", next + 1); if (next === -1) { if (ignore || ignoreUnclosed) { next = pos; break; } else { unclosed("bracket"); } } escapePos = next; while (css.charCodeAt(escapePos - 1) === BACKSLASH) { escapePos -= 1; escaped = !escaped; } } while (escaped); currentToken = ["brackets", css.slice(pos, next + 1), pos, next]; pos = next; } else { next = css.indexOf(")", pos + 1); content = css.slice(pos, next + 1); if (next === -1 || RE_BAD_BRACKET.test(content)) { currentToken = ["(", "(", pos]; } else { currentToken = ["brackets", content, pos, next]; pos = next; } } break; } case SINGLE_QUOTE: case DOUBLE_QUOTE: { quote = code === SINGLE_QUOTE ? "'" : '"'; next = pos; do { escaped = false; next = css.indexOf(quote, next + 1); if (next === -1) { if (ignore || ignoreUnclosed) { next = pos + 1; break; } else { unclosed("string"); } } escapePos = next; while (css.charCodeAt(escapePos - 1) === BACKSLASH) { escapePos -= 1; escaped = !escaped; } } while (escaped); currentToken = ["string", css.slice(pos, next + 1), pos, next]; pos = next; break; } case AT: { RE_AT_END.lastIndex = pos + 1; RE_AT_END.test(css); if (RE_AT_END.lastIndex === 0) { next = css.length - 1; } else { next = RE_AT_END.lastIndex - 2; } currentToken = ["at-word", css.slice(pos, next + 1), pos, next]; pos = next; break; } case BACKSLASH: { next = pos; escape = true; while (css.charCodeAt(next + 1) === BACKSLASH) { next += 1; escape = !escape; } code = css.charCodeAt(next + 1); if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) { next += 1; if (RE_HEX_ESCAPE.test(css.charAt(next))) { while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) { next += 1; } if (css.charCodeAt(next + 1) === SPACE) { next += 1; } } } currentToken = ["word", css.slice(pos, next + 1), pos, next]; pos = next; break; } default: { if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) { next = css.indexOf("*/", pos + 2) + 1; if (next === 0) { if (ignore || ignoreUnclosed) { next = css.length; } else { unclosed("comment"); } } currentToken = ["comment", css.slice(pos, next + 1), pos, next]; pos = next; } else { RE_WORD_END.lastIndex = pos + 1; RE_WORD_END.test(css); if (RE_WORD_END.lastIndex === 0) { next = css.length - 1; } else { next = RE_WORD_END.lastIndex - 2; } currentToken = ["word", css.slice(pos, next + 1), pos, next]; buffer.push(currentToken); pos = next; } break; } } pos++; return currentToken; } function back(token) { returned.push(token); } return { back, endOfFile, nextToken, position }; }; } }); // node_modules/postcss/lib/terminal-highlight.js var require_terminal_highlight = __commonJS({ "node_modules/postcss/lib/terminal-highlight.js"(exports, module) { "use strict"; init_esm_shims(); var pico = require_picocolors(); var tokenizer = require_tokenize(); var Input2; function registerInput(dependant) { Input2 = dependant; } var HIGHLIGHT_THEME = { ";": pico.yellow, ":": pico.yellow, "(": pico.cyan, ")": pico.cyan, "[": pico.yellow, "]": pico.yellow, "{": pico.yellow, "}": pico.yellow, "at-word": pico.cyan, "brackets": pico.cyan, "call": pico.cyan, "class": pico.yellow, "comment": pico.gray, "hash": pico.magenta, "string": pico.green }; function getTokenType([type, value], processor) { if (type === "word") { if (value[0] === ".") { return "class"; } if (value[0] === "#") { return "hash"; } } if (!processor.endOfFile()) { let next = processor.nextToken(); processor.back(next); if (next[0] === "brackets" || next[0] === "(") return "call"; } return type; } function terminalHighlight(css) { let processor = tokenizer(new Input2(css), { ignoreErrors: true }); let result = ""; while (!processor.endOfFile()) { let token = processor.nextToken(); let color = HIGHLIGHT_THEME[getTokenType(token, processor)]; if (color) { result += token[1].split(/\r?\n/).map((i) => color(i)).join("\n"); } else { result += token[1]; } } return result; } terminalHighlight.registerInput = registerInput; module.exports = terminalHighlight; } }); // node_modules/postcss/lib/css-syntax-error.js var require_css_syntax_error = __commonJS({ "node_modules/postcss/lib/css-syntax-error.js"(exports, module) { "use strict"; init_esm_shims(); var pico = require_picocolors(); var terminalHighlight = require_terminal_highlight(); var CssSyntaxError2 = class _CssSyntaxError extends Error { constructor(message, line, column, source, file, plugin3) { super(message); this.name = "CssSyntaxError"; this.reason = message; if (file) { this.file = file; } if (source) { this.source = source; } if (plugin3) { this.plugin = plugin3; } if (typeof line !== "undefined" && typeof column !== "undefined") { if (typeof line === "number") { this.line = line; this.column = column; } else { this.line = line.line; this.column = line.column; this.endLine = column.line; this.endColumn = column.column; } } this.setMessage(); if (Error.captureStackTrace) { Error.captureStackTrace(this, _CssSyntaxError); } } setMessage() { this.message = this.plugin ? this.plugin + ": " : ""; this.message += this.file ? this.file : "<css input>"; if (typeof this.line !== "undefined") { this.message += ":" + this.line + ":" + this.column; } this.message += ": " + this.reason; } showSourceCode(color) { if (!this.source) return ""; let css = this.source; if (color == null) color = pico.isColorSupported; let aside = (text) => text; let mark = (text) => text; let highlight = (text) => text; if (color) { let { bold, gray, red } = pico.createColors(true); mark = (text) => bold(red(text)); aside = (text) => gray(text); if (terminalHighlight) { highlight = (text) => terminalHighlight(text); } } let lines = css.split(/\r?\n/); let start = Math.max(this.line - 3, 0); let end = Math.min(this.line + 2, lines.length); let maxWidth = String(end).length; return lines.slice(start, end).map((line, index) => { let number = start + 1 + index; let gutter = " " + (" " + number).slice(-maxWidth) + " | "; if (number === this.line) { if (line.length > 160) { let padding = 20; let subLineStart = Math.max(0, this.column - padding); let subLineEnd = Math.max( this.column + padding, this.endColumn + padding ); let subLine = line.slice(subLineStart, subLineEnd); let spacing2 = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, padding - 1)).replace(/[^\t]/g, " "); return mark(">") + aside(gutter) + highlight(subLine) + "\n " + spacing2 + mark("^"); } let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " "); return mark(">") + aside(gutter) + highlight(line) + "\n " + spacing + mark("^"); } return " " + aside(gutter) + highlight(line); }).join("\n"); } toString() { let code = this.showSourceCode(); if (code) { code = "\n\n" + code + "\n"; } return this.name + ": " + this.message + code; } }; module.exports = CssSyntaxError2; CssSyntaxError2.default = CssSyntaxError2; } }); // node_modules/postcss/lib/stringifier.js var require_stringifier = __commonJS({ "node_modules/postcss/lib/stringifier.js"(exports, module) { "use strict"; init_esm_shims(); var DEFAULT_RAW = { after: "\n", beforeClose: "\n", beforeComment: "\n", beforeDecl: "\n", beforeOpen: " ", beforeRule: "\n", colon: ": ", commentLeft: " ", commentRight: " ", emptyBody: "", indent: " ", semicolon: false }; function capitalize(str) { return str[0].toUpperCase() + str.slice(1); } var Stringifier = class { constructor(builder) { this.builder = builder; } atrule(node, semicolon) { let name = "@" + node.name; let params = node.params ? this.rawValue(node, "params") : ""; if (typeof node.raws.afterName !== "undefined") { name += node.raws.afterName; } else if (params) { name += " "; } if (node.nodes) { this.block(node, name + params); } else { let end = (node.raws.between || "") + (semicolon ? ";" : ""); this.builder(name + params + end, node); } } beforeAfter(node, detect) { let value; if (node.type === "decl") { value = this.raw(node, null, "beforeDecl"); } else if (node.type === "comment") { value = this.raw(node, null, "beforeComment"); } else if (detect === "before") { value = this.raw(node, null, "beforeRule"); } else { value = this.raw(node, null, "beforeClose"); } let buf = node.parent; let depth = 0; while (buf && buf.type !== "root") { depth += 1; buf = buf.parent; } if (value.includes("\n")) { let indent = this.raw(node, null, "indent"); if (indent.length) { for (let step = 0; step < depth; step++) value += indent; } } return value; } block(node, start) { let between = this.raw(node, "between", "beforeOpen"); this.builder(start + between + "{", node, "start"); let after; if (node.nodes && node.nodes.length) { this.body(node); after = this.raw(node, "after"); } else { after = this.raw(node, "after", "emptyBody"); } if (after) this.builder(after); this.builder("}", node, "end"); } body(node) { let last = node.nodes.length - 1; while (last > 0) { if (node.nodes[last].type !== "comment") break; last -= 1; } let semicolon = this.raw(node, "semicolon"); for (let i = 0; i < node.nodes.length; i++) { let child = node.nodes[i]; let before = this.raw(child, "before"); if (before) this.builder(before); this.stringify(child, last !== i || semicolon); } } comment(node) { let left = this.raw(node, "left", "commentLeft"); let right = this.raw(node, "right", "commentRight"); this.builder("/*" + left + node.text + right + "*/", node); } decl(node, semicolon) { let between = this.raw(node, "between", "colon"); let string = node.prop + between + this.rawValue(node, "value"); if (node.important) { string += node.raws.important || " !important"; } if (semicolon) string += ";"; this.builder(string, node); } document(node) { this.body(node); } raw(node, own, detect) { let value; if (!detect) detect = own; if (own) { value = node.raws[own]; if (typeof value !== "undefined") return value; } let parent = node.parent; if (detect === "before") { if (!parent || parent.type === "root" && parent.first === node) { return ""; } if (parent && parent.type === "document") { return ""; } } if (!parent) return DEFAULT_RAW[detect]; let root2 = node.root(); if (!root2.rawCache) root2.rawCache = {}; if (typeof root2.rawCache[detect] !== "undefined") { return root2.rawCache[detect]; } if (detect === "before" || detect === "after") { return this.beforeAfter(node, detect); } else { let method = "raw" + capitalize(detect); if (this[method]) { value = this[method](root2, node); } else { root2.walk((i) => { value = i.raws[own]; if (typeof value !== "undefined") return false; }); } } if (typeof value === "undefined") value = DEFAULT_RAW[detect]; root2.rawCache[detect] = value; return value; } rawBeforeClose(root2) { let value; root2.walk((i) => { if (i.nodes && i.nodes.length > 0) { if (typeof i.raws.after !== "undefined") { value = i.raws.after; if (value.includes("\n")) { value = value.replace(/[^\n]+$/, ""); } return false; } } }); if (value) value = value.replace(/\S/g, ""); return value; } rawBeforeComment(root2, node) { let value; root2.walkComments((i) => { if (typeof i.raws.before !== "undefined") { value = i.raws.before; if (value.includes("\n")) { value = value.replace(/[^\n]+$/, ""); } return false; } }); if (typeof value === "undefined") { value = this.raw(node, null, "beforeDecl"); } else if (value) { value = value.replace(/\S/g, ""); } return value; } rawBeforeDecl(root2, node) { let value; root2.walkDecls((i) => { if (typeof i.raws.before !== "undefined") { value = i.raws.before; if (value.includes("\n")) { value = value.replace(/[^\n]+$/, ""); } return false; } }); if (typeof value === "undefined") { value = this.raw(node, null, "beforeRule"); } else if (value) { value = value.replace(/\S/g, ""); } return value; } rawBeforeOpen(root2) { let value; root2.walk((i) => { if (i.type !== "decl") { value = i.raws.between; if (typeof value !== "undefined") return false; } }); return value; } rawBeforeRule(root2) { let value; root2.walk((i) => { if (i.nodes && (i.parent !== root2 || root2.first !== i)) { if (typeof i.raws.before !== "undefined") { value = i.raws.before; if (value.includes("\n")) { value = value.replace(/[^\n]+$/, ""); } return false; } } }); if (value) value = value.replace(/\S/g, ""); return value; } rawColon(root2) { let value; root2.walkDecls((i) => { if (typeof i.raws.between !== "undefined") { value = i.raws.between.replace(/[^\s:]/g, ""); return false; } }); return value; } rawEmptyBody(root2) { let value; root2.walk((i) => { if (i.nodes && i.nodes.length === 0) { value = i.raws.after; if (typeof value !== "undefined") return false; } }); return value; } rawIndent(root2) { if (root2.raws.indent) return root2.raws.indent; let value; root2.walk((i) => { let p = i.parent; if (p && p !== root2 && p.parent && p.parent === root2) { if (typeof i.raws.before !== "undefined") { let parts = i.raws.before.split("\n"); value = parts[parts.length - 1]; value = value.replace(/\S/g, ""); return false; } } }); return value; } rawSemicolon(root2) { let value; root2.walk((i) => { if (i.nodes && i.nodes.length && i.last.type === "decl") { value = i.raws.semicolon; if (typeof value !== "undefined") return false; } }); return value; } rawValue(node, prop) { let value = node[prop]; let raw = node.raws[prop]; if (raw && raw.value === value) { return raw.raw; } return value; } root(node) { this.body(node); if (node.raws.after) this.builder(node.raws.after); } rule(node) { this.block(node, this.rawValue(node, "selector")); if (node.raws.ownSemicolon) { this.builder(node.raws.ownSemicolon, node, "end"); } } stringify(node, semicolon) { if (!this[node.type]) { throw new Error( "Unknown AST node type " + node.type + ". Maybe you need to change PostCSS stringifier." ); } this[node.type](node, semicolon); } }; module.exports = Stringifier; Stringifier.default = Stringifier; } }); // node_modules/postcss/lib/stringify.js var require_stringify = __commonJS({ "node_modules/postcss/lib/stringify.js"(exports, module) { "use strict"; init_esm_shims(); var Stringifier = require_stringifier(); function stringify2(node, builder) { let str = new Stringifier(builder); str.stringify(node); } module.exports = stringify2; stringify2.default = stringify2; } }); // node_modules/postcss/lib/symbols.js var require_symbols = __commonJS({ "node_modules/postcss/lib/symbols.js"(exports, module) { "use strict"; init_esm_shims(); module.exports.isClean = Symbol("isClean"); module.exports.my = Symbol("my"); } }); // node_modules/postcss/lib/node.js var require_node = __commonJS({ "node_modules/postcss/lib/node.js"(exports, module) { "use strict"; init_esm_shims(); var CssSyntaxError2 = require_css_syntax_error(); var Stringifier = require_stringifier(); var stringify2 = require_stringify(); var { isClean, my } = require_symbols(); function cloneNode(obj, parent) { let cloned = new obj.constructor(); for (let i in obj) { if (!Object.prototype.hasOwnProperty.call(obj, i)) { continue; } if (i === "proxyCache") continue; let value = obj[i]; let type = typeof value; if (i === "parent" && type === "object") { if (parent) cloned[i] = parent; } else if (i === "source") { cloned[i] = value; } else if (Array.isArray(value)) { cloned[i] = value.map((j) => cloneNode(j, cloned)); } else { if (type === "object" && value !== null) value = cloneNode(value); cloned[i] = value; } } return cloned; } function sourceOffset(inputCSS, position) { if (position && typeof position.offset !== "undefined") { return position.offset; } let column = 1; let line = 1; let offset = 0; for (let i = 0; i < inputCSS.length; i++) { if (line === position.line && column === position.column) { offset = i; break; } if (inputCSS[i] === "\n") { column = 1; line += 1; } else { column += 1; } } return offset; } var Node2 = class { get proxyOf() { return this; } constructor(defaults = {}) { this.raws = {}; this[isClean] = false; this[my] = true; for (let name in defaults) { if (name === "nodes") { this.nodes = []; for (let node of defaults[name]) { if (typeof node.clone === "function") { this.append(node.clone()); } else { this.append(node); } } } else { this[name] = defaults[name]; } } } addToError(error) { error.postcssNode = this; if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) { let s = this.source; error.stack = error.stack.replace( /\n\s{4}at /, `$&${s.input.from}:${s.start.line}:${s.start.column}$&` ); } return error; } after(add) { this.parent.insertAfter(this, add); return this; } assign(overrides = {}) { for (let name in overrides) { this[name] = overrides[name]; } return this; } before(add) { this.parent.insertBefore(this, add); return this; } cleanRaws(keepBetween) { delete this.raws.before; delete this.raws.after; if (!keepBetween) delete this.raws.between; } clone(overrides = {}) { let cloned = cloneNode(this); for (let name in overrides) { cloned[name] = overrides[name]; } return cloned; } cloneAfter(overrides = {}) { let cloned = this.clone(overrides); this.parent.insertAfter(this, cloned); return cloned; } cloneBefore(overrides = {}) { let cloned = this.clone(overrides); this.parent.insertBefore(this, cloned); return cloned; } error(message, opts = {}) { if (this.source) { let { end, start } = this.rangeBy(opts); return this.source.input.error( message, { column: start.column, line: start.line }, { column: end.column, line: end.line }, opts ); } return new CssSyntaxError2(message); } getProxyProcessor() { return { get(node, prop) { if (prop === "proxyOf") { return node; } else if (prop === "root") { return () => node.root().toProxy(); } else { return node[prop]; } }, set(node, prop, value) { if (node[prop] === value) return true; node[prop] = value; if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") { node.markDirty(); } return true; } }; } /* c8 ignore next 3 */ markClean() { this[isClean] = true; } markDirty() { if (this[isClean]) { this[isClean] = false; let next = this; while (next = next.parent) { next[isClean] = false; } } } next() { if (!this.parent) return void 0; let index = this.parent.index(this); return this.parent.nodes[index + 1]; } positionBy(opts) { let pos = this.source.start; if (opts.index) { pos = this.positionInside(opts.index); } else if (opts.word) { let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css; let stringRepresentation = inputString.slice( sourceOffset(inputString, this.source.start), sourceOffset(inputString, this.source.end) ); let index = stringRepresentation.indexOf(opts.word); if (index !== -1) pos = this.positionInside(index); } return pos; } positionInside(index) { let column = this.source.start.column; let line = this.source.start.line; let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css; let offset = sourceOffset(inputString, this.source.start); let end = offset + index; for (let i = offset; i < end; i++) { if (inputString[i] === "\n") { column = 1; line += 1; } else { column += 1; } } return { column, line }; } prev() { if (!this.parent) return void 0; let index = this.parent.index(this); return this.parent.nodes[index - 1]; } rangeBy(opts) { let start = { column: this.source.start.column, line: this.source.start.line }; let end = this.source.end ? { column: this.source.end.column + 1, line: this.source.end.line } : { column: start.column + 1, line: start.line }; if (opts.word) { let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css; let stringRepresentation = inputString.slice( sourceOffset(inputString, this.source.start), sourceOffset(inputString, this.source.end) ); let index = stringRepresentation.indexOf(opts.word); if (index !== -1) { start = this.positionInside(index); end = this.positionInside( index + opts.word.length ); } } else { if (opts.start) { start = { column: opts.start.column, line: opts.start.line }; } else if (opts.index) { start = this.positionInside(opts.index); } if (opts.end) { end = { column: opts.end.column, line: opts.end.line }; } else if (typeof opts.endIndex === "number") { end = this.positionInside(opts.endIndex); } else if (opts.index) { end = this.positionInside(opts.index + 1); } } if (end.line < start.line || end.line === start.line && end.column <= start.column) { end = { column: start.column + 1, line: start.line }; } return { end, start }; } raw(prop, defaultType) { let str = new Stringifier(); return str.raw(this, prop, defaultType); } remove() { if (this.parent) { this.parent.removeChild(this); } this.parent = void 0; return this; } replaceWith(...nodes) { if (this.parent) { let bookmark = this; let foundSelf = false; for (let node of nodes) { if (node === this) { foundSelf = true; } else if (foundSelf) { this.parent.insertAfter(bookmark, node); bookmark = node; } else { this.parent.insertBefore(bookmark, node); } } if (!foundSelf) { this.remove(); } } return this; } root() { let result = this; while (result.parent && result.parent.type !== "document") { result = result.parent; } return result; } toJSON(_, inputs) { let fixed = {}; let emitInputs = inputs == null; inputs = inputs || /* @__PURE__ */ new Map(); let inputsNextIndex = 0; for (let name in this) { if (!Object.prototype.hasOwnProperty.call(this, name)) { continue; } if (name === "parent" || name === "proxyCache") continue; let value = this[name]; if (Array.isArray(value)) { fixed[name] = value.map((i) => { if (typeof i === "object" && i.toJSON) { return i.toJSON(null, inputs); } else { return i; } }); } else if (typeof value === "object" && value.toJSON) { fixed[name] = value.toJSON(null, inputs); } else if (name === "source") { let inputId = inputs.get(value.input); if (inputId == null) { inputId = inputsNextIndex; inputs.set(value.input, inputsNextIndex); inputsNextIndex++; } fixed[name] = { end: value.end, inputId, start: value.start }; } else { fixed[name] = value; } } if (emitInputs) { fixed.inputs = [...inputs.keys()].map((input) => input.toJSON()); } return fixed; } toProxy() { if (!this.proxyCache) { this.proxyCache = new Proxy(this, this.getProxyProcessor()); } return this.proxyCache; } toString(stringifier = stringify2) { if (stringifier.stringify) stringifier = stringifier.stringify; let result = ""; stringifier(this, (i) => { result += i; }); return result; } warn(result, text, opts) { let data = { node: this }; for (let i in opts) data[i] = opts[i]; return result.warn(text, data); } }; module.exports = Node2; Node2.default = Node2; } }); // node_modules/postcss/lib/comment.js var require_comment = __commonJS({ "node_modules/postcss/lib/comment.js"(exports, module) { "use strict"; init_esm_shims(); var Node2 = require_node(); var Comment2 = class extends Node2 { constructor(defaults) { super(defaults); this.type = "comment"; } }; module.exports = Comment2; Comment2.default = Comment2; } }); // node_modules/postcss/lib/declaration.js var require_declaration = __commonJS({ "node_modules/postcss/lib/declaration.js"(exports, module) { "use strict"; init_esm_shims(); var Node2 = require_node(); var Declaration2 = class extends Node2 { get variable() { return this.prop.startsWith("--") || this.prop[0] === "$"; } constructor(defaults) { if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") { defaults = { ...defaults, value: String(defaults.value) }; } super(defaults); this.type = "decl"; } }; module.exports = Declaration2; Declaration2.default = Declaration2; } }); // node_modules/postcss/lib/container.js var require_container = __commonJS({ "node_modules/postcss/lib/container.js"(exports, module) { "use strict"; init_esm_shims(); var Comment2 = require_comment(); var Declaration2 = require_declaration(); var Node2 = require_node(); var { isClean, my } = require_symbols(); var AtRule2; var parse2; var Root2; var Rule3; function cleanSource(nodes) { return nodes.map((i) => { if (i.nodes) i.nodes = cleanSource(i.nodes); delete i.source; return i; }); } function markTreeDirty(node) { node[isClean] = false; if (node.proxyOf.nodes) { for (let i of node.proxyOf.nodes) { markTreeDirty(i); } } } var Container2 = class _Container extends Node2 { get first() { if (!this.proxyOf.nodes) return void 0; return this.proxyOf.nodes[0]; } get last() { if (!this.proxyOf.nodes) return void 0; return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]; } append(...children) { for (let child of children) { let nodes = this.normalize(child, this.last); for (let node of nodes) this.proxyOf.nodes.push(node); } this.markDirty(); return this; } cleanRaws(keepBetween) { super.cleanRaws(keepBetween); if (this.nodes) { for (let node of this.nodes) node.cleanRaws(keepBetween); } } each(callback) { if (!this.proxyOf.nodes) return void 0; let iterator = this.getIterator(); let index, result; while (this.indexes[iterator] < this.proxyOf.nodes.length) { index = this.indexes[iterator]; result = callback(this.proxyOf.nodes[index], index); if (result === false) break; this.indexes[iterator] += 1; } delete this.indexes[iterator]; return result; } every(condition) { return this.nodes.every(condition); } getIterator() { if (!this.lastEach) this.lastEach = 0; if (!this.indexes) this.indexes = {}; this.lastEach += 1; let iterator = this.lastEach; this.indexes[iterator] = 0; return iterator; } getProxyProcessor() { return { get(node, prop) { if (prop === "proxyOf") { return node; } else if (!node[prop]) { return node[prop]; } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) { return (...args) => { return node[prop]( ...args.map((i) => { if (typeof i === "function") { return (child, index) => i(child.toProxy(), index); } else { return i; } }) ); }; } else if (prop === "every" || prop === "some") { return (cb) => { return node[prop]( (child, ...other) => cb(child.toProxy(), ...other) ); }; } else if (prop === "root") { return () => node.root().toProxy(); } else if (prop === "nodes") { return node.nodes.map((i) => i.toProxy()); } else if (prop === "first" || prop === "last") { return node[prop].toProxy(); } else { return node[prop]; } }, set(node, prop, value) { if (node[prop] === value) return true; node[prop] = value; if (prop === "name" || prop === "params" || prop === "selector") { node.markDirty(); } return true; } }; } index(child) { if (typeof child === "number") return child; if (child.proxyOf) child = child.proxyOf; return this.proxyOf.nodes.indexOf(child); } insertAfter(exist, add) { let existIndex = this.index(exist); let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse(); existIndex = this.index(exist); for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node); let index; for (let id in this.indexes) { index = this.indexes[id]; if (existIndex < index) { this.indexes[id] = index + nodes.length; } } this.markDirty(); return this; } insertBefore(exist, add) { let existIndex = this.index(exist); let type = existIndex === 0 ? "prepend" : false; let nodes = this.normalize( add, this.proxyOf.nodes[existIndex], type ).reverse(); existIndex = this.index(exist); for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node); let index; for (let id in this.indexes) { index = this.indexes[id]; if (existIndex <= index) { this.indexes[id] = index + nodes.length; } } this.markDirty(); return this; } normalize(nodes, sample) { if (typeof nodes === "string") { nodes = cleanSource(parse2(nodes).nodes); } else if (typeof nodes === "undefined") { nodes = []; } else if (Array.isArray(nodes)) { nodes = nodes.slice(0); for (let i of nodes) { if (i.parent) i.parent.removeChild(i, "ignore"); } } else if (nodes.type === "root" && this.type !== "document") { nodes = nodes.nodes.slice(0); for (let i of nodes) { if (i.parent) i.parent.removeChild(i, "ignore"); } } else if (nodes.type) { nodes = [nodes]; } else if (nodes.prop) { if (typeof nodes.value === "undefined") { throw new Error("Value field is missed in node creation"); } else if (typeof nodes.value !== "string") { nodes.value = String(nodes.value); } nodes = [new Declaration2(nodes)]; } else if (nodes.selector || nodes.selectors) { nodes = [new Rule3(nodes)]; } else if (nodes.name) { nodes = [new AtRule2(nodes)]; } else if (nodes.text) { nodes = [new Comment2(nodes)]; } else { throw new Error("Unknown node type in node creation"); } let processed = nodes.map((i) => { if (!i[my]) _Container.rebuild(i); i = i.proxyOf; if (i.parent) i.parent.removeChild(i); if (i[isClean]) markTreeDirty(i); if (!i.raws) i.raws = {}; if (typeof i.raws.before === "undefined") { if (sample && typeof sample.raws.before !== "undefined") { i.raws.before = sample.raws.before.replace(/\S/g, ""); } } i.parent = this.proxyOf; return i; }); return processed; } prepend(...children) { children = children.reverse(); for (let child of children) { let nodes = this.normalize(child, this.first, "prepend").reverse(); for (let node of nodes) this.proxyOf.nodes.unshift(node); for (let id in this.indexes) { this.indexes[id] = this.indexes[id] + nodes.length; } } this.markDirty(); return this; } push(child) { child.parent = this; this.proxyOf.nodes.push(child); return this; } removeAll() { for (let node of this.proxyOf.nodes) node.parent = void 0; this.proxyOf.nodes = []; this.markDirty(); return this; } removeChild(child) { child = this.index(child); this.proxyOf.nodes[child].parent = void 0; this.proxyOf.nodes.splice(child, 1); let index; for (let id in this.indexes) { index = this.indexes[id]; if (index >= child) { this.indexes[id] = index - 1; } } this.markDirty(); return this; } replaceValues(pattern, opts, callback) { if (!callback) { callback = opts; opts = {}; } this.walkDecls((decl2) => { if (opts.props && !opts.props.includes(decl2.prop)) return; if (opts.fast && !decl2.value.includes(opts.fast)) return; decl2.value = decl2.value.replace(pattern, callback); }); this.markDirty(); return this; } some(condition) { return this.nodes.some(condition); } walk(callback) { return this.each((child, i) => { let result; try { result = callback(child, i); } catch (e) { throw child.addToError(e); } if (result !== false && child.walk) { result = child.walk(callback); } return result; }); } walkAtRules(name, callback) { if (!callback) { callback = name; return this.walk((child, i) => { if (child.type === "atrule") { return callback(child, i); }