{
  "version": 3,
  "sources": ["../src/with-viewport-match.js"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tcreateHigherOrderComponent,\n\tpure,\n\tuseViewportMatch,\n} from '@wordpress/compose';\n\n/**\n * Higher-order component creator, creating a new component which renders with\n * the given prop names, where the value passed to the underlying component is\n * the result of the query assigned as the object's value.\n *\n * @see isViewportMatch\n *\n * @param {Object} queries Object of prop name to viewport query.\n *\n * @example\n *\n * ```jsx\n * function MyComponent( { isMobile } ) {\n * \treturn (\n * \t\t<div>Currently: { isMobile ? 'Mobile' : 'Not Mobile' }</div>\n * \t);\n * }\n *\n * MyComponent = withViewportMatch( { isMobile: '< small' } )( MyComponent );\n * ```\n *\n * @return {Function} Higher-order component.\n */\nconst withViewportMatch = ( queries ) => {\n\tconst queryEntries = Object.entries( queries );\n\tconst useViewPortQueriesResult = () =>\n\t\tObject.fromEntries(\n\t\t\tqueryEntries.map( ( [ key, query ] ) => {\n\t\t\t\tlet [ operator, breakpointName ] = query.split( ' ' );\n\t\t\t\tif ( breakpointName === undefined ) {\n\t\t\t\t\tbreakpointName = operator;\n\t\t\t\t\toperator = '>=';\n\t\t\t\t}\n\t\t\t\t// Hooks should unconditionally execute in the same order,\n\t\t\t\t// we are respecting that as from the static query of the HOC we generate\n\t\t\t\t// a hook that calls other hooks always in the same order (because the query never changes).\n\t\t\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\t\t\treturn [ key, useViewportMatch( breakpointName, operator ) ];\n\t\t\t} )\n\t\t);\n\treturn createHigherOrderComponent( ( WrappedComponent ) => {\n\t\treturn pure( ( props ) => {\n\t\t\tconst queriesResult = useViewPortQueriesResult();\n\t\t\treturn <WrappedComponent { ...props } { ...queriesResult } />;\n\t\t} );\n\t}, 'withViewportMatch' );\n};\n\nexport default withViewportMatch;\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAIO;AA6CG;AApBV,IAAM,oBAAoB,CAAE,YAAa;AACxC,QAAM,eAAe,OAAO,QAAS,OAAQ;AAC7C,QAAM,2BAA2B,MAChC,OAAO;AAAA,IACN,aAAa,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO;AACvC,UAAI,CAAE,UAAU,cAAe,IAAI,MAAM,MAAO,GAAI;AACpD,UAAK,mBAAmB,QAAY;AACnC,yBAAiB;AACjB,mBAAW;AAAA,MACZ;AAKA,aAAO,CAAE,SAAK,iCAAkB,gBAAgB,QAAS,CAAE;AAAA,IAC5D,CAAE;AAAA,EACH;AACD,aAAO,2CAA4B,CAAE,qBAAsB;AAC1D,eAAO,qBAAM,CAAE,UAAW;AACzB,YAAM,gBAAgB,yBAAyB;AAC/C,aAAO,4CAAC,oBAAmB,GAAG,OAAU,GAAG,eAAgB;AAAA,IAC5D,CAAE;AAAA,EACH,GAAG,mBAAoB;AACxB;AAEA,IAAO,8BAAQ;",
  "names": []
}
