{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport React from 'react';\nimport { atomic } from \"../react-native-web-fucntions/atomic\";\nimport preprocess from \"../react-native-web-fucntions/preprocess\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport stableHash from 'stable-hash';\nimport hash from \"./hash\";\nimport { useStableMemo } from \"./useStableMemo\";\nimport { getResponsiveStylesImpl, useDimensionsWithEnable } from \"./common\";\nimport { useNativeBaseConfig } from \"../../core/NativeBaseContext\";\nvar textContentMap = {};\nexport var useResponsiveQuery = function useResponsiveQuery(queries) {\n  var isSSR = useNativeBaseConfig('NativeBase').isSSR;\n  var disableCSSMediaQueries = !isSSR;\n  var windowWidth = useDimensionsWithEnable({\n    enable: disableCSSMediaQueries\n  }).width;\n  var values = useStableMemo(function () {\n    if (disableCSSMediaQueries) {\n      var _getResponsiveStyles = getResponsiveStylesImpl(windowWidth);\n      if (queries) {\n        var _getResponsiveStyles2 = _getResponsiveStyles(queries),\n          styles = _getResponsiveStyles2.styles,\n          styleFromQuery = _getResponsiveStyles2.styleFromQuery;\n        return {\n          styles: styles,\n          styleFromQuery: styleFromQuery,\n          getResponsiveStyles: _getResponsiveStyles\n        };\n      } else {\n        return {\n          getResponsiveStyles: _getResponsiveStyles\n        };\n      }\n    } else {\n      if (queries) {\n        var _getResponsiveStyles3 = getResponsiveStyles(queries),\n          _styles = _getResponsiveStyles3.styles,\n          dataSet = _getResponsiveStyles3.dataSet,\n          _styleFromQuery = _getResponsiveStyles3.styleFromQuery;\n        return {\n          dataSet: dataSet,\n          styles: _styles,\n          styleFromQuery: _styleFromQuery,\n          getResponsiveStyles: getResponsiveStyles\n        };\n      } else {\n        return {\n          getResponsiveStyles: getResponsiveStyles\n        };\n      }\n    }\n  }, [queries, windowWidth, disableCSSMediaQueries]);\n  return values;\n};\nvar getDataAttribute = function getDataAttribute(queryRule) {\n  if (typeof queryRule.minWidth === 'number' && typeof queryRule.maxWidth === 'number') {\n    return \"min-width-\".concat(queryRule.minWidth, \"-max-width-\").concat(queryRule.maxWidth);\n  } else if (typeof queryRule.minWidth === 'number') {\n    return \"min-width-\".concat(queryRule.minWidth);\n  } else if (typeof queryRule.maxWidth === 'number') {\n    return \"max-width-\".concat(queryRule.maxWidth);\n  }\n  return undefined;\n};\nvar getMediaQueryRule = function getMediaQueryRule(query, newRule) {\n  if (typeof query.minWidth === 'number' && typeof query.maxWidth === 'number') {\n    return \"@media only screen and (min-width: \".concat(query.minWidth, \"px) and (max-width: \").concat(query.maxWidth, \"px) { \").concat(newRule, \" }\");\n  } else if (typeof query.minWidth === 'number') {\n    return \"@media only screen and (min-width: \".concat(query.minWidth, \"px) { \").concat(newRule, \" }\");\n  } else if (typeof query.maxWidth === 'number') {\n    return \"@media only screen and (max-width: \".concat(query.maxWidth, \"px) { \").concat(newRule, \" }\");\n  }\n  return undefined;\n};\nvar getResponsiveStyles = function getResponsiveStyles(queries) {\n  var queryString = stableHash(queries.query);\n  var queriesHash = hash(queryString);\n  var styles = queries.initial ? [StyleSheet.create({\n    initial: StyleSheet.flatten(queries.initial)\n  }).initial] : undefined;\n  var dataSet = {};\n  var styleSheet;\n  var insert = function insert(rule) {\n    if (typeof window !== 'undefined') {\n      if (!styleSheet) {\n        var styleEl = document.createElement('style');\n        styleEl.type = 'text/css';\n        styleEl.appendChild(document.createTextNode(''));\n        document.head.appendChild(styleEl);\n        styleSheet = styleEl.sheet;\n      }\n      styleSheet.insertRule(rule, styleSheet.cssRules.length);\n    }\n  };\n  if (queries.query) {\n    queries.query.forEach(function (queryRule) {\n      var queryHash = queriesHash + hash(stableHash(queryRule));\n      var dataAttribute = getDataAttribute(queryRule);\n      if (dataAttribute) {\n        var newIdentifier = \"[data-\".concat(dataAttribute, \"$=\\\"\").concat(queryHash, \"\\\"]\");\n        dataSet[dataAttribute] = queryHash;\n        var mediaRules = '';\n        var flattenQueryStyle = StyleSheet.flatten(queryRule.style);\n        var newStyle = preprocess(flattenQueryStyle);\n        var _atomic = atomic(newStyle),\n          _atomic2 = _slicedToArray(_atomic, 2),\n          compiledStyle = _atomic2[0],\n          compiledOrderedRules = _atomic2[1];\n        delete compiledStyle.$$css;\n        Object.keys(compiledStyle).forEach(function (key) {\n          var oldIdentifier = compiledStyle[key];\n          compiledOrderedRules.forEach(function (_ref) {\n            var _ref2 = _slicedToArray(_ref, 2),\n              rules = _ref2[0],\n              _order = _ref2[1];\n            var newRule = rules[0].replace('.' + oldIdentifier, newIdentifier);\n            mediaRules += newRule;\n          });\n        });\n        if (mediaRules) {\n          var mediaQueryRule = getMediaQueryRule(queryRule, mediaRules);\n          insert(\"/*\".concat(queryHash, \"{}*/\").concat(mediaQueryRule));\n          textContentMap[\"/*\".concat(queryHash, \"{}*/\").concat(mediaQueryRule)] = true;\n        }\n      }\n    });\n  }\n  return {\n    styles: styles,\n    styleFromQuery: StyleSheet.flatten(styles),\n    dataSet: dataSet\n  };\n};\nexport var getStyleElement = function getStyleElement() {\n  return React.createElement(\"style\", {\n    type: \"text/css\",\n    dangerouslySetInnerHTML: {\n      __html: Object.keys(textContentMap).join('')\n    }\n  });\n};","map":{"version":3,"sources":["useResponsiveQuery.web.tsx"],"names":["React","atomic","preprocess","stableHash","hash","useStableMemo","getResponsiveStylesImpl","useDimensionsWithEnable","useNativeBaseConfig","textContentMap","useResponsiveQuery","queries","isSSR","disableCSSMediaQueries","windowWidth","enable","width","values","getResponsiveStyles","styles","styleFromQuery","dataSet","getDataAttribute","queryRule","minWidth","maxWidth","undefined","getMediaQueryRule","query","newRule","queryString","queriesHash","initial","create","StyleSheet","flatten","styleSheet","insert","rule","window","styleEl","document","createElement","type","appendChild","createTextNode","head","sheet","insertRule","cssRules","length","forEach","queryHash","dataAttribute","newIdentifier","mediaRules","flattenQueryStyle","style","newStyle","compiledStyle","compiledOrderedRules","$$css","Object","keys","key","oldIdentifier","rules","_order","replace","mediaQueryRule","getStyleElement","__html","join"],"mappings":";AACA,OAAOA,KAAP,MAAkB,OAAlB;A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A;cAAxBM,KAAD,GAAA,KAAA;cAAQC,MAAT,GAAA,KAAA;YAE3B,IAAMtC,OAAO,GAAGqC,KAAK,CAAC,CAAD,CAALA,CAASE,OAATF,CACd,GAAA,GAAMD,aADQC,EAEdZ,aAFcY,CAAhB;YAIAX,UAAU,IAAI1B,OAAd0B;UACD,CAPDK,CAAAA;QAQD,CAVDE,CAAAA;QAWA,IAAIP,UAAJ,EAAgB;UACd,IAAMc,cAAc,GAAG1C,iBAAiB,CAACJ,SAAD,EAAYgC,UAAZ,CAAxC;UACAlB,MAAM,CAAA,IAAA,CAAA,MAAA,CAAMe,SAAN,EAAA,MAAA,CAAA,CAAA,MAAA,CAAsBiB,cAAtB,CAAA,CAANhC;UACA5B,cAAc,CAAA,IAAA,CAAA,MAAA,CAAM2C,SAAN,EAAA,MAAA,CAAA,CAAA,MAAA,CAAsBiB,cAAtB,CAAA,CAAd5D,GAAwD,IAAxDA;QACD;MACF;IACF,CAhCDE,CAAAA;EAiCD;EAED,OAAO;IAAEQ,MAAF,EAAEA,MAAF;IAAUC,cAAc,EAAEc,UAAU,CAACC,OAAXD,CAAmBf,MAAnBe,CAA1B;IAAsDb,OAAAA,EAAAA;EAAtD,CAAP;AACD,CArED;AA0EA,OAAO,IAAMiD,eAAe,GAAG,SAAlBA,eAAe,CAAA,EAAS;EACnC,OACE,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA;IACE,IAAI,EAAC,UADP;IAEE,uBAAuB,EAAE;MAAEC,MAAM,EAAET,MAAM,CAACC,IAAPD,CAAYrD,cAAZqD,CAAAA,CAA4BU,IAA5BV,CAAiC,EAAjCA;IAAV;EAF3B,CAAA,CADF;AAMD,CAPM","sourcesContent":["// import { atomic } from 'react-native-web/dist/exports/StyleSheet/compiler';\nimport React from 'react';\nimport { atomic } from '../react-native-web-fucntions/atomic';\nimport preprocess from '../react-native-web-fucntions/preprocess';\nimport type {\n  DataSet,\n  Query,\n  UseResponsiveQueryParams,\n  UseResponsiveQueryReturnType,\n  GetResponsiveStylesParams,\n} from './types';\nimport { StyleSheet } from 'react-native';\n// @ts-ignore\nimport stableHash from 'stable-hash';\nimport hash from './hash';\n// import type { GetResponsiveStylesReturnType } from './types';\nimport { useStableMemo } from './useStableMemo';\nimport { getResponsiveStylesImpl, useDimensionsWithEnable } from './common';\nimport { useNativeBaseConfig } from '../../core/NativeBaseContext';\n\n/******************** Implementation after RNW v0.18 ***********************/\n\n/**\n * 1. preprocess:- Handles shadow/text shadow conversion from RN styles to web *                 styles\n *\n * 2. atomic:- it handles prefixing, converting RN specific styles to web styles *             and generating the CSS selector.\n *             Input {marginTop: 10}\n *             Output\n *             compiledStyle : marginTop: \"r-marginTop-156q2ks\"\n *             compiledOrderedRules : \".r-marginTop-156q2ks{margin-top:10px;}\"\n *      a)compiledStyle:- Array it holds identifier/selector with properties\n *      b)compiledOrderedRules:- Array it holds the css rule with selector name\n *      Also from RNW v0.18 handles swapping of ltr styles if enabled by user\n * 3. createSheet:- used to grab sheet which exist already created by rnw. when we *                  call createSheet without id it will return sheet which exist. *                  cause it automatically takes a default ID  which is already in *                  use (created by rnw with default ID) so this return sheet *                  which exist with  ID doesn't create a new sheet.\n *\n * This Implementation is based on asumptions that RNW doesn't change the         * function  or doesn't re-write them. if there is any change in RNW implmentation * it we'll break and needs to be updated.\n *\n */\nlet textContentMap: any = {};\n\nexport const useResponsiveQuery = (\n  queries?: UseResponsiveQueryParams\n): UseResponsiveQueryReturnType => {\n  const isSSR = useNativeBaseConfig('NativeBase').isSSR;\n  const disableCSSMediaQueries = !isSSR;\n\n  // Only attaches listener if disableCSSMediaQueries is true\n  const windowWidth = useDimensionsWithEnable({\n    enable: disableCSSMediaQueries,\n  }).width;\n\n  const values = useStableMemo(() => {\n    // Use the non-media query responsive styling\n    if (disableCSSMediaQueries) {\n      const getResponsiveStyles = getResponsiveStylesImpl(windowWidth);\n      if (queries) {\n        const { styles, styleFromQuery } = getResponsiveStyles(queries);\n        return { styles, styleFromQuery, getResponsiveStyles };\n      } else {\n        return { getResponsiveStyles };\n      }\n    } else {\n      if (queries) {\n        const { styles, dataSet, styleFromQuery } = getResponsiveStyles(\n          queries\n        );\n\n        return { dataSet, styles, styleFromQuery, getResponsiveStyles };\n      } else {\n        return { getResponsiveStyles };\n      }\n    }\n  }, [queries, windowWidth, disableCSSMediaQueries]);\n\n  return values;\n};\n\nconst getDataAttribute = (queryRule: Query) => {\n  if (\n    typeof queryRule.minWidth === 'number' &&\n    typeof queryRule.maxWidth === 'number'\n  ) {\n    return `min-width-${queryRule.minWidth}-max-width-${queryRule.maxWidth}`;\n  } else if (typeof queryRule.minWidth === 'number') {\n    return `min-width-${queryRule.minWidth}`;\n  } else if (typeof queryRule.maxWidth === 'number') {\n    return `max-width-${queryRule.maxWidth}`;\n  }\n\n  return undefined;\n};\n\nconst getMediaQueryRule = (query: Query, newRule: string) => {\n  if (\n    typeof query.minWidth === 'number' &&\n    typeof query.maxWidth === 'number'\n  ) {\n    return `@media only screen and (min-width: ${query.minWidth}px) and (max-width: ${query.maxWidth}px) { ${newRule} }`;\n  } else if (typeof query.minWidth === 'number') {\n    return `@media only screen and (min-width: ${query.minWidth}px) { ${newRule} }`;\n  } else if (typeof query.maxWidth === 'number') {\n    return `@media only screen and (max-width: ${query.maxWidth}px) { ${newRule} }`;\n  }\n  return undefined;\n};\n\nconst getResponsiveStyles = (queries: GetResponsiveStylesParams): any => {\n  const queryString = stableHash(queries.query);\n  const queriesHash = hash(queryString);\n\n  const styles = queries.initial\n    ? [\n        StyleSheet.create({ initial: StyleSheet.flatten(queries.initial) })\n          .initial,\n      ]\n    : undefined;\n\n  // const styleFromQuery = queries.initial ? [queries.initial] : undefined;\n  let dataSet: DataSet = {};\n  let styleSheet: any;\n\n  /**\n   * This function is copied from intergalacticspacehighway/rnw-responsive-ssr\n   */\n  const insert = (rule: string) => {\n    if (typeof window !== 'undefined') {\n      if (!styleSheet) {\n        const styleEl = document.createElement('style');\n        styleEl.type = 'text/css';\n        styleEl.appendChild(document.createTextNode(''));\n        document.head.appendChild(styleEl);\n        styleSheet = styleEl.sheet;\n      }\n\n      styleSheet.insertRule(rule, styleSheet.cssRules.length);\n    }\n  };\n\n  if (queries.query) {\n    queries.query.forEach((queryRule) => {\n      const queryHash = queriesHash + hash(stableHash(queryRule));\n      const dataAttribute = getDataAttribute(queryRule);\n\n      if (dataAttribute) {\n        const newIdentifier = `[data-${dataAttribute}$=\"${queryHash}\"]`;\n        dataSet[dataAttribute] = queryHash;\n\n        let mediaRules = '';\n\n        const flattenQueryStyle = StyleSheet.flatten(queryRule.style);\n        const newStyle = preprocess(flattenQueryStyle);\n        const [compiledStyle, compiledOrderedRules] = atomic(newStyle);\n        //@ts-ignore\n        delete compiledStyle.$$css; //removing unnecessary $$css property\n        Object.keys(compiledStyle).forEach((key) => {\n          const oldIdentifier = compiledStyle[key];\n          compiledOrderedRules.forEach(([rules, _order]: any) => {\n            // Rule returned by atomic has css selectors, so we'll replace it with data-attr selector\n            const newRule = rules[0].replace(\n              '.' + oldIdentifier,\n              newIdentifier\n            );\n            mediaRules += newRule;\n          });\n        });\n        if (mediaRules) {\n          const mediaQueryRule = getMediaQueryRule(queryRule, mediaRules);\n          insert(`/*${queryHash}{}*/${mediaQueryRule}`);\n          textContentMap[`/*${queryHash}{}*/${mediaQueryRule}`] = true;\n        }\n      }\n    });\n  }\n\n  return { styles, styleFromQuery: StyleSheet.flatten(styles), dataSet };\n};\n\n/**\n * This function is copied from intergalacticspacehighway/rnw-responsive-ssr\n */\nexport const getStyleElement = () => {\n  return (\n    <style\n      type=\"text/css\"\n      dangerouslySetInnerHTML={{ __html: Object.keys(textContentMap).join('') }}\n    />\n  );\n};\n"]},"metadata":{},"sourceType":"module"}