@ikas/storefront 0.0.102 → 0.0.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/build/__generated__/global-types.d.ts +22 -1
  2. package/build/api/cart/__generated__/getCart.d.ts +4 -0
  3. package/build/api/cart/__generated__/saveItemToCart.d.ts +4 -0
  4. package/build/api/checkout/__generated__/checkStocks.d.ts +3 -3
  5. package/build/api/checkout/index.d.ts +1 -1
  6. package/build/api/country/__generated__/getAvailableShippingCountries.d.ts +3 -0
  7. package/build/api/country/__generated__/getMyCountry.d.ts +3 -0
  8. package/build/api/country/__generated__/listCountry.d.ts +2 -0
  9. package/build/api/country/index.d.ts +2 -1
  10. package/build/api/index.d.ts +0 -2
  11. package/build/api/storefront/__generated__/getStorefront.d.ts +39 -10
  12. package/build/api/storefront/index.d.ts +1 -1
  13. package/build/components/checkout/index.d.ts +3 -0
  14. package/build/components/checkout/model.d.ts +4 -3
  15. package/build/index.es.js +727 -429
  16. package/build/index.js +729 -432
  17. package/build/models/data/cart/index.d.ts +9 -0
  18. package/build/models/data/country/index.d.ts +2 -0
  19. package/build/models/data/sales-channel/index.d.ts +12 -0
  20. package/build/models/data/storefront/{storefront-domain → domain}/index.d.ts +1 -0
  21. package/build/models/data/storefront/index.d.ts +17 -6
  22. package/build/models/data/storefront/localization/index.d.ts +7 -0
  23. package/build/models/data/storefront/routing/index.d.ts +9 -0
  24. package/build/models/data/storefront/theme/index.d.ts +13 -0
  25. package/build/models/data/storefront/theme-localization/index.d.ts +12 -0
  26. package/build/models/ui/product-list/index.d.ts +1 -1
  27. package/build/pages/404.d.ts +1 -0
  28. package/build/pages/[slug]/index.d.ts +1 -0
  29. package/build/pages/account/addresses.d.ts +1 -0
  30. package/build/pages/account/favorite-products.d.ts +1 -0
  31. package/build/pages/account/forgot-password.d.ts +1 -0
  32. package/build/pages/account/index.d.ts +1 -0
  33. package/build/pages/account/login.d.ts +1 -0
  34. package/build/pages/account/orders/[id].d.ts +1 -0
  35. package/build/pages/account/orders/index.d.ts +1 -0
  36. package/build/pages/account/recover-password.d.ts +1 -0
  37. package/build/pages/account/register.d.ts +1 -0
  38. package/build/pages/cart.d.ts +1 -0
  39. package/build/pages/checkout/[id].d.ts +4 -0
  40. package/build/pages/home.d.ts +1 -0
  41. package/build/pages/pages/[slug].d.ts +1 -0
  42. package/build/pages/search.d.ts +1 -0
  43. package/build/store/base.d.ts +13 -0
  44. package/build/storefront/index.d.ts +18 -0
  45. package/build/utils/providers/page-data.d.ts +10 -0
  46. package/build/utils/settings.d.ts +142 -0
  47. package/package.json +1 -1
  48. package/build/api/product-stock-location/__generated__/listProductStockLocation.d.ts +0 -13
  49. package/build/api/product-stock-location/index.d.ts +0 -4
  50. package/build/api/theme/index.d.ts +0 -4
  51. package/build/models/data/storefront/stockfront-location/index.d.ts +0 -5
  52. package/build/models/data/storefront/stockfront-route/index.d.ts +0 -5
  53. package/build/models/data/storefront/storefront-region/index.d.ts +0 -18
package/build/index.es.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { makeAutoObservable, toJS, runInAction, reaction, makeObservable, computed, observable, action, configure } from 'mobx';
2
- import fs from 'fs';
3
- import getConfig from 'next/config';
4
2
  import React, { createElement, Fragment, useState, useEffect, useCallback, useRef, useMemo } from 'react';
3
+ import getConfig from 'next/config';
5
4
  import { observer } from 'mobx-react-lite';
6
5
  import { useRouter } from 'next/router';
7
6
  import Image$1 from 'next/image';
8
7
  import Link from 'next/link';
9
8
  import Head from 'next/head';
9
+ import fs from 'fs';
10
10
  import dynamic from 'next/dynamic';
11
+ import Error$1 from 'next/error';
11
12
 
12
13
  /*! *****************************************************************************
13
14
  Copyright (c) Microsoft Corporation.
@@ -10871,10 +10872,37 @@ var IkasStorefrontConfig = /** @class */ (function () {
10871
10872
  IkasStorefrontConfig.components = components;
10872
10873
  IkasStorefrontConfig.config = config;
10873
10874
  IkasStorefrontConfig.apiUrlOverride = apiUrlOverride || null;
10875
+ if (process.env.NEXT_PUBLIC_ENV === "local") {
10876
+ this.storefrontId = config.storefrontId;
10877
+ }
10878
+ };
10879
+ IkasStorefrontConfig.initWithJson = function (json) {
10880
+ try {
10881
+ Object.entries(json).forEach(function (_a) {
10882
+ var key = _a[0], value = _a[1];
10883
+ //@ts-ignore
10884
+ IkasStorefrontConfig[key] = value;
10885
+ });
10886
+ }
10887
+ catch (err) {
10888
+ console.log(err);
10889
+ }
10890
+ };
10891
+ IkasStorefrontConfig.getJson = function () {
10892
+ return {
10893
+ storefrontId: IkasStorefrontConfig.storefrontId || null,
10894
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId || null,
10895
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId || null,
10896
+ salesChannelId: IkasStorefrontConfig.salesChannelId || null,
10897
+ priceListId: IkasStorefrontConfig.priceListId || null,
10898
+ stockLocationIds: IkasStorefrontConfig.stockLocationIds || null,
10899
+ routings: JSON.parse(JSON.stringify(IkasStorefrontConfig.routings)) || null,
10900
+ };
10874
10901
  };
10875
10902
  IkasStorefrontConfig.components = {};
10876
10903
  IkasStorefrontConfig.config = {};
10877
10904
  IkasStorefrontConfig.apiUrlOverride = null;
10905
+ IkasStorefrontConfig.routings = [];
10878
10906
  return IkasStorefrontConfig;
10879
10907
  }());
10880
10908
 
@@ -11003,6 +11031,7 @@ var IkasProductDetailPropValueProvider = /** @class */ (function () {
11003
11031
  return [2 /*return*/, null];
11004
11032
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
11005
11033
  productIdList: [this.productDetailPropValue.productId],
11034
+ priceListId: IkasStorefrontConfig.priceListId,
11006
11035
  })];
11007
11036
  case 1:
11008
11037
  productSearchResponse = _b.sent();
@@ -11811,11 +11840,15 @@ var IkasPageDataProvider = /** @class */ (function () {
11811
11840
  return {
11812
11841
  props: {
11813
11842
  propValuesStr: JSON.stringify(this.pageComponentPropValues),
11843
+ pageSpecificDataStr: this.pageSpecificData
11844
+ ? JSON.stringify(this.pageSpecificData || {})
11845
+ : "",
11814
11846
  page: toJS(this.page) || null,
11815
11847
  settingsStr: JSON.stringify(this.theme.settings || {}),
11816
11848
  merchantSettings: this.merchantSettings
11817
11849
  ? JSON.stringify(this.merchantSettings)
11818
11850
  : null,
11851
+ configJson: IkasStorefrontConfig.getJson(),
11819
11852
  },
11820
11853
  };
11821
11854
  },
@@ -12032,6 +12065,7 @@ var IkasPageDataProvider = /** @class */ (function () {
12032
12065
  return [2 /*return*/];
12033
12066
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
12034
12067
  productIdList: [metaDataResponse.metaData.targetId],
12068
+ priceListId: IkasStorefrontConfig.priceListId,
12035
12069
  })];
12036
12070
  case 2:
12037
12071
  productsResponse = _b.sent();
@@ -12790,6 +12824,10 @@ var IkasCart = /** @class */ (function () {
12790
12824
  : [];
12791
12825
  this.merchantId = data.merchantId || "";
12792
12826
  this.totalPrice = data.totalPrice || 0;
12827
+ this.salesChannelId = data.salesChannelId || "";
12828
+ this.storefrontId = data.storefrontId || null;
12829
+ this.storefrontRoutingId = data.storefrontRoutingId || null;
12830
+ this.storefrontThemeId = data.storefrontThemeId || null;
12793
12831
  makeAutoObservable(this);
12794
12832
  }
12795
12833
  Object.defineProperty(IkasCart.prototype, "totalTax", {
@@ -15817,7 +15855,7 @@ var MAX_CVC_LENGTH = 4;
15817
15855
  var USE_DIFFERENT_ADDRESS_KEY = "sAddr";
15818
15856
  var isServer$1 = typeof localStorage === "undefined";
15819
15857
  var CheckoutViewModel = /** @class */ (function () {
15820
- function CheckoutViewModel(checkout, queryParams, router) {
15858
+ function CheckoutViewModel(checkout, queryParams, router, returnPolicy, privacyPolicy, termsOfService) {
15821
15859
  var _this = this;
15822
15860
  this.checkout = new IkasCheckout();
15823
15861
  this.storefront = null;
@@ -15923,7 +15961,7 @@ var CheckoutViewModel = /** @class */ (function () {
15923
15961
  variantId: i.variant.id,
15924
15962
  productId: i.variant.productId,
15925
15963
  }); });
15926
- return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines)];
15964
+ return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines, IkasStorefrontConfig.stockLocationIds || [])];
15927
15965
  case 1:
15928
15966
  result = _b.sent();
15929
15967
  if (!result) {
@@ -15936,7 +15974,7 @@ var CheckoutViewModel = /** @class */ (function () {
15936
15974
  data = unavailableItems.map(function (item) { return ({
15937
15975
  variant: _this.cart.items.find(function (i) { return i.variant.id === item.variantId; })
15938
15976
  .variant,
15939
- availableQuantity: item.availableQuantity,
15977
+ availableQuantity: item.stockCount,
15940
15978
  }); });
15941
15979
  throw {
15942
15980
  type: ErrorType.STOCK_ERROR,
@@ -15953,7 +15991,7 @@ var CheckoutViewModel = /** @class */ (function () {
15953
15991
  switch (_b.label) {
15954
15992
  case 0:
15955
15993
  _a = this;
15956
- return [4 /*yield*/, IkasCountryAPI.listShippingCountries()];
15994
+ return [4 /*yield*/, IkasCountryAPI.listShippingCountries(IkasStorefrontConfig.storefrontId)];
15957
15995
  case 1:
15958
15996
  _a.shippingCountryIds = _b.sent();
15959
15997
  return [2 /*return*/];
@@ -16029,30 +16067,6 @@ var CheckoutViewModel = /** @class */ (function () {
16029
16067
  }
16030
16068
  });
16031
16069
  }); };
16032
- this.getStorefront = function () { return __awaiter(_this, void 0, void 0, function () {
16033
- var storefront;
16034
- return __generator(this, function (_a) {
16035
- switch (_a.label) {
16036
- case 0:
16037
- if (!IkasStorefrontConfig.config.storefrontId || !!this.storefront)
16038
- return [2 /*return*/];
16039
- _a.label = 1;
16040
- case 1:
16041
- _a.trys.push([1, 3, , 4]);
16042
- return [4 /*yield*/, IkasStorefrontAPI.getStorefront(IkasStorefrontConfig.config.storefrontId)];
16043
- case 2:
16044
- storefront = _a.sent();
16045
- if (storefront) {
16046
- this.storefront = storefront;
16047
- }
16048
- return [3 /*break*/, 4];
16049
- case 3:
16050
- _a.sent();
16051
- return [3 /*break*/, 4];
16052
- case 4: return [2 /*return*/];
16053
- }
16054
- });
16055
- }); };
16056
16070
  this.createCustomer = function () {
16057
16071
  if (_this.customerStore.customer) {
16058
16072
  _this.checkout.customer = _this.customerStore.customer;
@@ -16184,7 +16198,7 @@ var CheckoutViewModel = /** @class */ (function () {
16184
16198
  _this.router.push("/");
16185
16199
  };
16186
16200
  this.onProceedToShippingClick = function () { return __awaiter(_this, void 0, void 0, function () {
16187
- var newAddress, customer, err_3;
16201
+ var newAddress, customer, err_2;
16188
16202
  return __generator(this, function (_a) {
16189
16203
  switch (_a.label) {
16190
16204
  case 0:
@@ -16214,12 +16228,12 @@ var CheckoutViewModel = /** @class */ (function () {
16214
16228
  this.changeStep(CheckoutStep.SHIPPING);
16215
16229
  return [3 /*break*/, 7];
16216
16230
  case 6:
16217
- err_3 = _a.sent();
16218
- if (err_3.type) {
16219
- this.error = err_3;
16231
+ err_2 = _a.sent();
16232
+ if (err_2.type) {
16233
+ this.error = err_2;
16220
16234
  }
16221
16235
  else {
16222
- console.log(err_3);
16236
+ console.log(err_2);
16223
16237
  this.error = {
16224
16238
  type: ErrorType.UNKNOWN,
16225
16239
  };
@@ -16231,7 +16245,7 @@ var CheckoutViewModel = /** @class */ (function () {
16231
16245
  });
16232
16246
  }); };
16233
16247
  this.onProceedToPaymentClick = function () { return __awaiter(_this, void 0, void 0, function () {
16234
- var err_4;
16248
+ var err_3;
16235
16249
  return __generator(this, function (_a) {
16236
16250
  switch (_a.label) {
16237
16251
  case 0:
@@ -16251,12 +16265,12 @@ var CheckoutViewModel = /** @class */ (function () {
16251
16265
  this.changeStep(CheckoutStep.PAYMENT);
16252
16266
  return [3 /*break*/, 4];
16253
16267
  case 3:
16254
- err_4 = _a.sent();
16255
- if (err_4.type) {
16256
- this.error = err_4;
16268
+ err_3 = _a.sent();
16269
+ if (err_3.type) {
16270
+ this.error = err_3;
16257
16271
  }
16258
16272
  else {
16259
- console.log(err_4);
16273
+ console.log(err_3);
16260
16274
  this.error = {
16261
16275
  type: ErrorType.UNKNOWN,
16262
16276
  };
@@ -16268,7 +16282,7 @@ var CheckoutViewModel = /** @class */ (function () {
16268
16282
  });
16269
16283
  }); };
16270
16284
  this.performPayment = function () { return __awaiter(_this, void 0, void 0, function () {
16271
- var response, transactionStatus, err_5;
16285
+ var response, transactionStatus, err_4;
16272
16286
  return __generator(this, function (_a) {
16273
16287
  switch (_a.label) {
16274
16288
  case 0:
@@ -16315,10 +16329,10 @@ var CheckoutViewModel = /** @class */ (function () {
16315
16329
  }
16316
16330
  return [3 /*break*/, 6];
16317
16331
  case 5:
16318
- err_5 = _a.sent();
16319
- if (err_5.type) {
16320
- console.log(err_5);
16321
- this.error = err_5;
16332
+ err_4 = _a.sent();
16333
+ if (err_4.type) {
16334
+ console.log(err_4);
16335
+ this.error = err_4;
16322
16336
  }
16323
16337
  else {
16324
16338
  this.error = {
@@ -16397,6 +16411,9 @@ var CheckoutViewModel = /** @class */ (function () {
16397
16411
  }); };
16398
16412
  this.checkout = checkout;
16399
16413
  this.router = router;
16414
+ this.returnPolicy = returnPolicy;
16415
+ this.privacyPolicy = privacyPolicy;
16416
+ this.termsOfService = termsOfService;
16400
16417
  this.init(queryParams);
16401
16418
  makeAutoObservable(this);
16402
16419
  }
@@ -16407,15 +16424,6 @@ var CheckoutViewModel = /** @class */ (function () {
16407
16424
  enumerable: false,
16408
16425
  configurable: true
16409
16426
  });
16410
- Object.defineProperty(CheckoutViewModel.prototype, "storefrontRegion", {
16411
- get: function () {
16412
- var _a;
16413
- return ((_a = this.storefront) === null || _a === void 0 ? void 0 : _a.regions.length) ? this.storefront.regions[0]
16414
- : undefined;
16415
- },
16416
- enumerable: false,
16417
- configurable: true
16418
- });
16419
16427
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
16420
16428
  get: function () {
16421
16429
  var _this = this;
@@ -17079,6 +17087,7 @@ var IkasCustomerStore = /** @class */ (function () {
17079
17087
  return [2 /*return*/, []];
17080
17088
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
17081
17089
  productIdList: favoriteProductsResult.map(function (fP) { return fP.productId; }),
17090
+ priceListId: IkasStorefrontConfig.priceListId,
17082
17091
  })];
17083
17092
  case 2:
17084
17093
  productsResult = _b.sent();
@@ -21936,7 +21945,10 @@ var IkasProductList = /** @class */ (function () {
21936
21945
  Object.defineProperty(IkasProductList.prototype, "isFiltered", {
21937
21946
  get: function () {
21938
21947
  var _a;
21939
- return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) || !!this._searchKeyword);
21948
+ return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) ||
21949
+ !!this._searchKeyword ||
21950
+ (this._pageType !== IkasThemePageType.CATEGORY &&
21951
+ !!this._filterCategoryId));
21940
21952
  },
21941
21953
  enumerable: false,
21942
21954
  configurable: true
@@ -21999,13 +22011,20 @@ var IkasProductList = /** @class */ (function () {
21999
22011
  });
22000
22012
  Object.defineProperty(IkasProductList.prototype, "filterQueryParams", {
22001
22013
  get: function () {
22002
- var _a;
22014
+ var _this = this;
22015
+ var _a, _b, _c;
22003
22016
  var queryParams = {};
22004
22017
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
22005
22018
  queryParams[f.key] = f.keyList;
22006
22019
  });
22007
22020
  if (this._searchKeyword)
22008
22021
  queryParams.s = this._searchKeyword;
22022
+ if (this._pageType !== IkasThemePageType.CATEGORY &&
22023
+ this._filterCategoryId) {
22024
+ var slug = (_c = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _c === void 0 ? void 0 : _c.slug;
22025
+ if (slug)
22026
+ queryParams.c = slug;
22027
+ }
22009
22028
  return queryString.stringify(queryParams, { arrayFormat: "comma" });
22010
22029
  },
22011
22030
  enumerable: false,
@@ -22060,6 +22079,7 @@ var IkasProductList = /** @class */ (function () {
22060
22079
  categoryIdList: this._filterCategoryId
22061
22080
  ? [this._filterCategoryId]
22062
22081
  : undefined,
22082
+ priceListId: IkasStorefrontConfig.priceListId,
22063
22083
  query: this._searchKeyword,
22064
22084
  })];
22065
22085
  case 1: return [2 /*return*/, _c.sent()];
@@ -22087,6 +22107,7 @@ var IkasProductList = /** @class */ (function () {
22087
22107
  };
22088
22108
  IkasProductList.prototype.applyQueryParamFilters = function (queryParams) {
22089
22109
  var _this = this;
22110
+ var _a;
22090
22111
  try {
22091
22112
  queryParams === null || queryParams === void 0 ? void 0 : queryParams.forEach(function (value, key) {
22092
22113
  var _a;
@@ -22098,6 +22119,15 @@ var IkasProductList = /** @class */ (function () {
22098
22119
  var querySearch = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("s");
22099
22120
  if (querySearch)
22100
22121
  this._searchKeyword = querySearch;
22122
+ if (this._pageType !== IkasThemePageType.CATEGORY) {
22123
+ var queryCategory_1 = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("c");
22124
+ if (queryCategory_1) {
22125
+ var filterCategory = (_a = this.filterCategories) === null || _a === void 0 ? void 0 : _a.find(function (fc) { return fc.slug === queryCategory_1; });
22126
+ if (filterCategory) {
22127
+ this._filterCategoryId = filterCategory.id;
22128
+ }
22129
+ }
22130
+ }
22101
22131
  }
22102
22132
  catch (err) {
22103
22133
  console.log(err);
@@ -22144,12 +22174,32 @@ var IkasProductList = /** @class */ (function () {
22144
22174
  var _a;
22145
22175
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
22146
22176
  this._searchKeyword = "";
22177
+ if (this._pageType !== IkasThemePageType.CATEGORY) {
22178
+ this._filterCategoryId = undefined;
22179
+ }
22147
22180
  this.applyFilters();
22148
22181
  };
22149
- IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
22182
+ IkasProductList.prototype.onFilterCategoryClick = function (filterCategory, disableRoute) {
22150
22183
  var _a;
22151
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22152
- (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22184
+ if (disableRoute === void 0) { disableRoute = false; }
22185
+ return __awaiter(this, void 0, void 0, function () {
22186
+ return __generator(this, function (_b) {
22187
+ switch (_b.label) {
22188
+ case 0:
22189
+ if (!disableRoute) return [3 /*break*/, 2];
22190
+ this._filterCategoryId = filterCategory.id;
22191
+ return [4 /*yield*/, this.applyFilters()];
22192
+ case 1:
22193
+ _b.sent();
22194
+ return [3 /*break*/, 3];
22195
+ case 2:
22196
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22197
+ (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22198
+ _b.label = 3;
22199
+ case 3: return [2 /*return*/];
22200
+ }
22201
+ });
22202
+ });
22153
22203
  };
22154
22204
  IkasProductList.prototype.toJSON = function () {
22155
22205
  return {
@@ -24237,7 +24287,7 @@ var IkasCartAPI = /** @class */ (function () {
24237
24287
  return __generator(this, function (_b) {
24238
24288
  switch (_b.label) {
24239
24289
  case 0:
24240
- MUTATION = src(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
24290
+ MUTATION = src(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
24241
24291
  _b.label = 1;
24242
24292
  case 1:
24243
24293
  _b.trys.push([1, 3, , 4]);
@@ -24272,7 +24322,7 @@ var IkasCartAPI = /** @class */ (function () {
24272
24322
  return __generator(this, function (_b) {
24273
24323
  switch (_b.label) {
24274
24324
  case 0:
24275
- QUERY = src(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
24325
+ QUERY = src(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
24276
24326
  _b.label = 1;
24277
24327
  case 1:
24278
24328
  _b.trys.push([1, 3, , 4]);
@@ -24744,13 +24794,13 @@ var IkasCheckoutAPI = /** @class */ (function () {
24744
24794
  });
24745
24795
  });
24746
24796
  };
24747
- IkasCheckoutAPI.checkStocks = function (lines) {
24797
+ IkasCheckoutAPI.checkStocks = function (lines, stockLocationIdList) {
24748
24798
  return __awaiter(this, void 0, void 0, function () {
24749
24799
  var QUERY, _a, data, errors, err_7;
24750
24800
  return __generator(this, function (_b) {
24751
24801
  switch (_b.label) {
24752
24802
  case 0:
24753
- QUERY = src(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n query checkStocks($lines: [CheckStocksLineInput!]!) {\n checkStocks(lines: $lines) {\n lines {\n availableQuantity\n isAvailable\n stockLocationId\n variantId\n }\n }\n }\n "], ["\n query checkStocks($lines: [CheckStocksLineInput!]!) {\n checkStocks(lines: $lines) {\n lines {\n availableQuantity\n isAvailable\n stockLocationId\n variantId\n }\n }\n }\n "])));
24803
+ QUERY = src(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "], ["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "])));
24754
24804
  _b.label = 1;
24755
24805
  case 1:
24756
24806
  _b.trys.push([1, 3, , 4]);
@@ -24760,6 +24810,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
24760
24810
  query: QUERY,
24761
24811
  variables: {
24762
24812
  lines: lines,
24813
+ stockLocationIdList: stockLocationIdList,
24763
24814
  },
24764
24815
  })];
24765
24816
  case 2:
@@ -24842,7 +24893,7 @@ var IkasCountryAPI = /** @class */ (function () {
24842
24893
  return __generator(this, function (_b) {
24843
24894
  switch (_b.label) {
24844
24895
  case 0:
24845
- QUERY = src(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n query listCountry {\n listCountry {\n id\n name\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "], ["\n query listCountry {\n listCountry {\n id\n name\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "])));
24896
+ QUERY = src(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n query listCountry {\n listCountry {\n id\n name\n native\n iso2\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "], ["\n query listCountry {\n listCountry {\n id\n name\n native\n iso2\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "])));
24846
24897
  _b.label = 1;
24847
24898
  case 1:
24848
24899
  _b.trys.push([1, 3, , 4]);
@@ -24858,6 +24909,8 @@ var IkasCountryAPI = /** @class */ (function () {
24858
24909
  return [2 /*return*/, data.listCountry.map(function (c) { return ({
24859
24910
  id: c.id,
24860
24911
  name: pascalCase(c.locationTranslations.tr),
24912
+ native: c.native || "",
24913
+ iso2: c.iso2 || undefined,
24861
24914
  iso3: c.iso3 || undefined,
24862
24915
  phoneCode: c.phoneCode || undefined,
24863
24916
  }); })];
@@ -24871,13 +24924,13 @@ var IkasCountryAPI = /** @class */ (function () {
24871
24924
  });
24872
24925
  });
24873
24926
  };
24874
- IkasCountryAPI.listShippingCountries = function () {
24927
+ IkasCountryAPI.listShippingCountries = function (storefrontId) {
24875
24928
  return __awaiter(this, void 0, void 0, function () {
24876
24929
  var QUERY, _a, data, errors, err_2;
24877
24930
  return __generator(this, function (_b) {
24878
24931
  switch (_b.label) {
24879
24932
  case 0:
24880
- QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getAvailableShippingCountries {\n getAvailableShippingCountries\n }\n "], ["\n query getAvailableShippingCountries {\n getAvailableShippingCountries\n }\n "])));
24933
+ QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getAvailableShippingCountries($storefrontId: String!) {\n getAvailableShippingCountries(storefrontId: $storefrontId)\n }\n "], ["\n query getAvailableShippingCountries($storefrontId: String!) {\n getAvailableShippingCountries(storefrontId: $storefrontId)\n }\n "])));
24881
24934
  _b.label = 1;
24882
24935
  case 1:
24883
24936
  _b.trys.push([1, 3, , 4]);
@@ -24885,6 +24938,9 @@ var IkasCountryAPI = /** @class */ (function () {
24885
24938
  .getClient()
24886
24939
  .query({
24887
24940
  query: QUERY,
24941
+ variables: {
24942
+ storefrontId: storefrontId,
24943
+ },
24888
24944
  })];
24889
24945
  case 2:
24890
24946
  _a = _b.sent(), data = _a.data, errors = _a.errors;
@@ -24903,9 +24959,34 @@ var IkasCountryAPI = /** @class */ (function () {
24903
24959
  });
24904
24960
  });
24905
24961
  };
24962
+ IkasCountryAPI.getMyCountry = function () {
24963
+ return __awaiter(this, void 0, void 0, function () {
24964
+ var QUERY, data, err_3;
24965
+ return __generator(this, function (_a) {
24966
+ switch (_a.label) {
24967
+ case 0:
24968
+ QUERY = src(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n query getMyCountry {\n getMyCountry\n }\n "], ["\n query getMyCountry {\n getMyCountry\n }\n "])));
24969
+ _a.label = 1;
24970
+ case 1:
24971
+ _a.trys.push([1, 3, , 4]);
24972
+ return [4 /*yield*/, apollo.getClient().query({
24973
+ query: QUERY,
24974
+ })];
24975
+ case 2:
24976
+ data = (_a.sent()).data;
24977
+ return [2 /*return*/, data.getMyCountry];
24978
+ case 3:
24979
+ err_3 = _a.sent();
24980
+ console.log(err_3);
24981
+ return [3 /*break*/, 4];
24982
+ case 4: return [2 /*return*/];
24983
+ }
24984
+ });
24985
+ });
24986
+ };
24906
24987
  return IkasCountryAPI;
24907
24988
  }());
24908
- var templateObject_1$5, templateObject_2$3;
24989
+ var templateObject_1$5, templateObject_2$3, templateObject_3$1;
24909
24990
 
24910
24991
  var IkasCustomerAPI = /** @class */ (function () {
24911
24992
  function IkasCustomerAPI() {
@@ -24990,7 +25071,7 @@ var IkasCustomerAPI = /** @class */ (function () {
24990
25071
  return __generator(this, function (_b) {
24991
25072
  switch (_b.label) {
24992
25073
  case 0:
24993
- MUTATION = src(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "], ["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "])));
25074
+ MUTATION = src(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "], ["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "])));
24994
25075
  _b.label = 1;
24995
25076
  case 1:
24996
25077
  _b.trys.push([1, 3, , 4]);
@@ -25306,7 +25387,7 @@ var IkasCustomerAPI = /** @class */ (function () {
25306
25387
  };
25307
25388
  return IkasCustomerAPI;
25308
25389
  }());
25309
- var templateObject_1$6, templateObject_2$4, templateObject_3$1, templateObject_4$1, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
25390
+ var templateObject_1$6, templateObject_2$4, templateObject_3$2, templateObject_4$1, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
25310
25391
 
25311
25392
  var IkasDistrictAPI = /** @class */ (function () {
25312
25393
  function IkasDistrictAPI() {
@@ -25759,7 +25840,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25759
25840
  return __generator(this, function (_b) {
25760
25841
  switch (_b.label) {
25761
25842
  case 0:
25762
- SAVE_FAVORITE_PRODUCT = src(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "], ["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "])));
25843
+ SAVE_FAVORITE_PRODUCT = src(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "], ["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "])));
25763
25844
  _b.label = 1;
25764
25845
  case 1:
25765
25846
  _b.trys.push([1, 3, , 4]);
@@ -25785,7 +25866,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25785
25866
  };
25786
25867
  return IkasFavoriteProductAPI;
25787
25868
  }());
25788
- var templateObject_1$c, templateObject_2$6, templateObject_3$2;
25869
+ var templateObject_1$c, templateObject_2$6, templateObject_3$3;
25789
25870
 
25790
25871
  var IkasContactFormAPI = /** @class */ (function () {
25791
25872
  function IkasContactFormAPI() {
@@ -25878,150 +25959,6 @@ var IkasStateAPI = /** @class */ (function () {
25878
25959
  }());
25879
25960
  var templateObject_1$e;
25880
25961
 
25881
- var IkasStorefrontDomain = /** @class */ (function () {
25882
- function IkasStorefrontDomain(data) {
25883
- if (data === void 0) { data = {}; }
25884
- this.id = data.id || "";
25885
- this.merchantDomainId = data.merchantDomainId || "";
25886
- this.name = data.name || "";
25887
- this.redirectDomainName = data.redirectDomainName || null;
25888
- makeAutoObservable(this);
25889
- }
25890
- return IkasStorefrontDomain;
25891
- }());
25892
-
25893
- var IkasStorefrontLocation = /** @class */ (function () {
25894
- function IkasStorefrontLocation(data) {
25895
- if (data === void 0) { data = {}; }
25896
- this.countryId = data.countryId || "";
25897
- this.stateId = data.stateId || null;
25898
- makeAutoObservable(this);
25899
- }
25900
- return IkasStorefrontLocation;
25901
- }());
25902
-
25903
- var IkasStorefrontRoute = /** @class */ (function () {
25904
- function IkasStorefrontRoute(data) {
25905
- if (data === void 0) { data = {}; }
25906
- this.domainId = data.domainId || "";
25907
- this.useSubPath = data.useSubPath || false;
25908
- makeAutoObservable(this);
25909
- }
25910
- return IkasStorefrontRoute;
25911
- }());
25912
-
25913
- var IkasStorefrontRegion = /** @class */ (function () {
25914
- function IkasStorefrontRegion(data) {
25915
- if (data === void 0) { data = {}; }
25916
- // Extra
25917
- this.theme = new IkasTheme();
25918
- this.id = data.id || "";
25919
- this.locale = data.locale || "";
25920
- this.themeJSON = data.themeJSON || "";
25921
- this.shipping = data.shipping || null;
25922
- this.paymentSettingsId = data.paymentSettingsId || null;
25923
- this.priceListId = data.priceListId || null;
25924
- this.locations = data.locations
25925
- ? data.locations.map(function (o) { return new IkasStorefrontLocation(o); })
25926
- : [];
25927
- this.routes = data.routes
25928
- ? data.routes.map(function (o) { return new IkasStorefrontRoute(o); })
25929
- : null;
25930
- this.termsOfService = data.termsOfService || "";
25931
- this.privacyPolicy = data.privacyPolicy || "";
25932
- this.returnPolicy = data.returnPolicy || "";
25933
- try {
25934
- this.theme = this.themeJSON
25935
- ? new IkasTheme(JSON.parse(this.themeJSON))
25936
- : new IkasTheme();
25937
- }
25938
- catch (err) { }
25939
- makeAutoObservable(this);
25940
- }
25941
- return IkasStorefrontRegion;
25942
- }());
25943
-
25944
- var IkasStorefront = /** @class */ (function () {
25945
- function IkasStorefront(data) {
25946
- if (data === void 0) { data = {}; }
25947
- this.id = data.id || "";
25948
- this.name = data.name || "";
25949
- this.themeId = data.themeId || "";
25950
- this.themeVersionId = data.themeVersionId || "";
25951
- this.userId = data.userId || "";
25952
- this.domains = data.domains
25953
- ? data.domains.map(function (o) { return new IkasStorefrontDomain(o); })
25954
- : [];
25955
- this.regions = data.regions
25956
- ? data.regions.map(function (o) { return new IkasStorefrontRegion(o); })
25957
- : [];
25958
- makeAutoObservable(this);
25959
- }
25960
- return IkasStorefront;
25961
- }());
25962
-
25963
- var IkasStorefrontAPI = /** @class */ (function () {
25964
- function IkasStorefrontAPI() {
25965
- }
25966
- IkasStorefrontAPI.getStorefront = function (storefrontId) {
25967
- return __awaiter(this, void 0, void 0, function () {
25968
- var QUERY, _a, data, errors;
25969
- return __generator(this, function (_b) {
25970
- switch (_b.label) {
25971
- case 0:
25972
- QUERY = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query getStorefront($storefrontId: String!) {\n getStorefront(id: $storefrontId) {\n id\n name\n themeId\n themeVersionId\n userId\n # domains {\n # id\n # merchantDomainId\n # name\n # redirectDomainName\n # }\n regions {\n id\n locale\n # themeJSON\n privacyPolicy\n returnPolicy\n termsOfService\n }\n }\n }\n "], ["\n query getStorefront($storefrontId: String!) {\n getStorefront(id: $storefrontId) {\n id\n name\n themeId\n themeVersionId\n userId\n # domains {\n # id\n # merchantDomainId\n # name\n # redirectDomainName\n # }\n regions {\n id\n locale\n # themeJSON\n privacyPolicy\n returnPolicy\n termsOfService\n }\n }\n }\n "])));
25973
- _b.label = 1;
25974
- case 1:
25975
- _b.trys.push([1, 3, , 4]);
25976
- return [4 /*yield*/, apollo
25977
- .getClient()
25978
- .query({
25979
- query: QUERY,
25980
- variables: {
25981
- storefrontId: storefrontId,
25982
- },
25983
- })];
25984
- case 2:
25985
- _a = _b.sent(), data = _a.data, errors = _a.errors;
25986
- if (errors && errors.length) {
25987
- console.log(errors);
25988
- }
25989
- if (data)
25990
- return [2 /*return*/, new IkasStorefront(data.getStorefront)];
25991
- return [3 /*break*/, 4];
25992
- case 3:
25993
- _b.sent();
25994
- return [3 /*break*/, 4];
25995
- case 4: return [2 /*return*/, new IkasStorefront()];
25996
- }
25997
- });
25998
- });
25999
- };
26000
- return IkasStorefrontAPI;
26001
- }());
26002
- var templateObject_1$f;
26003
-
26004
- var IkasThemeAPI = /** @class */ (function () {
26005
- function IkasThemeAPI() {
26006
- }
26007
- IkasThemeAPI.fetchTheme = function () {
26008
- return new Promise(function (resolve, reject) {
26009
- var serverRuntimeConfig = getConfig().serverRuntimeConfig;
26010
- var themeJSONPath = serverRuntimeConfig.THEME_JSON_PATH || "./src/theme.json";
26011
- fs.readFile(themeJSONPath, {
26012
- flag: "a+",
26013
- }, function (err, file) {
26014
- if (err) {
26015
- return reject(err);
26016
- }
26017
- var result = file.length ? JSON.parse(file.toString()) : {};
26018
- resolve(new IkasTheme(result));
26019
- });
26020
- });
26021
- };
26022
- return IkasThemeAPI;
26023
- }());
26024
-
26025
25962
  var IkasVariantTypeAPI = /** @class */ (function () {
26026
25963
  function IkasVariantTypeAPI() {
26027
25964
  }
@@ -26031,7 +25968,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26031
25968
  return __generator(this, function (_b) {
26032
25969
  switch (_b.label) {
26033
25970
  case 0:
26034
- LIST_VARIANT_TYPE = src(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "], ["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "])));
25971
+ LIST_VARIANT_TYPE = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "], ["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "])));
26035
25972
  _b.label = 1;
26036
25973
  case 1:
26037
25974
  _b.trys.push([1, 3, , 4]);
@@ -26077,7 +26014,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26077
26014
  };
26078
26015
  return IkasVariantTypeAPI;
26079
26016
  }());
26080
- var templateObject_1$g;
26017
+ var templateObject_1$f;
26081
26018
 
26082
26019
  function styleInject(css, ref) {
26083
26020
  if ( ref === void 0 ) ref = {};
@@ -27267,6 +27204,11 @@ var IkasCartStore = /** @class */ (function () {
27267
27204
  name: product.name,
27268
27205
  },
27269
27206
  },
27207
+ priceListId: IkasStorefrontConfig.priceListId || null,
27208
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27209
+ storefrontId: IkasStorefrontConfig.storefrontId,
27210
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27211
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27270
27212
  };
27271
27213
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27272
27214
  case 1:
@@ -27307,6 +27249,11 @@ var IkasCartStore = /** @class */ (function () {
27307
27249
  name: item.variant.name,
27308
27250
  },
27309
27251
  },
27252
+ priceListId: IkasStorefrontConfig.priceListId || null,
27253
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27254
+ storefrontId: IkasStorefrontConfig.storefrontId,
27255
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27256
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27310
27257
  };
27311
27258
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27312
27259
  case 1:
@@ -27669,9 +27616,11 @@ function createCategoryBreadcrumbSchema(pageSpecificDataStr) {
27669
27616
 
27670
27617
  var IkasCheckoutPage = observer(function (_a) {
27671
27618
  var _b, _c, _d;
27672
- var checkout = _a.checkout, queryParams = _a.queryParams;
27619
+ var checkout = _a.checkout, returnPolicy = _a.returnPolicy, privacyPolicy = _a.privacyPolicy, termsOfService = _a.termsOfService, queryParams = _a.queryParams;
27673
27620
  var router = useRouter();
27674
- var vm = useState(function () { return new CheckoutViewModel(checkout, queryParams, router); })[0];
27621
+ var vm = useState(function () {
27622
+ return new CheckoutViewModel(checkout, queryParams, router, returnPolicy, privacyPolicy, termsOfService);
27623
+ })[0];
27675
27624
  useEffect(function () {
27676
27625
  Analytics.beginCheckout(vm.checkout);
27677
27626
  Analytics.checkoutStep(vm.checkout, vm.step);
@@ -27696,46 +27645,18 @@ var IkasCheckoutPage = observer(function (_a) {
27696
27645
  var onPolicyModalClose = function () {
27697
27646
  setPolicyModalText("");
27698
27647
  };
27699
- var onReturnPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27700
- var _a, _b;
27701
- return __generator(this, function (_c) {
27702
- switch (_c.label) {
27703
- case 0: return [4 /*yield*/, vm.getStorefront()];
27704
- case 1:
27705
- _c.sent();
27706
- console.log((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.returnPolicy);
27707
- setPolicyModalTitle("Para İade Politikası");
27708
- setPolicyModalText(((_b = vm.storefrontRegion) === null || _b === void 0 ? void 0 : _b.returnPolicy) || "");
27709
- return [2 /*return*/];
27710
- }
27711
- });
27712
- }); };
27713
- var onPrivacyPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27714
- var _a;
27715
- return __generator(this, function (_b) {
27716
- switch (_b.label) {
27717
- case 0: return [4 /*yield*/, vm.getStorefront()];
27718
- case 1:
27719
- _b.sent();
27720
- setPolicyModalTitle("Gizlilik Politikası");
27721
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.privacyPolicy) || "");
27722
- return [2 /*return*/];
27723
- }
27724
- });
27725
- }); };
27726
- var onTermsOfServiceClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27727
- var _a;
27728
- return __generator(this, function (_b) {
27729
- switch (_b.label) {
27730
- case 0: return [4 /*yield*/, vm.getStorefront()];
27731
- case 1:
27732
- _b.sent();
27733
- setPolicyModalTitle("Hizmet Şartları");
27734
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.termsOfService) || "");
27735
- return [2 /*return*/];
27736
- }
27737
- });
27738
- }); };
27648
+ var onReturnPolicyClick = function () {
27649
+ setPolicyModalTitle("Para İade Politikası");
27650
+ setPolicyModalText(vm.returnPolicy);
27651
+ };
27652
+ var onPrivacyPolicyClick = function () {
27653
+ setPolicyModalTitle("Gizlilik Politikası");
27654
+ setPolicyModalText(vm.privacyPolicy);
27655
+ };
27656
+ var onTermsOfServiceClick = function () {
27657
+ setPolicyModalTitle("Hizmet Şartları");
27658
+ setPolicyModalText(vm.termsOfService);
27659
+ };
27739
27660
  var onErrorClose = function () {
27740
27661
  vm.error = undefined;
27741
27662
  };
@@ -27838,6 +27759,9 @@ var IkasPage = observer(function (_a) {
27838
27759
  if (page) {
27839
27760
  store.currentPageType = page.type;
27840
27761
  }
27762
+ useEffect(function () {
27763
+ store.checkLocalization();
27764
+ }, []);
27841
27765
  var renderComponent = function (pageComponent, index) {
27842
27766
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
27843
27767
  return (createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -28355,24 +28279,358 @@ var index = /*#__PURE__*/Object.freeze({
28355
28279
  Image: Image
28356
28280
  });
28357
28281
 
28282
+ var IkasStorefrontLocalization = /** @class */ (function () {
28283
+ function IkasStorefrontLocalization(data) {
28284
+ this.id = data.id || "";
28285
+ this.isDefault = data.isDefault || false;
28286
+ this.locale = data.locale || "";
28287
+ this.name = data.name || "";
28288
+ }
28289
+ return IkasStorefrontLocalization;
28290
+ }());
28291
+
28292
+ var IkasStorefrontDomain = /** @class */ (function () {
28293
+ function IkasStorefrontDomain(data) {
28294
+ if (data === void 0) { data = {}; }
28295
+ this.id = data.id || "";
28296
+ this.merchantDomainId = data.merchantDomainId || "";
28297
+ this.name = data.name || "";
28298
+ this.redirectDomainName = data.redirectDomainName || null;
28299
+ this.isDefault = data.isDefault || false;
28300
+ makeAutoObservable(this);
28301
+ }
28302
+ return IkasStorefrontDomain;
28303
+ }());
28304
+
28305
+ var IkasStorefrontRouting = /** @class */ (function () {
28306
+ function IkasStorefrontRouting(data) {
28307
+ this.id = data.id || "";
28308
+ this.countryCodes = data.countryCodes || null;
28309
+ this.domain = data.domain || null;
28310
+ this.locale = data.locale || "";
28311
+ this.path = data.path || null;
28312
+ this.priceListId = data.priceListId || null;
28313
+ }
28314
+ return IkasStorefrontRouting;
28315
+ }());
28316
+
28317
+ var IkasStorefrontThemeStatus;
28318
+ (function (IkasStorefrontThemeStatus) {
28319
+ IkasStorefrontThemeStatus["WAITING"] = "WAITING";
28320
+ IkasStorefrontThemeStatus["READY"] = "READY";
28321
+ })(IkasStorefrontThemeStatus || (IkasStorefrontThemeStatus = {}));
28322
+ var IkasStorefrontTheme = /** @class */ (function () {
28323
+ function IkasStorefrontTheme(data) {
28324
+ this.id = data.id || "";
28325
+ this.isMainTheme = data.isMainTheme || false;
28326
+ this.name = data.name || "";
28327
+ this.status = data.status || IkasStorefrontThemeStatus.WAITING;
28328
+ this.themeId = data.themeId || "";
28329
+ this.themeVersionId = data.themeVersionId || "";
28330
+ }
28331
+ return IkasStorefrontTheme;
28332
+ }());
28333
+
28334
+ var StorefrontStatus;
28335
+ (function (StorefrontStatus) {
28336
+ StorefrontStatus["WAITING"] = "WAITING";
28337
+ StorefrontStatus["READY"] = "READY";
28338
+ })(StorefrontStatus || (StorefrontStatus = {}));
28339
+ var IkasStorefront = /** @class */ (function () {
28340
+ function IkasStorefront(data) {
28341
+ if (data === void 0) { data = {}; }
28342
+ this.id = data.id || "";
28343
+ this.name = data.name || "";
28344
+ this.status = data.status || StorefrontStatus.WAITING;
28345
+ this.mainStorefrontThemeId = data.mainStorefrontThemeId || null;
28346
+ this.emailSettingsId = data.emailSettingsId || null;
28347
+ this.salesChannelId = data.salesChannelId || null;
28348
+ this.gtmId = data.gtmId || null;
28349
+ this.fbpId = data.fbpId || null;
28350
+ // Sub Models
28351
+ this.localizations = data.localizations
28352
+ ? data.localizations.map(function (l) { return new IkasStorefrontLocalization(l); })
28353
+ : [];
28354
+ this.routings = data.routings
28355
+ ? data.routings.map(function (r) { return new IkasStorefrontRouting(r); })
28356
+ : [];
28357
+ this.domains = data.domains
28358
+ ? data.domains.map(function (o) { return new IkasStorefrontDomain(o); })
28359
+ : [];
28360
+ this.themes = data.themes
28361
+ ? data.themes.map(function (t) { return new IkasStorefrontTheme(t); })
28362
+ : [];
28363
+ }
28364
+ return IkasStorefront;
28365
+ }());
28366
+
28367
+ var IkasSalesChannel = /** @class */ (function () {
28368
+ function IkasSalesChannel(data) {
28369
+ if (data === void 0) { data = {}; }
28370
+ var _a;
28371
+ this.id = data.id || "";
28372
+ this.name = data.name || "";
28373
+ this.priceListId = data.priceListId || "";
28374
+ this.stockLocations =
28375
+ ((_a = data.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return new IkasSalesChannelStockLocation(sl); })) ||
28376
+ [];
28377
+ }
28378
+ return IkasSalesChannel;
28379
+ }());
28380
+ var IkasSalesChannelStockLocation = /** @class */ (function () {
28381
+ function IkasSalesChannelStockLocation(data) {
28382
+ this.id = data.id || "";
28383
+ this.order = data.order || 0;
28384
+ }
28385
+ return IkasSalesChannelStockLocation;
28386
+ }());
28387
+
28388
+ var IkasStorefrontThemeLocalization = /** @class */ (function () {
28389
+ function IkasStorefrontThemeLocalization(data) {
28390
+ this.id = data.id || "";
28391
+ this.locale = data.locale || "";
28392
+ this.storefrontId = data.storefrontId || "";
28393
+ this.storefrontThemeId = data.storefrontThemeId || "";
28394
+ this.themeJson = data.themeJson
28395
+ ? new IkasTheme(data.themeJson)
28396
+ : new IkasTheme();
28397
+ this.privacyPolicy = data.privacyPolicy || null;
28398
+ this.returnPolicy = data.returnPolicy || null;
28399
+ this.termsOfService = data.termsOfService || null;
28400
+ }
28401
+ return IkasStorefrontThemeLocalization;
28402
+ }());
28403
+
28404
+ var IkasStorefrontAPI = /** @class */ (function () {
28405
+ function IkasStorefrontAPI() {
28406
+ }
28407
+ IkasStorefrontAPI.getStorefront = function (id) {
28408
+ return __awaiter(this, void 0, void 0, function () {
28409
+ var QUERY, _a, data, errors, err_1;
28410
+ return __generator(this, function (_b) {
28411
+ switch (_b.label) {
28412
+ case 0:
28413
+ QUERY = src(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "], ["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "])));
28414
+ _b.label = 1;
28415
+ case 1:
28416
+ _b.trys.push([1, 3, , 4]);
28417
+ return [4 /*yield*/, apollo
28418
+ .getClient()
28419
+ .query({
28420
+ query: QUERY,
28421
+ variables: {
28422
+ id: id,
28423
+ },
28424
+ })];
28425
+ case 2:
28426
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
28427
+ if (errors && errors.length) {
28428
+ console.log(errors);
28429
+ }
28430
+ if (data)
28431
+ return [2 /*return*/, new IkasStorefront(data.getStorefront)];
28432
+ return [3 /*break*/, 4];
28433
+ case 3:
28434
+ err_1 = _b.sent();
28435
+ console.log(err_1);
28436
+ return [3 /*break*/, 4];
28437
+ case 4: return [2 /*return*/];
28438
+ }
28439
+ });
28440
+ });
28441
+ };
28442
+ return IkasStorefrontAPI;
28443
+ }());
28444
+ var templateObject_1$g;
28445
+
28446
+ var SettingsHelper = /** @class */ (function () {
28447
+ function SettingsHelper() {
28448
+ }
28449
+ SettingsHelper.readLocalTheme = function () {
28450
+ return new Promise(function (resolve, reject) {
28451
+ var themeJSONPath = "./src/theme.json";
28452
+ fs.readFile(themeJSONPath, {
28453
+ flag: "a+",
28454
+ }, function (err, file) {
28455
+ if (err) {
28456
+ return reject(err);
28457
+ }
28458
+ var result = file.length ? JSON.parse(file.toString()) : {};
28459
+ resolve(new IkasTheme(result));
28460
+ });
28461
+ });
28462
+ };
28463
+ SettingsHelper.readSettingsFile = function () {
28464
+ return new Promise(function (resolve) {
28465
+ var serverRuntimeConfig = getConfig().serverRuntimeConfig;
28466
+ var settingsPath = serverRuntimeConfig.SETTINGS;
28467
+ fs.readFile(settingsPath, {
28468
+ flag: "a+",
28469
+ }, function (err, file) {
28470
+ if (err) {
28471
+ console.error("SETTINGS FILE READ ERROR!!!");
28472
+ console.error(err);
28473
+ return resolve(null);
28474
+ }
28475
+ var result = file.length ? JSON.parse(file.toString()) : {};
28476
+ resolve(result);
28477
+ });
28478
+ });
28479
+ };
28480
+ SettingsHelper.getSettings = function (locale) {
28481
+ var _this = this;
28482
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
28483
+ var isLocal, storefrontResponse, storefront, localTheme, settings, storefront_1, salesChannel_1, localizationMap, themeLocalizationPath, routing_1;
28484
+ return __generator(this, function (_a) {
28485
+ switch (_a.label) {
28486
+ case 0:
28487
+ isLocal = process.env.NEXT_PUBLIC_ENV === "local";
28488
+ if (!isLocal) return [3 /*break*/, 3];
28489
+ if (!IkasStorefrontConfig.storefrontId) {
28490
+ console.error("Missing storefrontId in the config.json file!");
28491
+ return [2 /*return*/, resolve(null)];
28492
+ }
28493
+ return [4 /*yield*/, IkasStorefrontAPI.getStorefront(IkasStorefrontConfig.storefrontId)];
28494
+ case 1:
28495
+ storefrontResponse = _a.sent();
28496
+ if (!storefrontResponse)
28497
+ return [2 /*return*/, resolve(null)];
28498
+ storefront = storefrontResponse;
28499
+ return [4 /*yield*/, SettingsHelper.readLocalTheme()];
28500
+ case 2:
28501
+ localTheme = _a.sent();
28502
+ resolve({
28503
+ storefront: storefront,
28504
+ themeLocalization: new IkasStorefrontThemeLocalization({
28505
+ themeJson: localTheme,
28506
+ }),
28507
+ salesChannel: new IkasSalesChannel({
28508
+ id: storefront.salesChannelId,
28509
+ }),
28510
+ routing: storefront.routings.length
28511
+ ? storefront.routings[0]
28512
+ : new IkasStorefrontRouting({}),
28513
+ });
28514
+ return [3 /*break*/, 5];
28515
+ case 3: return [4 /*yield*/, SettingsHelper.readSettingsFile()];
28516
+ case 4:
28517
+ settings = _a.sent();
28518
+ if (!settings)
28519
+ return [2 /*return*/, resolve(null)];
28520
+ storefront_1 = new IkasStorefront(settings.storefront);
28521
+ salesChannel_1 = new IkasSalesChannel(settings.salesChannel);
28522
+ localizationMap = settings.localizationMap;
28523
+ themeLocalizationPath = localizationMap[locale];
28524
+ routing_1 = storefront_1.routings.find(function (r) { return r.id === locale || r.path === locale; });
28525
+ if (!themeLocalizationPath || !routing_1) {
28526
+ console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!");
28527
+ return [2 /*return*/, resolve(null)];
28528
+ }
28529
+ fs.readFile(themeLocalizationPath, {
28530
+ flag: "a+",
28531
+ }, function (err, file) {
28532
+ if (err) {
28533
+ console.error("THEME LOCALZIATION FILE READ ERROR!!!");
28534
+ console.error(err);
28535
+ return resolve(null);
28536
+ }
28537
+ var result = file.length ? JSON.parse(file.toString()) : {};
28538
+ resolve({
28539
+ storefront: storefront_1,
28540
+ themeLocalization: new IkasStorefrontThemeLocalization(result),
28541
+ salesChannel: salesChannel_1,
28542
+ routing: routing_1,
28543
+ });
28544
+ });
28545
+ _a.label = 5;
28546
+ case 5: return [2 /*return*/];
28547
+ }
28548
+ });
28549
+ }); });
28550
+ };
28551
+ SettingsHelper.getPageData = function (context, isServer, pageType) {
28552
+ var _a;
28553
+ return __awaiter(this, void 0, void 0, function () {
28554
+ var locale, settings, storefront, themeLocalization, salesChannel, routing, provider;
28555
+ return __generator(this, function (_b) {
28556
+ switch (_b.label) {
28557
+ case 0:
28558
+ locale = context.locale || context.defaultLocale || "en";
28559
+ return [4 /*yield*/, SettingsHelper.getSettings(locale)];
28560
+ case 1:
28561
+ settings = _b.sent();
28562
+ if (!settings ||
28563
+ !settings.storefront.mainStorefrontThemeId ||
28564
+ !settings.storefront.salesChannelId) {
28565
+ return [2 /*return*/, {
28566
+ props: {},
28567
+ notFound: true,
28568
+ }];
28569
+ }
28570
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, salesChannel = settings.salesChannel, routing = settings.routing;
28571
+ IkasStorefrontConfig.storefrontId = storefront.id;
28572
+ IkasStorefrontConfig.storefrontRoutingId = routing.id;
28573
+ IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28574
+ IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28575
+ IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
28576
+ IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
28577
+ IkasStorefrontConfig.routings = storefront.routings;
28578
+ provider = new IkasPageDataProvider(themeLocalization.themeJson, context.params, pageType);
28579
+ return [4 /*yield*/, provider.getPageData()];
28580
+ case 2:
28581
+ _b.sent();
28582
+ if (!provider.page) {
28583
+ return [2 /*return*/, {
28584
+ props: {},
28585
+ notFound: true,
28586
+ }];
28587
+ }
28588
+ if (isServer)
28589
+ return [2 /*return*/, provider.nextPageData];
28590
+ else
28591
+ return [2 /*return*/, {
28592
+ props: provider.nextPageData.props,
28593
+ revalidate: 60,
28594
+ }];
28595
+ }
28596
+ });
28597
+ });
28598
+ };
28599
+ SettingsHelper.getStaticProps = function (context, pageType) {
28600
+ return __awaiter(this, void 0, void 0, function () {
28601
+ return __generator(this, function (_a) {
28602
+ switch (_a.label) {
28603
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType)];
28604
+ case 1: return [2 /*return*/, _a.sent()];
28605
+ }
28606
+ });
28607
+ });
28608
+ };
28609
+ SettingsHelper.getServerSideProps = function (context, pageType) {
28610
+ return __awaiter(this, void 0, void 0, function () {
28611
+ return __generator(this, function (_a) {
28612
+ switch (_a.label) {
28613
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType)];
28614
+ case 1: return [2 /*return*/, _a.sent()];
28615
+ }
28616
+ });
28617
+ });
28618
+ };
28619
+ return SettingsHelper;
28620
+ }());
28621
+
28358
28622
  var Page = function (_a) {
28359
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28623
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28624
+ IkasStorefrontConfig.initWithJson(configJson);
28360
28625
  var router = useRouter();
28361
28626
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28362
28627
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28363
28628
  };
28364
28629
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28365
- var theme, provider;
28366
28630
  return __generator(this, function (_a) {
28367
28631
  switch (_a.label) {
28368
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28369
- case 1:
28370
- theme = _a.sent();
28371
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.INDEX);
28372
- return [4 /*yield*/, provider.getPageData()];
28373
- case 2:
28374
- _a.sent();
28375
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28632
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.INDEX)];
28633
+ case 1: return [2 /*return*/, _a.sent()];
28376
28634
  }
28377
28635
  });
28378
28636
  }); };
@@ -28384,7 +28642,8 @@ var home = /*#__PURE__*/Object.freeze({
28384
28642
  });
28385
28643
 
28386
28644
  var Page$1 = function (_a) {
28387
- var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28645
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28646
+ IkasStorefrontConfig.initWithJson(configJson);
28388
28647
  var router = useRouter();
28389
28648
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28390
28649
  var initialPropValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
@@ -28414,6 +28673,7 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28414
28673
  productMetaData = metaData.filter(function (m) { return m.targetType && m.targetType === IkasHTMLMetaDataTargetType.PRODUCT; });
28415
28674
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
28416
28675
  productIdList: productMetaData.map(function (p) { return p.targetId; }),
28676
+ priceListId: IkasStorefrontConfig.priceListId,
28417
28677
  })];
28418
28678
  case 2:
28419
28679
  productsResponse = _b.sent();
@@ -28460,25 +28720,10 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28460
28720
  });
28461
28721
  }); };
28462
28722
  var getStaticProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28463
- var theme, provider;
28464
28723
  return __generator(this, function (_a) {
28465
28724
  switch (_a.label) {
28466
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28467
- case 1:
28468
- theme = _a.sent();
28469
- provider = new IkasPageDataProvider(theme, context.params, undefined);
28470
- return [4 /*yield*/, provider.getPageData()];
28471
- case 2:
28472
- _a.sent();
28473
- if (!provider.page) {
28474
- return [2 /*return*/, {
28475
- notFound: true,
28476
- }];
28477
- }
28478
- return [2 /*return*/, {
28479
- props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr: JSON.stringify(provider.pageSpecificData || {}) }),
28480
- revalidate: 60,
28481
- }];
28725
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context)];
28726
+ case 1: return [2 /*return*/, _a.sent()];
28482
28727
  }
28483
28728
  });
28484
28729
  }); };
@@ -28517,25 +28762,52 @@ var index$2 = /*#__PURE__*/Object.freeze({
28517
28762
  });
28518
28763
 
28519
28764
  var Page$2 = function (_a) {
28520
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28765
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28766
+ IkasStorefrontConfig.initWithJson(configJson);
28521
28767
  var router = useRouter();
28522
28768
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28523
28769
  return (createElement(IkasPage, { page: page, settingsStr: settingsStr, propValues: propValues }));
28524
28770
  };
28525
28771
  var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28526
- var theme, customPages, customPagePaths;
28772
+ var allSettings, customPagePaths;
28527
28773
  return __generator(this, function (_a) {
28528
28774
  switch (_a.label) {
28529
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28775
+ case 0:
28776
+ if (!context.locales)
28777
+ return [2 /*return*/, {
28778
+ paths: [],
28779
+ fallback: "blocking",
28780
+ }];
28781
+ return [4 /*yield*/, Promise.all(context.locales.map(function (locale) { return SettingsHelper.getSettings(locale); }))];
28530
28782
  case 1:
28531
- theme = _a.sent();
28532
- customPages = theme.pages.filter(function (p) { return p.type === IkasThemePageType.CUSTOM; });
28533
- customPagePaths = customPages.map(function (p) { return ({
28534
- slug: p.slug,
28535
- }); });
28783
+ allSettings = (_a.sent());
28784
+ customPagePaths = [];
28785
+ allSettings.forEach(function (_a) {
28786
+ var themeLocalization = _a.themeLocalization, routing = _a.routing;
28787
+ if (!themeLocalization)
28788
+ return;
28789
+ var customPages = themeLocalization.themeJson.pages.filter(function (p) { return p.type === IkasThemePageType.CUSTOM; });
28790
+ customPages.forEach(function (customPage) {
28791
+ if (customPage.slug &&
28792
+ !customPagePaths.some(function (p) { return p.params.slug === customPage.slug; })) {
28793
+ if (process.env.NEXT_PUBLIC_ENV === "local") {
28794
+ customPagePaths.push({
28795
+ params: { slug: customPage.slug },
28796
+ });
28797
+ }
28798
+ else {
28799
+ customPagePaths.push({
28800
+ params: { slug: customPage.slug },
28801
+ locale: routing.path || routing.id,
28802
+ });
28803
+ }
28804
+ }
28805
+ });
28806
+ });
28536
28807
  return [2 /*return*/, {
28537
28808
  paths: customPagePaths.map(function (p) { return ({
28538
- params: p,
28809
+ params: p.params,
28810
+ locale: p.locale,
28539
28811
  }); }),
28540
28812
  fallback: "blocking",
28541
28813
  }];
@@ -28543,17 +28815,10 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
28543
28815
  });
28544
28816
  }); };
28545
28817
  var getStaticProps$2 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28546
- var theme, provider;
28547
28818
  return __generator(this, function (_a) {
28548
28819
  switch (_a.label) {
28549
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28550
- case 1:
28551
- theme = _a.sent();
28552
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.CUSTOM);
28553
- return [4 /*yield*/, provider.getPageData()];
28554
- case 2:
28555
- _a.sent();
28556
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28820
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.CUSTOM)];
28821
+ case 1: return [2 /*return*/, _a.sent()];
28557
28822
  }
28558
28823
  });
28559
28824
  }); };
@@ -28566,18 +28831,37 @@ var _slug_ = /*#__PURE__*/Object.freeze({
28566
28831
  });
28567
28832
 
28568
28833
  var CheckoutPage = function (_a) {
28569
- var checkoutStr = _a.checkoutStr, queryParams = _a.queryParams;
28834
+ var checkoutStr = _a.checkoutStr, configJson = _a.configJson, others = __rest(_a, ["checkoutStr", "configJson"]);
28835
+ IkasStorefrontConfig.initWithJson(configJson);
28570
28836
  Analytics.disableHTML();
28571
28837
  var checkout = new IkasCheckout(JSON.parse(checkoutStr));
28572
- return createElement(IkasCheckoutPage, { checkout: checkout, queryParams: queryParams });
28838
+ return createElement(IkasCheckoutPage, __assign({ checkout: checkout }, others));
28573
28839
  };
28574
28840
  var _id_ = observer(CheckoutPage);
28575
28841
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28576
- var id, redirect, checkout;
28842
+ var id, locale, settings, storefront, themeLocalization, routing, redirect, checkout;
28577
28843
  return __generator(this, function (_a) {
28578
28844
  switch (_a.label) {
28579
28845
  case 0:
28580
28846
  id = context.query.id;
28847
+ locale = context.locale || context.defaultLocale || "en";
28848
+ return [4 /*yield*/, SettingsHelper.getSettings(locale)];
28849
+ case 1:
28850
+ settings = _a.sent();
28851
+ // TODO maybe remove this and convert this page to static
28852
+ if (!settings ||
28853
+ !settings.storefront.mainStorefrontThemeId ||
28854
+ !settings.storefront.salesChannelId) {
28855
+ return [2 /*return*/, {
28856
+ props: {},
28857
+ notFound: true,
28858
+ }];
28859
+ }
28860
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, routing = settings.routing;
28861
+ IkasStorefrontConfig.storefrontId = storefront.id;
28862
+ IkasStorefrontConfig.storefrontRoutingId = routing.id;
28863
+ IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28864
+ IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28581
28865
  redirect = function () {
28582
28866
  context.res.writeHead(302, { Location: "/" });
28583
28867
  context.res.end();
@@ -28587,12 +28871,15 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28587
28871
  return [2 /*return*/, redirect()];
28588
28872
  }
28589
28873
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
28590
- case 1:
28874
+ case 2:
28591
28875
  checkout = _a.sent();
28592
28876
  if (checkout) {
28593
28877
  return [2 /*return*/, {
28594
28878
  props: {
28595
28879
  checkoutStr: JSON.stringify(checkout),
28880
+ returnPolicy: themeLocalization.returnPolicy || "",
28881
+ privacyPolicy: themeLocalization.privacyPolicy || "",
28882
+ termsOfService: themeLocalization.termsOfService || "",
28596
28883
  queryParams: context.query,
28597
28884
  },
28598
28885
  }];
@@ -28611,23 +28898,17 @@ var _id_$1 = /*#__PURE__*/Object.freeze({
28611
28898
  });
28612
28899
 
28613
28900
  var Page$3 = function (_a) {
28614
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28901
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28902
+ IkasStorefrontConfig.initWithJson(configJson);
28615
28903
  var router = useRouter();
28616
28904
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28617
28905
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28618
28906
  };
28619
28907
  var getStaticProps$3 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28620
- var theme, provider;
28621
28908
  return __generator(this, function (_a) {
28622
28909
  switch (_a.label) {
28623
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28624
- case 1:
28625
- theme = _a.sent();
28626
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ACCOUNT);
28627
- return [4 /*yield*/, provider.getPageData()];
28628
- case 2:
28629
- _a.sent();
28630
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28910
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.ACCOUNT)];
28911
+ case 1: return [2 /*return*/, _a.sent()];
28631
28912
  }
28632
28913
  });
28633
28914
  }); };
@@ -28639,23 +28920,17 @@ var index$3 = /*#__PURE__*/Object.freeze({
28639
28920
  });
28640
28921
 
28641
28922
  var Page$4 = function (_a) {
28642
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28923
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28924
+ IkasStorefrontConfig.initWithJson(configJson);
28643
28925
  var router = useRouter();
28644
28926
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28645
28927
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28646
28928
  };
28647
28929
  var getStaticProps$4 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28648
- var theme, provider;
28649
28930
  return __generator(this, function (_a) {
28650
28931
  switch (_a.label) {
28651
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28652
- case 1:
28653
- theme = _a.sent();
28654
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ADDRESSES);
28655
- return [4 /*yield*/, provider.getPageData()];
28656
- case 2:
28657
- _a.sent();
28658
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28932
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.ADDRESSES)];
28933
+ case 1: return [2 /*return*/, _a.sent()];
28659
28934
  }
28660
28935
  });
28661
28936
  }); };
@@ -28667,23 +28942,17 @@ var addresses = /*#__PURE__*/Object.freeze({
28667
28942
  });
28668
28943
 
28669
28944
  var Page$5 = function (_a) {
28670
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28945
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28946
+ IkasStorefrontConfig.initWithJson(configJson);
28671
28947
  var router = useRouter();
28672
28948
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28673
28949
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28674
28950
  };
28675
28951
  var getStaticProps$5 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28676
- var theme, provider;
28677
28952
  return __generator(this, function (_a) {
28678
28953
  switch (_a.label) {
28679
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28680
- case 1:
28681
- theme = _a.sent();
28682
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ORDERS);
28683
- return [4 /*yield*/, provider.getPageData()];
28684
- case 2:
28685
- _a.sent();
28686
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28954
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.ORDERS)];
28955
+ case 1: return [2 /*return*/, _a.sent()];
28687
28956
  }
28688
28957
  });
28689
28958
  }); };
@@ -28695,23 +28964,17 @@ var index$4 = /*#__PURE__*/Object.freeze({
28695
28964
  });
28696
28965
 
28697
28966
  var Page$6 = function (_a) {
28698
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28967
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28968
+ IkasStorefrontConfig.initWithJson(configJson);
28699
28969
  var router = useRouter();
28700
28970
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28701
28971
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28702
28972
  };
28703
28973
  var getServerSideProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28704
- var theme, provider;
28705
28974
  return __generator(this, function (_a) {
28706
28975
  switch (_a.label) {
28707
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28708
- case 1:
28709
- theme = _a.sent();
28710
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ORDER_DETAIL);
28711
- return [4 /*yield*/, provider.getPageData()];
28712
- case 2:
28713
- _a.sent();
28714
- return [2 /*return*/, provider.nextPageData];
28976
+ case 0: return [4 /*yield*/, SettingsHelper.getServerSideProps(context, IkasThemePageType.ORDER_DETAIL)];
28977
+ case 1: return [2 /*return*/, _a.sent()];
28715
28978
  }
28716
28979
  });
28717
28980
  }); };
@@ -28723,23 +28986,17 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
28723
28986
  });
28724
28987
 
28725
28988
  var Page$7 = function (_a) {
28726
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28989
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28990
+ IkasStorefrontConfig.initWithJson(configJson);
28727
28991
  var router = useRouter();
28728
28992
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28729
28993
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28730
28994
  };
28731
28995
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28732
- var theme, provider;
28733
28996
  return __generator(this, function (_a) {
28734
28997
  switch (_a.label) {
28735
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28736
- case 1:
28737
- theme = _a.sent();
28738
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.LOGIN);
28739
- return [4 /*yield*/, provider.getPageData()];
28740
- case 2:
28741
- _a.sent();
28742
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28998
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.LOGIN)];
28999
+ case 1: return [2 /*return*/, _a.sent()];
28743
29000
  }
28744
29001
  });
28745
29002
  }); };
@@ -28751,23 +29008,17 @@ var login = /*#__PURE__*/Object.freeze({
28751
29008
  });
28752
29009
 
28753
29010
  var Page$8 = function (_a) {
28754
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29011
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29012
+ IkasStorefrontConfig.initWithJson(configJson);
28755
29013
  var router = useRouter();
28756
29014
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28757
29015
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28758
29016
  };
28759
29017
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28760
- var theme, provider;
28761
29018
  return __generator(this, function (_a) {
28762
29019
  switch (_a.label) {
28763
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28764
- case 1:
28765
- theme = _a.sent();
28766
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.REGISTER);
28767
- return [4 /*yield*/, provider.getPageData()];
28768
- case 2:
28769
- _a.sent();
28770
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29020
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.REGISTER)];
29021
+ case 1: return [2 /*return*/, _a.sent()];
28771
29022
  }
28772
29023
  });
28773
29024
  }); };
@@ -28779,23 +29030,17 @@ var register = /*#__PURE__*/Object.freeze({
28779
29030
  });
28780
29031
 
28781
29032
  var Page$9 = function (_a) {
28782
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29033
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29034
+ IkasStorefrontConfig.initWithJson(configJson);
28783
29035
  var router = useRouter();
28784
29036
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28785
29037
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28786
29038
  };
28787
29039
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28788
- var theme, provider;
28789
29040
  return __generator(this, function (_a) {
28790
29041
  switch (_a.label) {
28791
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28792
- case 1:
28793
- theme = _a.sent();
28794
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.FORGOT_PASSWORD);
28795
- return [4 /*yield*/, provider.getPageData()];
28796
- case 2:
28797
- _a.sent();
28798
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29042
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.FORGOT_PASSWORD)];
29043
+ case 1: return [2 /*return*/, _a.sent()];
28799
29044
  }
28800
29045
  });
28801
29046
  }); };
@@ -28807,23 +29052,17 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
28807
29052
  });
28808
29053
 
28809
29054
  var Page$a = function (_a) {
28810
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29055
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29056
+ IkasStorefrontConfig.initWithJson(configJson);
28811
29057
  var router = useRouter();
28812
29058
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28813
29059
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28814
29060
  };
28815
29061
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28816
- var theme, provider;
28817
29062
  return __generator(this, function (_a) {
28818
29063
  switch (_a.label) {
28819
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28820
- case 1:
28821
- theme = _a.sent();
28822
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.RECOVER_PASSWORD);
28823
- return [4 /*yield*/, provider.getPageData()];
28824
- case 2:
28825
- _a.sent();
28826
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29064
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.RECOVER_PASSWORD)];
29065
+ case 1: return [2 /*return*/, _a.sent()];
28827
29066
  }
28828
29067
  });
28829
29068
  }); };
@@ -28835,7 +29074,8 @@ var recoverPassword = /*#__PURE__*/Object.freeze({
28835
29074
  });
28836
29075
 
28837
29076
  var Page$b = function (_a) {
28838
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
29077
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
29078
+ IkasStorefrontConfig.initWithJson(configJson);
28839
29079
  var router = useRouter();
28840
29080
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28841
29081
  var store = IkasStorefrontConfig.store;
@@ -28845,17 +29085,10 @@ var Page$b = function (_a) {
28845
29085
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28846
29086
  };
28847
29087
  var getStaticProps$a = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28848
- var theme, provider;
28849
29088
  return __generator(this, function (_a) {
28850
29089
  switch (_a.label) {
28851
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28852
- case 1:
28853
- theme = _a.sent();
28854
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.CART);
28855
- return [4 /*yield*/, provider.getPageData()];
28856
- case 2:
28857
- _a.sent();
28858
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29090
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.CART)];
29091
+ case 1: return [2 /*return*/, _a.sent()];
28859
29092
  }
28860
29093
  });
28861
29094
  }); };
@@ -28878,23 +29111,17 @@ var editor$1 = /*#__PURE__*/Object.freeze({
28878
29111
  });
28879
29112
 
28880
29113
  var Page$d = function (_a) {
28881
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
29114
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
29115
+ IkasStorefrontConfig.initWithJson(configJson);
28882
29116
  var router = useRouter();
28883
29117
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28884
29118
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28885
29119
  };
28886
29120
  var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28887
- var theme, provider;
28888
29121
  return __generator(this, function (_a) {
28889
29122
  switch (_a.label) {
28890
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28891
- case 1:
28892
- theme = _a.sent();
28893
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.FAVORITE_PRODUCTS);
28894
- return [4 /*yield*/, provider.getPageData()];
28895
- case 2:
28896
- _a.sent();
28897
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29123
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.FAVORITE_PRODUCTS)];
29124
+ case 1: return [2 /*return*/, _a.sent()];
28898
29125
  }
28899
29126
  });
28900
29127
  }); };
@@ -28906,7 +29133,8 @@ var favoriteProducts = /*#__PURE__*/Object.freeze({
28906
29133
  });
28907
29134
 
28908
29135
  var Page$e = function (_a) {
28909
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29136
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29137
+ IkasStorefrontConfig.initWithJson(configJson);
28910
29138
  var router = useRouter();
28911
29139
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28912
29140
  var initialPropValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
@@ -28920,17 +29148,10 @@ var Page$e = function (_a) {
28920
29148
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28921
29149
  };
28922
29150
  var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28923
- var theme, provider;
28924
29151
  return __generator(this, function (_a) {
28925
29152
  switch (_a.label) {
28926
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28927
- case 1:
28928
- theme = _a.sent();
28929
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.SEARCH);
28930
- return [4 /*yield*/, provider.getPageData()];
28931
- case 2:
28932
- _a.sent();
28933
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29153
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.SEARCH)];
29154
+ case 1: return [2 /*return*/, _a.sent()];
28934
29155
  }
28935
29156
  });
28936
29157
  }); };
@@ -28942,23 +29163,29 @@ var search = /*#__PURE__*/Object.freeze({
28942
29163
  });
28943
29164
 
28944
29165
  var Page$f = function (_a) {
28945
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29166
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29167
+ if (!propValuesStr || !page)
29168
+ return createElement(Error$1, { statusCode: 404 });
29169
+ IkasStorefrontConfig.initWithJson(configJson);
28946
29170
  var router = useRouter();
28947
29171
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28948
29172
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28949
29173
  };
28950
29174
  var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28951
- var theme, provider;
29175
+ var props;
28952
29176
  return __generator(this, function (_a) {
28953
29177
  switch (_a.label) {
28954
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
29178
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.NOT_FOUND)];
28955
29179
  case 1:
28956
- theme = _a.sent();
28957
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.NOT_FOUND);
28958
- return [4 /*yield*/, provider.getPageData()];
28959
- case 2:
28960
- _a.sent();
28961
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29180
+ props = _a.sent();
29181
+ //@ts-ignore
29182
+ if (props.notFound)
29183
+ return [2 /*return*/, {
29184
+ props: {},
29185
+ revalidate: 60,
29186
+ }];
29187
+ else
29188
+ return [2 /*return*/, props];
28962
29189
  }
28963
29190
  });
28964
29191
  }); };
@@ -28975,13 +29202,84 @@ configure({
28975
29202
  var IkasBaseStore = /** @class */ (function () {
28976
29203
  function IkasBaseStore() {
28977
29204
  this.currentPageType = null;
29205
+ this.localeOptions = [];
29206
+ this.showLocaleOptions = false;
29207
+ this.localeChecked = false;
28978
29208
  this.customerStore = new IkasCustomerStore(this);
28979
29209
  this.cartStore = new IkasCartStore(this);
28980
29210
  makeObservable(this, {
28981
29211
  currentPageType: observable,
29212
+ localeOptions: observable,
29213
+ showLocaleOptions: observable,
28982
29214
  });
28983
29215
  }
29216
+ IkasBaseStore.prototype.checkLocalization = function () {
29217
+ return __awaiter(this, void 0, void 0, function () {
29218
+ var myCountryCode, currentRouting, correctRouting, isCorrectLocale, countries_1, localeOptions_1;
29219
+ return __generator(this, function (_a) {
29220
+ switch (_a.label) {
29221
+ case 0:
29222
+ if (this.localeChecked)
29223
+ return [2 /*return*/];
29224
+ if (typeof window === undefined) {
29225
+ console.warn("checkRegion should be called on the client side!");
29226
+ return [2 /*return*/];
29227
+ }
29228
+ return [4 /*yield*/, IkasCountryAPI.getMyCountry()];
29229
+ case 1:
29230
+ myCountryCode = _a.sent();
29231
+ currentRouting = IkasStorefrontConfig.routings.find(function (r) { return r.id === IkasStorefrontConfig.storefrontRoutingId; });
29232
+ if (!(currentRouting && myCountryCode)) return [3 /*break*/, 3];
29233
+ correctRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); });
29234
+ isCorrectLocale = IkasStorefrontConfig.storefrontRoutingId === (correctRouting === null || correctRouting === void 0 ? void 0 : correctRouting.id);
29235
+ return [4 /*yield*/, IkasCountryAPI.listCountries()];
29236
+ case 2:
29237
+ countries_1 = _a.sent();
29238
+ localeOptions_1 = [];
29239
+ IkasStorefrontConfig.routings.map(function (r) {
29240
+ var _a;
29241
+ if ((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.length) {
29242
+ r.countryCodes.forEach(function (countryCode) {
29243
+ var _a;
29244
+ var country = countries_1.find(function (c) { return c.iso2 === countryCode; });
29245
+ localeOptions_1.push({
29246
+ id: v4(),
29247
+ countryName: (country === null || country === void 0 ? void 0 : country.native) || (country === null || country === void 0 ? void 0 : country.name) || "",
29248
+ routing: r,
29249
+ isRecommended: ((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode)) || false,
29250
+ });
29251
+ });
29252
+ }
29253
+ else {
29254
+ localeOptions_1.push({
29255
+ id: v4(),
29256
+ routing: r,
29257
+ isRecommended: !IkasStorefrontConfig.routings.some(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); }),
29258
+ });
29259
+ }
29260
+ });
29261
+ this.localeOptions = localeOptions_1;
29262
+ if (!isCorrectLocale) {
29263
+ this.showLocaleOptions = true;
29264
+ }
29265
+ this.localeChecked = true;
29266
+ _a.label = 3;
29267
+ case 3: return [2 /*return*/];
29268
+ }
29269
+ });
29270
+ });
29271
+ };
29272
+ IkasBaseStore.prototype.setLocalization = function (localeOption) {
29273
+ document.cookie = "NEXT_LOCALE=" + (localeOption.routing.path || localeOption.routing.id) + "; expires=Thu, 1 Dec 2050 12:00:00 UTC";
29274
+ if (localeOption.routing.domain) {
29275
+ window.location.replace("https://" + localeOption.routing.domain);
29276
+ }
29277
+ else {
29278
+ window.location.replace(window.location.origin +
29279
+ (localeOption.routing.path ? "/" + localeOption.routing.path : ""));
29280
+ }
29281
+ };
28984
29282
  return IkasBaseStore;
28985
29283
  }());
28986
29284
 
28987
- export { AccountInfoForm, index$3 as AccountPage, AddressForm, addresses as AddressesPage, Analytics, AnalyticsBody, AnalyticsHead, cart as CartPage, _id_$1 as CheckoutPage, ContactForm, _slug_ as CustomPage, editor$1 as EditorPage, EmailRule, EqualsRule, favoriteProducts as FavoriteProductsPage, ForgotPasswordForm, forgotPassword as ForgotPasswordPage, IkasAmountTypeEnum$1 as IkasAmountTypeEnum, IkasApplicableProductFilterValue, IkasBaseStore, IkasBrand, IkasBrandAPI, IkasBrandList, IkasBrandListPropValue, IkasBrandListSortType, IkasBrandListType, IkasBrandPropValue, IkasCardAssociation, IkasCardType, IkasCartAPI, IkasCategory, IkasCategoryAPI, IkasCategoryList, IkasCategoryListPropValue, IkasCategoryListSortType, IkasCategoryListType, IkasCategoryPropValue, IkasCheckout, IkasCheckoutAPI, IkasCheckoutPage, IkasCheckoutRecoveryEmailStatus, IkasCheckoutRecoveryStatus, IkasCheckoutStatus, IkasCityAPI, IkasContactForm, IkasContactFormAPI, IkasCountryAPI, IkasCustomer, IkasCustomerAPI, IkasCustomerAddress, IkasDistrictAPI, IkasFavoriteProduct, IkasFavoriteProductAPI, IkasHTMLMetaData, IkasHTMLMetaDataAPI, IkasHTMLMetaDataTargetType, IkasImage, IkasLinkPropValue, IkasLinkType, IkasMerchantAPI, IkasMerchantSettings, IkasNavigationLink, IkasOrder, IkasOrderCancelledReason, IkasOrderLineItem, IkasOrderPackageFulfillStatus, IkasOrderPackageStatus, IkasOrderPaymentStatus, IkasOrderShippingMethod, IkasOrderStatus, IkasOrderTransaction, IkasPage, IkasPageComponentPropValue, IkasPageDataProvider, IkasPageEditor, IkasPageHead, IkasPaymentMethod, IkasProduct, IkasProductAttribute, IkasProductAttributeAPI, IkasProductAttributeValue, IkasProductDetail, IkasProductDetailPropValue, IkasProductFilter, IkasProductFilterDisplayType, IkasProductFilterSettings, IkasProductFilterSortType, IkasProductFilterType, IkasProductFilterValue, IkasProductList, IkasProductListPropValue, IkasProductListSortType, IkasProductListType, IkasProductPrice, IkasProductSearchAPI, IkasProductType, IkasProductVariant, IkasProductVariantType, IkasShippingMethod, IkasShippingMethodEnum, IkasStateAPI, IkasStorefrontAPI, IkasStorefrontConfig, IkasTheme, IkasThemeAPI, IkasThemeComponent, IkasThemeComponentProp, IkasThemeComponentPropType, IkasThemeCustomData, IkasThemeCustomDataType, IkasThemePage, IkasThemePageComponent, IkasThemePageType, IkasThemeSettings, IkasTransactionStatusEnum, IkasTransactionTypeEnum, IkasVariantSelectionType, IkasVariantType, IkasVariantTypeAPI, IkasVariantValue, Image, home as IndexPage, LessThanRule, LoginForm, login as LoginPage, MaxRule, MinRule, _404 as NotFoundPage, _id_$2 as OrderDetailPage, OrderLineItemStatusEnum$1 as OrderLineItemStatusEnum, index$4 as OrdersPage, PhoneRule, RangeValue, RecoverPasswordForm, recoverPassword as RecoverPasswordPage, RegisterForm, register as RegisterPage, RequiredRule, search as SearchPage, index$2 as SlugPage, ValidationRule, Validator, ValidatorErrorType, apollo, decodeBase64, formatMoney, parseRangeStr, pascalCase, stringToSlug, validatePhoneNumber };
29285
+ export { AccountInfoForm, index$3 as AccountPage, AddressForm, addresses as AddressesPage, Analytics, AnalyticsBody, AnalyticsHead, cart as CartPage, _id_$1 as CheckoutPage, ContactForm, _slug_ as CustomPage, editor$1 as EditorPage, EmailRule, EqualsRule, favoriteProducts as FavoriteProductsPage, ForgotPasswordForm, forgotPassword as ForgotPasswordPage, IkasAmountTypeEnum$1 as IkasAmountTypeEnum, IkasApplicableProductFilterValue, IkasBaseStore, IkasBrand, IkasBrandAPI, IkasBrandList, IkasBrandListPropValue, IkasBrandListSortType, IkasBrandListType, IkasBrandPropValue, IkasCardAssociation, IkasCardType, IkasCartAPI, IkasCategory, IkasCategoryAPI, IkasCategoryList, IkasCategoryListPropValue, IkasCategoryListSortType, IkasCategoryListType, IkasCategoryPropValue, IkasCheckout, IkasCheckoutAPI, IkasCheckoutPage, IkasCheckoutRecoveryEmailStatus, IkasCheckoutRecoveryStatus, IkasCheckoutStatus, IkasCityAPI, IkasContactForm, IkasContactFormAPI, IkasCountryAPI, IkasCustomer, IkasCustomerAPI, IkasCustomerAddress, IkasDistrictAPI, IkasFavoriteProduct, IkasFavoriteProductAPI, IkasHTMLMetaData, IkasHTMLMetaDataAPI, IkasHTMLMetaDataTargetType, IkasImage, IkasLinkPropValue, IkasLinkType, IkasMerchantAPI, IkasMerchantSettings, IkasNavigationLink, IkasOrder, IkasOrderCancelledReason, IkasOrderLineItem, IkasOrderPackageFulfillStatus, IkasOrderPackageStatus, IkasOrderPaymentStatus, IkasOrderShippingMethod, IkasOrderStatus, IkasOrderTransaction, IkasPage, IkasPageComponentPropValue, IkasPageDataProvider, IkasPageEditor, IkasPageHead, IkasPaymentMethod, IkasProduct, IkasProductAttribute, IkasProductAttributeAPI, IkasProductAttributeValue, IkasProductDetail, IkasProductDetailPropValue, IkasProductFilter, IkasProductFilterDisplayType, IkasProductFilterSettings, IkasProductFilterSortType, IkasProductFilterType, IkasProductFilterValue, IkasProductList, IkasProductListPropValue, IkasProductListSortType, IkasProductListType, IkasProductPrice, IkasProductSearchAPI, IkasProductType, IkasProductVariant, IkasProductVariantType, IkasShippingMethod, IkasShippingMethodEnum, IkasStateAPI, IkasStorefrontConfig, IkasTheme, IkasThemeComponent, IkasThemeComponentProp, IkasThemeComponentPropType, IkasThemeCustomData, IkasThemeCustomDataType, IkasThemePage, IkasThemePageComponent, IkasThemePageType, IkasThemeSettings, IkasTransactionStatusEnum, IkasTransactionTypeEnum, IkasVariantSelectionType, IkasVariantType, IkasVariantTypeAPI, IkasVariantValue, Image, home as IndexPage, LessThanRule, LoginForm, login as LoginPage, MaxRule, MinRule, _404 as NotFoundPage, _id_$2 as OrderDetailPage, OrderLineItemStatusEnum$1 as OrderLineItemStatusEnum, index$4 as OrdersPage, PhoneRule, RangeValue, RecoverPasswordForm, recoverPassword as RecoverPasswordPage, RegisterForm, register as RegisterPage, RequiredRule, search as SearchPage, index$2 as SlugPage, ValidationRule, Validator, ValidatorErrorType, apollo, decodeBase64, formatMoney, parseRangeStr, pascalCase, stringToSlug, validatePhoneNumber };