// ============================================================================
// Design Tokens SCSS Functions - 由 Terrazzo 自动生成
// ============================================================================
// 此文件包含所有设计令牌的 SCSS 函数
// 请勿手动编辑此文件
// ============================================================================

@use "sass:string";
@use "sass:map";
@use "sass:meta";
@use "sass:list";
@use "sass:math";

// ============================================================================
// COLORS FUNCTIONS
// ============================================================================

// 颜色工具函数 - 与 CSS-in-JS API 完全一致

/// 颜色辅助函数 - 与 CSS-in-JS color() 完全一致
/// @param {String} $path - 颜色路径，如 'blue.500' 或 'text.secondary'
/// @param {Number} $alpha - 可选透明度值 (0-1)，会覆盖 token 自带的 alpha
/// @param {String} $mode - 可选主题模式 (SCSS 中暂不支持，保留兼容性)
/// @return {String} rgba(var(--cdt-color-xxx), alpha) 格式
/// @example scss - 使用示例
///   .button {
///     background: color("blue.500");
///     color: color("text.secondary", 0.8);
///   }
@function color($path, $alpha: null, $mode: ".") {
  @if not $path or $path == "" {
    @warn "[design-tokens] Invalid color path: #{$path}";
    @return rgba(0, 0, 0, if($alpha != null, $alpha, 1));
  }

  $token-path: if(string.index($path, "color.") == 1, $path, "color.#{$path}");
  
  @if not _color-exists($path) {
    @warn "[design-tokens] Color token '#{$path}' (#{$token-path}:#{$mode}) not found";
    @return rgba(0, 0, 0, if($alpha != null, $alpha, 1));
  }

  $css-var-name: str-replace($token-path, ".", "-");
  $css-var: "--cdt-#{$css-var-name}";
  
  // 确定最终的 alpha 值
  $final-alpha: null;
  
  // 如果用户提供了 alpha 值，使用用户的值
  @if $alpha != null {
    $final-alpha: clamp(0, $alpha, 1);
  }
  // 否则从 token 的默认 alpha 值中获取
  @else {
    $final-alpha: _get-color-alpha($path);
  }
  
  @return rgba(var(#{$css-var}), #{$final-alpha});
}

/// 获取原始颜色 CSS 变量（不包装 rgba）- 与 CSS-in-JS colorVar() 一致
/// @param {String} $path - 颜色路径
/// @return {String} CSS 变量
@function color-var($path) {
  $token-path: if(string.index($path, "color.") == 1, $path, "color.#{$path}");
  $css-var-name: str-replace($token-path, ".", "-");
  @return var(--cdt-#{$css-var-name});
}

/// 检查颜色 token 是否存在 - 与 CSS-in-JS hasColor() 一致
/// @param {String} $path - 颜色路径
/// @param {String} $mode - 主题模式（保留兼容性）
/// @return {Boolean} 是否存在
@function has-color($path, $mode: ".") {
  @if not $path or $path == "" {
    @return false;
  }
  @return _color-exists($path);
}

// ============================================================================
// 辅助函数
// ============================================================================

/// 字符串替换函数
/// @param {String} $string - 原字符串
/// @param {String} $search - 搜索字符串
/// @param {String} $replace - 替换字符串
/// @return {String} 替换后的字符串
/// @access private
@function str-replace($string, $search, $replace: "") {
  $index: string.index($string, $search);
  @if $index {
    @return string.slice($string, 1, $index - 1) + $replace + str-replace(string.slice($string, $index + string.length($search)), $search, $replace);
  }
  @return $string;
}

/// 获取颜色的默认 alpha 值
/// @param {String} $path - 颜色路径
/// @return {Number} alpha 值
/// @access private
@function _get-color-alpha($path) {
  // 颜色 alpha 映射表
  $color-alpha-map: (
    "text.on-accent-secondary": 0.8,
    "text.on-accent-tertiary": 0.4,
    "text.default": 0.9,
    "text.secondary": 0.5,
    "text.disabled": 0.3,
    "text.tertiary": 0.3
  );
  
  // 查找并返回 alpha 值，如果没有则返回 1
  @if map.has-key($color-alpha-map, $path) {
    @return map.get($color-alpha-map, $path);
  }
  @return 1;
}

/// 检查颜色是否存在
/// @param {String} $path - 颜色路径
/// @return {Boolean} 是否存在
/// @access private
@function _color-exists($path) {
  $valid-colors: (
    "blue.100",
    "blue.200",
    "blue.300",
    "blue.400",
    "blue.500",
    "blue.600",
    "blue.700",
    "blue.800",
    "blue.900",
    "blue.950",
    "violet.100",
    "violet.200",
    "violet.300",
    "violet.400",
    "violet.500",
    "violet.600",
    "violet.700",
    "violet.800",
    "violet.900",
    "violet.950",
    "purple.100",
    "purple.200",
    "purple.300",
    "purple.400",
    "purple.500",
    "purple.600",
    "purple.700",
    "purple.800",
    "purple.900",
    "purple.950",
    "pink.100",
    "pink.200",
    "pink.300",
    "pink.400",
    "pink.500",
    "pink.600",
    "pink.700",
    "pink.800",
    "pink.900",
    "pink.950",
    "teal.100",
    "teal.200",
    "teal.300",
    "teal.400",
    "teal.500",
    "teal.600",
    "teal.700",
    "teal.800",
    "teal.900",
    "teal.950",
    "red.100",
    "red.200",
    "red.300",
    "red.400",
    "red.500",
    "red.600",
    "red.700",
    "red.800",
    "red.900",
    "red.950",
    "orange.100",
    "orange.200",
    "orange.300",
    "orange.400",
    "orange.500",
    "orange.600",
    "orange.700",
    "orange.800",
    "orange.900",
    "orange.950",
    "yellow.100",
    "yellow.200",
    "yellow.300",
    "yellow.400",
    "yellow.500",
    "yellow.600",
    "yellow.700",
    "yellow.800",
    "yellow.900",
    "yellow.950",
    "green.100",
    "green.200",
    "green.300",
    "green.400",
    "green.500",
    "green.600",
    "green.700",
    "green.800",
    "green.900",
    "green.950",
    "blue-pale.100",
    "blue-pale.200",
    "blue-pale.300",
    "blue-pale.400",
    "blue-pale.500",
    "blue-pale.600",
    "blue-pale.700",
    "blue-pale.800",
    "blue-pale.900",
    "blue-pale.950",
    "violet-pale.100",
    "violet-pale.200",
    "violet-pale.300",
    "violet-pale.400",
    "violet-pale.500",
    "violet-pale.600",
    "violet-pale.700",
    "violet-pale.800",
    "violet-pale.900",
    "violet-pale.950",
    "purple-pale.100",
    "purple-pale.200",
    "purple-pale.300",
    "purple-pale.400",
    "purple-pale.500",
    "purple-pale.600",
    "purple-pale.700",
    "purple-pale.800",
    "purple-pale.900",
    "purple-pale.950",
    "pink-pale.100",
    "pink-pale.200",
    "pink-pale.300",
    "pink-pale.400",
    "pink-pale.500",
    "pink-pale.600",
    "pink-pale.700",
    "pink-pale.800",
    "pink-pale.900",
    "pink-pale.950",
    "teal-pale.100",
    "teal-pale.200",
    "teal-pale.300",
    "teal-pale.400",
    "teal-pale.500",
    "teal-pale.600",
    "teal-pale.700",
    "teal-pale.800",
    "teal-pale.900",
    "teal-pale.950",
    "red-pale.100",
    "red-pale.200",
    "red-pale.300",
    "red-pale.400",
    "red-pale.500",
    "red-pale.600",
    "red-pale.700",
    "red-pale.800",
    "red-pale.900",
    "red-pale.950",
    "orange-pale.100",
    "orange-pale.200",
    "orange-pale.300",
    "orange-pale.400",
    "orange-pale.500",
    "orange-pale.600",
    "orange-pale.700",
    "orange-pale.800",
    "orange-pale.900",
    "orange-pale.950",
    "yellow-pale.100",
    "yellow-pale.200",
    "yellow-pale.300",
    "yellow-pale.400",
    "yellow-pale.500",
    "yellow-pale.600",
    "yellow-pale.700",
    "yellow-pale.800",
    "yellow-pale.900",
    "yellow-pale.950",
    "green-pale.100",
    "green-pale.200",
    "green-pale.300",
    "green-pale.400",
    "green-pale.500",
    "green-pale.600",
    "green-pale.700",
    "green-pale.800",
    "green-pale.900",
    "green-pale.950",
    "white",
    "black",
    "gray.50",
    "gray.100",
    "gray.200",
    "gray.300",
    "gray.400",
    "gray.500",
    "gray.600",
    "gray.700",
    "gray.800",
    "gray.900",
    "gray.950",
    "text.on-accent",
    "text.on-accent-secondary",
    "text.on-accent-tertiary",
    "text.default",
    "text.secondary",
    "text.disabled",
    "text.tertiary",
    "text.accent",
    "text.success",
    "text.warning",
    "text.danger",
    "text.assistive",
    "text.component",
    "text.inverse",
    "background.accent",
    "background.accent-hover",
    "background.accent-secondary",
    "background.success",
    "background.success-hover",
    "background.success-secondary",
    "background.warning",
    "background.warning-hover",
    "background.warning-secondary",
    "background.danger",
    "background.danger-hover",
    "background.danger-secondary",
    "background.assistive",
    "background.assistive-hover",
    "background.assistive-secondary",
    "background.component",
    "background.component-hover",
    "background.component-secondary",
    "background.menu",
    "background.toolbar",
    "background.default",
    "background.secondary",
    "background.tertiary",
    "background.selected",
    "background.hover",
    "background.disabled",
    "background.inverse",
    "border.selected",
    "border.menu",
    "border.toolbar",
    "border.default",
    "border.strong",
    "border.selected-strong",
    "icon.default",
    "icon.secondary",
    "icon.tertiary",
    "icon.disabled"
  );
  @return list.index($valid-colors, $path) != null;
}

/// 列出所有可用颜色
/// @return {List} 颜色名称列表
/// @access private
@function _list-colors() {
  @return (
    "blue.100",
    "blue.200",
    "blue.300",
    "blue.400",
    "blue.500",
    "blue.600",
    "blue.700",
    "blue.800",
    "blue.900",
    "blue.950",
    // ... 共 244 个颜色
  );
}

// ============================================================================
// SPACING FUNCTIONS
// ============================================================================

// ============================================================================
// Spacing 工具函数 - 与 CSS-in-JS API 完全一致
// ============================================================================

/// 解析分数字符串为百分比
/// @param {String} $fraction - 分数字符串，如 '1/2', '2/3'
/// @return {String} 百分比字符串
/// @access private
@function _parse-fraction($fraction) {
  // 简单分数映射，避免复杂的字符串解析
  $fractions: (
    "1/2": 50%,
    "1/3": 33.333333%,
    "2/3": 66.666667%,
    "1/4": 25%,
    "3/4": 75%,
    "1/5": 20%,
    "2/5": 40%,
    "3/5": 60%,
    "4/5": 80%,
    "1/6": 16.666667%,
    "5/6": 83.333333%,
    "1/12": 8.333333%,
    "5/12": 41.666667%,
    "7/12": 58.333333%,
    "11/12": 91.666667%
  );
  
  @if map.has-key($fractions, $fraction) {
    @return map.get($fractions, $fraction);
  }
  
  @error "无效的分数格式: '#{$fraction}'. 支持的分数: #{map.keys($fractions)}";
}

/// 检查断点是否存在
/// @param {String} $name - 断点名称
/// @return {Boolean} 是否存在
/// @access private
@function _breakpoint-exists($name) {
  $valid-breakpoints: (
    "xs",
    "sm",
    "md",
    "lg",
    "xl",
    "2xl"
  );
  @return list.index($valid-breakpoints, $name) != null;
}

/// 获取间距值 - 与 CSS-in-JS spacing() 完全一致
/// @param {String|Number} $size - 间距大小，支持预设值、任意数值、分数、断点值或任意值
/// @return {String} 计算后的间距值
/// @example scss - 使用示例
///   .button {
///     padding: spacing(4);        // calc(var(--cdt-spacing) * 4)
///     margin: spacing(0);         // 0
///     border: spacing("px");      // var(--cdt-spacing-px)
///     width: spacing("1/2");      // 50%
///     max-width: spacing("md");   // var(--cdt-breakpoints-md)
///   }
@function spacing($size) {
  // 特殊值直接返回
  @if $size == 0 {
    @return 0;
  }

  // 处理任意值 [value]
  @if meta.type-of($size) == string {
    @if string.index($size, "[") == 1 and string.index($size, "]") == string.length($size) {
      @return string.slice($size, 2, -2);
    }
  }

  // 处理分数 1/2, 2/3 等
  @if meta.type-of($size) == string and string.index($size, "/") {
    @return _parse-fraction($size);
  }

  // 处理 "px" 特殊值
  @if $size == "px" {
    @return var(--cdt-spacing-px);
  }

  // 处理断点值
  @if meta.type-of($size) == string and _breakpoint-exists($size) {
    @return var(--cdt-breakpoints-#{$size});
  }

  // 处理数字值
  @if meta.type-of($size) == number {
    @if $size == 1 {
      @return var(--cdt-spacing);
    } @else {
      @return calc(var(--cdt-spacing) * #{$size});
    }
  }

  // 如果是字符串，尝试作为数字解析
  @if meta.type-of($size) == string {
    // 在 SCSS 中无法动态解析数字字符串，直接错误处理
    @error "spacing() 无法解析字符串数字 '#{$size}'，请使用数字类型";
  }

  $available-breakpoints: (
    "xs",
    "sm",
    "md",
    "lg",
    "xl",
    "2xl",
  );
  @error "spacing() 参数错误: '#{$size}' 不是有效的间距值.\A" +
         "支持的格式:\A" +
         "• 数字: 0, 4, 16 等\A" +
         "• 分数值: \"1/2\", \"1/3\", \"2/3\" 等\A" +
         "• 任意值: \"[10vh]\", \"[calc(100%-1rem)]\" 等\A" +
         "• 特殊值: \"px\"\A" +
         "• 断点值: #{$available-breakpoints}";
}

/// 批量获取间距值（用于 padding, margin 简写）- 与 CSS-in-JS spacingList() 一致
/// @param {List} $sizes - 间距大小列表
/// @return {String} 计算后的间距值字符串
/// @example scss - 使用示例
///   .card {
///     padding: spacing-list(4, 6, 2, 8);
///   }
@function spacing-list($sizes...) {
  $result: ();
  @each $size in $sizes {
    $result: list.append($result, spacing($size));
  }
  @return $result;
}

/// 检查是否为有效的间距值 - 与 CSS-in-JS spacingExists() 一致
/// @param {String|Number} $size - 间距大小
/// @return {Boolean} 是否为有效值
@function spacing-exists($size) {
  // 数值检查
  @if meta.type-of($size) == number {
    @return true;
  }

  @if meta.type-of($size) == string {
    // 任意值检查
    @if string.index($size, "[") == 1 and string.index($size, "]") == string.length($size) {
      @return true;
    }

    // 分数检查
    @if string.index($size, "/") {
      $valid-fractions: ("1/2", "1/3", "2/3", "1/4", "3/4", "1/5", "2/5", "3/5", "4/5", "1/6", "5/6", "1/12", "5/12", "7/12", "11/12");
      @return list.index($valid-fractions, $size) != null;
    }

    // 特殊值检查
    @if $size == "px" {
      @return true;
    }

    // 断点值检查
    @if _breakpoint-exists($size) {
      @return true;
    }
  }

  @return false;
}

// ============================================================================
// OTHER FUNCTIONS
// ============================================================================

// ============================================================================
// 其他工具函数 - 与 CSS-in-JS API 完全一致
// ============================================================================

// ============================================================================
// Radius Helper Functions - 圆角辅助函数
// ============================================================================

/// 获取圆角值 - 与 CSS-in-JS radius() 完全一致
/// @param {String} $name - 圆角名称
/// @param {String} $mode - 主题模式（保留兼容性）
/// @return {String} CSS 圆角变量
/// @example scss - 使用示例
///   .card {
///     border-radius: radius("md");
///   }
@function radius($name, $mode: ".") {
  @if not _radius-exists($name) {
    @error "Radius '#{$name}' not found. Available radius values: #{_list-radius()}";
  }
  @return var(--cdt-radius-#{$name});
}

/// 批量获取多个圆角值 - 与 CSS-in-JS radiusList() 一致
/// @param {String...} $names - 圆角名称列表
/// @return {List} CSS 圆角变量列表
@function radius-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, radius($name));
  }
  @return $result;
}

// ============================================================================
// Shadow Helper Functions - 阴影辅助函数
// ============================================================================

/// 获取阴影样式 - 与 CSS-in-JS shadow() 完全一致
/// @param {String} $name - 阴影名称
/// @param {String} $mode - 主题模式（保留兼容性）
/// @return {String} CSS 阴影变量
/// @example scss - 使用示例
///   .card {
///     box-shadow: shadow("md");
///   }
@function shadow($name, $mode: ".") {
  @if not _shadow-exists($name) {
    @error "Shadow '#{$name}' not found. Available shadows: #{_list-shadows()}";
  }
  @return var(--cdt-shadows-#{$name});
}

/// 批量获取多个阴影样式 - 与 CSS-in-JS shadowList() 一致
/// @param {String...} $names - 阴影名称列表
/// @return {List} CSS 阴影变量列表
@function shadow-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, shadow($name));
  }
  @return $result;
}

// ============================================================================
// Z-Index Helper Functions - 层级辅助函数
// ============================================================================

/// 获取 z-index CSS 变量 - 与 CSS-in-JS zIndex() 完全一致
/// @param {String} $name - z-index 名称
/// @param {String} $mode - 主题模式（保留兼容性）
/// @return {String} CSS z-index 变量
/// @example scss - 使用示例
///   .modal {
///     z-index: z-index("modal");
///   }
@function z-index($name, $mode: ".") {
  @if not _zindex-exists($name) {
    @error "Z-index '#{$name}' not found. Available z-index values: #{_list-zindex()}";
  }
  @return var(--cdt-zindex-#{$name});
}

/// 批量获取多个 z-index CSS 变量 - 与 CSS-in-JS zIndexList() 一致
/// @param {String...} $names - z-index 名称列表
/// @return {List} CSS z-index 变量列表
@function z-index-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, z-index($name));
  }
  @return $result;
}

// ============================================================================
// 辅助函数
// ============================================================================

/// 检查圆角是否存在
/// @param {String} $name - 圆角名称
/// @return {Boolean} 是否存在
/// @access private
@function _radius-exists($name) {
  $valid-radius: (
    "sm",
    "md",
    "lg",
    "xl"
  );
  @return list.index($valid-radius, $name) != null;
}

/// 列出所有可用圆角
/// @return {List} 圆角名称列表
/// @access private
@function _list-radius() {
  @return (
    "sm",
    "md",
    "lg",
    "xl",
  );
}

/// 检查阴影是否存在
/// @param {String} $name - 阴影名称
/// @return {Boolean} 是否存在
/// @access private
@function _shadow-exists($name) {
  $valid-shadows: (
    "xxs",
    "xs",
    "sm",
    "md",
    "lg",
    "xl",
    "focus",
    "line",
    "border-default",
    "border-default-inset"
  );
  @return list.index($valid-shadows, $name) != null;
}

/// 列出所有可用阴影
/// @return {List} 阴影名称列表
/// @access private
@function _list-shadows() {
  @return (
    "xxs",
    "xs",
    "sm",
    "md",
    "lg",
    "xl",
    "focus",
    "line",
    // ... 共 10 个阴影
  );
}

/// 检查 z-index 是否存在
/// @param {String} $name - z-index 名称
/// @return {Boolean} 是否存在
/// @access private
@function _zindex-exists($name) {
  $valid-zindex: (
    "sticky",
    "fixed",
    "backdrop",
    "modals",
    "popover",
    "menu",
    "alert",
    "tooltip",
    "notification",
    "scroll-bar"
  );
  @return list.index($valid-zindex, $name) != null;
}

/// 列出所有可用 z-index
/// @return {List} z-index 名称列表
/// @access private
@function _list-zindex() {
  @return (
    "sticky",
    "fixed",
    "backdrop",
    "modals",
    "popover",
    "menu",
    "alert",
    "tooltip",
    "notification",
    "scroll-bar",
  );
}

// ============================================================================
// TYPOGRAPHY FUNCTIONS
// ============================================================================


// ============================================================================
// TYPOGRAPHY FUNCTIONS
// ============================================================================

// ============================================================================
// Typography 工具函数 - 与 CSS-in-JS API 完全一致
// ============================================================================

// ============================================================================
// Font Family Functions - 字体族函数
// ============================================================================

/// 获取字体族 - 与 CSS-in-JS fontFamily() 完全一致
/// @param {String} $name - 字体族名称
/// @return {String} CSS 字体族变量
/// @example scss - 使用示例
///   .heading {
///     font-family: font-family("display");
///   }
@function font-family($name) {
  @if not _font-family-exists($name) {
    @error "Font family '#{$name}' not found. Available font families: #{_list-font-families()}";
  }
  @return var(--cdt-font-families-#{$name});
}

/// 批量获取多个字体族 - 与 CSS-in-JS fontFamilyList() 一致
/// @param {String...} $names - 字体族名称列表
/// @return {List} CSS 字体族变量列表
@function font-family-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, font-family($name));
  }
  @return $result;
}

// ============================================================================
// Font Weight Functions - 字体重量函数
// ============================================================================

/// 获取字体重量 - 与 CSS-in-JS fontWeight() 完全一致
/// @param {String} $name - 字体重量名称
/// @return {String} CSS 字体重量变量
/// @example scss - 使用示例
///   .bold {
///     font-weight: font-weight("strong");
///   }
@function font-weight($name) {
  @if not _font-weight-exists($name) {
    @error "Font weight '#{$name}' not found. Available font weights: #{_list-font-weights()}";
  }
  @return var(--cdt-font-weights-#{$name});
}

/// 批量获取多个字体重量 - 与 CSS-in-JS fontWeightList() 一致
/// @param {String...} $names - 字体重量名称列表
/// @return {List} CSS 字体重量变量列表
@function font-weight-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, font-weight($name));
  }
  @return $result;
}

// ============================================================================
// Font Size Functions - 字体大小函数
// ============================================================================

/// 获取字体大小 - 与 CSS-in-JS fontSize() 完全一致
/// @param {String} $name - 字体大小名称
/// @return {String} CSS 字体大小变量
/// @example scss - 使用示例
///   .large {
///     font-size: font-size("lg");
///   }
@function font-size($name) {
  @if not _font-size-exists($name) {
    @error "Font size '#{$name}' not found. Available font sizes: #{_list-font-sizes()}";
  }
  @return var(--cdt-font-sizes-#{$name});
}

/// 批量获取多个字体大小 - 与 CSS-in-JS fontSizeList() 一致
/// @param {String...} $names - 字体大小名称列表
/// @return {List} CSS 字体大小变量列表
@function font-size-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, font-size($name));
  }
  @return $result;
}

// ============================================================================
// Line Height Functions - 行高函数
// ============================================================================

/// 获取行高 - 与 CSS-in-JS lineHeight() 完全一致
/// @param {String} $name - 行高名称
/// @return {String} CSS 行高变量
/// @example scss - 使用示例
///   .relaxed {
///     line-height: line-height("relaxed");
///   }
@function line-height($name) {
  @if not _line-height-exists($name) {
    @error "Line height '#{$name}' not found. Available line heights: #{_list-line-heights()}";
  }
  @return var(--cdt-font-line-heights-#{$name});
}

/// 批量获取多个行高 - 与 CSS-in-JS lineHeightList() 一致
/// @param {String...} $names - 行高名称列表
/// @return {List} CSS 行高变量列表
@function line-height-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, line-height($name));
  }
  @return $result;
}

// ============================================================================
// Letter Spacing Functions - 字符间距函数
// ============================================================================

/// 获取字符间距 - 与 CSS-in-JS letterSpacing() 完全一致
/// @param {String} $name - 字符间距名称
/// @return {String} CSS 字符间距变量
/// @example scss - 使用示例
///   .spaced {
///     letter-spacing: letter-spacing("body-large");
///   }
@function letter-spacing($name) {
  @if not _letter-spacing-exists($name) {
    @error "Letter spacing '#{$name}' not found. Available letter spacings: #{_list-letter-spacings()}";
  }
  @return var(--cdt-font-letter-spacings-#{$name});
}

/// 批量获取多个字符间距 - 与 CSS-in-JS letterSpacingList() 一致
/// @param {String...} $names - 字符间距名称列表
/// @return {List} CSS 字符间距变量列表
@function letter-spacing-list($names...) {
  $result: ();
  @each $name in $names {
    $result: list.append($result, letter-spacing($name));
  }
  @return $result;
}

// ============================================================================
// 辅助函数
// ============================================================================

/// 检查字体族是否存在
/// @param {String} $name - 字体族名称
/// @return {Boolean} 是否存在
/// @access private
@function _font-family-exists($name) {
  $valid-families: ("default",
    "display",
    "mono");
  @return list.index($valid-families, $name) != null;
}

/// 列出所有可用字体族
/// @return {List} 字体族名称列表
/// @access private
@function _list-font-families() {
  @return ("default",
    "display",
    "mono");
}

/// 检查字体重量是否存在
/// @param {String} $name - 字体重量名称
/// @return {Boolean} 是否存在
/// @access private
@function _font-weight-exists($name) {
  $valid-weights: ("light",
    "default",
    "medium",
    "semibold",
    "strong",
    "heavy");
  @return list.index($valid-weights, $name) != null;
}

/// 列出所有可用字体重量
/// @return {List} 字体重量名称列表
/// @access private
@function _list-font-weights() {
  @return ("light",
    "default",
    "medium",
    "semibold",
    "strong",
    "heavy");
}

/// 检查字体大小是否存在
/// @param {String} $name - 字体大小名称
/// @return {Boolean} 是否存在
/// @access private
@function _font-size-exists($name) {
  $valid-sizes: ("xs",
    "sm",
    "md",
    "lg",
    "xl",
    "2xl");
  @return list.index($valid-sizes, $name) != null;
}

/// 列出所有可用字体大小
/// @return {List} 字体大小名称列表
/// @access private
@function _list-font-sizes() {
  @return ("xs",
    "sm",
    "md",
    "lg",
    "xl",
    "2xl");
}

/// 检查行高是否存在
/// @param {String} $name - 行高名称
/// @return {Boolean} 是否存在
/// @access private
@function _line-height-exists($name) {
  $valid-line-heights: ("tight",
    "snug",
    "normal",
    "relaxed",
    "loose",
    "extra-loose");
  @return list.index($valid-line-heights, $name) != null;
}

/// 列出所有可用行高
/// @return {List} 行高名称列表
/// @access private
@function _list-line-heights() {
  @return ("tight",
    "snug",
    "normal",
    "relaxed",
    "loose",
    "extra-loose");
}

/// 检查字符间距是否存在
/// @param {String} $name - 字符间距名称
/// @return {Boolean} 是否存在
/// @access private
@function _letter-spacing-exists($name) {
  $valid-letter-spacings: ("body-large",
    "body-medium",
    "body-small",
    "body-small-strong",
    "heading-large",
    "heading-medium",
    "heading-small",
    "display");
  @return list.index($valid-letter-spacings, $name) != null;
}

/// 列出所有可用字符间距
/// @return {List} 字符间距名称列表
/// @access private
@function _list-letter-spacings() {
  @return ("body-large",
    "body-medium",
    "body-small",
    "body-small-strong",
    "heading-large",
    "heading-medium",
    "heading-small",
    "display");
}
