{"version":3,"sources":["webpack:///src/var/www/virtualhost/client.tk.salome.ee/www/develop/src/main.ts","webpack:///src/var/www/virtualhost/client.tk.salome.ee/www/develop/src/main-router.ts","webpack:///./src/main-router.html"],"names":["configure","aurelia","window","location","pathname","replace","use","standardConfiguration","feature","plugin","config","init","attach","logging","enabled","pageTracking","ignore","fragments","routes","routeNames","getTitle","payload","document","title","getUrl","href","clickTracking","filter","element","HTMLElement","nodeName","toLowerCase","exceptionTracking","instance","aliases","configureAliases","i18next","with","loader","setup","backend","loadPath","attributes","lng","fallbackLng","debug","setEnvironments","local","dev","stage","prod","start","then","setRoot","addAppender","setLevel","logLevel","warn","warnings","wForgottenReturn","log","getLogger","appConfig","eventAggregator","cartService","userService","warehouseService","transportService","i18n","authInterceptor","container","currentYear","Date","getFullYear","currentLocaleClass","cartBadge","cartSync","isLoggedIn","updateTotal","this","registerInstance","register","delimiters","thousands","decimal","abbreviations","thousand","million","billion","trillion","ordinal","currency","symbol","locale","subscribe","localeChanged","getLocaleClass","cartProductsChanged","changedHere","sessionEnded","cartBadgeChanged","value","push","subscribeOnce","userSettingsLoaded","loadNames","event","currentRoute","instruction","name","ensureLoaded","activate","loadSettings","warningForOldBrowsers","configureRouter","router","transformTitle","tr","pageTitle","addAuthorizeStep","AuthorizeStep","options","pushState","root","map","route","moduleId","settings","auth","mapUnknownRoutes","fallbackRoute","getSettings","result","setSettings","catch","error","handleBackgroundLoadError","setLocale","userSettings","warehouseId","contractSettings","contract","getWarehouseTransportOptions","setTransportOptions","getWarehouses","setAllowedWarehouses","changeLocale","saveLocale","updateSettings","logout","token","beginFetch","fetchCurrent","cartPreview","acceptFetch","products","Wholesale","handleRequestNoise","showErrorToast","getErrorMessage","browser","navigator","userAgent","indexOf","body","textContent","getBrowser","tem","ua","M","match","test","exec","slice","join","appName","appVersion","splice","MainRouter","navigate","run","next","getAllInstructions","some","i","saveNextRoute","cancel","redirectUri","tryReturnTo","module","exports"],"mappings":"wrEAcO,SAAeA,EAAUC,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E7DE,EAAEK,KAAK,OA9YLI,EAAU,GADtB,I,uBAU+B,mB,OAAA,IAAT,UAAS,SACY,mBADZ,OACY,IAAf,sCAAe,SACR,mBADQ,OACR,IAAX,UAAW,SACA,mBADA,OACA,IAAX,UAAW,SACU,mBADV,OACU,IAAhB,UAAgB,SACA,mBADA,OACA,IAAhB,UAAgB,SACxB,mBADwB,OACxB,IAAJ,gBAAI,SACsB,mBADtB,OACsB,IAAf,UAAe,SACpB,mBADoB,OACpB,IAAT,UAAS,YAjBXA,GAAb,GAsZA,aACE,WACUpH,EACAqH,EACA9G,GAFA,KAAAP,YACA,KAAAqH,WACA,KAAA9G,kB,UAsBZ,OAnBE,YAAA+G,IAAA,SAAIxE,EAAoCyE,GAEtC,IADqBzE,EAAY0E,qBAAqBC,MAAK,SAAAC,GAAK,OAAAA,EAAE9K,OAAOqH,SAASC,QAEhF,OAAOqD,IAGT,IAAKtG,KAAKjB,UAAUe,WAGlB,OAFAE,KAAKoG,SAASM,cAAc7E,GAC5B7B,KAAKV,gBAAgBgF,SACdgC,EAAKK,OAAO,IAAI,IAAS,eAGlC,IAAMC,EAAc5G,KAAKoG,SAASS,cAClC,OAAID,EACKN,EAAKK,OAAO,IAAI,IAASC,IAG3BN,KAxBL7D,EAAa,GADlB,I,uBAG+B,mB,OAAA,IAAT,UAAS,SACW,mBADX,OACW,IAArB,UAAqB,SACC,mBADD,OACC,IAAf,UAAe,YAJtCA,GAAN,I,mCCtbAqE,EAAOC,QAAU","file":"app~bae3a95e.8c6e6ae14b4c9e4d7cce.chunk.js","sourcesContent":["import { Aurelia } from \"aurelia-framework\";\nimport { PLATFORM } from \"aurelia-pal\";\nimport * as Bluebird from \"bluebird\";\nimport { LogManager } from \"aurelia-framework\";\nimport { ConsoleAppender } from \"aurelia-logging-console\";\nimport { I18N, Backend, TCustomAttribute } from \"aurelia-i18n\";\nimport { isErrorPageBoot } from \"pages/error/boot\";\n\nLogManager.addAppender(new ConsoleAppender());\nLogManager.setLevel(LogManager.logLevel.warn);\n\n// remove out if you don't want a Promise polyfill (remove also from webpack.config.js)\nBluebird.config({ warnings: { wForgottenReturn: false } });\n\nexport async function configure(aurelia: Aurelia) {\n  // A real browser load of /error never goes through in-session fallback.\n  // Redirect before the router starts so the error page is not shown.\n  if (isErrorPageBoot(window.location.pathname)) {\n    window.location.replace(\"/\");\n    return;\n  }\n\n  aurelia.use.standardConfiguration().feature(PLATFORM.moduleName(\"resources/index\"));\n\n  // Added plugins\n  aurelia.use.plugin(PLATFORM.moduleName(\"aurelia-google-analytics\"), (config: any) => {\n    config.init(\"UA-2779760-6\");\n    config.attach({\n      logging: {\n        // Set to `true` to have some log messages appear in the browser console.\n        enabled: true,\n      },\n      pageTracking: {\n        // Set to `false` to disable in non-production environments.\n        enabled: true,\n        // Configure fragments/routes/route names to ignore page tracking for\n        ignore: {\n          fragments: [], // Ignore a route fragment, login fragment for example: ['/login']\n          routes: [], // Ignore a route, login route for example: ['login']\n          routeNames: [], // Ignore a route name, login route name for example: ['login-route']\n        },\n        // Optional. By default it gets the title from payload.instruction.config.title.\n        getTitle: (payload: any) => {\n          // For example, if you want to retrieve the tile from the document instead override with the following.\n          return document.title;\n        },\n        // Optional. By default it gets the URL fragment from payload.instruction.fragment.\n        getUrl: (payload: any) => {\n          // For example, if you want to get full URL each time override with the following.\n          return window.location.href;\n        },\n      },\n      clickTracking: {\n        // Set to `false` to disable in non-production environments.\n        enabled: true,\n        // Optional. By default it tracks clicks on anchors and buttons.\n        filter: (element: any) => {\n          // For example, if you want to also track clicks on span elements override with the following.\n          return (\n            element instanceof HTMLElement &&\n            (element.nodeName.toLowerCase() === \"a\" ||\n              element.nodeName.toLowerCase() === \"button\" ||\n              element.nodeName.toLowerCase() === \"span\")\n          );\n        },\n      },\n      exceptionTracking: {\n        // Set to `false` to disable in non-production environments.\n        enabled: true,\n      },\n    });\n  });\n\n  aurelia.use.plugin(PLATFORM.moduleName(\"aurelia-i18n\"), (instance: I18N) => {\n    const aliases = [\"t\", \"i18n\"];\n\n    TCustomAttribute.configureAliases(aliases);\n    instance.i18next.use(Backend.with(aurelia.loader));\n\n    // adapt options to your needs (see http://i18next.com/docs/options/)\n    return instance.setup({\n      backend: {\n        // this doesn't like dashes and will lose everything after \"-\" from \"lng\"\n        // even though loads default \"lng\" just fine and second attempt of other languages too\n        loadPath: \"locales/{{lng}}.json\",\n      },\n      attributes: aliases,\n      lng: \"et_EE\",\n      fallbackLng: \"et_EE\",\n      debug: false,\n    });\n  });\n\n  aurelia.use.plugin(PLATFORM.moduleName(\"aurelia-cookie\"));\n  aurelia.use.plugin(PLATFORM.moduleName(\"aurelia-configuration\"), (config: any) => {\n    config.setEnvironments({\n      local: [\"localhost:8080\"],\n      dev: [\"develop.client.tk.salome.ee.nuhvel.eu\"],\n      stage: [\"staging.client.tk.salome.ee.nuhvel.eu\"],\n      prod: [\"client.tk.salome.ee.nuhvel.eu\", \"tk.salome.ee\"],\n    });\n  });\n\n  // Uncomment the line below to enable animation.\n  // aurelia.use.plugin(PLATFORM.moduleName('aurelia-animator-css'));\n  // if the css animator is enabled, add swap-order=\"after\" to all router-view elements\n\n  // Anyone wanting to use HTMLImports to load views, will need to install the following plugin.\n  // aurelia.use.plugin(PLATFORM.moduleName('aurelia-html-import-template-loader'));\n\n  //aurelia.use.developmentLogging('debug');\n\n  /*if (environment.testing)\n    aurelia.use.plugin(PLATFORM.moduleName('aurelia-testing'));*/\n\n  return aurelia.start().then(() => aurelia.setRoot(PLATFORM.moduleName(\"main-router\")));\n}\n","import { I18N } from \"aurelia-i18n\";\nimport { TransportService } from \"services/client/transport-service\";\nimport { WarehouseService } from \"services/client/warehouse-service\";\nimport { UserService } from \"services/identity/user-service\";\nimport { Utils } from \"utils/helpers/utils\";\nimport { isRequestNoise } from \"utils/helpers/request-errors\";\nimport { TKEvent } from \"utils/enums/TKEvent\";\nimport { CartService } from \"services/cart/cart-service\";\nimport { ICart } from \"domain/Cart/ICart\";\nimport { Container, LogManager, autoinject, PLATFORM } from \"aurelia-framework\";\nimport {\n  RouterConfiguration,\n  Router,\n  NavigationInstruction,\n  Next,\n  Redirect,\n  PipelineResult,\n} from \"aurelia-router\";\nimport { AppConfig } from \"app-config\";\nimport numeral from \"numeral\";\nimport { EventAggregator } from \"aurelia-event-aggregator\";\nimport { NotAuthorizedRedirect } from \"utils/classes/NotAuthorizedRedirect\";\nimport { AuthInterceptor } from \"utils/classes/AuthInterceptor\";\nimport { unknownRouteFallback } from \"pages/error/boot\";\n\nimport { CartBadgeState, CartBadgeValue } from \"domain/Cart/CartBadge\";\nimport { CartSync, browserCartSyncEnv } from \"domain/Cart/CartSync\";\nimport { PriceType } from \"utils/enums/PriceType\";\n\nexport const log = LogManager.getLogger(\"app.main-router\");\n\n@autoinject\nexport class MainRouter {\n  router: Router;\n\n  cartPreview: ICart;\n\n  currentYear = new Date().getFullYear();\n  currentLocaleClass = \"flag-icon-ee\";\n\n  constructor(\n    private appConfig: AppConfig,\n    private eventAggregator: EventAggregator,\n    private cartService: CartService,\n    private userService: UserService,\n    private warehouseService: WarehouseService,\n    private transportService: TransportService,\n    private i18n: I18N,\n    private authInterceptor: AuthInterceptor,\n    container: Container,\n  ) {\n    this.authInterceptor = authInterceptor;\n    container.registerInstance(CartSync, this.cartSync);\n\n    numeral.register(\"locale\", \"et\", {\n      delimiters: { thousands: \" \", decimal: \",\" },\n      abbreviations: {\n        thousand: \" tuh\",\n        million: \" mln\",\n        billion: \" mld\",\n        trillion: \" trl\",\n      },\n      ordinal: () => \".\",\n      currency: { symbol: \"€\" },\n    });\n    numeral.locale(\"et\");\n\n    this.eventAggregator.subscribe(TKEvent.localeChanged, (locale: string) => {\n      // this.i18n.getLocale() returns wrong data here for some reason\n      this.currentLocaleClass = Utils.getLocaleClass(locale);\n    });\n    // SAL-165: refresh here and in the other open tabs.\n    this.eventAggregator.subscribe(TKEvent.cartProductsChanged, () => {\n      this.cartSync.changedHere();\n    });\n    this.eventAggregator.subscribe(TKEvent.sessionEnded, () => this.cartSync.sessionEnded());\n    this.cartSync.start();\n    this.eventAggregator.subscribe(TKEvent.cartBadgeChanged, (value: CartBadgeValue) => {\n      this.cartBadge.push(value);\n    });\n    this.eventAggregator.subscribeOnce(TKEvent.userSettingsLoaded, () => {\n      this.loadNames();\n    });\n    this.eventAggregator.subscribe(\n      \"router:navigation:success\",\n      (event: { instruction: NavigationInstruction; result: PipelineResult }) => {\n        const currentRoute = event.instruction.config.name;\n        if (currentRoute === undefined || currentRoute === null) return;\n\n        // SAL-165: only the first route of a session (e.g. right after login) loads the\n        // cart; every later route change used to refetch it (~100x more than add-to-cart).\n        this.cartSync.ensureLoaded();\n      },\n    );\n  }\n\n  // called only once: when the site is opened or refreshed\n  activate() {\n    // The VAT rate arrives with the user's settings, see AppConfig.setSettings\n\n    // If user is already logged in (refreshed the page). The cart total follows from the first\n    // router:navigation:success, so it is not fetched here as well.\n    if (this.appConfig.isLoggedIn) {\n      this.loadSettings();\n    }\n\n    this.warningForOldBrowsers();\n  }\n\n  configureRouter(config: RouterConfiguration, router: Router) {\n    this.router = router;\n\n    this.router.transformTitle = title => this.i18n.tr(\"general.title\", { pageTitle: title });\n\n    config.addAuthorizeStep(AuthorizeStep);\n\n    config.options.pushState = true;\n    config.options.root = \"/\";\n\n    config.map([\n      {\n        route: \"\",\n        name: \"home\",\n        title: this.i18n.tr(\"pages.home.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/home\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"error\",\n        name: \"errorIndex\",\n        title: this.i18n.tr(\"pages.error.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/error/index\"),\n        settings: { auth: false },\n      },\n      {\n        route: \"privacy\",\n        name: \"privacyIndex\",\n        title: this.i18n.tr(\"pages.privacy.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/privacy/index\"),\n        settings: { auth: false },\n      },\n\n      {\n        route: \"search/:query/:page?/:type?/:extendedSearch?\",\n        name: \"searchResult\",\n        title: this.i18n.tr(\"pages.search.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/search/index\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"car/manufacturers\",\n        name: \"carManufacturers\",\n        title: this.i18n.tr(\"pages.manufacturers.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/car/manufacturers\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"car/models/:id/:name/:query?\",\n        name: \"carModels\",\n        title: this.i18n.tr(\"pages.models.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/car/models\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"car/vehicles/:query\",\n        name: \"carVehiclesQuery\",\n        title: this.i18n.tr(\"pages.vehicles.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/car/vehicles\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"car/vehicles/:manuId/:modelId/:query?\",\n        name: \"carVehicles\",\n        title: this.i18n.tr(\"pages.vehicles.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/car/vehicles\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"catalogue/list/:vehicleId/:query?\",\n        name: \"catalogueList\",\n        title: this.i18n.tr(\"pages.car.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/catalogue/list\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"catalogue/products/:vehicleId/:catalogueId/:catalogueName/:page?\",\n        name: \"catalogueProducts\",\n        title: this.i18n.tr(\"pages.catalogue.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/catalogue/products\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"category/manufacturers/:categoryId\",\n        name: \"categoryManufacturers\",\n        title: this.i18n.tr(\"pages.manufacturers.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/category/manufacturers\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"category/models/:categoryId/:manufacturer\",\n        name: \"categoryModels\",\n        title: this.i18n.tr(\"pages.models.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/category/models\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"category/vehicles/:categoryId/:manufacturer/:model\",\n        name: \"categoryVehicles\",\n        title: this.i18n.tr(\"pages.vehicles.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/category/vehicles\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"category/products/:categoryId/:page/:vehicleId?\",\n        name: \"categoryProducts\",\n        title: this.i18n.tr(\"pages.category.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/category/products\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"cart\",\n        name: \"cartIndex\",\n        title: this.i18n.tr(\"pages.cart.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/cart/index\"),\n        settings: { auth: true },\n      },\n      /* {\n        route: 'cart/:id', name: 'cartInfo', title: 'Ostukorv',\n        moduleId: PLATFORM.moduleName('pages/cart/info'), settings: { auth: true }\n      },*/\n\n      {\n        route: \"order/:page?\",\n        name: \"orderIndex\",\n        title: this.i18n.tr(\"pages.orders.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/order/index\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"invoice/:page?\",\n        name: \"invoiceIndex\",\n        title: this.i18n.tr(\"pages.invoices.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/invoice/index\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"return/:page?\",\n        name: \"returnIndex\",\n        title: this.i18n.tr(\"pages.returns.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/return/index\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"contact\",\n        name: \"contactIndex\",\n        title: this.i18n.tr(\"pages.contact.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/contact/index\"),\n        settings: { auth: true },\n      },\n\n      {\n        route: \"user\",\n        name: \"userAccount\",\n        title: this.i18n.tr(\"pages.user.settings.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/user/index\"),\n        settings: { auth: true },\n      },\n      {\n        route: \"user/login\",\n        name: \"userLogin\",\n        title: this.i18n.tr(\"pages.user.login.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/user/login\"),\n        settings: { auth: false },\n      },\n      {\n        route: \"user/admin/:email/:token\",\n        name: \"userAdmin\",\n        moduleId: PLATFORM.moduleName(\"pages/user/admin\"),\n        settings: { auth: false },\n      },\n      {\n        route: \"user/reset/:locale/:email/:token\",\n        name: \"userReset\",\n        title: this.i18n.tr(\"pages.user.reset.title\"),\n        moduleId: PLATFORM.moduleName(\"pages/user/reset\"),\n        settings: { auth: false },\n      },\n    ]);\n\n    // fallbackRoute only restores a cancelled nav when there is no previous\n    // location. In-session unknown URLs would otherwise replace back to home.\n    config.mapUnknownRoutes(unknownRouteFallback);\n    config.fallbackRoute(\"error\");\n  }\n\n  // #region LOAD\n\n  loadSettings() {\n    this.userService\n      .getSettings()\n      .then(result => {\n        if (!result) {\n          log.warn(\"User settings were not returned\");\n          return;\n        }\n\n        this.appConfig.setSettings(result);\n      })\n      .catch(error => Utils.handleBackgroundLoadError(log, error, this.i18n, \"Load user settings\"));\n  }\n\n  loadNames() {\n    this.setLocale(this.appConfig.userSettings.locale);\n\n    const warehouseId = this.appConfig.contractSettings.contract.warehouseId;\n    this.transportService\n      .getWarehouseTransportOptions(warehouseId)\n      .then(result => {\n        this.appConfig.setTransportOptions(result);\n      })\n      .catch(error =>\n        Utils.handleBackgroundLoadError(log, error, this.i18n, \"Load transport options\"),\n      );\n\n    this.warehouseService\n      .getWarehouses()\n      .then(result => {\n        this.appConfig.setAllowedWarehouses(result);\n      })\n      .catch(error => Utils.handleBackgroundLoadError(log, error, this.i18n, \"Load warehouses\"));\n  }\n\n  // #endregion\n\n  // #region ACTIONS\n\n  setLocale(locale: string) {\n    Utils.setLocale(this.eventAggregator, this.i18n, locale);\n  }\n\n  changeLocale(locale: string) {\n    this.setLocale(locale);\n    this.saveLocale(locale);\n  }\n\n  saveLocale(locale: string) {\n    if (!this.appConfig.userSettings) return;\n\n    this.appConfig.userSettings.locale = locale;\n\n    this.userService.updateSettings();\n  }\n\n  logout() {\n    this.authInterceptor.logout();\n  }\n\n  // #endregion\n\n  // #region HELPERS\n\n  /** SAL-283 QA r5: one badge total (see domain/Cart/CartBadge); the cart page pushes it directly. */\n  cartBadge = new CartBadgeState();\n\n  /** SAL-165: when the cart is fetched (once per load, after changes, other tabs, focus, cart-page poll). */\n  cartSync = new CartSync(\n    browserCartSyncEnv(),\n    () => this.appConfig.isLoggedIn,\n    () => this.updateTotal(),\n  );\n\n  updateTotal() {\n    const token = this.cartBadge.beginFetch();\n    return this.cartService\n      .fetchCurrent()\n      .then(result => {\n        this.cartPreview = result;\n        this.cartBadge.acceptFetch(token, result?.products as any, PriceType.Wholesale);\n      })\n      .catch(error => {\n        if (isRequestNoise(error)) return Utils.handleRequestNoise(log, error, this.i18n);\n        Utils.showErrorToast(log, Utils.getErrorMessage(error, this.i18n));\n      });\n  }\n\n  // Use pure JS to display a warning for users of old browsers that aren't supported\n  warningForOldBrowsers() {\n    const browser = window.navigator.userAgent;\n\n    document.title = this.i18n.tr(\"general.title\", {\n      pageTitle: this.i18n.tr(\"pages.home.title\"),\n    });\n\n    // Internet Explorer\n    if (browser.indexOf(\"Trident\") > -1 || browser.indexOf(\"MSIE\") > -1) {\n      document.body.textContent = this.i18n.tr(\"general.errors.old-browser\", {\n        browser: this.getBrowser(),\n      });\n    }\n  }\n\n  // (c) https://stackoverflow.com/a/5918791/\n  getBrowser() {\n    const ua = navigator.userAgent;\n    let tem;\n    let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\\/))\\/?\\s*(\\d+)/i) || [];\n\n    // IE\n    if (/trident/i.test(M[1])) {\n      tem = /\\brv[ :]+(\\d+)/.exec(ua) || [];\n      return \"IE \" + (tem[1] || \"\");\n    }\n\n    // Chromium\n    if (M[1] === \"Chrome\") {\n      tem = ua.match(/\\b(OPR|Edge)\\/(\\d+)/);\n      if (tem != null) return tem.slice(1).join(\" \").replace(\"OPR\", \"Opera\");\n    }\n\n    M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, \"-?\"];\n\n    if ((tem = ua.match(/version\\/(\\d+)/i)) != null) M.splice(1, 1, tem[1]);\n\n    return M.join(\" \");\n  }\n\n  // #endregion\n}\n\n// (c) https://aurelia.io/docs/routing/configuration#pipelines\n@autoinject\nclass AuthorizeStep {\n  constructor(\n    private appConfig: AppConfig,\n    private navigate: NotAuthorizedRedirect,\n    private authInterceptor: AuthInterceptor,\n  ) {}\n\n  run(instruction: NavigationInstruction, next: Next): Promise<any> {\n    const requiresAuth = instruction.getAllInstructions().some(i => i.config.settings.auth);\n    if (!requiresAuth) {\n      return next();\n    }\n\n    if (!this.appConfig.isLoggedIn) {\n      this.navigate.saveNextRoute(instruction);\n      this.authInterceptor.logout();\n      return next.cancel(new Redirect(\"user/login\"));\n    }\n\n    const redirectUri = this.navigate.tryReturnTo();\n    if (redirectUri) {\n      return next.cancel(new Redirect(redirectUri));\n    }\n\n    return next();\n  }\n}\n","module.exports = \"<template>\\n  <require from=\\\"utils/classes/value-converters\\\"></require>\\n  <require from=\\\"components/general/toast\\\"></require>\\n  <require from=\\\"components/general/feedback-form\\\"></require>\\n  <require from=\\\"bootstrap/dist/css/bootstrap.min.css\\\"></require>\\n  <require from=\\\"flag-icon-css/css/flag-icon.min.css\\\"></require>\\n  <require from=\\\"resources/style.css\\\"></require>\\n  <require from=\\\"resources/mobile.css\\\"></require>\\n  <require from=\\\"/node_modules/bootstrap-icons/font/bootstrap-icons.css\\\"></require>\\n\\n  <div class=\\\"toast-container position-fixed top-0 end-0 mt-5 me-3 me-md-5\\\">\\n    <toast\\n      toast-class=\\\"error-toast\\\"\\n      message-class=\\\"text-danger\\\"\\n      message=\\\"${'components.toast.titles.error' & t}\\\"></toast>\\n    <toast\\n      toast-class=\\\"info-toast\\\"\\n      message-class=\\\"text-info\\\"\\n      message=\\\"${'components.toast.titles.info' & t}\\\"></toast>\\n    <toast\\n      toast-class=\\\"success-toast\\\"\\n      message-class=\\\"text-success\\\"\\n      message=\\\"${'components.toast.titles.success' & t}\\\"></toast>\\n  </div>\\n\\n  <div class=\\\"container-xl\\\">\\n    <nav class=\\\"navbar navbar-expand-lg navbar-light\\\">\\n      <a class=\\\"navbar-brand py-0\\\" href=\\\"#\\\">\\n        <img src=\\\"/salome-group-small.png\\\" class=\\\"img-fluid logo-image\\\" />\\n      </a>\\n\\n      <button\\n        if.bind=\\\"appConfig.isLoggedIn\\\"\\n        type=\\\"button\\\"\\n        class=\\\"navbar-toggler\\\"\\n        data-bs-toggle=\\\"collapse\\\"\\n        data-bs-target=\\\"#navbar-menu\\\">\\n        <span class=\\\"navbar-toggler-icon\\\"></span>\\n      </button>\\n\\n      <div if.bind=\\\"appConfig.isLoggedIn\\\" class=\\\"collapse navbar-collapse\\\" id=\\\"navbar-menu\\\">\\n        <div class=\\\"navbar-nav ms-auto\\\">\\n          <div class=\\\"dropdown\\\">\\n            <a\\n              class=\\\"nav-item nav-link dropdown-toggle\\\"\\n              href=\\\"\\\"\\n              role=\\\"button\\\"\\n              data-bs-toggle=\\\"dropdown\\\">\\n              ${'menu.help.title' & t}\\n            </a>\\n            <div class=\\\"dropdown-menu\\\">\\n              <a class=\\\"dropdown-item\\\" href=\\\"${'menu.help.children.pricing.link' & t}\\\">\\n                ${'menu.help.children.pricing.title' & t}\\n              </a>\\n              <a class=\\\"dropdown-item\\\" route-href=\\\"route: returnIndex\\\">\\n                ${'menu.help.children.returns.title' & t}\\n              </a>\\n              <a\\n                class=\\\"dropdown-item\\\"\\n                href=\\\"${'menu.help.children.warranty.link' & t}\\\"\\n                target=\\\"_blank\\\">\\n                ${'menu.help.children.warranty.title' & t}\\n              </a>\\n              <a class=\\\"dropdown-item\\\" route-href=\\\"route: privacyIndex\\\">\\n                ${'menu.help.children.privacy.title' & t}\\n              </a>\\n              <a class=\\\"dropdown-item\\\" route-href=\\\"route: contactIndex\\\">\\n                ${'menu.help.children.contact.title' & t}\\n              </a>\\n            </div>\\n          </div>\\n\\n          <a class=\\\"nav-item nav-link\\\" route-href=\\\"route: userAccount\\\">\\n            ${'menu.settings.title' & t}\\n          </a>\\n          <a class=\\\"nav-item nav-link\\\" route-href=\\\"route: invoiceIndex\\\">\\n            ${'menu.invoices.title' & t}\\n          </a>\\n          <a class=\\\"nav-item nav-link\\\" route-href=\\\"route: orderIndex\\\">\\n            ${'menu.orders.title' & t}\\n          </a>\\n\\n          <a class=\\\"nav-item nav-link\\\" route-href=\\\"route: cartIndex\\\">\\n            ${'menu.cart.title' & t}\\n            <template\\n              if.bind=\\\"cartBadge.count > 0\\\">\\n              <span class=\\\"badge rounded-pill badge-outline-secondary\\\"> ${cartBadge.count} </span>\\n              <span class=\\\"badge rounded-pill badge-outline-secondary\\\"> ${cartBadge.totalWithoutVat | currencyFormat} </span>\\n            </template>\\n          </a>\\n        </div>\\n      </div>\\n    </nav>\\n\\n    <compose\\n      if.bind=\\\"appConfig.isLoggedIn\\\"\\n      view-model=\\\"components/product/search/search-bar\\\"></compose>\\n\\n    <main class=\\\"mt-3 mb-3\\\">\\n      <router-view></router-view>\\n    </main>\\n  </div>\\n\\n  <footer class=\\\"footer mt-auto\\\">\\n    <div class=\\\"container-xl\\\">\\n      <nav class=\\\"navbar navbar-expand-lg navbar-light\\\">\\n        <span class=\\\"text-muted text-nowrap\\\">${'footer.copyright' & t: {'year': currentYear}}</span>\\n\\n        <button\\n          type=\\\"button\\\"\\n          class=\\\"navbar-toggler\\\"\\n          data-bs-toggle=\\\"collapse\\\"\\n          data-bs-target=\\\"#navbar-footer\\\">\\n          <span class=\\\"navbar-toggler-icon\\\"></span>\\n        </button>\\n\\n        <div class=\\\"collapse navbar-collapse\\\" id=\\\"navbar-footer\\\">\\n          <div class=\\\"navbar-nav ms-auto\\\">\\n            <div class=\\\"dropup\\\">\\n              <a\\n                class=\\\"nav-item nav-link dropdown-toggle\\\"\\n                href=\\\"\\\"\\n                role=\\\"button\\\"\\n                data-bs-toggle=\\\"dropdown\\\">\\n                <span class=\\\"flag-icon ${currentLocaleClass}\\\"></span>\\n              </a>\\n              <div class=\\\"dropdown-menu\\\">\\n                <a class=\\\"dropdown-item\\\" href=\\\"#\\\" click.delegate=\\\"changeLocale('et_EE')\\\">\\n                  <span class=\\\"flag-icon flag-icon-ee\\\"></span> Eesti\\n                </a>\\n                <a class=\\\"dropdown-item\\\" href=\\\"#\\\" click.delegate=\\\"changeLocale('en_GB')\\\">\\n                  <span class=\\\"flag-icon flag-icon-gb\\\"></span> English\\n                </a>\\n                <a class=\\\"dropdown-item\\\" href=\\\"#\\\" click.delegate=\\\"changeLocale('ru_RU')\\\">\\n                  <span class=\\\"flag-icon flag-icon-ru\\\"></span> Pусский\\n                </a>\\n                <a class=\\\"dropdown-item\\\" href=\\\"#\\\" click.delegate=\\\"changeLocale('fi_FI')\\\">\\n                  <span class=\\\"flag-icon flag-icon-fi\\\"></span> Suomi\\n                </a>\\n              </div>\\n            </div>\\n\\n            <feedback-form if.bind=\\\"appConfig.isLoggedIn\\\"></feedback-form>\\n\\n            <a class=\\\"nav-item nav-link\\\" href=\\\"mailto:${'footer.contact' & t}\\\">\\n              ${'footer.contact' & t}\\n            </a>\\n\\n            <a\\n              if.bind=\\\"appConfig.isLoggedIn\\\"\\n              class=\\\"nav-item nav-link\\\"\\n              href=\\\"#\\\"\\n              click.delegate=\\\"logout()\\\">\\n              ${'footer.logout' & t}\\n            </a>\\n          </div>\\n        </div>\\n      </nav>\\n    </div>\\n  </footer>\\n</template>\\n\";"],"sourceRoot":""}