var w = new Uint8Array(256);
function I(e, n) {
  let t = 0, r = [], a = 0, l = e.length, i = n.charCodeAt(0);
  for (let o = 0; o < l; o++) {
    let u = e.charCodeAt(o);
    if (t === 0 && u === i) {
      r.push(e.slice(a, o)), a = o + 1;
      continue;
    }
    switch (u) {
      case 92:
        o += 1;
        break;
      case 39:
      case 34:
        for (; ++o < l; ) {
          let s = e.charCodeAt(o);
          if (s === 92) {
            o += 1;
            continue;
          }
          if (s === u) break;
        }
        break;
      case 40:
        w[t] = 41, t++;
        break;
      case 91:
        w[t] = 93, t++;
        break;
      case 123:
        w[t] = 125, t++;
        break;
      case 93:
      case 125:
      case 41:
        t > 0 && u === w[t - 1] && t--;
        break;
    }
  }
  return r.push(e.slice(a)), r;
}
var m = class extends Map {
  constructor(e) {
    super(), this.factory = e;
  }
  get(e) {
    let n = super.get(e);
    return n === void 0 && (n = this.factory(e, this), this.set(e, n)), n;
  }
};
function f(e) {
  return { kind: "word", value: e };
}
function P(e, n) {
  return { kind: "function", value: e, nodes: n };
}
function V(e) {
  return { kind: "separator", value: e };
}
function b(e) {
  let n = "";
  for (let t of e) switch (t.kind) {
    case "word":
    case "separator": {
      n += t.value;
      break;
    }
    case "function":
      n += t.value + "(" + b(t.nodes) + ")";
  }
  return n;
}
var S = 92, q = 41, E = 58, x = 44, J = 34, N = 61, R = 62, T = 60, W = 10, M = 40, z = 39, F = 47, _ = 32, j = 9;
function A(e) {
  e = e.replaceAll(`\r
`, `
`);
  let n = [], t = [], r = null, a = "", l;
  for (let i = 0; i < e.length; i++) {
    let o = e.charCodeAt(i);
    switch (o) {
      case S: {
        a += e[i] + e[i + 1], i++;
        break;
      }
      case F: {
        if (a.length > 0) {
          let s = f(a);
          r ? r.nodes.push(s) : n.push(s), a = "";
        }
        let u = f(e[i]);
        r ? r.nodes.push(u) : n.push(u);
        break;
      }
      case E:
      case x:
      case N:
      case R:
      case T:
      case W:
      case _:
      case j: {
        if (a.length > 0) {
          let g = f(a);
          r ? r.nodes.push(g) : n.push(g), a = "";
        }
        let u = i, s = i + 1;
        for (; s < e.length && (l = e.charCodeAt(s), !(l !== E && l !== x && l !== N && l !== R && l !== T && l !== W && l !== _ && l !== j)); s++) ;
        i = s - 1;
        let c = V(e.slice(u, s));
        r ? r.nodes.push(c) : n.push(c);
        break;
      }
      case z:
      case J: {
        let u = i;
        for (let s = i + 1; s < e.length; s++) if (l = e.charCodeAt(s), l === S) s += 1;
        else if (l === o) {
          i = s;
          break;
        }
        a += e.slice(u, i + 1);
        break;
      }
      case M: {
        let u = P(a, []);
        a = "", r ? r.nodes.push(u) : n.push(u), t.push(u), r = u;
        break;
      }
      case q: {
        let u = t.pop();
        if (a.length > 0) {
          let s = f(a);
          u?.nodes.push(s), a = "";
        }
        t.length > 0 ? r = t[t.length - 1] : r = null;
        break;
      }
      default:
        a += String.fromCharCode(o);
    }
  }
  return a.length > 0 && n.push(f(a)), n;
}
var C = ((e) => (e[e.Continue = 0] = "Continue", e[e.Skip = 1] = "Skip", e[e.Stop = 2] = "Stop", e[e.Replace = 3] = "Replace", e[e.ReplaceSkip = 4] = "ReplaceSkip", e[e.ReplaceStop = 5] = "ReplaceStop", e))(C || {}), k = { Continue: { kind: 0 }, Skip: { kind: 1 }, Stop: { kind: 2 }, Replace: (e) => ({ kind: 3, nodes: Array.isArray(e) ? e : [e] }), ReplaceSkip: (e) => ({ kind: 4, nodes: Array.isArray(e) ? e : [e] }), ReplaceStop: (e) => ({ kind: 5, nodes: Array.isArray(e) ? e : [e] }) };
function y(e, n) {
  typeof n == "function" ? U(e, n) : U(e, n.enter, n.exit);
}
function U(e, n = () => k.Continue, t = () => k.Continue) {
  let r = [[e, 0, null]], a = { parent: null, depth: 0, path() {
    let l = [];
    for (let i = 1; i < r.length; i++) {
      let o = r[i][2];
      o && l.push(o);
    }
    return l;
  } };
  for (; r.length > 0; ) {
    let l = r.length - 1, i = r[l], o = i[0], u = i[1], s = i[2];
    if (u >= o.length) {
      r.pop();
      continue;
    }
    if (a.parent = s, a.depth = l, u >= 0) {
      let p = o[u], d = n(p, a) ?? k.Continue;
      switch (d.kind) {
        case 0: {
          p.nodes && p.nodes.length > 0 && r.push([p.nodes, 0, p]), i[1] = ~u;
          continue;
        }
        case 2:
          return;
        case 1: {
          i[1] = ~u;
          continue;
        }
        case 3: {
          o.splice(u, 1, ...d.nodes);
          continue;
        }
        case 5: {
          o.splice(u, 1, ...d.nodes);
          return;
        }
        case 4: {
          o.splice(u, 1, ...d.nodes), i[1] += d.nodes.length;
          continue;
        }
        default:
          throw new Error(`Invalid \`WalkAction.${C[d.kind] ?? `Unknown(${d.kind})`}\` in enter.`);
      }
    }
    let c = ~u, g = o[c], h = t(g, a) ?? k.Continue;
    switch (h.kind) {
      case 0:
        i[1] = c + 1;
        continue;
      case 2:
        return;
      case 3: {
        o.splice(c, 1, ...h.nodes), i[1] = c + h.nodes.length;
        continue;
      }
      case 5: {
        o.splice(c, 1, ...h.nodes);
        return;
      }
      case 4: {
        o.splice(c, 1, ...h.nodes), i[1] = c + h.nodes.length;
        continue;
      }
      default:
        throw new Error(`Invalid \`WalkAction.${C[h.kind] ?? `Unknown(${h.kind})`}\` in exit.`);
    }
  }
}
new m((e) => {
  let n = A(e), t = /* @__PURE__ */ new Set();
  return y(n, (r, a) => {
    let l = a.parent === null ? n : a.parent.nodes ?? [];
    if (r.kind === "word" && (r.value === "+" || r.value === "-" || r.value === "*" || r.value === "/")) {
      let i = l.indexOf(r) ?? -1;
      if (i === -1) return;
      let o = l[i - 1];
      if (o?.kind !== "separator" || o.value !== " ") return;
      let u = l[i + 1];
      if (u?.kind !== "separator" || u.value !== " ") return;
      t.add(o), t.add(u);
    } else r.kind === "separator" && r.value.length > 0 && r.value.trim() === "" ? (l[0] === r || l[l.length - 1] === r) && t.add(r) : r.kind === "separator" && r.value.trim() === "," && (r.value = ",");
  }), t.size > 0 && y(n, (r) => {
    if (t.has(r)) return t.delete(r), k.ReplaceSkip([]);
  }), $(n), b(n);
});
new m((e) => {
  let n = A(e);
  return n.length === 3 && n[0].kind === "word" && n[0].value === "&" && n[1].kind === "separator" && n[1].value === ":" && n[2].kind === "function" && n[2].value === "is" ? b(n[2].nodes) : e;
});
function $(e) {
  for (let n of e) switch (n.kind) {
    case "function": {
      if (n.value === "url" || n.value.endsWith("_url")) {
        n.value = v(n.value);
        break;
      }
      if (n.value === "var" || n.value.endsWith("_var") || n.value === "theme" || n.value.endsWith("_theme")) {
        n.value = v(n.value);
        for (let t = 0; t < n.nodes.length; t++) $([n.nodes[t]]);
        break;
      }
      n.value = v(n.value), $(n.nodes);
      break;
    }
    case "separator":
      n.value = v(n.value);
      break;
    case "word": {
      (n.value[0] !== "-" || n.value[1] !== "-") && (n.value = v(n.value));
      break;
    }
    default:
      K(n);
  }
}
new m((e) => {
  let n = A(e);
  return n.length === 1 && n[0].kind === "function" && n[0].value === "var";
});
function K(e) {
  throw new Error(`Unexpected value: ${e}`);
}
function v(e) {
  return e.replaceAll("_", String.raw`\_`).replaceAll(" ", "_");
}
function O(e, n) {
  if (n === null) return e;
  let t = Number(n);
  return Number.isNaN(t) || (n = `${t * 100}%`), n === "100%" ? e : `color-mix(in oklab, ${e} ${n}, transparent)`;
}
var Q = { "--alpha": Z, "--spacing": B, "--theme": H, theme: X };
function Z(e, n, t, ...r) {
  let [a, l] = I(t, "/").map((i) => i.trim());
  if (!a || !l) throw new Error(`The --alpha(…) function requires a color and an alpha value, e.g.: \`--alpha(${a || "var(--my-color)"} / ${l || "50%"})\``);
  if (r.length > 0) throw new Error(`The --alpha(…) function only accepts one argument, e.g.: \`--alpha(${a || "var(--my-color)"} / ${l || "50%"})\``);
  return O(a, l);
}
function B(e, n, t, ...r) {
  if (!t) throw new Error("The --spacing(…) function requires an argument, but received none.");
  if (r.length > 0) throw new Error(`The --spacing(…) function only accepts a single argument, but received ${r.length + 1}.`);
  let a = e.theme.resolve(null, ["--spacing"]);
  if (!a) throw new Error("The --spacing(…) function requires that the `--spacing` theme variable exists, but it was not found.");
  return `calc(${a} * ${t})`;
}
function H(e, n, t, ...r) {
  if (!t.startsWith("--")) throw new Error("The --theme(…) function can only be used with CSS variables from your theme.");
  let a = !1;
  t.endsWith(" inline") && (a = !0, t = t.slice(0, -7)), n.kind === "at-rule" && (a = !0);
  let l = e.resolveThemeValue(t, a);
  if (!l) {
    if (r.length > 0) return r.join(", ");
    throw new Error(`Could not resolve value for theme function: \`theme(${t})\`. Consider checking if the variable name is correct or provide a fallback value to silence this error.`);
  }
  if (r.length === 0) return l;
  let i = r.join(", ");
  if (i === "initial") return l;
  if (l === "initial") return i;
  if (l.startsWith("var(") || l.startsWith("theme(") || l.startsWith("--theme(")) {
    let o = A(l);
    return G(o, i), b(o);
  }
  return l;
}
function X(e, n, t, ...r) {
  t = D(t);
  let a = e.resolveThemeValue(t);
  if (!a && r.length > 0) return r.join(", ");
  if (!a) throw new Error(`Could not resolve value for theme function: \`theme(${t})\`. Consider checking if the path is correct or provide a fallback value to silence this error.`);
  return a;
}
new RegExp(Object.keys(Q).map((e) => `${e}\\(`).join("|"));
function D(e) {
  if (e[0] !== "'" && e[0] !== '"') return e;
  let n = "", t = e[0];
  for (let r = 1; r < e.length - 1; r++) {
    let a = e[r], l = e[r + 1];
    a === "\\" && (l === t || l === "\\") ? (n += l, r++) : n += a;
  }
  return n;
}
function G(e, n) {
  y(e, (t) => {
    if (t.kind === "function" && !(t.value !== "var" && t.value !== "theme" && t.value !== "--theme")) if (t.nodes.length === 1) t.nodes.push({ kind: "word", value: `, ${n}` });
    else {
      let r = t.nodes[t.nodes.length - 1];
      r.kind === "word" && r.value === "initial" && (r.value = n);
    }
  });
}
var L = /^(?<value>[-+]?(?:\d*\.)?\d+)(?<unit>[a-z]+|%)?$/i;
new m((e) => {
  let n = L.exec(e);
  if (!n) return null;
  let t = n.groups?.value;
  if (t === void 0) return null;
  let r = Number(t);
  if (Number.isNaN(r)) return null;
  let a = n.groups?.unit;
  return a === void 0 ? [r, null] : [r, a];
});
var Y = ((e) => (e[e.None = 0] = "None", e[e.AtProperty = 1] = "AtProperty", e[e.ColorMix = 2] = "ColorMix", e[e.All = 3] = "All", e))(Y || {}), ee = ((e) => (e[e.None = 0] = "None", e[e.AtApply = 1] = "AtApply", e[e.AtImport = 2] = "AtImport", e[e.JsPluginCompat = 4] = "JsPluginCompat", e[e.ThemeFunction = 8] = "ThemeFunction", e[e.Utilities = 16] = "Utilities", e[e.Variants = 32] = "Variants", e[e.AtTheme = 64] = "AtTheme", e))(ee || {});
