@ikas/storefront 6.1.0-beta.157 → 6.1.0-beta.159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/page/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js +1 -1
- package/build/store/customer/index.d.ts +2 -2
- package/build/store/customer/index.js +1 -1
- package/package.json +12 -11
- package/build/components/popup/utils/index.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t,__spreadArray as e,__awaiter as o,__generator as r}from'./../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as n}from"mobx-react-lite";import{useRouter as a}from"next/router.js";import"../../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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as s}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"../../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"../../models/data/image/index.js";import{IkasMerchantSettings as d}from"../../models/data/merchant-settings/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"../../models/data/product/index.js";import"../../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-filter/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{IkasThemeJsonCustomData as u}from"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/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"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageHead as c}from"./head.js";import{ThemeComponent as p}from"./ThemeComponent.js";import{IkasBaseStore as f}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{initIkasEvents as v}from"../../analytics/events.js";import{IkasPageDataInit as g}from"../../page-data-init/index.js";import{setAPIClientConfig as j,listStorefrontPopup as x}from"@ikas/storefront-api";import{getPopupProducts as h}from"../popup/utils/index.js";import w from"../../store/product/index.js";var y=function(t,e){return o(void 0,void 0,void 0,(function(){var o,i,n,a,s,d,u,l,c,p,f;return r(this,(function(r){switch(r.label){case 0:return o={popups:t,callbacks:e},[4,function(){return new Promise((function(t){var e=setInterval((function(){var o=m.getSessionId();o&&(clearInterval(e),t(o))}),100)}))}()];case 1:return r.sent(),(i=m.getSessionId())&&(o.sessionId=i),(n=m.getCdnUrl())&&(o.cdnUrl=n),(a=null===(c=m.getMerchantSettings())||void 0===c?void 0:c.merchantId)&&(o.merchantId=a),v=m.getDomain(),(s=v?v.startsWith("http")?v:"https://".concat(v):"undefined"!=typeof window?window.location.origin:void 0)&&(o.storeUrl=s),(d=m.getCustomerToken())&&(o.customerToken=d),(u=m.getCurrentLocale())&&(o.locale=u),(l=null===(f=null===(p=m.getCurrentRouting())||void 0===p?void 0:p.countryCodes)||void 0===f?void 0:f[0])&&(o.countryCode=l),[2,o]}var v}))}))},b=n((function(n){var p=n.propValues,b=n.themeJsonComponents,P=n.customDataList,C=n.pageType,k=n.pageTitle,I=n.pageDescription,D=n.pageSpecificData,E=n.canonicals,T=n.disableIndex,M=n.settings,F=n.configJson,L=n.reInitOnBrowser,R=n.addOgpMetas,V=n.components,N=n.productReviewSummary,O=a(),U=i.useState(),W=U[0],A=U[1];m.init(t(t({},F),{currentPageComponents:V,loginRequiredCallback:function(){O.push("/account/login")}})),f.getInstance().router=O,j();var B=f.getInstance();B.router=O,B.currentPageType=C;var z=i.useRef(new Map),H=i.useState(!1),J=H[0],_=H[1],q=i.useMemo((function(){return(null==W?void 0:W.id)===(null==D?void 0:D.id)&&g.pageSpecificData&&g.isBrowser?C===s.PRODUCT&&g._initProductOnBrowser(g.pageSpecificData):g.setPageSpecificData(D,C,J),g.initPagePropValues(p,b,P.map((function(t){return new u(t)})),M,J)}),e(e([],C!==s.SEARCH?[J]:[],!0),[p,C,M,D,b],!1));i.useEffect((function(){L&&_("undefined"!=typeof window),window.addToCart=B.cartStore._windowAddToCart,B.cartStore.getCart(),B.checkLocalization(),v()}),[]),i.useEffect((function(){D?(null==W?void 0:W.id)!==D.id&&A(D):A(null)}),[D]),i.useEffect((function(){var t=function(){B.customerStore.routeChangeInit()};return O.events.on("routeChangeStart",t),function(){O.events.off("routeChangeStart",t)}}),[]),i.useEffect((function(){!function(t,e){var i,n;o(this,void 0,void 0,(function(){var o,a,d,u,m,c;return r(this,(function(r){switch(r.label){case 0:return o=f.getInstance(),[4,l.pageView(t)];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,7,,8]),t!==s.PRODUCT?[3,4]:(a=e,[4,l.productView(a)]);case 3:r.sent(),o.customerStore.onProductView(a.id,a.selectedVariant.id),r.label=4;case 4:return t===s.CATEGORY&&(u=null===(i=(d=e).categoryPathItems)||void 0===i?void 0:i.map((function(t){return t.name})).join(" > "),u=d.categoryPathItems&&(null===(n=d.categoryPathItems)||void 0===n?void 0:n.length)>0?u+" > "+d.name:d.name,l.viewCategory(u,d)),t===s.BRAND&&(m=e,l.viewBrand(m)),t!==s.CART?[3,6]:[4,o.cartStore.waitUntilInitialized()];case 5:r.sent(),l.viewCart(o.cartStore.cart),r.label=6;case 6:return[3,8];case 7:return c=r.sent(),console.error(c),[3,8];case 8:return[2]}}))}))}(C,g.pageSpecificData)}),[C,D]),i.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var e,i=!1,n=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 o=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",o,{once:!0}),t.addEventListener("error",r,{once:!0}),function(){t.removeEventListener("load",o),t.removeEventListener("error",r)}};return o(void 0,void 0,void 0,(function(){var a,s,d,u,l,c,p,f,v,g;return r(this,(function(j){switch(j.label){case 0:return a=m.getStorefrontPopups()||[],[4,(b=a,o(void 0,void 0,void 0,(function(){var e,o,i,n,a;return r(this,(function(r){switch(r.label){case 0:if(!(e=b.map((function(t){return t.id})).filter(Boolean)).length)return[2,b];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,x({idList:e})];case 2:return(null==(o=r.sent())?void 0:o.isSuccess)&&(null===(a=o.data)||void 0===a?void 0:a.length)?(i=new Map(o.data.filter((function(t){return!!(null==t?void 0:t.id)})).map((function(t){return[t.id,t]}))),[2,b.map((function(e){var o=i.get(e.id);return o?t(t({},o),{isFilteredOnServerSide:e.isFilteredOnServerSide}):e}))]):[3,4];case 3:return n=r.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",n),[3,4];case 4:return[2,b]}}))})))];case 1:return s=j.sent(),(d=z.current).clear(),u=new Map,i?[2]:(l=function(t,e,i){var n=this,a=function(t){return!!t.url&&(window.location.href=t.url,!0)},s=function(e,s){return o(n,void 0,void 0,(function(){var e,o,n,d,u,m,l;return r(this,(function(r){switch(r.label){case 0:if(!(null==s?void 0:s.productId)||!(null==s?void 0:s.variantId))return[2,a(s)];if(e=t.get(s.productId))return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,w.searchProducts({input:{productIdList:[s.productId],page:1,perPage:1}})];case 2:return(o=r.sent()).isSuccess&&(null===(l=null===(m=o.data)||void 0===m?void 0:m.data)||void 0===l?void 0:l.length)&&(e=o.data.data[0],t.set(e.id,e)),[3,4];case 3:return n=r.sent(),console.error("[@ikas/storefront] Failed to fetch product for popup",n),[3,4];case 4:return e&&(d=e.variants.find((function(t){return t.id===s.variantId})))?(e.selectedVariantValues=d.variantValues.slice(),[4,i.cartStore.addItem(d,e)]):[2,a(s)];case 5:return(null==(u=r.sent())?void 0:u.success)?[2,!0]:[2,a(s)]}}))}))},d=function(t,e){return o(n,void 0,void 0,(function(){var o,n,a,s,d;return r(this,(function(r){switch(r.label){case 0:o=i.customerStore,n=o.customer,(a=(null==n?void 0:n.email)||e.email||"")||(s="".concat(e.firstName||"").concat(e.lastName||"").trim())&&(a=s),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,o.saveCustomerFormData({email:a,firstName:e.firstName||(null==n?void 0:n.firstName)||"",lastName:e.lastName||(null==n?void 0:n.lastName)||"",birthDate:e.birthday||(null==n?void 0:n.birthDate)||"",phone:e.phone||(null==n?void 0:n.phone)||"",storefrontPopupId:t,subscriptions:{email:!!e.hasPermission,phone:!!e.hasPermission,sms:!!e.hasPermission}})];case 2:return r.sent(),[3,4];case 3:return d=r.sent(),console.error("[@ikas/storefront] Failed to save popup customer form data",d),[3,4];case 4:return[2]}}))}))},u=function(i){return o(n,void 0,void 0,(function(){var o,n,a,s,d;return r(this,(function(r){switch(r.label){case 0:if(!i.contentJson)return[2,{}];if(o=e.get(i.id))return[2,o];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,h(i.contentJson,m.getCdnUrl()||"",(null===(d=m.getMerchantSettings())||void 0===d?void 0:d.merchantId)||"",m.getPriceListId())];case 2:return n=r.sent(),a=n.totalProducts,n.ikasProducts.forEach((function(e){(null==e?void 0:e.id)&&t.set(e.id,e)})),e.set(i.id,a),[2,a];case 3:return s=r.sent(),console.error("[@ikas/storefront] Failed to fetch popup products",s),[2,{}];case 4:return[2]}}))}))};return{addProductToCart:s,onCustomerSave:d,getPopupProducts:u}}(d,u,B),[4,y(s,l)]);case 2:return c=j.sent(),window.ikasPopupConfig=c,(p=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-widget.iife.js":"/sf/assets/popup/popup-script-injector.iife.js")?(f=function(){i||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(c)},(v=document.querySelector('script[data-ikas-popup-widget="true"]'))?(e=n(v,f),[2]):((g=document.createElement("script")).src=p,g.defer=!0,e=n(g,f),document.body.appendChild(g),[2])):[2]}var b}))})),function(){i=!0,null==e||e()}}}),[O.asPath,C,null==D?void 0:D.id]);var G=i.useMemo((function(){var t=q.find((function(t){return t.component.isHeader})),e=q.find((function(t){return t.component.isFooter})),o=q.filter((function(t){return!t.component.isHeader&&!t.component.isFooter}))||[];return i.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},i.createElement("div",null,t&&S(t,M,-1),o.map((function(t,e){return S(t,M,e)}))),e&&S(e,M,-1))}),[q,M]),Y=i.useMemo((function(){return m.getMerchantSettings()?new d(m.getMerchantSettings()):null}),[m.getMerchantSettings()]);return i.createElement(i.Fragment,null,i.createElement(c,{pageType:C,pageTitle:k,pageDescription:I,pageSpecificData:g.pageSpecificData,canonicals:E&&E.length>0?E:null,disableIndex:T,merchantSettings:Y,addOgpMetas:R,productReviewSummary:N,pageComponentPropValues:q}),G)})),S=function(t,e,o){return i.createElement(p,{key:t.pageComponent.id,index:o,pageComponentPropValue:t,settings:e})};export{b as IkasPage,S as renderComponent};
|
|
1
|
+
import{__assign as t,__spreadArray as e,__awaiter as o,__generator as r}from'./../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as n}from"mobx-react-lite";import{useRouter as a}from"next/router.js";import"../../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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as s}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"../../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"../../models/data/image/index.js";import{IkasMerchantSettings as d}from"../../models/data/merchant-settings/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"../../models/data/product/index.js";import"../../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-filter/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{IkasThemeJsonCustomData as u}from"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/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"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{Analytics as c}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageHead as l}from"./head.js";import{ThemeComponent as p}from"./ThemeComponent.js";import{IkasBaseStore as f}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{initIkasEvents as v}from"../../analytics/events.js";import{IkasPageDataInit as g}from"../../page-data-init/index.js";import{setAPIClientConfig as j,listStorefrontPopup as x,SortByDirectionEnum as h}from"@ikas/storefront-api";import w from"../../store/product/index.js";var y=function(t){return o(void 0,void 0,void 0,(function(){var e,i,n,a,s,d,u,c,l,p,v,g,j,x;return r(this,(function(h){switch(h.label){case 0:return e={popups:t},[4,function(){return new Promise((function(t){var e=setInterval((function(){var o=m.getSessionId();o&&(clearInterval(e),t(o))}),100)}))}()];case 1:return h.sent(),(i=m.getSessionId())&&(e.sessionId=i),(n=m.getCdnUrl())&&(e.cdnUrl=n),(a=null===(g=m.getMerchantSettings())||void 0===g?void 0:g.merchantId)&&(e.merchantId=a),S=m.getDomain(),(s=S?S.startsWith("http")?S:"https://".concat(S):"undefined"!=typeof window?window.location.origin:void 0)&&(e.storeUrl=s),(d=m.getCustomerToken())&&(e.customerToken=d),(u=m.getCurrentLocale())&&(e.locale=u),(c=null===(x=null===(j=m.getCurrentRouting())||void 0===j?void 0:j.countryCodes)||void 0===x?void 0:x[0])&&(e.countryCode=c),(l=m.getPriceListId())&&(e.priceListId=l),(p=m.getSalesChannelId())&&(e.salesChannelId=p),y=f.getInstance().customerStore.customer,(v=y?{email:y.email,firstName:y.firstName,lastName:y.lastName,birthDate:y.birthDate,phone:y.phone}:null)&&(e.customer=v),e.services=function(){var t=this,e=f.getInstance();return{searchProducts:function(e){return o(t,void 0,void 0,(function(){var t,o,i;return r(this,(function(r){switch(r.label){case 0:return[4,w.searchProducts(P(e))];case 1:return(null==(t=r.sent())?void 0:t.isSuccess)&&(null===(i=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===i?void 0:i.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(i){var n=i.product,a=i.variant,s=i.quantity;return o(t,void 0,void 0,(function(){var t;return r(this,(function(o){switch(o.label){case 0:return[4,e.cartStore.addItem(a,n,null!=s?s:1)];case 1:return[2,{success:!!(null==(t=o.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(i){return o(t,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,e.customerStore.saveCustomerFormData({email:i.email,firstName:i.firstName,lastName:i.lastName,birthDate:i.birthDate||"",phone:i.phone||"",storefrontPopupId:i.popupId,subscriptions:i.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return o(t,void 0,void 0,(function(){var t;return r(this,(function(o){return"function"==typeof(t=e.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)}}}(),[2,e]}var y,S}))}))},S=n((function(n){var p=n.propValues,h=n.themeJsonComponents,w=n.customDataList,S=n.pageType,P=n.pageTitle,C=n.pageDescription,I=n.pageSpecificData,k=n.canonicals,D=n.disableIndex,L=n.settings,E=n.configJson,T=n.reInitOnBrowser,V=n.addOgpMetas,F=n.components,M=n.productReviewSummary,R=a(),N=i.useState(),O=N[0],A=N[1];m.init(t(t({},E),{currentPageComponents:F,loginRequiredCallback:function(){R.push("/account/login")}})),f.getInstance().router=R,j();var U=f.getInstance();U.router=R,U.currentPageType=S;var W=i.useState(!1),B=W[0],z=W[1],H=i.useMemo((function(){return(null==O?void 0:O.id)===(null==I?void 0:I.id)&&g.pageSpecificData&&g.isBrowser?S===s.PRODUCT&&g._initProductOnBrowser(g.pageSpecificData):g.setPageSpecificData(I,S,B),g.initPagePropValues(p,h,w.map((function(t){return new u(t)})),L,B)}),e(e([],S!==s.SEARCH?[B]:[],!0),[p,S,L,I,h],!1));i.useEffect((function(){T&&z("undefined"!=typeof window),window.addToCart=U.cartStore._windowAddToCart,U.cartStore.getCart(),U.checkLocalization(),v()}),[]),i.useEffect((function(){I?(null==O?void 0:O.id)!==I.id&&A(I):A(null)}),[I]),i.useEffect((function(){var t=function(){U.customerStore.routeChangeInit()};return R.events.on("routeChangeStart",t),function(){R.events.off("routeChangeStart",t)}}),[]),i.useEffect((function(){!function(t,e){var i,n;o(this,void 0,void 0,(function(){var o,a,d,u,m,l;return r(this,(function(r){switch(r.label){case 0:return o=f.getInstance(),[4,c.pageView(t)];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,7,,8]),t!==s.PRODUCT?[3,4]:(a=e,[4,c.productView(a)]);case 3:r.sent(),o.customerStore.onProductView(a.id,a.selectedVariant.id),r.label=4;case 4:return t===s.CATEGORY&&(u=null===(i=(d=e).categoryPathItems)||void 0===i?void 0:i.map((function(t){return t.name})).join(" > "),u=d.categoryPathItems&&(null===(n=d.categoryPathItems)||void 0===n?void 0:n.length)>0?u+" > "+d.name:d.name,c.viewCategory(u,d)),t===s.BRAND&&(m=e,c.viewBrand(m)),t!==s.CART?[3,6]:[4,o.cartStore.waitUntilInitialized()];case 5:r.sent(),c.viewCart(o.cartStore.cart),r.label=6;case 6:return[3,8];case 7:return l=r.sent(),console.error(l),[3,8];case 8:return[2]}}))}))}(S,g.pageSpecificData)}),[S,I]),i.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var e,i=!1,n=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 o=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",o,{once:!0}),t.addEventListener("error",r,{once:!0}),function(){t.removeEventListener("load",o),t.removeEventListener("error",r)}};return o(void 0,void 0,void 0,(function(){var a,s,d,u,c,l,p;return r(this,(function(f){switch(f.label){case 0:return a=m.getStorefrontPopups()||[],[4,(v=a,o(void 0,void 0,void 0,(function(){var e,o,i,n,a;return r(this,(function(r){switch(r.label){case 0:if(!(e=v.map((function(t){return t.id})).filter(Boolean)).length)return[2,v];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,x({idList:e})];case 2:return(null==(o=r.sent())?void 0:o.isSuccess)&&(null===(a=o.data)||void 0===a?void 0:a.length)?(i=new Map(o.data.filter((function(t){return!!(null==t?void 0:t.id)})).map((function(t){return[t.id,t]}))),[2,v.map((function(e){var o=i.get(e.id);return o?t(t({},o),{isFilteredOnServerSide:e.isFilteredOnServerSide}):e}))]):[3,4];case 3:return n=r.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",n),[3,4];case 4:return[2,v]}}))})))];case 1:return s=f.sent(),i?[2]:[4,y(s)];case 2:return d=f.sent(),window.ikasPopupConfig=d,(u=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-script-injector.iife.js":"/sf/assets/popup/popup-script-injector.iife.js")?(c=function(){i||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(d)},(l=document.querySelector('script[data-ikas-popup-widget="true"]'))?(e=n(l,c),[2]):((p=document.createElement("script")).src=u,p.defer=!0,e=n(p,c),document.body.appendChild(p),[2])):[2]}var v}))})),function(){i=!0,null==e||e()}}}),[R.asPath,S,null==I?void 0:I.id]);var q=i.useMemo((function(){var t=H.find((function(t){return t.component.isHeader})),e=H.find((function(t){return t.component.isFooter})),o=H.filter((function(t){return!t.component.isHeader&&!t.component.isFooter}))||[];return i.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},i.createElement("div",null,t&&b(t,L,-1),o.map((function(t,e){return b(t,L,e)}))),e&&b(e,L,-1))}),[H,L]),_=i.useMemo((function(){return m.getMerchantSettings()?new d(m.getMerchantSettings()):null}),[m.getMerchantSettings()]);return i.createElement(i.Fragment,null,i.createElement(l,{pageType:S,pageTitle:P,pageDescription:C,pageSpecificData:g.pageSpecificData,canonicals:k&&k.length>0?k:null,disableIndex:D,merchantSettings:_,addOgpMetas:V,productReviewSummary:M,pageComponentPropValues:H}),q)})),b=function(t,e,o){return i.createElement(p,{key:t.pageComponent.id,index:o,pageComponentPropValue:t,settings:e})};function P(t){var e,o,r,i,n,a=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?h.ASC:h.DESC,type:t.type}}));return{input:{page:null!==(o=t.page)&&void 0!==o?o:1,perPage:null!==(r=t.perPage)&&void 0!==r?r:10,order:a,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(i=t.priceListId)&&void 0!==i?i:m.getPriceListId(),salesChannelId:null!==(n=t.salesChannelId)&&void 0!==n?n:m.getSalesChannelId()}}}export{S as IkasPage,b as renderComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"../../ext/tslib/tslib.es6.mjs.js";import"../../ext/libphonenumber-js/es6/PhoneNumberMatcher.js";import"../../ext/libphonenumber-js/es6/AsYouTypeFormatter.js";import{isValidPhoneNumber as e}from"../../ext/libphonenumber-js/min/exports/isValidPhoneNumber.js";import"../../ext/libphonenumber-js/min/exports/PhoneNumberMatcher.js";import"../../ext/libphonenumber-js/min/exports/AsYouType.js";import"../../ext/libphonenumber-js/min/exports/Metadata.js";import"../../ext/libphonenumber-js/es6/findNumbers/isValidCandidate.js";import"../../ext/libphonenumber-js/index.es6.exports/PhoneNumberSearch.js";import{ComponentHorizontalAlignmentEnum as t}from"../models/modal/step/elements/base/index.js";var n=function(e){var n="";switch(e){case t.LEFT:n="flex-start";break;case t.CENTER:n="center";break;case t.RIGHT:n="flex-end"}return n},r=function(e){if(e.name){var t=e.name.replace(/ /g,"+"),n="";if(e.variants){n+=":";var r=e.variants.some((function(e){return"italic"===e}));if(r&&(n+="ital,"),n+="wght@",r){var a=new RegExp("italic","i");n+=e.variants.reduce((function(e,t){return a.test(t)?e:e+"0,".concat(t.replace("regular","400"),";")}),""),n+=e.variants.reduce((function(e,t){return a.test(t)?e+"1,".concat("italic"===t?"400":t.replace("italic",""),";"):e}),"")}else n+=e.variants.reduce((function(e,t){return e+"".concat(t.replace("regular","400"),";")}),"");n=n.substring(0,n.length-1),n+="&display=swap"}return"https://fonts.googleapis.com/css2?family=".concat(t).concat(n)}},a=function(e){var t="'".concat(e.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif');if(document.getElementById("ikas-popup-font-".concat(e.name)))return t;var n=r(e);if(n){var a=document.createElement("link");return a.setAttribute("id","ikas-popup-font-".concat(e.name)),a.setAttribute("rel","stylesheet"),a.setAttribute("href",n),document.getElementsByTagName("head")[0].appendChild(a),t}},i=function(e){return!(e.length>320)&&/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(e)},s=function(t,n){return e(t,n?n.toUpperCase():"TR")},o=function(e){var t;return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)+(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)};export{o as generateRandomId,r as getGoogleFontHref,n as getHorizontalAlignment,a as injectFontScript,i as validateEmail,s as validatePhoneNumber};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__extends as t}from"../../../../../../ext/tslib/tslib.es6.mjs.js";import{makeObservable as o,observable as
|
|
1
|
+
import{__extends as t}from"../../../../../../ext/tslib/tslib.es6.mjs.js";import{makeObservable as o,observable as e}from"mobx";import{PopupElementTypeEnum as n,BaseElement as i}from"../base/index.js";import{ProductDetailSettings as r,ProductImageSettings as a,ProductButtonSettings as E}from"./detail-settings/index.js";import{ButtonElement as d}from"../button/index.js";import{TextElement as l}from"../text/index.js";var C,u,s,_;(_=C||(C={})).ASC_AVERAGE_RATING="ASC_AVERAGE_RATING",_.DESC_AVERAGE_RATING="DESC_AVERAGE_RATING",_.ASC_CREATED_AT="ASC_CREATED_AT",_.DESC_CREATED_AT="DESC_CREATED_AT",_.ASC_DISCOUNT_RATIO="ASC_DISCOUNT_RATIO",_.DESC_DISCOUNT_RATIO="DESC_DISCOUNT_RATIO",_.ASC_NAME="ASC_NAME",_.DESC_NAME="DESC_NAME",_.ASC_PRICE="ASC_PRICE",_.DESC_PRICE="DESC_PRICE",_.ASC_REVIEW_COUNT="ASC_REVIEW_COUNT",_.DESC_REVIEW_COUNT="DESC_REVIEW_COUNT",_.ASC_SALE_COUNT="ASC_SALE_COUNT",_.DESC_SALE_COUNT="DESC_SALE_COUNT",function(t){t.ALL="ALL",t.SPECIFIC="SPECIFIC",t.CATEGORY="CATEGORY",t.LAST_VIEWED="LAST_VIEWED"}(u||(u={})),function(t){t.ONE_COLUMN="ONE_COLUMN",t.TWO_COLUMN="TWO_COLUMN",t.THREE_COLUMN="THREE_COLUMN"}(s||(s={}));var S=function(i){function _(t){void 0===t&&(t={});var _,S,A,T,P,c,g,p,m,D,I=this;return(I=i.call(this,t)||this).type=n.PRODUCT_LIST,I.listType=t.listType||u.ALL,I.sortType=t.sortType||C.ASC_CREATED_AT,I.maxProductsToShow=null!==(_=t.maxProductsToShow)&&void 0!==_?_:10,I.categoryId=null!==(S=t.categoryId)&&void 0!==S?S:null,I.variantPairs=null!==(A=t.variantPairs)&&void 0!==A?A:null,I.layout=null!==(T=t.layout)&&void 0!==T?T:s.TWO_COLUMN,I.productDetailSettings=t.productDetailSettings?new r(t.productDetailSettings):new r({image:new a({}),name:new l({horizontalPadding:0,verticalPadding:6}),discountRatio:null,finalPrice:new l({horizontalPadding:0,verticalPadding:2,fontSize:14,color:"#697586"}),button:new E({})}),I.buttonSettings=t.buttonSettings?new d(t.buttonSettings):new d({outerHorizontalPadding:0,buttonBgColor:"#000000",borderColor:"#000000"}),I.productBgColor=t.productBgColor||"",I.gapBetweenProductElements=null!==(P=t.gapBetweenProductElements)&&void 0!==P?P:12,I.gapBetweenProducts=null!==(c=t.gapBetweenProducts)&&void 0!==c?c:12,I.outerHorizontalPadding=null!==(g=t.outerHorizontalPadding)&&void 0!==g?g:0,I.outerVerticalPadding=null!==(p=t.outerVerticalPadding)&&void 0!==p?p:10,I.verticalPadding=null!==(m=t.verticalPadding)&&void 0!==m?m:0,I.horizontalPadding=null!==(D=t.horizontalPadding)&&void 0!==D?D:0,o(I,{type:e,listType:e,sortType:e,maxProductsToShow:e,categoryId:e,variantPairs:e,layout:e,productDetailSettings:e,buttonSettings:e,productBgColor:e,gapBetweenProductElements:e,gapBetweenProducts:e}),I}return t(_,i),_}(i);export{S as ProductListElement,s as ProductListLayoutEnum,C as ProductListSortTypeEnum,u as ProductListTypeEnum};
|
|
@@ -56,11 +56,11 @@ export declare class IkasCustomerStore {
|
|
|
56
56
|
}>;
|
|
57
57
|
activateCustomer: () => Promise<boolean>;
|
|
58
58
|
resendCustomerActivationMail: (email: string) => Promise<boolean>;
|
|
59
|
-
validateCustomerPhoneVerificationCode: (verificationCode: string) => Promise<{
|
|
59
|
+
validateCustomerPhoneVerificationCode: (verificationCode: string, otpInfo?: string | null) => Promise<{
|
|
60
60
|
isSuccess: boolean;
|
|
61
61
|
errorCodes: IkasRegisterError[];
|
|
62
62
|
}>;
|
|
63
|
-
validateOTPCode: (verificationCode: string) => Promise<{
|
|
63
|
+
validateOTPCode: (verificationCode: string, otpInfo?: string | null) => Promise<{
|
|
64
64
|
isSuccess: boolean;
|
|
65
65
|
errorCodes: IkasRegisterError[];
|
|
66
66
|
otpSend?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/xorBy";import o from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}from"../../models/data/customer/index.js";import"../../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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as c}from"@ikas/storefront-models";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"../../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-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"../../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"../../models/data/product/index.js";import{IkasRaffleParticipant as u}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-filter/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"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import d from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import l from"../product/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{IkasLoginError as p,IkasRegisterError as f,SaveMyCustomerInput as v}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as g}from"@ikas/storefront-providers";import w from"../checkout/index.js";import{formatCurrency as C}from"../../utils/currency.js";var b="undefined"==typeof localStorage,k=function(){function k(i){var a=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(i=t.data,this.setToken(i.token,i.tokenExpiry),i.customer&&this.setCustomer(i.customer),this.customer&&h.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken,phone:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer?[4,h.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(p).includes(t)?t:p.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),h.customerLogout()},this.register=function(s,i,o,c,u,d,l,m){return t(a,void 0,void 0,(function(){var t,a,p,v;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:o,password:c,firstName:s,lastName:i,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:m})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),h.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(v=t.data)||void 0===v?void 0:v.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===f.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&h.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:o,firstName:s,lastName:i,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return s=e.sent(),this.clearCaptchaToken(),[2,s.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(s){return t(a,void 0,void 0,(function(){var t,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:return s?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),h.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(o=t.data)||void 0===o?void 0:o.otpSend)||(null===(a=t.data)||void 0===a?void 0:a.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(c=t.data)||void 0===c?void 0:c.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===f.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&h.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.saveContactForm=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return h.contactForm(s),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},s),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(s=t.data)||void 0===s?void 0:s.exists)]}}))}))},this.forgotPassword=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,s,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.recoverPassword({password:r,passwordAgain:s,token:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new v(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?(s=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),s.refundSettings=this._refundSettings,[2,s]}}))}))},this.getOrderByEmail=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:s})];case 1:return(t=e.sent()).isSuccess&&t.data?(i=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,s,i,o,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.length)?[4,l.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:m.getPriceListId(),salesChannelId:m.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(o=null===(i=r.data)||void 0===i?void 0:i.data)||void 0===o||o.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),h.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),h.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,h.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.saveCustomerFormData({input:r(r({},s),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,h.createEmailSubscripition(s.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(s){return t(a,void 0,void 0,(function(){var t,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=m.getCustomerReviewSettings(),i=m.getSalesChannelId(),o=m.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},s),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:i||"",locale:o})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer({password:r})]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,g(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,s,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(s=e.customerAttribute)||void 0===s?void 0:s.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,w.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,s){return t(a,void 0,void 0,(function(){var t,i,o,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),(t=r.orderLineItems.find((function(t){return t.variant.id===s.variantId})))?[4,w.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:i=e.sent(),(o=i.data)&&((n=document.createElement("a")).href=o,n.download=decodeURIComponent(s.name.split("/")[s.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,w.getStoreCreditBalance()];case 1:return t=e.sent(),r=m.getCurrentRouting(),[2,{amount:s=(null===(i=t.data)||void 0===i?void 0:i.amount)||0,formattedAmount:C(s,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=o(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=i,s(this)}return Object.defineProperty(k.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||b||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=m.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===i(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),k.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",s="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(s,{headers:{"x-api-key":m.getApiKey()||"","x-sfid":m.getStorefrontId()||"","x-sfrid":m.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return i=e.sent(),window.location.href=i.redirectUrl,[2]}}))}))},k.prototype.socialLoginToken=function(r){var s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,h.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},k.prototype.refundOrder=function(r,s){return t(this,void 0,void 0,(function(){var t,i,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:s,orderId:r.id,orderLineItems:t}})];case 1:return(i=e.sent()).isSuccess&&i.data?(Object.entries(i.data).forEach((function(t){var e=t[0],r=t[1];o[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},k.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer?[4,h.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},k.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},k.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return b||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},k.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,n.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},k.prototype.setCustomer=function(t){this.customer=new a(t)},k.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=o(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},k.prototype.saveLastViewedProducts=function(){b||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},k.prototype.loadLastViewedProducts=function(){b||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=o(this._lastViewedProducts).reverse())},k.prototype.getLocalLastViewedProducts=function(){if(b)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},k.prototype.removeLastViewedProducts=function(){b||window.localStorage.removeItem("lastViewedProducts")},k.prototype.onProductView=function(r,s){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:s}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:s}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:s}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},k.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(b)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},k.prototype.saveCustomerConsent=function(){b||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},k.prototype.loadCustomerConsent=function(){b||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},k.prototype.removeCustomerConsent=function(){b||window.localStorage.removeItem("customerConsent")},k.prototype.setToken=function(t,e){b||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.init({customerToken:t}))},k.prototype.loadToken=function(){if(!b){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},k.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},k.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.init({customerToken:""}),this.clearCaptchaToken()},k.prototype.clearCaptchaToken=function(){this._captchaToken=null},k.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},k}();export{k as IkasCustomerStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/xorBy";import o from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}from"../../models/data/customer/index.js";import"../../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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as c}from"@ikas/storefront-models";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"../../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-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"../../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"../../models/data/product/index.js";import{IkasRaffleParticipant as u}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-filter/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"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import d from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import l from"../product/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{IkasLoginError as p,IkasRegisterError as f,SaveMyCustomerInput as v}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as g}from"@ikas/storefront-providers";import w from"../checkout/index.js";import{formatCurrency as C}from"../../utils/currency.js";var b="undefined"==typeof localStorage,k=function(){function k(i){var a=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(i=t.data,this.setToken(i.token,i.tokenExpiry),i.customer&&this.setCustomer(i.customer),this.customer&&h.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken,phone:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer?[4,h.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(p).includes(t)?t:p.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),h.customerLogout()},this.register=function(s,i,o,c,u,d,l,m){return t(a,void 0,void 0,(function(){var t,a,p,v;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:o,password:c,firstName:s,lastName:i,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:m})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),h.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(v=t.data)||void 0===v?void 0:v.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===f.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&h.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:o,firstName:s,lastName:i,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return s=e.sent(),this.clearCaptchaToken(),[2,s.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken,otpInfo:s})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return s?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:s,captchaToken:this._captchaToken,otpInfo:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),h.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===f.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&h.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.saveContactForm=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return h.contactForm(s),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},s),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(s=t.data)||void 0===s?void 0:s.exists)]}}))}))},this.forgotPassword=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,s,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.recoverPassword({password:r,passwordAgain:s,token:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new v(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?(s=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),s.refundSettings=this._refundSettings,[2,s]}}))}))},this.getOrderByEmail=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:s})];case 1:return(t=e.sent()).isSuccess&&t.data?(i=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,s,i,o,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.length)?[4,l.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:m.getPriceListId(),salesChannelId:m.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(o=null===(i=r.data)||void 0===i?void 0:i.data)||void 0===o||o.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),h.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),h.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,h.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.saveCustomerFormData({input:r(r({},s),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,h.createEmailSubscripition(s.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(s){return t(a,void 0,void 0,(function(){var t,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=m.getCustomerReviewSettings(),i=m.getSalesChannelId(),o=m.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},s),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:i||"",locale:o})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer({password:r})]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,g(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,s,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(s=e.customerAttribute)||void 0===s?void 0:s.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,w.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,s){return t(a,void 0,void 0,(function(){var t,i,o,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),(t=r.orderLineItems.find((function(t){return t.variant.id===s.variantId})))?[4,w.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:i=e.sent(),(o=i.data)&&((n=document.createElement("a")).href=o,n.download=decodeURIComponent(s.name.split("/")[s.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,w.getStoreCreditBalance()];case 1:return t=e.sent(),r=m.getCurrentRouting(),[2,{amount:s=(null===(i=t.data)||void 0===i?void 0:i.amount)||0,formattedAmount:C(s,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=o(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=i,s(this)}return Object.defineProperty(k.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||b||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=m.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===i(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),k.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",s="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(s,{headers:{"x-api-key":m.getApiKey()||"","x-sfid":m.getStorefrontId()||"","x-sfrid":m.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return i=e.sent(),window.location.href=i.redirectUrl,[2]}}))}))},k.prototype.socialLoginToken=function(r){var s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,h.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},k.prototype.refundOrder=function(r,s){return t(this,void 0,void 0,(function(){var t,i,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:s,orderId:r.id,orderLineItems:t}})];case 1:return(i=e.sent()).isSuccess&&i.data?(Object.entries(i.data).forEach((function(t){var e=t[0],r=t[1];o[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},k.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer?[4,h.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},k.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},k.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return b||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},k.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,n.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},k.prototype.setCustomer=function(t){this.customer=new a(t)},k.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=o(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},k.prototype.saveLastViewedProducts=function(){b||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},k.prototype.loadLastViewedProducts=function(){b||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=o(this._lastViewedProducts).reverse())},k.prototype.getLocalLastViewedProducts=function(){if(b)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},k.prototype.removeLastViewedProducts=function(){b||window.localStorage.removeItem("lastViewedProducts")},k.prototype.onProductView=function(r,s){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:s}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:s}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:s}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},k.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(b)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},k.prototype.saveCustomerConsent=function(){b||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},k.prototype.loadCustomerConsent=function(){b||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},k.prototype.removeCustomerConsent=function(){b||window.localStorage.removeItem("customerConsent")},k.prototype.setToken=function(t,e){b||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.init({customerToken:t}))},k.prototype.loadToken=function(){if(!b){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},k.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},k.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.init({customerToken:""}),this.clearCaptchaToken()},k.prototype.clearCaptchaToken=function(){this._captchaToken=null},k.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},k}();export{k as IkasCustomerStore};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.159",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@ikas/popup-renderer": "1.0.211",
|
|
21
|
+
"@ikas/popup-script-injector": "1.0.0-alpha.4",
|
|
21
22
|
"swiper": "11.0.6"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
25
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
26
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
27
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
28
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
25
|
+
"@ikas/storefront-api": "^6.1.0-beta.159",
|
|
26
|
+
"@ikas/storefront-config": "^6.1.0-beta.159",
|
|
27
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.159",
|
|
28
|
+
"@ikas/storefront-models": "^6.1.0-beta.159",
|
|
29
|
+
"@ikas/storefront-providers": "^6.1.0-beta.159",
|
|
29
30
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
30
31
|
"@adyen/adyen-web": "^5.57.0",
|
|
31
32
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -60,11 +61,11 @@
|
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
63
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
63
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
64
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
65
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
66
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
67
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
64
|
+
"@ikas/storefront-api": "^6.1.0-beta.159",
|
|
65
|
+
"@ikas/storefront-config": "^6.1.0-beta.159",
|
|
66
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.159",
|
|
67
|
+
"@ikas/storefront-models": "^6.1.0-beta.159",
|
|
68
|
+
"@ikas/storefront-providers": "^6.1.0-beta.159",
|
|
68
69
|
"mobx": "^6.1.3",
|
|
69
70
|
"mobx-react-lite": "^3.1.5",
|
|
70
71
|
"next": "12.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as r,__assign as o}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import"lodash/throttle";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/components/index.js';import{getPopupDynamicData as n}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/index.js';import"mobx";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-condition/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/teaser/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/index.js';import{PopupElementTypeEnum as t}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/base/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/button/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/divider/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/checkbox/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-attribute/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-gender/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js';import{ProductListTypeEnum as s,PopupProduct as i,MAX_PRODUCT_COUNT as p}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/detail-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/social/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/space/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/text/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/background-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/close-settings/index.js';import{SortByDirectionEnum as u}from"@ikas/storefront-api";import l from"../../../store/product/index.js";import{IkasBaseStore as a}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";function m(m,c,f,g){var v,b,_,x;return e(this,void 0,void 0,(function(){var e,g,j,k,h,I,P,E;return r(this,(function(T){switch(T.label){case 0:e={},g=[],j=[],m.modal.steps.forEach((function(e){e.elements.forEach((function(e){e.type===t.PRODUCT_LIST&&j.push(e)}))})),k=n(m),h=function(n){var t,j,h,I,P,E,T,y,C,L,S,D;return r(this,(function(r){switch(r.label){case 0:switch(t={input:{}},j=n.sortType.includes("ASC")?u.ASC:u.DESC,h=n.sortType.replace("ASC_","").replace("DESC_",""),I={direction:j,type:h},P=[],n.listType){case s.ALL:case s.LAST_VIEWED:return[3,1];case s.SPECIFIC:return[3,4];case s.CATEGORY:return[3,5]}return[3,6];case 1:return E=[],n.listType!==s.LAST_VIEWED?[3,3]:[4,a.getInstance().customerStore.getLastViewedProducts()];case 2:P=r.sent(),E=P.map((function(e){return e.productId})),r.label=3;case 3:return t.input={page:1,perPage:p,order:I?[I]:void 0,productIdList:E},[3,6];case 4:return(T=n.variantPairs||[]).length&&(y=T.map((function(e){return e.productId})),t.input={productIdList:y,page:1,perPage:p,order:I?[I]:void 0}),[3,6];case 5:return C=n.categoryId,t.input={categoryIdList:C?[C]:void 0,page:1,perPage:p,order:I?[I]:void 0},[3,6];case 6:return n.listType!==s.CATEGORY||(null===(v=t.input.categoryIdList)||void 0===v?void 0:v.length)?[4,l.searchProducts({input:o(o({},t.input),{priceListId:d.getPriceListId(),salesChannelId:d.getSalesChannelId()})})]:[2,"continue"];case 7:return(L=r.sent())&&L.isSuccess&&(null===(_=null===(b=L.data)||void 0===b?void 0:b.data)||void 0===_?void 0:_.length)&&(null==(S=null===(x=L.data)||void 0===x?void 0:x.data)?void 0:S.length)&&(D=[],S.forEach((function(e){var r,o,d;if(n.listType===s.SPECIFIC){var t=k.variantPairs.filter((function(e){return e.productListElementId===n.id}));(a=e.variants.find((function(r){return t.some((function(o){return o.productId===e.id&&o.variantId===r.id}))})))&&(d=[a])}else if(n.listType===s.LAST_VIEWED&&P.length){var p=P.find((function(r){return r.productId===e.id}));if(p)(a=e.variants.find((function(e){return e.id===p.variantId})))&&(d=[a])}else d=(null==e?void 0:e.variants[0])?[e.variants[0]]:[];for(var u=0,l=d||[];u<l.length;u++){var a;if((a=l[u])&&e){var v=(null===(r=a.images)||void 0===r?void 0:r.length)?a.images[0]:null;D.push(new i({productId:e.id,variantId:a.id,name:e.name,price:a.formattedSellPrice,discountPrice:a.hasDiscount?a.formattedDiscountPrice:null,discountRatio:a.discountPercentage?a.discountPercentage:null,imageURL:v?"".concat(c,"images/").concat(f,"/").concat(v.imageId):null,url:"".concat(m.storeUrl,"/").concat(null===(o=e.metaData)||void 0===o?void 0:o.slug)})),g.find((function(r){return r.id===e.id}))||g.push(e)}}})),e[n.id]=D),[2]}}))},I=0,P=j,T.label=1;case 1:return I<P.length?(E=P[I],[5,h(E)]):[3,4];case 2:T.sent(),T.label=3;case 3:return I++,[3,1];case 4:return[2,{totalProducts:e,ikasProducts:g}]}}))}))}export{m as getPopupProducts};
|