import "../../chunks/chunk.QU3DSPNU.js";
function parseColorValue(value, context, level) {
  if (value === "transparent" || value === "currentColor" || value === "inherit") {
    return value;
  }
  const [colorName, transparency] = value.split("/");
  let colorVar;
  if (level && context === "background") {
    colorVar = `var(--gds-sys-color-l${level}-${colorName})`;
  } else {
    colorVar = `var(--gds-sys-color-${context}-${colorName})`;
  }
  return transparency ? `color-mix(in srgb, ${colorVar} ${parseFloat(transparency) * 100}%, transparent 0%)` : colorVar;
}
function forColorTokens(context) {
  return {
    valueTemplate: function(v) {
      return parseColorValue(v, context, this.level);
    }
  };
}
const forSpaceTokens = {
  valueTemplate: (value) => `var(--gds-sys-space-${value}, 0)`
};
const forRadiusTokens = {
  valueTemplate: (value) => `var(--gds-sys-radius-${value}, 0)`
};
const forSpaceTokensAndCustomValues = {
  valueTemplate: (value) => `var(--gds-sys-space-${sanitizeVariableName(value)}, ${value})`
};
const forSpaceTokensSupportingNegative = {
  valueTemplate: (v) => {
    const sign = v.startsWith("-") ? "neg" : "pos";
    const val = sign == "pos" ? `var(--gds-sys-space-${v})` : `calc(var(--gds-sys-space-${v.substring(1)}) * -1)`;
    return v === "auto" ? "auto" : val;
  },
  styleTemplate: (prop, values) => {
    const transformValue = (v) => v === "auto" ? "auto" : `${v}`;
    const top = transformValue(values[0]);
    const right = values.length > 1 ? transformValue(values[1]) : top;
    const bottom = values.length > 2 ? transformValue(values[2]) : top;
    const left = values.length > 3 ? transformValue(values[3]) : right;
    return `${prop}: ${top} ${right} ${bottom} ${left};`;
  }
};
function sanitizeVariableName(name) {
  return name.replace(/[^a-zA-Z0-9-]/g, "");
}
export {
  forColorTokens,
  forRadiusTokens,
  forSpaceTokens,
  forSpaceTokensAndCustomValues,
  forSpaceTokensSupportingNegative,
  parseColorValue
};
