@ikas/storefront 5.0.71 → 5.0.73

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{__awaiter as t,__generator as e,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import*as r from"react";import{reaction as o}from"mobx";import{listStorefrontPopup as i,SortByDirectionEnum as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as u}from"@ikas/storefront-config";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as c}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import d from"../../../store/product/index.js";import{POPUP_CONTEXT_UPDATE_EVENT as l}from'./../../../ext/@ikas/popup-script-injector/dist/popup-script-injector.es.js';import{resolveStoreUrl as p,resolveCartUrl as f}from"./common.js";var m=function(n){return t(void 0,void 0,void 0,(function(){var r,o,i,a,l,m,I,w,S,P,y,C,k,b,j,L;return e(this,(function(E){switch(E.label){case 0:return r={popups:n,cartUrl:""},[4,function(){return new Promise((function(t){var e=setInterval((function(){var n=u.getSessionId();n&&(clearInterval(e),t(n))}),100)}))}()];case 1:return E.sent(),(o=u.getSessionId())&&(r.sessionId=o),(i=u.getCdnUrl())&&(r.cdnUrl=i),(a=null===(b=u.getMerchantSettings())||void 0===b?void 0:b.merchantId)&&(r.merchantId=a),(l=p())&&(r.storeUrl=l),(m=f())&&(r.cartUrl=m),(I=u.getCustomerToken())&&(r.customerToken=I),(w=u.getCurrentLocale())&&(r.locale=w),(S=null===(L=null===(j=u.getCurrentRouting())||void 0===j?void 0:j.countryCodes)||void 0===L?void 0:L[0])&&(r.countryCode=S),(P=u.getPriceListId())&&(r.priceListId=P),(y=u.getSalesChannelId())&&(r.salesChannelId=y),T=c.getInstance().customerStore.customer,(C=T?g(T):null)&&(r.customer=C),D=c.getInstance().cartStore.cart,(k=D?h(D):null)&&(r.cart=k),r.services=function(){var n=this,r=c.getInstance();return{searchProducts:function(r){return t(n,void 0,void 0,(function(){var t,n,o;return e(this,(function(e){switch(e.label){case 0:return[4,d.searchProducts(v(r))];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(o=null===(n=t.data)||void 0===n?void 0:n.data)||void 0===o?void 0:o.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(o){var i=o.product,a=o.variant,u=o.quantity;return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,r.cartStore.addItem(a,i,null!=u?u:1)];case 1:return[2,{success:!!(null==(t=e.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(o){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,r.customerStore.saveCustomerFormData({email:o.email,firstName:o.firstName,lastName:o.lastName,birthDate:o.birthDate||"",phone:o.phone||"",storefrontPopupId:o.popupId,subscriptions:o.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){return"function"==typeof(t=r.customerStore).getLastViewedProducts?[2,t.getLastViewedProducts()]:[2,[]]}))}))},formatVariantSellPrice:function(t){return t.formattedSellPrice||""},formatVariantDiscountPrice:function(t){return t.formattedDiscountPrice||null},hasVariantDiscount:function(t){return!!t.hasDiscount},getVariantDiscountPercentage:function(t){var e=t.discountPercentage;return null==e?null:"number"==typeof e?e.toString():e},redirectToProduct:function(t){return!!t.url&&(window.location.href=t.url,!0)},viewPopup:function(t){s.viewStorefrontPopup(t)}}}(),[2,r]}var D,T}))}))};function v(t){var e,n,r,o,i,s=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?a.ASC:a.DESC,type:t.type}}));return{input:{page:null!==(n=t.page)&&void 0!==n?n:1,perPage:null!==(r=t.perPage)&&void 0!==r?r:10,order:s,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(o=t.priceListId)&&void 0!==o?o:u.getPriceListId(),salesChannelId:null!==(i=t.salesChannelId)&&void 0!==i?i:u.getSalesChannelId()}}}function g(t){return{email:t.email,firstName:t.firstName,lastName:t.lastName,birthDate:t.birthDate,phone:t.phone,gender:t.gender?String(t.gender):null,customerGroupIds:t.customerGroupIds||[],customerSegmentIds:t.customerSegmentIds||[],subscriptionStatus:t.subscriptionStatus?String(t.subscriptionStatus):null}}function h(t){var e,n,r=[],o=new Set,i=new Set,a=new Set,u=new Set,s=new Set,c=new Set;return t.items.forEach((function(t){var e,n,s,d=t.variant,l=(null==d?void 0:d.productId)||null,p=(null==d?void 0:d.id)||null,f=(null===(e=null==d?void 0:d.brand)||void 0===e?void 0:e.id)||null,m=(null===(n=null==d?void 0:d.categories)||void 0===n?void 0:n.map((function(t){return t.id})).filter(Boolean))||[];r.push({productId:l,variantId:p,brandId:f,categoryIds:m,quantity:t.quantity,finalPrice:t.finalPrice}),l&&o.add(l),p&&i.add(p),f&&a.add(f),m.forEach((function(t){return t&&u.add(t)})),(null===(s=t.discount)||void 0===s?void 0:s.campaignOfferId)&&c.add(t.discount.campaignOfferId)})),null===(e=t.campaignOffers)||void 0===e||e.forEach((function(t){t.campaignOfferId&&c.add(t.campaignOfferId)})),null===(n=t.orderAdjustments)||void 0===n||n.forEach((function(t){t.campaignId&&s.add(t.campaignId)})),{totalPrice:t.totalPrice,totalFinalPrice:t.totalFinalPrice,itemCount:t.itemCount,itemQuantity:t.itemQuantity,currencyCode:t.currencyCode||null,lines:r,productIds:Array.from(o),variantIds:Array.from(i),brandIds:Array.from(a),categoryIds:Array.from(u),appliedCampaignIds:Array.from(s),appliedCampaignOfferIds:Array.from(c),couponCode:t.couponCode||null}}function I(t){"undefined"!=typeof window&&(window.ikasPopupConfig&&(void 0!==t.customer&&(window.ikasPopupConfig.customer=t.customer),void 0!==t.cart&&(window.ikasPopupConfig.cart=t.cart),void 0!==t.customerToken&&(window.ikasPopupConfig.customerToken=t.customerToken||void 0)),"function"!=typeof window.updateIkasPopupContext?window.dispatchEvent(new CustomEvent(l,{detail:t})):window.updateIkasPopupContext(t))}function w(a){var s=this;a.router;var d=a.pageSpecificDataId,l=a.pageType;r.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var r,a=!1,d=[],l=function(t,e){if(function(t){t.setAttribute("data-ikas-popup-widget","true"),!t.dataset.ikasPopupWidgetUrl&&t.src&&(t.dataset.ikasPopupWidgetUrl=t.src)}(t),"true"===t.dataset.ikasPopupWidgetLoaded)return e(),function(){};var n=function(){t.dataset.ikasPopupWidgetLoaded="true",e()},r=function(e){console.error("[@ikas/storefront] Failed to load popup widget script",t.src,e)};return t.addEventListener("load",n,{once:!0}),t.addEventListener("error",r,{once:!0}),function(){t.removeEventListener("load",n),t.removeEventListener("error",r)}},p=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-script-injector.iife.js":"/sf/assets/popup/popup-script-injector.iife.js";if(e){var n=function(){a||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(t)},o=document.querySelector('script[data-ikas-popup-widget="true"]');if(o)r=l(o,n);else{var i=document.createElement("script");i.src=e,i.defer=!0,r=l(i,n),document.body.appendChild(i)}}},f=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/style.css":"/sf/assets/popup/style.css";if(e&&!document.querySelector('link[href="'.concat(e,'"]'))){var n=document.createElement("link");n.rel="stylesheet",n.href=e,n.setAttribute("data-ikas-popup-widget","true");n.addEventListener("error",(function(t){console.error("[@ikas/storefront] Failed to load popup widget CSS",e,t)}),{once:!0}),document.head.appendChild(n)}};return t(s,void 0,void 0,(function(){var r,l,v;return e(this,(function(w){switch(w.label){case 0:return r=u.getStorefrontPopups()||[],[4,(C=r,t(s,void 0,void 0,(function(){var t,r,o,a,u;return e(this,(function(e){switch(e.label){case 0:if(!(t=C.map((function(t){return t.id})).filter(Boolean)).length)return[2,C];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i({idList:t})];case 2:return(null==(r=e.sent())?void 0:r.isSuccess)&&(null===(u=r.data)||void 0===u?void 0:u.length)?(o=r.data,[2,C.map((function(t){var e=o.find((function(e){return e.id===t.id}));return e?n(n({},e),{isFilteredOnServerSide:t.isFilteredOnServerSide}):t}))]):[3,4];case 3:return a=e.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",a),[3,4];case 4:return[2,C]}}))})))];case 1:return l=w.sent(),a?[2]:[4,m(l)];case 2:return v=w.sent(),window.ikasPopupConfig=v,p(v),f(),S=c.getInstance(),P=o((function(){var t=S.customerStore.customer;return t?{email:t.email,gender:t.gender,groupIds:(t.customerGroupIds||[]).join(","),segmentIds:(t.customerSegmentIds||[]).join(","),subscriptionStatus:t.subscriptionStatus}:null}),(function(){var t=S.customerStore.customer;I({customer:t?g(t):null,customerToken:u.getCustomerToken()||null})})),y=o((function(){var t=S.cartStore.cart;return t?{total:t.totalFinalPrice,itemCount:t.itemCount,quantity:t.itemQuantity,productSignature:t.items.map((function(t){var e,n;return"".concat((null===(e=t.variant)||void 0===e?void 0:e.productId)||"",":").concat((null===(n=t.variant)||void 0===n?void 0:n.id)||"",":").concat(t.quantity)})).join("|"),campaignSignature:(t.orderAdjustments||[]).map((function(t){return t.campaignId||""})).join("|"),couponCode:t.couponCode}:null}),(function(){var t=S.cartStore.cart;I({cart:t?h(t):null})})),d.push(P,y),[2]}var S,P,y,C}))})),function(){a=!0,null==r||r(),d.forEach((function(t){return t()})),d=[],"function"==typeof window.destroyIkasPopupWidget&&window.destroyIkasPopupWidget()}}}),[d,l])}export{w as usePopupWidget};
1
+ import{__awaiter as t,__generator as e,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import*as r from"react";import{reaction as o}from"mobx";import{listStorefrontPopup as i,SortByDirectionEnum as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as u}from"@ikas/storefront-config";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as c}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import d from"../../../store/product/index.js";import{POPUP_CONTEXT_UPDATE_EVENT as l}from'./../../../ext/@ikas/popup-script-injector/dist/popup-script-injector.es.js';import{resolveStoreUrl as p,resolveCartUrl as f}from"./common.js";var m=function(n){return t(void 0,void 0,void 0,(function(){var r,o,i,a,l,m,I,w,S,P,y,C,k,b,j,L;return e(this,(function(E){switch(E.label){case 0:return r={popups:n,cartUrl:""},[4,function(){return new Promise((function(t){var e=setInterval((function(){var n=u.getSessionId();n&&(clearInterval(e),t(n))}),100)}))}()];case 1:return E.sent(),(o=u.getSessionId())&&(r.sessionId=o),(i=u.getCdnUrl())&&(r.cdnUrl=i),(a=null===(b=u.getMerchantSettings())||void 0===b?void 0:b.merchantId)&&(r.merchantId=a),(l=p())&&(r.storeUrl=l),(m=f())&&(r.cartUrl=m),(I=u.getCustomerToken())&&(r.customerToken=I),(w=u.getCurrentLocale())&&(r.locale=w),(S=null===(L=null===(j=u.getCurrentRouting())||void 0===j?void 0:j.countryCodes)||void 0===L?void 0:L[0])&&(r.countryCode=S),(P=u.getPriceListId())&&(r.priceListId=P),(y=u.getSalesChannelId())&&(r.salesChannelId=y),T=c.getInstance().customerStore.customer,(C=T?g(T):null)&&(r.customer=C),D=c.getInstance().cartStore.cart,(k=D?h(D):null)&&(r.cart=k),r.services=function(){var n=this,r=c.getInstance();return{searchProducts:function(r){return t(n,void 0,void 0,(function(){var t,n,o;return e(this,(function(e){switch(e.label){case 0:return[4,d.searchProducts(v(r))];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(o=null===(n=t.data)||void 0===n?void 0:n.data)||void 0===o?void 0:o.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(o){var i=o.product,a=o.variant,u=o.quantity;return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,r.cartStore.addItem(a,i,null!=u?u:1)];case 1:return[2,{success:!!(null==(t=e.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(o){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,r.customerStore.saveCustomerFormData({email:o.email,firstName:o.firstName,lastName:o.lastName,birthDate:o.birthDate||null,phone:o.phone||"",storefrontPopupId:o.popupId,subscriptions:o.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){return"function"==typeof(t=r.customerStore).getLastViewedProducts?[2,t.getLastViewedProducts()]:[2,[]]}))}))},formatVariantSellPrice:function(t){return t.formattedSellPrice||""},formatVariantDiscountPrice:function(t){return t.formattedDiscountPrice||null},hasVariantDiscount:function(t){return!!t.hasDiscount},getVariantDiscountPercentage:function(t){var e=t.discountPercentage;return null==e?null:"number"==typeof e?e.toString():e},redirectToProduct:function(t){return!!t.url&&(window.location.href=t.url,!0)},viewPopup:function(t){s.viewStorefrontPopup(t)}}}(),[2,r]}var D,T}))}))};function v(t){var e,n,r,o,i,s=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?a.ASC:a.DESC,type:t.type}}));return{input:{page:null!==(n=t.page)&&void 0!==n?n:1,perPage:null!==(r=t.perPage)&&void 0!==r?r:10,order:s,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(o=t.priceListId)&&void 0!==o?o:u.getPriceListId(),salesChannelId:null!==(i=t.salesChannelId)&&void 0!==i?i:u.getSalesChannelId()}}}function g(t){return{email:t.email,firstName:t.firstName,lastName:t.lastName,birthDate:t.birthDate,phone:t.phone,gender:t.gender?String(t.gender):null,customerGroupIds:t.customerGroupIds||[],customerSegmentIds:t.customerSegmentIds||[],subscriptionStatus:t.subscriptionStatus?String(t.subscriptionStatus):null}}function h(t){var e,n,r=[],o=new Set,i=new Set,a=new Set,u=new Set,s=new Set,c=new Set;return t.items.forEach((function(t){var e,n,s,d=t.variant,l=(null==d?void 0:d.productId)||null,p=(null==d?void 0:d.id)||null,f=(null===(e=null==d?void 0:d.brand)||void 0===e?void 0:e.id)||null,m=(null===(n=null==d?void 0:d.categories)||void 0===n?void 0:n.map((function(t){return t.id})).filter(Boolean))||[];r.push({productId:l,variantId:p,brandId:f,categoryIds:m,quantity:t.quantity,finalPrice:t.finalPrice}),l&&o.add(l),p&&i.add(p),f&&a.add(f),m.forEach((function(t){return t&&u.add(t)})),(null===(s=t.discount)||void 0===s?void 0:s.campaignOfferId)&&c.add(t.discount.campaignOfferId)})),null===(e=t.campaignOffers)||void 0===e||e.forEach((function(t){t.campaignOfferId&&c.add(t.campaignOfferId)})),null===(n=t.orderAdjustments)||void 0===n||n.forEach((function(t){t.campaignId&&s.add(t.campaignId)})),{totalPrice:t.totalPrice,totalFinalPrice:t.totalFinalPrice,itemCount:t.itemCount,itemQuantity:t.itemQuantity,currencyCode:t.currencyCode||null,lines:r,productIds:Array.from(o),variantIds:Array.from(i),brandIds:Array.from(a),categoryIds:Array.from(u),appliedCampaignIds:Array.from(s),appliedCampaignOfferIds:Array.from(c),couponCode:t.couponCode||null}}function I(t){"undefined"!=typeof window&&(window.ikasPopupConfig&&(void 0!==t.customer&&(window.ikasPopupConfig.customer=t.customer),void 0!==t.cart&&(window.ikasPopupConfig.cart=t.cart),void 0!==t.customerToken&&(window.ikasPopupConfig.customerToken=t.customerToken||void 0)),"function"!=typeof window.updateIkasPopupContext?window.dispatchEvent(new CustomEvent(l,{detail:t})):window.updateIkasPopupContext(t))}function w(a){var s=this;a.router;var d=a.pageSpecificDataId,l=a.pageType;r.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var r,a=!1,d=[],l=function(t,e){if(function(t){t.setAttribute("data-ikas-popup-widget","true"),!t.dataset.ikasPopupWidgetUrl&&t.src&&(t.dataset.ikasPopupWidgetUrl=t.src)}(t),"true"===t.dataset.ikasPopupWidgetLoaded)return e(),function(){};var n=function(){t.dataset.ikasPopupWidgetLoaded="true",e()},r=function(e){console.error("[@ikas/storefront] Failed to load popup widget script",t.src,e)};return t.addEventListener("load",n,{once:!0}),t.addEventListener("error",r,{once:!0}),function(){t.removeEventListener("load",n),t.removeEventListener("error",r)}},p=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-script-injector.iife.js":"/sf/assets/popup/popup-script-injector.iife.js";if(e){var n=function(){a||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(t)},o=document.querySelector('script[data-ikas-popup-widget="true"]');if(o)r=l(o,n);else{var i=document.createElement("script");i.src=e,i.defer=!0,r=l(i,n),document.body.appendChild(i)}}},f=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/style.css":"/sf/assets/popup/style.css";if(e&&!document.querySelector('link[href="'.concat(e,'"]'))){var n=document.createElement("link");n.rel="stylesheet",n.href=e,n.setAttribute("data-ikas-popup-widget","true");n.addEventListener("error",(function(t){console.error("[@ikas/storefront] Failed to load popup widget CSS",e,t)}),{once:!0}),document.head.appendChild(n)}};return t(s,void 0,void 0,(function(){var r,l,v;return e(this,(function(w){switch(w.label){case 0:return r=u.getStorefrontPopups()||[],[4,(C=r,t(s,void 0,void 0,(function(){var t,r,o,a,u;return e(this,(function(e){switch(e.label){case 0:if(!(t=C.map((function(t){return t.id})).filter(Boolean)).length)return[2,C];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i({idList:t})];case 2:return(null==(r=e.sent())?void 0:r.isSuccess)&&(null===(u=r.data)||void 0===u?void 0:u.length)?(o=r.data,[2,C.map((function(t){var e=o.find((function(e){return e.id===t.id}));return e?n(n({},e),{isFilteredOnServerSide:t.isFilteredOnServerSide}):t}))]):[3,4];case 3:return a=e.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",a),[3,4];case 4:return[2,C]}}))})))];case 1:return l=w.sent(),a?[2]:[4,m(l)];case 2:return v=w.sent(),window.ikasPopupConfig=v,p(v),f(),S=c.getInstance(),P=o((function(){var t=S.customerStore.customer;return t?{email:t.email,gender:t.gender,groupIds:(t.customerGroupIds||[]).join(","),segmentIds:(t.customerSegmentIds||[]).join(","),subscriptionStatus:t.subscriptionStatus}:null}),(function(){var t=S.customerStore.customer;I({customer:t?g(t):null,customerToken:u.getCustomerToken()||null})})),y=o((function(){var t=S.cartStore.cart;return t?{total:t.totalFinalPrice,itemCount:t.itemCount,quantity:t.itemQuantity,productSignature:t.items.map((function(t){var e,n;return"".concat((null===(e=t.variant)||void 0===e?void 0:e.productId)||"",":").concat((null===(n=t.variant)||void 0===n?void 0:n.id)||"",":").concat(t.quantity)})).join("|"),campaignSignature:(t.orderAdjustments||[]).map((function(t){return t.campaignId||""})).join("|"),couponCode:t.couponCode}:null}),(function(){var t=S.cartStore.cart;I({cart:t?h(t):null})})),d.push(P,y),[2]}var S,P,y,C}))})),function(){a=!0,null==r||r(),d.forEach((function(t){return t()})),d=[],"function"==typeof window.destroyIkasPopupWidget&&window.destroyIkasPopupWidget()}}}),[d,l])}export{w as usePopupWidget};
@@ -1 +1 @@
1
- import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as s}from"./variant/index.js";import{IkasProductAttributeValue as u}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as l}from"../brand/index.js";import{IkasHTMLMetaData as d}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductOptionPriceTypeEnum as f,IkasProductType as v}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as h}from"./option-set/index.js";import{makeObservable as m,observable as g,computed as b}from"mobx";import{IkasProductFunctions as V}from"@ikas/storefront-model-functions";import{IkasProductCampaign as y}from"./campaign/index.js";import{IkasStorefrontConfig as P}from"@ikas/storefront-config";import{IkasBaseStore as I}from"../../../store/base.js";import w from"lodash/groupBy";import{IkasProductBaseUnit as O}from"./base-unit/index.js";import{formatCurrency as S}from"../../../utils/currency.js";import"lodash/get";import T from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as C}from"./star/index.js";import{IkasProductCampaignOffer as L,IkasProductOffer as x}from"./campaign-offer/index.js";import{IkasProductGroup as R}from"./group/index.js";import{IkasImage as E}from"../image/index.js";import{IkasProductSalesChannel as G}from"./sales-channel/index.js";import{IkasProductTranslation as k}from"./translations/index.js";var A=function(){function A(V){void 0===V&&(V={});var w,E,D,U=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.translations=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.selectVariantValue=function(i,n){var r,a=U.metaData,o=U.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),s=U.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(s)U.selectedVariantValues=o;else{var u=U.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(u>0){var c=U.variantTypes.slice(0,u),l=U.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),d=t(t([],l,!0),[i],!1);s=U.variants.find((function(t){return t.isActive&&d.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(s=U.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(s=U.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!s)return;U.selectedVariantValues=s.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;"vid"!==i&&(f=e(e({},f),((n={})[i]=t,n)))})),U.variantTypes.map((function(t){delete f[decodeURIComponent(t.variantType.slug)]}));var v=t(t([],Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0),U.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return U.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0).filter((function(t){return!!t})).join("&");if(U.setOptionRealPrices(),!n){var h="/".concat(a.slug);if(v&&(h="/".concat(a.slug,"?").concat(v)),h===window.location.pathname)return;null===(r=I.getInstance().router)||void 0===r||r.replace(h,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&U.baseUnit){var r=U.baseUnit.baseAmount,a=(null===(i=null===(e=U.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(S(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=I.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,T.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:P.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=P.getPickupStockLocationIds(),[4,T.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.updatePrices=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a=this;return n(this,(function(n){switch(n.label){case 0:return[4,T.searchProducts({input:{productIdList:[this.id],perPage:1,priceListId:P.getPriceListId(),salesChannelId:P.getSalesChannelId()}})];case 1:return t=n.sent(),(e=null===(r=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===r?void 0:r.find((function(t){return t.id===a.id})))?(this.variants.forEach((function(t){var i=e.variants.find((function(e){return e.id===t.id}));i&&(t.prices=i.prices,t.baseBundlePrices=i.baseBundlePrices)})),[2]):[2]}}))}))},this.getCustomerReviews=function(t){return i(U,void 0,void 0,(function(){var i,r,a,o,s;return n(this,(function(n){switch(n.label){case 0:return i=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],i&&(null===(s=this.selectedVariant.bundleSettings)||void 0===s||s.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new j(e(e(e({},i?{}:{productId:this.id}),{locale:null==t?void 0:t.locale,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage,sortWithImagesFirst:null==t?void 0:t.sortWithImagesFirst}),i?{productIds:r}:{}))).getInitial()];case 1:return n.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,T.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),this.setOptionRealPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o;return n(this,(function(n){switch(n.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(i=null===(a=I.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===i.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:n.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,n,r;try{var a=null===(e=i.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(n=i.variant.bundleProducts)||void 0===n?void 0:n.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),n.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){U.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i,r,o,s,u,c=this;return n(this,(function(n){switch(n.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,T.searchProducts({input:{productIdList:e,perPage:200,priceListId:P.getPriceListId(),salesChannelId:P.getSalesChannelId()}})]:[3,2];case 1:(i=n.sent()).isSuccess&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){c.bundleProductCache[t.id]=t}))),n.label=2;case 2:return null===(u=t.bundleSettings)||void 0===u||u.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new A(a(e)))})),[2]}}))}))},this.getSubscriptionPlanOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i=this;return n(this,(function(n){return null===(e=t.subscriptionPlan)||void 0===e||e.periods.forEach((function(t,e){t.setProduct(i),0===e&&(t.isSelected=!0)})),[2]}))}))},this.setOptionRealPrices=function(){var t,e=U.selectedVariant||U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;if(t.selectSettings)t.selectSettings.values.forEach((function(t){var e;if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}));else if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}))}},this.setOptionPrices=function(){var t,e=U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var n,r;if(t.selectSettings&&t.selectSettings.values.forEach((function(t){var n,r;if(t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price})),t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price}))}},this.id=V.id||Date.now()+"",this.name=V.name||"",this.type=V.type||v.PHYSICAL,this.description=V.description||"",this.shortDescription=V.shortDescription||"",this.metaData=V.metaData?new d(V.metaData):null,this.brand=V.brand?new l(V.brand):null,this.categories=V.categories?V.categories.map((function(t){return new o(t)})):[],this.deleted=V.deleted||null,this.tags=V.tags?V.tags.map((function(t){return new p(t)})):[],this.variants=V.variants?V.variants.map((function(t){return new s(t)})):[],this.attributes=V.attributes?V.attributes.map((function(t){return new u(t)})):[],this.variantTypes=V.variantTypes?V.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=V.productOptionSetId||null,this.averageRating=null!==(w=V.averageRating)&&void 0!==w?w:null,this.reviewCount=null!==(E=V.reviewCount)&&void 0!==E?E:null,this.stars=V.stars?V.stars.map((function(t){return new C(t)})):null,this.baseUnit=V.baseUnit?new O(V.baseUnit):null,this.campaigns=(null===(D=V.campaigns)||void 0===D?void 0:D.map((function(t){return new y(t)})))||null,this.selectedVariantValues=V.selectedVariantValues||[],this.productOptionSet=V.productOptionSet?new h(V.productOptionSet):null,this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=V.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=V.dynamicPriceListIds||null,this.productVolumeDiscountId=V.productVolumeDiscountId||null,this.campaignOffers=V.campaignOffers?V.campaignOffers.map((function(t){return new L(t)})):null,this.appliedCampaignOffer=V.appliedCampaignOffer,this.offers=V.offers?V.offers.map((function(t){return new x(t)})):void 0,this.productGroup=V.productGroup?new R(V.productGroup):null,this.salesChannels=V.salesChannels?V.salesChannels.map((function(t){return new G(t)})):null,this.translations=V.translations?V.translations.map((function(t){return new k(t)})):null,this.productGroupItems=V.productGroupItems,this.variants.forEach((function(t){return t.product=U})),this.setOptionPrices(),this.setOptionRealPrices(),this.customerReviews=V.customerReviews?new j(V.customerReviews):null,m(this,{selectedVariantValues:g,isFiltered:g,isStatic:g,showVariantsInGroup:g,hasVariant:b,hasStock:b,hasValidProductOptionValues:b,href:b,productHref:b,mainVariantType:b,mainVariantValue:b,selectedVariant:b,displayedVariantTypes:b,isCustomerReviewEnabled:b,isCustomerReviewLoginRequired:b,isAddToCartEnabled:b,groupedAttributeValues:b,selectedVariantUnitPriceText:b,displayedProductGroups:b})}return Object.defineProperty(A.prototype,"hasVariant",{get:function(){return V.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:V.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"href",{get:function(){return V.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:V.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantType",{get:function(){return V.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantValue",{get:function(){return V.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?V.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewEnabled",{get:function(){return P.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewLoginRequired",{get:function(){return P.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"groupedAttributeValues",{get:function(){var t,e=w(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedProductGroups",{get:function(){var e,i=this,n=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){n.includes(t.name)||n.push(t.name)}))})),n.forEach((function(e){var n,o={name:e,items:[]};i.productGroupItems=r(i.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(n=i.productGroupItems)||void 0===n||n.forEach((function(n){var r,a,s,u=n.groupValues.find((function(t){return t.name===e}));if(u&&!o.items.some((function(t){return t.value===u.value}))){var c="";if(n.productId===i.id)c=i.href;else{var l=(null===(r=i.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],d=t(t([],l,!0),[u],!1),p=null===(a=i.productGroupItems)||void 0===a?void 0:a.find((function(t){return d.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:n.href}o.items.push({image:n.image?new E(n.image):null,href:c,value:u.value,isSelected:(null===(s=i.productGroupItems)||void 0===s?void 0:s.some((function(t){return t.groupValues.some((function(t){return t.value===u.value}))&&t.productId===i.id})))||!1,isSelectable:function(){var n,r,a=(null===(n=i.productGroup)||void 0===n?void 0:n.values.filter((function(t){return t.name!==e})))||[],o=t(t([],a,!0),[u],!1);return!!(null===(r=i.productGroupItems)||void 0===r?void 0:r.find((function(t){return o.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))})))}(),hasStock:n.hasStock})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),A.prototype.dispose=function(){var t,e,i=this;(null===(t=this.variants)||void 0===t||t.forEach((function(t){var e,i;t.product=null,t.bundleSettings&&(null===(e=t.bundleSettings.products)||void 0===e||e.forEach((function(t){t.product=null}))),t.subscriptionPlan&&(null===(i=t.subscriptionPlan.periods)||void 0===i||i.forEach((function(t){t.product=null})))})),this.bundleProductCache={},null===(e=this.offers)||void 0===e||e.forEach((function(t){t.product=null})),"undefined"!=typeof window)&&(window.requestIdleCallback||function(t){return window.setTimeout(t,200)})((function(){try{i.variants=[],i.attributes=[],i.variantTypes=[],i.categories=[],i.tags=null,i.campaigns=null,i.campaignOffers=null,i.productOptionSet=null,i.productGroup=null,i.salesChannels=null,i.translations=null,i.customerReviews=null,i.offers=void 0,i.metaData=null,i.brand=null,i.selectedVariantValues=[]}catch(t){}}))},A}();export{A as IkasProduct};
1
+ import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as s}from"./variant/index.js";import{IkasProductAttributeValue as u}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductOptionPriceTypeEnum as f,IkasProductType as v}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as h}from"./option-set/index.js";import{makeObservable as m,observable as g,computed as b}from"mobx";import{IkasProductFunctions as V}from"@ikas/storefront-model-functions";import{IkasProductCampaign as y}from"./campaign/index.js";import{IkasStorefrontConfig as P}from"@ikas/storefront-config";import{IkasBaseStore as I}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as S}from"./base-unit/index.js";import{formatCurrency as w}from"../../../utils/currency.js";import"lodash/get";import T from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as C}from"./star/index.js";import{IkasProductCampaignOffer as L,IkasProductOffer as x}from"./campaign-offer/index.js";import{IkasProductGroup as R}from"./group/index.js";import{IkasImage as G}from"../image/index.js";import{IkasProductSalesChannel as E}from"./sales-channel/index.js";import{IkasProductTranslation as k}from"./translations/index.js";var A=function(){function A(V){void 0===V&&(V={});var O,G,D,U=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.translations=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.selectVariantValue=function(i,n){var r,a=U.metaData,o=U.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),s=U.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(s)U.selectedVariantValues=o;else{var u=U.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(u>0){var c=U.variantTypes.slice(0,u),d=U.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[i],!1);s=U.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(s=U.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(s=U.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!s)return;U.selectedVariantValues=s.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;"vid"!==i&&(f=e(e({},f),((n={})[i]=t,n)))})),U.variantTypes.map((function(t){delete f[decodeURIComponent(t.variantType.slug)]}));var v=t(t([],Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0),U.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return U.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0).filter((function(t){return!!t})).join("&");if(U.setOptionRealPrices(),!n){var h="/".concat(a.slug);if(v&&(h="/".concat(a.slug,"?").concat(v)),h===window.location.pathname)return;null===(r=I.getInstance().router)||void 0===r||r.replace(h,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&U.baseUnit){var r=U.baseUnit.baseAmount,a=(null===(i=null===(e=U.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(w(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=I.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,T.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:P.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=P.getPickupStockLocationIds(),[4,T.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.updatePrices=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a=this;return n(this,(function(n){switch(n.label){case 0:return[4,T.searchProducts({input:{productIdList:[this.id],perPage:1,priceListId:P.getPriceListId(),salesChannelId:P.getSalesChannelId()}})];case 1:return t=n.sent(),(e=null===(r=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===r?void 0:r.find((function(t){return t.id===a.id})))?(this.variants.forEach((function(t){var i=e.variants.find((function(e){return e.id===t.id}));i&&(t.prices=i.prices,t.baseBundlePrices=i.baseBundlePrices)})),[2]):[2]}}))}))},this.getCustomerReviews=function(t){return i(U,void 0,void 0,(function(){var i,r,a,o,s;return n(this,(function(n){switch(n.label){case 0:return i=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],i&&(null===(s=this.selectedVariant.bundleSettings)||void 0===s||s.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new j(e(e(e({},i?{}:{productId:this.id}),{locale:null==t?void 0:t.locale,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage,sortWithImagesFirst:null==t?void 0:t.sortWithImagesFirst}),i?{productIds:r}:{}))).getInitial()];case 1:return n.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,T.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),this.setOptionRealPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o;return n(this,(function(n){switch(n.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(i=null===(a=I.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===i.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:n.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,n,r;try{var a=null===(e=i.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(n=i.variant.bundleProducts)||void 0===n?void 0:n.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),n.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){U.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i,r,o,s,u,c=this;return n(this,(function(n){switch(n.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,T.searchProducts({input:{productIdList:e,perPage:200,priceListId:P.getPriceListId(),salesChannelId:P.getSalesChannelId()}})]:[3,2];case 1:(i=n.sent()).isSuccess&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){c.bundleProductCache[t.id]=t}))),n.label=2;case 2:return null===(u=t.bundleSettings)||void 0===u||u.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new A(a(e)))})),[2]}}))}))},this.getSubscriptionPlanOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i=this;return n(this,(function(n){return null===(e=t.subscriptionPlan)||void 0===e||e.periods.forEach((function(t,e){t.setProduct(i),0===e&&(t.isSelected=!0)})),[2]}))}))},this.setOptionRealPrices=function(){var t,e=U.selectedVariant||U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;if(t.selectSettings)t.selectSettings.values.forEach((function(t){var e;if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}));else if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}))}},this.setOptionPrices=function(){var t,e=U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var n,r;if(t.selectSettings&&t.selectSettings.values.forEach((function(t){var n,r;if(t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price})),t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price}))}},this.id=V.id||Date.now()+"",this.name=V.name||"",this.type=V.type||v.PHYSICAL,this.description=V.description||"",this.shortDescription=V.shortDescription||"",this.metaData=V.metaData?new l(V.metaData):null,this.brand=V.brand?new d(V.brand):null,this.categories=V.categories?V.categories.map((function(t){return new o(t)})):[],this.deleted=V.deleted||null,this.tags=V.tags?V.tags.map((function(t){return new p(t)})):[],this.variants=V.variants?V.variants.map((function(t){return new s(t)})):[],this.attributes=V.attributes?V.attributes.map((function(t){return new u(t)})):[],this.variantTypes=V.variantTypes?V.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=V.productOptionSetId||null,this.averageRating=null!==(O=V.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(G=V.reviewCount)&&void 0!==G?G:null,this.stars=V.stars?V.stars.map((function(t){return new C(t)})):null,this.baseUnit=V.baseUnit?new S(V.baseUnit):null,this.campaigns=(null===(D=V.campaigns)||void 0===D?void 0:D.map((function(t){return new y(t)})))||null,this.selectedVariantValues=V.selectedVariantValues||[],this.productOptionSet=V.productOptionSet?new h(V.productOptionSet):null,this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=V.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=V.dynamicPriceListIds||null,this.productVolumeDiscountId=V.productVolumeDiscountId||null,this.campaignOffers=V.campaignOffers?V.campaignOffers.map((function(t){return new L(t)})):null,this.appliedCampaignOffer=V.appliedCampaignOffer,this.offers=V.offers?V.offers.map((function(t){return new x(t)})):void 0,this.productGroup=V.productGroup?new R(V.productGroup):null,this.salesChannels=V.salesChannels?V.salesChannels.map((function(t){return new E(t)})):null,this.translations=V.translations?V.translations.map((function(t){return new k(t)})):null,this.productGroupItems=V.productGroupItems,this.variants.forEach((function(t){return t.product=U})),this.setOptionPrices(),this.setOptionRealPrices(),this.customerReviews=V.customerReviews?new j(V.customerReviews):null,m(this,{selectedVariantValues:g,isFiltered:g,isStatic:g,showVariantsInGroup:g,hasVariant:b,hasStock:b,hasValidProductOptionValues:b,href:b,productHref:b,mainVariantType:b,mainVariantValue:b,selectedVariant:b,displayedVariantTypes:b,isCustomerReviewEnabled:b,isCustomerReviewLoginRequired:b,isAddToCartEnabled:b,groupedAttributeValues:b,selectedVariantUnitPriceText:b,displayedProductGroups:b})}return Object.defineProperty(A.prototype,"hasVariant",{get:function(){return V.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:V.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"href",{get:function(){return V.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:V.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantType",{get:function(){return V.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantValue",{get:function(){return V.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?V.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewEnabled",{get:function(){return P.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewLoginRequired",{get:function(){return P.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedProductGroups",{get:function(){var e,i=this,n=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){n.includes(t.name)||n.push(t.name)}))})),n.forEach((function(e){var n,o={name:e,items:[]};i.productGroupItems=r(i.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(n=i.productGroupItems)||void 0===n||n.forEach((function(n){var r,a,s,u=n.groupValues.find((function(t){return t.name===e}));if(u&&!o.items.some((function(t){return t.value===u.value}))){var c="";if(n.productId===i.id)c=i.href;else{var d=(null===(r=i.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[u],!1),p=null===(a=i.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:n.href}o.items.push({image:n.image?new G(n.image):null,href:c,value:u.value,isSelected:(null===(s=i.productGroupItems)||void 0===s?void 0:s.some((function(t){return t.groupValues.some((function(t){return t.value===u.value}))&&t.productId===i.id})))||!1,isSelectable:function(){var n,r,a=(null===(n=i.productGroup)||void 0===n?void 0:n.values.filter((function(t){return t.name!==e})))||[],o=t(t([],a,!0),[u],!1);return!!(null===(r=i.productGroupItems)||void 0===r?void 0:r.find((function(t){return o.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))})))}(),hasStock:n.hasStock})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),A.prototype.dispose=function(){},A}();export{A as IkasProduct};
@@ -20,10 +20,6 @@ export declare class IkasPageDataInit {
20
20
  static initBrandListPropValue(propValue: IkasBrandListParams): IkasBrandList;
21
21
  static initCategoryPropValue(propValue: IkasCategoryPropValueData): any;
22
22
  static initCategoryListPropValue(propValue: IkasCategoryListParams): IkasCategoryList;
23
- static _productListRegistry: Map<string, {
24
- list: IkasProductList;
25
- propValue: IkasProductListParams;
26
- }>;
27
23
  static initProductListPropValue(propValue: IkasProductListParams): IkasProductList;
28
24
  private static _nextPrefetchCleanerInstalled;
29
25
  private static NEXT_SDC_MAX_ENTRIES;
@@ -1 +1 @@
1
- import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{renderComponent as t}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as r}from"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import{IkasBlog as a}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,initIkasCategory as s,IkasThemeJsonComponentPropType as u,IkasProductAttributeType as d}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as l}from"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import{IkasImage as c}from"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as p}from"../models/data/product/index.js";import{IkasRaffle as m}from"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as f}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasBlogList as g}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as v}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as P}from"../models/ui/brand-list/index.js";import{IkasCategoryList as h}from"../models/ui/category-list/index.js";import{IkasNavigationLink as V}from"../models/ui/navigation-link/index.js";import{IkasProductList as j}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as C}from"../models/ui/product-attribute-detail/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-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/ikas-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{IkasComponentRenderer as D}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as L}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as T,getPlaceholderBrand as x,getPlaceholderCategory as y,getPlaceholderProduct as I,getPlaceholderBlog as S,getPlaceholderBlogCategory as w,getPlaceholderRaffle as _,ProductDataBindingFields as b,ProductVariantDataBindingFields as E,CategoryDataBindingFields as R,BrandDataBindingFields as O}from"@ikas/storefront-providers";import A from"lodash/flatten";import{IkasBaseStore as B}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import{IkasProductVariantFunctions as k,stringToSlug as N}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as G}from"@ikas/storefront-config";import U from"react";var M=function(){function M(){}return M.setPageSpecificData=function(t,i,u){var d;if(this.pageType=i,this.isBrowser=u,t)switch(i){case n.PRODUCT:var c=t;M.pageSpecificData=new p(e(e({},c),{selectedVariantValues:c.selectedVariantValues||(null===(d=c.variants.find((function(e){return k.hasStock(e)})))||void 0===d?void 0:d.variantValues)||c.variants[0].variantValues})),u&&this._initProductOnBrowser(M.pageSpecificData);break;case n.CATEGORY:var f=t;s(f,G.getCurrentLocale()),M.pageSpecificData=new l(f);break;case n.BRAND:var g=t;M.pageSpecificData=new o(g);break;case n.BLOG:var v=t;M.pageSpecificData=new a(v);break;case n.BLOG_CATEGORY:var P=t;M.pageSpecificData=new r(P);break;case n.RAFFLE_DETAIL:var h=t;M.pageSpecificData=new m(h)}else this.pageSpecificData=void 0},M.isServer=function(){return"undefined"==typeof window},M.initPagePropValues=function(e,t,i,r,a){return this.flatCustomDataList=A(i.map((function(e){return e.flat}))),e.map((function(e){return M.initPageComponentPropValue(e,t,r,a)}))},M.initPageComponentPropValue=function(t,i,r,a){var o=i.find((function(e){return e.id===t.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(e){var i=t.propValues[e.name];s[e.name]=M.initPropValue(e,i,r,a)})),new T(e(e({},t),{pageComponent:new f(e(e({},t.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},M.initPropValue=function(e,t,i,r){if(null==t)return null;switch(e.type){case u.TEXT:return M.initTextPropValue(t);case u.IMAGE:return M.initImagePropValue(t);case u.IMAGE_LIST:return M.initImageListPropValue(t);case u.BRAND:return M.initBrandPropValue(t);case u.BRAND_LIST:return M.initBrandListPropValue(t);case u.CATEGORY:return M.initCategoryPropValue(t);case u.CATEGORY_LIST:return M.initCategoryListPropValue(t);case u.PRODUCT_LIST:return M.initProductListPropValue(t);case u.PRODUCT_DETAIL:return M.initProductPropValue(t);case u.PRODUCT_ATTRIBUTE:return M.initAttributePropValue(t);case u.PRODUCT_ATTRIBUTE_LIST:return M.initAttributeListPropValue(t);case u.LINK:case u.LIST_OF_LINK:return M.initLinkPropValue(t);case u.COMPONENT:return M.initComponentPropValue(t,i,r);case u.COMPONENT_LIST:return M.initComponentListPropValue(t,i,r);case u.CUSTOM:return M.initCustomDataPropValue(t,i,r);case u.BLOG:return M.initBlogPropValue(t);case u.BLOG_LIST:return M.initBlogListPropValue(t);case u.BLOG_CATEGORY:return M.initBlogCategoryPropValue(t);case u.BLOG_LIST:return M.initBlogCategoryListPropValue(t);case u.RAFFLE:return M.initRafflePropValue(t);case u.RAFFLE_LIST:return M.initRaffleListPropValue(t);case u.SLIDER:return M.initSliderPropValue(t);case u.VIDEO:return M.initVideoPropValue(t);default:return t}},M.initTextPropValue=function(e){var t=this;function i(e){for(var t,i=/{{(.*?)}}|([^{}]+)/g,r=[];null!==(t=i.exec(e));)t[1]?r.push({value:t[1],isVariable:!0}):t[2]&&r.push({value:t[2],isVariable:!1});return r}return i(e).filter((function(e){return e.isVariable})).length?U.createElement("div",null,function(){for(var r,a,o,s,u=i(e),l=u.filter((function(e){return e.isVariable})),c={},p=B.getInstance().currentPageType,m=function(e){var i=e.value;if(p===n.PRODUCT){var u=t.pageSpecificData;if(i.includes(b.ATTRIBUTE_VALUE)){var l=i.split(b.ATTRIBUTE_VALUE)[1].split("_")[1],m=u.groupedAttributeValues.find((function(e){return e.attribute.id===l})),f=u.selectedVariant.groupedAttributeValues.find((function(e){return e.attribute.id===l}))||m;f?f.attribute.type===d.CHOICE?c[i]=(null===(r=f.values[0].productAttributeOption)||void 0===r?void 0:r.name)||"":f.attribute.type===d.MULTIPLE_CHOICE?c[i]=f.values.map((function(e){var t;return null===(t=e.productAttributeOption)||void 0===t?void 0:t.name})).join(", ")||"":c[i]=f.values[0].value||"":c[i]=""}else i.includes(b.NAME)?c[i]=u.name:i.includes(b.DESCRIPTION)?c[i]=u.description:i.includes(b.SHORT_DESCRIPTION)?c[i]=u.shortDescription:i.includes(b.CATEGORY_NAME)?c[i]=(null===(a=u.categories[0])||void 0===a?void 0:a.name)||"":i.includes(b.TAG)?c[i]=(null===(o=u.tags)||void 0===o?void 0:o.map((function(e){return e.name})).join(", "))||"":i.includes(E.BARCODE)?c[i]=(null===(s=u.selectedVariant.barcodeList)||void 0===s?void 0:s.length)?u.selectedVariant.barcodeList[0]:"":i.includes(E.SKU)?c[i]=u.selectedVariant.sku:i.includes(E.SELL_PRICE)?c[i]=u.selectedVariant.formattedSellPrice:i.includes(E.DISCOUNT_PRICE)?c[i]=u.selectedVariant.formattedDiscountPrice:i.includes(E.STOCK)?c[i]=u.selectedVariant.stock:c[i]=""}else if(p===n.CATEGORY){var g=t.pageSpecificData;i===R.NAME?c[i]=g.name:i===R.DESCRIPTION?c[i]=g.description:c[i]=""}else if(p===n.BRAND){var v=t.pageSpecificData;i===O.NAME?c[i]=v.name:c[i]=""}else c[i]=""},f=0,g=l;f<g.length;f++){m(g[f])}for(var v="",P=0,h=u;P<h.length;P++){var V=h[P];V.isVariable?v+=c[V.value]:v+=V.value}return v}()):e},M.initBrandPropValue=function(e){return e.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.brand?new o(e.brand):x()},M.initBrandListPropValue=function(e){return new P(e)},M.initCategoryPropValue=function(t){var i,r;return t.categoryPropValue.usePageData&&this.pageSpecificData?((null===(i=t.categoryPropValue.excludedFieldsCategory)||void 0===i?void 0:i.length)&&(this.pageSpecificData.description=null),this.pageSpecificData):t.category?new l(e(e({},t.category),{description:(null===(r=t.categoryPropValue.excludedFieldsCategory)||void 0===r?void 0:r.length)?null:t.category.description})):y()},M.initCategoryListPropValue=function(e){return new h(e)},M.initProductListPropValue=function(t){var i,r,a,o=null===(i=null==t?void 0:t.productListPropValue)||void 0===i?void 0:i.id;if(o){var n=M._productListRegistry.get(o);if(n){if(n.propValue===t)return n.list;(null===(a=null===(r=n.list)||void 0===r?void 0:r.data)||void 0===a?void 0:a.length)&&n.list.data.forEach((function(e){var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)}));try{var s=n.propValue;s&&(s.data=null,s.relatedProductData=null,s.recommendedProductData=null,s.viewedTogetherProductData=null,s.purchasedTogetherProductData=null)}catch(e){}}}var u=new j(e(e({},t),{pageSpecificData:this.pageSpecificData}),B.getInstance().router);return o&&M._productListRegistry.set(o,{list:u,propValue:t}),M.trimNextRouterCache(),M.installNextPrefetchCleaner(),u},M._getNextRouter=function(){var e;if("undefined"==typeof window)return null;try{var t=B.getInstance().router;if(t&&t.sdc)return t}catch(e){}return(null===(e=window.next)||void 0===e?void 0:e.router)||null},M.installNextPrefetchCleaner=function(){if("undefined"!=typeof window)if(window.__ikasSdcSweepInterval)M._nextPrefetchCleanerInstalled=!0;else try{window.__ikasSdcSweepInterval=window.setInterval((function(){try{var e=M._getNextRouter();if(!e)return;var t=M.NEXT_SDC_MAX_ENTRIES;if(e.sdc&&"object"==typeof e.sdc){var i=Object.keys(e.sdc);if(i.length>t){var r=e.asPath,a=r&&i.find((function(e){return e.endsWith(r+".json")})),o=i.slice(-t),n=new Set(o);a&&n.add(a);for(var s=0,u=i;s<u.length;s++){var d=u[s];if(!n.has(d))try{delete e.sdc[d]}catch(e){}}var l=e.pageLoader;if(l&&l.prefetched&&"object"==typeof l.prefetched)for(var c=Object.keys(e.sdc),p=Object.keys(l.prefetched),m=function(e){if(!c.some((function(t){return t.includes(e)})))try{delete l.prefetched[e]}catch(e){}},f=0,g=p;f<g.length;f++){m(g[f])}}}}catch(e){}}),500);var e=function(){var e=M._getNextRouter();return!(!e||!e.events||"function"!=typeof e.events.on)&&(window.__ikasRouteHookAttached||(e.events.on("routeChangeComplete",(function(){M.trimNextRouterCache()})),window.__ikasRouteHookAttached=!0),!0)};if(!e())var t=window.setInterval((function(){e()&&window.clearInterval(t)}),500);M._nextPrefetchCleanerInstalled=!0}catch(e){}},M.trimNextRouterCache=function(){if("undefined"!=typeof window)try{var e=B.getInstance().router;if(!e)return;var t=e.asPath;if(e.sdc&&"object"==typeof e.sdc){var i=Object.keys(e.sdc),r=M.NEXT_SDC_MAX_ENTRIES,a=t&&i.find((function(e){return e.endsWith(t+".json")})),o=i.slice(-r),n=new Set(o);a&&n.add(a);for(var s=0,u=i;s<u.length;s++){var d=u[s];n.has(d)||delete e.sdc[d]}}var l=e.route;if(e.components&&"object"==typeof e.components)for(var c=Object.keys(e.components),p=0,m=c;p<m.length;p++){if((d=m[p])!==l&&"/_app"!==d){var f=e.components[d];f&&f.props&&f.props.pageProps&&(f.props.pageProps=null)}}var g=e.pageLoader;if(g){if(g.pageCache&&"object"==typeof g.pageCache)for(var v=Object.keys(g.pageCache),P=0,h=v;P<h.length;P++){if((d=h[P])!==l&&"/_app"!==d&&"/_error"!==d)try{delete g.pageCache[d]}catch(e){}}if(g.prefetched&&"object"==typeof g.prefetched&&e.sdc)for(var V=Object.keys(e.sdc),j=Object.keys(g.prefetched),C=function(e){if(!V.some((function(t){return t.includes(e)})))try{delete g.prefetched[e]}catch(e){}},D=0,L=j;D<L.length;D++){C(L[D])}}if("undefined"!=typeof document&&e.sdc){var T=Object.keys(e.sdc);document.querySelectorAll('link[rel="prefetch"][href$=".json"]').forEach((function(e){var t,i=e.href;if(i&&!T.some((function(e){return i.endsWith(e)})))try{null===(t=e.parentNode)||void 0===t||t.removeChild(e)}catch(e){}}))}}catch(e){}},M.initProductPropValue=function(t){var i=new p(I());if(t.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new p(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return i},M._initProductOnBrowser=function(e){var t=new URLSearchParams(window.location.search),i=t.get("vid");if(i){var r=e.variants.find((function(e){return e.id===i}));r&&(e.selectedVariantValues=r.variantValues)}else{var a=e.variantTypes.map((function(e){return e.variantType.slug})),o=[];a.forEach((function(i,r){var a=e.variantTypes[r],n=N(t.get(decodeURIComponent(i))||"");if(n){var s=a.variantType.values.find((function(e){return e.slug===n}));s&&o.push(s)}})),o.length===e.selectedVariantValues.length&&(e.selectedVariantValues=o)}e.setOptionRealPrices()},M.initAttributePropValue=function(t){var i=null;if(t.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new p(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return new C(i,t.attributePropValue)},M.initAttributeListPropValue=function(t){var r=null;if(t.attributeListPropValue.usePageData&&this.pageSpecificData)r=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;r=new p(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return new i(r,t.attributeListPropValue)},M.initLinkPropValue=function(e){return Array.isArray(e)?e.map((function(e){return new V(e.href,e.label,e.subLinks,e.isExternal||void 0)})):e?new V(e.href,e.label,e.subLinks,e.isExternal||void 0):void 0},M.initImagePropValue=function(e){return new c(e)},M.initImageListPropValue=function(e){return e.map((function(e){return new c(e)}))},M.initCustomDataPropValue=function(e,t,i){if(e&&e.value&&e.customDataId){var r=this.flatCustomDataList.find((function(t){return t.id===e.customDataId}));if(r)return this._initCustomDataPropValue(e,r,t,i)}},M._initCustomDataPropValue=function(e,t,i,r){var a=this;if(!e)return null;var o=e.value;if(null==o)return null;switch(t.type){case u.TEXT:return this.initTextPropValue(o);case u.BRAND:return this.initBrandPropValue(o);case u.BRAND_LIST:return this.initBrandListPropValue(o);case u.CATEGORY_LIST:return this.initCategoryListPropValue(o);case u.CATEGORY:return this.initCategoryPropValue(o);case u.IMAGE_LIST:return this.initImageListPropValue(o);case u.IMAGE:return this.initImagePropValue(o);case u.LINK:return this.initLinkPropValue(o);case u.PRODUCT_DETAIL:return this.initProductPropValue(o);case u.PRODUCT_LIST:return this.initProductListPropValue(o);case u.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case u.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case u.BLOG:return this.initBlogPropValue(o);case u.BLOG_LIST:return this.initBlogListPropValue(o);case u.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case u.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case u.RAFFLE:return this.initRafflePropValue(o);case u.RAFFLE_LIST:return this.initRaffleListPropValue(o);case u.SLIDER:return this.initSliderPropValue(o);case u.VIDEO:return M.initVideoPropValue(o);case u.OBJECT:for(var n={},s=function(e){var t=o[e.key],a=void 0;e.customDataId&&(a=d.flatCustomDataList.find((function(e){return e.id===t.customDataId}))),n[e.key]=d._initCustomDataPropValue(t,a||e,i,r)},d=this,l=0,c=t.nestedData||[];l<c.length;l++){s(c[l])}return n;case u.DYNAMIC_LIST:case u.STATIC_LIST:try{if(!o||!o.length)return null;var p=[],m=t.nestedData[0];return o.forEach((function(e){var t;m.customDataId&&(t=a.flatCustomDataList.find((function(t){return t.id===e.customDataId}))),p.push(a._initCustomDataPropValue(e,t||m,i,r))})),p}catch(e){return[]}case u.COMPONENT:return this.initComponentPropValue(o,i,r);case u.COMPONENT_LIST:return this.initComponentListPropValue(o,i,r);default:return o}},M.initComponentPropValue=function(e,t,i){return this._initComponentPropValue(e,t,i)},M._initComponentPropValue=function(e,i,r){var a=e.length?e[0]:void 0;if(a){var o=new T(a),n=M.initPageComponentPropValue(o,[o.component],i,r);if(n)return new D((function(){return t(n,i,-10)}))}},M.initComponentListPropValue=function(e,t,i){return this._initComponentListPropValue(e,t,i)},M._initComponentListPropValue=function(e,i,r){return e&&e.length?e.map((function(e){var a=new T(e),o=M.initPageComponentPropValue(a,[a.component],i,r);return new D((function(){return t(o,i,-1)}))})):[]},M.initBlogPropValue=function(e){return e.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blog?new a(e.blog):S()},M.initBlogListPropValue=function(e){return new g(e)},M.initBlogCategoryPropValue=function(e){return e.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blogCategory?new r(e.blogCategory):w()},M.initBlogCategoryListPropValue=function(e){return new v(e)},M.initRafflePropValue=function(e){return e.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.raffle?new m(e.raffle):new m(_())},M.initRaffleListPropValue=function(e){return new L(e)},M.initSliderPropValue=function(e){return e},M.initVideoPropValue=function(t){return e(e({},t),{thumbnailImage:t.thumbnailImage?new c(t.thumbnailImage):null})},M.pageSpecificData={},M.flatCustomDataList=[],M.isBrowser=!1,M._productListRegistry=new Map,M._nextPrefetchCleanerInstalled=!1,M.NEXT_SDC_MAX_ENTRIES=20,M}();export{M as IkasPageDataInit};
1
+ import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{renderComponent as t}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as r}from"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import{IkasBlog as a}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,initIkasCategory as s,IkasThemeJsonComponentPropType as u,IkasProductAttributeType as d}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as l}from"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import{IkasImage as c}from"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as p}from"../models/data/product/index.js";import{IkasRaffle as m}from"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as f}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasBlogList as g}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as v}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as P}from"../models/ui/brand-list/index.js";import{IkasCategoryList as h}from"../models/ui/category-list/index.js";import{IkasNavigationLink as V}from"../models/ui/navigation-link/index.js";import{IkasProductList as j}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as C}from"../models/ui/product-attribute-detail/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-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/ikas-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{IkasComponentRenderer as D}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as x}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as T,getPlaceholderBrand as L,getPlaceholderCategory as I,getPlaceholderProduct as y,getPlaceholderBlog as S,getPlaceholderBlogCategory as w,getPlaceholderRaffle as b,ProductDataBindingFields as _,ProductVariantDataBindingFields as E,CategoryDataBindingFields as O,BrandDataBindingFields as R}from"@ikas/storefront-providers";import A from"lodash/flatten";import{IkasBaseStore as B}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import{IkasProductVariantFunctions as k,stringToSlug as N}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as G}from"@ikas/storefront-config";import U from"react";var M=function(){function M(){}return M.setPageSpecificData=function(t,i,u){var d;if(this.pageType=i,this.isBrowser=u,t)switch(i){case n.PRODUCT:var c=t;M.pageSpecificData=new p(e(e({},c),{selectedVariantValues:c.selectedVariantValues||(null===(d=c.variants.find((function(e){return k.hasStock(e)})))||void 0===d?void 0:d.variantValues)||c.variants[0].variantValues})),u&&this._initProductOnBrowser(M.pageSpecificData);break;case n.CATEGORY:var f=t;s(f,G.getCurrentLocale()),M.pageSpecificData=new l(f);break;case n.BRAND:var g=t;M.pageSpecificData=new o(g);break;case n.BLOG:var v=t;M.pageSpecificData=new a(v);break;case n.BLOG_CATEGORY:var P=t;M.pageSpecificData=new r(P);break;case n.RAFFLE_DETAIL:var h=t;M.pageSpecificData=new m(h)}else this.pageSpecificData=void 0},M.isServer=function(){return"undefined"==typeof window},M.initPagePropValues=function(e,t,i,r,a){return this.flatCustomDataList=A(i.map((function(e){return e.flat}))),e.map((function(e){return M.initPageComponentPropValue(e,t,r,a)}))},M.initPageComponentPropValue=function(t,i,r,a){var o=i.find((function(e){return e.id===t.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(e){var i=t.propValues[e.name];s[e.name]=M.initPropValue(e,i,r,a)})),new T(e(e({},t),{pageComponent:new f(e(e({},t.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},M.initPropValue=function(e,t,i,r){if(null==t)return null;switch(e.type){case u.TEXT:return M.initTextPropValue(t);case u.IMAGE:return M.initImagePropValue(t);case u.IMAGE_LIST:return M.initImageListPropValue(t);case u.BRAND:return M.initBrandPropValue(t);case u.BRAND_LIST:return M.initBrandListPropValue(t);case u.CATEGORY:return M.initCategoryPropValue(t);case u.CATEGORY_LIST:return M.initCategoryListPropValue(t);case u.PRODUCT_LIST:return M.initProductListPropValue(t);case u.PRODUCT_DETAIL:return M.initProductPropValue(t);case u.PRODUCT_ATTRIBUTE:return M.initAttributePropValue(t);case u.PRODUCT_ATTRIBUTE_LIST:return M.initAttributeListPropValue(t);case u.LINK:case u.LIST_OF_LINK:return M.initLinkPropValue(t);case u.COMPONENT:return M.initComponentPropValue(t,i,r);case u.COMPONENT_LIST:return M.initComponentListPropValue(t,i,r);case u.CUSTOM:return M.initCustomDataPropValue(t,i,r);case u.BLOG:return M.initBlogPropValue(t);case u.BLOG_LIST:return M.initBlogListPropValue(t);case u.BLOG_CATEGORY:return M.initBlogCategoryPropValue(t);case u.BLOG_LIST:return M.initBlogCategoryListPropValue(t);case u.RAFFLE:return M.initRafflePropValue(t);case u.RAFFLE_LIST:return M.initRaffleListPropValue(t);case u.SLIDER:return M.initSliderPropValue(t);case u.VIDEO:return M.initVideoPropValue(t);default:return t}},M.initTextPropValue=function(e){var t=this;function i(e){for(var t,i=/{{(.*?)}}|([^{}]+)/g,r=[];null!==(t=i.exec(e));)t[1]?r.push({value:t[1],isVariable:!0}):t[2]&&r.push({value:t[2],isVariable:!1});return r}return i(e).filter((function(e){return e.isVariable})).length?U.createElement("div",null,function(){for(var r,a,o,s,u=i(e),l=u.filter((function(e){return e.isVariable})),c={},p=B.getInstance().currentPageType,m=function(e){var i=e.value;if(p===n.PRODUCT){var u=t.pageSpecificData;if(i.includes(_.ATTRIBUTE_VALUE)){var l=i.split(_.ATTRIBUTE_VALUE)[1].split("_")[1],m=u.groupedAttributeValues.find((function(e){return e.attribute.id===l})),f=u.selectedVariant.groupedAttributeValues.find((function(e){return e.attribute.id===l}))||m;f?f.attribute.type===d.CHOICE?c[i]=(null===(r=f.values[0].productAttributeOption)||void 0===r?void 0:r.name)||"":f.attribute.type===d.MULTIPLE_CHOICE?c[i]=f.values.map((function(e){var t;return null===(t=e.productAttributeOption)||void 0===t?void 0:t.name})).join(", ")||"":c[i]=f.values[0].value||"":c[i]=""}else i.includes(_.NAME)?c[i]=u.name:i.includes(_.DESCRIPTION)?c[i]=u.description:i.includes(_.SHORT_DESCRIPTION)?c[i]=u.shortDescription:i.includes(_.CATEGORY_NAME)?c[i]=(null===(a=u.categories[0])||void 0===a?void 0:a.name)||"":i.includes(_.TAG)?c[i]=(null===(o=u.tags)||void 0===o?void 0:o.map((function(e){return e.name})).join(", "))||"":i.includes(E.BARCODE)?c[i]=(null===(s=u.selectedVariant.barcodeList)||void 0===s?void 0:s.length)?u.selectedVariant.barcodeList[0]:"":i.includes(E.SKU)?c[i]=u.selectedVariant.sku:i.includes(E.SELL_PRICE)?c[i]=u.selectedVariant.formattedSellPrice:i.includes(E.DISCOUNT_PRICE)?c[i]=u.selectedVariant.formattedDiscountPrice:i.includes(E.STOCK)?c[i]=u.selectedVariant.stock:c[i]=""}else if(p===n.CATEGORY){var g=t.pageSpecificData;i===O.NAME?c[i]=g.name:i===O.DESCRIPTION?c[i]=g.description:c[i]=""}else if(p===n.BRAND){var v=t.pageSpecificData;i===R.NAME?c[i]=v.name:c[i]=""}else c[i]=""},f=0,g=l;f<g.length;f++){m(g[f])}for(var v="",P=0,h=u;P<h.length;P++){var V=h[P];V.isVariable?v+=c[V.value]:v+=V.value}return v}()):e},M.initBrandPropValue=function(e){return e.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.brand?new o(e.brand):L()},M.initBrandListPropValue=function(e){return new P(e)},M.initCategoryPropValue=function(t){var i,r;return t.categoryPropValue.usePageData&&this.pageSpecificData?((null===(i=t.categoryPropValue.excludedFieldsCategory)||void 0===i?void 0:i.length)&&(this.pageSpecificData.description=null),this.pageSpecificData):t.category?new l(e(e({},t.category),{description:(null===(r=t.categoryPropValue.excludedFieldsCategory)||void 0===r?void 0:r.length)?null:t.category.description})):I()},M.initCategoryListPropValue=function(e){return new h(e)},M.initProductListPropValue=function(t){var i=new j(e(e({},t),{pageSpecificData:this.pageSpecificData}),B.getInstance().router);return M.trimNextRouterCache(),M.installNextPrefetchCleaner(),i},M._getNextRouter=function(){var e;if("undefined"==typeof window)return null;try{var t=B.getInstance().router;if(t&&t.sdc)return t}catch(e){}return(null===(e=window.next)||void 0===e?void 0:e.router)||null},M.installNextPrefetchCleaner=function(){if("undefined"!=typeof window)if(window.__ikasSdcSweepInterval)M._nextPrefetchCleanerInstalled=!0;else try{window.__ikasSdcSweepInterval=window.setInterval((function(){try{var e=M._getNextRouter();if(!e)return;var t=M.NEXT_SDC_MAX_ENTRIES;if(e.sdc&&"object"==typeof e.sdc){var i=Object.keys(e.sdc);if(i.length>t){var r=e.asPath,a=r&&i.find((function(e){return e.endsWith(r+".json")})),o=i.slice(-t),n=new Set(o);a&&n.add(a);for(var s=0,u=i;s<u.length;s++){var d=u[s];if(!n.has(d))try{delete e.sdc[d]}catch(e){}}var l=e.pageLoader;if(l&&l.prefetched&&"object"==typeof l.prefetched)for(var c=Object.keys(e.sdc),p=Object.keys(l.prefetched),m=function(e){if(!c.some((function(t){return t.includes(e)})))try{delete l.prefetched[e]}catch(e){}},f=0,g=p;f<g.length;f++){m(g[f])}}}}catch(e){}}),500);var e=function(){var e=M._getNextRouter();return!(!e||!e.events||"function"!=typeof e.events.on)&&(window.__ikasRouteHookAttached||(e.events.on("routeChangeComplete",(function(){M.trimNextRouterCache()})),window.__ikasRouteHookAttached=!0),!0)};if(!e())var t=window.setInterval((function(){e()&&window.clearInterval(t)}),500);M._nextPrefetchCleanerInstalled=!0}catch(e){}},M.trimNextRouterCache=function(){if("undefined"!=typeof window)try{var e=B.getInstance().router;if(!e)return;var t=e.asPath;if(e.sdc&&"object"==typeof e.sdc){var i=Object.keys(e.sdc),r=M.NEXT_SDC_MAX_ENTRIES,a=t&&i.find((function(e){return e.endsWith(t+".json")})),o=i.slice(-r),n=new Set(o);a&&n.add(a);for(var s=0,u=i;s<u.length;s++){var d=u[s];n.has(d)||delete e.sdc[d]}}var l=e.route;if(e.components&&"object"==typeof e.components)for(var c=Object.keys(e.components),p=0,m=c;p<m.length;p++){if((d=m[p])!==l&&"/_app"!==d){var f=e.components[d];f&&f.props&&f.props.pageProps&&(f.props.pageProps=null)}}var g=e.pageLoader;if(g){if(g.pageCache&&"object"==typeof g.pageCache)for(var v=Object.keys(g.pageCache),P=0,h=v;P<h.length;P++){if((d=h[P])!==l&&"/_app"!==d&&"/_error"!==d)try{delete g.pageCache[d]}catch(e){}}if(g.prefetched&&"object"==typeof g.prefetched&&e.sdc)for(var V=Object.keys(e.sdc),j=Object.keys(g.prefetched),C=function(e){if(!V.some((function(t){return t.includes(e)})))try{delete g.prefetched[e]}catch(e){}},D=0,x=j;D<x.length;D++){C(x[D])}}if("undefined"!=typeof document&&e.sdc){var T=Object.keys(e.sdc);document.querySelectorAll('link[rel="prefetch"][href$=".json"]').forEach((function(e){var t,i=e.href;if(i&&!T.some((function(e){return i.endsWith(e)})))try{null===(t=e.parentNode)||void 0===t||t.removeChild(e)}catch(e){}}))}}catch(e){}},M.initProductPropValue=function(t){var i=new p(y());if(t.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new p(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return i},M._initProductOnBrowser=function(e){var t=new URLSearchParams(window.location.search),i=t.get("vid");if(i){var r=e.variants.find((function(e){return e.id===i}));r&&(e.selectedVariantValues=r.variantValues)}else{var a=e.variantTypes.map((function(e){return e.variantType.slug})),o=[];a.forEach((function(i,r){var a=e.variantTypes[r],n=N(t.get(decodeURIComponent(i))||"");if(n){var s=a.variantType.values.find((function(e){return e.slug===n}));s&&o.push(s)}})),o.length===e.selectedVariantValues.length&&(e.selectedVariantValues=o)}e.setOptionRealPrices()},M.initAttributePropValue=function(t){var i=null;if(t.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new p(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return new C(i,t.attributePropValue)},M.initAttributeListPropValue=function(t){var r=null;if(t.attributeListPropValue.usePageData&&this.pageSpecificData)r=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;r=new p(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return new i(r,t.attributeListPropValue)},M.initLinkPropValue=function(e){return Array.isArray(e)?e.map((function(e){return new V(e.href,e.label,e.subLinks,e.isExternal||void 0)})):e?new V(e.href,e.label,e.subLinks,e.isExternal||void 0):void 0},M.initImagePropValue=function(e){return new c(e)},M.initImageListPropValue=function(e){return e.map((function(e){return new c(e)}))},M.initCustomDataPropValue=function(e,t,i){if(e&&e.value&&e.customDataId){var r=this.flatCustomDataList.find((function(t){return t.id===e.customDataId}));if(r)return this._initCustomDataPropValue(e,r,t,i)}},M._initCustomDataPropValue=function(e,t,i,r){var a=this;if(!e)return null;var o=e.value;if(null==o)return null;switch(t.type){case u.TEXT:return this.initTextPropValue(o);case u.BRAND:return this.initBrandPropValue(o);case u.BRAND_LIST:return this.initBrandListPropValue(o);case u.CATEGORY_LIST:return this.initCategoryListPropValue(o);case u.CATEGORY:return this.initCategoryPropValue(o);case u.IMAGE_LIST:return this.initImageListPropValue(o);case u.IMAGE:return this.initImagePropValue(o);case u.LINK:return this.initLinkPropValue(o);case u.PRODUCT_DETAIL:return this.initProductPropValue(o);case u.PRODUCT_LIST:return this.initProductListPropValue(o);case u.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case u.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case u.BLOG:return this.initBlogPropValue(o);case u.BLOG_LIST:return this.initBlogListPropValue(o);case u.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case u.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case u.RAFFLE:return this.initRafflePropValue(o);case u.RAFFLE_LIST:return this.initRaffleListPropValue(o);case u.SLIDER:return this.initSliderPropValue(o);case u.VIDEO:return M.initVideoPropValue(o);case u.OBJECT:for(var n={},s=function(e){var t=o[e.key],a=void 0;e.customDataId&&(a=d.flatCustomDataList.find((function(e){return e.id===t.customDataId}))),n[e.key]=d._initCustomDataPropValue(t,a||e,i,r)},d=this,l=0,c=t.nestedData||[];l<c.length;l++){s(c[l])}return n;case u.DYNAMIC_LIST:case u.STATIC_LIST:try{if(!o||!o.length)return null;var p=[],m=t.nestedData[0];return o.forEach((function(e){var t;m.customDataId&&(t=a.flatCustomDataList.find((function(t){return t.id===e.customDataId}))),p.push(a._initCustomDataPropValue(e,t||m,i,r))})),p}catch(e){return[]}case u.COMPONENT:return this.initComponentPropValue(o,i,r);case u.COMPONENT_LIST:return this.initComponentListPropValue(o,i,r);default:return o}},M.initComponentPropValue=function(e,t,i){return this._initComponentPropValue(e,t,i)},M._initComponentPropValue=function(e,i,r){var a=e.length?e[0]:void 0;if(a){var o=new T(a),n=M.initPageComponentPropValue(o,[o.component],i,r);if(n)return new D((function(){return t(n,i,-10)}))}},M.initComponentListPropValue=function(e,t,i){return this._initComponentListPropValue(e,t,i)},M._initComponentListPropValue=function(e,i,r){return e&&e.length?e.map((function(e){var a=new T(e),o=M.initPageComponentPropValue(a,[a.component],i,r);return new D((function(){return t(o,i,-1)}))})):[]},M.initBlogPropValue=function(e){return e.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blog?new a(e.blog):S()},M.initBlogListPropValue=function(e){return new g(e)},M.initBlogCategoryPropValue=function(e){return e.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blogCategory?new r(e.blogCategory):w()},M.initBlogCategoryListPropValue=function(e){return new v(e)},M.initRafflePropValue=function(e){return e.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.raffle?new m(e.raffle):new m(b())},M.initRaffleListPropValue=function(e){return new x(e)},M.initSliderPropValue=function(e){return e},M.initVideoPropValue=function(t){return e(e({},t),{thumbnailImage:t.thumbnailImage?new c(t.thumbnailImage):null})},M.pageSpecificData={},M.flatCustomDataList=[],M.isBrowser=!1,M._nextPrefetchCleanerInstalled=!1,M.NEXT_SDC_MAX_ENTRIES=20,M}();export{M as IkasPageDataInit};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "5.0.71",
3
+ "version": "5.0.73",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -23,11 +23,11 @@
23
23
  "swiper": "11.0.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@ikas/storefront-api": "^5.0.71",
27
- "@ikas/storefront-config": "^5.0.71",
28
- "@ikas/storefront-model-functions": "^5.0.71",
29
- "@ikas/storefront-models": "^5.0.71",
30
- "@ikas/storefront-providers": "^5.0.71",
26
+ "@ikas/storefront-api": "^5.0.73",
27
+ "@ikas/storefront-config": "^5.0.73",
28
+ "@ikas/storefront-model-functions": "^5.0.73",
29
+ "@ikas/storefront-models": "^5.0.73",
30
+ "@ikas/storefront-providers": "^5.0.73",
31
31
  "@ikas/localized-address": "1.0.0-beta.6",
32
32
  "@adyen/adyen-web": "^5.57.0",
33
33
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -62,11 +62,11 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@ikas/localized-address": "1.0.0-beta.6",
65
- "@ikas/storefront-api": "^5.0.71",
66
- "@ikas/storefront-config": "^5.0.71",
67
- "@ikas/storefront-model-functions": "^5.0.71",
68
- "@ikas/storefront-models": "^5.0.71",
69
- "@ikas/storefront-providers": "^5.0.71",
65
+ "@ikas/storefront-api": "^5.0.73",
66
+ "@ikas/storefront-config": "^5.0.73",
67
+ "@ikas/storefront-model-functions": "^5.0.73",
68
+ "@ikas/storefront-models": "^5.0.73",
69
+ "@ikas/storefront-providers": "^5.0.73",
70
70
  "mobx": "^6.1.3",
71
71
  "mobx-react-lite": "^3.1.5",
72
72
  "next": "12.2.0",