export const isUndefined = value => value === undefined;
export const pick = (obj, keys = []) => {
  if (obj === undefined) {
    return {};
  }
  return Object.fromEntries(Object.entries(obj).filter(([k]) => keys.includes(k)));
};
export const omitBy = (obj, predicate) => Object.fromEntries(Object.entries(obj).filter(([, v]) => !predicate(v)));
export const debounce = (func, wait) => {
  let timeout;
  return (...args) => {
    clearTimeout(timeout);
    timeout = setTimeout(() => func(...args), wait);
  };
};
export const matches = srcObj => {
  return obj => {
    let key;
    for (key in srcObj) {
      if (obj[key] === undefined || obj[key] !== srcObj[key]) {
        return false;
      }
    }
    return true;
  };
};
function getRandomHexValues(byte) {
  return [...Array(byte * 2)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');
}
export function getRandomHex(byte) {
  var _window;
  let randomHex;
  if ((_window = window) !== null && _window !== void 0 && _window.crypto) {
    try {
      randomHex = Array.from(window.crypto.getRandomValues(new Uint8Array(byte))).map(b => b.toString(16).padStart(2, '0')).join('');
    } catch (e) {
      randomHex = getRandomHexValues(byte);
    }
  } else {
    randomHex = getRandomHexValues(byte);
  }
  return randomHex;
}
export function getRandomTelemetryId() {
  return getRandomHex(8);
}