{"ast":null,"code":"\"use strict\";\n\nvar _interopRequireWildcard = require(\"@babel/runtime/helpers/interopRequireWildcard\");\n\nexports.__esModule = true;\nexports.default = void 0;\n\nvar _react = _interopRequireWildcard(require(\"react\"));\n\nvar _router = require(\"../next-server/lib/router/router\");\n\nvar _router2 = require(\"./router\");\n\nvar _useIntersection = require(\"./use-intersection\");\n\nconst prefetched = {};\n\nfunction prefetch(router, href, as, options) {\n  if (true || !router) return;\n  if (!(0, _router.isLocalURL)(href)) return; // Prefetch the JSON page if asked (only in the client)\n  // We need to handle a prefetch error here since we may be\n  // loading with priority which can reject but we don't\n  // want to force navigation since this is only a prefetch\n\n  router.prefetch(href, as, options).catch(err => {\n    if (true) {\n      // rethrow to show invalid URL errors\n      throw err;\n    }\n  });\n  const curLocale = options && typeof options.locale !== 'undefined' ? options.locale : router && router.locale; // Join on an invalid URI character\n\n  prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')] = true;\n}\n\nfunction isModifiedEvent(event) {\n  const {\n    target\n  } = event.currentTarget;\n  return target && target !== '_self' || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || // triggers resource download\n  event.nativeEvent && event.nativeEvent.which === 2;\n}\n\nfunction linkClicked(e, router, href, as, replace, shallow, scroll, locale) {\n  const {\n    nodeName\n  } = e.currentTarget;\n\n  if (nodeName === 'A' && (isModifiedEvent(e) || !(0, _router.isLocalURL)(href))) {\n    // ignore click for browser’s default behavior\n    return;\n  }\n\n  e.preventDefault(); //  avoid scroll for urls with anchor refs\n\n  if (scroll == null) {\n    scroll = as.indexOf('#') < 0;\n  } // replace state instead of push if prop is present\n\n\n  router[replace ? 'replace' : 'push'](href, as, {\n    shallow,\n    locale,\n    scroll\n  }).then(success => {\n    if (!success) return;\n\n    if (scroll) {\n      // FIXME: proper route announcing at Router level, not Link:\n      document.body.focus();\n    }\n  });\n}\n\nfunction Link(props) {\n  if (true) {\n    function createPropError(args) {\n      return new Error(`Failed prop type: The prop \\`${args.key}\\` expects a ${args.expected} in \\`<Link>\\`, but got \\`${args.actual}\\` instead.` + (false ? \"\\nOpen your browser's console to view the Component stack trace.\" : ''));\n    } // TypeScript trick for type-guarding:\n\n\n    const requiredPropsGuard = {\n      href: true\n    };\n    const requiredProps = Object.keys(requiredPropsGuard);\n    requiredProps.forEach(key => {\n      if (key === 'href') {\n        if (props[key] == null || typeof props[key] !== 'string' && typeof props[key] !== 'object') {\n          throw createPropError({\n            key,\n            expected: '`string` or `object`',\n            actual: props[key] === null ? 'null' : typeof props[key]\n          });\n        }\n      } else {\n        // TypeScript trick for type-guarding:\n        // eslint-disable-next-line @typescript-eslint/no-unused-vars\n        const _ = key;\n      }\n    }); // TypeScript trick for type-guarding:\n\n    const optionalPropsGuard = {\n      as: true,\n      replace: true,\n      scroll: true,\n      shallow: true,\n      passHref: true,\n      prefetch: true,\n      locale: true\n    };\n    const optionalProps = Object.keys(optionalPropsGuard);\n    optionalProps.forEach(key => {\n      const valType = typeof props[key];\n\n      if (key === 'as') {\n        if (props[key] && valType !== 'string' && valType !== 'object') {\n          throw createPropError({\n            key,\n            expected: '`string` or `object`',\n            actual: valType\n          });\n        }\n      } else if (key === 'locale') {\n        if (props[key] && valType !== 'string') {\n          throw createPropError({\n            key,\n            expected: '`string`',\n            actual: valType\n          });\n        }\n      } else if (key === 'replace' || key === 'scroll' || key === 'shallow' || key === 'passHref' || key === 'prefetch') {\n        if (props[key] != null && valType !== 'boolean') {\n          throw createPropError({\n            key,\n            expected: '`boolean`',\n            actual: valType\n          });\n        }\n      } else {\n        // TypeScript trick for type-guarding:\n        // eslint-disable-next-line @typescript-eslint/no-unused-vars\n        const _ = key;\n      }\n    }); // This hook is in a conditional but that is ok because `process.env.NODE_ENV` never changes\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n\n    const hasWarned = _react.default.useRef(false);\n\n    if (props.prefetch && !hasWarned.current) {\n      hasWarned.current = true;\n      console.warn('Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://err.sh/vercel/next.js/prefetch-true-deprecated');\n    }\n  }\n\n  const p = props.prefetch !== false;\n  const router = (0, _router2.useRouter)();\n  const pathname = router && router.pathname || '/';\n\n  const {\n    href,\n    as\n  } = _react.default.useMemo(() => {\n    const [resolvedHref, resolvedAs] = (0, _router.resolveHref)(pathname, props.href, true);\n    return {\n      href: resolvedHref,\n      as: props.as ? (0, _router.resolveHref)(pathname, props.as) : resolvedAs || resolvedHref\n    };\n  }, [pathname, props.href, props.as]);\n\n  let {\n    children,\n    replace,\n    shallow,\n    scroll,\n    locale\n  } = props; // Deprecated. Warning shown by propType check. If the children provided is a string (<Link>example</Link>) we wrap it in an <a> tag\n\n  if (typeof children === 'string') {\n    children = /*#__PURE__*/_react.default.createElement(\"a\", null, children);\n  } // This will return the first child, if multiple are provided it will throw an error\n\n\n  const child = _react.Children.only(children);\n\n  const childRef = child && typeof child === 'object' && child.ref;\n  const [setIntersectionRef, isVisible] = (0, _useIntersection.useIntersection)({\n    rootMargin: '200px'\n  });\n\n  const setRef = _react.default.useCallback(el => {\n    setIntersectionRef(el);\n\n    if (childRef) {\n      if (typeof childRef === 'function') childRef(el);else if (typeof childRef === 'object') {\n        childRef.current = el;\n      }\n    }\n  }, [childRef, setIntersectionRef]);\n\n  (0, _react.useEffect)(() => {\n    const shouldPrefetch = isVisible && p && (0, _router.isLocalURL)(href);\n    const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale;\n    const isPrefetched = prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')];\n\n    if (shouldPrefetch && !isPrefetched) {\n      prefetch(router, href, as, {\n        locale: curLocale\n      });\n    }\n  }, [as, href, isVisible, locale, p, router]);\n  const childProps = {\n    ref: setRef,\n    onClick: e => {\n      if (child.props && typeof child.props.onClick === 'function') {\n        child.props.onClick(e);\n      }\n\n      if (!e.defaultPrevented) {\n        linkClicked(e, router, href, as, replace, shallow, scroll, locale);\n      }\n    }\n  };\n\n  childProps.onMouseEnter = e => {\n    if (!(0, _router.isLocalURL)(href)) return;\n\n    if (child.props && typeof child.props.onMouseEnter === 'function') {\n      child.props.onMouseEnter(e);\n    }\n\n    prefetch(router, href, as, {\n      priority: true\n    });\n  }; // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is\n  // defined, we specify the current 'href', so that repetition is not needed by the user\n\n\n  if (props.passHref || child.type === 'a' && !('href' in child.props)) {\n    const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale; // we only render domain locales if we are currently on a domain locale\n    // so that locale links are still visitable in development/preview envs\n\n    const localeDomain = router && router.isLocaleDomain && (0, _router.getDomainLocale)(as, curLocale, router && router.locales, router && router.domainLocales);\n    childProps.href = localeDomain || (0, _router.addBasePath)((0, _router.addLocale)(as, curLocale, router && router.defaultLocale));\n  }\n\n  return /*#__PURE__*/_react.default.cloneElement(child, childProps);\n}\n\nvar _default = Link;\nexports.default = _default;","map":{"version":3,"sources":["../../client/link.tsx"],"names":["prefetched","router","err","curLocale","options","href","event","target","e","nodeName","isModifiedEvent","scroll","as","replace","success","document","args","key","expected","actual","requiredPropsGuard","requiredProps","Object","props","createPropError","_","optionalPropsGuard","shallow","passHref","prefetch","locale","optionalProps","valType","hasWarned","React","console","p","pathname","resolvedAs","children","child","Children","childRef","rootMargin","setRef","el","setIntersectionRef","shouldPrefetch","isVisible","isPrefetched","childProps","ref","onClick","linkClicked","priority","localeDomain","Link"],"mappings":";;;;;;;AAAA,IAAA,MAAA,GAAA,uBAAA,CAAA,OAAA,CAAA,OAAA,CAAA,CAAA;;AAEA,IAAA,OAAA,GAAA,OAAA,CAAA,kCAAA,CAAA;;AASA,IAAA,QAAA,GAAA,OAAA,CAAA,UAAA,CAAA;;AACA,IAAA,gBAAA,GAAA,OAAA,CAAA,oBAAA,CAAA;;AAuBA,MAAMA,UAA2C,GAAjD,EAAA;;AAEA,SAAA,QAAA,CAAA,MAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAKQ;AACN,MAAI,QAAiC,CAArC,MAAA,EAA8C;AAC9C,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ocale,\n  getDomainLocale,\n  isLocalURL,\n  NextRouter,\n  PrefetchOptions,\n  resolveHref,\n} from '../next-server/lib/router/router'\nimport { useRouter } from './router'\nimport { useIntersection } from './use-intersection'\n\ntype Url = string | UrlObject\ntype RequiredKeys<T> = {\n  [K in keyof T]-?: {} extends Pick<T, K> ? never : K\n}[keyof T]\ntype OptionalKeys<T> = {\n  [K in keyof T]-?: {} extends Pick<T, K> ? K : never\n}[keyof T]\n\nexport type LinkProps = {\n  href: Url\n  as?: Url\n  replace?: boolean\n  scroll?: boolean\n  shallow?: boolean\n  passHref?: boolean\n  prefetch?: boolean\n  locale?: string | false\n}\ntype LinkPropsRequired = RequiredKeys<LinkProps>\ntype LinkPropsOptional = OptionalKeys<LinkProps>\n\nconst prefetched: { [cacheKey: string]: boolean } = {}\n\nfunction prefetch(\n  router: NextRouter,\n  href: string,\n  as: string,\n  options?: PrefetchOptions\n): void {\n  if (typeof window === 'undefined' || !router) return\n  if (!isLocalURL(href)) return\n  // Prefetch the JSON page if asked (only in the client)\n  // We need to handle a prefetch error here since we may be\n  // loading with priority which can reject but we don't\n  // want to force navigation since this is only a prefetch\n  router.prefetch(href, as, options).catch((err) => {\n    if (process.env.NODE_ENV !== 'production') {\n      // rethrow to show invalid URL errors\n      throw err\n    }\n  })\n  const curLocale =\n    options && typeof options.locale !== 'undefined'\n      ? options.locale\n      : router && router.locale\n\n  // Join on an invalid URI character\n  prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')] = true\n}\n\nfunction isModifiedEvent(event: React.MouseEvent): boolean {\n  const { target } = event.currentTarget as HTMLAnchorElement\n  return (\n    (target && target !== '_self') ||\n    event.metaKey ||\n    event.ctrlKey ||\n    event.shiftKey ||\n    event.altKey || // triggers resource download\n    (event.nativeEvent && event.nativeEvent.which === 2)\n  )\n}\n\nfunction linkClicked(\n  e: React.MouseEvent,\n  router: NextRouter,\n  href: string,\n  as: string,\n  replace?: boolean,\n  shallow?: boolean,\n  scroll?: boolean,\n  locale?: string | false\n): void {\n  const { nodeName } = e.currentTarget\n\n  if (nodeName === 'A' && (isModifiedEvent(e) || !isLocalURL(href))) {\n    // ignore click for browser’s default behavior\n    return\n  }\n\n  e.preventDefault()\n\n  //  avoid scroll for urls with anchor refs\n  if (scroll == null) {\n    scroll = as.indexOf('#') < 0\n  }\n\n  // replace state instead of push if prop is present\n  router[replace ? 'replace' : 'push'](href, as, {\n    shallow,\n    locale,\n    scroll,\n  }).then((success: boolean) => {\n    if (!success) return\n    if (scroll) {\n      // FIXME: proper route announcing at Router level, not Link:\n      document.body.focus()\n    }\n  })\n}\n\nfunction Link(props: React.PropsWithChildren<LinkProps>) {\n  if (process.env.NODE_ENV !== 'production') {\n    function createPropError(args: {\n      key: string\n      expected: string\n      actual: string\n    }) {\n      return new Error(\n        `Failed prop type: The prop \\`${args.key}\\` expects a ${args.expected} in \\`<Link>\\`, but got \\`${args.actual}\\` instead.` +\n          (typeof window !== 'undefined'\n            ? \"\\nOpen your browser's console to view the Component stack trace.\"\n            : '')\n      )\n    }\n\n    // TypeScript trick for type-guarding:\n    const requiredPropsGuard: Record<LinkPropsRequired, true> = {\n      href: true,\n    } as const\n    const requiredProps: LinkPropsRequired[] = Object.keys(\n      requiredPropsGuard\n    ) as LinkPropsRequired[]\n    requiredProps.forEach((key: LinkPropsRequired) => {\n      if (key === 'href') {\n        if (\n          props[key] == null ||\n          (typeof props[key] !== 'string' && typeof props[key] !== 'object')\n        ) {\n          throw createPropError({\n            key,\n            expected: '`string` or `object`',\n            actual: props[key] === null ? 'null' : typeof props[key],\n          })\n        }\n      } else {\n        // TypeScript trick for type-guarding:\n        // eslint-disable-next-line @typescript-eslint/no-unused-vars\n        const _: never = key\n      }\n    })\n\n    // TypeScript trick for type-guarding:\n    const optionalPropsGuard: Record<LinkPropsOptional, true> = {\n      as: true,\n      replace: true,\n      scroll: true,\n      shallow: true,\n      passHref: true,\n      prefetch: true,\n      locale: true,\n    } as const\n    const optionalProps: LinkPropsOptional[] = Object.keys(\n      optionalPropsGuard\n    ) as LinkPropsOptional[]\n    optionalProps.forEach((key: LinkPropsOptional) => {\n      const valType = typeof props[key]\n\n      if (key === 'as') {\n        if (props[key] && valType !== 'string' && valType !== 'object') {\n          throw createPropError({\n            key,\n            expected: '`string` or `object`',\n            actual: valType,\n          })\n        }\n      } else if (key === 'locale') {\n        if (props[key] && valType !== 'string') {\n          throw createPropError({\n            key,\n            expected: '`string`',\n            actual: valType,\n          })\n        }\n      } else if (\n        key === 'replace' ||\n        key === 'scroll' ||\n        key === 'shallow' ||\n        key === 'passHref' ||\n        key === 'prefetch'\n      ) {\n        if (props[key] != null && valType !== 'boolean') {\n          throw createPropError({\n            key,\n            expected: '`boolean`',\n            actual: valType,\n          })\n        }\n      } else {\n        // TypeScript trick for type-guarding:\n        // eslint-disable-next-line @typescript-eslint/no-unused-vars\n        const _: never = key\n      }\n    })\n\n    // This hook is in a conditional but that is ok because `process.env.NODE_ENV` never changes\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    const hasWarned = React.useRef(false)\n    if (props.prefetch && !hasWarned.current) {\n      hasWarned.current = true\n      console.warn(\n        'Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://err.sh/vercel/next.js/prefetch-true-deprecated'\n      )\n    }\n  }\n  const p = props.prefetch !== false\n\n  const router = useRouter()\n  const pathname = (router && router.pathname) || '/'\n\n  const { href, as } = React.useMemo(() => {\n    const [resolvedHref, resolvedAs] = resolveHref(pathname, props.href, true)\n    return {\n      href: resolvedHref,\n      as: props.as\n        ? resolveHref(pathname, props.as)\n        : resolvedAs || resolvedHref,\n    }\n  }, [pathname, props.href, props.as])\n\n  let { children, replace, shallow, scroll, locale } = props\n\n  // Deprecated. Warning shown by propType check. If the children provided is a string (<Link>example</Link>) we wrap it in an <a> tag\n  if (typeof children === 'string') {\n    children = <a>{children}</a>\n  }\n\n  // This will return the first child, if multiple are provided it will throw an error\n  const child: any = Children.only(children)\n  const childRef: any = child && typeof child === 'object' && child.ref\n\n  const [setIntersectionRef, isVisible] = useIntersection({\n    rootMargin: '200px',\n  })\n  const setRef = React.useCallback(\n    (el: Element) => {\n      setIntersectionRef(el)\n      if (childRef) {\n        if (typeof childRef === 'function') childRef(el)\n        else if (typeof childRef === 'object') {\n          childRef.current = el\n        }\n      }\n    },\n    [childRef, setIntersectionRef]\n  )\n  useEffect(() => {\n    const shouldPrefetch = isVisible && p && isLocalURL(href)\n    const curLocale =\n      typeof locale !== 'undefined' ? locale : router && router.locale\n    const isPrefetched =\n      prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')]\n    if (shouldPrefetch && !isPrefetched) {\n      prefetch(router, href, as, {\n        locale: curLocale,\n      })\n    }\n  }, [as, href, isVisible, locale, p, router])\n\n  const childProps: {\n    onMouseEnter?: React.MouseEventHandler\n    onClick: React.MouseEventHandler\n    href?: string\n    ref?: any\n  } = {\n    ref: setRef,\n    onClick: (e: React.MouseEvent) => {\n      if (child.props && typeof child.props.onClick === 'function') {\n        child.props.onClick(e)\n      }\n      if (!e.defaultPrevented) {\n        linkClicked(e, router, href, as, replace, shallow, scroll, locale)\n      }\n    },\n  }\n\n  childProps.onMouseEnter = (e: React.MouseEvent) => {\n    if (!isLocalURL(href)) return\n    if (child.props && typeof child.props.onMouseEnter === 'function') {\n      child.props.onMouseEnter(e)\n    }\n    prefetch(router, href, as, { priority: true })\n  }\n\n  // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is\n  // defined, we specify the current 'href', so that repetition is not needed by the user\n  if (props.passHref || (child.type === 'a' && !('href' in child.props))) {\n    const curLocale =\n      typeof locale !== 'undefined' ? locale : router && router.locale\n\n    // we only render domain locales if we are currently on a domain locale\n    // so that locale links are still visitable in development/preview envs\n    const localeDomain =\n      router &&\n      router.isLocaleDomain &&\n      getDomainLocale(\n        as,\n        curLocale,\n        router && router.locales,\n        router && router.domainLocales\n      )\n\n    childProps.href =\n      localeDomain ||\n      addBasePath(addLocale(as, curLocale, router && router.defaultLocale))\n  }\n\n  return React.cloneElement(child, childProps)\n}\n\nexport default Link\n"]},"metadata":{},"sourceType":"script"}