@ikas/storefront-providers 6.1.0-beta.23 → 6.1.0-beta.230

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.
@@ -11,6 +11,7 @@ export declare type IkasProductListPropValue = {
11
11
  relatedProductsType?: IkasRelatedProductsType | null;
12
12
  recommendedProductsType?: IkasRecommendedProductsType | null;
13
13
  excludedFields?: string[] | null;
14
+ isFacetListNotSent?: boolean;
14
15
  };
15
16
  declare type IkasProductVariantId = {
16
17
  productId: string;
@@ -1,4 +1,4 @@
1
- import { IkasImage } from "@ikas/storefront";
1
+ import { IkasImage } from "@ikas/storefront-models";
2
2
  export declare type IkasVideoPropValue = {
3
3
  video: IkasImage | null;
4
4
  thumbnailImage: IkasImage | null;
@@ -1,6 +1,7 @@
1
1
  import { IkasCustomerReview } from "@ikas/storefront-models";
2
2
  export declare type IkasCustomerReviewList = {
3
3
  data: IkasCustomerReview[];
4
+ locale: string;
4
5
  limit: number;
5
6
  page: number;
6
7
  count: number;
@@ -26,6 +26,7 @@ export declare type IkasProductList = {
26
26
  isLoading?: boolean;
27
27
  fetchRequestTime?: number;
28
28
  excludedFields?: string[] | null;
29
+ isFacetListNotSent?: boolean;
29
30
  disabledSortTypes?: IkasProductListSortByTypeEnum[] | null;
30
31
  };
31
32
  export declare enum IkasProductListType {
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i,IkasCategoryProductsOrderType as n}from"@ikas/storefront-models";import{IkasProductListType as a,IkasProductSearchShowStockOption as o,IkasProductListSortType as d}from"./index.js";import{IkasProductFilterFunctions as s}from"@ikas/storefront-model-functions";import{searchProducts as u,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as I,SortByTypeEnum as v}from"@ikas/storefront-api";import{IkasStorefrontConfig as E}from"@ikas/storefront-config";import"../blog-category-list/index.js";import"../blog-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";function C(i,o){var u,l,c,f;return e(this,void 0,void 0,(function(){var e,I,v,E,C,g,y;return t(this,(function(t){switch(t.label){case 0:!function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&[a.ALL].includes(e.type))switch(e.pageSpecificData.orderType){case n.HIGHEST_DISCOUNT_RATIO:e.sort=d.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:e.sort=d.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:e.sort=d.DECREASING_PRICE;break;case n.LOWEST_PRICE:e.sort=d.INCREASING_PRICE;break;case n.NEWEST:e.sort=d.LAST_ADDED;break;case n.OLDEST:e.sort=d.FIRST_ADDED;break;case n.MANUALLY:e.sort=d.FEATURED}}(i),i.isLoading=!0,e=Date.now(),i.fetchRequestTime=e,t.label=1;case 1:return t.trys.push([1,5,,6]),I=o?i.page:1,v=i.limit,!function(e){return e.type===a.ALL||e.type===a.CATEGORY}(i)||i.filters?[3,3]:[4,T(i)];case 2:t.sent(),t.label=3;case 3:if(S(i))return i.data=[],i.page=1,i.minPage=1,i.count=0,i.initialized=!0,[2,!0];if(void 0,p(i))I=void 0,v=200;else if(function(e){return e.type===a.DISCOUNTED}(i))I=1,v=10;else if(function(e){return e.type===a.RECOMMENDED}(i))I=1,v=10;else if(D(i))return[2];return[4,A(i,I||1,v||10,undefined)];case 4:return(E=t.sent())&&i.fetchRequestTime===e?(C=[],D(i)?[2]:(p(i)?(g=i.productListPropValue.productIds||[],C=(null==g?void 0:g.map((function(e){var t,i,n=null===(i=null===(t=E.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.productId})),a=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==a?void 0:a.isActive)||(a=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&a)return r(r({},n),{selectedVariantValues:a.variantValues})})).filter((function(e){return!!e})))||[]):C=(null===(l=null===(u=E.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.map((function(e){var t=e.variants.find((function(e){return e.isActive}));return r(r({},e),{selectedVariantValues:(t||e.variants[0]).variantValues})})))||[],function(e,t){var r,i,n=s.isCustomValueFilter;null===(r=e.filters)||void 0===r||r.forEach((function(e){var r,i,a,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=o.values.find((function(e){return e.id===t.id}));r?t.resultCount=r.count:n(e)?t.resultCount=null:t.resultCount=0})):n(e)?null===(i=e.values)||void 0===i||i.forEach((function(e){return e.resultCount=null})):null===(a=e.values)||void 0===a||a.forEach((function(e){return e.resultCount=0}))}));var a=null==t?void 0:t.find((function(e){return"category"===e.id}));a&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=a.values.find((function(t){return t.id===e.id}));e.resultCount=t?t.count:0})))}(i,null===(c=E.data)||void 0===c?void 0:c.facets),i.data=C,i.count=(null===(f=E.data)||void 0===f?void 0:f.count)||0,i.initialized=!0,i.page=I||1,i.minPage=i.page,[2,!0])):[2];case 5:return y=t.sent(),console.error(y),[3,6];case 6:return[2]}}))}))}function p(e){return e.type===a.STATIC}function D(e){return e.type===a.LAST_VIEWED}function S(e){return e.type===a.SEARCH}function A(r,n,f,C){var D,A,T;return e(this,void 0,void 0,(function(){var e,g,y,R,m,h;return t(this,(function(t){switch(t.label){case 0:return e=[],g=[],y=s.getValueList,null===(D=r.filters)||void 0===D||D.forEach((function(t){var r=y(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&g.push({id:t.id,type:t.type,displayType:t.displayType})})),R=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(e){return e.isSelected})).map((function(e){return e.id})),m=function(e){var t,r;switch(e.sort){case d.INCREASING_PRICE:t=I.ASC,r=v.PRICE;break;case d.DECREASING_PRICE:t=I.DESC,r=v.PRICE;break;case d.FIRST_ADDED:t=I.ASC,r=v.CREATED_AT;break;case d.LAST_ADDED:t=I.DESC,r=v.CREATED_AT;break;case d.INCREASING_DISCOUNT:t=I.ASC,r=v.DISCOUNT_RATIO;break;case d.DECRASING_DISCOUNT:t=I.DESC,r=v.DISCOUNT_RATIO;break;case d.FEATURED:if(S(e))return;t=I.ASC,r=v.MANUAL_SORT;break;case d.DEFAULT:t=void 0,r=void 0;break;case d.AVERAGE_RATING:t=I.DESC,r=v.AVERAGE_RATING;break;case d.REVIEW_COUNT:t=I.DESC,r=v.REVIEW_COUNT;break;case d.SALE_COUNT:t=I.DESC,r=v.SALE_COUNT;break;case d.A_Z:t=I.ASC,r=v.NAME;break;case d.Z_A:t=I.DESC,r=v.NAME}if(t&&r)return{direction:t,type:r}}(r),function(e){return e.type===a.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds,locale:E.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:case 7:return[2,t.sent()];case 2:return function(e){return e.type===a.RECOMMENDED_PRODUCTS}(r)&&r.recommendedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),brandIds:r.recommendedProductData.brandIds,categoryIds:r.recommendedProductData.categoryIds,locale:E.getCurrentLocale()})]:[3,4];case 4:return function(e){return e.type===a.VIEWED_TOGETHER}(r)&&r.viewedTogetherProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),method:c.VIEWED_TOGETHER,productIds:r.viewedTogetherProductData.productIds,locale:E.getCurrentLocale()})]:[3,6];case 6:return h={input:{page:n,perPage:f,productIdList:p(r)?null===(T=r.productListPropValue.productIds)||void 0===T?void 0:T.map((function(e){return e.productId})):C,filterList:e,facetList:g,brandId:r.pageType===i.BRAND&&r.type!==a.SEARCH?r.filterBrandId:void 0,categoryIdList:R&&R.length?R:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),query:r.searchKeyword,order:r.type===a.SEARCH?[]:m?[m]:[],showStockOption:E.getStockPreference()||o.SHOW_ALL}},[4,u(h,r.excludedFields)]}}))}))}function T(r){var n,a,o,d,s;return e(this,void 0,void 0,(function(){var e,u;return t(this,(function(t){switch(t.label){case 0:return[4,f({categoryId:r.filterCategoryId?r.filterCategoryId:void 0,locale:E.getCurrentLocale()})];case 1:return e=t.sent(),r.filters=(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.filters)||null,r.filterCategories=(null===(o=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.categories)||void 0===o?void 0:o.map((function(e){return new g(e)})))||null,r.disabledSortTypes=null===(d=e.data)||void 0===d?void 0:d.disabledSortTypes,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(s=r.filterCategories)||void 0===s?void 0:s.find((function(e){return e.id===r.filterCategoryId})))&&(u.isSelected=!0),r.filters&&r.filters.sort((function(e,t){return e.order>t.order?1:-1})),[2]}}))}))}var g=function(e){this.id=e.id,this.name=e.name,this.metaData=e.metaData,this.isAutomated=e.isAutomated,this.resultCount=e.resultCount,this.isSelected=e.isSelected,this.imageId=e.imageId};export{C as getInitial};
1
+ import{__awaiter as e,__generator as t,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i,IkasCategoryProductsOrderType as n}from"@ikas/storefront-models";import{IkasProductListType as a,IkasProductSearchShowStockOption as o,IkasProductListSortType as d}from"./index.js";import{IkasProductFilterFunctions as s}from"@ikas/storefront-model-functions";import{searchProducts as u,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as v,SortByTypeEnum as I}from"@ikas/storefront-api";import{IkasStorefrontConfig as E}from"@ikas/storefront-config";import"../blog-category-list/index.js";import"../blog-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";function p(i,o){var u,l,c,f;return e(this,void 0,void 0,(function(){var e,v,I,E,p,g,y;return t(this,(function(t){switch(t.label){case 0:!function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&[a.ALL].includes(e.type))switch(e.pageSpecificData.orderType){case n.HIGHEST_DISCOUNT_RATIO:e.sort=d.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:e.sort=d.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:e.sort=d.DECREASING_PRICE;break;case n.LOWEST_PRICE:e.sort=d.INCREASING_PRICE;break;case n.NEWEST:e.sort=d.LAST_ADDED;break;case n.OLDEST:e.sort=d.FIRST_ADDED;break;case n.MANUALLY:e.sort=d.FEATURED}}(i),i.isLoading=!0,e=Date.now(),i.fetchRequestTime=e,t.label=1;case 1:return t.trys.push([1,5,,6]),v=o?i.page:1,I=i.limit,!function(e){return e.type===a.ALL||e.type===a.CATEGORY}(i)||i.filters?[3,3]:[4,T(i)];case 2:t.sent(),t.label=3;case 3:if(S(i))return i.data=[],i.page=1,i.minPage=1,i.count=0,i.initialized=!0,[2,!0];if(void 0,C(i))v=void 0,I=200;else if(function(e){return e.type===a.DISCOUNTED}(i))v=1,I=10;else if(function(e){return e.type===a.RECOMMENDED}(i))v=1,I=10;else if(D(i))return[2];return[4,A(i,v||1,I||10,undefined)];case 4:return(E=t.sent())&&i.fetchRequestTime===e?(p=[],D(i)?[2]:(C(i)?(g=i.productListPropValue.productIds||[],p=(null==g?void 0:g.map((function(e){var t,i,n=null===(i=null===(t=E.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.productId})),a=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==a?void 0:a.isActive)||(a=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&a)return r(r({},n),{selectedVariantValues:a.variantValues})})).filter((function(e){return!!e})))||[]):p=(null===(l=null===(u=E.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.map((function(e){var t=e.variants.find((function(e){return e.isActive}));return r(r({},e),{selectedVariantValues:(t||e.variants[0]).variantValues})})))||[],function(e,t){var r,i,n=s.isCustomValueFilter,a=s.getDiscountStatusMapping,o=s.isDiscountStatusFilter;null===(r=e.filters)||void 0===r||r.forEach((function(e){var r,i,d,s=null==t?void 0:t.find((function(t){return t.id===e.id}));s?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=o(e)?a()[t.id]:t.id,i=s.values.find((function(e){return e.id===r}));i?t.resultCount=i.count:n(e)?t.resultCount=null:t.resultCount=0})):n(e)?null===(i=e.values)||void 0===i||i.forEach((function(e){return e.resultCount=null})):null===(d=e.values)||void 0===d||d.forEach((function(e){return e.resultCount=0}))}));var d=null==t?void 0:t.find((function(e){return"category"===e.id}));d&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=d.values.find((function(t){return t.id===e.id}));e.resultCount=t?t.count:0})));e.filters&&e.filters.forEach((function(e){e.values=s.getDisplayedValues(e)}))}(i,null===(c=E.data)||void 0===c?void 0:c.facets),i.data=p,i.count=(null===(f=E.data)||void 0===f?void 0:f.count)||0,i.initialized=!0,i.page=v||1,i.minPage=i.page,[2,!0])):[2];case 5:return y=t.sent(),console.error(y),[3,6];case 6:return[2]}}))}))}function C(e){return e.type===a.STATIC}function D(e){return e.type===a.LAST_VIEWED}function S(e){return e.type===a.SEARCH}function A(r,n,f,p){var D,A,T;return e(this,void 0,void 0,(function(){var e,g,y,R,h,m;return t(this,(function(t){switch(t.label){case 0:return e=[],g=[],y=s.getValueList,null===(D=r.filters)||void 0===D||D.forEach((function(t){var i=y(t);i.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:i}),t.isFacetFilter&&!r.isFacetListNotSent&&g.push({id:t.id,type:t.type,displayType:t.displayType})})),R=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(e){return e.isSelected})).map((function(e){return e.id})),h=function(e){var t,r;switch(e.sort){case d.INCREASING_PRICE:t=v.ASC,r=I.PRICE;break;case d.DECREASING_PRICE:t=v.DESC,r=I.PRICE;break;case d.FIRST_ADDED:t=v.ASC,r=I.CREATED_AT;break;case d.LAST_ADDED:t=v.DESC,r=I.CREATED_AT;break;case d.INCREASING_DISCOUNT:t=v.ASC,r=I.DISCOUNT_RATIO;break;case d.DECRASING_DISCOUNT:t=v.DESC,r=I.DISCOUNT_RATIO;break;case d.FEATURED:if(S(e))return;t=v.ASC,r=I.MANUAL_SORT;break;case d.DEFAULT:t=void 0,r=void 0;break;case d.AVERAGE_RATING:t=v.DESC,r=I.AVERAGE_RATING;break;case d.REVIEW_COUNT:t=v.DESC,r=I.REVIEW_COUNT;break;case d.SALE_COUNT:t=v.DESC,r=I.SALE_COUNT;break;case d.A_Z:t=v.ASC,r=I.NAME;break;case d.Z_A:t=v.DESC,r=I.NAME}if(t&&r)return{direction:t,type:r}}(r),function(e){return e.type===a.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds,locale:E.getCurrentLocale()},r.excludedFields)]:[3,2];case 1:case 3:case 5:case 7:return[2,t.sent()];case 2:return function(e){return e.type===a.RECOMMENDED_PRODUCTS}(r)&&r.recommendedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),brandIds:r.recommendedProductData.brandIds,categoryIds:r.recommendedProductData.categoryIds,locale:E.getCurrentLocale()},r.excludedFields)]:[3,4];case 4:return function(e){return e.type===a.VIEWED_TOGETHER}(r)&&r.viewedTogetherProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),method:c.VIEWED_TOGETHER,productIds:r.viewedTogetherProductData.productIds,locale:E.getCurrentLocale()},r.excludedFields)]:[3,6];case 6:return m={input:{page:n,perPage:f,productIdList:C(r)?null===(T=r.productListPropValue.productIds)||void 0===T?void 0:T.map((function(e){return e.productId})):p,filterList:e,facetList:g,brandId:r.pageType===i.BRAND&&r.type!==a.SEARCH?r.filterBrandId:void 0,categoryIdList:R&&R.length?R:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),query:r.searchKeyword,order:r.type===a.SEARCH?[]:h?[h]:[],showStockOption:E.getStockPreference()||o.SHOW_ALL}},[4,u(m,r.excludedFields)]}}))}))}function T(r){var n,a,o,d,s;return e(this,void 0,void 0,(function(){var e,u;return t(this,(function(t){switch(t.label){case 0:return[4,f({categoryId:r.filterCategoryId?r.filterCategoryId:void 0,locale:E.getCurrentLocale()})];case 1:return e=t.sent(),r.filters=(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.filters)||null,r.filterCategories=(null===(o=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.categories)||void 0===o?void 0:o.map((function(e){return new g(e)})))||null,r.disabledSortTypes=null===(d=e.data)||void 0===d?void 0:d.disabledSortTypes,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(s=r.filterCategories)||void 0===s?void 0:s.find((function(e){return e.id===r.filterCategoryId})))&&(u.isSelected=!0),r.filters&&r.filters.sort((function(e,t){return e.order>t.order?1:-1})),[2]}}))}))}var g=function(e){this.id=e.id,this.name=e.name,this.metaData=e.metaData,this.isAutomated=e.isAutomated,this.resultCount=e.resultCount,this.isSelected=e.isSelected,this.imageId=e.imageId};export{p as getInitial};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as n,__spreadArray as r}from'./../ext/tslib/tslib.es6.js';import i from"lodash/uniq";import a from"lodash/flatten";import{makeAutoObservable as s}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as o,IkasThemeJsonPageType as u,IkasStorefrontPopupPageFilterDataTypeEnum as c,IkasProductAttributeType as l,IkasAmountType as d,IkasCampaignOfferProductApplicablePriceEnum as p,IkasCategoryConditionTypeEnum as f,IkasRaffleMetadataTargetType as g,IkasBlogMetaDataTargetType as v,IkasHTMLMetaDataTargetType as h,IkasThemeJsonComponentPropType as m}from"@ikas/storefront-models";import{IkasStorefrontConfig as T}from"@ikas/storefront-config";import{IkasProductFunctions as S,IkasProductVariantFunctions as I}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as P}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as D}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as O}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as C}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as b}from"./prop-value/link.js";import{IkasImageListPropValueProvider as R}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as y}from"./prop-value/text.js";import{IkasColorPropValueProvider as L}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as E}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as A}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as w}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as F}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as G}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as V}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as U}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as _}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as j}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as N}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as B}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as M}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as k}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as x}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as Y}from"./prop-value/raffle-list.js";import{listMerchantSettings as q,listCustomerReviewSummary as J,searchProducts as H,listCampaignOffer as K,listCustomerReviews as X,listProductOptionSet as z,listProductBrand as Q,listCategory as $,listBlog as W,listBlogCategory as Z,listStorefrontRaffle as ee,listHTMLMetaData as te,listRaffleMetaData as ne,listBlogMetaData as re}from"@ikas/storefront-api";import{populateRaffleProducts as ie}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as ae}from"./prop-value/video.js";var se=function(){function se(e,t,n,r){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=n,this.merchantSettings=r,s(this)}return Object.defineProperty(se.prototype,"page",{get:function(){var e=this;if(this.pageType===u.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===u.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(se.prototype,"nextPageData",{get:function(){var e,t,r,i,a,s=[],o=[];return this.pageComponentPropValues.forEach((function(e){if(o.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:o,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||u.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(i=this.page)||void 0===i?void 0:i.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:T.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),se.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=T.getCurrentRouting();T.getCurrentLocale(),T.getDomain();var n=T.getStorefrontId(),r=T.getStorefrontRoutingId(),i=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=T.getStorefrontPopups(),s=[];a.length&&a.forEach((function(t){var a,l,d,p,f=!1,g=!1,v=!1,h=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===o.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case o.ACCOUNT:if(i)return[u.ACCOUNT,u.ORDERS,u.ORDER_DETAIL,u.FAVORITE_PRODUCTS,u.ADDRESSES,u.RAFFLE_ACCOUNT].includes(i);case o.LOGIN:return i===u.LOGIN;case o.REGISTER:return i===u.REGISTER;case o.CART:return i===u.CART;case o.CATEGORY:return i===u.CATEGORY;case o.HOME:return i===u.INDEX;case o.PRODUCT:return i===u.PRODUCT;case o.PRODUCT_BRAND:return i===u.BRAND;case o.CUSTOM:return!0}}));if(null===(l=null==m?void 0:m.filters)||void 0===l?void 0:l.length)switch(m.pageType){case o.CATEGORY:case o.PRODUCT:case o.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===c.ID_LIST&&T&&(f=S.value.includes(T),h=!0);break;case o.CUSTOM:f=!0;break;default:h=!0,f=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(f=!0,h=!0)}else f=!0,h=!0;if(f)if(g=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===r}))),t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,P=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,D=new Date;(I&&P&&I.getTime()<=D.getTime()&&P.getTime()>=D.getTime()||I&&!P&&I.getTime()<=D.getTime()||P&&!I&&P.getTime()>=D.getTime())&&(v=!0)}}else v=!0;f&&g&&v&&(t.isFilteredOnServerSide=h,s.push(t))})),T.init({storefrontPopups:s})},Object.defineProperty(se.prototype,"specification",{get:function(){var e,t,n=this,r=this.page;return(null==r?void 0:r.type)===u.PRODUCT?null===(e=r.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==r?void 0:r.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(se.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(se.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),se.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,q({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},se.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,n=this;return t(this,(function(t){switch(t.label){case 0:return this.pageSpecificData?[3,2]:[4,this.getPageSpecificData()];case 1:t.sent(),t.label=2;case 2:return this.page?[4,this.getMerchantSettings()]:[2];case 3:return t.sent(),e=this,[4,Promise.all(this.pageComponents.map((function(e){return n.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[4,this.getProductReviewSummary()];case 6:return t.sent(),[2]}}))}))},se.prototype.getProductReviewSummary=function(){var n,r,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==u.PRODUCT?[3,2]:[4,J({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},se.prototype.getPageSpecificData=function(){var r,i,a,s;return e(this,void 0,void 0,(function(){var o,c,m,P,D,O,C,b,R,y,L=this;return t(this,(function(E){switch(E.label){case 0:return this.pageType&&![u.BRAND,u.PRODUCT,u.CATEGORY,u.BLOG,u.BLOG_CATEGORY,u.RAFFLE_DETAIL].includes(this.pageType)?[2]:(o=this.pageParams.slug)?(c=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(u.BLOG))||(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(u.BLOG_CATEGORY))?[4,re({slug:{eq:o}})]:[3,2]):[2];case 1:return m=E.sent(),(c=(null===(a=m.data)||void 0===a?void 0:a.data)||[]).length?[3,6]:[2];case 2:return(null===(s=this.possiblePageTypes)||void 0===s?void 0:s.includes(u.RAFFLE_DETAIL))?[4,ne({slug:{eq:o}})]:[3,4];case 3:return m=E.sent(),(c=m.data||[]).length?[3,6]:[2];case 4:return[4,te({slug:{eq:o}})];case 5:if(m=E.sent(),!(c=m.data||[])||!c.length)return[2];E.label=6;case 6:if(!(P=c[0]).targetId)return[2];switch(D=function(){return e(L,void 0,void 0,(function(){var r,i,a,s,o,c,f,g,v,h,m,D,O,C,b,R,y,L,E,A,w,F,G,V,U,_,j,N,B,M,k,x,Y,q,J,Q,$,W,Z,ee,te,ne,re,ie=this;return t(this,(function(ae){switch(ae.label){case 0:return[4,H({input:{productIdList:[P.targetId],priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})];case 1:return r=ae.sent(),(null===(x=null===(k=null==r?void 0:r.data)||void 0===k?void 0:k.data)||void 0===x?void 0:x.length)?(i=T.getCurrentRouting(),a=T.getRoutings(),s=a.find((function(e){return null===e.path})),o=null==i?void 0:i.path,(c=r.data.data[0]).productOptionSetId?[4,z({id:{eq:c.productOptionSetId}})]:[3,3]):[2];case 2:(f=ae.sent()).isSuccess&&(null===(Y=null==f?void 0:f.data)||void 0===Y?void 0:Y.length)&&(c.productOptionSet=f.data[0]),ae.label=3;case 3:return((null===(q=T.getDomain())||void 0===q?void 0:q.includes("thepurestsolutions"))||(null===(J=process.env.NEXT_PUBLIC_GQL_URL)||void 0===J?void 0:J.includes(".dev"))&&!T.getIsEditor())&&(g=c.variants.find((function(e){return e.isActive})))?(v=!!(null===(Q=g.bundleSettings)||void 0===Q?void 0:Q.products.length),h=[c.id],v&&(null===($=g.bundleSettings)||void 0===$||$.products.forEach((function(e){h.push(e.productId)}))),[4,X({productId:v?null:c.id,productIds:v?h:null,input:{salesChannelId:T.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:m=ae.sent(),(null===(W=m.data)||void 0===W?void 0:W.data)&&m.isSuccess&&(D=m.data.data,O=!!(null===(Z=g.bundleSettings)||void 0===Z?void 0:Z.products.length),C=[c.id],O&&(null===(ee=g.bundleSettings)||void 0===ee||ee.products.forEach((function(e){C.push(e.productId)}))),c.customerReviews=n(n({data:D,count:D.length,limit:10,page:1,initialized:!0},O?{}:{productId:c.id}),O?{productIds:C}:{})),ae.label=5;case 5:return(null===(te=c.campaignOffers)||void 0===te?void 0:te.length)?[4,K({id:{in:c.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(b=ae.sent()).isSuccess&&(null===(ne=b.data)||void 0===ne?void 0:ne.length)?(R=b.data[0],y=[],L=[],R.offers.forEach((function(e){return y.push(e.productId)})),[4,H({input:{productIdList:y,priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})]):[3,8];case 7:(A=ae.sent()).isSuccess&&A.data&&R.offers.forEach((function(e){var t,r,i=null===(r=null===(t=A.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.productId}));if(i){var a=i.variants.filter((function(t){return I.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var r=!1;return e.discountType===d.AMOUNT&&(r=!0),n(n({},t),{prices:t.prices.map((function(t){var i=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=i,s=i-(r?e.discountAmount:i*e.discountAmount/100);return e.applicablePrice===p.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(r?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&L.push({campaignOfferId:R.id,campaignOfferProductId:e.id,product:n(n({},i),{variants:a})})}E||(E={campaignOfferId:R.id,title:e.title,description:e.description})})),c.appliedCampaignOffer=E,c.offers=L,ae.label=8;case 8:return c.productGroup?[4,H({input:{productGroupId:c.productGroup.id,productGroupKey:c.productGroup.groupKey,priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(w=ae.sent()).isSuccess&&(null===(re=w.data)||void 0===re?void 0:re.data)&&(c.productGroupItems=w.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:S.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order}}))),ae.label=10;case 10:return c.attributes.length||c.variants.some((function(e){return e.attributes.some((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)===l.PRODUCT}))}))?(F=c,[4,this.setProductAttributes(c)]):[3,13];case 11:return F.attributes=ae.sent(),[4,Promise.all(c.variants.map((function(n){return e(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=n,[4,this.setProductAttributes(n)];case 1:return e.attributes=t.sent(),[2]}}))}))})))];case 12:ae.sent(),ae.label=13;case 13:return(G=c.variants.find((function(e){return e.isActive})))?(c.selectedVariantValues=G.variantValues,V=S.getDisplayedVariantTypes,this.pageSpecificData=c,(U=V(this.pageSpecificData,c.selectedVariantValues)).length&&(_=U[0]).displayedVariantValues.length&&(j=_.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=j.variant.variantValues),this.pageType=u.PRODUCT,N=P,B=s&&s.locale===(null==i?void 0:i.locale),N&&(null==N?void 0:N.translations)&&!B&&(M=null==N?void 0:N.translations.find((function(e){return e.locale===o})),N.pageTitle=(null==M?void 0:M.pageTitle)||null,N.description=(null==M?void 0:M.description)||null),this.setPageMetaData(N),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Q({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BRAND,this.setPageMetaData(P),[2]):[2]}}))}))},C=function(){return e(L,void 0,void 0,(function(){var e,n,r,i,a,s,o,c;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(s=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?(n=e.data.data[0]).conditions&&(r=n.conditions.find((function(e){return e.conditionType===f.PRODUCT_BRAND})))?[4,Q({id:{eq:r.valueList[0]}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(c=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===c?void 0:c.length)&&(n.conditionValues={brand:i.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=u.CATEGORY,this.setPageMetaData(P),[2]}}))}))},b=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BLOG,this.setPageMetaData(P),[2]):[2]}}))}))},R=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Z({id:{eq:P.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BLOG_CATEGORY,this.setPageMetaData(P),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,ee({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],[4,ie([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=u.RAFFLE_DETAIL,this.setPageMetaData(P),[2]}}))}))},P.targetType){case h.BRAND:return[3,7];case h.CATEGORY:return[3,9];case h.PRODUCT:return[3,11];case v.BLOG:return[3,13];case v.BLOG_CATEGORY:return[3,15];case g.RAFFLE:return[3,17]}return[3,19];case 7:return[4,O()];case 8:return[2,E.sent()];case 9:return[4,C()];case 10:return[2,E.sent()];case 11:return[4,D()];case 12:return[2,E.sent()];case 13:return[4,b()];case 14:return[2,E.sent()];case 15:return[4,R()];case 16:return[2,E.sent()];case 17:return[4,y()];case 18:return[2,E.sent()];case 19:return[3,20];case 20:return[2]}}))}))},se.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var r,i,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((r=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||r.isFooter)&&(n.propValues=r.commonPropValues||n.propValues),i={pageComponent:n,component:r,propValues:{}},a=function(r){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=i.propValues,a=r.name,[4,this.getPageComponentPropValue(n,r)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(a))];case 1:return o.sent(),[2,i]}}))}))},se.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,o,u,c,l,d,p,f,g=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[m.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case m.TEXT:return[3,1];case m.RICH_TEXT:return[3,2];case m.BOOLEAN:return[3,3];case m.IMAGE:return[3,4];case m.IMAGE_LIST:return[3,5];case m.BRAND:return[3,6];case m.BRAND_LIST:return[3,7];case m.PRODUCT_LIST:return[3,8];case m.PRODUCT_DETAIL:return[3,9];case m.PRODUCT_ATTRIBUTE:return[3,10];case m.PRODUCT_ATTRIBUTE_LIST:return[3,11];case m.CATEGORY:return[3,12];case m.CATEGORY_LIST:return[3,13];case m.LINK:case m.LIST_OF_LINK:return[3,14];case m.COLOR:return[3,15];case m.CUSTOM:return[3,16];case m.COMPONENT:case m.COMPONENT_LIST:return[3,17];case m.BLOG:return[3,19];case m.BLOG_LIST:return[3,20];case m.BLOG_CATEGORY:return[3,21];case m.BLOG_CATEGORY_LIST:return[3,22];case m.RAFFLE:return[3,23];case m.RAFFLE_LIST:return[3,24];case m.SLIDER:return[3,25];case m.VIDEO:return[3,26]}return[3,27];case 1:return e=new y(a),[3,28];case 2:return e=new U(a),[3,28];case 3:return e=new E(a),[3,28];case 4:return e=new A(a),[3,28];case 5:return e=new R(a),[3,28];case 6:return e=new C(a),[3,28];case 7:return e=new O(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===r.componentId})),u=[],o&&(d=o.props.find((function(e){return e.name===i.name})))&&(u=d.excludedFields||[]),e=new P(this.pageType,n(n({},a),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new D(a),[3,28];case 10:return e=new N(a),[3,28];case 11:return e=new B(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===r.componentId})),l=[],c&&(d=c.props.find((function(e){return e.name===i.name})))&&(l=d.excludedFieldsCategory||[]),e=new w(n(n({},a),{excludedFieldsCategory:l})),[3,28];case 13:return e=new F(a),[3,28];case 14:return e=new b(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new L(a),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new G(a,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return f=a,[4,Promise.all(f.map((function(e){return g.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new _(a),[3,28];case 20:return e=new j(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new M(a),[3,28];case 22:return e=new k(a),[3,28];case 23:return e=new x(a),[3,28];case 24:return e=new Y,[3,28];case 25:return e=new V(a),[3,28];case 26:return e=new ae(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},se.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle||null,this.page.description=e.description||null,this.page.canonicals=e.canonicals||null,this.page.disableIndex=e.disableIndex||null)},se.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},se.prototype.getLinkSlugs=function(n,r){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=i(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],r){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,te({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,re({targetId:{in:a}})];case 4:return i=t.sent(),e=(null===(u=i.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ne({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},se.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=a(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(n)},se.prototype.setProductAttributes=function(i){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=i.attributes.filter((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)===l.PRODUCT})).map((function(r){return e(o,void 0,void 0,(function(){var e,i,a,s;return t(this,(function(t){switch(t.label){case 0:return r.value?[4,H({input:{productIdList:JSON.parse(r.value),priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})]:[2,n(n({},r),{products:[]})];case 1:return e=t.sent(),null===(a=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===a||a.forEach((function(e){e.selectedVariantValues=e.variants[0].variantValues})),[2,n(n({},r),{products:(null===(s=e.data)||void 0===s?void 0:s.data)||[]})]}}))}))})),[4,Promise.allSettled(a)];case 1:return s=u.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value})),[2,r(r([],i.attributes.filter((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)!==l.PRODUCT})),!0),s,!0)]}}))}))},se}();export{se as IkasPageDataProvider};
1
+ import{__awaiter as e,__generator as t,__assign as n,__spreadArray as i}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import a from"lodash/flatten";import{makeAutoObservable as s}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as o,IkasThemeJsonPageType as u,IkasStorefrontPopupPageFilterDataTypeEnum as l,IkasProductAttributeType as c,IkasAmountType as d,IkasCampaignOfferProductApplicablePriceEnum as p,IkasCategoryConditionTypeEnum as f,IkasRaffleMetadataTargetType as g,IkasBlogMetaDataTargetType as v,IkasHTMLMetaDataTargetType as h,IkasThemeJsonComponentPropType as m}from"@ikas/storefront-models";import{IkasStorefrontConfig as T}from"@ikas/storefront-config";import{IkasProductFunctions as S,IkasProductVariantFunctions as I}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as P}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as D}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as O}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as C}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as L}from"./prop-value/link.js";import{IkasImageListPropValueProvider as R}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as b}from"./prop-value/text.js";import{IkasColorPropValueProvider as y}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as E}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as A}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as w}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as F}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as G}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as V}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as U}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as _}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as N}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as j}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as B}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as M}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as k}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as x}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as Y}from"./prop-value/raffle-list.js";import{listMerchantSettings as q,listCustomerReviewSummary as J,searchProducts as X,listCampaignOffer as H,listCustomerReviews as K,listProductOptionSet as Q,listProductBrand as z,listCategory as $,listBlog as W,listBlogCategory as Z,listStorefrontRaffle as ee,listHTMLMetaData as te,listRaffleMetaData as ne,listBlogMetaData as ie}from"@ikas/storefront-api";import{populateRaffleProducts as re}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as ae}from"./prop-value/video.js";var se=function(){function se(e,t,n,i){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=n,this.merchantSettings=i,s(this)}return Object.defineProperty(se.prototype,"page",{get:function(){var e=this;if(this.pageType===u.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===u.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(se.prototype,"nextPageData",{get:function(){var e,t,i,r,a,s=[],o=[];return this.pageComponentPropValues.forEach((function(e){if(o.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:o,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||u.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(i=this.page)||void 0===i?void 0:i.description)||null,canonicals:(null===(r=this.page)||void 0===r?void 0:r.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:n(n({},T.toJSON()||{}),{apiUrl:process.env.NEXT_PUBLIC_GQL_URL}),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),se.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=T.getCurrentRouting();T.getCurrentLocale(),T.getDomain();var n=T.getStorefrontId(),i=T.getStorefrontRoutingId(),r=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=T.getStorefrontPopups(),s=[];a.length&&a.forEach((function(t){var a,c,d,p,f,g=!1,v=!1,h=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===o.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case o.ACCOUNT:if(r)return[u.ACCOUNT,u.ORDERS,u.ORDER_DETAIL,u.FAVORITE_PRODUCTS,u.ADDRESSES,u.RAFFLE_ACCOUNT].includes(r);case o.LOGIN:return r===u.LOGIN;case o.REGISTER:return r===u.REGISTER;case o.CART:return r===u.CART;case o.CATEGORY:return r===u.CATEGORY;case o.HOME:return r===u.INDEX;case o.PRODUCT:return r===u.PRODUCT;case o.PRODUCT_BRAND:return r===u.BRAND;case o.CUSTOM:return!0}}));if(null===(c=null==m?void 0:m.filters)||void 0===c?void 0:c.length)switch(m.pageType){case o.CATEGORY:case o.PRODUCT:case o.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===l.ID_LIST&&T&&(g=S.value.includes(T),h=!0);break;case o.CUSTOM:g=!0,h=!1;break;default:h=!0,g=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(g=!0,h=!0)}else g=!0,h=!0;if(f=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===i}))),g)if(t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,P=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,D=new Date;(I&&P&&I.getTime()<=D.getTime()&&P.getTime()>=D.getTime()||I&&!P&&I.getTime()<=D.getTime()||P&&!I&&P.getTime()>=D.getTime())&&(v=!0)}}else v=!0;g&&f&&v&&(t.isFilteredOnServerSide=h,s.push(t))})),T.init({storefrontPopups:s})},Object.defineProperty(se.prototype,"specification",{get:function(){var e,t,n=this,i=this.page;return(null==i?void 0:i.type)===u.PRODUCT?null===(e=i.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==i?void 0:i.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(se.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(se.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),se.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,q({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},se.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,n=this;return t(this,(function(t){switch(t.label){case 0:return this.pageSpecificData?[3,2]:[4,this.getPageSpecificData()];case 1:t.sent(),t.label=2;case 2:return this.page?[4,this.getMerchantSettings()]:[2];case 3:return t.sent(),e=this,[4,Promise.all(this.pageComponents.map((function(e){return n.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[4,this.getProductReviewSummary()];case 6:return t.sent(),[2]}}))}))},se.prototype.getProductReviewSummary=function(){var n,i,r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==u.PRODUCT?[3,2]:[4,J({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(r=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===r?void 0:r.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},se.prototype.getPageSpecificData=function(){var i,r,a,s;return e(this,void 0,void 0,(function(){var o,l,m,P,D,O,C,L,R,b,y=this;return t(this,(function(E){switch(E.label){case 0:return this.pageType&&![u.BRAND,u.PRODUCT,u.CATEGORY,u.BLOG,u.BLOG_CATEGORY,u.RAFFLE_DETAIL].includes(this.pageType)?[2]:(o=this.pageParams.slug)?(l=[],(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(u.BLOG))||(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(u.BLOG_CATEGORY))?[4,ie({slug:{eq:o}})]:[3,2]):[2];case 1:return m=E.sent(),(l=(null===(a=m.data)||void 0===a?void 0:a.data)||[]).length?[3,6]:[2];case 2:return(null===(s=this.possiblePageTypes)||void 0===s?void 0:s.includes(u.RAFFLE_DETAIL))?[4,ne({slug:{eq:o}})]:[3,4];case 3:return m=E.sent(),(l=m.data||[]).length?[3,6]:[2];case 4:return[4,te({slug:{eq:o}})];case 5:if(m=E.sent(),!(l=m.data||[])||!l.length)return[2];E.label=6;case 6:if(!(P=l[0]).targetId)return[2];switch(D=function(){return e(y,void 0,void 0,(function(){var i,r,a,s,o,l,f,g,v,h,m,D,O,C,L,R,b,y,E,A,w,F,G,V,U,_,N,j,B,M,k,x,Y,q,J,z,$,W,Z,ee,te,ne,ie=this;return t(this,(function(re){switch(re.label){case 0:return[4,X({input:{productIdList:[P.targetId],priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})];case 1:return i=re.sent(),(null===(M=null===(B=null==i?void 0:i.data)||void 0===B?void 0:B.data)||void 0===M?void 0:M.length)?(r=T.getCurrentRouting(),a=null==r?void 0:r.locale,(s=i.data.data[0]).productOptionSetId?[4,Q({id:{eq:s.productOptionSetId}})]:[3,3]):[2];case 2:(o=re.sent()).isSuccess&&(null===(k=null==o?void 0:o.data)||void 0===k?void 0:k.length)&&(s.productOptionSet=o.data[0]),re.label=3;case 3:return((null===(x=T.getDomain())||void 0===x?void 0:x.includes("thepurestsolutions"))||(null===(Y=process.env.NEXT_PUBLIC_GQL_URL)||void 0===Y?void 0:Y.includes(".dev"))&&!T.getIsEditor())&&(l=s.variants.find((function(e){return e.isActive})))?(f=!!(null===(q=l.bundleSettings)||void 0===q?void 0:q.products.length),g=[s.id],f&&(null===(J=l.bundleSettings)||void 0===J||J.products.forEach((function(e){g.push(e.productId)}))),[4,K({productId:f?null:s.id,productIds:f?g:null,input:{salesChannelId:T.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:v=re.sent(),(null===(z=v.data)||void 0===z?void 0:z.data)&&v.isSuccess&&(h=v.data.data,m=!!(null===($=l.bundleSettings)||void 0===$?void 0:$.products.length),D=[s.id],m&&(null===(W=l.bundleSettings)||void 0===W||W.products.forEach((function(e){D.push(e.productId)}))),s.customerReviews=n(n({data:h,count:h.length,limit:10,page:1,initialized:!0},m?{}:{productId:s.id}),m?{productIds:D}:{})),re.label=5;case 5:return(null===(Z=s.campaignOffers)||void 0===Z?void 0:Z.length)?[4,H({id:{in:s.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(O=re.sent()).isSuccess&&(null===(ee=O.data)||void 0===ee?void 0:ee.length)?(C=O.data[0],L=[],R=[],C.offers.forEach((function(e){return L.push(e.productId)})),[4,X({input:{productIdList:L,priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})]):[3,8];case 7:(y=re.sent()).isSuccess&&y.data&&C.offers.forEach((function(e){var t,i,r=null===(i=null===(t=y.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.productId}));if(r){var a=r.variants.filter((function(t){return I.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var i=!1;return e.discountType===d.AMOUNT&&(i=!0),n(n({},t),{prices:t.prices.map((function(t){var r=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=r,s=r-(i?e.discountAmount:r*e.discountAmount/100);return e.applicablePrice===p.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(i?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&R.push({campaignOfferId:C.id,campaignOfferProductId:e.id,title:e.title,description:e.description,product:n(n({},r),{variants:a})})}b||(b={campaignOfferId:C.id,title:e.title,description:e.description})})),s.appliedCampaignOffer=b,s.offers=R,re.label=8;case 8:return s.productGroup?[4,X({input:{productGroupId:s.productGroup.id,productGroupKey:s.productGroup.groupKey,priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(E=re.sent()).isSuccess&&(null===(te=E.data)||void 0===te?void 0:te.data)&&(s.productGroupItems=E.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:S.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order,hasStock:S.hasStock(e)}}))),re.label=10;case 10:return s.attributes.length||s.variants.some((function(e){return e.attributes.some((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)===c.PRODUCT}))}))?(A=s,[4,this.setProductAttributes(s)]):[3,13];case 11:return A.attributes=re.sent(),[4,Promise.all(s.variants.map((function(n){return e(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=n,[4,this.setProductAttributes(n)];case 1:return e.attributes=t.sent(),[2]}}))}))})))];case 12:re.sent(),re.label=13;case 13:return(w=s.variants.find((function(e){return e.isActive})))?(s.selectedVariantValues=w.variantValues,F=S.getDisplayedVariantTypes,this.pageSpecificData=s,(G=F(this.pageSpecificData,s.selectedVariantValues)).length&&(V=G[0]).displayedVariantValues.length&&(U=V.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=U.variant.variantValues),this.pageType=u.PRODUCT,_=P,N=(null===(ne=T.getMerchantSettings())||void 0===ne?void 0:ne.defaultLocale)||"tr",N===a||_&&(null==_?void 0:_.translations)&&(j=null==_?void 0:_.translations.find((function(e){return e.locale===a})),_.pageTitle=(null==j?void 0:j.pageTitle)||null,_.description=(null==j?void 0:j.description)||null),this.setPageMetaData(_),[2]):[2]}}))}))},O=function(){return e(y,void 0,void 0,(function(){var e,n,i,r,a,s,o,l,c,d;return t(this,(function(t){switch(t.label){case 0:return[4,z({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(c=null===(l=e.data)||void 0===l?void 0:l.data)||void 0===c?void 0:c.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BRAND,i=P,r=T.getCurrentRouting(),a=null==r?void 0:r.locale,s=(null===(d=T.getMerchantSettings())||void 0===d?void 0:d.defaultLocale)||"tr",s===a||i&&(null==i?void 0:i.translations)&&(o=null==i?void 0:i.translations.find((function(e){return e.locale===a})),i.pageTitle=(null==o?void 0:o.pageTitle)||null,i.description=(null==o?void 0:o.description)||null),this.setPageMetaData(i),[2]):[2]}}))}))},C=function(){return e(y,void 0,void 0,(function(){var e,n,i,r,a,s,o,l,c,d,p,g,v,h;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(p=null===(d=e.data)||void 0===d?void 0:d.data)||void 0===p?void 0:p.length)?(n=e.data.data[0]).conditions&&(i=n.conditions.find((function(e){return e.conditionType===f.PRODUCT_BRAND})))?[4,z({id:{eq:i.valueList[0]}})]:[3,3]:[2];case 2:(r=t.sent()).isSuccess&&(null===(v=null===(g=r.data)||void 0===g?void 0:g.data)||void 0===v?void 0:v.length)&&(n.conditionValues={brand:r.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=u.CATEGORY,a=P,s=T.getCurrentRouting(),o=null==s?void 0:s.locale,l=(null===(h=T.getMerchantSettings())||void 0===h?void 0:h.defaultLocale)||"tr",l===o||a&&(null==a?void 0:a.translations)&&(c=null==a?void 0:a.translations.find((function(e){return e.locale===o})),a.pageTitle=(null==c?void 0:c.pageTitle)||null,a.description=(null==c?void 0:c.description)||null),this.setPageMetaData(a),[2]}}))}))},L=function(){return e(y,void 0,void 0,(function(){var e,n,i,r;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===r?void 0:r.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BLOG,this.setPageMetaData(P),[2]):[2]}}))}))},R=function(){return e(y,void 0,void 0,(function(){var e,n,i,r;return t(this,(function(t){switch(t.label){case 0:return[4,Z({id:{eq:P.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===r?void 0:r.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BLOG_CATEGORY,this.setPageMetaData(P),[2]):[2]}}))}))},b=function(){return e(y,void 0,void 0,(function(){var e,n,i,r;return t(this,(function(t){switch(t.label){case 0:return[4,ee({id:{eq:P.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===r?void 0:r.length)?(n=e.data.data[0],[4,re([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=u.RAFFLE_DETAIL,this.setPageMetaData(P),[2]}}))}))},P.targetType){case h.BRAND:return[3,7];case h.CATEGORY:return[3,9];case h.PRODUCT:return[3,11];case v.BLOG:return[3,13];case v.BLOG_CATEGORY:return[3,15];case g.RAFFLE:return[3,17]}return[3,19];case 7:return[4,O()];case 8:return[2,E.sent()];case 9:return[4,C()];case 10:return[2,E.sent()];case 11:return[4,D()];case 12:return[2,E.sent()];case 13:return[4,L()];case 14:return[2,E.sent()];case 15:return[4,R()];case 16:return[2,E.sent()];case 17:return[4,b()];case 18:return[2,E.sent()];case 19:return[3,20];case 20:return[2]}}))}))},se.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var i,r,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((i=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||i.isFooter)&&(n.propValues=i.commonPropValues||n.propValues),r={pageComponent:n,component:i,propValues:{}},a=function(i){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=r.propValues,a=i.name,[4,this.getPageComponentPropValue(n,i)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(i.props.map(a))];case 1:return o.sent(),[2,r]}}))}))},se.prototype.getPageComponentPropValue=function(i,r){return e(this,void 0,void 0,(function(){var e,a,s,o,u,l,c,d,p,f,g,v=this;return t(this,(function(t){switch(t.label){case 0:if(a=i.propValues[r.name],s=[m.RAFFLE_LIST],null==a&&!s.includes(r.type))return[2,null];switch(r.type){case m.TEXT:return[3,1];case m.RICH_TEXT:return[3,2];case m.BOOLEAN:return[3,3];case m.IMAGE:return[3,4];case m.IMAGE_LIST:return[3,5];case m.BRAND:return[3,6];case m.BRAND_LIST:return[3,7];case m.PRODUCT_LIST:return[3,8];case m.PRODUCT_DETAIL:return[3,9];case m.PRODUCT_ATTRIBUTE:return[3,10];case m.PRODUCT_ATTRIBUTE_LIST:return[3,11];case m.CATEGORY:return[3,12];case m.CATEGORY_LIST:return[3,13];case m.LINK:case m.LIST_OF_LINK:return[3,14];case m.COLOR:return[3,15];case m.CUSTOM:return[3,16];case m.COMPONENT:case m.COMPONENT_LIST:return[3,17];case m.BLOG:return[3,19];case m.BLOG_LIST:return[3,20];case m.BLOG_CATEGORY:return[3,21];case m.BLOG_CATEGORY_LIST:return[3,22];case m.RAFFLE:return[3,23];case m.RAFFLE_LIST:return[3,24];case m.SLIDER:return[3,25];case m.VIDEO:return[3,26]}return[3,27];case 1:return e=new b(a),[3,28];case 2:return e=new U(a),[3,28];case 3:return e=new E(a),[3,28];case 4:return e=new A(a),[3,28];case 5:return e=new R(a),[3,28];case 6:return e=new C(a),[3,28];case 7:return e=new O(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===i.componentId})),u=[],l=!1,o&&(p=o.props.find((function(e){return e.name===r.name})))&&(u=p.excludedFields||[],l=!!p.isFacetListNotSent),e=new P(this.pageType,n(n({},a),{excludedFields:u,isFacetListNotSent:l}),this.pageSpecificData),[3,28];case 9:return e=new D(a),[3,28];case 10:return e=new j(a),[3,28];case 11:return e=new B(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===i.componentId})),d=[],c&&(p=c.props.find((function(e){return e.name===r.name})))&&(d=p.excludedFieldsCategory||[]),e=new w(n(n({},a),{excludedFieldsCategory:d})),[3,28];case 13:return e=new F(a),[3,28];case 14:return e=new L(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new y(a),[3,28];case 16:return(f=this.theme.customData.find((function(e){return e.id===r.customDataId})))?(e=new G(a,f,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return g=a,[4,Promise.all(g.map((function(e){return v.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new _(a),[3,28];case 20:return e=new N(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new M(a),[3,28];case 22:return e=new k(a),[3,28];case 23:return e=new x(a),[3,28];case 24:return e=new Y,[3,28];case 25:return e=new V(a),[3,28];case 26:return e=new ae(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},se.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle||null,this.page.description=e.description||null,this.page.canonicals=e.canonicals||null,this.page.disableIndex=e.disableIndex||null)},se.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,i;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],i=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":i.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(i,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},se.prototype.getLinkSlugs=function(n,i){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=r(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],i){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,te({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,ie({targetId:{in:a}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ne({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},se.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=a(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),i=[];return i.push(e),i=i.concat(n)},se.prototype.setProductAttributes=function(r){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=r.attributes.filter((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)===c.PRODUCT})).map((function(i){return e(o,void 0,void 0,(function(){var e,r,a,s;return t(this,(function(t){switch(t.label){case 0:return i.value?[4,X({input:{productIdList:JSON.parse(i.value),priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})]:[2,n(n({},i),{products:[]})];case 1:return e=t.sent(),null===(a=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===a||a.forEach((function(e){e.selectedVariantValues=e.variants[0].variantValues})),[2,n(n({},i),{products:(null===(s=e.data)||void 0===s?void 0:s.data)||[]})]}}))}))})),[4,Promise.allSettled(a)];case 1:return s=u.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value})),[2,i(i([],r.attributes.filter((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)!==c.PRODUCT})),!0),s,!0)]}}))}))},se}();export{se as IkasPageDataProvider};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import a from"lodash/cloneDeep";import{IkasBrandListPropValueProvider as s}from"./brand-list.js";import{IkasBrandPropValueProvider as u}from"./brand.js";import{IkasCategoryListPropValueProvider as i}from"./category-list.js";import{IkasCategoryPropValueProvider as n}from"./category.js";import{IkasColorPropValueProvider as o}from"./color.js";import{IkasBooleanPropValueProvider as c}from"./boolean.js";import{IkasTextPropValueProvider as l}from"./text.js";import{IkasImageListPropValueProvider as h}from"./image-list.js";import{IkasImagePropValueProvider as d}from"./image.js";import{IkasVideoPropValueProvider as p}from"./video.js";import{IkasLinkPropValueProvider as m}from"./link.js";import{IkasProductPropValueProvider as f}from"./product-detail.js";import{IkasProductListPropValueProvider as g}from"./product-list.js";import{IkasRichTextPropValueProvider as v}from"./rich-text.js";import{IkasBlogPropValueProvider as D}from"./blog.js";import{IkasBlogListPropValueProvider as V}from"./blog-list.js";import{IkasAttributePropValueProvider as w}from"./attribute.js";import{IkasAttributeListPropValueProvider as I}from"./attribute-list.js";import{IkasBlogCategoryPropValueProvider as y}from"./blog-category.js";import{IkasBlogCategoryListPropValueProvider as P}from"./blog-category-list.js";import{IkasRaffleListPropValueProvider as T}from"./raffle-list.js";import{IkasRafflePropValueProvider as b}from"./raffle.js";import{IkasSliderPropValueProvider as L}from"./slider.js";import{IkasThemeJsonComponentPropType as R}from"@ikas/storefront-models";var C=function(){function C(t,e,r,a,s,u,i){this.value=t,this.customData=e,this.theme=r,this.pageType=a,this.pageDataProvider=s,this.pageSpecificData=u,this.pageParams=i}return C.prototype.getValue=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if((void 0===this.value||null===this.value)&&this.customData.type!==R.RAFFLE_LIST)return[2,{value:null,customDataId:this.customData.id}];e.label=1;case 1:switch(e.trys.push([1,60,,61]),this.customData.type){case R.TEXT:return[3,2];case R.RICH_TEXT:return[3,4];case R.BOOLEAN:return[3,6];case R.BRAND_LIST:return[3,8];case R.BRAND:return[3,10];case R.CATEGORY_LIST:return[3,12];case R.CATEGORY:return[3,14];case R.COLOR:return[3,16];case R.IMAGE_LIST:return[3,18];case R.IMAGE:return[3,20];case R.LINK:case R.LIST_OF_LINK:return[3,22];case R.PRODUCT_DETAIL:return[3,24];case R.PRODUCT_LIST:return[3,26];case R.PRODUCT_ATTRIBUTE:return[3,28];case R.PRODUCT_ATTRIBUTE_LIST:return[3,30];case R.OBJECT:return[3,32];case R.DYNAMIC_LIST:case R.STATIC_LIST:return[3,34];case R.ENUM:return[3,36];case R.CUSTOM:return[3,38];case R.COMPONENT:case R.COMPONENT_LIST:return[3,40];case R.BLOG:return[3,42];case R.BLOG_LIST:return[3,44];case R.BLOG_CATEGORY:return[3,46];case R.BLOG_CATEGORY_LIST:return[3,48];case R.RAFFLE:return[3,50];case R.RAFFLE_LIST:return[3,52];case R.SLIDER:return[3,54];case R.VIDEO:return[3,56]}return[3,58];case 2:return[4,this.getTextValue()];case 3:return t=e.sent(),[3,59];case 4:return[4,this.getRichTextPropValue()];case 5:return t=e.sent(),[3,59];case 6:return[4,this.getBooleanValue()];case 7:return t=e.sent(),[3,59];case 8:return[4,this.getBrandListPropValue()];case 9:return t=e.sent(),[3,59];case 10:return[4,this.getBrandPropValue()];case 11:return t=e.sent(),[3,59];case 12:return[4,this.getCategoryListPropValue()];case 13:return t=e.sent(),[3,59];case 14:return[4,this.getCategoryPropValue()];case 15:return t=e.sent(),[3,59];case 16:return[4,this.getColorPropValue()];case 17:return t=e.sent(),[3,59];case 18:return[4,this.getImageListPropValue()];case 19:return t=e.sent(),[3,59];case 20:return[4,this.getImagePropValue()];case 21:return t=e.sent(),[3,59];case 22:return[4,this.getLinkPropValue()];case 23:return t=e.sent(),[3,59];case 24:return[4,this.getProductDetailPropValue()];case 25:return t=e.sent(),[3,59];case 26:return[4,this.getProductListPropValue()];case 27:return t=e.sent(),[3,59];case 28:return[4,this.getProductAttributePropValue()];case 29:return t=e.sent(),[3,59];case 30:return[4,this.getProductAttributeListPropValue()];case 31:return t=e.sent(),[3,59];case 32:return[4,this.getObjectValue()];case 33:return t=e.sent(),[3,59];case 34:return[4,this.getArrayValue()];case 35:return t=e.sent(),[3,59];case 36:return[4,this.getEnumValue()];case 37:return t=e.sent(),[3,59];case 38:return[4,this.getCustomDataValue()];case 39:return t=e.sent(),[3,59];case 40:return[4,this.getComponentListValue()];case 41:return t=e.sent(),[3,59];case 42:return[4,this.getBlogValue()];case 43:return t=e.sent(),[3,59];case 44:return[4,this.getBlogListValue()];case 45:return t=e.sent(),[3,59];case 46:return[4,this.getBlogCategoryValue()];case 47:return t=e.sent(),[3,59];case 48:return[4,this.getBlogCategoryListValue()];case 49:return t=e.sent(),[3,59];case 50:return[4,this.getRaffleValue()];case 51:return t=e.sent(),[3,59];case 52:return[4,this.getRaffleListValue()];case 53:return t=e.sent(),[3,59];case 54:return[4,this.getSliderValue()];case 55:return t=e.sent(),[3,59];case 56:return[4,this.getVideoPropValue()];case 57:return t=e.sent(),[3,59];case 58:return[3,59];case 59:return[3,61];case 60:return e.sent(),[2];case 61:return!this.customData.isRequired||void 0!==(null==t?void 0:t.value)&&null!==(null==t?void 0:t.value)?[2,t]:[2]}}))}))},C.prototype.getBooleanValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new c(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBrandListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new s(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBrandPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new u(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getCategoryListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new i(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getCategoryPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new n(r(r({},this.value),{excludedFieldsCategory:this.customData.excludedFieldsCategory})).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getColorPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new o(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getRichTextPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new v(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getImageListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new h(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getImagePropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new d(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getLinkPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new m(this.value,this.theme,this.pageDataProvider.linkMetaDataTargetIds).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductDetailPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new f(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new g(this.pageType,r(r({},this.value),{excludedFields:this.customData.excludedFields}),this.pageSpecificData).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductAttributePropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new w(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductAttributeListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new I(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getTextValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new l(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getObjectValue=function(){return t(this,void 0,void 0,(function(){var t,r,a,s,u,i;return e(this,(function(e){switch(e.label){case 0:t={},r=0,a=this.customData.nestedData||[],e.label=1;case 1:if(!(r<a.length))return[3,4];if(!(s=a[r]).key)return[3,3];if(u=this.value[s.key],s.isRequired&&s.type!==R.RAFFLE_LIST&&null==u)throw new Error("Required data is missing");return[4,new C(u,s,this.theme,this.pageType,this.pageDataProvider,this.pageSpecificData).getValue()];case 2:if(i=e.sent(),s.isRequired&&null==i)throw new Error("Required data is missing");t[s.key]=i,e.label=3;case 3:return r++,[3,1];case 4:return[2,{value:t,customDataId:this.customData.id}]}}))}))},C.prototype.getArrayValue=function(){return t(this,void 0,void 0,(function(){var t,r,a,s,u,i;return e(this,(function(e){switch(e.label){case 0:if(!this.value||!Array.isArray(this.value))throw new Error("Incorrect data!");t=[],r=this.customData.nestedData[0],a=0,s=this.value,e.label=1;case 1:if(!(a<s.length))return[3,4];if(u=s[a],r.isRequired&&r.type!==R.RAFFLE_LIST&&null==u)throw new Error("Required data is missing");return[4,new C(u,r,this.theme,this.pageType,this.pageDataProvider,this.pageSpecificData).getValue()];case 2:if(i=e.sent(),r.isRequired&&null==i)throw new Error("Required data is missing");t.push(i),e.label=3;case 3:return a++,[3,1];case 4:return[2,{value:t,customDataId:this.customData.id}]}}))}))},C.prototype.getEnumValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,{value:this.value,customDataId:this.customData.id}]}))}))},C.prototype.getCustomDataValue=function(){return t(this,void 0,void 0,(function(){var t,r=this;return e(this,(function(e){switch(e.label){case 0:return(t=this.theme.customData.find((function(t){return t.id===r.customData.customDataId})))?((t=a(t)).isRequired=this.customData.isRequired,[4,new C(this.value,t,this.theme,this.pageType,this.pageDataProvider,this.pageSpecificData).getValue()]):[2,{value:null,customDataId:this.customData.id}];case 1:return[2,e.sent()]}}))}))},C.prototype.getComponentListValue=function(){return t(this,void 0,void 0,(function(){var t,a,s=this;return e(this,(function(e){switch(e.label){case 0:return t=this.value?this.value.map((function(t){return r({},t)})):[],a={},[4,Promise.all(t.map((function(t){return s.pageDataProvider.getPageComponentPropValues(t)})))];case 1:return[2,(a.value=e.sent(),a.customDataId=this.customData.id,a)]}}))}))},C.prototype.getBlogValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new D(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBlogListValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new V(this.pageType,this.value,this.pageSpecificData).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBlogCategoryValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new y(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBlogCategoryListValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new P(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getRaffleValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new b(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getRaffleListValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,(new T).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getSliderValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new L(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getVideoPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new p(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C}();export{C as IkasCustomPropValueProvider};
1
+ import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import a from"lodash/cloneDeep";import{IkasBrandListPropValueProvider as s}from"./brand-list.js";import{IkasBrandPropValueProvider as u}from"./brand.js";import{IkasCategoryListPropValueProvider as i}from"./category-list.js";import{IkasCategoryPropValueProvider as n}from"./category.js";import{IkasColorPropValueProvider as o}from"./color.js";import{IkasBooleanPropValueProvider as c}from"./boolean.js";import{IkasTextPropValueProvider as l}from"./text.js";import{IkasImageListPropValueProvider as h}from"./image-list.js";import{IkasImagePropValueProvider as d}from"./image.js";import{IkasVideoPropValueProvider as p}from"./video.js";import{IkasLinkPropValueProvider as m}from"./link.js";import{IkasProductPropValueProvider as f}from"./product-detail.js";import{IkasProductListPropValueProvider as g}from"./product-list.js";import{IkasRichTextPropValueProvider as v}from"./rich-text.js";import{IkasBlogPropValueProvider as D}from"./blog.js";import{IkasBlogListPropValueProvider as V}from"./blog-list.js";import{IkasAttributePropValueProvider as w}from"./attribute.js";import{IkasAttributeListPropValueProvider as I}from"./attribute-list.js";import{IkasBlogCategoryPropValueProvider as y}from"./blog-category.js";import{IkasBlogCategoryListPropValueProvider as L}from"./blog-category-list.js";import{IkasRaffleListPropValueProvider as P}from"./raffle-list.js";import{IkasRafflePropValueProvider as T}from"./raffle.js";import{IkasSliderPropValueProvider as b}from"./slider.js";import{IkasThemeJsonComponentPropType as R}from"@ikas/storefront-models";var C=function(){function C(t,e,r,a,s,u,i){this.value=t,this.customData=e,this.theme=r,this.pageType=a,this.pageDataProvider=s,this.pageSpecificData=u,this.pageParams=i}return C.prototype.getValue=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if((void 0===this.value||null===this.value)&&this.customData.type!==R.RAFFLE_LIST)return[2,{value:null,customDataId:this.customData.id}];e.label=1;case 1:switch(e.trys.push([1,60,,61]),this.customData.type){case R.TEXT:return[3,2];case R.RICH_TEXT:return[3,4];case R.BOOLEAN:return[3,6];case R.BRAND_LIST:return[3,8];case R.BRAND:return[3,10];case R.CATEGORY_LIST:return[3,12];case R.CATEGORY:return[3,14];case R.COLOR:return[3,16];case R.IMAGE_LIST:return[3,18];case R.IMAGE:return[3,20];case R.LINK:case R.LIST_OF_LINK:return[3,22];case R.PRODUCT_DETAIL:return[3,24];case R.PRODUCT_LIST:return[3,26];case R.PRODUCT_ATTRIBUTE:return[3,28];case R.PRODUCT_ATTRIBUTE_LIST:return[3,30];case R.OBJECT:return[3,32];case R.DYNAMIC_LIST:case R.STATIC_LIST:return[3,34];case R.ENUM:return[3,36];case R.CUSTOM:return[3,38];case R.COMPONENT:case R.COMPONENT_LIST:return[3,40];case R.BLOG:return[3,42];case R.BLOG_LIST:return[3,44];case R.BLOG_CATEGORY:return[3,46];case R.BLOG_CATEGORY_LIST:return[3,48];case R.RAFFLE:return[3,50];case R.RAFFLE_LIST:return[3,52];case R.SLIDER:return[3,54];case R.VIDEO:return[3,56]}return[3,58];case 2:return[4,this.getTextValue()];case 3:return t=e.sent(),[3,59];case 4:return[4,this.getRichTextPropValue()];case 5:return t=e.sent(),[3,59];case 6:return[4,this.getBooleanValue()];case 7:return t=e.sent(),[3,59];case 8:return[4,this.getBrandListPropValue()];case 9:return t=e.sent(),[3,59];case 10:return[4,this.getBrandPropValue()];case 11:return t=e.sent(),[3,59];case 12:return[4,this.getCategoryListPropValue()];case 13:return t=e.sent(),[3,59];case 14:return[4,this.getCategoryPropValue()];case 15:return t=e.sent(),[3,59];case 16:return[4,this.getColorPropValue()];case 17:return t=e.sent(),[3,59];case 18:return[4,this.getImageListPropValue()];case 19:return t=e.sent(),[3,59];case 20:return[4,this.getImagePropValue()];case 21:return t=e.sent(),[3,59];case 22:return[4,this.getLinkPropValue()];case 23:return t=e.sent(),[3,59];case 24:return[4,this.getProductDetailPropValue()];case 25:return t=e.sent(),[3,59];case 26:return[4,this.getProductListPropValue()];case 27:return t=e.sent(),[3,59];case 28:return[4,this.getProductAttributePropValue()];case 29:return t=e.sent(),[3,59];case 30:return[4,this.getProductAttributeListPropValue()];case 31:return t=e.sent(),[3,59];case 32:return[4,this.getObjectValue()];case 33:return t=e.sent(),[3,59];case 34:return[4,this.getArrayValue()];case 35:return t=e.sent(),[3,59];case 36:return[4,this.getEnumValue()];case 37:return t=e.sent(),[3,59];case 38:return[4,this.getCustomDataValue()];case 39:return t=e.sent(),[3,59];case 40:return[4,this.getComponentListValue()];case 41:return t=e.sent(),[3,59];case 42:return[4,this.getBlogValue()];case 43:return t=e.sent(),[3,59];case 44:return[4,this.getBlogListValue()];case 45:return t=e.sent(),[3,59];case 46:return[4,this.getBlogCategoryValue()];case 47:return t=e.sent(),[3,59];case 48:return[4,this.getBlogCategoryListValue()];case 49:return t=e.sent(),[3,59];case 50:return[4,this.getRaffleValue()];case 51:return t=e.sent(),[3,59];case 52:return[4,this.getRaffleListValue()];case 53:return t=e.sent(),[3,59];case 54:return[4,this.getSliderValue()];case 55:return t=e.sent(),[3,59];case 56:return[4,this.getVideoPropValue()];case 57:return t=e.sent(),[3,59];case 58:return[3,59];case 59:return[3,61];case 60:return e.sent(),[2];case 61:return!this.customData.isRequired||void 0!==(null==t?void 0:t.value)&&null!==(null==t?void 0:t.value)?[2,t]:[2]}}))}))},C.prototype.getBooleanValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new c(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBrandListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new s(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBrandPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new u(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getCategoryListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new i(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getCategoryPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new n(r(r({},this.value),{excludedFieldsCategory:this.customData.excludedFieldsCategory})).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getColorPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new o(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getRichTextPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new v(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getImageListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new h(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getImagePropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new d(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getLinkPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new m(this.value,this.theme,this.pageDataProvider.linkMetaDataTargetIds).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductDetailPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new f(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new g(this.pageType,r(r({},this.value),{excludedFields:this.customData.excludedFields,isFacetListNotSent:this.customData.isFacetListNotSent}),this.pageSpecificData).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductAttributePropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new w(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getProductAttributeListPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new I(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getTextValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new l(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getObjectValue=function(){return t(this,void 0,void 0,(function(){var t,r,a,s,u,i;return e(this,(function(e){switch(e.label){case 0:t={},r=0,a=this.customData.nestedData||[],e.label=1;case 1:if(!(r<a.length))return[3,4];if(!(s=a[r]).key)return[3,3];if(u=this.value[s.key],s.isRequired&&s.type!==R.RAFFLE_LIST&&null==u)throw new Error("Required data is missing");return[4,new C(u,s,this.theme,this.pageType,this.pageDataProvider,this.pageSpecificData).getValue()];case 2:if(i=e.sent(),s.isRequired&&null==i)throw new Error("Required data is missing");t[s.key]=i,e.label=3;case 3:return r++,[3,1];case 4:return[2,{value:t,customDataId:this.customData.id}]}}))}))},C.prototype.getArrayValue=function(){return t(this,void 0,void 0,(function(){var t,r,a,s,u,i;return e(this,(function(e){switch(e.label){case 0:if(!this.value||!Array.isArray(this.value))throw new Error("Incorrect data!");t=[],r=this.customData.nestedData[0],a=0,s=this.value,e.label=1;case 1:if(!(a<s.length))return[3,4];if(u=s[a],r.isRequired&&r.type!==R.RAFFLE_LIST&&null==u)throw new Error("Required data is missing");return[4,new C(u,r,this.theme,this.pageType,this.pageDataProvider,this.pageSpecificData).getValue()];case 2:if(i=e.sent(),r.isRequired&&null==i)throw new Error("Required data is missing");t.push(i),e.label=3;case 3:return a++,[3,1];case 4:return[2,{value:t,customDataId:this.customData.id}]}}))}))},C.prototype.getEnumValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,{value:this.value,customDataId:this.customData.id}]}))}))},C.prototype.getCustomDataValue=function(){return t(this,void 0,void 0,(function(){var t,r=this;return e(this,(function(e){switch(e.label){case 0:return(t=this.theme.customData.find((function(t){return t.id===r.customData.customDataId})))?((t=a(t)).isRequired=this.customData.isRequired,[4,new C(this.value,t,this.theme,this.pageType,this.pageDataProvider,this.pageSpecificData).getValue()]):[2,{value:null,customDataId:this.customData.id}];case 1:return[2,e.sent()]}}))}))},C.prototype.getComponentListValue=function(){return t(this,void 0,void 0,(function(){var t,a,s=this;return e(this,(function(e){switch(e.label){case 0:return t=this.value?this.value.map((function(t){return r({},t)})):[],a={},[4,Promise.all(t.map((function(t){return s.pageDataProvider.getPageComponentPropValues(t)})))];case 1:return[2,(a.value=e.sent(),a.customDataId=this.customData.id,a)]}}))}))},C.prototype.getBlogValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new D(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBlogListValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new V(this.pageType,this.value,this.pageSpecificData).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBlogCategoryValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new y(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getBlogCategoryListValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new L(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getRaffleValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new T(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getRaffleListValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,(new P).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getSliderValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new b(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C.prototype.getVideoPropValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new p(this.value).getValue()];case 1:return[2,{value:t.sent(),customDataId:this.customData.id}]}}))}))},C}();export{C as IkasCustomPropValueProvider};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i}from"@ikas/storefront-models";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductListType as r,IkasRelatedProductsType as d,IkasProductListSortType as o}from"../../models/ui/product-list/index.js";import{getInitial as a}from"../../models/ui/product-list/init.js";var s=function(){function s(t,e,i){this.relatedProductData=null,this.viewedTogetherProductData=null,this.recommendedProductData=null,this.pageType=t,this.productListPropValue=e,this.pageSpecificData=i,this.relatedProductData=null,this.viewedTogetherProductData=null,this.recommendedProductData=null}return s.prototype.getValue=function(){var s,u;return t(this,void 0,void 0,(function(){var t,c,p,l,n;return e(this,(function(e){switch(e.label){case 0:return this.productListPropValue.productListType===r.ALL&&this.productListPropValue.usePageFilter&&(this.pageType===i.CATEGORY?(p=this.pageSpecificData,c=p.id):this.pageType===i.BRAND&&(l=this.pageSpecificData,t=l.id)),this.productListPropValue.productListType===r.CATEGORY&&this.productListPropValue.category&&(c=this.productListPropValue.category),this.pageType===i.PRODUCT&&this.productListPropValue.productListType===r.RELATED_PRODUCTS&&this.productListPropValue.relatedProductsType&&this.pageSpecificData&&(this.relatedProductData={brandIds:null,categoryIds:null,productId:""},this.productListPropValue.relatedProductsType===d.CATEGORY?this.relatedProductData.categoryIds=this.pageSpecificData.categories.map((function(t){return t.id})):this.relatedProductData.brandIds=[null===(u=null===(s=this.pageSpecificData)||void 0===s?void 0:s.brand)||void 0===u?void 0:u.id],this.relatedProductData.productId=this.pageSpecificData.id),this.pageType===i.PRODUCT&&this.productListPropValue.productListType===r.VIEWED_TOGETHER&&this.pageSpecificData&&(this.viewedTogetherProductData={productIds:[]},this.viewedTogetherProductData.productIds=[this.pageSpecificData.id]),this.productListPropValue.productListType===r.RECOMMENDED_PRODUCTS&&this.productListPropValue.recommendedProductsType&&(this.recommendedProductData={brandIds:null,categoryIds:null},this.productListPropValue.recommendedProductsType.category?this.recommendedProductData.categoryIds=[this.productListPropValue.recommendedProductsType.category]:this.productListPropValue.recommendedProductsType.brand&&(this.recommendedProductData.brandIds=[this.productListPropValue.recommendedProductsType.brand])),n={data:[],count:0,page:1,limit:this.productListPropValue.initialLimit||10,type:this.productListPropValue.productListType||r.ALL,sort:this.productListPropValue.initialSort||o.LAST_ADDED,productListPropValue:this.productListPropValue,filterBrandId:t,filterCategoryId:c,pageType:this.pageType,pageSpecificData:[i.CATEGORY,i.BRAND].includes(this.pageType)?this.pageSpecificData:null,relatedProductData:this.relatedProductData,recommendedProductData:this.recommendedProductData,viewedTogetherProductData:this.viewedTogetherProductData,excludedFields:this.productListPropValue.excludedFields,filters:null,infiniteScrollPage:null},[4,a(n)];case 1:return e.sent(),n.pageSpecificData=null,[2,n]}}))}))},s}();export{s as IkasProductListPropValueProvider};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i}from"@ikas/storefront-models";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductListType as r,IkasRelatedProductsType as a,IkasProductListSortType as o}from"../../models/ui/product-list/index.js";import{getInitial as d}from"../../models/ui/product-list/init.js";var s=function(){function s(t,e,i){this.relatedProductData=null,this.viewedTogetherProductData=null,this.recommendedProductData=null,this.pageType=t,this.productListPropValue=e,this.pageSpecificData=i,this.relatedProductData=null,this.viewedTogetherProductData=null,this.recommendedProductData=null}return s.prototype.getValue=function(){var s,c;return t(this,void 0,void 0,(function(){var t,p,u,l,n;return e(this,(function(e){switch(e.label){case 0:return this.productListPropValue.productListType===r.ALL&&this.productListPropValue.usePageFilter&&(this.pageType===i.CATEGORY?(u=this.pageSpecificData,p=u.id):this.pageType===i.BRAND&&(l=this.pageSpecificData,t=l.id)),this.productListPropValue.productListType===r.CATEGORY&&this.productListPropValue.category&&(p=this.productListPropValue.category),this.pageType===i.PRODUCT&&this.productListPropValue.productListType===r.RELATED_PRODUCTS&&this.productListPropValue.relatedProductsType&&this.pageSpecificData&&(this.relatedProductData={brandIds:null,categoryIds:null,productId:""},this.productListPropValue.relatedProductsType===a.CATEGORY?this.relatedProductData.categoryIds=this.pageSpecificData.categories&&this.pageSpecificData.categories.length?[this.pageSpecificData.categories[0].id]:null:this.relatedProductData.brandIds=[null===(c=null===(s=this.pageSpecificData)||void 0===s?void 0:s.brand)||void 0===c?void 0:c.id],this.relatedProductData.productId=this.pageSpecificData.id),this.pageType===i.PRODUCT&&this.productListPropValue.productListType===r.VIEWED_TOGETHER&&this.pageSpecificData&&(this.viewedTogetherProductData={productIds:[]},this.viewedTogetherProductData.productIds=[this.pageSpecificData.id]),this.productListPropValue.productListType===r.RECOMMENDED_PRODUCTS&&this.productListPropValue.recommendedProductsType&&(this.recommendedProductData={brandIds:null,categoryIds:null},this.productListPropValue.recommendedProductsType.category?this.recommendedProductData.categoryIds=[this.productListPropValue.recommendedProductsType.category]:this.productListPropValue.recommendedProductsType.brand&&(this.recommendedProductData.brandIds=[this.productListPropValue.recommendedProductsType.brand])),n={data:[],count:0,page:1,limit:this.productListPropValue.initialLimit||10,type:this.productListPropValue.productListType||r.ALL,sort:this.productListPropValue.initialSort||o.LAST_ADDED,productListPropValue:this.productListPropValue,filterBrandId:t,filterCategoryId:p,pageType:this.pageType,pageSpecificData:[i.CATEGORY,i.BRAND].includes(this.pageType)?this.pageSpecificData:null,relatedProductData:this.relatedProductData,recommendedProductData:this.recommendedProductData,viewedTogetherProductData:this.viewedTogetherProductData,excludedFields:this.productListPropValue.excludedFields,isFacetListNotSent:this.productListPropValue.isFacetListNotSent,filters:null,infiniteScrollPage:null},[4,d(n)];case 1:return e.sent(),n.pageSpecificData=null,[2,n]}}))}))},s}();export{s as IkasProductListPropValueProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-providers",
3
- "version": "6.1.0-beta.23",
3
+ "version": "6.1.0-beta.230",
4
4
  "description": "Data providers for ikas storefront theme components.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@rollup/plugin-commonjs": "^22.0.0",
20
- "@ikas/storefront-api": "^6.1.0-beta.23",
21
- "@ikas/storefront-config": "^6.1.0-beta.23",
22
- "@ikas/storefront-model-functions": "^6.1.0-beta.23",
23
- "@ikas/storefront-models": "^6.1.0-beta.23",
20
+ "@ikas/storefront-api": "^6.1.0-beta.230",
21
+ "@ikas/storefront-config": "^6.1.0-beta.230",
22
+ "@ikas/storefront-model-functions": "^6.1.0-beta.230",
23
+ "@ikas/storefront-models": "^6.1.0-beta.230",
24
24
  "@rollup/plugin-node-resolve": "^13.3.0",
25
25
  "rollup-plugin-rename-node-modules": "^1.2.0",
26
26
  "@types/lodash": "^4.14.168",
@@ -38,10 +38,10 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "mobx": "^6.1.3",
41
- "@ikas/storefront-api": "^6.1.0-beta.23",
42
- "@ikas/storefront-config": "^6.1.0-beta.23",
43
- "@ikas/storefront-model-functions": "^6.1.0-beta.23",
44
- "@ikas/storefront-models": "^6.1.0-beta.23",
41
+ "@ikas/storefront-api": "^6.1.0-beta.230",
42
+ "@ikas/storefront-config": "^6.1.0-beta.230",
43
+ "@ikas/storefront-model-functions": "^6.1.0-beta.230",
44
+ "@ikas/storefront-models": "^6.1.0-beta.230",
45
45
  "lodash": "^4.17.21"
46
46
  }
47
47
  }