export const isArguments = function (val) {
  return Object.prototype.toString.call(val) === "[object Arguments]";
};

export const isArrayBuffer = function (val) {
  return Object.prototype.toString.call(val) === "[object ArrayBuffer]";
};

export const isArrayLike = function (val) {
  if (!val) return false;
  const length = val.length;
  return typeof length === "number" && length >= 0 && length % 1 === 0;
};

export const isArrayLikeObject = function (val) {
  return isArrayLike(val) && isObject(val);
};

export const isBuffer = function () {
  return false; // 如果没有特定的 Buffer 库支持，可以直接返回 false
};

export const isBoolean = function (val) {
  return typeof val === "boolean";
};

export const isDate = function (val) {
  return Object.prototype.toString.call(val) === "[object Date]";
};

export const isElement = function (val) {
  return val instanceof Element;
};

export const isEmpty = function (val) {
  if (!val) return true;
  if (isArrayLike(val) && val.length === 0) return true;
  if (isObject(val)) {
    for (const key in val) {
      if (Object.prototype.hasOwnProperty.call(val, key)) return false;
    }
    return true;
  }
  return false;
};

export const isEqual = function () {
  // 实现具体的相等判断逻辑
  return false;
};

export const isEqualWith = function () {
  // 实现具体的相等判断逻辑，可使用自定义比较器
  return false;
};

export const isError = function (val) {
  return val instanceof Error;
};

export const isFunction = function (val) {
  return typeof val === "function";
};

export const isFinite = function (val) {
  return Number.isFinite(val);
};

export const isLength = function (val) {
  return typeof val === "number" && val > -1 && val % 1 === 0;
};

export const isMap = function (val) {
  return Object.prototype.toString.call(val) === "[object Map]";
};

export const isMatch = function () {
  // 实现具体的匹配逻辑
  return false;
};

export const isMatchWith = function () {
  // 实现具体的匹配逻辑，可使用自定义比较器
  return false;
};

export const isNative = function () {
  return false; // 如果没有特定的判断逻辑，可以直接返回 false
};

export const isNil = function (val) {
  return val === null || val === undefined;
};

export const isNumber = function (val) {
  return typeof val === "number";
};

export const isNull = function (val) {
  return val === null;
};

export const isObjectLike = function (val) {
  return typeof val === "object" && val !== null;
};

export const isPlainObject = function (val) {
  if (!isObjectLike(val) || Object.getPrototypeOf(val) === null) return false;
  let proto = val;
  while (Object.getPrototypeOf(proto) !== null) {
    proto = Object.getPrototypeOf(proto);
  }
  return Object.getPrototypeOf(val) === proto;
};

export const isRegExp = function (val) {
  return Object.prototype.toString.call(val) === "[object RegExp]";
};

export const isSafeInteger = function (val) {
  return Number.isSafeInteger(val);
};

export const isSet = function (val) {
  return Object.prototype.toString.call(val) === "[object Set]";
};

export const isString = function (val) {
  return typeof val === "string";
};

export const isSymbol = function (val) {
  return typeof val === "symbol";
};

export const isTypedArray = function () {
  return false; // 如果没有特定的判断逻辑，可以直接返回 false
};

export const isUndefined = function (val) {
  return typeof val === "undefined";
};

export const isWeakMap = function (val) {
  return Object.prototype.toString.call(val) === "[object WeakMap]";
};

export const isWeakSet = function (val) {
  return Object.prototype.toString.call(val) === "[object WeakSet]";
};

export const toString = Object.prototype.toString;

export function is(val, type) {
  return toString.call(val) === `[object ${type}]`;
}

export function isDef(val) {
  return typeof val !== "undefined";
}

export function isObject(val) {
  return val !== null && is(val, "Object");
}

export function isArray(val) {
  return val && Array.isArray(val);
}

export function isWindow(val) {
  return typeof window !== "undefined" && is(val, "Window");
}

export const isServer = typeof window === "undefined";

export const isClient = !isServer;

export function isHttpUrl(path) {
  const reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/;
  return reg.test(path);
}

export function isPascalCase(str) {
  const regex = /^[A-Z][A-Za-z]*$/;
  return regex.test(str);
}

export function isUrl(path) {
  const reg = /^(https?|HTTPS?):\/\/[^\s/:$.?#].[^\s]*(:[0-9]+)?(\/[^\s]*)?$/;
  return reg.test(path);
}
