@ikas/storefront 0.0.49 → 0.0.51

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 (34) hide show
  1. package/build/__generated__/global-types.d.ts +61 -0
  2. package/build/api/checkout/index.d.ts +1 -0
  3. package/build/api/customer/__generated__/getMyCustomer.d.ts +1 -0
  4. package/build/api/customer/__generated__/saveMyCustomer.d.ts +1 -0
  5. package/build/api/favorite-product/__generated__/isFavoriteProduct.d.ts +6 -0
  6. package/build/api/favorite-product/__generated__/listFavoriteProducts.d.ts +12 -0
  7. package/build/api/favorite-product/__generated__/saveFavoriteProduct.d.ts +7 -0
  8. package/build/api/favorite-product/index.d.ts +6 -0
  9. package/build/api/index.d.ts +2 -0
  10. package/build/api/product-search/__generated__/getProductFilterData.d.ts +27 -0
  11. package/build/api/product-search/__generated__/searchProducts.d.ts +26 -0
  12. package/build/api/product-search/index.d.ts +16 -0
  13. package/build/components/image/index.d.ts +3 -0
  14. package/build/components/index.d.ts +1 -0
  15. package/build/index.es.js +1513 -210
  16. package/build/index.js +1519 -209
  17. package/build/models/data/category/index.d.ts +2 -0
  18. package/build/models/data/favorite-product/index.d.ts +6 -0
  19. package/build/models/data/index.d.ts +2 -0
  20. package/build/models/data/product/attribute-value/index.d.ts +5 -1
  21. package/build/models/data/product-attribute/index.d.ts +1 -1
  22. package/build/models/data/product-filter/index.d.ts +72 -0
  23. package/build/models/data/simple-product/index.d.ts +134 -0
  24. package/build/models/data/variant-type/variant-value/index.d.ts +1 -1
  25. package/build/models/theme/page/index.d.ts +2 -1
  26. package/build/models/ui/index.d.ts +0 -1
  27. package/build/models/ui/product-list/index.d.ts +30 -7
  28. package/build/pages/account/favorite-products.d.ts +11 -0
  29. package/build/pages/index.d.ts +2 -1
  30. package/build/store/customer.d.ts +6 -1
  31. package/build/utils/providers/page-data.d.ts +2 -2
  32. package/build/utils/providers/prop-value/product-detail.d.ts +2 -2
  33. package/package.json +1 -1
  34. package/build/models/ui/product-list/filter.d.ts +0 -18
package/build/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { makeAutoObservable, toJS, runInAction, reaction, makeObservable, computed, observable, action, configure } from 'mobx';
2
- import React, { createElement, useState, useEffect, Fragment, useCallback, useRef } from 'react';
2
+ import React, { createElement, useState, useEffect, Fragment, useCallback, useRef, useMemo } from 'react';
3
3
  import { observer } from 'mobx-react-lite';
4
4
  import { useRouter } from 'next/router';
5
- import Image from 'next/image';
5
+ import Image$1 from 'next/image';
6
6
  import Link from 'next/link';
7
7
  import Head from 'next/head';
8
8
  import dynamic from 'next/dynamic';
@@ -10883,7 +10883,7 @@ var Apollo = /** @class */ (function () {
10883
10883
  this.createApolloClient = function (apiKey) {
10884
10884
  var authLink = setContext(function (_request, _a) {
10885
10885
  var headers = _a.headers;
10886
- var newHeaders = __assign(__assign({}, headers), { "x-api-key": apiKey || IkasStorefrontConfig.config.apiKey });
10886
+ var newHeaders = __assign(__assign({}, headers), { "x-api-key": apiKey || IkasStorefrontConfig.config.apiKey, "X-Operation-Name": _request.operationName });
10887
10887
  if (Apollo.customerToken) {
10888
10888
  newHeaders.Authorization = "Bearer " + Apollo.customerToken;
10889
10889
  }
@@ -10940,32 +10940,32 @@ var IkasProductListPropValueProvider = /** @class */ (function () {
10940
10940
  }
10941
10941
  IkasProductListPropValueProvider.prototype.getValue = function () {
10942
10942
  return __awaiter(this, void 0, void 0, function () {
10943
- var filters, category, brand, productList;
10943
+ var filterBrandId, filterCategoryId, category, brand, productList;
10944
10944
  return __generator(this, function (_a) {
10945
10945
  switch (_a.label) {
10946
10946
  case 0:
10947
- filters = new IkasProductListFilter();
10948
10947
  if (this.productListPropValue.productListType === IkasProductListType.ALL) {
10949
10948
  // TODO use pageParams to insert filters
10950
10949
  if (this.productListPropValue.usePageFilter) {
10951
10950
  if (this.pageType === IkasThemePageType.CATEGORY) {
10952
10951
  category = this.pageSpecificData;
10953
- filters.category = category.id;
10952
+ filterCategoryId = category.id;
10954
10953
  }
10955
10954
  else if (this.pageType === IkasThemePageType.BRAND) {
10956
10955
  brand = this.pageSpecificData;
10957
- filters.brand = brand.id;
10956
+ filterBrandId = brand.id;
10958
10957
  }
10959
10958
  }
10960
10959
  }
10961
- if (this.productListPropValue.productListType === IkasProductListType.CATEGORY) {
10962
- if (this.productListPropValue.category) {
10963
- filters.category = this.productListPropValue.category;
10964
- }
10960
+ if (this.productListPropValue.productListType ===
10961
+ IkasProductListType.CATEGORY &&
10962
+ this.productListPropValue.category) {
10963
+ filterCategoryId = this.productListPropValue.category;
10965
10964
  }
10966
10965
  productList = new IkasProductList({
10967
10966
  productListPropValue: this.productListPropValue,
10968
- filters: filters,
10967
+ filterBrandId: filterBrandId,
10968
+ filterCategoryId: filterCategoryId,
10969
10969
  });
10970
10970
  if (!!this.skipInitialFetch) return [3 /*break*/, 2];
10971
10971
  return [4 /*yield*/, productList.getInitial()];
@@ -10988,7 +10988,7 @@ var IkasProductDetailPropValueProvider = /** @class */ (function () {
10988
10988
  IkasProductDetailPropValueProvider.prototype.getValue = function () {
10989
10989
  var _a;
10990
10990
  return __awaiter(this, void 0, void 0, function () {
10991
- var productListResponse, product, variant;
10991
+ var productSearchResponse, productList, product, variant;
10992
10992
  var _this = this;
10993
10993
  return __generator(this, function (_b) {
10994
10994
  switch (_b.label) {
@@ -10996,17 +10996,30 @@ var IkasProductDetailPropValueProvider = /** @class */ (function () {
10996
10996
  if ((_a = this.productDetailPropValue) === null || _a === void 0 ? void 0 : _a.usePageData) {
10997
10997
  return [2 /*return*/, this.pageSpecificData];
10998
10998
  }
10999
- return [4 /*yield*/, IkasProductAPI.listProducts({
11000
- idList: [this.productDetailPropValue.productId],
10999
+ if (!this.productDetailPropValue.productId)
11000
+ return [2 /*return*/, null];
11001
+ return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
11002
+ productIdList: [this.productDetailPropValue.productId],
11001
11003
  })];
11002
11004
  case 1:
11003
- productListResponse = _b.sent();
11004
- product = productListResponse.products[0];
11005
- if (product === null || product === void 0 ? void 0 : product.hasVariant) {
11006
- variant = product.variants.find(function (v) { return v.id === _this.productDetailPropValue.variantId; });
11007
- return [2 /*return*/, new IkasProductDetail(product, variant.variantValues)];
11005
+ productSearchResponse = _b.sent();
11006
+ if (productSearchResponse) {
11007
+ productList = productSearchResponse.data;
11008
+ if (productList.length) {
11009
+ product = productList[0];
11010
+ if (product === null || product === void 0 ? void 0 : product.hasVariant) {
11011
+ variant = product.variants.find(function (v) { return v.id === _this.productDetailPropValue.variantId; });
11012
+ if (variant)
11013
+ return [2 /*return*/, new IkasProductDetail(product, variant.variantValues)];
11014
+ else
11015
+ return [2 /*return*/, null];
11016
+ }
11017
+ else {
11018
+ return [2 /*return*/, new IkasProductDetail(product, product.variants[0].variantValues)];
11019
+ }
11020
+ }
11008
11021
  }
11009
- return [2 /*return*/, new IkasProductDetail(product, [])];
11022
+ return [2 /*return*/, null];
11010
11023
  }
11011
11024
  });
11012
11025
  });
@@ -11982,14 +11995,14 @@ var IkasPageDataProvider = /** @class */ (function () {
11982
11995
  metaDataResponse = _b.sent();
11983
11996
  if (!metaDataResponse)
11984
11997
  return [2 /*return*/];
11985
- return [4 /*yield*/, IkasProductAPI.listProducts({
11986
- idList: [metaDataResponse.metaData.targetId],
11998
+ return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
11999
+ productIdList: [metaDataResponse.metaData.targetId],
11987
12000
  })];
11988
12001
  case 2:
11989
12002
  productsResponse = _b.sent();
11990
- if (!productsResponse.products.length)
12003
+ if (!(productsResponse === null || productsResponse === void 0 ? void 0 : productsResponse.data.length))
11991
12004
  return [2 /*return*/];
11992
- product = productsResponse.products[0];
12005
+ product = productsResponse.data[0];
11993
12006
  isMainProductSlug = slug.length === metaDataResponse.slug.length;
11994
12007
  selectedVariantValues = [];
11995
12008
  if (!isMainProductSlug) {
@@ -12150,7 +12163,7 @@ var IkasPageDataProvider = /** @class */ (function () {
12150
12163
  IkasPageDataProvider.initCategoryListPropValue(prop, propValue, pageComponentPropValue);
12151
12164
  break;
12152
12165
  case IkasThemeComponentPropType.PRODUCT_LIST:
12153
- IkasPageDataProvider.initProductListPropValue(prop, propValue, pageComponentPropValue);
12166
+ IkasPageDataProvider.initProductListPropValue(prop, propValue, pageComponentPropValue, router);
12154
12167
  break;
12155
12168
  case IkasThemeComponentPropType.PRODUCT_DETAIL:
12156
12169
  IkasPageDataProvider.initProductDetailPropValue(prop, propValue, pageComponentPropValue, router, isBrowser);
@@ -12192,11 +12205,11 @@ var IkasPageDataProvider = /** @class */ (function () {
12192
12205
  IkasPageDataProvider._initCategoryListPropValue = function (propValue) {
12193
12206
  return new IkasCategoryList(propValue);
12194
12207
  };
12195
- IkasPageDataProvider.initProductListPropValue = function (prop, propValue, pageComponentPropValue) {
12196
- pageComponentPropValue.propValues[prop.name] = this._initProductListPropValue(propValue);
12208
+ IkasPageDataProvider.initProductListPropValue = function (prop, propValue, pageComponentPropValue, router) {
12209
+ pageComponentPropValue.propValues[prop.name] = this._initProductListPropValue(propValue, router);
12197
12210
  };
12198
- IkasPageDataProvider._initProductListPropValue = function (propValue) {
12199
- return new IkasProductList(propValue);
12211
+ IkasPageDataProvider._initProductListPropValue = function (propValue, router) {
12212
+ return new IkasProductList(propValue, router);
12200
12213
  };
12201
12214
  IkasPageDataProvider.initProductDetailPropValue = function (prop, propValue, pageComponentPropValue, router, isBrowser) {
12202
12215
  pageComponentPropValue.propValues[prop.name] = this._initProductDetailPropValue(propValue, router, isBrowser);
@@ -12274,7 +12287,7 @@ var IkasPageDataProvider = /** @class */ (function () {
12274
12287
  case IkasThemeCustomDataType.PRODUCT_DETAIL:
12275
12288
  return this._initProductDetailPropValue(propValue, router, isBrowser);
12276
12289
  case IkasThemeCustomDataType.PRODUCT_LIST:
12277
- return this._initProductListPropValue(propValue);
12290
+ return this._initProductListPropValue(propValue, router);
12278
12291
  case IkasThemeCustomDataType.OBJECT:
12279
12292
  var objectValue = {};
12280
12293
  for (var _i = 0, _a = customData.nestedData || []; _i < _a.length; _i++) {
@@ -12425,6 +12438,7 @@ var IkasCategory = /** @class */ (function () {
12425
12438
  ? new IkasHTMLMetaData(data.metaData)
12426
12439
  : undefined;
12427
12440
  this.image = data.image ? new IkasImage(data.image.id) : null;
12441
+ this.path = data.path || [];
12428
12442
  makeAutoObservable(this);
12429
12443
  }
12430
12444
  Object.defineProperty(IkasCategory.prototype, "href", {
@@ -13094,7 +13108,7 @@ var IkasVariantValue = /** @class */ (function () {
13094
13108
  this.id = data.id || "";
13095
13109
  this.name = data.name || "";
13096
13110
  this.colorCode = data.colorCode || null;
13097
- this.thumbnilImageId = data.thumbnilImageId || null;
13111
+ this.thumbnailImageId = data.thumbnailImageId || null;
13098
13112
  this.variantTypeId = data.variantTypeId || "";
13099
13113
  makeAutoObservable(this);
13100
13114
  }
@@ -13107,8 +13121,8 @@ var IkasVariantValue = /** @class */ (function () {
13107
13121
  });
13108
13122
  Object.defineProperty(IkasVariantValue.prototype, "thumbnailImage", {
13109
13123
  get: function () {
13110
- if (this.thumbnilImageId)
13111
- return new IkasImage(this.thumbnilImageId);
13124
+ if (this.thumbnailImageId)
13125
+ return new IkasImage(this.thumbnailImageId);
13112
13126
  },
13113
13127
  enumerable: false,
13114
13128
  configurable: true
@@ -13116,11 +13130,48 @@ var IkasVariantValue = /** @class */ (function () {
13116
13130
  return IkasVariantValue;
13117
13131
  }());
13118
13132
 
13133
+ var IkasProductAttributeOption = /** @class */ (function () {
13134
+ function IkasProductAttributeOption(data) {
13135
+ if (data === void 0) { data = {}; }
13136
+ this.id = data.id || "";
13137
+ this.name = data.name || "";
13138
+ makeAutoObservable(this);
13139
+ }
13140
+ return IkasProductAttributeOption;
13141
+ }());
13142
+
13143
+ var IkasProductAttribute = /** @class */ (function () {
13144
+ function IkasProductAttribute(data) {
13145
+ this.id = data.id || "";
13146
+ this.name = data.name || "";
13147
+ this.type = data.type || IkasProductAttributeType.TEXT;
13148
+ this.options = data.options || null;
13149
+ makeAutoObservable(this);
13150
+ }
13151
+ return IkasProductAttribute;
13152
+ }());
13153
+ var IkasProductAttributeType;
13154
+ (function (IkasProductAttributeType) {
13155
+ IkasProductAttributeType["CHOICE"] = "CHOICE";
13156
+ IkasProductAttributeType["MULTIPLE_CHOICE"] = "MULTIPLE_CHOICE";
13157
+ IkasProductAttributeType["TEXT"] = "TEXT";
13158
+ IkasProductAttributeType["BOOLEAN"] = "BOOLEAN";
13159
+ IkasProductAttributeType["NUMERIC"] = "NUMERIC";
13160
+ IkasProductAttributeType["DATETIME"] = "DATETIME";
13161
+ IkasProductAttributeType["HTML"] = "HTML";
13162
+ })(IkasProductAttributeType || (IkasProductAttributeType = {}));
13163
+
13119
13164
  var IkasProductAttributeValue = /** @class */ (function () {
13120
13165
  function IkasProductAttributeValue(data) {
13121
13166
  this.value = data.value || null;
13122
13167
  this.productAttributeId = data.productAttributeId || "";
13123
13168
  this.productAttributeOptionId = data.productAttributeOptionId || null;
13169
+ this.productAttribute = data.productAttribute
13170
+ ? new IkasProductAttribute(data.productAttribute)
13171
+ : null;
13172
+ this.productAttributeOption = data.productAttributeOption
13173
+ ? new IkasProductAttributeOption(data.productAttributeOption)
13174
+ : null;
13124
13175
  makeAutoObservable(this);
13125
13176
  }
13126
13177
  return IkasProductAttributeValue;
@@ -13270,26 +13321,201 @@ var IkasProductType;
13270
13321
  IkasProductType["MEMBERSHIP"] = "MEMBERSHIP";
13271
13322
  })(IkasProductType || (IkasProductType = {}));
13272
13323
 
13273
- var IkasProductAttribute = /** @class */ (function () {
13274
- function IkasProductAttribute(data) {
13324
+ var IkasProductFilter = /** @class */ (function () {
13325
+ function IkasProductFilter(data) {
13326
+ if (data === void 0) { data = {}; }
13327
+ this.values = null;
13328
+ this.customValues = null;
13329
+ // Extra
13330
+ this.numberRange = null; // Selected range value for the number slider
13331
+ this.numberRangeLimit = null; // Limits for the number range slider
13332
+ this.numberRangeListOptions = null; // List options for the number range select
13275
13333
  this.id = data.id || "";
13334
+ this.key = data.key || "";
13276
13335
  this.name = data.name || "";
13277
- this.type = data.type || IkasProductAttributeType.TEXT;
13278
- this.options = data.options || null;
13336
+ this.order = data.order || 0;
13337
+ this.type = data.type || IkasProductFilterType.BRAND;
13338
+ this.displayType = data.displayType || IkasProductFilterDisplayType.BOX;
13339
+ this.isMultiSelect = data.isMultiSelect || false;
13340
+ this.values = data.values
13341
+ ? data.values.map(function (v) { return new IkasApplicableProductFilterValue(v); })
13342
+ : null;
13343
+ this.customValues = data.customValues || null;
13344
+ if (this.displayType === IkasProductFilterDisplayType.NUMBER_RANGE_LIST &&
13345
+ this.customValues &&
13346
+ this.customValues.length) {
13347
+ this.numberRangeListOptions = this.customValues.map(function (cv) {
13348
+ return new NumberRangeListOption(__assign(__assign({ key: cv }, parseRangeStr(cv)), { isSelected: false }));
13349
+ });
13350
+ }
13351
+ if (this.displayType === IkasProductFilterDisplayType.NUMBER_RANGE &&
13352
+ this.customValues &&
13353
+ this.customValues.length) {
13354
+ var value = this.customValues[0];
13355
+ this.numberRangeLimit = parseRangeStr(value);
13356
+ }
13279
13357
  makeAutoObservable(this);
13280
13358
  }
13281
- return IkasProductAttribute;
13359
+ Object.defineProperty(IkasProductFilter.prototype, "isCustomValueFilter", {
13360
+ get: function () {
13361
+ return [
13362
+ IkasProductFilterDisplayType.NUMBER_RANGE_LIST,
13363
+ IkasProductFilterDisplayType.NUMBER_RANGE,
13364
+ ].includes(this.displayType);
13365
+ },
13366
+ enumerable: false,
13367
+ configurable: true
13368
+ });
13369
+ Object.defineProperty(IkasProductFilter.prototype, "valueList", {
13370
+ get: function () {
13371
+ var _this = this;
13372
+ var _a;
13373
+ if (this.numberRange)
13374
+ return [this.rangeToId(this.numberRange)];
13375
+ if (this.numberRangeListOptions)
13376
+ return this.numberRangeListOptions
13377
+ .filter(function (o) { return o.isSelected; })
13378
+ .map(function (o) { return _this.rangeToId(o); });
13379
+ return ((_a = this.values) === null || _a === void 0 ? void 0 : _a.filter(function (v) { return v.isSelected; }).map(function (v) { return v.id; })) || [];
13380
+ },
13381
+ enumerable: false,
13382
+ configurable: true
13383
+ });
13384
+ Object.defineProperty(IkasProductFilter.prototype, "keyList", {
13385
+ get: function () {
13386
+ var _this = this;
13387
+ var _a;
13388
+ if (this.numberRange)
13389
+ return [this.rangeToId(this.numberRange)];
13390
+ if (this.numberRangeListOptions)
13391
+ return this.numberRangeListOptions
13392
+ .filter(function (o) { return o.isSelected; })
13393
+ .map(function (o) { return _this.rangeToId(o); });
13394
+ return ((_a = this.values) === null || _a === void 0 ? void 0 : _a.filter(function (v) { return v.isSelected; }).map(function (v) { return v.key; })) || [];
13395
+ },
13396
+ enumerable: false,
13397
+ configurable: true
13398
+ });
13399
+ IkasProductFilter.prototype.clear = function () {
13400
+ var _a, _b;
13401
+ this.numberRange = null;
13402
+ (_a = this.numberRangeListOptions) === null || _a === void 0 ? void 0 : _a.forEach(function (o) { return (o.isSelected = false); });
13403
+ (_b = this.values) === null || _b === void 0 ? void 0 : _b.forEach(function (v) { return (v.isSelected = false); });
13404
+ };
13405
+ IkasProductFilter.prototype.toInput = function () {
13406
+ return {
13407
+ id: this.key,
13408
+ type: this.type,
13409
+ valueList: this.valueList,
13410
+ };
13411
+ };
13412
+ IkasProductFilter.prototype.rangeToId = function (range) {
13413
+ return range.from + ":" + (range.to || "");
13414
+ };
13415
+ return IkasProductFilter;
13282
13416
  }());
13283
- var IkasProductAttributeType;
13284
- (function (IkasProductAttributeType) {
13285
- IkasProductAttributeType["CHOICE"] = "CHOICE";
13286
- IkasProductAttributeType["MULTIPLE_CHOICE"] = "MULTIPLE_CHOICE";
13287
- IkasProductAttributeType["TEXT"] = "TEXT";
13288
- IkasProductAttributeType["BOOLEAN"] = "BOOLEAN";
13289
- IkasProductAttributeType["NUMERIC"] = "NUMERIC";
13290
- IkasProductAttributeType["DATETIME"] = "DATETIME";
13291
- IkasProductAttributeType["HTML"] = "HTML";
13292
- })(IkasProductAttributeType || (IkasProductAttributeType = {}));
13417
+ var IkasApplicableProductFilterValue = /** @class */ (function () {
13418
+ function IkasApplicableProductFilterValue(data) {
13419
+ if (data === void 0) { data = {}; }
13420
+ this.colorCode = null;
13421
+ this.thumbnailImageId = null;
13422
+ this.thumbnailImage = null;
13423
+ // Extra
13424
+ this._isSelected = false;
13425
+ this.id = data.id || "";
13426
+ this.key = data.key || "";
13427
+ this.name = data.name || "";
13428
+ this.colorCode = data.colorCode || null;
13429
+ this.thumbnailImageId = data.thumbnailImageId || null;
13430
+ if (this.thumbnailImageId)
13431
+ this.thumbnailImage = new IkasImage(this.thumbnailImageId);
13432
+ this._isSelected = data.isSelected || false;
13433
+ makeAutoObservable(this);
13434
+ }
13435
+ Object.defineProperty(IkasApplicableProductFilterValue.prototype, "isSelected", {
13436
+ get: function () {
13437
+ return this._isSelected;
13438
+ },
13439
+ set: function (value) {
13440
+ this._isSelected = value;
13441
+ },
13442
+ enumerable: false,
13443
+ configurable: true
13444
+ });
13445
+ return IkasApplicableProductFilterValue;
13446
+ }());
13447
+ var IkasProductFilterValue = /** @class */ (function () {
13448
+ function IkasProductFilterValue(data) {
13449
+ this.id = data.id;
13450
+ this.type = data.type;
13451
+ this.valueList = data.valueList;
13452
+ makeAutoObservable(this);
13453
+ }
13454
+ return IkasProductFilterValue;
13455
+ }());
13456
+ var IkasProductFilterType;
13457
+ (function (IkasProductFilterType) {
13458
+ IkasProductFilterType["ATTRIBUTE"] = "ATTRIBUTE";
13459
+ IkasProductFilterType["BRAND"] = "BRAND";
13460
+ IkasProductFilterType["DISCOUNT_RATIO"] = "DISCOUNT_RATIO";
13461
+ IkasProductFilterType["PRICE"] = "PRICE";
13462
+ IkasProductFilterType["STOCK_STATUS"] = "STOCK_STATUS";
13463
+ IkasProductFilterType["TAG"] = "TAG";
13464
+ IkasProductFilterType["VARIANT_TYPE"] = "VARIANT_TYPE";
13465
+ })(IkasProductFilterType || (IkasProductFilterType = {}));
13466
+ var IkasProductFilterDisplayType;
13467
+ (function (IkasProductFilterDisplayType) {
13468
+ IkasProductFilterDisplayType["BOX"] = "BOX";
13469
+ IkasProductFilterDisplayType["DATE_RANGE"] = "DATE_RANGE";
13470
+ IkasProductFilterDisplayType["LIST"] = "LIST";
13471
+ IkasProductFilterDisplayType["NUMBER_RANGE_LIST"] = "NUMBER_RANGE_LIST";
13472
+ IkasProductFilterDisplayType["NUMBER_RANGE"] = "NUMBER_RANGE";
13473
+ IkasProductFilterDisplayType["SWATCH"] = "SWATCH";
13474
+ })(IkasProductFilterDisplayType || (IkasProductFilterDisplayType = {}));
13475
+ var RangeValue = /** @class */ (function () {
13476
+ function RangeValue(data) {
13477
+ this.from = data.from || 0;
13478
+ this.to = data.to || null;
13479
+ makeAutoObservable(this);
13480
+ }
13481
+ return RangeValue;
13482
+ }());
13483
+ var NumberRangeListOption = /** @class */ (function () {
13484
+ function NumberRangeListOption(data) {
13485
+ this.from = data.from || 0;
13486
+ this.to = data.to || null;
13487
+ this.key = data.key || "";
13488
+ this.isSelected = data.isSelected || false;
13489
+ makeAutoObservable(this);
13490
+ }
13491
+ return NumberRangeListOption;
13492
+ }());
13493
+ function parseRangeStr(rangeStr) {
13494
+ try {
13495
+ var parsedValues = rangeStr.split(":").map(function (i) { return parseInt(i); });
13496
+ return new RangeValue({
13497
+ from: isNaN(parsedValues[0]) ? 0 : parsedValues[0],
13498
+ to: isNaN(parsedValues[1]) ? undefined : parsedValues[1],
13499
+ });
13500
+ }
13501
+ catch (err) {
13502
+ console.log(err);
13503
+ return new RangeValue({
13504
+ from: 0,
13505
+ to: 0,
13506
+ });
13507
+ }
13508
+ }
13509
+
13510
+ var IkasFavoriteProduct = /** @class */ (function () {
13511
+ function IkasFavoriteProduct(data) {
13512
+ this.id = data.id || "";
13513
+ this.customerId = data.customerId || "";
13514
+ this.productId = data.productId || "";
13515
+ makeAutoObservable(this);
13516
+ }
13517
+ return IkasFavoriteProduct;
13518
+ }());
13293
13519
 
13294
13520
  var IkasOrderTransaction = /** @class */ (function () {
13295
13521
  function IkasOrderTransaction(data) {
@@ -13562,6 +13788,7 @@ var IkasThemePageType;
13562
13788
  IkasThemePageType["FORGOT_PASSWORD"] = "FORGOT_PASSWORD";
13563
13789
  IkasThemePageType["RECOVER_PASSWORD"] = "RECOVER_PASSWORD";
13564
13790
  IkasThemePageType["CART"] = "CART";
13791
+ IkasThemePageType["FAVORITE_PRODUCTS"] = "FAVORITE_PRODUCTS";
13565
13792
  })(IkasThemePageType || (IkasThemePageType = {}));
13566
13793
 
13567
13794
  var IkasThemeColor = /** @class */ (function () {
@@ -14288,111 +14515,611 @@ var IkasProductDetail = /** @class */ (function () {
14288
14515
  return IkasProductDetail;
14289
14516
  }());
14290
14517
 
14291
- var IkasProductListFilter = /** @class */ (function () {
14292
- function IkasProductListFilter(data) {
14293
- if (data === void 0) { data = {}; }
14294
- this.category = null;
14295
- this.brand = null;
14296
- this.category = data.category || null;
14297
- this.brand = data.brand || null;
14298
- this.categories = data.categories || [];
14299
- this.brands = data.brands || [];
14300
- this.variantValues = data.variantValues || [];
14301
- this.attributes = data.attributes || [];
14302
- makeAutoObservable(this);
14303
- }
14304
- return IkasProductListFilter;
14305
- }());
14518
+ var strictUriEncode = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
14519
+
14520
+ var token = '%[a-f0-9]{2}';
14521
+ var singleMatcher = new RegExp(token, 'gi');
14522
+ var multiMatcher = new RegExp('(' + token + ')+', 'gi');
14523
+
14524
+ function decodeComponents(components, split) {
14525
+ try {
14526
+ // Try to decode the entire string first
14527
+ return decodeURIComponent(components.join(''));
14528
+ } catch (err) {
14529
+ // Do nothing
14530
+ }
14531
+
14532
+ if (components.length === 1) {
14533
+ return components;
14534
+ }
14535
+
14536
+ split = split || 1;
14537
+
14538
+ // Split the array in 2 parts
14539
+ var left = components.slice(0, split);
14540
+ var right = components.slice(split);
14541
+
14542
+ return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
14543
+ }
14544
+
14545
+ function decode(input) {
14546
+ try {
14547
+ return decodeURIComponent(input);
14548
+ } catch (err) {
14549
+ var tokens = input.match(singleMatcher);
14550
+
14551
+ for (var i = 1; i < tokens.length; i++) {
14552
+ input = decodeComponents(tokens, i).join('');
14553
+
14554
+ tokens = input.match(singleMatcher);
14555
+ }
14556
+
14557
+ return input;
14558
+ }
14559
+ }
14560
+
14561
+ function customDecodeURIComponent(input) {
14562
+ // Keep track of all the replacements and prefill the map with the `BOM`
14563
+ var replaceMap = {
14564
+ '%FE%FF': '\uFFFD\uFFFD',
14565
+ '%FF%FE': '\uFFFD\uFFFD'
14566
+ };
14567
+
14568
+ var match = multiMatcher.exec(input);
14569
+ while (match) {
14570
+ try {
14571
+ // Decode as big chunks as possible
14572
+ replaceMap[match[0]] = decodeURIComponent(match[0]);
14573
+ } catch (err) {
14574
+ var result = decode(match[0]);
14575
+
14576
+ if (result !== match[0]) {
14577
+ replaceMap[match[0]] = result;
14578
+ }
14579
+ }
14580
+
14581
+ match = multiMatcher.exec(input);
14582
+ }
14583
+
14584
+ // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
14585
+ replaceMap['%C2'] = '\uFFFD';
14586
+
14587
+ var entries = Object.keys(replaceMap);
14588
+
14589
+ for (var i = 0; i < entries.length; i++) {
14590
+ // Replace all decoded components
14591
+ var key = entries[i];
14592
+ input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
14593
+ }
14594
+
14595
+ return input;
14596
+ }
14597
+
14598
+ var decodeUriComponent = function (encodedURI) {
14599
+ if (typeof encodedURI !== 'string') {
14600
+ throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
14601
+ }
14602
+
14603
+ try {
14604
+ encodedURI = encodedURI.replace(/\+/g, ' ');
14605
+
14606
+ // Try the built in decoder first
14607
+ return decodeURIComponent(encodedURI);
14608
+ } catch (err) {
14609
+ // Fallback to a more advanced decoder
14610
+ return customDecodeURIComponent(encodedURI);
14611
+ }
14612
+ };
14613
+
14614
+ var splitOnFirst = (string, separator) => {
14615
+ if (!(typeof string === 'string' && typeof separator === 'string')) {
14616
+ throw new TypeError('Expected the arguments to be of type `string`');
14617
+ }
14618
+
14619
+ if (separator === '') {
14620
+ return [string];
14621
+ }
14622
+
14623
+ const separatorIndex = string.indexOf(separator);
14624
+
14625
+ if (separatorIndex === -1) {
14626
+ return [string];
14627
+ }
14628
+
14629
+ return [
14630
+ string.slice(0, separatorIndex),
14631
+ string.slice(separatorIndex + separator.length)
14632
+ ];
14633
+ };
14634
+
14635
+ var queryString = createCommonjsModule(function (module, exports) {
14636
+
14637
+
14638
+
14639
+
14640
+ const isNullOrUndefined = value => value === null || value === undefined;
14641
+
14642
+ function encoderForArrayFormat(options) {
14643
+ switch (options.arrayFormat) {
14644
+ case 'index':
14645
+ return key => (result, value) => {
14646
+ const index = result.length;
14647
+
14648
+ if (
14649
+ value === undefined ||
14650
+ (options.skipNull && value === null) ||
14651
+ (options.skipEmptyString && value === '')
14652
+ ) {
14653
+ return result;
14654
+ }
14655
+
14656
+ if (value === null) {
14657
+ return [...result, [encode(key, options), '[', index, ']'].join('')];
14658
+ }
14659
+
14660
+ return [
14661
+ ...result,
14662
+ [encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
14663
+ ];
14664
+ };
14665
+
14666
+ case 'bracket':
14667
+ return key => (result, value) => {
14668
+ if (
14669
+ value === undefined ||
14670
+ (options.skipNull && value === null) ||
14671
+ (options.skipEmptyString && value === '')
14672
+ ) {
14673
+ return result;
14674
+ }
14675
+
14676
+ if (value === null) {
14677
+ return [...result, [encode(key, options), '[]'].join('')];
14678
+ }
14679
+
14680
+ return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
14681
+ };
14682
+
14683
+ case 'comma':
14684
+ case 'separator':
14685
+ return key => (result, value) => {
14686
+ if (value === null || value === undefined || value.length === 0) {
14687
+ return result;
14688
+ }
14689
+
14690
+ if (result.length === 0) {
14691
+ return [[encode(key, options), '=', encode(value, options)].join('')];
14692
+ }
14693
+
14694
+ return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
14695
+ };
14696
+
14697
+ default:
14698
+ return key => (result, value) => {
14699
+ if (
14700
+ value === undefined ||
14701
+ (options.skipNull && value === null) ||
14702
+ (options.skipEmptyString && value === '')
14703
+ ) {
14704
+ return result;
14705
+ }
14706
+
14707
+ if (value === null) {
14708
+ return [...result, encode(key, options)];
14709
+ }
14710
+
14711
+ return [...result, [encode(key, options), '=', encode(value, options)].join('')];
14712
+ };
14713
+ }
14714
+ }
14715
+
14716
+ function parserForArrayFormat(options) {
14717
+ let result;
14718
+
14719
+ switch (options.arrayFormat) {
14720
+ case 'index':
14721
+ return (key, value, accumulator) => {
14722
+ result = /\[(\d*)\]$/.exec(key);
14723
+
14724
+ key = key.replace(/\[\d*\]$/, '');
14725
+
14726
+ if (!result) {
14727
+ accumulator[key] = value;
14728
+ return;
14729
+ }
14730
+
14731
+ if (accumulator[key] === undefined) {
14732
+ accumulator[key] = {};
14733
+ }
14734
+
14735
+ accumulator[key][result[1]] = value;
14736
+ };
14737
+
14738
+ case 'bracket':
14739
+ return (key, value, accumulator) => {
14740
+ result = /(\[\])$/.exec(key);
14741
+ key = key.replace(/\[\]$/, '');
14742
+
14743
+ if (!result) {
14744
+ accumulator[key] = value;
14745
+ return;
14746
+ }
14747
+
14748
+ if (accumulator[key] === undefined) {
14749
+ accumulator[key] = [value];
14750
+ return;
14751
+ }
14752
+
14753
+ accumulator[key] = [].concat(accumulator[key], value);
14754
+ };
14755
+
14756
+ case 'comma':
14757
+ case 'separator':
14758
+ return (key, value, accumulator) => {
14759
+ const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);
14760
+ const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));
14761
+ value = isEncodedArray ? decode(value, options) : value;
14762
+ const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
14763
+ accumulator[key] = newValue;
14764
+ };
14765
+
14766
+ default:
14767
+ return (key, value, accumulator) => {
14768
+ if (accumulator[key] === undefined) {
14769
+ accumulator[key] = value;
14770
+ return;
14771
+ }
14772
+
14773
+ accumulator[key] = [].concat(accumulator[key], value);
14774
+ };
14775
+ }
14776
+ }
14777
+
14778
+ function validateArrayFormatSeparator(value) {
14779
+ if (typeof value !== 'string' || value.length !== 1) {
14780
+ throw new TypeError('arrayFormatSeparator must be single character string');
14781
+ }
14782
+ }
14783
+
14784
+ function encode(value, options) {
14785
+ if (options.encode) {
14786
+ return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
14787
+ }
14788
+
14789
+ return value;
14790
+ }
14791
+
14792
+ function decode(value, options) {
14793
+ if (options.decode) {
14794
+ return decodeUriComponent(value);
14795
+ }
14796
+
14797
+ return value;
14798
+ }
14799
+
14800
+ function keysSorter(input) {
14801
+ if (Array.isArray(input)) {
14802
+ return input.sort();
14803
+ }
14804
+
14805
+ if (typeof input === 'object') {
14806
+ return keysSorter(Object.keys(input))
14807
+ .sort((a, b) => Number(a) - Number(b))
14808
+ .map(key => input[key]);
14809
+ }
14810
+
14811
+ return input;
14812
+ }
14813
+
14814
+ function removeHash(input) {
14815
+ const hashStart = input.indexOf('#');
14816
+ if (hashStart !== -1) {
14817
+ input = input.slice(0, hashStart);
14818
+ }
14819
+
14820
+ return input;
14821
+ }
14822
+
14823
+ function getHash(url) {
14824
+ let hash = '';
14825
+ const hashStart = url.indexOf('#');
14826
+ if (hashStart !== -1) {
14827
+ hash = url.slice(hashStart);
14828
+ }
14829
+
14830
+ return hash;
14831
+ }
14832
+
14833
+ function extract(input) {
14834
+ input = removeHash(input);
14835
+ const queryStart = input.indexOf('?');
14836
+ if (queryStart === -1) {
14837
+ return '';
14838
+ }
14839
+
14840
+ return input.slice(queryStart + 1);
14841
+ }
14842
+
14843
+ function parseValue(value, options) {
14844
+ if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
14845
+ value = Number(value);
14846
+ } else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
14847
+ value = value.toLowerCase() === 'true';
14848
+ }
14849
+
14850
+ return value;
14851
+ }
14852
+
14853
+ function parse(query, options) {
14854
+ options = Object.assign({
14855
+ decode: true,
14856
+ sort: true,
14857
+ arrayFormat: 'none',
14858
+ arrayFormatSeparator: ',',
14859
+ parseNumbers: false,
14860
+ parseBooleans: false
14861
+ }, options);
14862
+
14863
+ validateArrayFormatSeparator(options.arrayFormatSeparator);
14864
+
14865
+ const formatter = parserForArrayFormat(options);
14866
+
14867
+ // Create an object with no prototype
14868
+ const ret = Object.create(null);
14869
+
14870
+ if (typeof query !== 'string') {
14871
+ return ret;
14872
+ }
14873
+
14874
+ query = query.trim().replace(/^[?#&]/, '');
14875
+
14876
+ if (!query) {
14877
+ return ret;
14878
+ }
14879
+
14880
+ for (const param of query.split('&')) {
14881
+ let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '=');
14882
+
14883
+ // Missing `=` should be `null`:
14884
+ // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
14885
+ value = value === undefined ? null : ['comma', 'separator'].includes(options.arrayFormat) ? value : decode(value, options);
14886
+ formatter(decode(key, options), value, ret);
14887
+ }
14888
+
14889
+ for (const key of Object.keys(ret)) {
14890
+ const value = ret[key];
14891
+ if (typeof value === 'object' && value !== null) {
14892
+ for (const k of Object.keys(value)) {
14893
+ value[k] = parseValue(value[k], options);
14894
+ }
14895
+ } else {
14896
+ ret[key] = parseValue(value, options);
14897
+ }
14898
+ }
14899
+
14900
+ if (options.sort === false) {
14901
+ return ret;
14902
+ }
14903
+
14904
+ return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
14905
+ const value = ret[key];
14906
+ if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
14907
+ // Sort object keys, not values
14908
+ result[key] = keysSorter(value);
14909
+ } else {
14910
+ result[key] = value;
14911
+ }
14912
+
14913
+ return result;
14914
+ }, Object.create(null));
14915
+ }
14916
+
14917
+ exports.extract = extract;
14918
+ exports.parse = parse;
14919
+
14920
+ exports.stringify = (object, options) => {
14921
+ if (!object) {
14922
+ return '';
14923
+ }
14924
+
14925
+ options = Object.assign({
14926
+ encode: true,
14927
+ strict: true,
14928
+ arrayFormat: 'none',
14929
+ arrayFormatSeparator: ','
14930
+ }, options);
14931
+
14932
+ validateArrayFormatSeparator(options.arrayFormatSeparator);
14933
+
14934
+ const shouldFilter = key => (
14935
+ (options.skipNull && isNullOrUndefined(object[key])) ||
14936
+ (options.skipEmptyString && object[key] === '')
14937
+ );
14938
+
14939
+ const formatter = encoderForArrayFormat(options);
14940
+
14941
+ const objectCopy = {};
14942
+
14943
+ for (const key of Object.keys(object)) {
14944
+ if (!shouldFilter(key)) {
14945
+ objectCopy[key] = object[key];
14946
+ }
14947
+ }
14948
+
14949
+ const keys = Object.keys(objectCopy);
14950
+
14951
+ if (options.sort !== false) {
14952
+ keys.sort(options.sort);
14953
+ }
14954
+
14955
+ return keys.map(key => {
14956
+ const value = object[key];
14957
+
14958
+ if (value === undefined) {
14959
+ return '';
14960
+ }
14961
+
14962
+ if (value === null) {
14963
+ return encode(key, options);
14964
+ }
14965
+
14966
+ if (Array.isArray(value)) {
14967
+ return value
14968
+ .reduce(formatter(key), [])
14969
+ .join('&');
14970
+ }
14971
+
14972
+ return encode(key, options) + '=' + encode(value, options);
14973
+ }).filter(x => x.length > 0).join('&');
14974
+ };
14975
+
14976
+ exports.parseUrl = (url, options) => {
14977
+ options = Object.assign({
14978
+ decode: true
14979
+ }, options);
14980
+
14981
+ const [url_, hash] = splitOnFirst(url, '#');
14982
+
14983
+ return Object.assign(
14984
+ {
14985
+ url: url_.split('?')[0] || '',
14986
+ query: parse(extract(url), options)
14987
+ },
14988
+ options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}
14989
+ );
14990
+ };
14991
+
14992
+ exports.stringifyUrl = (object, options) => {
14993
+ options = Object.assign({
14994
+ encode: true,
14995
+ strict: true
14996
+ }, options);
14997
+
14998
+ const url = removeHash(object.url).split('?')[0] || '';
14999
+ const queryFromUrl = exports.extract(object.url);
15000
+ const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false});
15001
+
15002
+ const query = Object.assign(parsedQueryFromUrl, object.query);
15003
+ let queryString = exports.stringify(query, options);
15004
+ if (queryString) {
15005
+ queryString = `?${queryString}`;
15006
+ }
15007
+
15008
+ let hash = getHash(object.url);
15009
+ if (object.fragmentIdentifier) {
15010
+ hash = `#${encode(object.fragmentIdentifier, options)}`;
15011
+ }
15012
+
15013
+ return `${url}${queryString}${hash}`;
15014
+ };
15015
+ });
14306
15016
 
14307
15017
  var IkasProductList = /** @class */ (function () {
14308
- function IkasProductList(data) {
15018
+ function IkasProductList(data, router) {
14309
15019
  var _this = this;
15020
+ this.filters = null;
14310
15021
  this._initialized = false;
14311
15022
  this._minPage = null;
14312
- // Used for ProducListType.ALL
14313
- this._filters = null;
14314
- // Used for recommending products for a specific product
15023
+ this._filterBrandId = null;
15024
+ this._filterCategoryId = null;
14315
15025
  this._recommendFor = null; // productId
14316
15026
  this._isLoading = false;
14317
- this.getInitial = function () { return __awaiter(_this, void 0, void 0, function () {
14318
- var page, limit, response_1, data_1, err_1;
14319
- var _this = this;
14320
- var _a, _b, _c;
14321
- return __generator(this, function (_d) {
14322
- switch (_d.label) {
15027
+ this._fetchRequestTime = 0;
15028
+ this.router = null;
15029
+ this.applyFilters = function () { return __awaiter(_this, void 0, void 0, function () {
15030
+ var _a, _b;
15031
+ return __generator(this, function (_c) {
15032
+ switch (_c.label) {
15033
+ case 0: return [4 /*yield*/, this.getInitial()];
15034
+ case 1:
15035
+ _c.sent();
15036
+ // Change url params
15037
+ if (this.isBrowser()) {
15038
+ if (this.isFiltered) {
15039
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.replace(location.pathname + "?" + this.filterQueryParams, undefined, { shallow: true });
15040
+ }
15041
+ else {
15042
+ (_b = this.router) === null || _b === void 0 ? void 0 : _b.replace("" + location.pathname, undefined, {
15043
+ shallow: true,
15044
+ });
15045
+ }
15046
+ }
15047
+ return [2 /*return*/];
15048
+ }
15049
+ });
15050
+ }); };
15051
+ this.getInitial = function (queryParams) { return __awaiter(_this, void 0, void 0, function () {
15052
+ var fetchRequestTime, page, limit, response_1, data, err_1;
15053
+ return __generator(this, function (_a) {
15054
+ switch (_a.label) {
14323
15055
  case 0:
14324
- if (this._isLoading)
14325
- return [2 /*return*/];
14326
15056
  this._isLoading = true;
14327
- _d.label = 1;
15057
+ fetchRequestTime = Date.now();
15058
+ this._fetchRequestTime = fetchRequestTime;
15059
+ _a.label = 1;
14328
15060
  case 1:
14329
- _d.trys.push([1, 3, 4, 5]);
14330
- page = this._page;
15061
+ _a.trys.push([1, 5, 6, 7]);
15062
+ page = 1;
14331
15063
  limit = this._limit;
15064
+ if (!(this.isFilterable && !this.filters)) return [3 /*break*/, 3];
15065
+ return [4 /*yield*/, this.getFilters()];
15066
+ case 2:
15067
+ _a.sent();
15068
+ _a.label = 3;
15069
+ case 3:
15070
+ this.applyQueryParamFilters(queryParams);
14332
15071
  if (this.isStatic) {
14333
15072
  page = undefined;
14334
15073
  limit = undefined;
14335
15074
  }
14336
15075
  else if (this.isDiscounted) {
14337
- // TODO use filter
14338
15076
  page = 1;
14339
15077
  limit = 10;
14340
15078
  }
14341
15079
  else if (this.isRecommended) {
14342
- // TODO use filter
14343
15080
  page = 1;
14344
15081
  limit = 10;
14345
15082
  }
14346
- return [4 /*yield*/, IkasProductAPI.listProducts({
14347
- idList: this.isStatic
14348
- ? (_a = this._productListPropValue.productIds) === null || _a === void 0 ? void 0 : _a.map(function (p) { return p.productId; }) : undefined,
14349
- page: page,
14350
- limit: limit,
14351
- brandId: ((_b = this._filters) === null || _b === void 0 ? void 0 : _b.brand) ? this._filters.brand : undefined,
14352
- categoryIds: ((_c = this._filters) === null || _c === void 0 ? void 0 : _c.category) ? [this._filters.category]
14353
- : undefined,
14354
- })];
14355
- case 2:
14356
- response_1 = _d.sent();
14357
- data_1 = [];
15083
+ return [4 /*yield*/, this.searchProducts(page || 1, limit || 10)];
15084
+ case 4:
15085
+ response_1 = _a.sent();
15086
+ if (!response_1 || this._fetchRequestTime !== fetchRequestTime)
15087
+ return [2 /*return*/];
15088
+ data = [];
14358
15089
  if (this.isStatic) {
14359
- data_1 = this._productListPropValue.productIds.map(function (pID) {
14360
- var product = response_1.products.find(function (p) { return p.id === pID.productId; });
15090
+ data = this._productListPropValue.productIds.map(function (pID) {
15091
+ var product = response_1.data.find(function (p) { return p.id === pID.productId; });
14361
15092
  var variant = product === null || product === void 0 ? void 0 : product.variants.find(function (v) { return v.id === pID.variantId; });
14362
15093
  return new IkasProductDetail(product, variant.variantValues);
14363
15094
  });
14364
15095
  }
14365
15096
  else {
14366
- data_1 = response_1.products.map(function (product, index) {
15097
+ data = response_1.data.map(function (product) {
14367
15098
  return new IkasProductDetail(product, product.variants[0].variantValues);
14368
15099
  });
14369
15100
  }
14370
- runInAction(function () {
14371
- _this.data = data_1;
14372
- _this._count = response_1.count;
14373
- _this._initialized = true;
14374
- _this._minPage = _this.page;
14375
- });
14376
- return [3 /*break*/, 5];
14377
- case 3:
14378
- err_1 = _d.sent();
15101
+ this.data = data;
15102
+ this._count = response_1.count;
15103
+ this._initialized = true;
15104
+ this._page = page || 1;
15105
+ this._minPage = this.page;
15106
+ return [3 /*break*/, 7];
15107
+ case 5:
15108
+ err_1 = _a.sent();
14379
15109
  console.log(err_1);
14380
- return [3 /*break*/, 5];
14381
- case 4:
14382
- runInAction(function () {
14383
- _this._isLoading = false;
14384
- });
15110
+ return [3 /*break*/, 7];
15111
+ case 6:
15112
+ if (fetchRequestTime === this._fetchRequestTime)
15113
+ this._isLoading = false;
14385
15114
  return [7 /*endfinally*/];
14386
- case 5: return [2 /*return*/];
15115
+ case 7: return [2 /*return*/];
14387
15116
  }
14388
15117
  });
14389
15118
  }); };
14390
15119
  this.getPrev = function () { return __awaiter(_this, void 0, void 0, function () {
14391
- var minPage_1, response_2, data_2, err_2;
14392
- var _this = this;
14393
- var _a, _b, _c;
14394
- return __generator(this, function (_d) {
14395
- switch (_d.label) {
15120
+ var minPage, response, data, err_2;
15121
+ return __generator(this, function (_a) {
15122
+ switch (_a.label) {
14396
15123
  case 0:
14397
15124
  if (this.isStatic ||
14398
15125
  this.isDiscounted ||
@@ -14401,49 +15128,37 @@ var IkasProductList = /** @class */ (function () {
14401
15128
  !this.hasPrev)
14402
15129
  return [2 /*return*/];
14403
15130
  this._isLoading = true;
14404
- _d.label = 1;
15131
+ _a.label = 1;
14405
15132
  case 1:
14406
- _d.trys.push([1, 3, 4, 5]);
14407
- minPage_1 = this._minPage - 1;
14408
- return [4 /*yield*/, IkasProductAPI.listProducts({
14409
- idList: this.isStatic
14410
- ? (_a = this._productListPropValue.productIds) === null || _a === void 0 ? void 0 : _a.map(function (p) { return p.productId; }) : undefined,
14411
- page: minPage_1,
14412
- limit: this._limit,
14413
- brandId: ((_b = this._filters) === null || _b === void 0 ? void 0 : _b.brand) ? this._filters.brand : undefined,
14414
- categoryIds: ((_c = this._filters) === null || _c === void 0 ? void 0 : _c.category) ? [this._filters.category]
14415
- : undefined,
14416
- })];
15133
+ _a.trys.push([1, 3, 4, 5]);
15134
+ minPage = this._minPage - 1;
15135
+ return [4 /*yield*/, this.searchProducts(minPage, this.limit)];
14417
15136
  case 2:
14418
- response_2 = _d.sent();
14419
- data_2 = response_2.products.map(function (product) {
15137
+ response = _a.sent();
15138
+ if (!response)
15139
+ return [2 /*return*/];
15140
+ data = response.data.map(function (product) {
14420
15141
  return new IkasProductDetail(product, product.variants[0].variantValues);
14421
15142
  });
14422
- runInAction(function () {
14423
- _this.data = data_2.concat(_this.data);
14424
- _this._count = response_2.count;
14425
- _this._minPage = minPage_1;
14426
- });
15143
+ this.data = data.concat(this.data);
15144
+ this._count = response.count;
15145
+ this._minPage = minPage;
14427
15146
  return [3 /*break*/, 5];
14428
15147
  case 3:
14429
- err_2 = _d.sent();
15148
+ err_2 = _a.sent();
14430
15149
  console.log(err_2);
14431
15150
  return [3 /*break*/, 5];
14432
15151
  case 4:
14433
- runInAction(function () {
14434
- _this._isLoading = false;
14435
- });
15152
+ this._isLoading = false;
14436
15153
  return [7 /*endfinally*/];
14437
15154
  case 5: return [2 /*return*/];
14438
15155
  }
14439
15156
  });
14440
15157
  }); };
14441
15158
  this.getNext = function () { return __awaiter(_this, void 0, void 0, function () {
14442
- var response_3, data_3, err_3;
14443
- var _this = this;
14444
- var _a, _b;
14445
- return __generator(this, function (_c) {
14446
- switch (_c.label) {
15159
+ var response, data, err_3;
15160
+ return __generator(this, function (_a) {
15161
+ switch (_a.label) {
14447
15162
  case 0:
14448
15163
  if (this.isStatic ||
14449
15164
  this.isDiscounted ||
@@ -14452,46 +15167,36 @@ var IkasProductList = /** @class */ (function () {
14452
15167
  !this.hasNext)
14453
15168
  return [2 /*return*/];
14454
15169
  this._isLoading = true;
14455
- _c.label = 1;
15170
+ _a.label = 1;
14456
15171
  case 1:
14457
- _c.trys.push([1, 3, 4, 5]);
14458
- return [4 /*yield*/, IkasProductAPI.listProducts({
14459
- page: this.page + 1,
14460
- limit: this.limit,
14461
- brandId: ((_a = this._filters) === null || _a === void 0 ? void 0 : _a.brand) ? this._filters.brand : undefined,
14462
- categoryIds: ((_b = this._filters) === null || _b === void 0 ? void 0 : _b.category) ? [this._filters.category]
14463
- : undefined,
14464
- })];
15172
+ _a.trys.push([1, 3, 4, 5]);
15173
+ return [4 /*yield*/, this.searchProducts(this.page + 1, this.limit)];
14465
15174
  case 2:
14466
- response_3 = _c.sent();
14467
- data_3 = response_3.products.map(function (product) {
15175
+ response = _a.sent();
15176
+ if (!response)
15177
+ return [2 /*return*/];
15178
+ data = response.data.map(function (product) {
14468
15179
  return new IkasProductDetail(product, product.variants[0].variantValues);
14469
15180
  });
14470
- runInAction(function () {
14471
- _this.data = _this.data.concat(data_3);
14472
- _this._count = response_3.count;
14473
- _this._page = _this.page + 1;
14474
- });
15181
+ this.data = this.data.concat(data);
15182
+ this._count = response.count;
15183
+ this._page = this.page + 1;
14475
15184
  return [3 /*break*/, 5];
14476
15185
  case 3:
14477
- err_3 = _c.sent();
15186
+ err_3 = _a.sent();
14478
15187
  console.log(err_3);
14479
15188
  return [3 /*break*/, 5];
14480
15189
  case 4:
14481
- runInAction(function () {
14482
- _this._isLoading = false;
14483
- });
15190
+ this._isLoading = false;
14484
15191
  return [7 /*endfinally*/];
14485
15192
  case 5: return [2 /*return*/];
14486
15193
  }
14487
15194
  });
14488
15195
  }); };
14489
15196
  this.getPage = function (page) { return __awaiter(_this, void 0, void 0, function () {
14490
- var response_4, data_4, err_4;
14491
- var _this = this;
14492
- var _a, _b;
14493
- return __generator(this, function (_c) {
14494
- switch (_c.label) {
15197
+ var response, data, err_4;
15198
+ return __generator(this, function (_a) {
15199
+ switch (_a.label) {
14495
15200
  case 0:
14496
15201
  if (this._isLoading ||
14497
15202
  this.isStatic ||
@@ -14499,36 +15204,28 @@ var IkasProductList = /** @class */ (function () {
14499
15204
  this.isRecommended)
14500
15205
  return [2 /*return*/];
14501
15206
  this._isLoading = true;
14502
- _c.label = 1;
15207
+ _a.label = 1;
14503
15208
  case 1:
14504
- _c.trys.push([1, 3, 4, 5]);
14505
- return [4 /*yield*/, IkasProductAPI.listProducts({
14506
- page: this.page + 1,
14507
- limit: this.limit,
14508
- brandId: ((_a = this._filters) === null || _a === void 0 ? void 0 : _a.brand) ? this._filters.brand : undefined,
14509
- categoryIds: ((_b = this._filters) === null || _b === void 0 ? void 0 : _b.category) ? [this._filters.category]
14510
- : undefined,
14511
- })];
15209
+ _a.trys.push([1, 3, 4, 5]);
15210
+ return [4 /*yield*/, this.searchProducts(page, this.limit)];
14512
15211
  case 2:
14513
- response_4 = _c.sent();
14514
- data_4 = response_4.products.map(function (product) {
15212
+ response = _a.sent();
15213
+ if (!response)
15214
+ return [2 /*return*/];
15215
+ data = response.data.map(function (product) {
14515
15216
  return new IkasProductDetail(product, product.variants[0].variantValues);
14516
15217
  });
14517
- runInAction(function () {
14518
- _this.data = data_4;
14519
- _this._count = response_4.count;
14520
- _this._page = page;
14521
- _this._minPage = page;
14522
- });
15218
+ this.data = data;
15219
+ this._count = response.count;
15220
+ this._page = page;
15221
+ this._minPage = page;
14523
15222
  return [3 /*break*/, 5];
14524
15223
  case 3:
14525
- err_4 = _c.sent();
15224
+ err_4 = _a.sent();
14526
15225
  console.log(err_4);
14527
15226
  return [3 /*break*/, 5];
14528
15227
  case 4:
14529
- runInAction(function () {
14530
- _this._isLoading = false;
14531
- });
15228
+ this._isLoading = false;
14532
15229
  return [7 /*endfinally*/];
14533
15230
  case 5: return [2 /*return*/];
14534
15231
  }
@@ -14548,12 +15245,21 @@ var IkasProductList = /** @class */ (function () {
14548
15245
  this._limit = data.limit || data.productListPropValue.initialLimit || 20;
14549
15246
  this._page = data.page || 1;
14550
15247
  this._count = data.count || 0;
15248
+ this._searchKeyword = data.searchKeyword || "";
14551
15249
  this._productListPropValue = data.productListPropValue;
14552
- this._filters = data.filters
14553
- ? new IkasProductListFilter(data.filters)
14554
- : undefined;
15250
+ this._filterBrandId = data.filterBrandId || null;
15251
+ this._filterCategoryId = data.filterCategoryId || null;
14555
15252
  this._recommendFor = data.recommendFor;
15253
+ this.filters = data.filters
15254
+ ? data.filters.map(function (f) { return new IkasProductFilter(f); })
15255
+ : null;
15256
+ this.router = router;
14556
15257
  makeAutoObservable(this);
15258
+ console.log("constructor");
15259
+ if (this.isBrowser() && location.search) {
15260
+ var queryParams = this.getQueryParams();
15261
+ this.getInitial(queryParams);
15262
+ }
14557
15263
  }
14558
15264
  Object.defineProperty(IkasProductList.prototype, "sort", {
14559
15265
  get: function () {
@@ -14583,6 +15289,16 @@ var IkasProductList = /** @class */ (function () {
14583
15289
  enumerable: false,
14584
15290
  configurable: true
14585
15291
  });
15292
+ Object.defineProperty(IkasProductList.prototype, "searchKeyword", {
15293
+ get: function () {
15294
+ return this._searchKeyword;
15295
+ },
15296
+ set: function (value) {
15297
+ this._searchKeyword = value;
15298
+ },
15299
+ enumerable: false,
15300
+ configurable: true
15301
+ });
14586
15302
  Object.defineProperty(IkasProductList.prototype, "isInitialized", {
14587
15303
  get: function () {
14588
15304
  return this._initialized;
@@ -14590,6 +15306,22 @@ var IkasProductList = /** @class */ (function () {
14590
15306
  enumerable: false,
14591
15307
  configurable: true
14592
15308
  });
15309
+ Object.defineProperty(IkasProductList.prototype, "isFilterable", {
15310
+ get: function () {
15311
+ return (this._type === IkasProductListType.ALL ||
15312
+ this._type === IkasProductListType.CATEGORY);
15313
+ },
15314
+ enumerable: false,
15315
+ configurable: true
15316
+ });
15317
+ Object.defineProperty(IkasProductList.prototype, "isFiltered", {
15318
+ get: function () {
15319
+ var _a;
15320
+ return (_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; });
15321
+ },
15322
+ enumerable: false,
15323
+ configurable: true
15324
+ });
14593
15325
  Object.defineProperty(IkasProductList.prototype, "isStatic", {
14594
15326
  get: function () {
14595
15327
  return this._type === IkasProductListType.STATIC;
@@ -14639,8 +15371,111 @@ var IkasProductList = /** @class */ (function () {
14639
15371
  enumerable: false,
14640
15372
  configurable: true
14641
15373
  });
14642
- IkasProductList.prototype.applyFilters = function () {
14643
- return;
15374
+ Object.defineProperty(IkasProductList.prototype, "filterQueryParams", {
15375
+ get: function () {
15376
+ var _a;
15377
+ var queryParams = {};
15378
+ (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
15379
+ queryParams[f.key] = f.keyList;
15380
+ });
15381
+ return queryString.stringify(queryParams, { arrayFormat: "comma" });
15382
+ },
15383
+ enumerable: false,
15384
+ configurable: true
15385
+ });
15386
+ IkasProductList.prototype.searchProducts = function (page, limit) {
15387
+ var _a, _b;
15388
+ return __awaiter(this, void 0, void 0, function () {
15389
+ var filterList;
15390
+ return __generator(this, function (_c) {
15391
+ switch (_c.label) {
15392
+ case 0:
15393
+ filterList = [];
15394
+ if (this._filterBrandId) {
15395
+ filterList.push(new IkasProductFilterValue({
15396
+ id: this._filterBrandId,
15397
+ type: IkasProductFilterType.BRAND,
15398
+ valueList: [this._filterBrandId],
15399
+ }));
15400
+ }
15401
+ (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) {
15402
+ if (filter.valueList.length) {
15403
+ filterList.push(new IkasProductFilterValue({
15404
+ id: filter.id,
15405
+ type: filter.type,
15406
+ valueList: filter.valueList,
15407
+ }));
15408
+ }
15409
+ });
15410
+ return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
15411
+ page: page,
15412
+ perPage: limit,
15413
+ productIdList: this.isStatic
15414
+ ? (_b = this._productListPropValue.productIds) === null || _b === void 0 ? void 0 : _b.map(function (p) { return p.productId; }) : undefined,
15415
+ filterList: filterList,
15416
+ categoryIdList: this._filterCategoryId
15417
+ ? [this._filterCategoryId]
15418
+ : undefined,
15419
+ query: this._searchKeyword,
15420
+ })];
15421
+ case 1: return [2 /*return*/, _c.sent()];
15422
+ }
15423
+ });
15424
+ });
15425
+ };
15426
+ IkasProductList.prototype.clear = function () {
15427
+ var _a;
15428
+ (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
15429
+ this._searchKeyword = "";
15430
+ };
15431
+ IkasProductList.prototype.getFilters = function () {
15432
+ return __awaiter(this, void 0, void 0, function () {
15433
+ var _a;
15434
+ return __generator(this, function (_b) {
15435
+ switch (_b.label) {
15436
+ case 0:
15437
+ _a = this;
15438
+ return [4 /*yield*/, IkasProductSearchAPI.getProductFilterData()];
15439
+ case 1:
15440
+ _a.filters = _b.sent();
15441
+ // this._filterCategoryId ? [this._filterCategoryId] : undefined
15442
+ if (this.filters)
15443
+ this.filters.sort(function (f1, f2) { return (f1.order > f2.order ? 1 : -1); });
15444
+ return [2 /*return*/];
15445
+ }
15446
+ });
15447
+ });
15448
+ };
15449
+ IkasProductList.prototype.applyQueryParamFilters = function (queryParams) {
15450
+ var _this = this;
15451
+ try {
15452
+ queryParams === null || queryParams === void 0 ? void 0 : queryParams.forEach(function (value, key) {
15453
+ var _a, _b, _c;
15454
+ var filter = (_a = _this.filters) === null || _a === void 0 ? void 0 : _a.find(function (f) { return f.key === key; });
15455
+ var valueKeys = value.split(",");
15456
+ if (filter) {
15457
+ if (filter.displayType === IkasProductFilterDisplayType.NUMBER_RANGE) {
15458
+ filter.numberRange = new RangeValue(parseRangeStr(value));
15459
+ }
15460
+ else if (filter.displayType ===
15461
+ IkasProductFilterDisplayType.NUMBER_RANGE_LIST) {
15462
+ (_b = filter.numberRangeListOptions) === null || _b === void 0 ? void 0 : _b.forEach(function (o) {
15463
+ if (valueKeys.includes(o.key))
15464
+ o.isSelected = true;
15465
+ });
15466
+ }
15467
+ else {
15468
+ (_c = filter.values) === null || _c === void 0 ? void 0 : _c.forEach(function (filterValue) {
15469
+ if (valueKeys.includes(filterValue.key))
15470
+ filterValue.isSelected = true;
15471
+ });
15472
+ }
15473
+ }
15474
+ });
15475
+ }
15476
+ catch (err) {
15477
+ console.log(err);
15478
+ }
14644
15479
  };
14645
15480
  IkasProductList.prototype.toJSON = function () {
14646
15481
  return {
@@ -14650,13 +15485,24 @@ var IkasProductList = /** @class */ (function () {
14650
15485
  limit: this._limit,
14651
15486
  page: this._page,
14652
15487
  count: this._count,
15488
+ searchKeyword: this._searchKeyword,
14653
15489
  initialized: this._initialized,
14654
15490
  minPage: this._minPage,
14655
- filters: this._filters,
15491
+ pageBrandId: this._filterBrandId,
15492
+ pageCategoryId: this._filterCategoryId,
15493
+ filters: this.filters,
14656
15494
  recommendFor: this._recommendFor,
14657
15495
  productListPropValue: this._productListPropValue,
14658
15496
  };
14659
15497
  };
15498
+ IkasProductList.prototype.getQueryParams = function () {
15499
+ if (!this.isBrowser())
15500
+ return;
15501
+ return new URLSearchParams(location.search);
15502
+ };
15503
+ IkasProductList.prototype.isBrowser = function () {
15504
+ return typeof window !== "undefined";
15505
+ };
14660
15506
  return IkasProductList;
14661
15507
  }());
14662
15508
  var IkasProductListType;
@@ -19454,6 +20300,8 @@ var AddressForm = /** @class */ (function () {
19454
20300
  this.store = props.store;
19455
20301
  this.validator = new Validator(this.address, this.validatorRules());
19456
20302
  this.listCountries();
20303
+ if (this.address.state)
20304
+ this.listStates();
19457
20305
  if (this.address.country)
19458
20306
  this.listCities();
19459
20307
  if (this.address.city)
@@ -21908,7 +22756,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
21908
22756
  id: vv.id,
21909
22757
  name: vv.name,
21910
22758
  colorCode: vv.colorCode,
21911
- thumbnilImageId: vv.thumbnailImageId,
22759
+ thumbnailImageId: vv.thumbnailImageId,
21912
22760
  variantTypeId: vt.id,
21913
22761
  });
21914
22762
  }),
@@ -22166,6 +23014,220 @@ var IkasProductAPI = /** @class */ (function () {
22166
23014
  }());
22167
23015
  var templateObject_1$d;
22168
23016
 
23017
+ var IkasProductSearchAPI = /** @class */ (function () {
23018
+ function IkasProductSearchAPI() {
23019
+ }
23020
+ IkasProductSearchAPI.searchProducts = function (input) {
23021
+ return __awaiter(this, void 0, void 0, function () {
23022
+ var SEARCH_PRODUCTS, _a, data, errors, err_1;
23023
+ return __generator(this, function (_b) {
23024
+ switch (_b.label) {
23025
+ case 0:
23026
+ _b.trys.push([0, 2, , 3]);
23027
+ SEARCH_PRODUCTS = src(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\n query searchProducts($input: SearchInput!) {\n searchProducts(input: $input) {\n count\n data\n facets {\n id\n values {\n count\n id\n }\n }\n limit\n page\n totalCount\n }\n }\n "], ["\n query searchProducts($input: SearchInput!) {\n searchProducts(input: $input) {\n count\n data\n facets {\n id\n values {\n count\n id\n }\n }\n limit\n page\n totalCount\n }\n }\n "])));
23028
+ return [4 /*yield*/, apollo
23029
+ .getClient()
23030
+ .query({
23031
+ query: SEARCH_PRODUCTS,
23032
+ variables: {
23033
+ input: input,
23034
+ },
23035
+ })];
23036
+ case 1:
23037
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
23038
+ if (errors && errors.length) {
23039
+ console.log(errors);
23040
+ return [2 /*return*/];
23041
+ }
23042
+ return [2 /*return*/, __assign(__assign({}, data.searchProducts), { data: data.searchProducts.data.map(function (d) {
23043
+ return simpleToProduct(d);
23044
+ }) })];
23045
+ case 2:
23046
+ err_1 = _b.sent();
23047
+ console.log(err_1);
23048
+ return [3 /*break*/, 3];
23049
+ case 3: return [2 /*return*/];
23050
+ }
23051
+ });
23052
+ });
23053
+ };
23054
+ IkasProductSearchAPI.getProductFilterData = function (categoryIds) {
23055
+ return __awaiter(this, void 0, void 0, function () {
23056
+ var QUERY, _a, data, errors, err_2;
23057
+ return __generator(this, function (_b) {
23058
+ switch (_b.label) {
23059
+ case 0:
23060
+ _b.trys.push([0, 2, , 3]);
23061
+ QUERY = src(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n query getProductFilterData($categoryIds: [String!]) {\n getProductFilterData(categoryIds: $categoryIds) {\n customValues\n displayType\n id\n isMultiSelect\n key\n name\n order\n type\n values {\n colorCode\n id\n key\n name\n thumbnailImageId\n }\n }\n }\n "], ["\n query getProductFilterData($categoryIds: [String!]) {\n getProductFilterData(categoryIds: $categoryIds) {\n customValues\n displayType\n id\n isMultiSelect\n key\n name\n order\n type\n values {\n colorCode\n id\n key\n name\n thumbnailImageId\n }\n }\n }\n "])));
23062
+ return [4 /*yield*/, apollo
23063
+ .getClient()
23064
+ .query({
23065
+ query: QUERY,
23066
+ variables: {
23067
+ categoryIds: categoryIds || null,
23068
+ },
23069
+ })];
23070
+ case 1:
23071
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
23072
+ if (errors && errors.length) {
23073
+ console.log(errors);
23074
+ return [2 /*return*/];
23075
+ }
23076
+ return [2 /*return*/, data.getProductFilterData.map(function (d) {
23077
+ var _a;
23078
+ return new IkasProductFilter(__assign(__assign({}, d), { displayType: d.displayType, type: d.type, values: (_a = d.values) === null || _a === void 0 ? void 0 : _a.map(function (v) { return new IkasApplicableProductFilterValue(v); }) }));
23079
+ })];
23080
+ case 2:
23081
+ err_2 = _b.sent();
23082
+ console.log(err_2);
23083
+ return [3 /*break*/, 3];
23084
+ case 3: return [2 /*return*/];
23085
+ }
23086
+ });
23087
+ });
23088
+ };
23089
+ return IkasProductSearchAPI;
23090
+ }());
23091
+ function simpleToProduct(simple) {
23092
+ var _a, _b, _c, _d, _e;
23093
+ return new IkasProduct({
23094
+ id: simple.id,
23095
+ attributes: (_a = simple.attributes) === null || _a === void 0 ? void 0 : _a.map(function (a) {
23096
+ var _a, _b, _c, _d, _e;
23097
+ return new IkasProductAttributeValue({
23098
+ value: a.value,
23099
+ productAttributeId: (_a = a.productAttribute) === null || _a === void 0 ? void 0 : _a.id,
23100
+ productAttributeOptionId: (_b = a.productAttributeOption) === null || _b === void 0 ? void 0 : _b.id,
23101
+ productAttribute: new IkasProductAttribute({
23102
+ id: (_c = a.productAttribute) === null || _c === void 0 ? void 0 : _c.id,
23103
+ name: (_d = a.productAttribute) === null || _d === void 0 ? void 0 : _d.name,
23104
+ type: (_e = a.productAttribute) === null || _e === void 0 ? void 0 : _e.type,
23105
+ }),
23106
+ productAttributeOption: a.productAttributeOption,
23107
+ });
23108
+ }),
23109
+ brand: new IkasBrand({
23110
+ id: (_b = simple.brand) === null || _b === void 0 ? void 0 : _b.id,
23111
+ name: (_c = simple.brand) === null || _c === void 0 ? void 0 : _c.name,
23112
+ metaData: new IkasHTMLMetaData({
23113
+ slug: ((_d = simple.brand) === null || _d === void 0 ? void 0 : _d.slug) || "",
23114
+ }),
23115
+ }),
23116
+ categories: (_e = simple.categories) === null || _e === void 0 ? void 0 : _e.map(function (c) {
23117
+ return new IkasCategory({
23118
+ id: c.id,
23119
+ name: c.name,
23120
+ path: c.path,
23121
+ metaData: new IkasHTMLMetaData({
23122
+ slug: c.slug || "",
23123
+ }),
23124
+ });
23125
+ }),
23126
+ description: simple.description || undefined,
23127
+ metaData: new IkasHTMLMetaData(simple.metaData || undefined),
23128
+ name: simple.name,
23129
+ shortDescription: simple.shortDescription || undefined,
23130
+ taxValue: simple.taxValue || undefined,
23131
+ type: simple.type || undefined,
23132
+ variantTypes: simple.productVariantTypes.map(function (pvt) {
23133
+ return new IkasProductVariantType({
23134
+ variantType: new IkasVariantType({
23135
+ id: pvt.variantType.id,
23136
+ name: pvt.variantType.name,
23137
+ selectionType: pvt.variantType.selectionType,
23138
+ values: pvt.variantType.values
23139
+ .map(function (v) {
23140
+ return new IkasVariantValue({
23141
+ id: v.id,
23142
+ colorCode: v.colorCode,
23143
+ name: v.name,
23144
+ thumbnailImageId: v.thumbnailImageId,
23145
+ variantTypeId: pvt.variantType.id,
23146
+ });
23147
+ })
23148
+ .filter(function (v) { return pvt.variantValueIds.includes(v.id); }),
23149
+ }),
23150
+ variantValueIds: pvt.variantValueIds,
23151
+ });
23152
+ }),
23153
+ variants: simple.variants.map(function (v) {
23154
+ var _a, _b, _c, _d;
23155
+ return new IkasProductVariant({
23156
+ id: v.id,
23157
+ attributes: (_a = v.attributes) === null || _a === void 0 ? void 0 : _a.map(function (a) {
23158
+ var _a, _b, _c, _d, _e;
23159
+ return new IkasProductAttributeValue({
23160
+ value: a.value,
23161
+ productAttributeId: (_a = a.productAttribute) === null || _a === void 0 ? void 0 : _a.id,
23162
+ productAttributeOptionId: (_b = a.productAttributeOption) === null || _b === void 0 ? void 0 : _b.id,
23163
+ productAttribute: new IkasProductAttribute({
23164
+ id: (_c = a.productAttribute) === null || _c === void 0 ? void 0 : _c.id,
23165
+ name: (_d = a.productAttribute) === null || _d === void 0 ? void 0 : _d.name,
23166
+ type: (_e = a.productAttribute) === null || _e === void 0 ? void 0 : _e.type,
23167
+ }),
23168
+ productAttributeOption: a.productAttributeOption,
23169
+ });
23170
+ }),
23171
+ sku: v.sku,
23172
+ barcodeList: v.barcodeList || undefined,
23173
+ images: (_b = v.images) === null || _b === void 0 ? void 0 : _b.map(function (i) { return new IkasImage(i.id); }),
23174
+ price: new IkasProductPrice((_c = v.prices) === null || _c === void 0 ? void 0 : _c.find(function (p) { return p.priceListId === null; })),
23175
+ stock: v.stocks.length ? v.stocks[0].stockCount : 0,
23176
+ variantValues: (_d = v.variantValues) === null || _d === void 0 ? void 0 : _d.map(function (vv) {
23177
+ var _a;
23178
+ var variantValue = (_a = simple.productVariantTypes
23179
+ .find(function (pvt) { return pvt.variantType.id === vv.variantTypeId; })) === null || _a === void 0 ? void 0 : _a.variantType.values.find(function (_vv) { return _vv.id === vv.variantValueId; });
23180
+ return new IkasVariantValue({
23181
+ id: vv.variantValueId,
23182
+ name: variantValue === null || variantValue === void 0 ? void 0 : variantValue.name,
23183
+ colorCode: variantValue === null || variantValue === void 0 ? void 0 : variantValue.colorCode,
23184
+ thumbnailImageId: variantValue === null || variantValue === void 0 ? void 0 : variantValue.thumbnailImageId,
23185
+ });
23186
+ }),
23187
+ });
23188
+ }),
23189
+ });
23190
+ }
23191
+ var templateObject_1$e, templateObject_2$4;
23192
+ // type SearchInput = {
23193
+ // categoryIdList: string[] | null;
23194
+ // filterList: SearchInputFilter[] | null;
23195
+ // order: SearchInputOrder[] | null;
23196
+ // page: number | null;
23197
+ // perPage: number | null;
23198
+ // priceListId: string | null;
23199
+ // productId: string | null;
23200
+ // query: string | null;
23201
+ // slug: string | null;
23202
+ // };
23203
+ // type SearchInputFilter = {
23204
+ // id: string;
23205
+ // type: ProductFilterType;
23206
+ // valueList: string[];
23207
+ // };
23208
+ // export type SearchInputOrder = {
23209
+ // direction: SortByDirection;
23210
+ // type: SortByType;
23211
+ // };
23212
+ // enum SortByDirection {
23213
+ // ASC = "ASC",
23214
+ // DESC = "DESC",
23215
+ // }
23216
+ // enum SortByType {
23217
+ // CREATED_AT = "CREATED_AT",
23218
+ // DISCOUNT_RATIO = "DISCOUNT_RATIO",
23219
+ // PRICE = "PRICE",
23220
+ // }
23221
+ // export enum ProductFilterType {
23222
+ // ATTRIBUTE = "ATTRIBUTE",
23223
+ // BRAND = "BRAND",
23224
+ // DISCOUNT_RATIO = "DISCOUNT_RATIO",
23225
+ // PRICE = "PRICE",
23226
+ // STOCK_STATUS = "STOCK_STATUS",
23227
+ // TAG = "TAG",
23228
+ // VARIANT_TYPE = "VARIANT_TYPE",
23229
+ // }
23230
+
22169
23231
  var IkasProductAttributeAPI = /** @class */ (function () {
22170
23232
  function IkasProductAttributeAPI() {
22171
23233
  }
@@ -22175,7 +23237,7 @@ var IkasProductAttributeAPI = /** @class */ (function () {
22175
23237
  return __generator(this, function (_b) {
22176
23238
  switch (_b.label) {
22177
23239
  case 0:
22178
- LIST_PRODUCT_ATTRIBUTES = src(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\n query listProductAttribute($id: StringFilterInput!) {\n listProductAttribute(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n description\n type\n options {\n id\n createdAt\n updatedAt\n deleted\n name\n }\n }\n }\n "], ["\n query listProductAttribute($id: StringFilterInput!) {\n listProductAttribute(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n description\n type\n options {\n id\n createdAt\n updatedAt\n deleted\n name\n }\n }\n }\n "])));
23240
+ LIST_PRODUCT_ATTRIBUTES = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query listProductAttribute($id: StringFilterInput!) {\n listProductAttribute(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n description\n type\n options {\n id\n createdAt\n updatedAt\n deleted\n name\n }\n }\n }\n "], ["\n query listProductAttribute($id: StringFilterInput!) {\n listProductAttribute(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n description\n type\n options {\n id\n createdAt\n updatedAt\n deleted\n name\n }\n }\n }\n "])));
22179
23241
  _b.label = 1;
22180
23242
  case 1:
22181
23243
  _b.trys.push([1, 3, , 4]);
@@ -22208,7 +23270,103 @@ var IkasProductAttributeAPI = /** @class */ (function () {
22208
23270
  };
22209
23271
  return IkasProductAttributeAPI;
22210
23272
  }());
22211
- var templateObject_1$e;
23273
+ var templateObject_1$f;
23274
+
23275
+ var IkasFavoriteProductAPI = /** @class */ (function () {
23276
+ function IkasFavoriteProductAPI() {
23277
+ }
23278
+ IkasFavoriteProductAPI.listFavoriteProducts = function () {
23279
+ return __awaiter(this, void 0, void 0, function () {
23280
+ var LIST_FAVORITE_PRODUCTS, _a, data, errors, err_1;
23281
+ return __generator(this, function (_b) {
23282
+ switch (_b.label) {
23283
+ case 0:
23284
+ LIST_FAVORITE_PRODUCTS = src(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n query listFavoriteProducts {\n listFavoriteProducts {\n id\n createdAt\n updatedAt\n deleted\n productId\n customerId\n }\n }\n "], ["\n query listFavoriteProducts {\n listFavoriteProducts {\n id\n createdAt\n updatedAt\n deleted\n productId\n customerId\n }\n }\n "])));
23285
+ _b.label = 1;
23286
+ case 1:
23287
+ _b.trys.push([1, 3, , 4]);
23288
+ return [4 /*yield*/, apollo
23289
+ .getClient()
23290
+ .query({
23291
+ query: LIST_FAVORITE_PRODUCTS,
23292
+ })];
23293
+ case 2:
23294
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
23295
+ if (errors && errors.length)
23296
+ return [2 /*return*/, []];
23297
+ return [2 /*return*/, data.listFavoriteProducts.map(function (fP) { return new IkasFavoriteProduct(fP); })];
23298
+ case 3:
23299
+ err_1 = _b.sent();
23300
+ console.log(err_1);
23301
+ return [3 /*break*/, 4];
23302
+ case 4: return [2 /*return*/, []];
23303
+ }
23304
+ });
23305
+ });
23306
+ };
23307
+ IkasFavoriteProductAPI.isFavoriteProduct = function (productId) {
23308
+ return __awaiter(this, void 0, void 0, function () {
23309
+ var IS_FAVORITE_PRODUCT, _a, data, errors, err_2;
23310
+ return __generator(this, function (_b) {
23311
+ switch (_b.label) {
23312
+ case 0:
23313
+ IS_FAVORITE_PRODUCT = src(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n query isFavoriteProduct($productId: String!) {\n isFavoriteProduct(productId: $productId)\n }\n "], ["\n query isFavoriteProduct($productId: String!) {\n isFavoriteProduct(productId: $productId)\n }\n "])));
23314
+ _b.label = 1;
23315
+ case 1:
23316
+ _b.trys.push([1, 3, , 4]);
23317
+ return [4 /*yield*/, apollo
23318
+ .getClient()
23319
+ .query({
23320
+ query: IS_FAVORITE_PRODUCT,
23321
+ variables: { productId: productId },
23322
+ })];
23323
+ case 2:
23324
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
23325
+ if (errors && errors.length)
23326
+ return [2 /*return*/, false];
23327
+ return [2 /*return*/, data.isFavoriteProduct];
23328
+ case 3:
23329
+ err_2 = _b.sent();
23330
+ console.log(err_2);
23331
+ return [3 /*break*/, 4];
23332
+ case 4: return [2 /*return*/, false];
23333
+ }
23334
+ });
23335
+ });
23336
+ };
23337
+ IkasFavoriteProductAPI.saveFavoriteProduct = function (isFavorite, productId) {
23338
+ return __awaiter(this, void 0, void 0, function () {
23339
+ var SAVE_FAVORITE_PRODUCT, _a, data, errors, err_3;
23340
+ return __generator(this, function (_b) {
23341
+ switch (_b.label) {
23342
+ case 0:
23343
+ 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 "])));
23344
+ _b.label = 1;
23345
+ case 1:
23346
+ _b.trys.push([1, 3, , 4]);
23347
+ return [4 /*yield*/, apollo
23348
+ .getClient()
23349
+ .mutate({
23350
+ mutation: SAVE_FAVORITE_PRODUCT,
23351
+ variables: { isFavorite: isFavorite, productId: productId },
23352
+ })];
23353
+ case 2:
23354
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
23355
+ if (errors && errors.length)
23356
+ return [2 /*return*/, false];
23357
+ return [2 /*return*/, (data === null || data === void 0 ? void 0 : data.saveFavoriteProduct) || true];
23358
+ case 3:
23359
+ err_3 = _b.sent();
23360
+ console.log(err_3);
23361
+ return [3 /*break*/, 4];
23362
+ case 4: return [2 /*return*/, false];
23363
+ }
23364
+ });
23365
+ });
23366
+ };
23367
+ return IkasFavoriteProductAPI;
23368
+ }());
23369
+ var templateObject_1$g, templateObject_2$5, templateObject_3$2;
22212
23370
 
22213
23371
  var IkasStateAPI = /** @class */ (function () {
22214
23372
  function IkasStateAPI() {
@@ -22219,7 +23377,7 @@ var IkasStateAPI = /** @class */ (function () {
22219
23377
  return __generator(this, function (_b) {
22220
23378
  switch (_b.label) {
22221
23379
  case 0:
22222
- QUERY = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query listState($countryId: StringFilterInput!) {\n listState(countryId: $countryId) {\n id\n name\n stateCode\n }\n }\n "], ["\n query listState($countryId: StringFilterInput!) {\n listState(countryId: $countryId) {\n id\n name\n stateCode\n }\n }\n "])));
23380
+ QUERY = src(templateObject_1$h || (templateObject_1$h = __makeTemplateObject(["\n query listState($countryId: StringFilterInput!) {\n listState(countryId: $countryId) {\n id\n name\n stateCode\n }\n }\n "], ["\n query listState($countryId: StringFilterInput!) {\n listState(countryId: $countryId) {\n id\n name\n stateCode\n }\n }\n "])));
22223
23381
  _b.label = 1;
22224
23382
  case 1:
22225
23383
  _b.trys.push([1, 3, , 4]);
@@ -22256,7 +23414,7 @@ var IkasStateAPI = /** @class */ (function () {
22256
23414
  };
22257
23415
  return IkasStateAPI;
22258
23416
  }());
22259
- var templateObject_1$f;
23417
+ var templateObject_1$h;
22260
23418
 
22261
23419
  var IkasStorefrontDomain = /** @class */ (function () {
22262
23420
  function IkasStorefrontDomain(data) {
@@ -22349,7 +23507,7 @@ var IkasStorefrontAPI = /** @class */ (function () {
22349
23507
  return __generator(this, function (_b) {
22350
23508
  switch (_b.label) {
22351
23509
  case 0:
22352
- QUERY = src(templateObject_1$g || (templateObject_1$g = __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 "])));
23510
+ QUERY = src(templateObject_1$i || (templateObject_1$i = __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 "])));
22353
23511
  _b.label = 1;
22354
23512
  case 1:
22355
23513
  _b.trys.push([1, 3, , 4]);
@@ -22379,7 +23537,7 @@ var IkasStorefrontAPI = /** @class */ (function () {
22379
23537
  };
22380
23538
  return IkasStorefrontAPI;
22381
23539
  }());
22382
- var templateObject_1$g;
23540
+ var templateObject_1$i;
22383
23541
 
22384
23542
  var IkasThemeAPI = /** @class */ (function () {
22385
23543
  function IkasThemeAPI() {
@@ -22536,6 +23694,107 @@ var IkasCustomerStore = /** @class */ (function () {
22536
23694
  });
22537
23695
  });
22538
23696
  };
23697
+ this.getFavoriteProductsIds = function () { return __awaiter(_this, void 0, void 0, function () {
23698
+ var favoriteProductsResult;
23699
+ return __generator(this, function (_b) {
23700
+ switch (_b.label) {
23701
+ case 0:
23702
+ _b.trys.push([0, 2, , 3]);
23703
+ return [4 /*yield*/, IkasFavoriteProductAPI.listFavoriteProducts()];
23704
+ case 1:
23705
+ favoriteProductsResult = _b.sent();
23706
+ return [2 /*return*/, favoriteProductsResult];
23707
+ case 2:
23708
+ _b.sent();
23709
+ return [2 /*return*/, []];
23710
+ case 3: return [2 /*return*/];
23711
+ }
23712
+ });
23713
+ }); };
23714
+ this.getFavoriteProducts = function () { return __awaiter(_this, void 0, void 0, function () {
23715
+ var favoriteProductsResult, productsResult;
23716
+ return __generator(this, function (_b) {
23717
+ switch (_b.label) {
23718
+ case 0:
23719
+ _b.trys.push([0, 3, , 4]);
23720
+ return [4 /*yield*/, IkasFavoriteProductAPI.listFavoriteProducts()];
23721
+ case 1:
23722
+ favoriteProductsResult = _b.sent();
23723
+ if (!favoriteProductsResult.length)
23724
+ return [2 /*return*/, []];
23725
+ return [4 /*yield*/, IkasProductAPI.listProducts({
23726
+ idList: favoriteProductsResult.map(function (fP) { return fP.productId; }),
23727
+ })];
23728
+ case 2:
23729
+ productsResult = _b.sent();
23730
+ return [2 /*return*/, productsResult.products];
23731
+ case 3:
23732
+ _b.sent();
23733
+ return [2 /*return*/, []];
23734
+ case 4: return [2 /*return*/];
23735
+ }
23736
+ });
23737
+ }); };
23738
+ this.addItemToFavorite = function (productId) { return __awaiter(_this, void 0, void 0, function () {
23739
+ var customerId, result;
23740
+ var _b;
23741
+ return __generator(this, function (_c) {
23742
+ switch (_c.label) {
23743
+ case 0:
23744
+ customerId = (_b = this.customer) === null || _b === void 0 ? void 0 : _b.id;
23745
+ if (!customerId)
23746
+ throw Error("Unauthorized");
23747
+ _c.label = 1;
23748
+ case 1:
23749
+ _c.trys.push([1, 3, , 4]);
23750
+ return [4 /*yield*/, IkasFavoriteProductAPI.saveFavoriteProduct(true, productId)];
23751
+ case 2:
23752
+ result = _c.sent();
23753
+ return [2 /*return*/, result];
23754
+ case 3:
23755
+ _c.sent();
23756
+ return [2 /*return*/, false];
23757
+ case 4: return [2 /*return*/];
23758
+ }
23759
+ });
23760
+ }); };
23761
+ this.removeItemFromFavorite = function (productId) { return __awaiter(_this, void 0, void 0, function () {
23762
+ var customerId, result;
23763
+ var _b;
23764
+ return __generator(this, function (_c) {
23765
+ switch (_c.label) {
23766
+ case 0:
23767
+ customerId = (_b = this.customer) === null || _b === void 0 ? void 0 : _b.id;
23768
+ if (!customerId)
23769
+ throw Error("Unauthorized");
23770
+ _c.label = 1;
23771
+ case 1:
23772
+ _c.trys.push([1, 3, , 4]);
23773
+ return [4 /*yield*/, IkasFavoriteProductAPI.saveFavoriteProduct(false, productId)];
23774
+ case 2:
23775
+ result = _c.sent();
23776
+ return [2 /*return*/, result];
23777
+ case 3:
23778
+ _c.sent();
23779
+ return [2 /*return*/, false];
23780
+ case 4: return [2 /*return*/];
23781
+ }
23782
+ });
23783
+ }); };
23784
+ this.isProductFavorite = function (productId) { return __awaiter(_this, void 0, void 0, function () {
23785
+ var customerId;
23786
+ var _a;
23787
+ return __generator(this, function (_b) {
23788
+ switch (_b.label) {
23789
+ case 0:
23790
+ customerId = (_a = this.customer) === null || _a === void 0 ? void 0 : _a.id;
23791
+ if (!customerId)
23792
+ throw Error("Unauthorized");
23793
+ return [4 /*yield*/, IkasFavoriteProductAPI.isFavoriteProduct(productId)];
23794
+ case 1: return [2 /*return*/, _b.sent()];
23795
+ }
23796
+ });
23797
+ }); };
22539
23798
  this.baseStore = baseStore;
22540
23799
  this.init();
22541
23800
  makeAutoObservable(this);
@@ -22798,6 +24057,7 @@ var CheckoutViewModel = /** @class */ (function () {
22798
24057
  lines = this.cart.items.map(function (i) { return ({
22799
24058
  quantity: i.quantity,
22800
24059
  variantId: i.variant.id,
24060
+ productId: i.variant.productId,
22801
24061
  }); });
22802
24062
  return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines)];
22803
24063
  case 1:
@@ -25007,6 +26267,8 @@ var IkasPageHead = observer(function (_a) {
25007
26267
  var page = _a.page, pageTitle = _a.pageTitle, description = _a.description, pageSpecificDataStr = _a.pageSpecificDataStr, props = __rest(_a, ["page", "pageTitle", "description", "pageSpecificDataStr"]);
25008
26268
  var ogpMetas = [];
25009
26269
  var schemas = [];
26270
+ var isCanonicalLinkAdd = false;
26271
+ var canonicalHref = "";
25010
26272
  if (props.addOgpMetas) {
25011
26273
  ogpMetas.push({
25012
26274
  property: "og:type",
@@ -25065,7 +26327,15 @@ var IkasPageHead = observer(function (_a) {
25065
26327
  schemas.push(storeSchema);
25066
26328
  }
25067
26329
  if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === IkasThemePageType.PRODUCT) {
25068
- var schema = createProductSchema(pageSpecificDataStr);
26330
+ var productDetailParsed = JSON.parse(pageSpecificDataStr);
26331
+ var productDetail = new IkasProductDetail(productDetailParsed.product, productDetailParsed.selectedVariantValues);
26332
+ if (typeof window !== "undefined" && productDetail.product.hasVariant) {
26333
+ isCanonicalLinkAdd =
26334
+ window.location.pathname !== productDetail.product.href;
26335
+ canonicalHref =
26336
+ "https://" + window.location.hostname + productDetail.product.href;
26337
+ }
26338
+ var schema = createProductSchema(productDetail);
25069
26339
  if (schema)
25070
26340
  schemas.push(schema);
25071
26341
  }
@@ -25082,6 +26352,7 @@ var IkasPageHead = observer(function (_a) {
25082
26352
  return (createElement(Head, null,
25083
26353
  createElement("title", null, pageTitle || ""),
25084
26354
  createElement("meta", { name: "description", content: description || "" }),
26355
+ isCanonicalLinkAdd && createElement("link", { rel: "canonical", href: canonicalHref }),
25085
26356
  !!props.addOgpMetas &&
25086
26357
  ogpMetas.map(function (ogpMeta, index) { return (createElement("meta", { key: ogpMeta.content + "-" + index, property: ogpMeta.property, content: ogpMeta.content })); }),
25087
26358
  !!schemas.length &&
@@ -25115,11 +26386,9 @@ function createStoreSchema(merchantSettings) {
25115
26386
  url: "https://" + hostname,
25116
26387
  };
25117
26388
  }
25118
- function createProductSchema(pageSpecificDataStr) {
26389
+ function createProductSchema(productDetail) {
25119
26390
  var _a;
25120
26391
  try {
25121
- var productDetailParsed = JSON.parse(pageSpecificDataStr);
25122
- var productDetail = new IkasProductDetail(productDetailParsed.product, productDetailParsed.selectedVariantValues);
25123
26392
  var isBrowser = typeof window !== "undefined";
25124
26393
  if (isBrowser) {
25125
26394
  var urlParams = new URLSearchParams(window.location.search);
@@ -25305,7 +26574,7 @@ var IkasCheckoutPage = observer(function (_a) {
25305
26574
  createElement("div", null,
25306
26575
  createElement("div", { className: styles$2.Header },
25307
26576
  createElement("a", { href: "/" }, !!((_c = vm.merchantSettings) === null || _c === void 0 ? void 0 : _c.logoId) ? (createElement("div", { className: styles$2.Logo },
25308
- createElement(Image, { layout: "fill", src: vm.merchantSettings.logo.src, quality: 100 }))) : (((_d = vm.merchantSettings) === null || _d === void 0 ? void 0 : _d.merchantName) || ""))),
26577
+ createElement(Image$1, { layout: "fill", src: vm.merchantSettings.logo.src, quality: 100 }))) : (((_d = vm.merchantSettings) === null || _d === void 0 ? void 0 : _d.merchantName) || ""))),
25309
26578
  vm.step !== CheckoutStep.SUCCESS && createElement(Breadcrumbs, { vm: vm }),
25310
26579
  !!vm.error && renderError(),
25311
26580
  createElement("div", { className: styles$2.MobileCartSummary },
@@ -25823,6 +27092,10 @@ var pageStyle$1 = {
25823
27092
  justifyContent: "space-between",
25824
27093
  };
25825
27094
 
27095
+ var Image = function (props) {
27096
+ return createElement(Image$1, __assign({}, props, { unoptimized: true, quality: 100 }));
27097
+ };
27098
+
25826
27099
  var GTMHead = function (_a) {
25827
27100
  var blockHTML = _a.blockHTML;
25828
27101
  var gtmId = process.env.GTM_ID;
@@ -25851,6 +27124,7 @@ var index = /*#__PURE__*/Object.freeze({
25851
27124
  IkasPage: IkasPage,
25852
27125
  IkasPageHead: IkasPageHead,
25853
27126
  IkasPageEditor: IkasPageEditor,
27127
+ Image: Image,
25854
27128
  GTMHead: GTMHead,
25855
27129
  GTMBody: GTMBody,
25856
27130
  GTMPageView: GTMPageView,
@@ -25895,7 +27169,8 @@ var Page$1 = function (_a) {
25895
27169
  var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
25896
27170
  var router = useRouter();
25897
27171
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
25898
- var _c = useState(IkasPageDataProvider.initPropValues(propValuesStr, router)), propValues = _c[0], setPropValues = _c[1];
27172
+ var initialPropValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
27173
+ var _c = useState(initialPropValues), propValues = _c[0], setPropValues = _c[1];
25899
27174
  useEffect(function () {
25900
27175
  setIsBrowser(typeof window !== "undefined");
25901
27176
  }, []);
@@ -26369,6 +27644,34 @@ var editor$1 = /*#__PURE__*/Object.freeze({
26369
27644
  'default': editor
26370
27645
  });
26371
27646
 
27647
+ var Page$d = function (_a) {
27648
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
27649
+ var router = useRouter();
27650
+ var propValues = IkasPageDataProvider.initPropValues(propValuesStr, router);
27651
+ return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
27652
+ };
27653
+ var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
27654
+ var theme, provider;
27655
+ return __generator(this, function (_a) {
27656
+ switch (_a.label) {
27657
+ case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
27658
+ case 1:
27659
+ theme = _a.sent();
27660
+ provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.FAVORITE_PRODUCTS);
27661
+ return [4 /*yield*/, provider.getPageData()];
27662
+ case 2:
27663
+ _a.sent();
27664
+ return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
27665
+ }
27666
+ });
27667
+ }); };
27668
+
27669
+ var favoriteProducts = /*#__PURE__*/Object.freeze({
27670
+ __proto__: null,
27671
+ 'default': Page$d,
27672
+ getStaticProps: getStaticProps$b
27673
+ });
27674
+
26372
27675
  configure({
26373
27676
  enforceActions: "never",
26374
27677
  });
@@ -26380,4 +27683,4 @@ var IkasBaseStore = /** @class */ (function () {
26380
27683
  return IkasBaseStore;
26381
27684
  }());
26382
27685
 
26383
- export { AccountInfoForm, index$3 as AccountPage, AddressForm, addresses as AddressesPage, cart as CartPage, _id_$1 as CheckoutPage, _slug_ as CustomPage, editor$1 as EditorPage, EmailRule, EqualsRule, ForgotPasswordForm, forgotPassword as ForgotPasswordPage, GTMAddToCart, GTMBeginCheckout, GTMBody, GTMCheckoutStep, GTMDisableHTML, GTMHead, GTMPageView, GTMProductView, GTMPurchase, GTMRemoveFromCart, IkasAmountTypeEnum$1 as IkasAmountTypeEnum, 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, IkasCountryAPI, IkasCustomer, IkasCustomerAPI, IkasCustomerAddress, IkasDistrictAPI, 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, IkasProductAPI, IkasProductAttribute, IkasProductAttributeAPI, IkasProductAttributeValue, IkasProductDetail, IkasProductDetailPropValue, IkasProductList, IkasProductListFilter, IkasProductListPropValue, IkasProductListSortType, IkasProductListType, IkasProductPrice, 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, home as IndexPage, LessThanRule, LoginForm, login as LoginPage, MaxRule, MinRule, _id_$2 as OrderDetailPage, index$4 as OrdersPage, PhoneRule, RecoverPasswordForm, recoverPassword as RecoverPasswordPage, RegisterForm, register as RegisterPage, RequiredRule, index$2 as SlugPage, ValidationRule, Validator, ValidatorErrorType, apollo, decodeBase64, formatMoney, pascalCase, stringToSlug, validatePhoneNumber };
27686
+ export { AccountInfoForm, index$3 as AccountPage, AddressForm, addresses as AddressesPage, cart as CartPage, _id_$1 as CheckoutPage, _slug_ as CustomPage, editor$1 as EditorPage, EmailRule, EqualsRule, favoriteProducts as FavoriteProductsPage, ForgotPasswordForm, forgotPassword as ForgotPasswordPage, GTMAddToCart, GTMBeginCheckout, GTMBody, GTMCheckoutStep, GTMDisableHTML, GTMHead, GTMPageView, GTMProductView, GTMPurchase, GTMRemoveFromCart, 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, 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, IkasProductAPI, IkasProductAttribute, IkasProductAttributeAPI, IkasProductAttributeValue, IkasProductDetail, IkasProductDetailPropValue, IkasProductFilter, IkasProductFilterDisplayType, 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, _id_$2 as OrderDetailPage, index$4 as OrdersPage, PhoneRule, RangeValue, RecoverPasswordForm, recoverPassword as RecoverPasswordPage, RegisterForm, register as RegisterPage, RequiredRule, index$2 as SlugPage, ValidationRule, Validator, ValidatorErrorType, apollo, decodeBase64, formatMoney, parseRangeStr, pascalCase, stringToSlug, validatePhoneNumber };