{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["import { getWindow } from \"ssr-window\";\r\n\r\nexport type TIsMediaQueryArgs = Parameters<typeof isMediaQuery>;\r\n\r\nexport type TIsMediaQueryReturn = ReturnType<typeof isMediaQuery>;\r\n\r\n/**\r\n * Gets a result of testing a CSS media query and wraps bare media features when needed.\n * @param str{string} source media query string\r\n * @returns {boolean}\r\n * @throws {TypeError} isMediaQuery: str must be a string\r\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Testing_media_queries\r\n * @example\r\n * // How to check if a user device has portrait or landscape orientation?\r\n * const mediaQuery = \"(orientation: portrait)\";\r\n * const isPortrait = isMediaQuery(mediaQuery);\n * console.log(isPortrait); // => false\n * @example\n * // Disable decorative animation when the user prefers reduced motion\n * const shouldReduceMotion = isMediaQuery(\"(prefers-reduced-motion: reduce)\");\n */\nexport const isMediaQuery = (str: string): boolean => {\r\n  if (typeof str !== \"string\") {\r\n    throw new TypeError(\"isMediaQuery: str must be a string\");\r\n  }\r\n\r\n  const query = /^[\\w-]+\\s*:/u.test(str.trim()) ? `(${str.trim()})` : str.trim();\n\r\n  return getWindow().matchMedia(query)?.matches ?? false;\r\n};\r\n"],"names":["isMediaQuery","str","TypeError","query","test","trim","getWindow","matchMedia","matches"],"mappings":"kCAqBO,MAAMA,aAAgBC,MAC3B,UAAWA,MAAQ,SACjB,MAAM,IAAIC,UAAU,sCAGtB,MAAMC,MAAQ,eAAeC,KAAKH,IAAII,QAAU,IAAIJ,IAAII,UAAYJ,IAAII,OAExE,OAAOC,YAAYC,WAAWJ,QAAQK,SAAW"}