{"ast":null,"code":"/*\n  This `Router` is a wrap of the standard\n  NextJs `Router`, 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  Very important: if you import `Router` 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 NextRouter from 'next/router';\nimport { lngPathCorrector, subpathIsRequired } from '../utils';\nvar propertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'events'];\nvar coreMethods = ['reload', 'back', 'beforePopState', 'ready', 'prefetch'];\nvar wrappedMethods = ['push', 'replace'];\nexport var wrapRouter = function wrapRouter(nextI18NextInternals) {\n  var Router = {};\n  propertyFields.forEach(function (field) {\n    Object.defineProperty(Router, field, {\n      get: function get() {\n        return NextRouter[field];\n      }\n    });\n  });\n  coreMethods.forEach(function (method) {\n    Router[method] = function () {\n      var _ref;\n\n      return (_ref = NextRouter)[method].apply(_ref, arguments);\n    };\n  });\n  wrappedMethods.forEach(function (method) {\n    Router[method] = function (path, as, options) {\n      var config = nextI18NextInternals.config,\n          i18n = nextI18NextInternals.i18n;\n\n      if (subpathIsRequired(config, i18n.languages[0])) {\n        var _lngPathCorrector = lngPathCorrector(config, {\n          as: as,\n          href: path\n        }, i18n.languages[0]),\n            correctedAs = _lngPathCorrector.as,\n            correctedHref = _lngPathCorrector.href;\n\n        return NextRouter[method](correctedHref, correctedAs, options);\n      }\n\n      return NextRouter[method](path, as, options);\n    };\n  });\n  return Router;\n};","map":null,"metadata":{},"sourceType":"module"}