@ikas/storefront 2.0.0-alpha.23 → 2.0.0-alpha.24
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'../ext/
|
|
1
|
+
import e from'../ext/decode-uri-component/index.js';export{default}from"../node_modules/decode-uri-component/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from'../ext/strict-uri-encode/index.js';export{default}from"../node_modules/strict-uri-encode/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from'../ext/split-on-first/index.js';export{default}from"../node_modules/split-on-first/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import i from'../ext/lodash/uniq.js';import a from'../ext/lzutf8/build/production/lzutf8.js';import{IkasBlogMetadataTargetType as s}from"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import{IkasHTMLMetaDataTargetType as n}from"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import{IkasRaffleMetadataTargetType as o}from"../models/data/raffle/index.js";import{IkasTheme as p}from"../models/theme/theme.js";import{IkasThemePageType as u}from"../models/theme/page/index.js";import{IkasThemePageComponent as c}from"../models/theme/page/component/index.js";import{IkasThemeComponent as l}from"../models/theme/component/index.js";import{IkasThemeComponentPropType as d}from"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import{IkasProductDetail as m}from"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import{IkasBlogAPI as f}from"../api/blog/index.js";import{IkasBrandAPI as g}from"../api/brand/index.js";import"../api/cart/index.js";import{IkasCategoryAPI as h}from"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/district/index.js";import{IkasHTMLMetaDataAPI as v}from"../api/html-meta-data/index.js";import{IkasMerchantAPI as j}from"../api/merchant/index.js";import{IkasProductSearchAPI as T}from"../api/product-search/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import{IkasProductOptionSetAPI as y}from"../api/product-option-set/index.js";import{IkasRaffleAPI as b}from"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import{IkasProductListPropValueProvider as x}from"./prop-value/product-list.js";import{IkasProductDetailPropValueProvider as D}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as L}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as S}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as O}from"./prop-value/link.js";import{IkasImageListPropValueProvider as w}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as P}from"./prop-value/text.js";import{IkasColorPropValueProvider as C}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as I}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as E}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as R}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as A}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as B}from"./prop-value/custom.js";import{IkasStorefrontConfig as M}from"../storefront/index.js";import{IkasSliderPropValueProvider as G}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as _}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as V}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as F}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as k}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as U}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as N}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as Y}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as J}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as H}from"./prop-value/raffle-list.js";import{populateRaffleProducts as z}from"./helpers/raffles.js";var K=function(){function c(e,t,i){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.theme=new p(e),this.pageParams=t||{},this.pageType=i,r(this)}return Object.defineProperty(c.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(c.prototype,"nextPageData",{get:function(){var e,t,r;return{props:{propValuesStr:a.compress(JSON.stringify(this.pageComponentPropValues),{outputEncoding:"Base64"}),pageSpecificDataStr:this.pageSpecificData?JSON.stringify(this.pageSpecificData||{}):"",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,settingsStr:JSON.stringify(this.theme.settings||{}),merchantSettingsStr:this.merchantSettings?JSON.stringify(this.merchantSettings):null,configJson:M.getJson()}}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"specification",{get:function(){var e,t,r=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=r.pageSpecificData)||void 0===t?void 0:t.product.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=r.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(c.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}),c.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.listMerchantSettings()];case 1:return(e=t.sent())&&(this.merchantSettings=e),[2]}}))}))},c.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,r=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 r.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[2]}}))}))},c.prototype.getPageSpecificData=function(){var r,i,a;return e(this,void 0,void 0,(function(){var p,c,l,d,j,x,D,L,S,O=this;return t(this,(function(w){switch(w.label){case 0:return this.pageType&&![u.BRAND,u.PRODUCT,u.CATEGORY,u.BLOG,u.BLOG_CATEGORY,u.RAFFLE_DETAIL].includes(this.pageType)?[2]:(p=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,f.listBlogMetaData(p)]:[3,2]):[2];case 1:return(c=w.sent()).length?[3,6]:[2];case 2:return(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(u.RAFFLE_DETAIL))?[4,b.listRaffleMetaData(p)]:[3,4];case 3:return(c=w.sent()).length?[3,6]:[2];case 4:return[4,v.listHTMLMetaData(p)];case 5:if(!(c=w.sent())||!c.length)return[2];w.label=6;case 6:if(!(l=c[0]).targetId)return[2];switch(d=function(){return e(O,void 0,void 0,(function(){var e,r,i,a,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,T.searchProducts({productIdList:[l.targetId],priceListId:M.priceListId,salesChannelId:M.salesChannelId})];case 1:return(null==(e=t.sent())?void 0:e.data.length)?(r=e.data[0]).productOptionSetId?[4,y.list([r.productOptionSetId])]:[3,3]:[2];case 2:(null==(i=t.sent())?void 0:i.length)&&(r.productOptionSet=i[0]),t.label=3;case 3:return(a=r.variants.find((function(e){return e.isActive})))?(this.pageSpecificData=new m(r,a.variantValues),this.pageSpecificData.displayedVariantTypes.length&&(s=this.pageSpecificData.displayedVariantTypes[0]).displayedVariantValues.length&&(n=s.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=n.variant.variantValues),this.pageType=u.PRODUCT,this.setPageMetaData(l),[2]):[2]}}))}))},j=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,g.listBrands({idList:[l.targetId]})];case 1:return(e=t.sent()).brands.length?(r=e.brands[0],this.pageSpecificData=r,this.pageType=u.BRAND,this.setPageMetaData(l),[2]):[2]}}))}))},x=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,h.listCategories({idList:[l.targetId]})];case 1:return(e=t.sent()).categories.length?(r=e.categories[0],this.pageSpecificData=r,this.pageType=u.CATEGORY,this.setPageMetaData(l),[2]):[2]}}))}))},D=function(){return e(O,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,f.getBlog({id:l.targetId})];case 1:return(e=t.sent())?(this.pageSpecificData=e,this.pageType=u.BLOG,this.setPageMetaData(l),[2]):[2]}}))}))},L=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,f.listBlogCategory({idList:[l.targetId],page:1,limit:1})];case 1:return(e=t.sent())&&e.blogCategories.length?(r=e.blogCategories[0],this.pageSpecificData=r,this.pageType=u.BLOG_CATEGORY,this.setPageMetaData(l),[2]):[2]}}))}))},S=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,b.listRaffles({id:l.targetId})];case 1:return(e=t.sent())&&e.raffles.length?(r=e.raffles[0],[4,z([r])]):[2];case 2:return t.sent(),this.pageSpecificData=r,this.pageType=u.RAFFLE_DETAIL,this.setPageMetaData(l),[2]}}))}))},l.targetType){case n.BRAND:return[3,7];case n.CATEGORY:return[3,9];case n.PRODUCT:return[3,11];case s.BLOG:return[3,13];case s.BLOG_CATEGORY:return[3,15];case o.RAFFLE:return[3,17]}return[3,19];case 7:return[4,j()];case 8:return[2,w.sent()];case 9:return[4,x()];case 10:return[2,w.sent()];case 11:return[4,d()];case 12:return[2,w.sent()];case 13:return[4,D()];case 14:return[2,w.sent()];case 15:return[4,L()];case 16:return[2,w.sent()];case 17:return[4,S()];case 18:return[2,w.sent()];case 19:return[3,20];case 20:return[2]}}))}))},c.prototype.getPageComponentPropValues=function(r){return e(this,void 0,void 0,(function(){var i,a,s,n=this;return t(this,(function(o){switch(o.label){case 0:return i=this.theme.components.find((function(e){return e.id===r.componentId})),a={pageComponent:r,component:i,propValues:{}},s=function(i){return e(n,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return e=a.propValues,s=i.name,[4,this.getPageComponentPropValue(r,i)];case 1:return e[s]=t.sent(),[2]}}))}))},[4,Promise.all(i.props.map(s))];case 1:return o.sent(),[2,a]}}))}))},c.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,n,o,p=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[d.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case d.TEXT:return[3,1];case d.RICH_TEXT:return[3,2];case d.BOOLEAN:return[3,3];case d.IMAGE:return[3,4];case d.IMAGE_LIST:return[3,5];case d.BRAND:return[3,6];case d.BRAND_LIST:return[3,7];case d.PRODUCT_LIST:return[3,8];case d.PRODUCT_DETAIL:return[3,9];case d.PRODUCT_ATTRIBUTE:return[3,10];case d.PRODUCT_ATTRIBUTE_LIST:return[3,11];case d.CATEGORY:return[3,12];case d.CATEGORY_LIST:return[3,13];case d.LINK:case d.LIST_OF_LINK:return[3,14];case d.COLOR:return[3,15];case d.CUSTOM:return[3,16];case d.COMPONENT:case d.COMPONENT_LIST:return[3,17];case d.BLOG:return[3,19];case d.BLOG_LIST:return[3,20];case d.BLOG_CATEGORY:return[3,21];case d.BLOG_CATEGORY_LIST:return[3,22];case d.RAFFLE:return[3,23];case d.RAFFLE_LIST:return[3,24];case d.SLIDER:return[3,25]}return[3,26];case 1:return e=new P(a),[3,27];case 2:return e=new _(a),[3,27];case 3:return e=new I(a),[3,27];case 4:return e=new E(a),[3,27];case 5:return e=new w(a),[3,27];case 6:return e=new S(a),[3,27];case 7:return e=new L(a),[3,27];case 8:return e=new x(this.pageType,a,this.pageSpecificData),[3,27];case 9:return e=new D(a),[3,27];case 10:return e=new k(a),[3,27];case 11:return e=new U(a),[3,27];case 12:return e=new R(a),[3,27];case 13:return e=new A(a),[3,27];case 14:return e=new O(a,this.theme,this.linkMetaDataTargetIds),[3,27];case 15:return e=new C(a),[3,27];case 16:return(n=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new B(a,n,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,27]):[2];case 17:return o=a,[4,Promise.all(o.map((function(e){return p.getPageComponentPropValues(e)})))];case 18:case 28:return[2,t.sent()];case 19:return e=new V(a),[3,27];case 20:return e=new F(this.pageType,a,this.pageSpecificData),[3,27];case 21:return e=new N(a),[3,27];case 22:return e=new Y(a),[3,27];case 23:return e=new J(a),[3,27];case 24:return e=new H,[3,27];case 25:return e=new G(a),[3,27];case 26:return[3,27];case 27:return[4,null==e?void 0:e.getValue()]}}))}))},c.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle,this.page.description=e.description)},c.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,r,i;return t(this,(function(t){switch(t.label){case 0:return e=[],r=[],i=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":r.push(t);break;case"RAFFLE":i.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(r,"BLOG"),this.getLinkSlugs(i,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},c.prototype.getLinkSlugs=function(r,a){return e(this,void 0,void 0,(function(){var s,n,o,p,u,c,l=this;return t(this,(function(d){switch(d.label){case 0:s=i(r.map((function(e){return e.id}))),n=1,o=200,p=[],u=!1,c=function(){return e(l,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:switch(e=[],a){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,v.listHTMLMetaData(void 0,s,void 0,n,o)];case 2:case 4:case 6:return e=t.sent(),[3,8];case 3:return[4,f.listBlogMetaData(void 0,s,void 0,n,o)];case 5:return[4,b.listRaffleMetaData(void 0,s,void 0,n,o)];case 7:return[3,8];case 8:return(null==e?void 0:e.length)?(p=p.concat(e),e.length<o&&(u=!0)):u=!0,n++,[2]}}))}))},d.label=1;case 1:return!u&&p.length<s.length?[4,c()]:[3,3];case 2:return d.sent(),[3,1];case 3:return p.forEach((function(e){r.filter((function(t){return t.id===e.targetId})).forEach((function(t){t.navigationLink.href+=e.slug}))})),[2]}}))}))},c}(),X=function(e){this.pageComponent=e.pageComponent?new c(e.pageComponent):new c({}),this.component=e.component?new l(e.component):new l({}),this.propValues=e.propValues||{}};export{X as IkasPageComponentPropValue,K as IkasPageDataProvider};
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import i from'../ext/lodash/uniq.js';import a from'../ext/lzutf8/build/production/lzutf8.js';import{IkasBlogMetadataTargetType as s}from"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import{IkasHTMLMetaDataTargetType as n}from"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import{IkasRaffleMetadataTargetType as o}from"../models/data/raffle/index.js";import{IkasTheme as p}from"../models/theme/theme.js";import{IkasThemePageType as u}from"../models/theme/page/index.js";import{IkasThemePageComponent as c}from"../models/theme/page/component/index.js";import{IkasThemeComponent as l}from"../models/theme/component/index.js";import{IkasThemeComponentPropType as d}from"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import{IkasProductDetail as m}from"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import{IkasBlogAPI as f}from"../api/blog/index.js";import{IkasBrandAPI as g}from"../api/brand/index.js";import"../api/cart/index.js";import{IkasCategoryAPI as h}from"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/district/index.js";import{IkasHTMLMetaDataAPI as v}from"../api/html-meta-data/index.js";import{IkasMerchantAPI as j}from"../api/merchant/index.js";import{IkasProductSearchAPI as T}from"../api/product-search/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import{IkasProductOptionSetAPI as y}from"../api/product-option-set/index.js";import{IkasRaffleAPI as x}from"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import{IkasProductListPropValueProvider as b}from"./prop-value/product-list.js";import{IkasProductDetailPropValueProvider as D}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as L}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as S}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as O}from"./prop-value/link.js";import{IkasImageListPropValueProvider as w}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as P}from"./prop-value/text.js";import{IkasColorPropValueProvider as C}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as I}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as R}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as E}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as A}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as B}from"./prop-value/custom.js";import{IkasStorefrontConfig as M}from"../storefront/index.js";import{IkasSliderPropValueProvider as G}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as _}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as V}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as F}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as k}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as U}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as N}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as Y}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as J}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as H}from"./prop-value/raffle-list.js";import{populateRaffleProducts as z}from"./helpers/raffles.js";var K=function(){function c(e,t,i){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.theme=new p(e),this.pageParams=t||{},this.pageType=i,r(this)}return Object.defineProperty(c.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(c.prototype,"nextPageData",{get:function(){var e,t,r;return{props:{propValuesStr:a.compress(JSON.stringify(this.pageComponentPropValues),{outputEncoding:"Base64"}),pageSpecificDataStr:this.pageSpecificData?JSON.stringify(this.pageSpecificData||{}):"",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,settingsStr:JSON.stringify(this.theme.settings||{}),merchantSettingsStr:this.merchantSettings?JSON.stringify(this.merchantSettings):null,configJson:M.getJson()}}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"specification",{get:function(){var e,t,r=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=r.pageSpecificData)||void 0===t?void 0:t.product.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=r.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(c.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}),c.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.listMerchantSettings()];case 1:return(e=t.sent())&&(this.merchantSettings=e),[2]}}))}))},c.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,r=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 r.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[2]}}))}))},c.prototype.getPageSpecificData=function(){var r,i,a;return e(this,void 0,void 0,(function(){var p,c,l,d,j,b,D,L,S,O=this;return t(this,(function(w){switch(w.label){case 0:return this.pageType&&![u.BRAND,u.PRODUCT,u.CATEGORY,u.BLOG,u.BLOG_CATEGORY,u.RAFFLE_DETAIL].includes(this.pageType)?[2]:(p=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,f.listBlogMetaData(p)]:[3,2]):[2];case 1:return(c=w.sent()).length?[3,6]:[2];case 2:return(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(u.RAFFLE_DETAIL))?[4,x.listRaffleMetaData(p)]:[3,4];case 3:return(c=w.sent()).length?[3,6]:[2];case 4:return[4,v.listHTMLMetaData(p)];case 5:if(!(c=w.sent())||!c.length)return[2];w.label=6;case 6:if(!(l=c[0]).targetId)return[2];switch(d=function(){return e(O,void 0,void 0,(function(){var e,r,i,a,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,T.searchProducts({productIdList:[l.targetId],priceListId:M.priceListId,salesChannelId:M.salesChannelId})];case 1:return(null==(e=t.sent())?void 0:e.data.length)?(r=e.data[0]).productOptionSetId?[4,y.list([r.productOptionSetId])]:[3,3]:[2];case 2:(null==(i=t.sent())?void 0:i.length)&&(r.productOptionSet=i[0]),t.label=3;case 3:return(a=r.variants.find((function(e){return e.isActive})))?(this.pageSpecificData=new m(r,a.variantValues),this.pageSpecificData.displayedVariantTypes.length&&(s=this.pageSpecificData.displayedVariantTypes[0]).displayedVariantValues.length&&(n=s.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=n.variant.variantValues),this.pageType=u.PRODUCT,this.setPageMetaData(l),[2]):[2]}}))}))},j=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,g.listBrands({idList:[l.targetId]})];case 1:return(e=t.sent()).brands.length?(r=e.brands[0],this.pageSpecificData=r,this.pageType=u.BRAND,this.setPageMetaData(l),[2]):[2]}}))}))},b=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,h.listCategories({idList:[l.targetId]})];case 1:return(e=t.sent()).categories.length?(r=e.categories[0],this.pageSpecificData=r,this.pageType=u.CATEGORY,this.setPageMetaData(l),[2]):[2]}}))}))},D=function(){return e(O,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,f.getBlog({id:l.targetId})];case 1:return(e=t.sent())?(this.pageSpecificData=e,this.pageType=u.BLOG,this.setPageMetaData(l),[2]):[2]}}))}))},L=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,f.listBlogCategory({idList:[l.targetId],page:1,limit:1})];case 1:return(e=t.sent())&&e.blogCategories.length?(r=e.blogCategories[0],this.pageSpecificData=r,this.pageType=u.BLOG_CATEGORY,this.setPageMetaData(l),[2]):[2]}}))}))},S=function(){return e(O,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return[4,x.listRaffles({id:l.targetId})];case 1:return(e=t.sent())&&e.raffles.length?(r=e.raffles[0],[4,z([r])]):[2];case 2:return t.sent(),this.pageSpecificData=r,this.pageType=u.RAFFLE_DETAIL,this.setPageMetaData(l),[2]}}))}))},l.targetType){case n.BRAND:return[3,7];case n.CATEGORY:return[3,9];case n.PRODUCT:return[3,11];case s.BLOG:return[3,13];case s.BLOG_CATEGORY:return[3,15];case o.RAFFLE:return[3,17]}return[3,19];case 7:return[4,j()];case 8:return[2,w.sent()];case 9:return[4,b()];case 10:return[2,w.sent()];case 11:return[4,d()];case 12:return[2,w.sent()];case 13:return[4,D()];case 14:return[2,w.sent()];case 15:return[4,L()];case 16:return[2,w.sent()];case 17:return[4,S()];case 18:return[2,w.sent()];case 19:return[3,20];case 20:return[2]}}))}))},c.prototype.getPageComponentPropValues=function(r){return e(this,void 0,void 0,(function(){var i,a,s,n=this;return t(this,(function(o){switch(o.label){case 0:return i=this.theme.components.find((function(e){return e.id===r.componentId})),a={pageComponent:r,component:i,propValues:{}},s=function(i){return e(n,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return e=a.propValues,s=i.name,[4,this.getPageComponentPropValue(r,i)];case 1:return e[s]=t.sent(),[2]}}))}))},[4,Promise.all(i.props.map(s))];case 1:return o.sent(),[2,a]}}))}))},c.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,n,o,p=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[d.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case d.TEXT:return[3,1];case d.RICH_TEXT:return[3,2];case d.BOOLEAN:return[3,3];case d.IMAGE:return[3,4];case d.IMAGE_LIST:return[3,5];case d.BRAND:return[3,6];case d.BRAND_LIST:return[3,7];case d.PRODUCT_LIST:return[3,8];case d.PRODUCT_DETAIL:return[3,9];case d.PRODUCT_ATTRIBUTE:return[3,10];case d.PRODUCT_ATTRIBUTE_LIST:return[3,11];case d.CATEGORY:return[3,12];case d.CATEGORY_LIST:return[3,13];case d.LINK:case d.LIST_OF_LINK:return[3,14];case d.COLOR:return[3,15];case d.CUSTOM:return[3,16];case d.COMPONENT:case d.COMPONENT_LIST:return[3,17];case d.BLOG:return[3,19];case d.BLOG_LIST:return[3,20];case d.BLOG_CATEGORY:return[3,21];case d.BLOG_CATEGORY_LIST:return[3,22];case d.RAFFLE:return[3,23];case d.RAFFLE_LIST:return[3,24];case d.SLIDER:return[3,25]}return[3,26];case 1:return e=new P(a),[3,27];case 2:return e=new _(a),[3,27];case 3:return e=new I(a),[3,27];case 4:return e=new R(a),[3,27];case 5:return e=new w(a),[3,27];case 6:return e=new S(a),[3,27];case 7:return e=new L(a),[3,27];case 8:return e=new b(this.pageType,a,this.pageSpecificData),[3,27];case 9:return e=new D(a),[3,27];case 10:return e=new k(a),[3,27];case 11:return e=new U(a),[3,27];case 12:return e=new E(a),[3,27];case 13:return e=new A(a),[3,27];case 14:return e=new O(a,this.theme,this.linkMetaDataTargetIds),[3,27];case 15:return e=new C(a),[3,27];case 16:return(n=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new B(a,n,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,27]):[2];case 17:return o=a,[4,Promise.all(o.map((function(e){return p.getPageComponentPropValues(e)})))];case 18:case 28:return[2,t.sent()];case 19:return e=new V(a),[3,27];case 20:return e=new F(this.pageType,a,this.pageSpecificData),[3,27];case 21:return e=new N(a),[3,27];case 22:return e=new Y(a),[3,27];case 23:return e=new J(a),[3,27];case 24:return e=new H,[3,27];case 25:return e=new G(a),[3,27];case 26:return[3,27];case 27:return[4,null==e?void 0:e.getValue()]}}))}))},c.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle,this.page.description=e.description)},c.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,r,i;return t(this,(function(t){switch(t.label){case 0:return e=[],r=[],i=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":r.push(t);break;case"RAFFLE":i.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(r,"BLOG"),this.getLinkSlugs(i,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},c.prototype.getLinkSlugs=function(r,a){return e(this,void 0,void 0,(function(){var s,n,o=this;return t(this,(function(p){switch(p.label){case 0:return s=i(r.map((function(e){return e.id}))),n=[],[4,function(){return e(o,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:switch(e=[],a){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,v.listHTMLMetaData(void 0,s,void 0)];case 2:case 4:case 6:return e=t.sent(),[3,8];case 3:return[4,f.listBlogMetaData(void 0,s,void 0)];case 5:return[4,x.listRaffleMetaData(void 0,s,void 0)];case 7:return[3,8];case 8:return e.length&&(n=e),[2]}}))}))}()];case 1:return p.sent(),r.forEach((function(e){var t=n.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},c}(),X=function(e){this.pageComponent=e.pageComponent?new c(e.pageComponent):new c({}),this.component=e.component?new l(e.component):new l({}),this.propValues=e.propValues||{}};export{X as IkasPageComponentPropValue,K as IkasPageDataProvider};
|