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EAAM,gBAAkB,EAAM,kBAAoB,IACpD,GAEJ,GACF,GAT6C,iBAAhB,EAA2B,EAAc,CACpE,WAAY,UASd,EAAG,QAAQ,GACX,EAAW,MAAK,WACd,EAAG,YACL,GAIJ,CAEA,GAAI,EAEF,GAAmC,oBAAxB,oBAAqC,CAE9C,IAAI,EAAiB,oBAAoB,EAAS,CAChD,QAAS,MAEX,EAAW,MAAK,WAEd,mBAAmB,EACrB,GACF,KAAO,CACL,IAAI,EAAK,WAAW,EAAS,KAC7B,EAAW,MAAK,WACd,aAAa,EACf,GACF,CAaF,MAVa,GAAG,OAAO,GAChB,SAAQ,SAAU,GACvB,EAAY,iBAAiB,EAAO,EAAS,CAC3C,MAAM,EACN,SAAS,IAEX,EAAW,MAAK,WACd,EAAY,oBAAoB,EAAO,EAAS,CAAC,EACnD,GACF,IA9DA,WACE,EAAW,SAAQ,SAAU,GAC3B,GACF,GACF,CAR+B,CAoEjC,GAAG,CAAC,EAAU,EAAI,EAAS,EAAU,EAAa,EAAY,EAAS,IACvE,IAAI,EAAsC,iBAAd,EAAyB,EAAY,MAEjE,OAAI,EACE,EACK,EAGW,MAAM,cAAc,EAAgB,SAAS,CAC/D,IAAK,EACL,MAAO,CACL,QAAS,aAEV,GAAO,GAEU,MAAM,cAAc,EAAgB,SAAS,CAAC,EAAG,EAAM,CACzE,IAAK,EACL,0BAA0B,EAC1B,wBAAyB,CACvB,OAAQ,MAIhB,CAEA,QAAQ,QAAU","file":"/npm/react-lazy-hydration@0.1.0/dist/index.browser.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/react-lazy-hydration@0.1.0/dist/index.browser.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar _extends = _interopDefault(require('@babel/runtime/helpers/extends'));\nvar _objectWithoutPropertiesLoose = _interopDefault(require('@babel/runtime/helpers/objectWithoutPropertiesLoose'));\nvar React = require('react');\n\n// React currently throws a warning when using useLayoutEffect on the server.\nvar useIsomorphicLayoutEffect =  React.useLayoutEffect ;\n\nfunction reducer() {\n  return true;\n}\n\nfunction LazyHydrate(props) {\n  var childRef = React.useRef(null); // Always render on server\n\n  var _React$useReducer = React.useReducer(reducer, !(true )),\n      hydrated = _React$useReducer[0],\n      hydrate = _React$useReducer[1];\n\n  var noWrapper = props.noWrapper,\n      ssrOnly = props.ssrOnly,\n      whenIdle = props.whenIdle,\n      whenVisible = props.whenVisible,\n      promise = props.promise,\n      _props$on = props.on,\n      on = _props$on === void 0 ? [] : _props$on,\n      children = props.children,\n      didHydrate = props.didHydrate,\n      rest = _objectWithoutPropertiesLoose(props, [\"noWrapper\", \"ssrOnly\", \"whenIdle\", \"whenVisible\", \"promise\", \"on\", \"children\", \"didHydrate\"]);\n\n  if ('production' !== process.env.NODE_ENV && !ssrOnly && !whenIdle && !whenVisible && !on.length && !promise) {\n    console.error(\"LazyHydration: Enable atleast one trigger for hydration.\\n\" + \"If you don't want to hydrate, use ssrOnly\");\n  }\n\n  useIsomorphicLayoutEffect(function () {\n    // No SSR Content\n    if (!childRef.current.hasChildNodes()) {\n      hydrate();\n    }\n  }, []);\n  React.useEffect(function () {\n    if (hydrated && didHydrate) {\n      didHydrate();\n    } // eslint-disable-next-line react-hooks/exhaustive-deps\n\n  }, [hydrated]);\n  React.useEffect(function () {\n    if (ssrOnly || hydrated) return;\n    var rootElement = childRef.current;\n    var cleanupFns = [];\n\n    function cleanup() {\n      cleanupFns.forEach(function (fn) {\n        fn();\n      });\n    }\n\n    if (promise) {\n      promise.then(hydrate, hydrate);\n    }\n\n    if (whenVisible) {\n      var element = noWrapper ? rootElement : // As root node does not have any box model, it cannot intersect.\n      rootElement.firstElementChild;\n\n      if (element && typeof IntersectionObserver !== \"undefined\") {\n        var observerOptions = typeof whenVisible === \"object\" ? whenVisible : {\n          rootMargin: \"250px\"\n        };\n        var io = new IntersectionObserver(function (entries) {\n          entries.forEach(function (entry) {\n            if (entry.isIntersecting || entry.intersectionRatio > 0) {\n              hydrate();\n            }\n          });\n        }, observerOptions);\n        io.observe(element);\n        cleanupFns.push(function () {\n          io.disconnect();\n        });\n      } else {\n        return hydrate();\n      }\n    }\n\n    if (whenIdle) {\n      // @ts-ignore\n      if (typeof requestIdleCallback !== \"undefined\") {\n        // @ts-ignore\n        var idleCallbackId = requestIdleCallback(hydrate, {\n          timeout: 500\n        });\n        cleanupFns.push(function () {\n          // @ts-ignore\n          cancelIdleCallback(idleCallbackId);\n        });\n      } else {\n        var id = setTimeout(hydrate, 2000);\n        cleanupFns.push(function () {\n          clearTimeout(id);\n        });\n      }\n    }\n\n    var events = [].concat(on);\n    events.forEach(function (event) {\n      rootElement.addEventListener(event, hydrate, {\n        once: true,\n        passive: true\n      });\n      cleanupFns.push(function () {\n        rootElement.removeEventListener(event, hydrate, {});\n      });\n    });\n    return cleanup;\n  }, [hydrated, on, ssrOnly, whenIdle, whenVisible, didHydrate, promise, noWrapper]);\n  var WrapperElement = typeof noWrapper === \"string\" ? noWrapper : \"div\";\n\n  if (hydrated) {\n    if (noWrapper) {\n      return children;\n    }\n\n    return /*#__PURE__*/React.createElement(WrapperElement, _extends({\n      ref: childRef,\n      style: {\n        display: \"contents\"\n      }\n    }, rest), children);\n  } else {\n    return /*#__PURE__*/React.createElement(WrapperElement, _extends({}, rest, {\n      ref: childRef,\n      suppressHydrationWarning: true,\n      dangerouslySetInnerHTML: {\n        __html: \"\"\n      }\n    }));\n  }\n}\n\nexports.default = LazyHydrate;\n"]}