{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/esm/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/esm/getPrototypeOf\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nvar __jsx = React.createElement;\n\nfunction _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\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\nvar removeWithTranslationProps = function removeWithTranslationProps(props) {\n  var 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\nvar Link = /*#__PURE__*/function (_React$Component) {\n  _inherits(Link, _React$Component);\n\n  var _super = _createSuper(Link);\n\n  function Link() {\n    _classCallCheck(this, Link);\n\n    return _super.apply(this, arguments);\n  }\n\n  _createClass(Link, [{\n    key: \"render\",\n    value: function render() {\n      var _this$props = this.props,\n          as = _this$props.as,\n          children = _this$props.children,\n          href = _this$props.href,\n          i18n = _this$props.i18n,\n          nextI18NextInternals = _this$props.nextI18NextInternals,\n          props = _objectWithoutProperties(_this$props, [\"as\", \"children\", \"href\", \"i18n\", \"nextI18NextInternals\"]);\n\n      var config = nextI18NextInternals.config;\n      var language = i18n.language;\n\n      if (subpathIsRequired(config, language)) {\n        var _lngPathCorrector = lngPathCorrector(config, {\n          as: as,\n          href: href\n        }, language),\n            correctedAs = _lngPathCorrector.as,\n            correctedHref = _lngPathCorrector.href;\n\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  return Link;\n}(React.Component);\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"}