@ikas/storefront 2.0.19 → 2.0.21

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.
Files changed (62) hide show
  1. package/build/__generated__/global-types.d.ts +5 -0
  2. package/build/_virtual/index.js_commonjs-proxy2.js +1 -1
  3. package/build/_virtual/index.js_commonjs-proxy3.js +1 -1
  4. package/build/_virtual/index.js_commonjs-proxy4.js +1 -1
  5. package/build/api/blog/__generated__/getBlog.d.ts +5 -1
  6. package/build/api/blog/__generated__/listBlog.d.ts +5 -1
  7. package/build/api/blog/__generated__/listBlogCategory.d.ts +5 -1
  8. package/build/api/blog/__generated__/listBlogMetaData.d.ts +5 -1
  9. package/build/api/cart/__generated__/getCart.d.ts +4 -2
  10. package/build/api/cart/__generated__/saveItemToCart.d.ts +4 -2
  11. package/build/api/checkout/__generated__/getCheckoutById.d.ts +4 -2
  12. package/build/api/checkout/__generated__/getOrder.d.ts +11 -5
  13. package/build/api/customer/__generated__/createOrderRefundRequest.d.ts +11 -5
  14. package/build/api/customer/__generated__/customerLogin.d.ts +2 -1
  15. package/build/api/customer/__generated__/customerSocialLogin.d.ts +2 -1
  16. package/build/api/customer/__generated__/getCustomerOrders.d.ts +11 -5
  17. package/build/api/customer/__generated__/getMyCustomer.d.ts +2 -1
  18. package/build/api/customer/__generated__/registerCustomer.d.ts +2 -1
  19. package/build/api/customer/__generated__/saveMyCustomer.d.ts +2 -1
  20. package/build/api/customer-review/__generated__/listCustomerReviews.d.ts +5 -1
  21. package/build/api/html-meta-data/__generated__/listHTMLMetaData.d.ts +10 -0
  22. package/build/api/html-meta-data/index.js +1 -1
  23. package/build/api/index.d.ts +1 -1
  24. package/build/api/{product-campanign → product-campaign}/__generated__/getProductCampaigns.d.ts +1 -0
  25. package/build/api/{product-campanign → product-campaign}/index.d.ts +0 -0
  26. package/build/api/product-campaign/index.js +1 -0
  27. package/build/api/raffle/__generated__/listRaffle.d.ts +5 -1
  28. package/build/api/variant-type/__generated__/listVariantType.d.ts +6 -2
  29. package/build/components/checkout/components/address-form/model.js +1 -1
  30. package/build/components/checkout/model.js +1 -1
  31. package/build/components/page-editor/model.d.ts +3 -1
  32. package/build/components/page-editor/model.js +1 -1
  33. package/build/ikas.js +1 -1
  34. package/build/models/data/product/variant/index.js +1 -1
  35. package/build/models/data/product-campaing/campaign/index.d.ts +1 -1
  36. package/build/models/data/product-campaing/campaign/index.js +1 -1
  37. package/build/models/ui/blog-category-list/index.js +1 -1
  38. package/build/models/ui/blog-list/index.js +1 -1
  39. package/build/models/ui/brand-list/index.js +1 -1
  40. package/build/models/ui/category-list/index.js +1 -1
  41. package/build/models/ui/customer-review-list/index.js +1 -1
  42. package/build/models/ui/product-detail/index.js +1 -1
  43. package/build/models/ui/product-list/index.js +1 -1
  44. package/build/models/ui/raffle-list/index.js +1 -1
  45. package/build/models/ui/validator/form/address.js +1 -1
  46. package/build/pages/checkout.js +1 -1
  47. package/build/providers/helpers/raffles.js +1 -1
  48. package/build/providers/page-data-get.js +1 -1
  49. package/build/providers/page-data-next.js +1 -1
  50. package/build/providers/prop-value/attribute-list.js +1 -1
  51. package/build/providers/prop-value/attribute.js +1 -1
  52. package/build/providers/prop-value/blog-category.js +1 -1
  53. package/build/providers/prop-value/blog.js +1 -1
  54. package/build/providers/prop-value/brand.js +1 -1
  55. package/build/providers/prop-value/category.js +1 -1
  56. package/build/providers/prop-value/product-detail.js +1 -1
  57. package/build/providers/prop-value/raffle.js +1 -1
  58. package/build/store/base.js +1 -1
  59. package/build/store/cart.js +1 -1
  60. package/build/store/customer.js +1 -1
  61. package/package.json +1 -1
  62. package/build/api/product-campanign/index.js +0 -1
@@ -1 +1 @@
1
- import{__awaiter as i,__generator as t}from'../../ext/tslib/tslib.es6.js';import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"mobx";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import{IkasRaffleAPI as o}from"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campanign/index.js";import{getPlaceholderRaffle as e}from"../placeholders.js";import{populateRaffleProducts as r}from"../helpers/raffles.js";var d=function(){function d(i){this.rafflePropValue=i}return d.prototype.getValue=function(){var d;return i(this,void 0,void 0,(function(){var i,a;return t(this,(function(t){switch(t.label){case 0:return(null===(d=this.rafflePropValue)||void 0===d?void 0:d.usePageData)?[2,{raffle:null,rafflePropValue:this.rafflePropValue}]:this.rafflePropValue.raffleId?[4,o.listRaffles({id:this.rafflePropValue.raffleId})]:[2,null];case 1:return(i=t.sent()).raffles.length?(a=i.raffles[0],[4,r([a])]):[2,null];case 2:return t.sent(),[2,{raffle:a||e(),rafflePropValue:this.rafflePropValue}]}}))}))},d}();export{d as IkasRafflePropValueProvider};
1
+ import{__awaiter as i,__generator as t}from'../../ext/tslib/tslib.es6.js';import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"mobx";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import{IkasRaffleAPI as o}from"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import{getPlaceholderRaffle as e}from"../placeholders.js";import{populateRaffleProducts as r}from"../helpers/raffles.js";var d=function(){function d(i){this.rafflePropValue=i}return d.prototype.getValue=function(){var d;return i(this,void 0,void 0,(function(){var i,a;return t(this,(function(t){switch(t.label){case 0:return(null===(d=this.rafflePropValue)||void 0===d?void 0:d.usePageData)?[2,{raffle:null,rafflePropValue:this.rafflePropValue}]:this.rafflePropValue.raffleId?[4,o.listRaffles({id:this.rafflePropValue.raffleId})]:[2,null];case 1:return(i=t.sent()).raffles.length?(a=i.raffles[0],[4,r([a])]):[2,null];case 2:return t.sent(),[2,{raffle:a||e(),rafflePropValue:this.rafflePropValue}]}}))}))},d}();export{d as IkasRafflePropValueProvider};
@@ -1 +1 @@
1
- import{__awaiter as o,__generator as t}from'../ext/tslib/tslib.es6.js';import{configure as i,makeObservable as e,observable as r}from"mobx";import s from'../ext/lodash/sortBy.js';import d from'../ext/lodash/flatten.js';import{IkasCartStore as n}from"./cart.js";import{IkasCustomerStore as a}from"./customer.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{IkasThemeSettings as m}from"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import{IkasCountryAPI as p}from"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import"../api/product-search/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campanign/index.js";import{IkasStorefrontConfig as l}from"../storefront/index.js";import u from'../ext/uuid/dist/esm-browser/v4.js';i({enforceActions:"never"});var c=function(){function i(){this.currentPageType=null,this.localeOptions=[],this.showLocaleOptions=!1,this.currentCountryCode=null,this.localeChecked=!1,this.settingsSet=!1,this.customerStore=new a(this),this.cartStore=new n(this),e(this,{currentPageType:r,localeOptions:r,showLocaleOptions:r,currentCountryCode:r})}return i.prototype.checkLocalization=function(){return o(this,void 0,void 0,(function(){var o,i,e,r,n,a,m,c;return t(this,(function(t){switch(t.label){case 0:return this.localeChecked?[2]:void 0===typeof window?(console.warn("checkLocalization should be called on the client side!"),[2]):[4,p.getMyCountry()];case 1:return o=t.sent(),i=l.routings.find((function(o){return o.id===l.storefrontRoutingId})),this.currentCountryCode=o,i&&o?(e=!0,r=l.routings.find((function(t){var i;return null===(i=t.countryCodes)||void 0===i?void 0:i.includes(o)})),n=l.routings.find((function(o){var t;return!(null===(t=o.countryCodes)||void 0===t?void 0:t.length)})),r?i.id!==r.id&&(e=!1):n&&i.id!==n.id&&(e=!1),a=d(l.routings.map((function(o){return o.countryCodes||[]}))),[4,p.listCountries(a)]):[3,3];case 2:m=t.sent(),c=[],l.routings.map((function(t){var i;(null===(i=t.countryCodes)||void 0===i?void 0:i.length)?t.countryCodes.forEach((function(i){var e,r=m.find((function(o){return o.iso2===i}));c.push({id:u(),countryName:(null==r?void 0:r.native)||(null==r?void 0:r.name)||"",routing:t,isRecommended:(null===(e=t.countryCodes)||void 0===e?void 0:e.includes(o))||!1})})):c.push({id:u(),routing:t,isRecommended:!l.routings.some((function(t){var i;return null===(i=t.countryCodes)||void 0===i?void 0:i.includes(o)}))})})),this.localeOptions=s(c,"countryName"),e||(this.showLocaleOptions=!0),this.localeChecked=!0,t.label=3;case 3:return[2]}}))}))},i.prototype.setLocalization=function(o){o.routing.domain?window.location.replace("https://"+o.routing.domain):window.location.replace(window.location.origin+(o.routing.path?"/"+o.routing.path:""))},i.prototype.setSettings=function(o){this.settingsSet||new m(JSON.parse(o)).colors.map((function(o){return document.documentElement.style.setProperty(o.key,o.color)}))},i}();export{c as IkasBaseStore};
1
+ import{__awaiter as o,__generator as t}from'../ext/tslib/tslib.es6.js';import{configure as i,makeObservable as e,observable as r}from"mobx";import s from'../ext/lodash/sortBy.js';import d from'../ext/lodash/flatten.js';import{IkasCartStore as n}from"./cart.js";import{IkasCustomerStore as a}from"./customer.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{IkasThemeSettings as m}from"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import{IkasCountryAPI as p}from"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import"../api/product-search/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campaign/index.js";import{IkasStorefrontConfig as l}from"../storefront/index.js";import u from'../ext/uuid/dist/esm-browser/v4.js';i({enforceActions:"never"});var c=function(){function i(){this.currentPageType=null,this.localeOptions=[],this.showLocaleOptions=!1,this.currentCountryCode=null,this.localeChecked=!1,this.settingsSet=!1,this.customerStore=new a(this),this.cartStore=new n(this),e(this,{currentPageType:r,localeOptions:r,showLocaleOptions:r,currentCountryCode:r})}return i.prototype.checkLocalization=function(){return o(this,void 0,void 0,(function(){var o,i,e,r,n,a,m,c;return t(this,(function(t){switch(t.label){case 0:return this.localeChecked?[2]:void 0===typeof window?(console.warn("checkLocalization should be called on the client side!"),[2]):[4,p.getMyCountry()];case 1:return o=t.sent(),i=l.routings.find((function(o){return o.id===l.storefrontRoutingId})),this.currentCountryCode=o,i&&o?(e=!0,r=l.routings.find((function(t){var i;return null===(i=t.countryCodes)||void 0===i?void 0:i.includes(o)})),n=l.routings.find((function(o){var t;return!(null===(t=o.countryCodes)||void 0===t?void 0:t.length)})),r?i.id!==r.id&&(e=!1):n&&i.id!==n.id&&(e=!1),a=d(l.routings.map((function(o){return o.countryCodes||[]}))),[4,p.listCountries(a)]):[3,3];case 2:m=t.sent(),c=[],l.routings.map((function(t){var i;(null===(i=t.countryCodes)||void 0===i?void 0:i.length)?t.countryCodes.forEach((function(i){var e,r=m.find((function(o){return o.iso2===i}));c.push({id:u(),countryName:(null==r?void 0:r.native)||(null==r?void 0:r.name)||"",routing:t,isRecommended:(null===(e=t.countryCodes)||void 0===e?void 0:e.includes(o))||!1})})):c.push({id:u(),routing:t,isRecommended:!l.routings.some((function(t){var i;return null===(i=t.countryCodes)||void 0===i?void 0:i.includes(o)}))})})),this.localeOptions=s(c,"countryName"),e||(this.showLocaleOptions=!0),this.localeChecked=!0,t.label=3;case 3:return[2]}}))}))},i.prototype.setLocalization=function(o){o.routing.domain?window.location.replace("https://"+o.routing.domain):window.location.replace(window.location.origin+(o.routing.path?"/"+o.routing.path:""))},i.prototype.setSettings=function(o){this.settingsSet||new m(JSON.parse(o)).colors.map((function(o){return document.documentElement.style.setProperty(o.key,o.color)}))},i}();export{c as IkasBaseStore};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'../ext/tslib/tslib.es6.js';import"../api/blog/index.js";import"../api/brand/index.js";import{IkasCartAPI as i}from"../api/cart/index.js";import"../api/category/index.js";import{IkasCheckoutAPI as o}from"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import"../api/product-search/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import{makeAutoObservable as r}from"mobx";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campanign/index.js";import{Analytics as n}from"../analytics/analytics.js";import"../analytics/head/index.js";import{IkasStorefrontConfig as a}from"../storefront/index.js";import{IkasProductCartLineOption as s}from"../models/data/product-cart-item-options/index.js";var d="cartId",c="checkoutId",u=function(){function d(d){var c=this;this.cart=null,this._checkoutId=null,this._isLoadingCart=!1,this._cartLoadFinished=!1,this.addItem=function(o,r,s){return void 0===s&&(s=1),t(c,void 0,void 0,(function(){var t,d,c,u,l,m,p,h,v,f,j,I,g;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),r.canAddToCart?[4,this.beforeCartOperationCheck()]:[2,!1];case 1:return e.sent(),this.cart&&(t=this.findExistingItem(o,r))?(null===(v=r.productOptionSet)||void 0===v||v.initOptionValues(),[2,this.changeItemQuantity(t,t.quantity+1)]):(d=this.getOptionValues(r),c=(null===(f=this.cart)||void 0===f?void 0:f.id)||localStorage.getItem("cartId"),u={cartId:c,customerId:(null===(j=this.cart)||void 0===j?void 0:j.customerId)||(null===(I=this.baseStore.customerStore.customer)||void 0===I?void 0:I.id)||null,item:{id:null,quantity:s,variant:{id:o.id,name:r.name}},options:d.length?d:null,priceListId:a.priceListId||null,salesChannelId:a.salesChannelId,storefrontId:a.storefrontId,storefrontRoutingId:a.storefrontRoutingId,storefrontThemeId:a.storefrontThemeId},[4,i.saveItemToCart(u)]);case 2:return(l=e.sent())?[4,this.setCart(l)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(m="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=this.cart.items.find((function(t){return t.variant.id})))&&n.addToCart(p,s,m,this.cart)),null===(g=r.productOptionSet)||void 0===g||g.initOptionValues(),[2,!0];case 5:return h=e.sent(),console.log(h),[2,!1];case 6:return[2]}}))}))},this.changeItemQuantity=function(o,r){return t(c,void 0,void 0,(function(){var t,s,d,c,u,l,m,p;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),t={cartId:(null===(l=this.cart)||void 0===l?void 0:l.id)||null,customerId:(null===(m=this.cart)||void 0===m?void 0:m.customerId)||(null===(p=this.baseStore.customerStore.customer)||void 0===p?void 0:p.id)||null,item:{id:o.id,quantity:r,variant:{id:o.variant.id,name:o.variant.name}},options:this.createCartLineOptions(o),priceListId:a.priceListId||null,salesChannelId:a.salesChannelId,storefrontId:a.storefrontId,storefrontRoutingId:a.storefrontRoutingId,storefrontThemeId:a.storefrontThemeId},[4,i.saveItemToCart(t)];case 2:return(s=e.sent())?[4,this.setCart(s)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.removeCardIfEmpty(),this.cart&&(d="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(c=o.quantity)>r?n.removeFromCart(o,c-r,this.cart):n.addToCart(o,r-c,d,this.cart)),[2,!0];case 5:return u=e.sent(),console.log(u),[2,!1];case 6:return[2]}}))}))},this.removeItem=function(i){return t(c,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return t.sent(),[2]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),localStorage.removeItem("checkoutId"),c.cart=void 0,c._checkoutId=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){c.cartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.findExistingItem=function(t,e){var i,o,r,n,a;if(!e.productOptionSetId)return null===(i=c.cart)||void 0===i?void 0:i.items.find((function(e){return e.variant.id===t.id}));for(var s=c.getOptionValues(e),d=(null===(o=c.cart)||void 0===o?void 0:o.items.filter((function(e){var i;return e.variant.id===t.id&&(null===(i=e.options)||void 0===i?void 0:i.length)===s.length})))||[],u=0,l=d;u<l.length;u++){var m=l[u];if(m.options){for(var p=!0,h=function(t){var i=t.values.map((function(t){return t.value})),o=null===(a=null===(n=null===(r=e.productOptionSet)||void 0===r?void 0:r.options)||void 0===n?void 0:n.find((function(e){return e.id===t.productOptionId})))||void 0===a?void 0:a.values;if(!(p=p&&i.length===(null==o?void 0:o.length)&&i.every((function(t){return null==o?void 0:o.includes(t)}))))return"break"},v=0,f=m.options;v<f.length;v++){if("break"===h(f[v]))break}if(p)return m}}},this.removeCardIfEmpty=function(){var t;0===(null===(t=c.cart)||void 0===t?void 0:t.itemCount)&&c.removeCart()},this.getCart=function(){return t(c,void 0,void 0,(function(){var t,o,r,n,a,s;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(a=this.baseStore.customerStore.customer)||void 0===a?void 0:a.id,(o=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,i.getCart(o||void 0)]:[2];case 2:return(r=e.sent())?[4,this.setCart(r)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return n=e.sent(),console.log(n),[3,8];case 7:return this._isLoadingCart=!1,this._cartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(c,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return localStorage.setItem("cartId",i.id),this.cart=i,this._checkoutId||(this._checkoutId=localStorage.getItem("checkoutId")||void 0),this._checkoutId?[3,2]:[4,o.getCheckoutId(i.id)];case 1:t=e.sent(),this._checkoutId=t,t&&localStorage.setItem("checkoutId",t),e.label=2;case 2:return[2]}}))}))},this.beforeCartOperationCheck=function(){return t(c,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,o=t.options;i<o.length;i++){var r=o[i],n=new s({});n.productOptionId=r.productOptionId,n.productOptionsSetId=r.productOptionsSetId,n.values=r.values.map((function(t){return t.value})),e.push(n)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push(new s({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values}))})),i},this.baseStore=d,r(this)}return Object.defineProperty(d.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"cartLoadFinished",{get:function(){return this._cartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"checkoutId",{get:function(){return this._checkoutId},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"checkoutUrl",{get:function(){if(this._checkoutId)return"/checkout?id=".concat(this._checkoutId,"&step=info")},enumerable:!1,configurable:!0}),d}();export{d as CART_LS_KEY,c as CHECKOUT_LS_KEY,u as IkasCartStore};
1
+ import{__awaiter as t,__generator as e}from'../ext/tslib/tslib.es6.js';import"../api/blog/index.js";import"../api/brand/index.js";import{IkasCartAPI as i}from"../api/cart/index.js";import"../api/category/index.js";import{IkasCheckoutAPI as o}from"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import"../api/product-search/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import{makeAutoObservable as r}from"mobx";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campaign/index.js";import{Analytics as n}from"../analytics/analytics.js";import"../analytics/head/index.js";import{IkasStorefrontConfig as a}from"../storefront/index.js";import{IkasProductCartLineOption as s}from"../models/data/product-cart-item-options/index.js";var d="cartId",c="checkoutId",u=function(){function d(d){var c=this;this.cart=null,this._checkoutId=null,this._isLoadingCart=!1,this._cartLoadFinished=!1,this.addItem=function(o,r,s){return void 0===s&&(s=1),t(c,void 0,void 0,(function(){var t,d,c,u,l,m,p,h,v,f,j,I,g;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),r.canAddToCart?[4,this.beforeCartOperationCheck()]:[2,!1];case 1:return e.sent(),this.cart&&(t=this.findExistingItem(o,r))?(null===(v=r.productOptionSet)||void 0===v||v.initOptionValues(),[2,this.changeItemQuantity(t,t.quantity+1)]):(d=this.getOptionValues(r),c=(null===(f=this.cart)||void 0===f?void 0:f.id)||localStorage.getItem("cartId"),u={cartId:c,customerId:(null===(j=this.cart)||void 0===j?void 0:j.customerId)||(null===(I=this.baseStore.customerStore.customer)||void 0===I?void 0:I.id)||null,item:{id:null,quantity:s,variant:{id:o.id,name:r.name}},options:d.length?d:null,priceListId:a.priceListId||null,salesChannelId:a.salesChannelId,storefrontId:a.storefrontId,storefrontRoutingId:a.storefrontRoutingId,storefrontThemeId:a.storefrontThemeId},[4,i.saveItemToCart(u)]);case 2:return(l=e.sent())?[4,this.setCart(l)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(m="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=this.cart.items.find((function(t){return t.variant.id})))&&n.addToCart(p,s,m,this.cart)),null===(g=r.productOptionSet)||void 0===g||g.initOptionValues(),[2,!0];case 5:return h=e.sent(),console.log(h),[2,!1];case 6:return[2]}}))}))},this.changeItemQuantity=function(o,r){return t(c,void 0,void 0,(function(){var t,s,d,c,u,l,m,p;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),t={cartId:(null===(l=this.cart)||void 0===l?void 0:l.id)||null,customerId:(null===(m=this.cart)||void 0===m?void 0:m.customerId)||(null===(p=this.baseStore.customerStore.customer)||void 0===p?void 0:p.id)||null,item:{id:o.id,quantity:r,variant:{id:o.variant.id,name:o.variant.name}},options:this.createCartLineOptions(o),priceListId:a.priceListId||null,salesChannelId:a.salesChannelId,storefrontId:a.storefrontId,storefrontRoutingId:a.storefrontRoutingId,storefrontThemeId:a.storefrontThemeId},[4,i.saveItemToCart(t)];case 2:return(s=e.sent())?[4,this.setCart(s)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.removeCardIfEmpty(),this.cart&&(d="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(c=o.quantity)>r?n.removeFromCart(o,c-r,this.cart):n.addToCart(o,r-c,d,this.cart)),[2,!0];case 5:return u=e.sent(),console.log(u),[2,!1];case 6:return[2]}}))}))},this.removeItem=function(i){return t(c,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return t.sent(),[2]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),localStorage.removeItem("checkoutId"),c.cart=void 0,c._checkoutId=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){c.cartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.findExistingItem=function(t,e){var i,o,r,n,a;if(!e.productOptionSetId)return null===(i=c.cart)||void 0===i?void 0:i.items.find((function(e){return e.variant.id===t.id}));for(var s=c.getOptionValues(e),d=(null===(o=c.cart)||void 0===o?void 0:o.items.filter((function(e){var i;return e.variant.id===t.id&&(null===(i=e.options)||void 0===i?void 0:i.length)===s.length})))||[],u=0,l=d;u<l.length;u++){var m=l[u];if(m.options){for(var p=!0,h=function(t){var i=t.values.map((function(t){return t.value})),o=null===(a=null===(n=null===(r=e.productOptionSet)||void 0===r?void 0:r.options)||void 0===n?void 0:n.find((function(e){return e.id===t.productOptionId})))||void 0===a?void 0:a.values;if(!(p=p&&i.length===(null==o?void 0:o.length)&&i.every((function(t){return null==o?void 0:o.includes(t)}))))return"break"},v=0,f=m.options;v<f.length;v++){if("break"===h(f[v]))break}if(p)return m}}},this.removeCardIfEmpty=function(){var t;0===(null===(t=c.cart)||void 0===t?void 0:t.itemCount)&&c.removeCart()},this.getCart=function(){return t(c,void 0,void 0,(function(){var t,o,r,n,a,s;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(a=this.baseStore.customerStore.customer)||void 0===a?void 0:a.id,(o=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,i.getCart(o||void 0)]:[2];case 2:return(r=e.sent())?[4,this.setCart(r)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return n=e.sent(),console.log(n),[3,8];case 7:return this._isLoadingCart=!1,this._cartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(c,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return localStorage.setItem("cartId",i.id),this.cart=i,this._checkoutId||(this._checkoutId=localStorage.getItem("checkoutId")||void 0),this._checkoutId?[3,2]:[4,o.getCheckoutId(i.id)];case 1:t=e.sent(),this._checkoutId=t,t&&localStorage.setItem("checkoutId",t),e.label=2;case 2:return[2]}}))}))},this.beforeCartOperationCheck=function(){return t(c,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,o=t.options;i<o.length;i++){var r=o[i],n=new s({});n.productOptionId=r.productOptionId,n.productOptionsSetId=r.productOptionsSetId,n.values=r.values.map((function(t){return t.value})),e.push(n)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push(new s({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values}))})),i},this.baseStore=d,r(this)}return Object.defineProperty(d.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"cartLoadFinished",{get:function(){return this._cartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"checkoutId",{get:function(){return this._checkoutId},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"checkoutUrl",{get:function(){if(this._checkoutId)return"/checkout?id=".concat(this._checkoutId,"&step=info")},enumerable:!1,configurable:!0}),d}();export{d as CART_LS_KEY,c as CHECKOUT_LS_KEY,u as IkasCartStore};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as r}from'../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import{apollo as o}from"../api/apollo.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import{IkasCustomer as s,IkasCustomerEmailSubscriptionStatus as n}from"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import{IkasCustomerAPI as a}from"../api/customer/index.js";import{IkasCustomerReviewAPI as u}from"../api/customer-review/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import{IkasProductSearchAPI as d}from"../api/product-search/index.js";import{IkasFavoriteProductAPI as c}from"../api/favorite-product/index.js";import{IkasContactFormAPI as l}from"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import{IkasRaffleAPI as m}from"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campanign/index.js";import{Analytics as h}from"../analytics/analytics.js";import"../analytics/head/index.js";import{IkasStorefrontConfig as p}from"../storefront/index.js";import{populateRaffleProducts as f}from"../providers/helpers/raffles.js";import v from'../ext/lodash/uniqBy.js';var w="undefined"==typeof localStorage,g=function(){function g(o){var s=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.login=function(r,i){return t(s,void 0,void 0,(function(){var t,o,s;return e(this,(function(e){switch(e.label){case 0:return[4,a.login(r,i)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&h.customerLogin(),(o=null===(s=this.baseStore)||void 0===s?void 0:s.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(o.items[0],o.items[0].quantity)]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:return this.saveLocalLastViewedProducts(),[2,!0];case 4:return[2,!1]}}))}))},this.register=function(r,i,o,n,u){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.register(o,n,r,i,u)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return h.contactForm(r),[4,l.sendContactFormToMerchant(r)];case 1:return[2,t.sent()]}}))}))},this.checkEmail=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.checkEmail(r)];case 1:return[2,t.sent()]}}))}))},this.forgotPassword=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.forgotPassword(r)];case 1:return[2,t.sent()]}}))}))},this.recoverPassword=function(r,i,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.recoverPassword(r,i,o)];case 1:return[2,t.sent()]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),h.customerLogout()},this.saveCustomer=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.saveCustomer(r)];case 1:return(t=e.sent())?(this.setCustomer(t),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrders()];case 1:return[2,t.sent()]}}))}))},this.getOrder=function(r){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,a.getOrders(r)];case 1:return t=e.sent(),Array.isArray(t)&&t.length?((i=t[0])._refundSettings=this._refundSettings,[2,i]):[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrderTransactions(r)];case 1:return[2,t.sent()]}}))}))},this.getFavoriteProductsIds=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,c.listFavoriteProducts()];case 1:return[2,t.sent()];case 2:return t.sent(),[2,[]];case 3:return[2]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,c.listFavoriteProducts()];case 1:return(t=e.sent()).length?[4,d.searchProducts({productIdList:t.map((function(t){return t.productId})),priceListId:p.priceListId,salesChannelId:p.salesChannelId})]:[2,[]];case 2:return[2,(null==(r=e.sent())?void 0:r.data)||[]];case 3:return e.sent(),[2,[]];case 4:return[2]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:(t=this,[4,a.getOrderRefundSettings()]);case 1:t._refundSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.addItemToFavorite=function(r){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.saveFavoriteProduct(!0,r)];case 2:return t=e.sent(),h.addToWishlist(r),[2,t];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.removeItemFromFavorite=function(r){return t(s,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");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.saveFavoriteProduct(!1,r)];case 2:return[2,e.sent()];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.isProductFavorite=function(r){return t(s,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,c.isFavoriteProduct(r)];case 1:return[2,e.sent()]}}))}))},this.createEmailSubscription=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.createCustomerEmailSubscription(r)];case 1:return(t=e.sent())&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,n.SUBSCRIBED):this._visitorSubscribedEmail=!0),[2,t]}}))}))},this.sendReview=function(i){return t(s,void 0,void 0,(function(){var t,o,s,n,a;return e(this,(function(e){switch(e.label){case 0:if(e.trys.push([0,2,,3]),t=p.customerReviewSettings,o=p.salesChannelId,!t)return[2];if(!(s=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview(r(r({},i),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""}))];case 1:return[2,e.sent()];case 2:return n=e.sent(),console.log(n),[3,3];case 3:return[2]}}))}))},this.onCustomerConsentGrant=function(){s.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){s.initialized&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,m.getRafflesByCustomerId()];case 1:return t=e.sent(),[4,m.getRafflesByCustomerId(!0)];case 2:return r=e.sent(),null==t||t.forEach((function(t){(null==r?void 0:r.find((function(e){return e.id===t.id})))&&(t.isCustomerWinner=!0)})),t?[4,f(t)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2,t]}}))}))},this.baseStore=o,this.init(),i(this)}return Object.defineProperty(g.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||w||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),g.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":p.config.apiKey||"","x-sfid":p.storefrontId||"","x-sfrid":p.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),p.router?p.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},g.prototype.socialLoginToken=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.socialLogin(r)];case 1:return(null==(t=e.sent())?void 0:t.customer)?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&h.customerLogin(),[2,!0]):[2,!1]}}))}))},g.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(),[4,this.getOrderRefundSettings()];case 3:return t.sent(),this._initialized=!0,this.customer&&h.customerVisit(),[2]}}))}))},g.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},g.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return w||!this.token?[2]:[4,a.getCustomer()];case 1:return(t=e.sent())&&this.setCustomer(t),[2]}}))}))},g.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,a.refreshToken(this.token)]:[2];case 1:return(null==(t=e.sent())?void 0:t.token)||(null==t?void 0:t.tokenExpiry)?this.setToken(t.token,t.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},g.prototype.setCustomer=function(t){this.customer=new s(t)},g.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?(t=this,[4,a.getLastViewedProducts(this.customer.id)]):[3,2];case 1:return t._lastViewedProducts=e.sent(),[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},g.prototype.saveLastViewedProducts=function(){w||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},g.prototype.loadLastViewedProducts=function(){if(!w)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=v(this._lastViewedProducts,"variantId"))}catch(t){}},g.prototype.removeLastViewedProducts=function(){w||window.localStorage.removeItem("lastViewedProducts")},g.prototype.onProductView=function(r,i){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,a.saveLastViewedProducts({customerId:this.customer.id,products:[{productId:r,variantId:i}]})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=v(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},g.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(w)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,a.saveLastViewedProducts({customerId:this.customer.id,products:this._lastViewedProducts})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},g.prototype.saveCustomerConsent=function(){w||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},g.prototype.loadCustomerConsent=function(){w||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},g.prototype.removeCustomerConsent=function(){w||window.localStorage.removeItem("customerConsent")},g.prototype.setToken=function(t,e){w||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),o.setCustomerToken(t))},g.prototype.loadToken=function(){if(!w){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},g.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},g.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,o.setCustomerToken()},g}();export{g as IkasCustomerStore};
1
+ import{__awaiter as t,__generator as e,__assign as r}from'../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import{apollo as o}from"../api/apollo.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import{IkasCustomer as s,IkasCustomerEmailSubscriptionStatus as n}from"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import{IkasCustomerAPI as a}from"../api/customer/index.js";import{IkasCustomerReviewAPI as u}from"../api/customer-review/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import{IkasProductSearchAPI as d}from"../api/product-search/index.js";import{IkasFavoriteProductAPI as c}from"../api/favorite-product/index.js";import{IkasContactFormAPI as l}from"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import{IkasRaffleAPI as m}from"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campaign/index.js";import{Analytics as h}from"../analytics/analytics.js";import"../analytics/head/index.js";import{IkasStorefrontConfig as p}from"../storefront/index.js";import{populateRaffleProducts as f}from"../providers/helpers/raffles.js";import v from'../ext/lodash/uniqBy.js';var w="undefined"==typeof localStorage,g=function(){function g(o){var s=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.login=function(r,i){return t(s,void 0,void 0,(function(){var t,o,s;return e(this,(function(e){switch(e.label){case 0:return[4,a.login(r,i)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&h.customerLogin(),(o=null===(s=this.baseStore)||void 0===s?void 0:s.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(o.items[0],o.items[0].quantity)]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:return this.saveLocalLastViewedProducts(),[2,!0];case 4:return[2,!1]}}))}))},this.register=function(r,i,o,n,u){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.register(o,n,r,i,u)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return h.contactForm(r),[4,l.sendContactFormToMerchant(r)];case 1:return[2,t.sent()]}}))}))},this.checkEmail=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.checkEmail(r)];case 1:return[2,t.sent()]}}))}))},this.forgotPassword=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.forgotPassword(r)];case 1:return[2,t.sent()]}}))}))},this.recoverPassword=function(r,i,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.recoverPassword(r,i,o)];case 1:return[2,t.sent()]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),h.customerLogout()},this.saveCustomer=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.saveCustomer(r)];case 1:return(t=e.sent())?(this.setCustomer(t),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrders()];case 1:return[2,t.sent()]}}))}))},this.getOrder=function(r){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,a.getOrders(r)];case 1:return t=e.sent(),Array.isArray(t)&&t.length?((i=t[0])._refundSettings=this._refundSettings,[2,i]):[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrderTransactions(r)];case 1:return[2,t.sent()]}}))}))},this.getFavoriteProductsIds=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,c.listFavoriteProducts()];case 1:return[2,t.sent()];case 2:return t.sent(),[2,[]];case 3:return[2]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,c.listFavoriteProducts()];case 1:return(t=e.sent()).length?[4,d.searchProducts({productIdList:t.map((function(t){return t.productId})),priceListId:p.priceListId,salesChannelId:p.salesChannelId})]:[2,[]];case 2:return[2,(null==(r=e.sent())?void 0:r.data)||[]];case 3:return e.sent(),[2,[]];case 4:return[2]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:(t=this,[4,a.getOrderRefundSettings()]);case 1:t._refundSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.addItemToFavorite=function(r){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.saveFavoriteProduct(!0,r)];case 2:return t=e.sent(),h.addToWishlist(r),[2,t];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.removeItemFromFavorite=function(r){return t(s,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");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.saveFavoriteProduct(!1,r)];case 2:return[2,e.sent()];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.isProductFavorite=function(r){return t(s,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,c.isFavoriteProduct(r)];case 1:return[2,e.sent()]}}))}))},this.createEmailSubscription=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.createCustomerEmailSubscription(r)];case 1:return(t=e.sent())&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,n.SUBSCRIBED):this._visitorSubscribedEmail=!0),[2,t]}}))}))},this.sendReview=function(i){return t(s,void 0,void 0,(function(){var t,o,s,n,a;return e(this,(function(e){switch(e.label){case 0:if(e.trys.push([0,2,,3]),t=p.customerReviewSettings,o=p.salesChannelId,!t)return[2];if(!(s=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview(r(r({},i),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""}))];case 1:return[2,e.sent()];case 2:return n=e.sent(),console.log(n),[3,3];case 3:return[2]}}))}))},this.onCustomerConsentGrant=function(){s.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){s.initialized&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,m.getRafflesByCustomerId()];case 1:return t=e.sent(),[4,m.getRafflesByCustomerId(!0)];case 2:return r=e.sent(),null==t||t.forEach((function(t){(null==r?void 0:r.find((function(e){return e.id===t.id})))&&(t.isCustomerWinner=!0)})),t?[4,f(t)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2,t]}}))}))},this.baseStore=o,this.init(),i(this)}return Object.defineProperty(g.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||w||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),g.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":p.config.apiKey||"","x-sfid":p.storefrontId||"","x-sfrid":p.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),p.router?p.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},g.prototype.socialLoginToken=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.socialLogin(r)];case 1:return(null==(t=e.sent())?void 0:t.customer)?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&h.customerLogin(),[2,!0]):[2,!1]}}))}))},g.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(),[4,this.getOrderRefundSettings()];case 3:return t.sent(),this._initialized=!0,this.customer&&h.customerVisit(),[2]}}))}))},g.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},g.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return w||!this.token?[2]:[4,a.getCustomer()];case 1:return(t=e.sent())&&this.setCustomer(t),[2]}}))}))},g.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,a.refreshToken(this.token)]:[2];case 1:return(null==(t=e.sent())?void 0:t.token)||(null==t?void 0:t.tokenExpiry)?this.setToken(t.token,t.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},g.prototype.setCustomer=function(t){this.customer=new s(t)},g.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?(t=this,[4,a.getLastViewedProducts(this.customer.id)]):[3,2];case 1:return t._lastViewedProducts=e.sent(),[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},g.prototype.saveLastViewedProducts=function(){w||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},g.prototype.loadLastViewedProducts=function(){if(!w)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=v(this._lastViewedProducts,"variantId"))}catch(t){}},g.prototype.removeLastViewedProducts=function(){w||window.localStorage.removeItem("lastViewedProducts")},g.prototype.onProductView=function(r,i){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,a.saveLastViewedProducts({customerId:this.customer.id,products:[{productId:r,variantId:i}]})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=v(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},g.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(w)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,a.saveLastViewedProducts({customerId:this.customer.id,products:this._lastViewedProducts})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},g.prototype.saveCustomerConsent=function(){w||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},g.prototype.loadCustomerConsent=function(){w||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},g.prototype.removeCustomerConsent=function(){w||window.localStorage.removeItem("customerConsent")},g.prototype.setToken=function(t,e){w||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),o.setCustomerToken(t))},g.prototype.loadToken=function(){if(!w){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},g.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},g.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,o.setCustomerToken()},g}();export{g as IkasCustomerStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.js",
6
6
  "author": "Umut Ozan Yıldırım",
@@ -1 +0,0 @@
1
- import{__awaiter as n,__generator as t,__makeTemplateObject as e}from'../../ext/tslib/tslib.es6.js';import{IkasProductCampaign as a}from"../../models/data/product-campaing/index.js";import i from'../../ext/graphql-tag/src/index.js';import{apollo as r}from"../apollo.js";var u,s=function(){function s(){}return s.getProductCampaigns=function(s){return n(this,void 0,void 0,(function(){var n,o,d,p,c;return t(this,(function(t){switch(t.label){case 0:n=i(u||(u=e(["\n query getProductCampaigns($input: GetProductCampaignsInput!) {\n getProductCampaigns(input: $input) {\n campaign {\n applicableCustomerGroupIds\n applicableCustomerIds\n applicablePrice\n buyXThenGetY {\n buyX {\n amount\n applyByQuantity\n filter {\n idList\n type\n }\n }\n getY {\n amount\n discountRatio\n filter {\n idList\n type\n }\n }\n maxUsagePerOrder\n }\n canCombineWithOtherCampaigns\n createdAt\n createdFor\n currencyCode\n dateRange {\n end\n start\n }\n deleted\n fixedDiscount {\n amount\n filters {\n idList\n type\n }\n lineItemQuantityRange {\n min\n max\n }\n priceRange {\n min\n max\n }\n }\n hasCoupon\n id\n includeDiscountedProducts\n salesChannelIds\n title\n type\n updatedAt\n usageCount\n usageLimit\n usageLimitPerCustomer\n }\n variantIds\n }\n }\n "],["\n query getProductCampaigns($input: GetProductCampaignsInput!) {\n getProductCampaigns(input: $input) {\n campaign {\n applicableCustomerGroupIds\n applicableCustomerIds\n applicablePrice\n buyXThenGetY {\n buyX {\n amount\n applyByQuantity\n filter {\n idList\n type\n }\n }\n getY {\n amount\n discountRatio\n filter {\n idList\n type\n }\n }\n maxUsagePerOrder\n }\n canCombineWithOtherCampaigns\n createdAt\n createdFor\n currencyCode\n dateRange {\n end\n start\n }\n deleted\n fixedDiscount {\n amount\n filters {\n idList\n type\n }\n lineItemQuantityRange {\n min\n max\n }\n priceRange {\n min\n max\n }\n }\n hasCoupon\n id\n includeDiscountedProducts\n salesChannelIds\n title\n type\n updatedAt\n usageCount\n usageLimit\n usageLimitPerCustomer\n }\n variantIds\n }\n }\n "]))),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.getClient().query({query:n,variables:{input:s}})];case 2:return o=t.sent(),d=o.data,(p=o.errors)&&p.length?[2,[]]:[2,d.getProductCampaigns?d.getProductCampaigns.map((function(n){return new a(n)})):null];case 3:return c=t.sent(),console.log(c),[3,4];case 4:return[2,[]]}}))}))},s}();export{s as IkasProductCampaignAPI};