{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["import { getDocument } from \"ssr-window\";\r\n\r\nexport type TIsSelectorValidArgs = Parameters<typeof isSelectorValid>;\r\n\r\nexport type TIsSelectorValidReturn = ReturnType<typeof isSelectorValid>;\r\n\r\n/**\r\n * Checks if string is valid CSS selector\r\n * @param str{String} source selector\r\n * @returns {boolean}\r\n * @throws {TypeError} isSelectorValid: str must be a string\r\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors\r\n * @example\r\n * // How to check if the CSS selector is valid?\r\n * const selector = \"#myElement\";\r\n * const isValid = isSelectorValid(selector);\r\n * console.log(isValid); // => true\r\n */\r\nexport const isSelectorValid = (str: string): boolean => {\r\n  if (typeof str !== \"string\") {\r\n    throw new TypeError(\"isSelectorValid: str must be a string\");\r\n  }\r\n  try {\r\n    getDocument().createDocumentFragment().querySelector(str);\r\n  } catch {\r\n    return false;\r\n  }\r\n  return true;\r\n};\r\n"],"names":["isSelectorValid","str","TypeError","getDocument","createDocumentFragment","querySelector"],"mappings":";;;;;;;;;;;;GAkBO,MAAMA,gBAAmBC,MAC9B,UAAWA,MAAQ,SACjB,MAAM,IAAIC,UAAU,yCAEtB,IACEC,cAAcC,yBAAyBC,cAAcJ,IACvD,CAAE,MACA,OAAO,KACT,CACA,OAAO"}