export default function classnames(...args) {
  let classNames = [];

  // 遍历参数数组
  for (let i = 0; i < args.length; i++) {
    const arg = args[i];
    if (!arg) continue; // 排除 null, undefined, false, 0, ''

    const argType = typeof arg;

    switch (argType) {
      // 参数是字符串
      case 'string':
        classNames.push(arg.trim());
        break;

      // 参数是数组
      case 'object':
        if (Array.isArray(arg)) {
          const nestedClassNames = classnames(...arg);
          if (nestedClassNames) {
            classNames.push(nestedClassNames);
          }
        } else {
          // 参数是对象
          for (let key in arg) {
            if (arg[key]) {
              classNames.push(key.trim());
            }
          }
        }
        break;
      default:
    }
  }

  return classNames.join(' ');
}
