{"ast":null,"code":"var __jsx = React.createElement;\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n/*\n  This `Link` component is a wrap of the standard\n  NextJs `Link` component, with some simple lang\n  redirect logic in place.\n\n  If you haven't already, read this issue comment:\n  https://github.com/zeit/next.js/issues/2833#issuecomment-414919347\n\n  This component automatically provides this functionality:\n  <Link href=\"/product?slug=something\" as=\"/products/something\">\n\n  Wherein `slug` is actually our i18n lang, and it gets\n  pulled automatically.\n\n  Very important: if you import `Link` from NextJs directly,\n  and not this file, your lang subpath routing will break.\n*/\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport NextLink from 'next/link';\nimport { lngPathCorrector, subpathIsRequired } from '../utils';\nimport React from 'react';\nimport { withTranslation } from 'react-i18next';\n\nconst removeWithTranslationProps = props => {\n  const strippedProps = Object.assign({}, props);\n  delete strippedProps.defaultNS;\n  delete strippedProps.i18n;\n  delete strippedProps.i18nOptions;\n  delete strippedProps.lng;\n  delete strippedProps.reportNS;\n  delete strippedProps.t;\n  delete strippedProps.tReady;\n  delete strippedProps.forwardedRef;\n  return strippedProps;\n};\n\nclass Link extends React.Component {\n  render() {\n    const _this$props = this.props,\n          {\n      as,\n      children,\n      href,\n      i18n,\n      nextI18NextInternals\n    } = _this$props,\n          props = _objectWithoutProperties(_this$props, [\"as\", \"children\", \"href\", \"i18n\", \"nextI18NextInternals\"]);\n\n    const {\n      config\n    } = nextI18NextInternals;\n    const {\n      language\n    } = i18n;\n\n    if (subpathIsRequired(config, language)) {\n      const {\n        as: correctedAs,\n        href: correctedHref\n      } = lngPathCorrector(config, {\n        as,\n        href\n      }, language);\n      return __jsx(NextLink, _extends({\n        href: correctedHref,\n        as: correctedAs\n      }, removeWithTranslationProps(props)), children);\n    }\n\n    return __jsx(NextLink, _extends({\n      href: href,\n      as: as\n    }, removeWithTranslationProps(props)), children);\n  }\n\n}\n/*\n  Usage of `withTranslation` here is just to\n  force `Link` to rerender on language change\n*/\n\n\n_defineProperty(Link, \"defaultProps\", {\n  as: undefined\n});\n\nexport default withTranslation()(Link);","map":null,"metadata":{},"sourceType":"module"}