@ikas/bp-storefront 1.4.0-beta.14 → 1.4.0-beta.141
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.
- package/dist/functions/api/product/index.js +1 -1
- package/dist/functions/models/image/index.d.ts +65 -20
- package/dist/functions/models/image/index.js +1 -1
- package/dist/functions/models/product/variant/index.d.ts +96 -6
- package/dist/functions/models/product/variant/index.js +1 -1
- package/dist/functions/models/product-list/index.js +1 -1
- package/dist/functions/models/validator/address/index.d.ts +70 -2
- package/dist/functions/stores/cart/index.js +1 -1
- package/dist/functions/stores/customer/index.d.ts +29 -23
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/packages/storefront-config/src/index.js +1 -1
- package/dist/packages/storefront-config/src/theme-globals.js +1 -0
- package/dist/storefront-config/src/index.d.ts +4 -0
- package/dist/storefront-config/src/theme-globals.d.ts +305 -0
- package/dist/storefront-models/src/index.d.ts +1 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/color.d.ts +2 -0
- package/dist/storefront-models/src/models/product/campaign/data/index.d.ts +2 -0
- package/dist/storefront-models/src/models/product/campaign/filter/index.d.ts +1 -1
- package/dist/storefront-models/src/models/product/campaign/product-tiered-discount/index.d.ts +13 -0
- package/dist/storefront-models/src/models/product/variant/index.d.ts +17 -0
- package/dist/theme/settings/index.d.ts +48 -0
- package/dist/theme/settings/index.js +1 -0
- package/dist/utils/component-renderer.js +1 -1
- package/dist/utils/pay-with-ikas.d.ts +552 -0
- package/dist/utils/pay-with-ikas.js +1 -0
- package/dist/utils/svg.d.ts +15 -0
- package/dist/utils/svg.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{APIResponse as n}from"../../../packages/storefront-api-client/src/utils/api.js";import'./../../../ext/isomorphic-fetch/fetch-npm-node.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import{initIkasProductAttribute as a}from"../../models/product/attribute/init.js";import{initIkasCampaignOffer as o}from"../../models/product/campaign-offer/init.js";import{initIkasProduct as u}from"../../models/product/init.js";import{initIkasProductOptionSet as d}from"../../models/product/option-set/init.js";function s(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listProductBackInStockRemind.js")];case 1:return[4,(0,t.sent().listProductBackInStockRemind)(r)];case 2:return[2,t.sent()]}})})}function c(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/saveProductBackInStockRemind.js")];case 1:return[4,(0,t.sent().saveProductBackInStockRemind)(r)];case 2:return[2,t.sent()]}})})}function l(r){return t(this,void 0,void 0,function(){var t,a;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listCampaignOffer.js")];case 1:return[4,(0,e.sent().listCampaignOffer)(r)];case 2:return t=e.sent(),null===(a=t.data)||void 0===a||a.forEach(function(t){o(t,i.getCurrentLocale())}),[2,new n(t.data||null,t.graphQLErrors)]}})})}function p(a,o){return t(this,void 0,void 0,function(){var t,d,s,c,l,p;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/searchProducts.js")];case 1:return t=e.sent().searchProducts,d=null===(l=i.getCurrentRouting())||void 0===l?void 0:l.dynamicCurrencySettings,[4,t({input:r(r({locale:i.getCurrentLocale(),dynamicCurrencySettings:d?{roundingFormat:d.roundingFormat,targetCurrencyCode:d.targetCurrencyCode}:void 0},a.input),{showStockOption:a.input.showStockOption||i.stockPreference||"SHOW_ALL"})},o)];case 2:return s=e.sent(),null==(c=null===(p=s.data)||void 0===p?void 0:p.results.map(I))||c.forEach(function(t){return u(t,i.getCurrentLocale())}),[2,new n(s.data?r(r({},s.data),{data:c}):null,s.graphQLErrors)]}})})}function v(r){return t(this,void 0,void 0,function(){var t,i,a,o,u,d,s;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getProductFilterData.js")];case 1:return[4,(0,e.sent().getProductFilterData)(r)];case 2:return t=e.sent(),i=null===(u=t.data)||void 0===u?void 0:u.filters,a=(null===(d=t.data)||void 0===d?void 0:d.categories)||null,o=(null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes)||null,[2,new n(t.data?{filters:i,categories:a,disabledSortTypes:o}:null,t.graphQLErrors)]}})})}function m(a){return t(this,void 0,void 0,function(){var t,o,d,s,c,l;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getRelatedProducts.js")];case 1:return t=e.sent().getRelatedProducts,o=null===(c=i.getCurrentRouting())||void 0===c?void 0:c.dynamicCurrencySettings,[4,t(r({locale:i.getCurrentLocale(),dynamicCurrencySettings:o?{roundingFormat:o.roundingFormat,targetCurrencyCode:o.targetCurrencyCode}:void 0},a))];case 2:return d=e.sent(),(s=(null===(l=null==d?void 0:d.data)||void 0===l?void 0:l.map(function(t){return I(t)}))||[]).forEach(function(t){return u(t,i.getCurrentLocale())}),[2,new n(d.data?{data:s,count:d.data.length,facets:null,limit:20,page:1,totalCount:d.data.length}:null,d.graphQLErrors)]}})})}function g(a){return t(this,void 0,void 0,function(){var t,o,d,s,c,l;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getSuggestedProducts.js")];case 1:return t=e.sent().getSuggestedProducts,o=null===(c=i.getCurrentRouting())||void 0===c?void 0:c.dynamicCurrencySettings,[4,t(r({locale:i.getCurrentLocale(),dynamicCurrencySettings:o?{roundingFormat:o.roundingFormat,targetCurrencyCode:o.targetCurrencyCode}:void 0},a))];case 2:return d=e.sent(),(s=(null===(l=null==d?void 0:d.data)||void 0===l?void 0:l.map(function(t){return I(t)}))||[]).forEach(function(t){return u(t,i.getCurrentLocale())}),[2,new n(d.data?{data:s,count:d.data.length,facets:null,limit:20,page:1,totalCount:d.data.length}:null,d.graphQLErrors)]}})})}function f(r){return t(this,void 0,void 0,function(){var t,o;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listProductAttribute.js")];case 1:return[4,(0,e.sent().listProductAttribute)(r)];case 2:return t=e.sent(),null==(o=t.data)||o.forEach(function(t){return a(t,i.getCurrentLocale())}),[2,new n(o,t.graphQLErrors)]}})})}function h(r){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getProductCampaigns.js")];case 1:return[4,(0,e.sent().getProductCampaigns)(r)];case 2:return t=e.sent(),[2,new n(t.data,t.graphQLErrors)]}})})}function b(r){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getVariantStockLocations.js")];case 1:return[4,(0,e.sent().getVariantStockLocations)(r)];case 2:return t=e.sent(),[2,new n(t.data,t.graphQLErrors)]}})})}function y(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/getOrderLineFile.js")];case 1:return[4,(0,t.sent().getOrderLineFile)(r)];case 2:return[2,t.sent()]}})})}function C(r,a){return t(this,void 0,void 0,function(){var t,o;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listProductOptionSet.js")];case 1:return[4,(0,e.sent().listProductOptionSet)(r)];case 2:return t=e.sent(),null==(o=t.data)||o.forEach(function(t){return d(t,i.getCurrentLocale(),a)}),[2,new n(o,t.graphQLErrors)]}})})}function I(t){var e,n,a,o,u,d="local"===import.meta.env.VITE_ENV;return{id:t.id,type:t.type,groupVariantsByVariantTypeId:t.groupVariantsByVariantTypeId,deleted:t.deleted,selectedVariantValues:[],offers:[],bundleProductCache:{},productOptionSet:null,showVariantsInGroup:!1,attributes:(null===(e=t.attributes)||void 0===e?void 0:e.map(function(t){var e,n,i,a,o,u;return r(r({},t),{value:t.value,productAttributeId:(null===(e=t.productAttribute)||void 0===e?void 0:e.id)||null,productAttributeOptionId:(null===(n=t.productAttributeOption)||void 0===n?void 0:n.id)||null,productAttribute:{id:(null===(i=t.productAttribute)||void 0===i?void 0:i.id)||"",name:(null===(a=t.productAttribute)||void 0===a?void 0:a.name)||"",description:null,type:null===(o=t.productAttribute)||void 0===o?void 0:o.type,tableTemplate:(null===(u=t.productAttribute)||void 0===u?void 0:u.tableTemplate)?t.productAttribute.tableTemplate:null,options:null},productAttributeOption:t.productAttributeOption})}))||[],brand:t.brand?r(r({},t.brand),{id:t.brand.id,name:t.brand.name,createdAt:0,updatedAt:0,description:null,imageId:t.brand.imageId,orderType:"BEST_SELLER",metaData:{id:"",createdAt:0,updatedAt:0,slug:t.brand.slug||""}}):null,campaigns:null===(n=t.campaigns)||void 0===n?void 0:n.map(function(t){return{campaign:t,variantIds:[]}}),campaignOffers:t.campaignOffers,categories:(null===(a=t.categories)||void 0===a?void 0:a.map(function(t){var e;return r(r({},t),{categoryPath:t.path.map(function(t){return t.name}),description:null,imageId:null,parentId:null,metaData:t.slug?{id:"",createdAt:0,updatedAt:0,name:t.name||"",slug:t.slug,translations:null===(e=t.translations)||void 0===e?void 0:e.map(function(t){return{pageTitle:t.name,slug:t.slug,locale:t.locale,description:null}})}:null,categoryPathItems:t.path.map(function(t){return{metaData:{id:"",createdAt:0,updatedAt:0,name:t.name||"",slug:t.slug||""},description:null,name:t.name,translations:t.translations,imageId:null,id:t.id,createdAt:0,updatedAt:0}}),createdAt:0,updatedAt:0,orderType:"BEST_SELLER",conditions:null,conditionValues:null})}))||[],tags:t.tags||[],description:t.description||"",averageRating:t.averageRating,reviewCount:t.reviewCount,stars:t.stars,baseUnit:t.baseUnit,metaData:r(r({},t.metaData),{id:"",createdAt:0,updatedAt:0,slug:(null===(o=t.metaData)||void 0===o?void 0:o.slug)||""}),name:t.name,productOptionSetId:t.productOptionSetId,variantTypes:t.productVariantTypes.map(function(t){return{order:t.order,variantType:{id:t.variantType.id,name:t.variantType.name,selectionType:t.variantType.selectionType,values:t.variantType.values.map(function(e){return{id:e.id,colorCode:e.colorCode,name:e.name,thumbnailImageId:e.thumbnailImageId,variantTypeId:t.variantType.id}}).filter(function(e){return t.variantValueIds.includes(e.id)})},variantValueIds:t.variantValueIds}}),variants:t.variants.map(function(e){var n,a,o,u;return r(r({},e),{id:e.id,productId:t.id,images:(null===(n=e.images)||void 0===n?void 0:n.map(function(t){return{imageId:t.id,isMain:t.isMain||!1,isVideo:t.isVideo,order:t.order,fileName:t.fileName}}))||null,sellIfOutOfStock:e.sellIfOutOfStock||!1,isBackInStockReminderSaved:!1,unit:e.unit,attributes:(null===(a=e.attributes)||void 0===a?void 0:a.map(function(t){var e,n,i,a,o,u;return r(r({},t),{value:t.value,productAttributeId:(null===(e=t.productAttribute)||void 0===e?void 0:e.id)||null,productAttributeOptionId:(null===(n=t.productAttributeOption)||void 0===n?void 0:n.id)||null,productAttribute:{id:(null===(i=t.productAttribute)||void 0===i?void 0:i.id)||"",name:(null===(a=t.productAttribute)||void 0===a?void 0:a.name)||"",description:"",type:null===(o=t.productAttribute)||void 0===o?void 0:o.type,tableTemplate:(null===(u=t.productAttribute)||void 0===u?void 0:u.tableTemplate)?t.productAttribute.tableTemplate:null,options:null},productAttributeOption:t.productAttributeOption})}))||[],sku:e.sku,barcodeList:e.barcodeList||null,prices:e.prices||[],price:{buyPrice:null,campaignPrice:null,currency:"",currencyCode:"",currencySymbol:"",discountPrice:null,priceListId:null,sellPrice:0,unitPrice:null},stock:(null===(o=e.stocks)||void 0===o?void 0:o.filter(function(t){var e;return d||i.isEditor||(null===(e=i.stockLocationIds)||void 0===e?void 0:e.includes(t.stockLocationId))}).reduce(function(t,e){return e.stockCount+t},0))||0,variantValues:(null===(u=e.variantValues)||void 0===u?void 0:u.map(function(e){var r=t.productVariantTypes.find(function(t){return t.variantType.id===e.variantTypeId}),n=null==r?void 0:r.variantType.values.find(function(t){return t.id===e.variantValueId});return{id:e.variantValueId,name:(null==n?void 0:n.name)||"",colorCode:(null==n?void 0:n.colorCode)||"",thumbnailImageId:(null==n?void 0:n.thumbnailImageId)||"",variantTypeId:(null==r?void 0:r.variantType.id)||""}}))||[],isActive:e.isActive||!1,bundleSettings:e.bundleSettings||null})}),dynamicPriceListIds:null,productGroup:t.productGroup,salesChannels:null===(u=t.salesChannels)||void 0===u?void 0:u.filter(function(t){return t.id===i.salesChannelId})}}export{y as apiGetOrderLineFile,h as apiGetProductCampaigns,v as apiGetProductFilterData,m as apiGetRelatedProducts,g as apiGetSuggestedProducts,b as apiGetVariantStockLocations,l as apiListCampaignOffer,f as apiListProductAttribute,s as apiListProductBackInStockRemind,C as apiListProductOptionSet,c as apiSaveProductBackInStockRemind,p as apiSearchProducts};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{APIResponse as n}from"../../../packages/storefront-api-client/src/utils/api.js";import'./../../../ext/isomorphic-fetch/fetch-npm-node.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import{initIkasProductAttribute as a}from"../../models/product/attribute/init.js";import{initIkasCampaignOffer as o}from"../../models/product/campaign-offer/init.js";import{initIkasProduct as u}from"../../models/product/init.js";import{initIkasProductOptionSet as d}from"../../models/product/option-set/init.js";function s(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listProductBackInStockRemind.js")];case 1:return[4,(0,t.sent().listProductBackInStockRemind)(r)];case 2:return[2,t.sent()]}})})}function c(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/saveProductBackInStockRemind.js")];case 1:return[4,(0,t.sent().saveProductBackInStockRemind)(r)];case 2:return[2,t.sent()]}})})}function l(r){return t(this,void 0,void 0,function(){var t,a;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listCampaignOffer.js")];case 1:return[4,(0,e.sent().listCampaignOffer)(r)];case 2:return t=e.sent(),null===(a=t.data)||void 0===a||a.forEach(function(t){o(t,i.getCurrentLocale())}),[2,new n(t.data||null,t.graphQLErrors)]}})})}function p(a,o){return t(this,void 0,void 0,function(){var t,d,s,c,l,p;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/searchProducts.js")];case 1:return t=e.sent().searchProducts,d=null===(l=i.getCurrentRouting())||void 0===l?void 0:l.dynamicCurrencySettings,[4,t({input:r(r({locale:i.getCurrentLocale(),dynamicCurrencySettings:d?{roundingFormat:d.roundingFormat,targetCurrencyCode:d.targetCurrencyCode}:void 0},a.input),{showStockOption:a.input.showStockOption||i.stockPreference||"SHOW_ALL"})},o)];case 2:return s=e.sent(),null==(c=null===(p=s.data)||void 0===p?void 0:p.results.map(I))||c.forEach(function(t){return u(t,i.getCurrentLocale())}),[2,new n(s.data?r(r({},s.data),{data:c}):null,s.graphQLErrors)]}})})}function v(r){return t(this,void 0,void 0,function(){var t,i,a,o,u,d,s;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getProductFilterData.js")];case 1:return[4,(0,e.sent().getProductFilterData)(r)];case 2:return t=e.sent(),i=null===(u=t.data)||void 0===u?void 0:u.filters,a=(null===(d=t.data)||void 0===d?void 0:d.categories)||null,o=(null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes)||null,[2,new n(t.data?{filters:i,categories:a,disabledSortTypes:o}:null,t.graphQLErrors)]}})})}function m(a){return t(this,void 0,void 0,function(){var t,o,d,s,c,l;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getRelatedProducts.js")];case 1:return t=e.sent().getRelatedProducts,o=null===(c=i.getCurrentRouting())||void 0===c?void 0:c.dynamicCurrencySettings,[4,t(r({locale:i.getCurrentLocale(),dynamicCurrencySettings:o?{roundingFormat:o.roundingFormat,targetCurrencyCode:o.targetCurrencyCode}:void 0},a))];case 2:return d=e.sent(),(s=(null===(l=null==d?void 0:d.data)||void 0===l?void 0:l.map(function(t){return I(t)}))||[]).forEach(function(t){return u(t,i.getCurrentLocale())}),[2,new n(d.data?{data:s,count:d.data.length,facets:null,limit:20,page:1,totalCount:d.data.length}:null,d.graphQLErrors)]}})})}function g(a){return t(this,void 0,void 0,function(){var t,o,d,s,c,l;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getSuggestedProducts.js")];case 1:return t=e.sent().getSuggestedProducts,o=null===(c=i.getCurrentRouting())||void 0===c?void 0:c.dynamicCurrencySettings,[4,t(r({locale:i.getCurrentLocale(),dynamicCurrencySettings:o?{roundingFormat:o.roundingFormat,targetCurrencyCode:o.targetCurrencyCode}:void 0},a))];case 2:return d=e.sent(),(s=(null===(l=null==d?void 0:d.data)||void 0===l?void 0:l.map(function(t){return I(t)}))||[]).forEach(function(t){return u(t,i.getCurrentLocale())}),[2,new n(d.data?{data:s,count:d.data.length,facets:null,limit:20,page:1,totalCount:d.data.length}:null,d.graphQLErrors)]}})})}function f(r){return t(this,void 0,void 0,function(){var t,o;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listProductAttribute.js")];case 1:return[4,(0,e.sent().listProductAttribute)(r)];case 2:return t=e.sent(),null==(o=t.data)||o.forEach(function(t){return a(t,i.getCurrentLocale())}),[2,new n(o,t.graphQLErrors)]}})})}function h(r){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getProductCampaigns.js")];case 1:return[4,(0,e.sent().getProductCampaigns)(r)];case 2:return t=e.sent(),[2,new n(t.data,t.graphQLErrors)]}})})}function b(r){return t(this,void 0,void 0,function(){var t,i;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getVariantStockLocations.js")];case 1:return[4,(0,e.sent().getVariantStockLocations)(r)];case 2:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.stockLocations,t.graphQLErrors)]}})})}function y(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/getOrderLineFile.js")];case 1:return[4,(0,t.sent().getOrderLineFile)(r)];case 2:return[2,t.sent()]}})})}function C(r,a){return t(this,void 0,void 0,function(){var t,o;return e(this,function(e){switch(e.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/listProductOptionSet.js")];case 1:return[4,(0,e.sent().listProductOptionSet)(r)];case 2:return t=e.sent(),null==(o=t.data)||o.forEach(function(t){return d(t,i.getCurrentLocale(),a)}),[2,new n(o,t.graphQLErrors)]}})})}function I(t){var e,n,a,o,u,d="local"===import.meta.env.VITE_ENV;return{id:t.id,type:t.type,groupVariantsByVariantTypeId:t.groupVariantsByVariantTypeId,deleted:t.deleted,selectedVariantValues:[],offers:[],bundleProductCache:{},productOptionSet:null,showVariantsInGroup:!1,attributes:(null===(e=t.attributes)||void 0===e?void 0:e.map(function(t){var e,n,i,a,o,u;return r(r({},t),{value:t.value,productAttributeId:(null===(e=t.productAttribute)||void 0===e?void 0:e.id)||null,productAttributeOptionId:(null===(n=t.productAttributeOption)||void 0===n?void 0:n.id)||null,productAttribute:{id:(null===(i=t.productAttribute)||void 0===i?void 0:i.id)||"",name:(null===(a=t.productAttribute)||void 0===a?void 0:a.name)||"",description:null,type:null===(o=t.productAttribute)||void 0===o?void 0:o.type,tableTemplate:(null===(u=t.productAttribute)||void 0===u?void 0:u.tableTemplate)?t.productAttribute.tableTemplate:null,options:null},productAttributeOption:t.productAttributeOption})}))||[],brand:t.brand?r(r({},t.brand),{id:t.brand.id,name:t.brand.name,createdAt:0,updatedAt:0,description:null,imageId:t.brand.imageId,orderType:"BEST_SELLER",metaData:{id:"",createdAt:0,updatedAt:0,slug:t.brand.slug||""}}):null,campaigns:null===(n=t.campaigns)||void 0===n?void 0:n.map(function(t){return{campaign:t,variantIds:[]}}),campaignOffers:t.campaignOffers,categories:(null===(a=t.categories)||void 0===a?void 0:a.map(function(t){var e;return r(r({},t),{categoryPath:t.path.map(function(t){return t.name}),description:null,imageId:null,parentId:null,metaData:t.slug?{id:"",createdAt:0,updatedAt:0,name:t.name||"",slug:t.slug,translations:null===(e=t.translations)||void 0===e?void 0:e.map(function(t){return{pageTitle:t.name,slug:t.slug,locale:t.locale,description:null}})}:null,categoryPathItems:t.path.map(function(t){return{metaData:{id:"",createdAt:0,updatedAt:0,name:t.name||"",slug:t.slug||""},description:null,name:t.name,translations:t.translations,imageId:null,id:t.id,createdAt:0,updatedAt:0}}),createdAt:0,updatedAt:0,orderType:"BEST_SELLER",conditions:null,conditionValues:null})}))||[],tags:t.tags||[],description:t.description||"",averageRating:t.averageRating,reviewCount:t.reviewCount,stars:t.stars,baseUnit:t.baseUnit,metaData:r(r({},t.metaData),{id:"",createdAt:0,updatedAt:0,slug:(null===(o=t.metaData)||void 0===o?void 0:o.slug)||""}),name:t.name,productOptionSetId:t.productOptionSetId,variantTypes:t.productVariantTypes.map(function(t){return{order:t.order,variantType:{id:t.variantType.id,name:t.variantType.name,selectionType:t.variantType.selectionType,values:t.variantType.values.map(function(e){return{id:e.id,colorCode:e.colorCode,name:e.name,thumbnailImageId:e.thumbnailImageId,variantTypeId:t.variantType.id}}).filter(function(e){return t.variantValueIds.includes(e.id)})},variantValueIds:t.variantValueIds}}),variants:t.variants.map(function(e){var n,a,o,u;return r(r({},e),{id:e.id,productId:t.id,images:(null===(n=e.images)||void 0===n?void 0:n.map(function(t){return{imageId:t.id,isMain:t.isMain||!1,isVideo:t.isVideo,order:t.order,fileName:t.fileName}}))||null,sellIfOutOfStock:e.sellIfOutOfStock||!1,isBackInStockReminderSaved:!1,unit:e.unit,attributes:(null===(a=e.attributes)||void 0===a?void 0:a.map(function(t){var e,n,i,a,o,u;return r(r({},t),{value:t.value,productAttributeId:(null===(e=t.productAttribute)||void 0===e?void 0:e.id)||null,productAttributeOptionId:(null===(n=t.productAttributeOption)||void 0===n?void 0:n.id)||null,productAttribute:{id:(null===(i=t.productAttribute)||void 0===i?void 0:i.id)||"",name:(null===(a=t.productAttribute)||void 0===a?void 0:a.name)||"",description:"",type:null===(o=t.productAttribute)||void 0===o?void 0:o.type,tableTemplate:(null===(u=t.productAttribute)||void 0===u?void 0:u.tableTemplate)?t.productAttribute.tableTemplate:null,options:null},productAttributeOption:t.productAttributeOption})}))||[],sku:e.sku,barcodeList:e.barcodeList||null,prices:e.prices||[],price:{buyPrice:null,campaignPrice:null,currency:"",currencyCode:"",currencySymbol:"",discountPrice:null,priceListId:null,sellPrice:0,unitPrice:null},stock:(null===(o=e.stocks)||void 0===o?void 0:o.filter(function(t){var e;return d||i.isEditor||(null===(e=i.stockLocationIds)||void 0===e?void 0:e.includes(t.stockLocationId))}).reduce(function(t,e){return e.stockCount+t},0))||0,variantValues:(null===(u=e.variantValues)||void 0===u?void 0:u.map(function(e){var r=t.productVariantTypes.find(function(t){return t.variantType.id===e.variantTypeId}),n=null==r?void 0:r.variantType.values.find(function(t){return t.id===e.variantValueId});return{id:e.variantValueId,name:(null==n?void 0:n.name)||"",colorCode:(null==n?void 0:n.colorCode)||"",thumbnailImageId:(null==n?void 0:n.thumbnailImageId)||"",variantTypeId:(null==r?void 0:r.variantType.id)||""}}))||[],isActive:e.isActive||!1,bundleSettings:e.bundleSettings||null})}),dynamicPriceListIds:null,productGroup:t.productGroup,salesChannels:null===(u=t.salesChannels)||void 0===u?void 0:u.filter(function(t){return t.id===i.salesChannelId})}}export{y as apiGetOrderLineFile,h as apiGetProductCampaigns,v as apiGetProductFilterData,m as apiGetRelatedProducts,g as apiGetSuggestedProducts,b as apiGetVariantStockLocations,l as apiListCampaignOffer,f as apiListProductAttribute,s as apiListProductBackInStockRemind,C as apiListProductOptionSet,c as apiSaveProductBackInStockRemind,p as apiSearchProducts};
|
|
@@ -1,62 +1,97 @@
|
|
|
1
1
|
import { IkasImage } from "../../../storefront-models/src";
|
|
2
2
|
/**
|
|
3
|
-
* Returns the default source URL for an image at 1080px resolution.
|
|
3
|
+
* Returns the default source URL for an image OR video at 1080px resolution.
|
|
4
|
+
*
|
|
5
|
+
* Product media items (IkasProductImage) can be videos. ALWAYS check `item.isVideo`
|
|
6
|
+
* and render a `<video src={getDefaultSrc(item)}>` instead of an `<img>` when it is true.
|
|
7
|
+
* Never assume every media item is an image.
|
|
4
8
|
*
|
|
5
9
|
* @ai-category Image
|
|
6
10
|
* @ai-related getThumbnailSrc, getSrc, createMediaSrcset
|
|
7
11
|
*
|
|
8
12
|
* @param image - The image object to generate the default source URL for.
|
|
9
|
-
* @returns The CDN URL string for the image at 1080px size.
|
|
13
|
+
* @returns The CDN URL string for the image or video at 1080px size.
|
|
10
14
|
*
|
|
11
15
|
* @example
|
|
12
16
|
* ```typescript
|
|
13
|
-
* import { getDefaultSrc } from "@ikas/bp-storefront";
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* import { getDefaultSrc, createMediaSrcset } from "@ikas/bp-storefront";
|
|
18
|
+
*
|
|
19
|
+
* // Product images can be videos — ALWAYS branch on isVideo when mapping media:
|
|
20
|
+
* {product.images.map((item, i) =>
|
|
21
|
+
* item.isVideo ? (
|
|
22
|
+
* <video key={i} src={getDefaultSrc(item)} muted playsInline preload="metadata">
|
|
23
|
+
* <track kind="captions" />
|
|
24
|
+
* </video>
|
|
25
|
+
* ) : (
|
|
26
|
+
* <img key={i} src={getDefaultSrc(item)} srcSet={createMediaSrcset(item)} alt={`Product ${i + 1}`} />
|
|
27
|
+
* )
|
|
28
|
+
* )}
|
|
17
29
|
* ```
|
|
18
30
|
*/
|
|
19
31
|
export declare function getDefaultSrc(image: IkasImage): string;
|
|
20
32
|
/**
|
|
21
|
-
* Returns the thumbnail source URL for an image at 180px resolution.
|
|
33
|
+
* Returns the thumbnail source URL for an image OR video at 180px resolution.
|
|
34
|
+
*
|
|
35
|
+
* When mapping over product media (IkasProductImage[]), some items are videos:
|
|
36
|
+
* check `item.isVideo` and render a `<video>` thumbnail (typically with a play
|
|
37
|
+
* overlay) instead of an `<img>` when it is true.
|
|
22
38
|
*
|
|
23
39
|
* @ai-category Image
|
|
24
40
|
* @ai-related getDefaultSrc, getSrc, createMediaSrcset
|
|
25
41
|
*
|
|
26
42
|
* @param image - The image object to generate the thumbnail source URL for.
|
|
27
|
-
* @returns The CDN URL string for the image at 180px size.
|
|
43
|
+
* @returns The CDN URL string for the image or video at 180px size.
|
|
28
44
|
*
|
|
29
45
|
* @example
|
|
30
46
|
* ```typescript
|
|
31
|
-
* import { getThumbnailSrc } from "@ikas/bp-storefront";
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
47
|
+
* import { getThumbnailSrc, getDefaultSrc } from "@ikas/bp-storefront";
|
|
48
|
+
*
|
|
49
|
+
* // Thumbnail rail — branch on isVideo per item:
|
|
50
|
+
* {product.images.map((item, i) =>
|
|
51
|
+
* item.isVideo ? (
|
|
52
|
+
* <video key={i} src={getDefaultSrc(item)} muted preload="metadata">
|
|
53
|
+
* <track kind="captions" />
|
|
54
|
+
* </video>
|
|
55
|
+
* ) : (
|
|
56
|
+
* <img key={i} src={getThumbnailSrc(item)} sizes="112px" alt={`Thumb ${i + 1}`} />
|
|
57
|
+
* )
|
|
58
|
+
* )}
|
|
35
59
|
* ```
|
|
36
60
|
*/
|
|
37
61
|
export declare function getThumbnailSrc(image: IkasImage): string;
|
|
38
62
|
/**
|
|
39
63
|
* Generates the full CDN source URL for an image or video at the specified size, handling both legacy path-based and merchant-scoped ID formats.
|
|
40
64
|
*
|
|
65
|
+
* NOTE: For videos (`image.isVideo === true`) the `size` argument is IGNORED — the original .mp4 is always returned.
|
|
66
|
+
* So `getSrc(item, 240)` and `getDefaultSrc(item)` produce the identical URL for a video. PREFER `getDefaultSrc(item)`
|
|
67
|
+
* for video `src` (no size param) — do NOT pass an arbitrary size like `getSrc(item, 240)`, it is misleading.
|
|
68
|
+
*
|
|
41
69
|
* @ai-category Image
|
|
42
70
|
* @ai-related getDefaultSrc, getThumbnailSrc, createMediaSrcset
|
|
43
71
|
*
|
|
44
72
|
* @param image - The image object containing the id, fileName, and isVideo flag.
|
|
45
|
-
* @param size - The desired image width in pixels for
|
|
73
|
+
* @param size - The desired image width in pixels. Ignored for videos.
|
|
46
74
|
* @returns The full CDN URL string for the image or video.
|
|
47
75
|
*
|
|
48
76
|
* @example
|
|
49
77
|
* ```typescript
|
|
50
|
-
* import { getSrc } from "@ikas/bp-storefront";
|
|
78
|
+
* import { getSrc, getDefaultSrc } from "@ikas/bp-storefront";
|
|
51
79
|
*
|
|
52
80
|
* const src = getSrc(image, 640);
|
|
53
81
|
* console.log(src); // "https://cdn.example.com/images/.../640/image.webp"
|
|
82
|
+
*
|
|
83
|
+
* // For a video, use getDefaultSrc (size is ignored anyway):
|
|
84
|
+
* <video src={getDefaultSrc(item)} muted playsInline preload="metadata" />
|
|
54
85
|
* ```
|
|
55
86
|
*/
|
|
56
87
|
export declare function getSrc(image: IkasImage, size: number): string;
|
|
57
88
|
/**
|
|
58
89
|
* Generates a complete responsive `srcset` string for an image across all standard sizes (180–3840px).
|
|
59
90
|
*
|
|
91
|
+
* srcset applies to `<img>` only — video media (`item.isVideo === true`) has no srcset
|
|
92
|
+
* and must be rendered with `<video src={getDefaultSrc(item)}>`. When mapping product
|
|
93
|
+
* images, branch on `item.isVideo` first, then only use createMediaSrcset on the image branch.
|
|
94
|
+
*
|
|
60
95
|
* @ai-category Image
|
|
61
96
|
* @ai-related getDefaultSrc, getThumbnailSrc, getSrc
|
|
62
97
|
*
|
|
@@ -67,12 +102,22 @@ export declare function getSrc(image: IkasImage, size: number): string;
|
|
|
67
102
|
* ```typescript
|
|
68
103
|
* import { createMediaSrcset, getDefaultSrc } from "@ikas/bp-storefront";
|
|
69
104
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
105
|
+
* // Product images can be videos — ALWAYS branch on isVideo when mapping media:
|
|
106
|
+
* {product.images.map((item, i) =>
|
|
107
|
+
* item.isVideo ? (
|
|
108
|
+
* <video key={i} src={getDefaultSrc(item)} muted playsInline preload="metadata">
|
|
109
|
+
* <track kind="captions" />
|
|
110
|
+
* </video>
|
|
111
|
+
* ) : (
|
|
112
|
+
* <img
|
|
113
|
+
* key={i}
|
|
114
|
+
* src={getDefaultSrc(item)}
|
|
115
|
+
* srcSet={createMediaSrcset(item)}
|
|
116
|
+
* sizes="(max-width: 768px) 100vw, 50vw"
|
|
117
|
+
* alt={`Product ${i + 1}`}
|
|
118
|
+
* />
|
|
119
|
+
* )
|
|
120
|
+
* )}
|
|
76
121
|
* ```
|
|
77
122
|
*/
|
|
78
123
|
export declare function createMediaSrcset(image?: IkasImage | null): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IkasStorefrontConfig as c}from"../../../packages/storefront-config/src/index.js";function n(c){return
|
|
1
|
+
import{IkasStorefrontConfig as c}from"../../../packages/storefront-config/src/index.js";function n(c){return o(c,1080)}function i(c){return o(c,180)}function o(n,i){var o;if(!(null==n?void 0:n.id))return"";var a=c.cdnUrl,t=c.videoCdnUrl;if(n.id.includes("/"))return n.isVideo?"".concat(t,"videos/").concat(n.id,"/original.mp4"):n.fileName?"".concat(a,"images/").concat(n.id,"/").concat(i,"/").concat(n.fileName,".webp"):"".concat(a,"images/").concat(n.id,"/image_").concat(i,".webp");var e=null===(o=c.merchantSettings)||void 0===o?void 0:o.merchantId;return n.isVideo?"".concat(t,"videos/").concat(e,"/").concat(n.id,"/original.mp4"):n.fileName?"".concat(a,"images/").concat(e,"/").concat(n.id,"/").concat(i,"/").concat(n.fileName,".webp"):"".concat(a,"images/").concat(e,"/").concat(n.id,"/image_").concat(i,".webp")}var a=[180,360,420,540,640,720,800,900,1080,1296,1350,1512,1728,1950,2560,3840];function t(c){return(null==c?void 0:c.id)?a.map(function(n){return"".concat(o(c,n)," ").concat(n,"w")}).join(", "):""}export{t as createMediaSrcset,n as getDefaultSrc,o as getSrc,i as getThumbnailSrc};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { BackInStockNotificationForm, IkasAppliedCampaignAmount, IkasProductAttributeMap, IkasProductPrice, IkasProductVariant } from "../../../../storefront-models/src";
|
|
1
|
+
import { BackInStockNotificationForm, IkasAppliedCampaignAmount, IkasProductAttributeMap, IkasProductPrice, IkasProductVariant, IkasTieredDiscountProduct } from "../../../../storefront-models/src";
|
|
2
2
|
/**
|
|
3
|
-
* Get the main/primary
|
|
3
|
+
* Get the main/primary media item for a product variant.
|
|
4
|
+
*
|
|
5
|
+
* The returned IkasProductImage may be a video (`isVideo === true`) — branch on it
|
|
6
|
+
* and render `<video>` instead of `<img>`.
|
|
4
7
|
*
|
|
5
8
|
* @ai-category ProductDetail, ProductList
|
|
6
9
|
* @ai-related getSelectedProductVariant
|
|
7
10
|
*
|
|
8
11
|
* @param variant - The product variant
|
|
9
|
-
* @returns The first IkasProductImage of the variant, or undefined if no images.
|
|
12
|
+
* @returns The first IkasProductImage of the variant, or undefined if no images. Check `.isVideo` to decide between `<video>` and `<img>`, and access `.image` to get the IkasImage for CDN helpers.
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
12
15
|
* ```typescript
|
|
13
|
-
* import { getProductVariantMainImage, getSelectedProductVariant, getDefaultSrc } from "@ikas/bp-storefront";
|
|
16
|
+
* import { getProductVariantMainImage, getSelectedProductVariant, getDefaultSrc, createMediaSrcset } from "@ikas/bp-storefront";
|
|
14
17
|
* import { IkasProduct } from "@ikas/bp-storefront";
|
|
15
18
|
*
|
|
16
19
|
* function ProductImage({ product }: { product: IkasProduct }) {
|
|
@@ -22,7 +25,14 @@ import { BackInStockNotificationForm, IkasAppliedCampaignAmount, IkasProductAttr
|
|
|
22
25
|
* return <div className="no-image">No image available</div>;
|
|
23
26
|
* }
|
|
24
27
|
*
|
|
25
|
-
*
|
|
28
|
+
* // Media can be a video — branch on isVideo:
|
|
29
|
+
* return productImage.isVideo ? (
|
|
30
|
+
* <video src={getDefaultSrc(image)} muted playsInline loop>
|
|
31
|
+
* <track kind="captions" />
|
|
32
|
+
* </video>
|
|
33
|
+
* ) : (
|
|
34
|
+
* <img src={getDefaultSrc(image)} srcSet={createMediaSrcset(image)} alt={product.name} />
|
|
35
|
+
* );
|
|
26
36
|
* }
|
|
27
37
|
* ```
|
|
28
38
|
*/
|
|
@@ -328,11 +338,19 @@ export declare function getProductVariantFormattedBuyPrice(variant: IkasProductV
|
|
|
328
338
|
/**
|
|
329
339
|
* Get the applied campaign discount amount details for a product variant, including type and formatted value.
|
|
330
340
|
*
|
|
341
|
+
* How the discount value is interpreted depends on `campaign.type`:
|
|
342
|
+
* - `"FIXED_AMOUNT"` → the value is an absolute money amount, returned in `formattedPrice` (e.g. "$10.00"); `discountPercentage` stays null.
|
|
343
|
+
* - `"RATIO"` → the value is a percentage, returned in `discountPercentage` (e.g. "10" for 10% off); `formattedPrice` stays null.
|
|
344
|
+
*
|
|
345
|
+
* Both fixed and tiered campaigns are supported. For a tiered-discount campaign
|
|
346
|
+
* (`campaign.fixedDiscount` is null and the discount lives in `campaign.tieredDiscount.rules`),
|
|
347
|
+
* the first tier's amount (`campaign.tieredDiscount.rules[0].amount`) is used, matching the storefront runtime.
|
|
348
|
+
*
|
|
331
349
|
* @ai-category Pricing, ProductVariant
|
|
332
350
|
* @ai-related getProductVariantCampaignPrice, getProductVariantFormattedCampaignPrice, hasProductVariantDiscount
|
|
333
351
|
*
|
|
334
352
|
* @param variant - The product variant to check for applied campaigns
|
|
335
|
-
* @returns An object
|
|
353
|
+
* @returns An object `{ type, formattedPrice, discountPercentage }` — `formattedPrice` is set for FIXED_AMOUNT campaigns, `discountPercentage` for RATIO campaigns (fixed and tiered alike); the other field stays null. Returns null if no campaign is applied.
|
|
336
354
|
*
|
|
337
355
|
* @example
|
|
338
356
|
* ```typescript
|
|
@@ -700,6 +718,78 @@ export declare function getProductVariantFormattedSellPriceWithCampaignOffers(va
|
|
|
700
718
|
* ```
|
|
701
719
|
*/
|
|
702
720
|
export declare function getProductVariantCampaignOffersDiscountPercentage(variant: IkasProductVariant): number;
|
|
721
|
+
/**
|
|
722
|
+
* Get the tiered-discount breakdown for a product variant, one entry per discount tier.
|
|
723
|
+
*
|
|
724
|
+
* A tiered discount defines multiple quantity tiers (`campaign.tieredDiscount.rules`), each with its own
|
|
725
|
+
* amount and quantity range. This resolves every tier against the variant's price and returns the
|
|
726
|
+
* per-tier sell/final prices (both raw numbers and formatted strings), matching the storefront runtime.
|
|
727
|
+
* The raw rules are `IkasProductTieredDiscountRule` (ranges may be null); this function returns the
|
|
728
|
+
* resolved `IkasTieredDiscountProduct` with normalized `{ min, max }` — use the resolved shape, not the raw rule.
|
|
729
|
+
*
|
|
730
|
+
* `sellPrice`/`finalPrice` (and their `formatted*` variants) are PER UNIT; the `*WithQuantity` fields are the
|
|
731
|
+
* tier total for buying the minimum quantity. A `"FIXED_AMOUNT"` discount is applied only to that total, so
|
|
732
|
+
* per-unit `finalPrice` equals `sellPrice` and the saving shows only in `finalPriceWithQuantity`.
|
|
733
|
+
*
|
|
734
|
+
* The discount `amount` is interpreted by `campaign.type`: `"RATIO"` treats it as a percentage,
|
|
735
|
+
* `"FIXED_AMOUNT"` as an absolute money amount subtracted from the tier total. `amount`/`type` are
|
|
736
|
+
* informational — the discount is already applied in the resolved `*Price` fields, so prefer those over
|
|
737
|
+
* recomputing it yourself.
|
|
738
|
+
*
|
|
739
|
+
* `lineItemQuantityRange.min`/`max` are normalized numbers where `0` means "unbounded". In particular
|
|
740
|
+
* `max === 0` marks an open-ended top tier (e.g. "6+" with no upper limit) — render it as "min+" rather
|
|
741
|
+
* than "min–max", and never treat `max` as a real quantity when it is `0`.
|
|
742
|
+
*
|
|
743
|
+
* Each tier's `salesChannelIds` lists the channels it targets (empty/null = all channels). Filter tiers
|
|
744
|
+
* against `IkasStorefrontConfig.salesChannelId` so only those valid for the current storefront are shown.
|
|
745
|
+
*
|
|
746
|
+
* Returns an empty array when the variant has no tiered-discount campaign, when a
|
|
747
|
+
* `PRODUCT_AND_VARIANT` filter excludes this variant, or when no tier defines a quantity range.
|
|
748
|
+
*
|
|
749
|
+
* @ai-category Pricing, ProductVariant
|
|
750
|
+
* @ai-related getProductVariantAppliedCampaignAmount, getProductVariantCampaignOffersDiscountPercentage, getProductVariantFinalPrice
|
|
751
|
+
*
|
|
752
|
+
* @param variant - The product variant to resolve tiered discounts for
|
|
753
|
+
* @returns An array of tier objects (`amount`, `lineItemQuantityRange`, `type`, sell/final prices with their formatted variants, `salesChannelIds`), or an empty array if no tiered discount applies
|
|
754
|
+
*
|
|
755
|
+
* @example
|
|
756
|
+
* ```typescript
|
|
757
|
+
* import {
|
|
758
|
+
* getProductVariantTieredDiscountProducts,
|
|
759
|
+
* getSelectedProductVariant,
|
|
760
|
+
* IkasStorefrontConfig,
|
|
761
|
+
* } from "@ikas/bp-storefront";
|
|
762
|
+
* import { IkasProduct } from "@ikas/bp-storefront";
|
|
763
|
+
*
|
|
764
|
+
* function TieredDiscountTable({ product }: { product: IkasProduct }) {
|
|
765
|
+
* const variant = getSelectedProductVariant(product);
|
|
766
|
+
* const tiers = getProductVariantTieredDiscountProducts(variant);
|
|
767
|
+
* const salesChannelId = IkasStorefrontConfig.salesChannelId;
|
|
768
|
+
*
|
|
769
|
+
* if (!tiers.length) return null;
|
|
770
|
+
*
|
|
771
|
+
* return (
|
|
772
|
+
* <ul>
|
|
773
|
+
* {tiers.map((tier, i) => {
|
|
774
|
+
* // A tier applies when it targets no channels or includes the current one
|
|
775
|
+
* const scoped =
|
|
776
|
+
* !tier.salesChannelIds?.length ||
|
|
777
|
+
* (!!salesChannelId && tier.salesChannelIds.includes(salesChannelId));
|
|
778
|
+
* if (!scoped) return null;
|
|
779
|
+
*
|
|
780
|
+
* return (
|
|
781
|
+
* <li key={i}>
|
|
782
|
+
* Buy {tier.lineItemQuantityRange.min}+ → {tier.formattedFinalPriceWithQuantity}{" "}
|
|
783
|
+
* <s>{tier.formattedSellPriceWithQuantity}</s>
|
|
784
|
+
* </li>
|
|
785
|
+
* );
|
|
786
|
+
* })}
|
|
787
|
+
* </ul>
|
|
788
|
+
* );
|
|
789
|
+
* }
|
|
790
|
+
* ```
|
|
791
|
+
*/
|
|
792
|
+
export declare function getProductVariantTieredDiscountProducts(variant: IkasProductVariant): IkasTieredDiscountProduct[];
|
|
703
793
|
/**
|
|
704
794
|
* Check if the back-in-stock notification feature is enabled for the storefront.
|
|
705
795
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as r,__generator as n}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as i}from"../../../../packages/storefront-config/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{formatCurrency as e}from"../../../../utils/currency.js";import{groupBy as u}from"../../../../utils/helper.js";import{initBackInStockNotificationForm as o}from"../../validator/back-in-stock-notification/index.js";import{getBundleProductFinalPriceWithQuantity as c,getBundleProductSellPriceWithQuantity as d,getSelectedProductVariant as l}from"../index.js";import{isProductOfferAccepted as a}from"../campaign-offer/index.js";import{getProductFromStore as s}from"../init.js";import{getIkasProductPriceFinalPrice as v}from"./price/index.js";function f(r){var n;return(null===(n=r.images)||void 0===n?void 0:n.length)?r.images[0]:void 0}function m(r){return r.stock>0||r.sellIfOutOfStock}function p(r){var n,i=u(r.attributes,"productAttributeId");return(null===(n=r.attributes)||void 0===n?void 0:n.map(function(r){var n=r.productAttributeId;if(n){var t=i[n];return(null==t?void 0:t.length)&&t[0].productAttribute?{attribute:t[0].productAttribute,values:t}:void 0}}).filter(function(r){return!!r}))||[]}function y(r){var n,i,e=t.customer,u=null==e?void 0:e.priceListRules,o=s(r.id),c=function(n){var i,t,e,u;if("CATEGORY"===n.type)return c=null===(i=n.valueList)||void 0===i?void 0:i.some(function(r){return null==o?void 0:o.categories.find(function(n){return n.id===r})});if("PRODUCT"===n.type)return c=null===(t=n.valueList)||void 0===t?void 0:t.some(function(n){return r.id===n});if("PRODUCT_BRAND"===n.type){var c=null===(e=n.valueList)||void 0===e?void 0:e.some(function(r){var n;return(null===(n=null==o?void 0:o.brand)||void 0===n?void 0:n.id)===r});return c}if("PRODUCT_TAG"===n.type){c=null===(u=n.valueList)||void 0===u?void 0:u.some(function(r){var n;return null===(n=null==o?void 0:o.tags)||void 0===n?void 0:n.find(function(n){return n.id===r})});return c}};if(u){for(var d=0,l=u;d<l.length;d++){var a=l[d];if(a.shouldMatchAllFilters?null===(n=a.filters)||void 0===n?void 0:n.every(c):null===(i=a.filters)||void 0===i?void 0:i.some(c))return a}return null}return null}function b(r){var n,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(n=r.prices)||void 0===n?void 0:n.find(function(r){return r.priceListId===u.priceListId});if(o)return o}}return null===(e=r.prices)||void 0===e?void 0:e.find(function(r){return i.priceListId?r.priceListId===i.priceListId:null===r.priceListId})}function I(r){return!!r.bundleSettings}function S(r){var n,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(n=r.baseBundlePrices)||void 0===n?void 0:n.find(function(r){return r.priceListId===u.priceListId});if(o)return o}}return(null===(e=r.baseBundlePrices)||void 0===e?void 0:e.find(function(r){return i.priceListId?r.priceListId===i.priceListId:null===r.priceListId}))||b(r)}function g(r){var n=0;if(r.bundleSettings&&r.bundleSettings.products.every(function(r){return!!r.product})){var i=S(r);n=v(i)+r.bundleSettings.products.reduce(function(r,n){return r+(n.addToBundleBasePrice?c(n):0)},0)}else n=v(b(r));var t=y(r);if(!t)return n;switch(t.valueType){case"DISCOUNT_RATE":return n*((100-t.value)/100);case"DISCOUNT_AMOUNT":return n-t.value;case"FIXED_PRICE":return t.value;default:return n}}function k(r){var n=b(r);return e(g(r),n.currency||"",n.currencySymbol||"")}function P(r){return r.bundleSettings&&r.bundleSettings.products.every(function(r){return!!r.product})?S(r).sellPrice+r.bundleSettings.products.reduce(function(r,n){return r+(n.addToBundleBasePrice?d(n):0)},0):b(r).sellPrice}function L(r){var n=b(r);return e(P(r),n.currency||"",n.currencySymbol||"")}function B(r){var n=b(r);return e(b(r).buyPrice||0,n.currency||"",n.currencySymbol||"")}function R(r){var n,i,t,u,o,c,d=s(r.id),l=b(r);if(!(null===(n=l.campaignPrice)||void 0===n?void 0:n.campaignId))return null;var a=(null===(t=null===(i=null==d?void 0:d.campaigns)||void 0===i?void 0:i.find(function(r){var n;return r.campaign.id===(null===(n=l.campaignPrice)||void 0===n?void 0:n.campaignId)}))||void 0===t?void 0:t.campaign)||null;if(!a)return null;var v={type:a.type,formattedPrice:null,discountPercentage:null};return"FIXED_AMOUNT"===a.type&&(v.formattedPrice=e((null===(u=a.fixedDiscount)||void 0===u?void 0:u.amount)||0,l.currency||"",l.currencySymbol||"")),"RATIO"===a.type&&(v.discountPercentage=(null===(c=null===(o=a.fixedDiscount)||void 0===o?void 0:o.amount)||void 0===c?void 0:c.toString())||null),v}function T(r){var n;return(null===(n=b(r).campaignPrice)||void 0===n?void 0:n.campaignPrice)||null}function A(r){var n=b(r);return e(T(r)||0,n.currency||"",n.currencySymbol||"")}function j(r){var n=g(r);return n===P(r)?null:n}function x(r){var n=b(r);return e(j(r)||0,n.currency||"",n.currencySymbol||"")}function _(r){return null!==j(r)}function h(r){var n=b(r);return e(F(r),n.currency||"",n.currencySymbol||"")}function F(r){var n=g(r),i=P(r);return _(r)?i-n:0}function O(r){return(100-100*g(r)/P(r)).toFixed(0)}function D(r){var n,i=g(r),t=s(r.id);return i+((null===(n=null==t?void 0:t.offers)||void 0===n?void 0:n.filter(function(r){return r.isSelected&&!a(r)}).reduce(function(r,n){return r+g(l(n.product))},0))||0)}function U(r){var n=D(r),i=b(r);return e(n,i.currency||"",i.currencySymbol||"")}function C(r){var n,i=P(r),t=s(r.id);return i+((null===(n=null==t?void 0:t.offers)||void 0===n?void 0:n.filter(function(r){return r.isSelected&&!a(r)}).reduce(function(r,n){return r+P(l(n.product))},0))||0)}function E(r){var n=C(r),i=b(r);return e(n,i.currency||"",i.currencySymbol||"")}function N(r){var n=D(r),i=C(r);return n!==i?Number((100-100*n/i).toFixed(0)):0}function q(r){return i.isBackInStockEnabled()}function M(r){return i.isCustomerLoginRequiredForBackInStock()}function w(i,t){return r(this,void 0,void 0,function(){var r,e;return n(this,function(n){switch(n.label){case 0:case 3:return[4,import("../../../api/product/index.js")];case 1:return[4,(0,n.sent().apiListProductBackInStockRemind)({email:{eq:t},productId:{eq:i.productId},variantId:{eq:i.id}})];case 2:return(r=n.sent())&&(null===(e=r.data)||void 0===e?void 0:e.length)?(i.isBackInStockReminderSaved=!0,[2,!1]):[3,3];case 4:return[4,(0,n.sent().apiSaveProductBackInStockRemind)({input:{email:t,productId:i.productId,variantId:i.id}})];case 5:return n.sent().isSuccess?(i.isBackInStockReminderSaved=!0,[2,!0]):(i.isBackInStockReminderSaved=!1,[2,!1]);case 6:return[2]}})})}function G(r){var n,i,t=s(r.id);if(!t)return"0";var u=b(r);if(u.unitPrice&&t.baseUnit){var o=t.baseUnit.baseAmount,c=(null===(i=null===(n=t.baseUnit)||void 0===n?void 0:n.unit)||void 0===i?void 0:i.name)||"";return"".concat(e(u.unitPrice,u.currency||"",u.currencySymbol||"")," / ").concat(o&&1!==o?o:"").concat(c)}}function X(r){return t._backInStockForms[r.id]||(t._backInStockForms[r.id]={},o(t._backInStockForms[r.id],r)),t._backInStockForms[r.id]}function Y(r){delete t._backInStockForms[r.id]}export{Y as clearProductVariantBackInStockForm,p as getGroupedAttributeValuesForVariant,R as getProductVariantAppliedCampaignAmount,y as getProductVariantB2bPriceRule,X as getProductVariantBackInStockForm,S as getProductVariantBundlePrice,N as getProductVariantCampaignOffersDiscountPercentage,T as getProductVariantCampaignPrice,F as getProductVariantDiscountAmount,O as getProductVariantDiscountPercentage,j as getProductVariantDiscountPrice,g as getProductVariantFinalPrice,D as getProductVariantFinalPriceWithCampaignOffers,B as getProductVariantFormattedBuyPrice,A as getProductVariantFormattedCampaignPrice,h as getProductVariantFormattedDiscountAmount,x as getProductVariantFormattedDiscountPrice,k as getProductVariantFormattedFinalPrice,U as getProductVariantFormattedFinalPriceWithCampaignOffers,L as getProductVariantFormattedSellPrice,E as getProductVariantFormattedSellPriceWithCampaignOffers,M as getProductVariantIsBackInStockCustomerLoginRequired,q as getProductVariantIsBackInStockEnabled,f as getProductVariantMainImage,b as getProductVariantPrice,P as getProductVariantSellPrice,C as getProductVariantSellPriceWithCampaignOffers,G as getProductVariantUnitPriceText,I as hasBundleSettings,_ as hasProductVariantDiscount,m as hasProductVariantStock,w as saveProductVariantBackInStockReminder};
|
|
1
|
+
import{__awaiter as n,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as i}from"../../../../packages/storefront-config/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{formatCurrency as e}from"../../../../utils/currency.js";import{groupBy as u}from"../../../../utils/helper.js";import{initBackInStockNotificationForm as o}from"../../validator/back-in-stock-notification/index.js";import{getBundleProductFinalPriceWithQuantity as c,getBundleProductSellPriceWithQuantity as l,getSelectedProductVariant as d}from"../index.js";import{isProductOfferAccepted as a}from"../campaign-offer/index.js";import{getProductFromStore as v}from"../init.js";import{getIkasProductPriceFinalPrice as s}from"./price/index.js";function f(n){var r;return(null===(r=n.images)||void 0===r?void 0:r.length)?n.images[0]:void 0}function m(n){return n.stock>0||n.sellIfOutOfStock}function p(n){var r,i=u(n.attributes,"productAttributeId");return(null===(r=n.attributes)||void 0===r?void 0:r.map(function(n){var r=n.productAttributeId;if(r){var t=i[r];return(null==t?void 0:t.length)&&t[0].productAttribute?{attribute:t[0].productAttribute,values:t}:void 0}}).filter(function(n){return!!n}))||[]}function y(n){var r,i,e=t.customer,u=null==e?void 0:e.priceListRules,o=v(n.id),c=function(r){var i,t,e,u;if("CATEGORY"===r.type)return c=null===(i=r.valueList)||void 0===i?void 0:i.some(function(n){return null==o?void 0:o.categories.find(function(r){return r.id===n})});if("PRODUCT"===r.type)return c=null===(t=r.valueList)||void 0===t?void 0:t.some(function(r){return n.id===r});if("PRODUCT_BRAND"===r.type){var c=null===(e=r.valueList)||void 0===e?void 0:e.some(function(n){var r;return(null===(r=null==o?void 0:o.brand)||void 0===r?void 0:r.id)===n});return c}if("PRODUCT_TAG"===r.type){c=null===(u=r.valueList)||void 0===u?void 0:u.some(function(n){var r;return null===(r=null==o?void 0:o.tags)||void 0===r?void 0:r.find(function(r){return r.id===n})});return c}};if(u){for(var l=0,d=u;l<d.length;l++){var a=d[l];if(a.shouldMatchAllFilters?null===(r=a.filters)||void 0===r?void 0:r.every(c):null===(i=a.filters)||void 0===i?void 0:i.some(c))return a}return null}return null}function I(n){var r,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(r=n.prices)||void 0===r?void 0:r.find(function(n){return n.priceListId===u.priceListId});if(o)return o}}return null===(e=n.prices)||void 0===e?void 0:e.find(function(n){return i.priceListId?n.priceListId===i.priceListId:null===n.priceListId})}function S(n){return!!n.bundleSettings}function b(n){var r,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(r=n.baseBundlePrices)||void 0===r?void 0:r.find(function(n){return n.priceListId===u.priceListId});if(o)return o}}return(null===(e=n.baseBundlePrices)||void 0===e?void 0:e.find(function(n){return i.priceListId?n.priceListId===i.priceListId:null===n.priceListId}))||I(n)}function g(n){var r=0;if(n.bundleSettings&&n.bundleSettings.products.every(function(n){return!!n.product})){var i=b(n);r=s(i)+n.bundleSettings.products.reduce(function(n,r){return n+(r.addToBundleBasePrice?c(r):0)},0)}else r=s(I(n));var t=y(n);if(!t)return r;switch(t.valueType){case"DISCOUNT_RATE":return r*((100-t.value)/100);case"DISCOUNT_AMOUNT":return r-t.value;case"FIXED_PRICE":return t.value;default:return r}}function P(n){var r=I(n);return e(g(n),r.currency||"",r.currencySymbol||"")}function k(n){return n.bundleSettings&&n.bundleSettings.products.every(function(n){return!!n.product})?b(n).sellPrice+n.bundleSettings.products.reduce(function(n,r){return n+(r.addToBundleBasePrice?l(r):0)},0):I(n).sellPrice}function R(n){var r=I(n);return e(k(n),r.currency||"",r.currencySymbol||"")}function L(n){var r=I(n);return e(I(n).buyPrice||0,r.currency||"",r.currencySymbol||"")}function D(n){var r,i,t,u,o,c,l,d,a,s,f,m,p=v(n.id),y=I(n);if(!(null===(r=y.campaignPrice)||void 0===r?void 0:r.campaignId))return null;var S=(null===(t=null===(i=null==p?void 0:p.campaigns)||void 0===i?void 0:i.find(function(n){var r;return n.campaign.id===(null===(r=y.campaignPrice)||void 0===r?void 0:r.campaignId)}))||void 0===t?void 0:t.campaign)||null;if(!S)return null;var b={type:S.type,formattedPrice:null,discountPercentage:null},g=(null==S?void 0:S.tieredDiscount)&&(null===(u=null==S?void 0:S.tieredDiscount)||void 0===u?void 0:u.rules)&&(null===(c=null===(o=null==S?void 0:S.tieredDiscount)||void 0===o?void 0:o.rules)||void 0===c?void 0:c.length)>0&&(null===(a=null===(d=null===(l=null==S?void 0:S.tieredDiscount)||void 0===l?void 0:l.rules)||void 0===d?void 0:d[0])||void 0===a?void 0:a.amount);return"FIXED_AMOUNT"===S.type&&(b.formattedPrice=e(S.fixedDiscount?(null===(s=S.fixedDiscount)||void 0===s?void 0:s.amount)||0:g||0,y.currency||"",y.currencySymbol||"")),"RATIO"===S.type&&(b.discountPercentage=S.fixedDiscount?(null===(m=null===(f=S.fixedDiscount)||void 0===f?void 0:f.amount)||void 0===m?void 0:m.toString())||null:g?g.toString():null),b}function h(n){var r;return(null===(r=I(n).campaignPrice)||void 0===r?void 0:r.campaignPrice)||null}function A(n){var r=I(n);return e(h(n)||0,r.currency||"",r.currencySymbol||"")}function B(n){var r=g(n);return r===k(n)?null:r}function T(n){var r=I(n);return e(B(n)||0,r.currency||"",r.currencySymbol||"")}function x(n){return null!==B(n)}function _(n){var r=I(n);return e(F(n),r.currency||"",r.currencySymbol||"")}function F(n){var r=g(n),i=k(n);return x(n)?i-r:0}function O(n){return(100-100*g(n)/k(n)).toFixed(0)}function j(n){var r,i=g(n),t=v(n.id);return i+((null===(r=null==t?void 0:t.offers)||void 0===r?void 0:r.filter(function(n){return n.isSelected&&!a(n)}).reduce(function(n,r){return n+g(d(r.product))},0))||0)}function C(n){var r=j(n),i=I(n);return e(r,i.currency||"",i.currencySymbol||"")}function U(n){var r,i=k(n),t=v(n.id);return i+((null===(r=null==t?void 0:t.offers)||void 0===r?void 0:r.filter(function(n){return n.isSelected&&!a(n)}).reduce(function(n,r){return n+k(d(r.product))},0))||0)}function Q(n){var r=U(n),i=I(n);return e(r,i.currency||"",i.currencySymbol||"")}function E(n){var r=j(n),i=U(n);return r!==i?Number((100-100*r/i).toFixed(0)):0}function N(n){var r,i,t,u=v(n.id),o=I(n),c=null===(i=null===(r=null==u?void 0:u.campaigns)||void 0===r?void 0:r.find(function(n){return!!n.campaign.tieredDiscount}))||void 0===i?void 0:i.campaign,l=null==c?void 0:c.tieredDiscount;if(!c||!l)return[];var d=null===(t=l.filters)||void 0===t?void 0:t.find(function(n){return"PRODUCT_AND_VARIANT"===n.type});if(d&&!d.idList.map(function(n){return n.replace("p:","").replace("v:","")}).some(function(r){return n.id===r||n.productId===r}))return[];if(l.rules.every(function(n){return!n.lineItemQuantityRange}))return[];var a=k(n),s=g(n);return l.rules.map(function(n){var r,i,t,u,l="SELL_PRICE"===c.applicablePrice?a:s,d=l*((null===(r=n.lineItemQuantityRange)||void 0===r?void 0:r.min)||1),v="RATIO"===c.type?l-l*(n.amount||1)/100:l,f=v*((null===(i=n.lineItemQuantityRange)||void 0===i?void 0:i.min)||1)-("FIXED_AMOUNT"===c.type&&n.amount||0);return{amount:n.amount,lineItemQuantityRange:{min:(null===(t=n.lineItemQuantityRange)||void 0===t?void 0:t.min)||0,max:(null===(u=n.lineItemQuantityRange)||void 0===u?void 0:u.max)||0},type:c.type,sellPrice:l,finalPrice:v,sellPriceWithQuantity:d,finalPriceWithQuantity:f,formattedSellPrice:e(l,o.currency||"",o.currencySymbol||""),formattedSellPriceWithQuantity:e(d,o.currency||"",o.currencySymbol||""),formattedFinalPrice:e(v,o.currency||"",o.currencySymbol||""),formattedFinalPriceWithQuantity:e(f,o.currency||"",o.currencySymbol||""),salesChannelIds:c.salesChannelIds}})}function q(n){return i.isBackInStockEnabled()}function M(n){return i.isCustomerLoginRequiredForBackInStock()}function W(i,t){return n(this,void 0,void 0,function(){var n,e;return r(this,function(r){switch(r.label){case 0:case 3:return[4,import("../../../api/product/index.js")];case 1:return[4,(0,r.sent().apiListProductBackInStockRemind)({email:{eq:t},productId:{eq:i.productId},variantId:{eq:i.id}})];case 2:return(n=r.sent())&&(null===(e=n.data)||void 0===e?void 0:e.length)?(i.isBackInStockReminderSaved=!0,[2,!1]):[3,3];case 4:return[4,(0,r.sent().apiSaveProductBackInStockRemind)({input:{email:t,productId:i.productId,variantId:i.id}})];case 5:return r.sent().isSuccess?(i.isBackInStockReminderSaved=!0,[2,!0]):(i.isBackInStockReminderSaved=!1,[2,!1]);case 6:return[2]}})})}function X(n){var r,i,t=v(n.id);if(!t)return"0";var u=I(n);if(u.unitPrice&&t.baseUnit){var o=t.baseUnit.baseAmount,c=(null===(i=null===(r=t.baseUnit)||void 0===r?void 0:r.unit)||void 0===i?void 0:i.name)||"";return"".concat(e(u.unitPrice,u.currency||"",u.currencySymbol||"")," / ").concat(o&&1!==o?o:"").concat(c)}}function w(n){return t._backInStockForms[n.id]||(t._backInStockForms[n.id]={},o(t._backInStockForms[n.id],n)),t._backInStockForms[n.id]}function G(n){delete t._backInStockForms[n.id]}export{G as clearProductVariantBackInStockForm,p as getGroupedAttributeValuesForVariant,D as getProductVariantAppliedCampaignAmount,y as getProductVariantB2bPriceRule,w as getProductVariantBackInStockForm,b as getProductVariantBundlePrice,E as getProductVariantCampaignOffersDiscountPercentage,h as getProductVariantCampaignPrice,F as getProductVariantDiscountAmount,O as getProductVariantDiscountPercentage,B as getProductVariantDiscountPrice,g as getProductVariantFinalPrice,j as getProductVariantFinalPriceWithCampaignOffers,L as getProductVariantFormattedBuyPrice,A as getProductVariantFormattedCampaignPrice,_ as getProductVariantFormattedDiscountAmount,T as getProductVariantFormattedDiscountPrice,P as getProductVariantFormattedFinalPrice,C as getProductVariantFormattedFinalPriceWithCampaignOffers,R as getProductVariantFormattedSellPrice,Q as getProductVariantFormattedSellPriceWithCampaignOffers,M as getProductVariantIsBackInStockCustomerLoginRequired,q as getProductVariantIsBackInStockEnabled,f as getProductVariantMainImage,I as getProductVariantPrice,k as getProductVariantSellPrice,U as getProductVariantSellPriceWithCampaignOffers,N as getProductVariantTieredDiscountProducts,X as getProductVariantUnitPriceText,S as hasBundleSettings,x as hasProductVariantDiscount,m as hasProductVariantStock,W as saveProductVariantBackInStockReminder};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../../../packages/storefront-config/src/index.js";import i from'./../../../ext/lodash/cloneDeep.js';import{I18n as a}from"../../../i18n/index.js";import{Router as o,withRoutePrefix as s}from"../../../router/index.js";import{customerStore as u}from"../../../stores/customer/index.js";import{isClient as d,isBackNavigation as l,getQueryParams as c,debounce as f,stringToSlug as v,stringifyQueryParams as p}from"../../../utils/helper.js";import{setSavedLastViewedProductsResponse as g,getLastViewedProducts as I,waitForCustomerStoreInit as E}from"../../stores/customer/index.js";import{getIkasFilterCategorySlug as C,getIkasFilterCategoryHref as S}from"../filter-category/index.js";import{getFilterValueList as A,clearFilter as y,selectFilterValue as T,onNumberRangeFilterOptionClick as R,getFilterKeyList as D,applyQueryParamForFilter as h,initIkasProductFilter as _,isCustomValueFilter as m}from"../product/filter/index.js";import{getProductVariantPrice as b,hasProductVariantStock as N}from"../product/variant/index.js";var L;function O(t){var r=e({data:[],limit:10,page:1,count:0,isInitialized:!1,isLoading:!1,type:"ALL",sort:"DEFAULT",searchKeyword:"",pageType:"CATEGORY",category:null,brand:null,productListPropValue:{id:"",productIds:[],initialLimit:10,productListType:"ALL"}},t);return function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL"].includes(e.type))switch(e.pageSpecificData.orderType){case"HIGHEST_DISCOUNT_RATIO":e.sort="DECRASING_DISCOUNT";break;case"LOWEST_DISCOUNT_RATIO":e.sort="INCREASING_DISCOUNT";break;case"HIGHEST_PRICE":e.sort="DECREASING_PRICE";break;case"LOWEST_PRICE":e.sort="INCREASING_PRICE";break;case"NEWEST":e.sort="LAST_ADDED";break;case"OLDEST":e.sort="FIRST_ADDED";break;case"MANUALLY":e.sort="FEATURED"}}(r),z(r),J(r),r}function P(e){var t;if(d()&&(!l()||!o.isFromBFCache)){!function(e){var t=c(),r=null==t?void 0:t.get("page");if(r){var n=parseInt(r);isNaN(n)||(e.page=n,e.infiniteScrollPage=n)}}(e);if(["CATEGORY","BRAND","SEARCH"].includes(e.pageType)&&location.search&&U(e)&&((null===(t=e.productListPropValue)||void 0===t?void 0:t.usePageFilter)||"SEARCH"===e.type))le(e,c(),e.page>1);else e.page>1?le(e,void 0,!0):k(e)?le(e):Re(e)}}function G(e,t){t!==e.searchKeyword&&(e.searchKeyword=t,_e(e),me(e))}function U(e){return"ALL"===e.type||"CATEGORY"===e.type}function V(e){var t,r;return(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))||!!e.searchKeyword||"CATEGORY"!==e.pageType&&(!!e.filterCategoryId||!!(null===(r=e.filterCategories)||void 0===r?void 0:r.some(function(e){return e.isSelected})))}function w(e){return"STATIC"===e.type}function F(e){return"DISCOUNTED"===e.type}function j(e){return"RECOMMENDED"===e.type}function k(e){return"LAST_VIEWED"===e.type}function x(e){return"RELATED_PRODUCTS"===e.type}function H(e){return"VIEWED_TOGETHER"===e.type}function W(e){return"PURCHASED_TOGETHER"===e.type}function K(e){return"SEARCH"===e.type}function B(e){return!(w(e)||F(e)||j(e)||!e.minPage)&&e.minPage>1}function Y(e){return!(w(e)||F(e)||j(e))&&e.page*e.limit<e.count}function Z(e){var t;return(null===(t=e.filterCategories)||void 0===t?void 0:t.filter(function(e){return 0!==e.resultCount}))||[]}function M(e){var t;return!!e.searchKeyword||!!(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))}function q(e){var t;return"MANUALLY"===(null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL","CATEGORY"].includes(e.type)}function z(e){var t=V(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function J(e){var t=w(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function X(e){e._enableSuggestions=!0}function Q(e){var t={};return e.categoryId&&(t.categoryId=e.categoryId),e.brandId&&(t.brandId=e.brandId),Object.keys(t).length?s("/search?suggestion=".concat(encodeURIComponent(JSON.stringify(t)))):s("/search")}function $(i,a,o,s){return t(this,void 0,void 0,function(){var t,u,d,l,f,v,p,g,I,E,C,S,y,T,R,D;return r(this,function(r){switch(r.label){case 0:return t=[],u=[],null===(S=i.filters)||void 0===S||S.forEach(function(e){var r=A(e);r.length&&t.push({id:e.id,type:e.type,displayType:e.displayType,valueList:r}),e.isFacetFilter&&u.push({id:e.id,type:e.type,displayType:e.displayType})}),d=c(),(l=null==d?void 0:d.get("suggestion"))&&(f=JSON.parse(decodeURIComponent(l)),(v=f.brandId)&&((p=null===(y=i.filters)||void 0===y?void 0:y.find(function(e){return"brand"===e.id&&"BRAND"===e.type}))&&(g=null===(T=p.values)||void 0===T?void 0:T.find(function(e){return e.id===v}))&&h(p,g.name),t.push({id:"brand",type:"BRAND",displayType:"BOX",valueList:[v]})),f.categoryId&&(i.filterCategoryId=f.categoryId),i.searchKeyword=f.term),I=null===(R=i.filterCategories)||void 0===R?void 0:R.filter(function(e){return e.isSelected}).map(function(e){return e.id}),E=function(e){var t,r;switch(e.sort){case"INCREASING_PRICE":t="ASC",r="PRICE";break;case"DECREASING_PRICE":t="DESC",r="PRICE";break;case"FIRST_ADDED":t="ASC",r="CREATED_AT";break;case"LAST_ADDED":t="DESC",r="CREATED_AT";break;case"INCREASING_DISCOUNT":t="ASC",r="DISCOUNT_RATIO";break;case"DECRASING_DISCOUNT":t="DESC",r="DISCOUNT_RATIO";break;case"FEATURED":if(K(e))return;t="ASC",r="MANUAL_SORT";break;case"DEFAULT":t=void 0,r=void 0;break;case"AVERAGE_RATING":t="DESC",r="AVERAGE_RATING";break;case"REVIEW_COUNT":t="DESC",r="REVIEW_COUNT";break;case"SALE_COUNT":t="DESC",r="SALE_COUNT";break;case"A_Z":t="ASC",r="NAME";break;case"Z_A":t="DESC",r="NAME"}if(t&&r)return{direction:t,type:r}}(i),j(i)&&i.recommendedProductData?[4,import("../../api/product/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,brandIds:i.recommendedProductData.brandIds,categoryIds:i.recommendedProductData.categoryIds,locale:n.getCurrentLocale()})];case 2:case 5:case 8:case 11:case 14:return[2,r.sent()];case 3:return x(i)&&i.relatedProductData?[4,import("../../api/product/index.js")]:[3,6];case 4:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,productId:i.relatedProductData.productId,brandIds:i.relatedProductData.brandIds,categoryIds:i.relatedProductData.categoryIds,locale:n.getCurrentLocale()})];case 6:return H(i)&&i.viewedTogetherProductData?[4,import("../../api/product/index.js")]:[3,9];case 7:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"VIEWED_TOGETHER",productIds:i.viewedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 9:return W(i)&&i.purchasedTogetherProductData?[4,import("../../api/product/index.js")]:[3,12];case 10:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"PURCHASED_TOGETHER",productIds:i.purchasedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 12:return C={input:e(e(e(e({page:a,perPage:o},i._enableSuggestions?{enableSuggestions:i._enableSuggestions}:{}),{productIdList:w(i)?null===(D=i.productListPropValue.productIds)||void 0===D?void 0:D.map(function(e){return e.productId}):s,filterList:t,facetList:u}),i.baseCategoryIdList?{baseCategoryIdList:i.baseCategoryIdList}:{}),{brandId:"BRAND"===i.pageType&&"SEARCH"!==i.type?i.filterBrandId:void 0,categoryIdList:I&&I.length?I:i.filterCategoryId?[i.filterCategoryId]:void 0,priceListId:n.priceListId,salesChannelId:n.salesChannelId,query:i.searchKeyword,order:E?[E]:[],showStockOption:n.stockPreference||"SHOW_ALL"})},[4,import("../../api/product/index.js")];case 13:return[4,(0,r.sent().apiSearchProducts)(C,i.excludedFields||[])]}})})}function ee(e){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,r.sent().apiGetProductFilterData)({categoryId:e.filterCategoryId?e.filterCategoryId:void 0,locale:n.getCurrentLocale()})];case 2:return t=r.sent(),e.filters=null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.filters.map(function(e){return _(e)}),e.filterCategories=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.categories,ye(e),e.disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,"CATEGORY"!==e.pageType&&e.filterCategoryId&&(i=null===(u=e.filterCategories)||void 0===u?void 0:u.find(function(t){return t.id===e.filterCategoryId}))&&(i.isSelected=!0),e.filters&&e.filters.sort(function(e,t){return e.order>t.order?1:-1}),[2]}})})}function te(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,le(e)];case 1:return t=r.sent(),["CATEGORY","BRAND","SEARCH"].includes(e.pageType)?(t&&ne(e),[2]):[2]}})})}function re(e){var t,r,n,i={};if(null===(t=e.filters)||void 0===t||t.forEach(function(e){var t=D(e);t.length&&(i[v(e.name)]=t)}),e.searchKeyword&&(i.s=e.searchKeyword),e.sort&&(i.o=be[e.sort]),e.baseCategoryIdList&&(i.bc=e.baseCategoryIdList),e.suggestionCategoryId&&(i.suggestionCategoryId=e.suggestionCategoryId),e.infiniteScrollPage?i.page=e.infiniteScrollPage:i.page=e.page,"CATEGORY"!==e.pageType){var a=null===(r=e.filterCategories)||void 0===r?void 0:r.filter(function(e){return e.isSelected});if(!!(null==a?void 0:a.length))i.c=null==a?void 0:a.map(function(e){return C(e)});else if(e.filterCategoryId){var o=null===(n=e.filterCategories)||void 0===n?void 0:n.find(function(t){return t.id===e.filterCategoryId}),s=o?C(o):void 0;s&&(i.c=s)}}return p(i,{arrayFormat:"comma"})}function ne(e){if(d()&&!K(e)&&!n.isEditor){var t=re(e),r=s("".concat(location.pathname).concat(t?"?"+t:""));o.navigate(r,!0)}}function ie(e){var t,r;null===(t=e.filters)||void 0===t||t.forEach(function(e){return y(e)}),e.searchKeyword="","CATEGORY"!==e.pageType&&(e.filterCategoryId=void 0),null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){return e.isSelected=!1}),te(e)}function ae(e,t){y(t),te(e)}function oe(e,t,r){T(t,r),te(e)}function se(e,t,r){R(t,r),te(e)}function ue(e){var t,r=null===(t=e.filters)||void 0===t?void 0:t.filter(function(e){var t;return null===(t=e.values)||void 0===t?void 0:t.some(function(e){return e.isSelected})});return null==r?void 0:r.map(function(e){var t,r;return e.numberRange?{filter:e,values:[e.numberRange.from+"-"+e.numberRange.to],commaSeperatedValues:e.numberRange.from+"-"+e.numberRange.to}:e.numberRangeListOptions?{filter:e,values:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}),commaSeperatedValues:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}).join(",")}:{filter:e,values:(null===(t=e.values)||void 0===t?void 0:t.filter(function(e){return e.isSelected}).map(function(e){return e.name}))||[],commaSeperatedValues:(null===(r=e.values)||void 0===r?void 0:r.filter(function(e){return e.isSelected}).map(function(e){return e.name}).join(","))||""}})}function de(e){return e.variants[0]}function le(e,n,a){return t(this,void 0,void 0,function(){var t,o,s,l,c,f,v,p,S,A,y,T,R,D,_,b;return r(this,function(r){switch(r.label){case 0:e.isLoading=!0,t=Date.now(),e.fetchRequestTime=t,r.label=1;case 1:return r.trys.push([1,14,15,16]),o=a?e.page:1,s=e.limit,!U(e)||e.filters?[3,3]:[4,ee(e)];case 2:r.sent(),r.label=3;case 3:return function(e,t){var r;try{null==t||t.forEach(function(t,r){var n,i=null===(n=e.filters)||void 0===n?void 0:n.find(function(e){return e.key===r});i&&h(i,t)});var n=null==t?void 0:t.get("s");n&&(e.searchKeyword=n);var i=null==t?void 0:t.get("o");if(i){var a=parseInt(i),o=Object.entries(be).find(function(e){return e[1]===a});o&&(e.sort=o[0])}if("CATEGORY"!==e.pageType){var s=null==t?void 0:t.get("c"),u=null==s?void 0:s.split(",");u&&u.length&&(null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){e.isSelected=u.some(function(t){return t===C(e)})}))}if("SEARCH"===e.pageType){var d=null==t?void 0:t.get("bc"),l=null==d?void 0:d.split(",");l&&(e.baseCategoryIdList=l);var c=null==t?void 0:t.get("suggestion");if(c){var f=JSON.parse(decodeURIComponent(c)).categoryId;f&&(e.suggestionCategoryId=f)}var v=null==t?void 0:t.get("suggestionCategoryId");v&&(e.suggestionCategoryId=v,e.filterCategoryId=v)}}catch(e){console.log(e)}}(e,n),[4,fe(e)];case 4:return r.sent(),K(e)&&!M(e)?(e.data=[],e.page=1,e.minPage=1,e.count=0,e.isInitialized=!0,[2,!0]):(l=void 0,c=!1,w(e)?(o=void 0,s=200,[3,10]):[3,5]);case 5:return F(e)||j(e)?(o=1,s=10,[3,10]):[3,6];case 6:return k(e)?d()?[4,E(u)]:[3,9]:[3,10];case 7:return r.sent(),[4,I(u)];case 8:return(f=r.sent())&&f.length?(l=f.map(function(e){return e.productId}),c=u.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return c?(p=u._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,$(e,o||1,s||10,l)];case 12:p=r.sent(),r.label=13;case 13:return(v=p)&&e.fetchRequestTime===t?(S=[],!c&&k(e)&&g(u,v),w(e)||k(e)?(A=w(e)?e.productListPropValue.productIds:u._lastViewedProducts,S=(null==A?void 0:A.map(function(e){var t,r,n=null===(r=null===(t=v.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.productId}),i=null==n?void 0:n.variants.find(function(t){return t.id===e.variantId});if((null==i?void 0:i.isActive)&&N(i)||(i=null==n?void 0:n.variants.find(function(e){return e.isActive&&N(e)})),n&&i)return n.selectedVariantValues=i.variantValues,n}).filter(function(e){return!!e}))||[]):S=(null===(R=null===(T=v.data)||void 0===T?void 0:T.data)||void 0===R?void 0:R.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}))||[],null===(D=e.filters)||void 0===D||D.forEach(function(e){var t,r;if(void 0===e.isCollapsed){var n=!1;(!1===(null===(t=e.settings)||void 0===t?void 0:t.showCollapsedOnMobile)&&d()&&window.innerWidth<768||!1===(null===(r=e.settings)||void 0===r?void 0:r.showCollapsedOnDesktop))&&(n=!0),e.isCollapsed=!n}}),function(e,t){var r,n,a=i(e);null===(r=a.filters)||void 0===r||r.forEach(function(e){var r,n,i,a=null==t?void 0:t.find(function(t){return t.id===e.id});a?null===(r=e.values)||void 0===r||r.forEach(function(t){var r=a.values.find(function(e){return e.id===t.id});r?t.resultCount=r.count:m(e)?t.resultCount=null:t.resultCount=0}):m(e)?null===(n=e.values)||void 0===n||n.forEach(function(e){return e.resultCount=null}):null===(i=e.values)||void 0===i||i.forEach(function(e){return e.resultCount=0})});var o=null==t?void 0:t.find(function(e){return"category"===e.id});o&&(null===(n=a.filterCategories)||void 0===n||n.forEach(function(e){var t=o.values.find(function(t){return t.id===e.id});e.resultCount=t?t.count:0})),e.filters=a.filters,e.filterCategories=a.filterCategories,ye(e)}(e,null===(_=v.data)||void 0===_?void 0:_.facets),e.data=S,e.count=(null===(b=v.data)||void 0===b?void 0:b.count)||0,e.isInitialized=!0,e.page=o||1,e.minPage=e.page,v.data&&"suggestions"in v.data&&(e.suggestions=v.data.suggestions),z(e),J(e),a||(e.infiniteScrollPage=null),Re(e),[2,!0]):[2];case 14:return y=r.sent(),console.log(y),[3,16];case 15:return t===e.fetchRequestTime&&(e.isLoading=!1),[7];case 16:return[2]}})})}function ce(e){e.isCollapsed=!e.isCollapsed}function fe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u,d,l,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,13,,14]),e.productListPropValue.category?[4,import("../../api/category/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiListCategory)({id:{eq:e.productListPropValue.category}})];case 2:return t=r.sent(),e.category=(null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o[0])||null,[3,7];case 3:return e.productListPropValue.usePageFilter&&"CATEGORY"===e.pageType&&e.pageSpecificData?(e.category=e.pageSpecificData,[3,7]):[3,4];case 4:return e.filterCategoryId?[4,import("../../api/category/index.js")]:[3,7];case 5:return[4,(0,r.sent().apiListCategory)({id:{eq:e.filterCategoryId}})];case 6:t=r.sent(),e.category=(null===(u=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===u?void 0:u[0])||null,r.label=7;case 7:return e.productListPropValue.usePageFilter&&"BRAND"===e.pageType&&e.pageSpecificData?(e.brand=e.pageSpecificData,[3,12]):[3,8];case 8:return e.filterBrandId?e.filterBrandId!==(null===(d=e.pageSpecificData)||void 0===d?void 0:d.id)?[3,9]:(e.brand=e.pageSpecificData,[3,12]):[3,12];case 9:return[4,import("../../api/brand/index.js")];case 10:return[4,(0,r.sent().apiListProductBrand)({id:{eq:e.filterBrandId}})];case 11:n=r.sent(),e.brand=(null===(c=null===(l=n.data)||void 0===l?void 0:l.data)||void 0===c?void 0:c[0])||null,r.label=12;case 12:return[3,14];case 13:return i=r.sent(),console.error(i),[3,14];case 14:return[2]}})})}function ve(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!B(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),t=e.minPage-1,[4,$(e,t,e.limit)];case 2:return(n=r.sent())?(i=null===(s=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=(null==i?void 0:i.concat(e.data))||e.data,e.count=(null===(u=n.data)||void 0===u?void 0:u.count)||e.count,e.minPage=t,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function pe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!Y(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,e.page+1,e.limit)];case 2:return(t=r.sent())?(n=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=e.data.concat(n||[]),e.count=(null===(s=t.data)||void 0===s?void 0:s.count)||e.count,e.page=e.page+1,z(e),J(e),ne(e),[3,5]):[2];case 3:return i=r.sent(),console.log(i),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function ge(e,n){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(e.isLoading||w(e)||F(e)||j(e)||k(e)||x(e)||H(e)||W(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,n,e.limit)];case 2:return(t=r.sent())?(i=null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=i||[],e.count=(null===(u=t.data)||void 0===u?void 0:u.count)||0,e.page=n,e.minPage=n,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function Ie(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.sort=n,[4,le(e)];case 1:return t.sent()&&ne(e),[2]}})})}function Ee(e){return Ce(e,e.sort)}function Ce(e,t){switch(t){case"INCREASING_PRICE":return a.translate("sort_type.increasing_price");case"DECREASING_PRICE":return a.translate("sort_type.decreasing_price");case"LAST_ADDED":return a.translate("sort_type.last_added");case"FIRST_ADDED":return a.translate("sort_type.first_added");case"INCREASING_DISCOUNT":return a.translate("sort_type.increasing_discount");case"DECRASING_DISCOUNT":return a.translate("sort_type.decreasing_discount");case"FEATURED":return a.translate("sort_type.featured");case"DEFAULT":return a.translate("sort_type.default");case"AVERAGE_RATING":return a.translate("sort_type.average_rating");case"REVIEW_COUNT":return a.translate("sort_type.review_count");case"SALE_COUNT":return a.translate("sort_type.sale_count");case"A_Z":return a.translate("sort_type.a_z");case"Z_A":return a.translate("sort_type.z_a")}}function Se(e){var t,r,n,i,a,o,s,u,d=[];return(null===(t=e.disabledSortTypes)||void 0===t?void 0:t.includes("NAME"))||(d.push({label:Ce(0,"A_Z"),value:"A_Z",isSelected:"A_Z"===e.sort}),d.push({label:Ce(0,"Z_A"),value:"Z_A",isSelected:"Z_A"===e.sort})),(null===(r=e.disabledSortTypes)||void 0===r?void 0:r.includes("PRICE"))||(d.push({label:Ce(0,"INCREASING_PRICE"),value:"INCREASING_PRICE",isSelected:"INCREASING_PRICE"===e.sort}),d.push({label:Ce(0,"DECREASING_PRICE"),value:"DECREASING_PRICE",isSelected:"DECREASING_PRICE"===e.sort})),(null===(n=e.disabledSortTypes)||void 0===n?void 0:n.includes("CREATED_AT"))||(d.push({label:Ce(0,"LAST_ADDED"),value:"LAST_ADDED",isSelected:"LAST_ADDED"===e.sort}),d.push({label:Ce(0,"FIRST_ADDED"),value:"FIRST_ADDED",isSelected:"FIRST_ADDED"===e.sort})),(null===(i=e.disabledSortTypes)||void 0===i?void 0:i.includes("DISCOUNT_RATIO"))||(d.push({label:Ce(0,"INCREASING_DISCOUNT"),value:"INCREASING_DISCOUNT",isSelected:"INCREASING_DISCOUNT"===e.sort}),d.push({label:Ce(0,"DECRASING_DISCOUNT"),value:"DECRASING_DISCOUNT",isSelected:"DECRASING_DISCOUNT"===e.sort})),(null===(a=e.disabledSortTypes)||void 0===a?void 0:a.includes("MANUAL_SORT"))||d.push({label:Ce(0,"FEATURED"),value:"FEATURED",isSelected:"FEATURED"===e.sort}),(null===(o=e.disabledSortTypes)||void 0===o?void 0:o.includes("AVERAGE_RATING"))||d.push({label:Ce(0,"AVERAGE_RATING"),value:"AVERAGE_RATING",isSelected:"AVERAGE_RATING"===e.sort}),(null===(s=e.disabledSortTypes)||void 0===s?void 0:s.includes("REVIEW_COUNT"))||d.push({label:Ce(0,"REVIEW_COUNT"),value:"REVIEW_COUNT",isSelected:"REVIEW_COUNT"===e.sort}),(null===(u=e.disabledSortTypes)||void 0===u?void 0:u.includes("SALE_COUNT"))||d.push({label:Ce(0,"SALE_COUNT"),value:"SALE_COUNT",isSelected:"SALE_COUNT"===e.sort}),d}function Ae(e,i,a){return t(this,void 0,void 0,function(){var t,s,u;return r(this,function(r){switch(r.label){case 0:return a?(null===(u=e.filterCategories)||void 0===u||u.forEach(function(e){e.id===i.id&&(e.isSelected=!e.isSelected)}),[4,te(e)]):[3,2];case 1:return r.sent(),[3,3];case 2:n.isEditor||(t=re(e),s=S(i)+(t?"?"+t:""),o.navigate(s)),r.label=3;case 3:return[2]}})})}function ye(e){var t;null===(t=e.filterCategories)||void 0===t||t.forEach(function(e){e.image=e.imageId?{id:e.imageId,isVideo:!1}:null})}function Te(e,t){if(e.infiniteScrollPage!==t){e.infiniteScrollPage=t;var r=re(e);o.navigate("".concat(location.pathname).concat(r?"?"+r:""),!0)}}function Re(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.searchKeyword&&e.data.length?[4,import("../../../analytics/analytics-functions/viewSearchResults.js")]:[3,2];case 1:return(0,t.sent().anl_viewSearchResults)(e.searchKeyword,e.data),[3,4];case 2:return e.data.length&&"ALL"===e.type?[4,import("../../../analytics/analytics-functions/viewListing.js")]:[3,4];case 3:(0,t.sent().anl_viewListing)(e.data),t.label=4;case 4:return[2]}})})}function De(e){var t=e.data[0];if(!t)return n.getDefaultCurrencyCode()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currency)||n.getDefaultCurrencyCode()||""}function he(e){var t=e.data[0];if(!t)return n.getDefaultCurrencySymbol()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currencySymbol)||n.getDefaultCurrencySymbol()||""}var _e=f(function(e){te(e)},500),me=f(function(e){return t(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../../analytics/analytics-functions/search.js")];case 1:return(0,t.sent().anl_search)(e.searchKeyword),[2]}})})},1e3),be=((L={}).INCREASING_PRICE=1,L.DECREASING_PRICE=2,L.LAST_ADDED=3,L.FIRST_ADDED=4,L.INCREASING_DISCOUNT=5,L.DECRASING_DISCOUNT=6,L.FEATURED=7,L.DEFAULT=8,L.AVERAGE_RATING=9,L.REVIEW_COUNT=10,L.SALE_COUNT=11,L.A_Z=12,L.Z_A=13,L);export{ae as clearProductListFilter,ie as clearProductListFilters,X as enableProductListSuggestions,De as getProductListCurrencyCode,he as getProductListCurrencySymbol,Z as getProductListFilterCategories,le as getProductListInitialData,pe as getProductListNextPage,ge as getProductListPage,ve as getProductListPrevPage,Se as getProductListSortOptions,Ee as getProductListSortTypeTranslation,Q as getProductListSuggestionHref,ue as getSelectedFilterValues,oe as handleFilterValueClick,se as handleNumberRangeOptionClick,M as hasProductListAppliedFilters,q as hasProductListFeaturedSortEnabled,Y as hasProductListNextPage,B as hasProductListPrevPage,O as initProductList,ye as initProductListFilterCategories,P as initProductListOnBrowser,F as isProductListDiscounted,U as isProductListFilterable,V as isProductListFiltered,k as isProductListLastViewed,W as isProductListPurchasedTogether,j as isProductListRecommended,x as isProductListRelatedProducts,K as isProductListSearch,w as isProductListStatic,H as isProductListViewedTogether,Ae as onFilterCategoryClick,ce as productListToggleFilterCollapsed,G as searchProductList,z as setProductListIsFilteredForProducts,J as setProductListIsStaticForProducts,Te as setProductListVisiblePage,Ie as setSortType,Ce as translateProductListSortType};
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../../../packages/storefront-config/src/index.js";import i from'./../../../ext/lodash/cloneDeep.js';import{I18n as a}from"../../../i18n/index.js";import{Router as o,withRoutePrefix as s}from"../../../router/index.js";import{customerStore as u}from"../../../stores/customer/index.js";import{isClient as d,isBackNavigation as l,getQueryParams as c,debounce as f,stringToSlug as v,stringifyQueryParams as p}from"../../../utils/helper.js";import{setSavedLastViewedProductsResponse as g,getLastViewedProducts as I,waitForCustomerStoreInit as E}from"../../stores/customer/index.js";import{getIkasFilterCategorySlug as C,getIkasFilterCategoryHref as S}from"../filter-category/index.js";import{getFilterValueList as A,clearFilter as y,selectFilterValue as T,onNumberRangeFilterOptionClick as R,getFilterKeyList as D,applyQueryParamForFilter as h,initIkasProductFilter as _,isCustomValueFilter as m}from"../product/filter/index.js";import{getProductVariantPrice as b,hasProductVariantStock as N}from"../product/variant/index.js";var L;function O(t){var r=e({data:[],limit:10,page:1,count:0,isInitialized:!1,isLoading:!1,type:"ALL",sort:"DEFAULT",searchKeyword:"",pageType:"CATEGORY",category:null,brand:null,productListPropValue:{id:"",productIds:[],initialLimit:10,productListType:"ALL"}},t);return function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL"].includes(e.type))switch(e.pageSpecificData.orderType){case"HIGHEST_DISCOUNT_RATIO":e.sort="DECRASING_DISCOUNT";break;case"LOWEST_DISCOUNT_RATIO":e.sort="INCREASING_DISCOUNT";break;case"HIGHEST_PRICE":e.sort="DECREASING_PRICE";break;case"LOWEST_PRICE":e.sort="INCREASING_PRICE";break;case"NEWEST":e.sort="LAST_ADDED";break;case"OLDEST":e.sort="FIRST_ADDED";break;case"MANUALLY":e.sort="FEATURED"}}(r),z(r),J(r),r}function P(e){var t;if(d()&&(!l()||!o.isFromBFCache)){!function(e){var t=c(),r=null==t?void 0:t.get("page");if(r){var n=parseInt(r);isNaN(n)||(e.page=n,e.infiniteScrollPage=n)}}(e);if(["CATEGORY","BRAND","SEARCH"].includes(e.pageType)&&location.search&&U(e)&&((null===(t=e.productListPropValue)||void 0===t?void 0:t.usePageFilter)||"SEARCH"===e.type))le(e,c(),e.page>1);else e.page>1?le(e,void 0,!0):k(e)?le(e):Re(e)}}function G(e,t){t!==e.searchKeyword&&(e.searchKeyword=t,_e(e),me(e))}function U(e){return"ALL"===e.type||"CATEGORY"===e.type}function V(e){var t,r;return(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))||!!e.searchKeyword||"CATEGORY"!==e.pageType&&(!!e.filterCategoryId||!!(null===(r=e.filterCategories)||void 0===r?void 0:r.some(function(e){return e.isSelected})))}function w(e){return"STATIC"===e.type}function F(e){return"DISCOUNTED"===e.type}function j(e){return"RECOMMENDED"===e.type}function k(e){return"LAST_VIEWED"===e.type}function x(e){return"RELATED_PRODUCTS"===e.type}function H(e){return"VIEWED_TOGETHER"===e.type}function W(e){return"PURCHASED_TOGETHER"===e.type}function K(e){return"SEARCH"===e.type}function B(e){return!(w(e)||F(e)||j(e)||!e.minPage)&&e.minPage>1}function Y(e){return!(w(e)||F(e)||j(e))&&e.page*e.limit<e.count}function Z(e){var t;return(null===(t=e.filterCategories)||void 0===t?void 0:t.filter(function(e){return 0!==e.resultCount}))||[]}function M(e){var t;return!!e.searchKeyword||!!(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))}function q(e){var t;return"MANUALLY"===(null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL","CATEGORY"].includes(e.type)}function z(e){var t=V(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function J(e){var t=w(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function X(e){e._enableSuggestions=!0}function Q(e){var t={};return e.categoryId&&(t.categoryId=e.categoryId),e.brandId&&(t.brandId=e.brandId),Object.keys(t).length?s("/search?suggestion=".concat(encodeURIComponent(JSON.stringify(t)))):s("/search")}function $(i,a,o,s){return t(this,void 0,void 0,function(){var t,u,d,l,f,v,p,g,I,E,C,S,y,T,R,D;return r(this,function(r){switch(r.label){case 0:return t=[],u=[],null===(S=i.filters)||void 0===S||S.forEach(function(e){var r=A(e);r.length&&t.push({id:e.id,type:e.type,displayType:e.displayType,valueList:r}),e.isFacetFilter&&u.push({id:e.id,type:e.type,displayType:e.displayType})}),d=c(),(l=null==d?void 0:d.get("suggestion"))&&(f=JSON.parse(decodeURIComponent(l)),(v=f.brandId)&&((p=null===(y=i.filters)||void 0===y?void 0:y.find(function(e){return"brand"===e.id&&"BRAND"===e.type}))&&(g=null===(T=p.values)||void 0===T?void 0:T.find(function(e){return e.id===v}))&&h(p,g.name),t.push({id:"brand",type:"BRAND",displayType:"BOX",valueList:[v]})),f.categoryId&&(i.filterCategoryId=f.categoryId),i.searchKeyword=f.term),I=null===(R=i.filterCategories)||void 0===R?void 0:R.filter(function(e){return e.isSelected}).map(function(e){return e.id}),E=function(e){var t,r;switch(e.sort){case"INCREASING_PRICE":t="ASC",r="PRICE";break;case"DECREASING_PRICE":t="DESC",r="PRICE";break;case"FIRST_ADDED":t="ASC",r="CREATED_AT";break;case"LAST_ADDED":t="DESC",r="CREATED_AT";break;case"INCREASING_DISCOUNT":t="ASC",r="DISCOUNT_RATIO";break;case"DECRASING_DISCOUNT":t="DESC",r="DISCOUNT_RATIO";break;case"FEATURED":if(K(e))return;t="ASC",r="MANUAL_SORT";break;case"DEFAULT":t=void 0,r=void 0;break;case"AVERAGE_RATING":t="DESC",r="AVERAGE_RATING";break;case"REVIEW_COUNT":t="DESC",r="REVIEW_COUNT";break;case"SALE_COUNT":t="DESC",r="SALE_COUNT";break;case"A_Z":t="ASC",r="NAME";break;case"Z_A":t="DESC",r="NAME"}if(t&&r)return{direction:t,type:r}}(i),j(i)&&i.recommendedProductData?[4,import("../../api/product/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,brandIds:i.recommendedProductData.brandIds,categoryIds:i.recommendedProductData.categoryIds,locale:n.getCurrentLocale()})];case 2:case 5:case 8:case 11:case 14:return[2,r.sent()];case 3:return x(i)&&i.relatedProductData?[4,import("../../api/product/index.js")]:[3,6];case 4:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,productId:i.relatedProductData.productId,brandIds:i.relatedProductData.brandIds,categoryIds:i.relatedProductData.categoryIds,locale:n.getCurrentLocale()})];case 6:return H(i)&&i.viewedTogetherProductData?[4,import("../../api/product/index.js")]:[3,9];case 7:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"VIEWED_TOGETHER",productIds:i.viewedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 9:return W(i)&&i.purchasedTogetherProductData?[4,import("../../api/product/index.js")]:[3,12];case 10:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"PURCHASED_TOGETHER",productIds:i.purchasedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 12:return C={input:e(e(e(e({page:a,perPage:o},i._enableSuggestions?{enableSuggestions:i._enableSuggestions}:{}),{productIdList:w(i)?null===(D=i.productListPropValue.productIds)||void 0===D?void 0:D.map(function(e){return e.productId}):s,filterList:t,facetList:u}),i.baseCategoryIdList?{baseCategoryIdList:i.baseCategoryIdList}:{}),{brandId:"BRAND"===i.pageType&&"SEARCH"!==i.type?i.filterBrandId:void 0,categoryIdList:I&&I.length?I:i.filterCategoryId?[i.filterCategoryId]:void 0,priceListId:n.priceListId,salesChannelId:n.salesChannelId,query:i.searchKeyword,order:E?[E]:[],showStockOption:n.stockPreference||"SHOW_ALL"})},[4,import("../../api/product/index.js")];case 13:return[4,(0,r.sent().apiSearchProducts)(C,i.excludedFields||[])]}})})}function ee(e){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,r.sent().apiGetProductFilterData)({categoryId:e.filterCategoryId?e.filterCategoryId:void 0,locale:n.getCurrentLocale()})];case 2:return t=r.sent(),e.filters=null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.filters.map(function(e){return _(e)}),e.filterCategories=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.categories,ye(e),e.disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,"CATEGORY"!==e.pageType&&e.filterCategoryId&&(i=null===(u=e.filterCategories)||void 0===u?void 0:u.find(function(t){return t.id===e.filterCategoryId}))&&(i.isSelected=!0),e.filters&&e.filters.sort(function(e,t){return e.order>t.order?1:-1}),[2]}})})}function te(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,le(e)];case 1:return t=r.sent(),["CATEGORY","BRAND","SEARCH"].includes(e.pageType)?(t&&ne(e),[2]):[2]}})})}function re(e){var t,r,n,i={};if(null===(t=e.filters)||void 0===t||t.forEach(function(e){var t=D(e);t.length&&(i[v(e.name)]=t)}),e.searchKeyword&&(i.s=e.searchKeyword),e.sort&&(i.o=be[e.sort]),e.baseCategoryIdList&&(i.bc=e.baseCategoryIdList),e.suggestionCategoryId&&(i.suggestionCategoryId=e.suggestionCategoryId),e.infiniteScrollPage?i.page=e.infiniteScrollPage:i.page=e.page,"CATEGORY"!==e.pageType){var a=null===(r=e.filterCategories)||void 0===r?void 0:r.filter(function(e){return e.isSelected});if(!!(null==a?void 0:a.length))i.c=null==a?void 0:a.map(function(e){return C(e)});else if(e.filterCategoryId){var o=null===(n=e.filterCategories)||void 0===n?void 0:n.find(function(t){return t.id===e.filterCategoryId}),s=o?C(o):void 0;s&&(i.c=s)}}return p(i,{arrayFormat:"comma"})}function ne(e){if(d()&&!K(e)&&!n.isEditor){var t=re(e),r=s("".concat(location.pathname).concat(t?"?"+t:""));o.navigate(r,!0)}}function ie(e){var t,r;null===(t=e.filters)||void 0===t||t.forEach(function(e){return y(e)}),e.searchKeyword="","CATEGORY"!==e.pageType&&(e.filterCategoryId=void 0),null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){return e.isSelected=!1}),te(e)}function ae(e,t){y(t),te(e)}function oe(e,t,r){T(t,r),te(e)}function se(e,t,r){R(t,r),te(e)}function ue(e){var t,r=null===(t=e.filters)||void 0===t?void 0:t.filter(function(e){var t;return null===(t=e.values)||void 0===t?void 0:t.some(function(e){return e.isSelected})});return null==r?void 0:r.map(function(e){var t,r;return e.numberRange?{filter:e,values:[e.numberRange.from+"-"+e.numberRange.to],commaSeperatedValues:e.numberRange.from+"-"+e.numberRange.to}:e.numberRangeListOptions?{filter:e,values:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}),commaSeperatedValues:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}).join(",")}:{filter:e,values:(null===(t=e.values)||void 0===t?void 0:t.filter(function(e){return e.isSelected}).map(function(e){return e.name}))||[],commaSeperatedValues:(null===(r=e.values)||void 0===r?void 0:r.filter(function(e){return e.isSelected}).map(function(e){return e.name}).join(","))||""}})}function de(e){return e.variants[0]}function le(e,n,a){return t(this,void 0,void 0,function(){var t,o,s,l,c,f,v,p,S,A,y,T,R,D,_,b;return r(this,function(r){switch(r.label){case 0:e.isLoading=!0,t=Date.now(),e.fetchRequestTime=t,r.label=1;case 1:return r.trys.push([1,14,15,16]),o=a?e.page:1,s=e.limit,!U(e)||e.filters?[3,3]:[4,ee(e)];case 2:r.sent(),r.label=3;case 3:return function(e,t){var r;try{null==t||t.forEach(function(t,r){var n,i=null===(n=e.filters)||void 0===n?void 0:n.find(function(e){return e.key===r});i&&h(i,t)});var n=null==t?void 0:t.get("s");n&&(e.searchKeyword=n);var i=null==t?void 0:t.get("o");if(i){var a=parseInt(i),o=Object.entries(be).find(function(e){return e[1]===a});o&&(e.sort=o[0])}if("CATEGORY"!==e.pageType){var s=null==t?void 0:t.get("c"),u=null==s?void 0:s.split(",");u&&u.length&&(null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){e.isSelected=u.some(function(t){return t===C(e)})}))}if("SEARCH"===e.pageType){var d=null==t?void 0:t.get("bc"),l=null==d?void 0:d.split(",");l&&(e.baseCategoryIdList=l);var c=null==t?void 0:t.get("suggestion");if(c){var f=JSON.parse(decodeURIComponent(c)).categoryId;f&&(e.suggestionCategoryId=f)}var v=null==t?void 0:t.get("suggestionCategoryId");v&&(e.suggestionCategoryId=v,e.filterCategoryId=v)}}catch(e){console.log(e)}}(e,n),[4,fe(e)];case 4:return r.sent(),K(e)&&!M(e)?(e.data=[],e.page=1,e.minPage=1,e.count=0,e.isInitialized=!0,[2,!0]):(l=void 0,c=!1,w(e)?(o=void 0,s=200,[3,10]):[3,5]);case 5:return F(e)||j(e)?(o=1,s=10,[3,10]):[3,6];case 6:return k(e)?d()?[4,E(u)]:[3,9]:[3,10];case 7:return r.sent(),[4,I(u)];case 8:return(f=r.sent())&&f.length?(l=f.map(function(e){return e.productId}),c=u.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return c?(p=u._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,$(e,o||1,s||10,l)];case 12:p=r.sent(),r.label=13;case 13:return(v=p)&&e.fetchRequestTime===t?(S=[],!c&&k(e)&&g(u,v),w(e)||k(e)?(A=w(e)?e.productListPropValue.productIds:u._lastViewedProducts,S=(null==A?void 0:A.map(function(e){var t,r,n=null===(r=null===(t=v.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.productId}),i=null==n?void 0:n.variants.find(function(t){return t.id===e.variantId});if((null==i?void 0:i.isActive)&&N(i)||(i=null==n?void 0:n.variants.find(function(e){return e.isActive&&N(e)})),n&&i)return n.selectedVariantValues=i.variantValues,n}).filter(function(e){return!!e}))||[]):S=(null===(R=null===(T=v.data)||void 0===T?void 0:T.data)||void 0===R?void 0:R.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}))||[],null===(D=e.filters)||void 0===D||D.forEach(function(e){var t,r;if(void 0===e.isCollapsed){var n=!1;(!1===(null===(t=e.settings)||void 0===t?void 0:t.showCollapsedOnMobile)&&d()&&window.innerWidth<768||!1===(null===(r=e.settings)||void 0===r?void 0:r.showCollapsedOnDesktop))&&(n=!0),e.isCollapsed=!n}}),function(e,t){var r,n,a=i(e);null===(r=a.filters)||void 0===r||r.forEach(function(e){var r,n,i,a=null==t?void 0:t.find(function(t){return t.id===e.id});a?null===(r=e.values)||void 0===r||r.forEach(function(t){var r=a.values.find(function(e){return e.id===t.id});r?t.resultCount=r.count:m(e)?t.resultCount=null:t.resultCount=0}):m(e)?null===(n=e.values)||void 0===n||n.forEach(function(e){return e.resultCount=null}):null===(i=e.values)||void 0===i||i.forEach(function(e){return e.resultCount=0})});var o=null==t?void 0:t.find(function(e){return"category"===e.id});o&&(null===(n=a.filterCategories)||void 0===n||n.forEach(function(e){var t=o.values.find(function(t){return t.id===e.id});e.resultCount=t?t.count:0})),e.filters=a.filters,e.filterCategories=a.filterCategories,ye(e)}(e,null===(_=v.data)||void 0===_?void 0:_.facets),e.data=S,e.count=(null===(b=v.data)||void 0===b?void 0:b.count)||0,e.isInitialized=!0,e.page=o||1,e.minPage=e.page,v.data&&"suggestions"in v.data&&(e.suggestions=v.data.suggestions),z(e),J(e),a||(e.infiniteScrollPage=null),Re(e),[2,!0]):[2];case 14:return y=r.sent(),console.log(y),[3,16];case 15:return t===e.fetchRequestTime&&(e.isLoading=!1),[7];case 16:return[2]}})})}function ce(e){e.isCollapsed=!e.isCollapsed}function fe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u,d,l,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,13,,14]),e.productListPropValue.category?[4,import("../../api/category/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiListCategory)({id:{eq:e.productListPropValue.category}})];case 2:return t=r.sent(),e.category=(null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o[0])||null,[3,7];case 3:return e.productListPropValue.usePageFilter&&"CATEGORY"===e.pageType&&e.pageSpecificData?(e.category=e.pageSpecificData,[3,7]):[3,4];case 4:return e.filterCategoryId?[4,import("../../api/category/index.js")]:[3,7];case 5:return[4,(0,r.sent().apiListCategory)({id:{eq:e.filterCategoryId}})];case 6:t=r.sent(),e.category=(null===(u=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===u?void 0:u[0])||null,r.label=7;case 7:return e.productListPropValue.usePageFilter&&"BRAND"===e.pageType&&e.pageSpecificData?(e.brand=e.pageSpecificData,[3,12]):[3,8];case 8:return e.filterBrandId?e.filterBrandId!==(null===(d=e.pageSpecificData)||void 0===d?void 0:d.id)?[3,9]:(e.brand=e.pageSpecificData,[3,12]):[3,12];case 9:return[4,import("../../api/brand/index.js")];case 10:return[4,(0,r.sent().apiListProductBrand)({id:{eq:e.filterBrandId}})];case 11:n=r.sent(),e.brand=(null===(c=null===(l=n.data)||void 0===l?void 0:l.data)||void 0===c?void 0:c[0])||null,r.label=12;case 12:return[3,14];case 13:return i=r.sent(),console.error(i),[3,14];case 14:return[2]}})})}function ve(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!B(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),t=e.minPage-1,[4,$(e,t,e.limit)];case 2:return(n=r.sent())?(i=null===(s=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=(null==i?void 0:i.concat(e.data))||e.data,e.count=(null===(u=n.data)||void 0===u?void 0:u.count)||e.count,e.minPage=t,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function pe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!Y(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,e.page+1,e.limit)];case 2:return(t=r.sent())?(n=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=e.data.concat(n||[]),e.count=(null===(s=t.data)||void 0===s?void 0:s.count)||e.count,e.page=e.page+1,z(e),J(e),ne(e),[3,5]):[2];case 3:return i=r.sent(),console.log(i),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function ge(e,n){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(e.isLoading||w(e)||F(e)||j(e)||k(e)||x(e)||H(e)||W(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,n,e.limit)];case 2:return(t=r.sent())?(i=null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=i||[],e.count=(null===(u=t.data)||void 0===u?void 0:u.count)||0,e.page=n,e.minPage=n,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function Ie(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.sort=n,[4,le(e)];case 1:return t.sent()&&ne(e),[2]}})})}function Ee(e){return Ce(e,e.sort)}function Ce(e,t){switch(t){case"INCREASING_PRICE":return a.translate("sort_type.increasing_price");case"DECREASING_PRICE":return a.translate("sort_type.decreasing_price");case"LAST_ADDED":return a.translate("sort_type.last_added");case"FIRST_ADDED":return a.translate("sort_type.first_added");case"INCREASING_DISCOUNT":return a.translate("sort_type.increasing_discount");case"DECRASING_DISCOUNT":return a.translate("sort_type.decreasing_discount");case"FEATURED":return a.translate("sort_type.featured");case"DEFAULT":return a.translate("sort_type.default");case"AVERAGE_RATING":return a.translate("sort_type.average_rating");case"REVIEW_COUNT":return a.translate("sort_type.review_count");case"SALE_COUNT":return a.translate("sort_type.sale_count");case"A_Z":return a.translate("sort_type.a_z");case"Z_A":return a.translate("sort_type.z_a")}}function Se(e){var t,r,n,i,a,o,s,u;if(!e)return[];var d=[];return(null===(t=e.disabledSortTypes)||void 0===t?void 0:t.includes("NAME"))||(d.push({label:Ce(0,"A_Z"),value:"A_Z",isSelected:"A_Z"===e.sort}),d.push({label:Ce(0,"Z_A"),value:"Z_A",isSelected:"Z_A"===e.sort})),(null===(r=e.disabledSortTypes)||void 0===r?void 0:r.includes("PRICE"))||(d.push({label:Ce(0,"INCREASING_PRICE"),value:"INCREASING_PRICE",isSelected:"INCREASING_PRICE"===e.sort}),d.push({label:Ce(0,"DECREASING_PRICE"),value:"DECREASING_PRICE",isSelected:"DECREASING_PRICE"===e.sort})),(null===(n=e.disabledSortTypes)||void 0===n?void 0:n.includes("CREATED_AT"))||(d.push({label:Ce(0,"LAST_ADDED"),value:"LAST_ADDED",isSelected:"LAST_ADDED"===e.sort}),d.push({label:Ce(0,"FIRST_ADDED"),value:"FIRST_ADDED",isSelected:"FIRST_ADDED"===e.sort})),(null===(i=e.disabledSortTypes)||void 0===i?void 0:i.includes("DISCOUNT_RATIO"))||(d.push({label:Ce(0,"INCREASING_DISCOUNT"),value:"INCREASING_DISCOUNT",isSelected:"INCREASING_DISCOUNT"===e.sort}),d.push({label:Ce(0,"DECRASING_DISCOUNT"),value:"DECRASING_DISCOUNT",isSelected:"DECRASING_DISCOUNT"===e.sort})),(null===(a=e.disabledSortTypes)||void 0===a?void 0:a.includes("MANUAL_SORT"))||d.push({label:Ce(0,"FEATURED"),value:"FEATURED",isSelected:"FEATURED"===e.sort}),(null===(o=e.disabledSortTypes)||void 0===o?void 0:o.includes("AVERAGE_RATING"))||d.push({label:Ce(0,"AVERAGE_RATING"),value:"AVERAGE_RATING",isSelected:"AVERAGE_RATING"===e.sort}),(null===(s=e.disabledSortTypes)||void 0===s?void 0:s.includes("REVIEW_COUNT"))||d.push({label:Ce(0,"REVIEW_COUNT"),value:"REVIEW_COUNT",isSelected:"REVIEW_COUNT"===e.sort}),(null===(u=e.disabledSortTypes)||void 0===u?void 0:u.includes("SALE_COUNT"))||d.push({label:Ce(0,"SALE_COUNT"),value:"SALE_COUNT",isSelected:"SALE_COUNT"===e.sort}),d}function Ae(e,i,a){return t(this,void 0,void 0,function(){var t,s,u;return r(this,function(r){switch(r.label){case 0:return a?(null===(u=e.filterCategories)||void 0===u||u.forEach(function(e){e.id===i.id&&(e.isSelected=!e.isSelected)}),[4,te(e)]):[3,2];case 1:return r.sent(),[3,3];case 2:n.isEditor||(t=re(e),s=S(i)+(t?"?"+t:""),o.navigate(s)),r.label=3;case 3:return[2]}})})}function ye(e){var t;null===(t=e.filterCategories)||void 0===t||t.forEach(function(e){e.image=e.imageId?{id:e.imageId,isVideo:!1}:null})}function Te(e,t){if(e.infiniteScrollPage!==t){e.infiniteScrollPage=t;var r=re(e);o.navigate("".concat(location.pathname).concat(r?"?"+r:""),!0)}}function Re(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.searchKeyword&&e.data.length?[4,import("../../../analytics/analytics-functions/viewSearchResults.js")]:[3,2];case 1:return(0,t.sent().anl_viewSearchResults)(e.searchKeyword,e.data),[3,4];case 2:return e.data.length&&"ALL"===e.type?[4,import("../../../analytics/analytics-functions/viewListing.js")]:[3,4];case 3:(0,t.sent().anl_viewListing)(e.data),t.label=4;case 4:return[2]}})})}function De(e){var t=e.data[0];if(!t)return n.getDefaultCurrencyCode()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currency)||n.getDefaultCurrencyCode()||""}function he(e){var t=e.data[0];if(!t)return n.getDefaultCurrencySymbol()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currencySymbol)||n.getDefaultCurrencySymbol()||""}var _e=f(function(e){te(e)},500),me=f(function(e){return t(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../../analytics/analytics-functions/search.js")];case 1:return(0,t.sent().anl_search)(e.searchKeyword),[2]}})})},1e3),be=((L={}).INCREASING_PRICE=1,L.DECREASING_PRICE=2,L.LAST_ADDED=3,L.FIRST_ADDED=4,L.INCREASING_DISCOUNT=5,L.DECRASING_DISCOUNT=6,L.FEATURED=7,L.DEFAULT=8,L.AVERAGE_RATING=9,L.REVIEW_COUNT=10,L.SALE_COUNT=11,L.A_Z=12,L.Z_A=13,L);export{ae as clearProductListFilter,ie as clearProductListFilters,X as enableProductListSuggestions,De as getProductListCurrencyCode,he as getProductListCurrencySymbol,Z as getProductListFilterCategories,le as getProductListInitialData,pe as getProductListNextPage,ge as getProductListPage,ve as getProductListPrevPage,Se as getProductListSortOptions,Ee as getProductListSortTypeTranslation,Q as getProductListSuggestionHref,ue as getSelectedFilterValues,oe as handleFilterValueClick,se as handleNumberRangeOptionClick,M as hasProductListAppliedFilters,q as hasProductListFeaturedSortEnabled,Y as hasProductListNextPage,B as hasProductListPrevPage,O as initProductList,ye as initProductListFilterCategories,P as initProductListOnBrowser,F as isProductListDiscounted,U as isProductListFilterable,V as isProductListFiltered,k as isProductListLastViewed,W as isProductListPurchasedTogether,j as isProductListRecommended,x as isProductListRelatedProducts,K as isProductListSearch,w as isProductListStatic,H as isProductListViewedTogether,Ae as onFilterCategoryClick,ce as productListToggleFilterCollapsed,G as searchProductList,z as setProductListIsFilteredForProducts,J as setProductListIsStaticForProducts,Te as setProductListVisiblePage,Ie as setSortType,Ce as translateProductListSortType};
|
|
@@ -2,6 +2,13 @@ import { AddressForm, IkasCustomerAddress } from "../../../../storefront-models/
|
|
|
2
2
|
/**
|
|
3
3
|
* Initializes an address form with default or existing address values, loads location data, and configures field settings.
|
|
4
4
|
*
|
|
5
|
+
* Also resolves `addressForm.addressFormat` for the selected country. That is an
|
|
6
|
+
* `AddressFormItem[][]` describing which fields the country uses and how they group into rows
|
|
7
|
+
* (outer array = rows, inner array = fields sharing a row), and it is the only correct source
|
|
8
|
+
* for laying out an address form -- a hardcoded field list will be wrong for most countries.
|
|
9
|
+
* It is empty until this promise resolves, and `setAddressFormCountry` re-resolves it, so
|
|
10
|
+
* render from it rather than copying it into local state.
|
|
11
|
+
*
|
|
5
12
|
* @ai-category Address, Form, Initialization, Checkout
|
|
6
13
|
* @ai-related submitAddressForm, setAddressFormCountry, setAddressFormState, setAddressFormCity
|
|
7
14
|
*
|
|
@@ -10,14 +17,75 @@ import { AddressForm, IkasCustomerAddress } from "../../../../storefront-models/
|
|
|
10
17
|
* @returns A promise that resolves once the form is fully initialized, including country/state/city lists, field settings, checkout settings, and shipping zones.
|
|
11
18
|
*
|
|
12
19
|
* @example
|
|
13
|
-
* ```
|
|
14
|
-
* import {
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { useEffect, useState } from "preact/hooks";
|
|
22
|
+
* import {
|
|
23
|
+
* type AddressForm,
|
|
24
|
+
* type AddressFormItem,
|
|
25
|
+
* initAddressForm,
|
|
26
|
+
* setAddressFormFirstName,
|
|
27
|
+
* setAddressFormLastName,
|
|
28
|
+
* setAddressFormIdentityNumber,
|
|
29
|
+
* setAddressFormAddressLine1,
|
|
30
|
+
* setAddressFormAddressLine2,
|
|
31
|
+
* setAddressFormPostalCode,
|
|
32
|
+
* setAddressFormPhone,
|
|
33
|
+
* } from "@ikas/bp-storefront";
|
|
15
34
|
*
|
|
16
35
|
* // Initialize an empty address form
|
|
17
36
|
* await initAddressForm(addressForm);
|
|
18
37
|
*
|
|
19
38
|
* // Initialize with an existing customer address for editing
|
|
20
39
|
* await initAddressForm(addressForm, existingAddress);
|
|
40
|
+
*
|
|
41
|
+
* // addressFormat is empty until init resolves, so gate the render on it.
|
|
42
|
+
* const [isLoading, setIsLoading] = useState(true);
|
|
43
|
+
* useEffect(() => {
|
|
44
|
+
* initAddressForm(addressForm, address).then(() => setIsLoading(false));
|
|
45
|
+
* }, []);
|
|
46
|
+
*
|
|
47
|
+
* // Every addressFormat key has a matching setter, each taking (addressForm, value).
|
|
48
|
+
* // The location keys (country, state, city, district, region) are omitted here: they
|
|
49
|
+
* // render as selects fed by addressForm.countryOptions / stateOptions / cityOptions /
|
|
50
|
+
* // districtOptions / regionOptions, and must fall back to a text input when the field
|
|
51
|
+
* // isFreeText or has no options.
|
|
52
|
+
* const SETTERS: Partial<Record<AddressFormItem, (form: AddressForm, value: string) => void>> = {
|
|
53
|
+
* firstName: setAddressFormFirstName,
|
|
54
|
+
* lastName: setAddressFormLastName,
|
|
55
|
+
* identityNumber: setAddressFormIdentityNumber,
|
|
56
|
+
* addressLine1: setAddressFormAddressLine1,
|
|
57
|
+
* addressLine2: setAddressFormAddressLine2,
|
|
58
|
+
* postalCode: setAddressFormPostalCode,
|
|
59
|
+
* phone: setAddressFormPhone,
|
|
60
|
+
* };
|
|
61
|
+
*
|
|
62
|
+
* // Render the country's own layout: outer array = rows, inner array = fields in that row.
|
|
63
|
+
* (addressForm.addressFormat ?? []).map((row) => {
|
|
64
|
+
* // A field the country does not use is absent from the form object entirely.
|
|
65
|
+
* const keys = row.filter((key) => addressForm[key] != null);
|
|
66
|
+
* if (!keys.length) return null;
|
|
67
|
+
*
|
|
68
|
+
* return (
|
|
69
|
+
* <div className="address-row" key={keys.join("-")}>
|
|
70
|
+
* {keys.map((key) => {
|
|
71
|
+
* // Each entry is an IkasFormItem: value, label, placeholder, hasError, message.
|
|
72
|
+
* const field = addressForm[key];
|
|
73
|
+
* if (!field) return null; // already guaranteed by the filter above; narrows the type
|
|
74
|
+
* return (
|
|
75
|
+
* <label key={key}>
|
|
76
|
+
* {field.label}
|
|
77
|
+
* <input
|
|
78
|
+
* value={field.value ?? ""}
|
|
79
|
+
* placeholder={field.placeholder}
|
|
80
|
+
* onInput={(e) => SETTERS[key]?.(addressForm, e.currentTarget.value)}
|
|
81
|
+
* />
|
|
82
|
+
* {field.hasError && <small>{field.message}</small>}
|
|
83
|
+
* </label>
|
|
84
|
+
* );
|
|
85
|
+
* })}
|
|
86
|
+
* </div>
|
|
87
|
+
* );
|
|
88
|
+
* })
|
|
21
89
|
* ```
|
|
22
90
|
*/
|
|
23
91
|
export declare function initAddressForm(addressForm: AddressForm, address?: IkasCustomerAddress): Promise<void>;
|