@ikas/storefront 5.0.11 → 5.0.13

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 (156) hide show
  1. package/build/analytics/analytics.js +1 -1
  2. package/build/analytics/googleAnalytics.js +1 -1
  3. package/build/analytics/googleTagManager.js +1 -1
  4. package/build/analytics/ikas.js +1 -1
  5. package/build/components/checkout/components/address-form/model.js +1 -1
  6. package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
  7. package/build/components/checkout/components/cart-summary/index.js +1 -1
  8. package/build/components/checkout/components/customer-addresses/model.js +1 -1
  9. package/build/components/checkout/components/error/argument-validation-error/index.d.ts +8 -0
  10. package/build/components/checkout/components/error/argument-validation-error/index.js +1 -0
  11. package/build/components/checkout/components/error/index.js +1 -1
  12. package/build/components/checkout/components/master-pass/credit-card-form/index.js +1 -1
  13. package/build/components/checkout/components/master-pass/modal-otp/index.js +1 -1
  14. package/build/components/checkout/components/offer-product/index.js +1 -1
  15. package/build/components/checkout/components/quick-registration/model.js +1 -1
  16. package/build/components/checkout/index.js +1 -1
  17. package/build/components/checkout/model.d.ts +2 -2
  18. package/build/components/checkout/model.js +1 -1
  19. package/build/components/checkout/modelMasterPass.js +1 -1
  20. package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
  21. package/build/components/checkout/steps/step-success/index.js +1 -1
  22. package/build/components/page/head.js +1 -1
  23. package/build/components/page/index.js +1 -1
  24. package/build/components/page-editor/ThemeComponentEditor.js +1 -1
  25. package/build/components/page-editor/model.js +1 -1
  26. package/build/components/popup/index.d.ts +2 -0
  27. package/build/components/popup/index.js +1 -0
  28. package/build/components/popup/renderer/index.d.ts +11 -0
  29. package/build/components/popup/renderer/index.js +1 -0
  30. package/build/components/popup/renderer/model.d.ts +21 -0
  31. package/build/components/popup/renderer/model.js +1 -0
  32. package/build/components/popup/utils/index.d.ts +8 -0
  33. package/build/components/popup/utils/index.js +1 -0
  34. package/build/ext/@ikas/popup-renderer/build/ext/tslib/tslib.es6.mjs.js +1 -0
  35. package/build/ext/@ikas/popup-renderer/build/popup-renderer/assets/left-arrow.js +1 -0
  36. package/build/ext/@ikas/popup-renderer/build/popup-renderer/assets/right-arrow.js +1 -0
  37. package/build/ext/@ikas/popup-renderer/build/popup-renderer/assets/x-close.js +1 -0
  38. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/button-element-renderer/index.js +1 -0
  39. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/divider-element-renderer/index.js +1 -0
  40. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/checkbox-item-view/index.js +1 -0
  41. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/date-item-view/index.js +1 -0
  42. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/gender-item-view/index.js +1 -0
  43. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/index.js +1 -0
  44. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/input-item-view/index.js +1 -0
  45. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-column-element-renderer/index.js +1 -0
  46. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-element-renderer/index.js +1 -0
  47. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/index.js +1 -0
  48. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/product-list-renderer/index.js +1 -0
  49. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/social-element-renderer/index.js +1 -0
  50. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/space-element-renderer/index.js +1 -0
  51. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/text-element-renderer/index.js +1 -0
  52. package/build/ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js +1 -0
  53. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/index.js +1 -0
  54. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/background-settings/index.js +1 -0
  55. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/close-settings/index.js +1 -0
  56. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/index.js +1 -0
  57. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/base/index.js +1 -0
  58. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/button/index.js +1 -0
  59. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/divider/index.js +1 -0
  60. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/checkbox/index.js +1 -0
  61. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-attribute/index.js +1 -0
  62. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-birthday/index.js +1 -0
  63. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-email/index.js +1 -0
  64. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-gender/index.js +1 -0
  65. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-name/index.js +1 -0
  66. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-phone/index.js +1 -0
  67. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-surname/index.js +1 -0
  68. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/form-settings/index.js +1 -0
  69. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js +1 -0
  70. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js +1 -0
  71. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js +1 -0
  72. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/detail-settings/index.js +1 -0
  73. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js +1 -0
  74. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/social/index.js +1 -0
  75. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/space/index.js +1 -0
  76. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/text/index.js +1 -0
  77. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/index.js +1 -0
  78. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/teaser/index.js +1 -0
  79. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/window-settings/index.js +1 -0
  80. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/settings/index.js +1 -0
  81. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-condition/index.js +1 -0
  82. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-time/index.js +1 -0
  83. package/build/ext/mobx-react/dist/mobxreact.esm.js +1 -0
  84. package/build/ext/swiper/modules/navigation.css.js +1 -0
  85. package/build/ext/swiper/modules/navigation.mjs.js +1 -0
  86. package/build/ext/swiper/modules/pagination.css.js +1 -0
  87. package/build/ext/swiper/modules/scrollbar.mjs.js +1 -0
  88. package/build/ext/swiper/shared/classes-to-selector.mjs.js +1 -0
  89. package/build/ext/swiper/shared/create-element-if-not-defined.mjs.js +1 -0
  90. package/build/ext/swiper/shared/ssr-window.esm.mjs.js +1 -0
  91. package/build/ext/swiper/shared/swiper-core.mjs.js +1 -0
  92. package/build/ext/swiper/shared/update-on-virtual-data.mjs.js +1 -0
  93. package/build/ext/swiper/shared/update-swiper.mjs.js +1 -0
  94. package/build/ext/swiper/shared/utils.mjs.js +1 -0
  95. package/build/ext/swiper/swiper-react.mjs.js +1 -0
  96. package/build/ext/swiper/swiper.css.js +1 -0
  97. package/build/hooks/useCustomerReviews.js +1 -1
  98. package/build/hooks/useStore.js +1 -1
  99. package/build/index.js +1 -1
  100. package/build/models/data/customer/index.d.ts +8 -1
  101. package/build/models/data/customer/index.js +1 -1
  102. package/build/models/data/customer-form-data-input/customer-register-subscription-input/index.d.ts +7 -0
  103. package/build/models/data/customer-form-data-input/customer-register-subscription-input/index.js +1 -0
  104. package/build/models/data/customer-form-data-input/index.d.ts +19 -0
  105. package/build/models/data/customer-form-data-input/index.js +1 -0
  106. package/build/models/data/index.d.ts +2 -0
  107. package/build/models/data/product/index.js +1 -1
  108. package/build/models/data/storefront-popup/index.d.ts +40 -0
  109. package/build/models/data/storefront-popup/index.js +1 -0
  110. package/build/models/data/storefront-popup/storefront-popup-analytics/index.d.ts +7 -0
  111. package/build/models/data/storefront-popup/storefront-popup-analytics/index.js +1 -0
  112. package/build/models/data/storefront-popup/storefront-popup-date-f/304/261lter/index.d.ts +6 -0
  113. package/build/models/data/storefront-popup/storefront-popup-date-f/304/261lter/index.js +1 -0
  114. package/build/models/data/storefront-popup/storefront-popup-display-filter/index.d.ts +11 -0
  115. package/build/models/data/storefront-popup/storefront-popup-display-filter/index.js +1 -0
  116. package/build/models/data/storefront-popup/storefront-popup-display-settings/index.d.ts +16 -0
  117. package/build/models/data/storefront-popup/storefront-popup-display-settings/index.js +1 -0
  118. package/build/models/data/storefront-popup/storefront-popup-page-filter/index.d.ts +16 -0
  119. package/build/models/data/storefront-popup/storefront-popup-page-filter/index.js +1 -0
  120. package/build/models/data/storefront-popup/storefront-popup-page-filter/storefront-popup-page-filter-data/index.d.ts +12 -0
  121. package/build/models/data/storefront-popup/storefront-popup-page-filter/storefront-popup-page-filter-data/index.js +1 -0
  122. package/build/models/data/storefront-popup/storefront-popup-routing/index.d.ts +6 -0
  123. package/build/models/data/storefront-popup/storefront-popup-routing/index.js +1 -0
  124. package/build/models/ui/blog-category-list/index.js +1 -1
  125. package/build/models/ui/brand-list/index.js +1 -1
  126. package/build/models/ui/category-list/index.js +1 -1
  127. package/build/models/ui/customer-review-list/index.d.ts +3 -0
  128. package/build/models/ui/customer-review-list/index.js +1 -1
  129. package/build/models/ui/customer-review-summary-list/index.js +1 -1
  130. package/build/models/ui/product-list/index.js +1 -1
  131. package/build/models/ui/raffle-list/index.js +1 -1
  132. package/build/models/ui/validator/form/account-info.js +1 -1
  133. package/build/models/ui/validator/form/address.js +1 -1
  134. package/build/models/ui/validator/form/ikas-address.js +1 -1
  135. package/build/models/ui/validator/form/register.js +1 -1
  136. package/build/page-data-init/index.js +1 -1
  137. package/build/pages/checkout.js +1 -1
  138. package/build/store/blog/index.js +1 -1
  139. package/build/store/brand/index.js +1 -1
  140. package/build/store/cart/index.js +1 -1
  141. package/build/store/category/index.js +1 -1
  142. package/build/store/checkout/index.js +1 -1
  143. package/build/store/customer/api.d.ts +2 -1
  144. package/build/store/customer/api.js +1 -1
  145. package/build/store/customer/index.d.ts +2 -0
  146. package/build/store/customer/index.js +1 -1
  147. package/build/store/html-meta-data/index.js +1 -1
  148. package/build/store/location/index.js +1 -1
  149. package/build/store/product/index.js +1 -1
  150. package/build/store/storefront-popup/index.d.ts +74 -0
  151. package/build/store/storefront-popup/index.js +1 -0
  152. package/package.json +18 -12
  153. package/build/components/checkout/components/epaykolay-button/index.d.ts +0 -5
  154. package/build/components/checkout/components/epaykolay-button/index.js +0 -1
  155. package/build/components/checkout/components/epaykolay-button/style.module.scss.js +0 -1
  156. package/build/components/checkout/components/svg/epaykolay.js +0 -1
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";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{IkasBrand as i}from"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as s}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as a}from"../models/data/category/index.js";import{IkasCheckout as c}from"../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/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/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as n}from"../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/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"../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{FacebookPixel as d}from"./facebookPixel.js";import{GoogleTagManager as m}from"./googleTagManager.js";import{IkasEventType as l}from"./events.js";import u from"lodash/cloneDeep";import{tryForEach as p}from"../utils/helper.js";import b from"./ikas.js";import{GoogleAnalytics as f}from"./googleAnalytics.js";import{TiktokPixel as h}from"./tiktokPixel.js";import{IkasBaseStore as g}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";var j=function(){function j(){o(this)}return j.getCustomerInfo=function(){return t(this,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,(t=g.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),(o=t.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:t.customerStore.customerConsentGranted})]:[2,null]}}))}))},j.pageView=function(r){return t(this,void 0,void 0,(function(){var t,o,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=window.location.href,[4,j.getCustomerInfo()];case 1:return o=e.sent(),m.pageView(t),b.pageView(r),h.pageView(t),p(j.subscribers,(function(e){e.callback({type:l.PAGE_VIEW,data:{url:t,pageType:r,customer:o}})})),[3,3];case 2:return i=e.sent(),console.error(i),[3,3];case 3:return[2]}}))}))},j.productView=function(t){try{if(d.productView(t),m.productView(t),b.productView(t),f.productView(t),h.productView(t),j.subscribers.length){var e=new n(u(t));p(j.subscribers,(function(t){t.callback({type:l.PRODUCT_VIEW,data:{productDetail:e}})}))}}catch(t){console.error(t)}},j.addToCart=function(t,e,r,o,i){try{if(d.addToCart(t,e,r),m.addToCart(t,e,i),b.addToCart(t,e,o),f.addToCart(t,e),h.addToCart(t,e),j.subscribers.length){var a=u(t),c=new s(u(o));p(j.subscribers,(function(t){t.callback({type:l.ADD_TO_CART,data:{item:a,quantity:e,cart:c}})}))}}catch(t){console.error(t)}},j.removeFromCart=function(t,e,r){try{if(m.removeFromCart(t,e),f.removeFromCart(t,e),j.subscribers.length){var o=u(t),i=new s(u(r));p(j.subscribers,(function(t){t.callback({type:l.REMOVE_FROM_CART,data:{item:o,quantity:e,cart:i}})}))}}catch(t){console.error(t)}},j.beginCheckout=function(t){try{var e=localStorage.getItem("gtmBeginCheckout");if(e&&t.id===e)return;if(localStorage.setItem("gtmBeginCheckout",t.id),d.beginCheckout(t),m.beginCheckout(t),b.beginCheckout(t),f.beginCheckout(t),h.beginCheckout(t),j.subscribers.length){var r=new c(u(t));p(j.subscribers,(function(t){t.callback({type:l.BEGIN_CHECKOUT,data:{checkout:r}})}))}}catch(t){console.error(t)}},j.purchase=function(t,e){try{if(localStorage.removeItem("gtmBeginCheckout"),d.purchase(t,e.id||""),m.purchase(t,t.orderNumber||""),b.orderSuccess(t),f.purchase(t,t.orderNumber||""),h.purchase(t),j.subscribers.length){var r=new c(u(t)),o=u(e);p(j.subscribers,(function(t){t.callback({type:l.COMPLETE_CHECKOUT,data:{checkout:r,transaction:o}})}))}}catch(t){console.error(t)}},j.checkoutStep=function(t,e){try{if(m.checkoutStep(t,e),b.checkoutStep(t,e),f.checkoutStep(t,e),j.subscribers.length){var r=new c(u(t));p(j.subscribers,(function(t){t.callback({type:l.CHECKOUT_STEP,data:{checkout:r,step:e}})}))}}catch(t){console.error(t)}},j.disableHTML=function(){try{m.disableHTML()}catch(t){console.error(t)}},j.addToWishlist=function(t,e){try{d.addToWishlist(t),h.addToWishlist(t),j.subscribers.length&&p(j.subscribers,(function(r){r.callback({type:e?l.REMOVE_FROM_WISHLIST:l.ADD_TO_WISHLIST,data:{productId:t}})}))}catch(t){console.error(t)}},j.search=function(t){try{d.search(t),m.search(t),h.search(t),f.search(t),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.SEARCH,data:{searchKeyword:t}})}))}catch(t){console.error(t)}},j.completeRegistration=function(t){try{d.completeRegistration(),m.completeRegistration(t),h.completeRegistration(),b.customerRegister(),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.CUSTOMER_REGISTER,data:{email:t.email,firstName:t.firstName,lastName:t.lastName,notificationsAccepted:t.subscriptionStatus}})}))}catch(t){console.error(t)}},j.createEmailSubscripition=function(t){try{j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.EMAIL_SUBSCRIPTION,data:{email:t}})}))}catch(t){console.error(t)}},j.customerLogin=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(m.customerLogin(t),b.customerLogin(),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.CUSTOMER_LOGIN,data:{customer:t}})})),[3,3]):[2];case 2:return r=e.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},j.customerLogout=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){try{m.customerLogout(),j.subscribers.length&&p(j.subscribers,(function(t){t.callback({type:l.CUSTOMER_LOGOUT,data:{}})}))}catch(t){console.error(t)}return[2]}))}))},j.customerVisit=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(m.customerVisit(t),b.customerVisit(),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.CUSTOMER_VISIT,data:{customer:t}})})),[3,3]):[2];case 2:return r=e.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},j.viewCart=function(t){try{if(t&&(d.viewCart(t),b.viewCart(t),f.viewCart(t),m.viewCart(t),j.subscribers.length)){var e=new s(u(t));p(j.subscribers,(function(t){t.callback({type:l.VIEW_CART,data:{cart:e}})}))}}catch(t){console.error(t)}},j.viewCategory=function(t,e){try{if(d.viewCategory(t),m.viewCategory(e,t),b.viewCategory(e),h.viewCategory(e),j.subscribers.length){var r=new a(u(e));p(j.subscribers,(function(e){e.callback({type:l.VIEW_CATEGORY,data:{categoryPath:t,category:r}})}))}}catch(t){console.error(t)}},j.viewBrand=function(t){try{if(b.viewBrand(t),j.subscribers.length){var e=new i(u(t));p(j.subscribers,(function(t){t.callback({type:l.VIEW_BRAND,data:{brand:e}})}))}}catch(t){console.error(t)}},j.viewSearchResults=function(t,e){try{if(j.subscribers.length){var r=u(e).map((function(t){return new n(t)}));p(j.subscribers,(function(e){e.callback({type:l.VIEW_SEARCH_RESULTS,data:{searchKeyword:t,productDetails:r}})}))}}catch(t){console.error(t)}},j.viewListing=function(t){try{if(j.subscribers.length){var e=u(t).map((function(t){return new n(t)}));p(j.subscribers,(function(t){t.callback({type:l.VIEW_LISTING,data:{productDetails:e}})}))}}catch(t){console.error(t)}},j.contactForm=function(t){try{if(d.contactForm(),h.contactForm(),j.subscribers.length){var e=u(t);p(j.subscribers,(function(t){t.callback({type:l.CONTACT_FORM,data:{form:e}})}))}}catch(t){console.error(t)}},j.subscribers=[],j}();export{j as Analytics};
1
+ import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";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{IkasBrand as i}from"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as s}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as a}from"../models/data/category/index.js";import{IkasCheckout as c}from"../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"../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/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as n}from"../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/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"../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{FacebookPixel as d}from"./facebookPixel.js";import{GoogleTagManager as m}from"./googleTagManager.js";import{IkasEventType as l}from"./events.js";import u from"lodash/cloneDeep";import{tryForEach as p}from"../utils/helper.js";import b from"./ikas.js";import{GoogleAnalytics as f}from"./googleAnalytics.js";import{TiktokPixel as h}from"./tiktokPixel.js";import{IkasBaseStore as g}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";var j=function(){function j(){o(this)}return j.getCustomerInfo=function(){return t(this,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,(t=g.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),(o=t.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:t.customerStore.customerConsentGranted})]:[2,null]}}))}))},j.pageView=function(r){return t(this,void 0,void 0,(function(){var t,o,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=window.location.href,[4,j.getCustomerInfo()];case 1:return o=e.sent(),m.pageView(t),b.pageView(r),h.pageView(t),p(j.subscribers,(function(e){e.callback({type:l.PAGE_VIEW,data:{url:t,pageType:r,customer:o}})})),[3,3];case 2:return i=e.sent(),console.error(i),[3,3];case 3:return[2]}}))}))},j.productView=function(t){try{if(d.productView(t),m.productView(t),b.productView(t),f.productView(t),h.productView(t),j.subscribers.length){var e=new n(u(t));p(j.subscribers,(function(t){t.callback({type:l.PRODUCT_VIEW,data:{productDetail:e}})}))}}catch(t){console.error(t)}},j.addToCart=function(t,e,r,o,i){try{if(d.addToCart(t,e,r),m.addToCart(t,e,i),b.addToCart(t,e,o),f.addToCart(t,e),h.addToCart(t,e),j.subscribers.length){var a=u(t),c=new s(u(o));p(j.subscribers,(function(t){t.callback({type:l.ADD_TO_CART,data:{item:a,quantity:e,cart:c}})}))}}catch(t){console.error(t)}},j.removeFromCart=function(t,e,r){try{if(m.removeFromCart(t,e),f.removeFromCart(t,e),j.subscribers.length){var o=u(t),i=new s(u(r));p(j.subscribers,(function(t){t.callback({type:l.REMOVE_FROM_CART,data:{item:o,quantity:e,cart:i}})}))}}catch(t){console.error(t)}},j.beginCheckout=function(t){try{var e=localStorage.getItem("gtmBeginCheckout");if(e&&t.id===e)return;if(localStorage.setItem("gtmBeginCheckout",t.id),d.beginCheckout(t),m.beginCheckout(t),b.beginCheckout(t),f.beginCheckout(t),h.beginCheckout(t),j.subscribers.length){var r=new c(u(t));p(j.subscribers,(function(t){t.callback({type:l.BEGIN_CHECKOUT,data:{checkout:r}})}))}}catch(t){console.error(t)}},j.purchase=function(t,e){try{if(localStorage.removeItem("gtmBeginCheckout"),d.purchase(t,e.id||""),m.purchase(t,t.orderNumber||""),b.orderSuccess(t),f.purchase(t,t.orderNumber||""),h.purchase(t),j.subscribers.length){var r=new c(u(t)),o=u(e);p(j.subscribers,(function(t){t.callback({type:l.COMPLETE_CHECKOUT,data:{checkout:r,transaction:o}})}))}}catch(t){console.error(t)}},j.checkoutStep=function(t,e){try{if(m.checkoutStep(t,e),b.checkoutStep(t,e),f.checkoutStep(t,e),j.subscribers.length){var r=new c(u(t));p(j.subscribers,(function(t){t.callback({type:l.CHECKOUT_STEP,data:{checkout:r,step:e}})}))}}catch(t){console.error(t)}},j.disableHTML=function(){try{m.disableHTML()}catch(t){console.error(t)}},j.addToWishlist=function(t,e){try{d.addToWishlist(t),h.addToWishlist(t),j.subscribers.length&&p(j.subscribers,(function(r){r.callback({type:e?l.REMOVE_FROM_WISHLIST:l.ADD_TO_WISHLIST,data:{productId:t}})}))}catch(t){console.error(t)}},j.search=function(t){try{d.search(t),m.search(t),h.search(t),f.search(t),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.SEARCH,data:{searchKeyword:t}})}))}catch(t){console.error(t)}},j.completeRegistration=function(t){try{d.completeRegistration(),m.completeRegistration(t),h.completeRegistration(),b.customerRegister(),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.CUSTOMER_REGISTER,data:{email:t.email,firstName:t.firstName,lastName:t.lastName,notificationsAccepted:t.subscriptionStatus}})}))}catch(t){console.error(t)}},j.createEmailSubscripition=function(t){try{j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.EMAIL_SUBSCRIPTION,data:{email:t}})}))}catch(t){console.error(t)}},j.customerLogin=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(m.customerLogin(t),b.customerLogin(),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.CUSTOMER_LOGIN,data:{customer:t}})})),[3,3]):[2];case 2:return r=e.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},j.customerLogout=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){try{m.customerLogout(),j.subscribers.length&&p(j.subscribers,(function(t){t.callback({type:l.CUSTOMER_LOGOUT,data:{}})}))}catch(t){console.error(t)}return[2]}))}))},j.customerVisit=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(m.customerVisit(t),b.customerVisit(),j.subscribers.length&&p(j.subscribers,(function(e){e.callback({type:l.CUSTOMER_VISIT,data:{customer:t}})})),[3,3]):[2];case 2:return r=e.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},j.viewCart=function(t){try{if(t&&(d.viewCart(t),b.viewCart(t),f.viewCart(t),m.viewCart(t),j.subscribers.length)){var e=new s(u(t));p(j.subscribers,(function(t){t.callback({type:l.VIEW_CART,data:{cart:e}})}))}}catch(t){console.error(t)}},j.viewCategory=function(t,e){try{if(d.viewCategory(t),m.viewCategory(e,t),b.viewCategory(e),h.viewCategory(e),j.subscribers.length){var r=new a(u(e));p(j.subscribers,(function(e){e.callback({type:l.VIEW_CATEGORY,data:{categoryPath:t,category:r}})}))}}catch(t){console.error(t)}},j.viewBrand=function(t){try{if(b.viewBrand(t),j.subscribers.length){var e=new i(u(t));p(j.subscribers,(function(t){t.callback({type:l.VIEW_BRAND,data:{brand:e}})}))}}catch(t){console.error(t)}},j.viewSearchResults=function(t,e){try{if(j.subscribers.length){var r=u(e).map((function(t){return new n(t)}));p(j.subscribers,(function(e){e.callback({type:l.VIEW_SEARCH_RESULTS,data:{searchKeyword:t,productDetails:r}})}))}}catch(t){console.error(t)}},j.viewListing=function(t){try{if(j.subscribers.length){var e=u(t).map((function(t){return new n(t)}));p(j.subscribers,(function(t){t.callback({type:l.VIEW_LISTING,data:{productDetails:e}})}))}}catch(t){console.error(t)}},j.contactForm=function(t){try{if(d.contactForm(),h.contactForm(),j.subscribers.length){var e=u(t);p(j.subscribers,(function(t){t.callback({type:l.CONTACT_FORM,data:{form:e}})}))}}catch(t){console.error(t)}},j.subscribers=[],j}();export{j as Analytics};
@@ -1 +1 @@
1
- import{makeAutoObservable as e}from"mobx";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"@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/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/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as t}from"../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/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"../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{CheckoutStep as i}from"../components/checkout/model.js";var o="undefined"==typeof window,r=function(){function r(){e(this)}return r.productView=function(e){try{return void(!o&&window.gtag&&window.gtag("event","view_item",{currency:""===e.selectedVariant.price.currency?"TRY":e.selectedVariant.price.currency,value:e.selectedVariant.price.finalPrice,items:[a(e)]}))}catch(e){console.error(e)}},r.addToCart=function(e,i){try{return void(!o&&window.gtag&&window.gtag("event","add_to_cart",{currency:e instanceof t?""===e.selectedVariant.price.currency?"TRY":e.selectedVariant.price.currency:e.currencyCode,value:e instanceof t?e.selectedVariant.finalPrice*i:e.finalPrice?e.finalPrice*i:null,items:[e instanceof t?a(e,i):n(e,i)]}))}catch(e){console.error(e)}},r.removeFromCart=function(e,i){try{return void(!o&&window.gtag&&window.gtag("event","remove_from_cart",{currency:e instanceof t?""===e.selectedVariant.price.currency?"TRY":e.selectedVariant.price.currency:e.currencyCode,value:e instanceof t?e.selectedVariant.price.finalPrice:e.finalPrice,items:[e instanceof t?a(e,i):n(e,i)]}))}catch(e){console.error(e)}},r.viewCart=function(e){try{return void(!o&&window.gtag&&window.gtag("event","view_cart",{currency:e.currencyCode,value:e.totalPrice,items:e.items.map((function(e){return n(e,e.quantity)}))}))}catch(e){console.error(e)}},r.beginCheckout=function(e){try{return void(!o&&window.gtag&&window.gtag("event","begin_checkout",{currency:e.currencyCode,value:e.totalFinalPrice,items:e.items.map((function(e){return n(e,e.quantity)}))}))}catch(e){console.error(e)}},r.purchase=function(e,t){try{return void(!o&&window.gtag&&window.gtag("event","purchase",{transaction_id:t,affiliation:window.location.hostname,value:e.totalFinalPrice,tax:e.totalTax,shipping:e.shippingTotal,currency:e.currencyCode,coupon:e.couponCode,items:e.items.map((function(e){return n(e,e.quantity)}))}))}catch(e){console.error(e)}},r.checkoutStep=function(e,t){var r;if(t===i.SHIPPING)try{return void(!o&&window.gtag&&window.gtag("event","add_shipping_info",{currency:e.currencyCode,value:e.totalFinalPrice,shipping_tier:"Ground",coupon:e.couponCode,items:e.items.map((function(e){return n(e,e.quantity)}))}))}catch(e){console.error(e)}if(t===i.PAYMENT)try{return void(!o&&window.gtag&&window.gtag("event","add_payment_info",{currency:e.currencyCode,value:e.totalFinalPrice,coupon:e.couponCode,payment_type:null===(r=e.selectedPaymentGateway)||void 0===r?void 0:r.paymentMethodType,items:e.items.map((function(e){return n(e,e.quantity)}))}))}catch(e){console.error(e)}},r.search=function(e){try{return void(!o&&window.gtag&&window.gtag("event","search",{search_term:e}))}catch(e){console.error(e)}},r}();function a(e,t){var i;void 0===t&&(t=1);var o=[],r=e.categories;return r&&r.length&&(r[0].categoryPath&&r[0].categoryPath.map((function(e){return o.push(e)})),o.push(r[0].name)),{item_name:e.name,item_id:e.selectedVariant.id,price:e.selectedVariant.price.finalPrice,item_brand:(null===(i=e.brand)||void 0===i?void 0:i.name)||"",item_category:o.length?o[0]:"",item_category2:o.length>1?o[1]:"",item_category3:o.length>2?o[2]:"",item_category4:o.length>3?o.slice(3,o.length).join(" > "):"",item_variant:e.selectedVariant.variantValues.map((function(e){return e.name})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}function n(e,t){var i,o;void 0===t&&(t=1);var r=[],a=e.variant.categories;return a&&a.length&&(a[0].categoryPath&&a[0].categoryPath.map((function(e){return r.push(e.name)})),r.push(a[0].name)),{item_name:e.variant.name,item_id:e.variant.id,price:e.finalPrice||"",item_brand:(null===(i=e.variant.brand)||void 0===i?void 0:i.name)||"",item_category:r.length?r[0]:"",item_category2:r.length>1?r[1]:"",item_category3:r.length>2?r[2]:"",item_category4:r.length>3?r.slice(3,r.length).join(" > "):"",item_variant:null===(o=e.variant.variantValues)||void 0===o?void 0:o.map((function(e){return e.variantValueName})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}export{r as GoogleAnalytics};
1
+ import{makeAutoObservable as e}from"mobx";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"@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/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/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as t}from"../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/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"../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{CheckoutStep as i}from"../components/checkout/model.js";var o="undefined"==typeof window,r=function(){function r(){e(this)}return r.productView=function(e){try{return void(!o&&window.gtag&&window.gtag("event","view_item",{currency:""===e.selectedVariant.price.currency?"TRY":e.selectedVariant.price.currency,value:e.selectedVariant.price.finalPrice,items:[a(e)]}))}catch(e){console.error(e)}},r.addToCart=function(e,i){try{return void(!o&&window.gtag&&window.gtag("event","add_to_cart",{currency:e instanceof t?""===e.selectedVariant.price.currency?"TRY":e.selectedVariant.price.currency:e.currencyCode,value:e instanceof t?e.selectedVariant.finalPrice*i:e.finalPrice?e.finalPrice*i:null,items:[e instanceof t?a(e,i):d(e,i)]}))}catch(e){console.error(e)}},r.removeFromCart=function(e,i){try{return void(!o&&window.gtag&&window.gtag("event","remove_from_cart",{currency:e instanceof t?""===e.selectedVariant.price.currency?"TRY":e.selectedVariant.price.currency:e.currencyCode,value:e instanceof t?e.selectedVariant.price.finalPrice:e.finalPrice,items:[e instanceof t?a(e,i):d(e,i)]}))}catch(e){console.error(e)}},r.viewCart=function(e){try{return void(!o&&window.gtag&&window.gtag("event","view_cart",{currency:e.currencyCode,value:e.totalPrice,items:e.items.map((function(e){return d(e,e.quantity)}))}))}catch(e){console.error(e)}},r.beginCheckout=function(e){try{return void(!o&&window.gtag&&window.gtag("event","begin_checkout",{currency:e.currencyCode,value:e.totalFinalPrice,items:e.items.map((function(e){return d(e,e.quantity)}))}))}catch(e){console.error(e)}},r.purchase=function(e,t){try{return void(!o&&window.gtag&&window.gtag("event","purchase",{transaction_id:t,affiliation:window.location.hostname,value:e.totalFinalPrice,tax:e.totalTax,shipping:e.shippingTotal,currency:e.currencyCode,coupon:e.couponCode,items:e.items.map((function(e){return d(e,e.quantity)}))}))}catch(e){console.error(e)}},r.checkoutStep=function(e,t){var r;if(t===i.SHIPPING)try{return void(!o&&window.gtag&&window.gtag("event","add_shipping_info",{currency:e.currencyCode,value:e.totalFinalPrice,shipping_tier:"Ground",coupon:e.couponCode,items:e.items.map((function(e){return d(e,e.quantity)}))}))}catch(e){console.error(e)}if(t===i.PAYMENT)try{return void(!o&&window.gtag&&window.gtag("event","add_payment_info",{currency:e.currencyCode,value:e.totalFinalPrice,coupon:e.couponCode,payment_type:null===(r=e.selectedPaymentGateway)||void 0===r?void 0:r.paymentMethodType,items:e.items.map((function(e){return d(e,e.quantity)}))}))}catch(e){console.error(e)}},r.search=function(e){try{return void(!o&&window.gtag&&window.gtag("event","search",{search_term:e}))}catch(e){console.error(e)}},r}();function a(e,t){var i;void 0===t&&(t=1);var o=[],r=e.categories;return r&&r.length&&(r[0].categoryPath&&r[0].categoryPath.map((function(e){return o.push(e)})),o.push(r[0].name)),{item_name:e.name,item_id:e.selectedVariant.id,price:e.selectedVariant.price.finalPrice,item_brand:(null===(i=e.brand)||void 0===i?void 0:i.name)||"",item_category:o.length?o[0]:"",item_category2:o.length>1?o[1]:"",item_category3:o.length>2?o[2]:"",item_category4:o.length>3?o.slice(3,o.length).join(" > "):"",item_variant:e.selectedVariant.variantValues.map((function(e){return e.name})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}function d(e,t){var i,o;void 0===t&&(t=1);var r=[],a=e.variant.categories;return a&&a.length&&(a[0].categoryPath&&a[0].categoryPath.map((function(e){return r.push(e.name)})),r.push(a[0].name)),{item_name:e.variant.name,item_id:e.variant.id,price:e.finalPrice||"",item_brand:(null===(i=e.variant.brand)||void 0===i?void 0:i.name)||"",item_category:r.length?r[0]:"",item_category2:r.length>1?r[1]:"",item_category3:r.length>2?r[2]:"",item_category4:r.length>3?r.slice(3,r.length).join(" > "):"",item_variant:null===(o=e.variant.variantValues)||void 0===o?void 0:o.map((function(e){return e.variantValueName})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}export{r as GoogleAnalytics};
@@ -1 +1 @@
1
- import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as t}from"mobx";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"@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/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/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as o}from"../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/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"../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{CheckoutStep as r}from"../components/checkout/model.js";import"./analytics.js";import"./head/index.js";import"../components/page/index.js";import"../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../components/link/index.js";import"../components/page-editor/loader/style.module.scss.js";import"../components/google-captcha/index.js";import"../pages/home.js";import"../pages/_slug_/index.js";import"../pages/pages/_slug_.js";import"../pages/checkout.js";import"../pages/account/index.js";import"../pages/account/addresses.js";import"../pages/account/orders/index.js";import"../pages/account/orders/_id_.js";import"../pages/account/login.js";import"../pages/account/register.js";import"../pages/account/forgot-password.js";import"../pages/account/recover-password.js";import"../pages/cart.js";import"../pages/editor.js";import"../pages/account/favorite-products.js";import"../pages/search.js";import"next/error.js";import"../pages/blog/index.js";import"../pages/blog/_slug_.js";import"../pages/raffle/_slug_.js";import"../pages/raffle/index.js";import"../pages/account/raffles.js";import"../pages/account/activate.js";import{IkasBaseStore as a}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import"@ikas/storefront-config";import"lodash/get";import i from"lodash/cloneDeep";var s="undefined"==typeof window,d=function(){function e(){t(this)}return e.pageView=function(e){try{var t={event:"page-view-GTM",page:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.productView=function(e){var t,o;try{var r={event:"view_item-GTM",ecommerce:{items:[n(e)],extraParams:{parent_id:e.id,currency:e.selectedVariant.price.currency,url:"https://".concat(window.location.hostname).concat(e.href),item_image:(null===(o=null===(t=e.selectedVariant.mainImage)||void 0===t?void 0:t.image)||void 0===o?void 0:o.src)||"",barcode:e.selectedVariant.barcodeList&&e.selectedVariant.barcodeList.length?e.selectedVariant.barcodeList[0]:"",sellPrice:e.selectedVariant.sellPrice,discountPrice:e.selectedVariant.discountPrice||0}}};return!s&&window.dataLayer&&window.dataLayer.push(r),r}catch(e){console.error(e)}},e.addToCart=function(e,t,r){var i=a.getInstance().cartStore.cart;try{var d={event:"add_to_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t,r)],cart:i}};return!s&&window.dataLayer&&window.dataLayer.push(d),d}catch(e){console.error(e)}},e.removeFromCart=function(e,t){var r=a.getInstance().cartStore.cart;try{var i={event:"remove_from_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t)],cart:0===(null==r?void 0:r.itemCount)?null:r}};return!s&&window.dataLayer&&window.dataLayer.push(i),i}catch(e){console.error(e)}},e.beginCheckout=function(e){try{var t={event:"begin_checkout-GTM",ecommerce:{items:e.items.map((function(e){return m(e,e.quantity)}))}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.purchase=function(e,t){try{var o={event:"purchase-GTM",ecommerce:{purchase:{transaction_id:t,affiliation:window.location.hostname,value:""+e.totalFinalPrice,tax:""+e.totalTax,shipping:""+e.shippingTotal,currency:e.currencyCode,coupon:e.couponCode,items:e.items.map((function(e){return m(e,e.quantity)}))}}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.checkoutStep=function(e,t){var o,a,d=i(e);null===(o=d.shippingAddress)||void 0===o||delete o.checkoutSettings,null===(a=d.billingAddress)||void 0===a||delete a.checkoutSettings;var n="";t===r.INFO?n="checkout_info-GTM":t===r.SHIPPING?n="checkout_shipping-GTM":t===r.PAYMENT?n="checkout_payment-GTM":t===r.SUCCESS&&(n="checkout_success-GTM");try{var m={event:n,ecommerce:{cart:d}};return!s&&window.dataLayer&&window.dataLayer.push(m),m}catch(e){console.error(e)}},e.disableHTML=function(){try{!s&&window.dataLayer&&window.dataLayer.push({"gtm.blocklist":["html","customScripts","customPixels","nonGoogleScripts"]})}catch(e){console.error(e)}},e.completeRegistration=function(e){try{var t={event:"customer_register-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.search=function(e){try{var t={event:"search-GTM",search_string:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCategory=function(e,t){try{var o={event:"view_category-GTM",ecommerce:{category:[{id:e.id,name:e.name,metaData:e.metaData,href:e.href,image:e.image,path:t}]}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.customerLogin=function(e){try{var t={event:"customer_login-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.customerLogout=function(){try{var e={event:"customer_logout-GTM"};return!s&&window.dataLayer&&window.dataLayer.push(e),e}catch(e){console.error(e)}},e.customerVisit=function(e){try{var t={event:"customer_visit-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCart=function(e){try{var t={event:"view_cart-GTM",ecommerce:{cart:e}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e}();function n(e,t){var o;void 0===t&&(t=1);var r=[],a=e.categories;return a&&a.length&&(a[0].categoryPath&&a[0].categoryPath.map((function(e){return r.push(e)})),r.push(a[0].name)),{item_name:e.name,item_id:e.selectedVariant.id,price:e.selectedVariant.price.finalPrice,item_brand:(null===(o=e.brand)||void 0===o?void 0:o.name)||"",item_category:r.length?r[0]:"",item_category_2:r.length>1?r[1]:"",item_category_3:r.length>2?r[2]:"",item_category_4:r.length>3?r.slice(3,r.length).join(" > "):"",item_variant:e.selectedVariant.variantValues.map((function(e){return e.name})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}function m(t,o,r){var a,i;void 0===o&&(o=1);var s=[],d=null==r?void 0:r.categories;return d&&d.length&&(d[0].categoryPath&&d[0].categoryPath.map((function(e){return s.push(e)})),s.push(d[0].name)),e(e({item_name:t.variant.name,item_id:t.variant.id,price:t.finalPrice||""},r?{item_brand:(null===(a=r.brand)||void 0===a?void 0:a.name)||"",item_category:s.length?s[0]:"",item_category_2:s.length>1?s[1]:"",item_category_3:s.length>2?s[2]:"",item_category_4:s.length>3?s.slice(3,s.length).join(" > "):""}:{item_brand:"",item_category:"",item_category_2:"",item_category_3:"",item_category_4:""}),{item_variant:null===(i=t.variant.variantValues)||void 0===i?void 0:i.map((function(e){return e.variantValueName})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:o})}export{d as GoogleTagManager};
1
+ import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as t}from"mobx";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"@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/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/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as o}from"../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/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"../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{CheckoutStep as r}from"../components/checkout/model.js";import"./analytics.js";import"./head/index.js";import"../components/page/index.js";import"../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../components/link/index.js";import"../components/page-editor/loader/style.module.scss.js";import"../components/google-captcha/index.js";import"../pages/home.js";import"../pages/_slug_/index.js";import"../pages/pages/_slug_.js";import"../pages/checkout.js";import"../pages/account/index.js";import"../pages/account/addresses.js";import"../pages/account/orders/index.js";import"../pages/account/orders/_id_.js";import"../pages/account/login.js";import"../pages/account/register.js";import"../pages/account/forgot-password.js";import"../pages/account/recover-password.js";import"../pages/cart.js";import"../pages/editor.js";import"../pages/account/favorite-products.js";import"../pages/search.js";import"next/error.js";import"../pages/blog/index.js";import"../pages/blog/_slug_.js";import"../pages/raffle/_slug_.js";import"../pages/raffle/index.js";import"../pages/account/raffles.js";import"../pages/account/activate.js";import{IkasBaseStore as a}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import"@ikas/storefront-config";import"lodash/get";import i from"lodash/cloneDeep";var s="undefined"==typeof window,d=function(){function e(){t(this)}return e.pageView=function(e){try{var t={event:"page-view-GTM",page:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.productView=function(e){var t,o;try{var r={event:"view_item-GTM",ecommerce:{items:[n(e)],extraParams:{parent_id:e.id,currency:e.selectedVariant.price.currency,url:"https://".concat(window.location.hostname).concat(e.href),item_image:(null===(o=null===(t=e.selectedVariant.mainImage)||void 0===t?void 0:t.image)||void 0===o?void 0:o.src)||"",barcode:e.selectedVariant.barcodeList&&e.selectedVariant.barcodeList.length?e.selectedVariant.barcodeList[0]:"",sellPrice:e.selectedVariant.sellPrice,discountPrice:e.selectedVariant.discountPrice||0}}};return!s&&window.dataLayer&&window.dataLayer.push(r),r}catch(e){console.error(e)}},e.addToCart=function(e,t,r){var i=a.getInstance().cartStore.cart;try{var d={event:"add_to_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t,r)],cart:i}};return!s&&window.dataLayer&&window.dataLayer.push(d),d}catch(e){console.error(e)}},e.removeFromCart=function(e,t){var r=a.getInstance().cartStore.cart;try{var i={event:"remove_from_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t)],cart:0===(null==r?void 0:r.itemCount)?null:r}};return!s&&window.dataLayer&&window.dataLayer.push(i),i}catch(e){console.error(e)}},e.beginCheckout=function(e){try{var t={event:"begin_checkout-GTM",ecommerce:{items:e.items.map((function(e){return m(e,e.quantity)}))}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.purchase=function(e,t){try{var o={event:"purchase-GTM",ecommerce:{purchase:{transaction_id:t,affiliation:window.location.hostname,value:""+e.totalFinalPrice,tax:""+e.totalTax,shipping:""+e.shippingTotal,currency:e.currencyCode,coupon:e.couponCode,items:e.items.map((function(e){return m(e,e.quantity)}))}}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.checkoutStep=function(e,t){var o,a,d=i(e);null===(o=d.shippingAddress)||void 0===o||delete o.checkoutSettings,null===(a=d.billingAddress)||void 0===a||delete a.checkoutSettings;var n="";t===r.INFO?n="checkout_info-GTM":t===r.SHIPPING?n="checkout_shipping-GTM":t===r.PAYMENT?n="checkout_payment-GTM":t===r.SUCCESS&&(n="checkout_success-GTM");try{var m={event:n,ecommerce:{cart:d}};return!s&&window.dataLayer&&window.dataLayer.push(m),m}catch(e){console.error(e)}},e.disableHTML=function(){try{!s&&window.dataLayer&&window.dataLayer.push({"gtm.blocklist":["html","customScripts","customPixels","nonGoogleScripts"]})}catch(e){console.error(e)}},e.completeRegistration=function(e){try{var t={event:"customer_register-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.search=function(e){try{var t={event:"search-GTM",search_string:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCategory=function(e,t){try{var o={event:"view_category-GTM",ecommerce:{category:[{id:e.id,name:e.name,metaData:e.metaData,href:e.href,image:e.image,path:t}]}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.customerLogin=function(e){try{var t={event:"customer_login-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.customerLogout=function(){try{var e={event:"customer_logout-GTM"};return!s&&window.dataLayer&&window.dataLayer.push(e),e}catch(e){console.error(e)}},e.customerVisit=function(e){try{var t={event:"customer_visit-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCart=function(e){try{var t={event:"view_cart-GTM",ecommerce:{cart:e}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e}();function n(e,t){var o;void 0===t&&(t=1);var r=[],a=e.categories;return a&&a.length&&(a[0].categoryPath&&a[0].categoryPath.map((function(e){return r.push(e)})),r.push(a[0].name)),{item_name:e.name,item_id:e.selectedVariant.id,price:e.selectedVariant.price.finalPrice,item_brand:(null===(o=e.brand)||void 0===o?void 0:o.name)||"",item_category:r.length?r[0]:"",item_category_2:r.length>1?r[1]:"",item_category_3:r.length>2?r[2]:"",item_category_4:r.length>3?r.slice(3,r.length).join(" > "):"",item_variant:e.selectedVariant.variantValues.map((function(e){return e.name})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}function m(t,o,r){var a,i;void 0===o&&(o=1);var s=[],d=null==r?void 0:r.categories;return d&&d.length&&(d[0].categoryPath&&d[0].categoryPath.map((function(e){return s.push(e)})),s.push(d[0].name)),e(e({item_name:t.variant.name,item_id:t.variant.id,price:t.finalPrice||""},r?{item_brand:(null===(a=r.brand)||void 0===a?void 0:a.name)||"",item_category:s.length?s[0]:"",item_category_2:s.length>1?s[1]:"",item_category_3:s.length>2?s[2]:"",item_category_4:s.length>3?s.slice(3,s.length).join(" > "):""}:{item_brand:"",item_category:"",item_category_2:"",item_category_3:"",item_category_4:""}),{item_variant:null===(i=t.variant.variantValues)||void 0===i?void 0:i.map((function(e){return e.variantValueName})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:o})}export{d as GoogleTagManager};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as s}from'./../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasBaseStore as r}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/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{IkasThemeJsonPageType as o}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/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/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/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"../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";var n,a;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW"}(n||(n={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT",t[t.ACTIVATE_CUSTOMER=21]="ACTIVATE_CUSTOMER"}(a||(a={}));var d=process.env.NEXT_PUBLIC_ANALYTICS_URL?"".concat(process.env.NEXT_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",c=function(){function c(){}return c.createUUID=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,fetch("".concat(process.env.NEXT_PUBLIC_BASE_URL,"/generate-id/1"))];case 1:return[4,t.sent().json()];case 2:return[2,t.sent().data[0]]}}))}))},c.createSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),i={},[4,this.createUUID()];case 1:return i.id=e.sent(),i.expiry=Date.now()+this.EXPIRY_LENGTH,t=i,localStorage.setItem(this.SESSION_ID_KEY,JSON.stringify(t)),this.sessionId=t.id,[4,this.sessionStart()];case 2:return e.sent(),[3,4];case 3:return s=e.sent(),console.error(s),[3,4];case 4:return[2]}}))}))},c.checkSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(this.SESSION_ID_KEY))?(s=JSON.parse(t)).expiry<Date.now()||s.id.length<=13?[4,this.createSessionId()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:this.sessionId=s.id,e.label=3;case 3:return[3,6];case 4:return[4,this.createSessionId()];case 5:e.sent(),e.label=6;case 6:return i.init({sessionId:this.sessionId||""}),[3,8];case 7:return r=e.sent(),console.error(r),[3,8];case 8:return[2]}}))}))},c.checkVisitorId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.VISITOR_ID_KEY))&&t.length>13?(this.visitorId=t,[3,3]):[3,1];case 1:return s=this,[4,this.createUUID()];case 2:s.visitorId=e.sent(),localStorage.setItem(this.VISITOR_ID_KEY,this.visitorId),e.label=3;case 3:return i.init({visitorId:this.visitorId}),[3,5];case 4:return r=e.sent(),console.error(r),[3,5];case 5:return[2]}}))}))},c.getPageType=function(t){switch(t){case o.INDEX:return a.INDEX;case o.CATEGORY:return a.CATEGORY;case o.BRAND:return a.BRAND;case o.PRODUCT:return a.PRODUCT;case o.CUSTOM:return a.CUSTOM;case o.ACCOUNT:return a.ACCOUNT;case o.ADDRESSES:return a.ADDRESSES;case o.ORDERS:return a.ORDERS;case o.ORDER_DETAIL:return a.ORDER_DETAIL;case o.LOGIN:return a.LOGIN;case o.REGISTER:return a.REGISTER;case o.FORGOT_PASSWORD:return a.FORGOT_PASSWORD;case o.RECOVER_PASSWORD:return a.RECOVER_PASSWORD;case o.ACTIVATE_CUSTOMER:return a.ACTIVATE_CUSTOMER;case o.CART:return a.CART;case o.FAVORITE_PRODUCTS:return a.FAVORITE_PRODUCTS;case o.SEARCH:return a.SEARCH;case o.NOT_FOUND:return a.NOT_FOUND;case o.BLOG:return a.BLOG;case o.BLOG_INDEX:return a.BLOG_INDEX;case o.BLOG_CATEGORY:return a.BLOG_CATEGORY;case o.CHECKOUT:return a.CHECKOUT}},c.getCustomerData=function(){var t=r.getInstance(),e=t.customerStore.customer;return{id:(null==e?void 0:e.id)||void 0,e:(null==e?void 0:e.email)||void 0,c:t.customerStore.customerConsentGranted}},c.getCommonEventData=function(){var t=r.getInstance();return{u:window.location.href,r:document.referrer,pt:t.currentPageType?this.getPageType(t.currentPageType):void 0}},c.sendEvents=function(s){var o;return t(this,void 0,void 0,(function(){var t,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,(t=r.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),[4,this.checkSessionId()];case 2:return e.sent(),[4,this.checkVisitorId()];case 3:return e.sent(),n={e:s,scid:i.getSalesChannelId(),sfid:i.getStorefrontId(),sid:this.sessionId,vid:this.visitorId,cid:null===(o=t.customerStore.customer)||void 0===o?void 0:o.id},[4,fetch(d,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json","x-api-key":i.getApiKey()}})];case 4:return e.sent(),[3,6];case 5:return a=e.sent(),console.error(a),[3,6];case 6:return[2]}}))}))},c.sessionStart=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.SESSION_START,ts:Date.now(),d:s({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.pageView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PAGE_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{pt:this.getPageType(i)})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.productView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PRODUCT_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{pr:{id:i.id,vid:i.selectedVariant.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.addToCart=function(i,r,o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ADD_TO_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:o.id,c:o.itemCount},crtItm:{id:i.id,c:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCart=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.VIEW_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:i.id,c:i.itemCount}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.orderSuccess=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ORDER_SUCCESS,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:"success"}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[4,this.createSessionId()];case 2:return e.sent(),[2]}}))}))},c.beginCheckout=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BEGIN_CHECKOUT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.checkoutStep=function(i,r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CHECKOUT_STEP,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerRegister=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_REGISTER,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerLogin=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_LOGIN,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerVisit=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_VISIT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewBrand=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BRAND_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),br:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCategory=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CATEGORY_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),ctg:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.SESSION_ID_KEY="ikas_session_id",c.VISITOR_ID_KEY="ikas_visitor_id",c.EXPIRY_LENGTH=18e5,c}();export{c as default};
1
+ import{__awaiter as t,__generator as e,__assign as s}from'./../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasBaseStore as r}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/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{IkasThemeJsonPageType as o}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"../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/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/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"../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";var n,a;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW"}(n||(n={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT",t[t.ACTIVATE_CUSTOMER=21]="ACTIVATE_CUSTOMER"}(a||(a={}));var d=process.env.NEXT_PUBLIC_ANALYTICS_URL?"".concat(process.env.NEXT_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",c=function(){function c(){}return c.createUUID=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,fetch("".concat(process.env.NEXT_PUBLIC_BASE_URL,"/generate-id/1"))];case 1:return[4,t.sent().json()];case 2:return[2,t.sent().data[0]]}}))}))},c.createSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),i={},[4,this.createUUID()];case 1:return i.id=e.sent(),i.expiry=Date.now()+this.EXPIRY_LENGTH,t=i,localStorage.setItem(this.SESSION_ID_KEY,JSON.stringify(t)),this.sessionId=t.id,[4,this.sessionStart()];case 2:return e.sent(),[3,4];case 3:return s=e.sent(),console.error(s),[3,4];case 4:return[2]}}))}))},c.checkSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(this.SESSION_ID_KEY))?(s=JSON.parse(t)).expiry<Date.now()||s.id.length<=13?[4,this.createSessionId()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:this.sessionId=s.id,e.label=3;case 3:return[3,6];case 4:return[4,this.createSessionId()];case 5:e.sent(),e.label=6;case 6:return i.init({sessionId:this.sessionId||""}),[3,8];case 7:return r=e.sent(),console.error(r),[3,8];case 8:return[2]}}))}))},c.checkVisitorId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.VISITOR_ID_KEY))&&t.length>13?(this.visitorId=t,[3,3]):[3,1];case 1:return s=this,[4,this.createUUID()];case 2:s.visitorId=e.sent(),localStorage.setItem(this.VISITOR_ID_KEY,this.visitorId),e.label=3;case 3:return i.init({visitorId:this.visitorId}),[3,5];case 4:return r=e.sent(),console.error(r),[3,5];case 5:return[2]}}))}))},c.getPageType=function(t){switch(t){case o.INDEX:return a.INDEX;case o.CATEGORY:return a.CATEGORY;case o.BRAND:return a.BRAND;case o.PRODUCT:return a.PRODUCT;case o.CUSTOM:return a.CUSTOM;case o.ACCOUNT:return a.ACCOUNT;case o.ADDRESSES:return a.ADDRESSES;case o.ORDERS:return a.ORDERS;case o.ORDER_DETAIL:return a.ORDER_DETAIL;case o.LOGIN:return a.LOGIN;case o.REGISTER:return a.REGISTER;case o.FORGOT_PASSWORD:return a.FORGOT_PASSWORD;case o.RECOVER_PASSWORD:return a.RECOVER_PASSWORD;case o.ACTIVATE_CUSTOMER:return a.ACTIVATE_CUSTOMER;case o.CART:return a.CART;case o.FAVORITE_PRODUCTS:return a.FAVORITE_PRODUCTS;case o.SEARCH:return a.SEARCH;case o.NOT_FOUND:return a.NOT_FOUND;case o.BLOG:return a.BLOG;case o.BLOG_INDEX:return a.BLOG_INDEX;case o.BLOG_CATEGORY:return a.BLOG_CATEGORY;case o.CHECKOUT:return a.CHECKOUT}},c.getCustomerData=function(){var t=r.getInstance(),e=t.customerStore.customer;return{id:(null==e?void 0:e.id)||void 0,e:(null==e?void 0:e.email)||void 0,c:t.customerStore.customerConsentGranted}},c.getCommonEventData=function(){var t=r.getInstance();return{u:window.location.href,r:document.referrer,pt:t.currentPageType?this.getPageType(t.currentPageType):void 0}},c.sendEvents=function(s){var o;return t(this,void 0,void 0,(function(){var t,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,(t=r.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),[4,this.checkSessionId()];case 2:return e.sent(),[4,this.checkVisitorId()];case 3:return e.sent(),n={e:s,scid:i.getSalesChannelId(),sfid:i.getStorefrontId(),sid:this.sessionId,vid:this.visitorId,cid:null===(o=t.customerStore.customer)||void 0===o?void 0:o.id},[4,fetch(d,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json","x-api-key":i.getApiKey()}})];case 4:return e.sent(),[3,6];case 5:return a=e.sent(),console.error(a),[3,6];case 6:return[2]}}))}))},c.sessionStart=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.SESSION_START,ts:Date.now(),d:s({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.pageView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PAGE_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{pt:this.getPageType(i)})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.productView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PRODUCT_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{pr:{id:i.id,vid:i.selectedVariant.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.addToCart=function(i,r,o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ADD_TO_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:o.id,c:o.itemCount},crtItm:{id:i.id,c:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCart=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.VIEW_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:i.id,c:i.itemCount}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.orderSuccess=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ORDER_SUCCESS,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:"success"}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[4,this.createSessionId()];case 2:return e.sent(),[2]}}))}))},c.beginCheckout=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BEGIN_CHECKOUT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.checkoutStep=function(i,r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CHECKOUT_STEP,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerRegister=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_REGISTER,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerLogin=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_LOGIN,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerVisit=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_VISIT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewBrand=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BRAND_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),br:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCategory=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CATEGORY_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),ctg:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.SESSION_ID_KEY="ikas_session_id",c.VISITOR_ID_KEY="ikas_visitor_id",c.EXPIRY_LENGTH=18e5,c}();export{c as default};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i,__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import s from"lodash/sortBy";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"@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/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{IkasOrderAddressCity as r}from"../../../../models/data/order/address/city/index.js";import{IkasOrderAddressCountry as n}from"../../../../models/data/order/address/country/index.js";import{IkasOrderAddressDistrict as d}from"../../../../models/data/order/address/district/index.js";import{IkasOrderAddressRegion as a}from"../../../../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/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/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"../../../../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{stringSorter as l,capitalize as u}from"../../../../utils/helper.js";import{FREE_TEXT_CITY_COUNTRY_LIST as c,DISTRICT_HIDDEN_COUNTRY_LIST as m}from"../../../../utils/constants.js";import p from"../../../../store/location/index.js";import{IkasStorefrontConfig as h}from"@ikas/storefront-config";var f=function(){function f(e){var s=this;this.isCorporate=!1,this.isErrorsVisible=!1,this.allowedCountryIds=null,this.allowCorporateInfo=!1,this.allowTitleChange=!1,this.firstNameChangeCallback=null,this.lastNameChangeCallback=null,this.countries=[],this.states=[],this.cities=[],this.districts=[],this.myCountryCode=null,this.fillDropdownOptions=function(){return t(s,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.listCountries()];case 1:return t.sent(),[4,this.listStates()];case 2:return t.sent(),[4,this.listCities()];case 3:return t.sent(),[4,this.listDistricts()];case 4:return t.sent(),[2]}}))}))},this.listCountries=function(){return t(s,void 0,void 0,(function(){var t,e,o,s,r,n,d,a,l=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),this.myCountryCode?[3,2]:[4,p.getMyCountry()];case 1:t=i.sent(),this.myCountryCode=t.data,i.label=2;case 2:return[4,p.listCountry({id:(null===(d=this.allowedCountryIds)||void 0===d?void 0:d.length)?{in:this.allowedCountryIds}:void 0,locale:h.getCurrentLocale()})];case 3:return e=i.sent(),o=e.data||[],s=h.getCurrentRouting(),(null===(a=null==s?void 0:s.countryCodes)||void 0===a?void 0:a.length)?o=o.filter((function(t){var i;return t.iso2&&(null===(i=s.countryCodes)||void 0===i?void 0:i.includes(t.iso2))})):(r=h.getRoutings().filter((function(t){return t.id!==h.getStorefrontRoutingId()})),o=o.filter((function(t){return t.iso2&&!r.some((function(i){var e;return null===(e=i.countryCodes)||void 0===e?void 0:e.includes(t.iso2)}))}))),this.countries=o,1!==this.countries.length||this.country?this.countries.length&&this.myCountryCode&&!this.country&&((n=this.countries.find((function(t){return t.iso2===l.myCountryCode})))?this.onCountryChange(n.id):this.onCountryChange(this.countries[0].id)):this.onCountryChange(this.countries[0].id),[3,5];case 4:return i.sent(),[3,5];case 5:return[2]}}))}))},this.listStates=function(){return t(s,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.country)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,p.listState({countryId:{eq:this.country.id},locale:h.getCurrentLocale()})];case 2:return t=i.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}}))}))},this.listCities=function(){return t(s,void 0,void 0,(function(){var t,e,o;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.state)||void 0===e?void 0:e.id)||!(null===(o=this.country)||void 0===o?void 0:o.id))return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,p.listCity({stateId:{eq:this.state.id},countryId:{eq:this.country.id}})];case 2:return t=i.sent(),this.cities=t.data||[],[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}}))}))},this.listDistricts=function(){return t(s,void 0,void 0,(function(){var t,e,o,s;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.city)||void 0===e?void 0:e.id)||this.isDistrictHidden)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,p.listDistrict({cityId:{eq:this.city.id},stateId:(null===(o=this.state)||void 0===o?void 0:o.id)?{eq:null===(s=this.state)||void 0===s?void 0:s.id}:void 0})];case 2:return t=i.sent(),this.districts=t.data||[],this.districts.length?this.address.isDistrictRequired=!0:this.address.isDistrictRequired=!1,[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}}))}))},this.modelToOption=function(t){return{label:t.name,value:t.id+""}},this.onFirstNameChange=function(t){s.firstNameChangeCallback&&s.firstNameChangeCallback(t),s.address.firstName=t},this.onLastNameChange=function(t){s.lastNameChangeCallback&&s.lastNameChangeCallback(t),s.address.lastName=t},this.onPhoneChange=function(t){s.address.phone=t},this.onIdentityNumberChange=function(t){t?t.length<=11&&(s.address.identityNumber=t):s.address.identityNumber=""},this.onAddressTitleChange=function(t){s.address.title=t},this.onAddressLine1Change=function(t){s.address.addressLine1=t},this.onAddressLine2Change=function(t){s.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){s.address.postalCode=t},this.onCountryChange=function(t){var i;if((null===(i=s.country)||void 0===i?void 0:i.id)!==t){var e=s.countries.find((function(i){return i.id===t}));s.address.country=new n({id:(null==e?void 0:e.id)||null,name:(null==e?void 0:e.name)||"",code:(null==e?void 0:e.iso3)||null,iso2:(null==e?void 0:e.iso2)||null,iso3:(null==e?void 0:e.iso3)||null}),s.address.state=null,s.address.city=null,s.address.district=null,s.address.phone=null,s.states=[],s.cities=[],s.districts=[],s.listStates()}},this.onStateChange=function(t){var i;if((null===(i=s.state)||void 0===i?void 0:i.id)!==t){var e=s.states.find((function(i){return i.id===t}));s.address.state={id:e.id,name:null==e?void 0:e.name,code:null==e?void 0:e.stateCode},s.address.isFreeTextCity||(s.address.city=null,s.cities=[],s.listCities()),s.address.isFreeTextDistrict||(s.address.district=null,s.districts=[])}},this.onCityChange=function(t){var i;if((null===(i=s.city)||void 0===i?void 0:i.id)!==t){var e=s.cities.find((function(i){return i.id===t}));s.address.city=new r({id:e.id,name:e.name}),s.address.isFreeTextDistrict||(s.address.district=null,s.districts=[],s.listDistricts())}},this.onCityInputChange=function(t){s.districts=[],s.address.city=new r({id:void 0,name:t})},this.onDistrictChange=function(t){var i;if((null===(i=s.district)||void 0===i?void 0:i.id)!==t){var e=s.districts.find((function(i){return i.id===t}));s.address.district=new d({id:e.id,name:e.name}),s.address.region=null}},this.onDistrictInputChange=function(t){s.address.district=new d({id:void 0,name:t})},this.onRegionChange=function(t){var i,e,o;if((null===(i=s.region)||void 0===i?void 0:i.id)!==t){var r=null===(o=null===(e=s.shippingZoneDistrict)||void 0===e?void 0:e.regions)||void 0===o?void 0:o.find((function(i){return i.id===t}));s.address.region=new a({id:r.id,name:r.name})}},this.onCorporateChange=function(t){s.isCorporate=t,t||(s.address.company=null,s.address.taxNumber=null,s.address.taxOffice=null)},this.onCompanyChange=function(t){s.address.company=t},this.onTaxNumberChange=function(t){s.address.taxNumber=t},this.onTaxOfficeChange=function(t){s.address.taxOffice=t},this.address=e.address,this.isCorporate=e.isCorporate||!1,this.isErrorsVisible=e.isErrorsVisible||!1,this.isCustomerAddress=e.isCustomerAddress||!1,this.allowedCountryIds=e.allowedCountryIds,this.allowCorporateInfo=e.allowCorporateInfo||!1,this.allowTitleChange=e.allowTitleChange||!1,this.firstNameChangeCallback=e.firstNameChangeCallback||null,this.lastNameChangeCallback=e.lastNameChangeCallback||null,o(this,{firstNameChangeCallback:!1,lastNameChangeCallback:!1}),this.fillDropdownOptions()}return Object.defineProperty(f.prototype,"firstName",{get:function(){return this.address.firstName},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"lastName",{get:function(){return this.address.lastName},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"phone",{get:function(){return this.address.phone},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"identityNumber",{get:function(){return this.address.identityNumber},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZone",{get:function(){var t,i=this;return null===(t=this.address.shippingZones)||void 0===t?void 0:t.find((function(t){var e;return t.countryId===(null===(e=i.address.country)||void 0===e?void 0:e.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneState",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZone)||void 0===t?void 0:t.states)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.state)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneCity",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZoneState)||void 0===t?void 0:t.cities)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.city)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneDistrict",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZoneCity)||void 0===t?void 0:t.districts)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.district)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneRegions",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZoneDistrict)||void 0===t?void 0:t.regions)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.region)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"country",{get:function(){return this.address.country},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"state",{get:function(){return this.address.state},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"city",{get:function(){return this.address.city},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"district",{get:function(){return this.address.district},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"region",{get:function(){return this.address.region},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"countryOptions",{get:function(){var t=this.countries.map(this.modelToOption);return t.sort((function(t,i){return l(t.label,i.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"stateOptions",{get:function(){var t,i,e=this,o=this.states.map(this.modelToOption);return this.shippingZone&&!this.shippingZone.showAllStates&&(null===(i=null===(t=this.shippingZone)||void 0===t?void 0:t.states)||void 0===i?void 0:i.length)&&(o=o.filter((function(t){var i,o;return null===(o=null===(i=e.shippingZone)||void 0===i?void 0:i.states)||void 0===o?void 0:o.some((function(i){return i.id===t.value}))}))),o.sort((function(t,i){return l(t.label,i.label)})),o},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"cityOptions",{get:function(){var t,i,e,o=this,r=s(this.cities,"order").map(this.modelToOption);return this.shippingZone&&!(null===(t=this.shippingZoneState)||void 0===t?void 0:t.showAllCities)&&(null===(e=null===(i=this.shippingZoneState)||void 0===i?void 0:i.cities)||void 0===e?void 0:e.length)&&(r=r.filter((function(t){var i,e;return null===(e=null===(i=o.shippingZoneState)||void 0===i?void 0:i.cities)||void 0===e?void 0:e.some((function(i){return i.id===t.value}))}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"districtOptions",{get:function(){var t,i,o,s=this,r=this.districts.map((function(t){return e(e({},t),{name:u(t.name)})})).map(this.modelToOption);return this.shippingZone&&!(null===(t=this.shippingZoneCity)||void 0===t?void 0:t.showAllDistricts)&&(null===(o=null===(i=this.shippingZoneCity)||void 0===i?void 0:i.districts)||void 0===o?void 0:o.length)&&(r=r.filter((function(t){var i,e;return null===(e=null===(i=s.shippingZoneCity)||void 0===i?void 0:i.districts)||void 0===e?void 0:e.some((function(i){return i.id===t.value}))}))),r.sort((function(t,i){return l(t.label,i.label)})),r},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"regionOptions",{get:function(){var t,i,e=(null===(i=null===(t=this.shippingZoneDistrict)||void 0===t?void 0:t.regions)||void 0===i?void 0:i.map(this.modelToOption))||[];return e.sort((function(t,i){return l(t.label,i.label)})),e},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isFreeTextCity",{get:function(){var t=this;return c.some((function(i){var e,o;return(null===(o=null===(e=t.address.country)||void 0===e?void 0:e.iso2)||void 0===o?void 0:o.toLowerCase())===i.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isDistrictHidden",{get:function(){var t=this;return m.some((function(i){var e,o;return(null===(o=null===(e=t.address.country)||void 0===e?void 0:e.iso2)||void 0===o?void 0:o.toLowerCase())===i.toLowerCase()}))},enumerable:!1,configurable:!0}),f}();export{f as default};
1
+ import{__awaiter as t,__generator as i,__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import s from"lodash/sortBy";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"@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/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{IkasOrderAddressCity as r}from"../../../../models/data/order/address/city/index.js";import{IkasOrderAddressCountry as n}from"../../../../models/data/order/address/country/index.js";import{IkasOrderAddressDistrict as d}from"../../../../models/data/order/address/district/index.js";import{IkasOrderAddressRegion as a}from"../../../../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/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/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"../../../../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{stringSorter as l,capitalize as u}from"../../../../utils/helper.js";import{FREE_TEXT_CITY_COUNTRY_LIST as c,DISTRICT_HIDDEN_COUNTRY_LIST as m}from"../../../../utils/constants.js";import p from"../../../../store/location/index.js";import{IkasStorefrontConfig as h}from"@ikas/storefront-config";var f=function(){function f(e){var s=this;this.isCorporate=!1,this.isErrorsVisible=!1,this.allowedCountryIds=null,this.allowCorporateInfo=!1,this.allowTitleChange=!1,this.firstNameChangeCallback=null,this.lastNameChangeCallback=null,this.countries=[],this.states=[],this.cities=[],this.districts=[],this.myCountryCode=null,this.fillDropdownOptions=function(){return t(s,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.listCountries()];case 1:return t.sent(),[4,this.listStates()];case 2:return t.sent(),[4,this.listCities()];case 3:return t.sent(),[4,this.listDistricts()];case 4:return t.sent(),[2]}}))}))},this.listCountries=function(){return t(s,void 0,void 0,(function(){var t,e,o,s,r,n,d,a,l=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),this.myCountryCode?[3,2]:[4,p.getMyCountry()];case 1:t=i.sent(),this.myCountryCode=t.data,i.label=2;case 2:return[4,p.listCountry({id:(null===(d=this.allowedCountryIds)||void 0===d?void 0:d.length)?{in:this.allowedCountryIds}:void 0,locale:h.getCurrentLocale()})];case 3:return e=i.sent(),o=e.data||[],s=h.getCurrentRouting(),(null===(a=null==s?void 0:s.countryCodes)||void 0===a?void 0:a.length)?o=o.filter((function(t){var i;return t.iso2&&(null===(i=s.countryCodes)||void 0===i?void 0:i.includes(t.iso2))})):(r=h.getRoutings().filter((function(t){return t.id!==h.getStorefrontRoutingId()})),o=o.filter((function(t){return t.iso2&&!r.some((function(i){var e;return null===(e=i.countryCodes)||void 0===e?void 0:e.includes(t.iso2)}))}))),this.countries=o,1!==this.countries.length||this.country?this.countries.length&&this.myCountryCode&&!this.country&&((n=this.countries.find((function(t){return t.iso2===l.myCountryCode})))?this.onCountryChange(n.id):this.onCountryChange(this.countries[0].id)):this.onCountryChange(this.countries[0].id),[3,5];case 4:return i.sent(),[3,5];case 5:return[2]}}))}))},this.listStates=function(){return t(s,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.country)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,p.listState({countryId:{eq:this.country.id},locale:h.getCurrentLocale()})];case 2:return t=i.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}}))}))},this.listCities=function(){return t(s,void 0,void 0,(function(){var t,e,o;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.state)||void 0===e?void 0:e.id)||!(null===(o=this.country)||void 0===o?void 0:o.id))return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,p.listCity({stateId:{eq:this.state.id},countryId:{eq:this.country.id}})];case 2:return t=i.sent(),this.cities=t.data||[],[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}}))}))},this.listDistricts=function(){return t(s,void 0,void 0,(function(){var t,e,o,s;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.city)||void 0===e?void 0:e.id)||this.isDistrictHidden)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,p.listDistrict({cityId:{eq:this.city.id},stateId:(null===(o=this.state)||void 0===o?void 0:o.id)?{eq:null===(s=this.state)||void 0===s?void 0:s.id}:void 0})];case 2:return t=i.sent(),this.districts=t.data||[],this.districts.length?this.address.isDistrictRequired=!0:this.address.isDistrictRequired=!1,[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}}))}))},this.modelToOption=function(t){return{label:t.name,value:t.id+""}},this.onFirstNameChange=function(t){s.firstNameChangeCallback&&s.firstNameChangeCallback(t),s.address.firstName=t},this.onLastNameChange=function(t){s.lastNameChangeCallback&&s.lastNameChangeCallback(t),s.address.lastName=t},this.onPhoneChange=function(t){s.address.phone=t},this.onIdentityNumberChange=function(t){t?t.length<=11&&(s.address.identityNumber=t):s.address.identityNumber=""},this.onAddressTitleChange=function(t){s.address.title=t},this.onAddressLine1Change=function(t){s.address.addressLine1=t},this.onAddressLine2Change=function(t){s.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){s.address.postalCode=t},this.onCountryChange=function(t){var i;if((null===(i=s.country)||void 0===i?void 0:i.id)!==t){var e=s.countries.find((function(i){return i.id===t}));s.address.country=new n({id:(null==e?void 0:e.id)||null,name:(null==e?void 0:e.name)||"",code:(null==e?void 0:e.iso3)||null,iso2:(null==e?void 0:e.iso2)||null,iso3:(null==e?void 0:e.iso3)||null}),s.address.state=null,s.address.city=null,s.address.district=null,s.address.phone=null,s.states=[],s.cities=[],s.districts=[],s.listStates()}},this.onStateChange=function(t){var i;if((null===(i=s.state)||void 0===i?void 0:i.id)!==t){var e=s.states.find((function(i){return i.id===t}));s.address.state={id:e.id,name:null==e?void 0:e.name,code:null==e?void 0:e.stateCode},s.address.isFreeTextCity||(s.address.city=null,s.cities=[],s.listCities()),s.address.isFreeTextDistrict||(s.address.district=null,s.districts=[])}},this.onCityChange=function(t){var i;if((null===(i=s.city)||void 0===i?void 0:i.id)!==t){var e=s.cities.find((function(i){return i.id===t}));s.address.city=new r({id:e.id,name:e.name}),s.address.isFreeTextDistrict||(s.address.district=null,s.districts=[],s.listDistricts())}},this.onCityInputChange=function(t){s.districts=[],s.address.city=new r({id:void 0,name:t})},this.onDistrictChange=function(t){var i;if((null===(i=s.district)||void 0===i?void 0:i.id)!==t){var e=s.districts.find((function(i){return i.id===t}));s.address.district=new d({id:e.id,name:e.name}),s.address.region=null}},this.onDistrictInputChange=function(t){s.address.district=new d({id:void 0,name:t})},this.onRegionChange=function(t){var i,e,o;if((null===(i=s.region)||void 0===i?void 0:i.id)!==t){var r=null===(o=null===(e=s.shippingZoneDistrict)||void 0===e?void 0:e.regions)||void 0===o?void 0:o.find((function(i){return i.id===t}));s.address.region=new a({id:r.id,name:r.name})}},this.onCorporateChange=function(t){s.isCorporate=t,t||(s.address.company=null,s.address.taxNumber=null,s.address.taxOffice=null)},this.onCompanyChange=function(t){s.address.company=t},this.onTaxNumberChange=function(t){s.address.taxNumber=t},this.onTaxOfficeChange=function(t){s.address.taxOffice=t},this.address=e.address,this.isCorporate=e.isCorporate||!1,this.isErrorsVisible=e.isErrorsVisible||!1,this.isCustomerAddress=e.isCustomerAddress||!1,this.allowedCountryIds=e.allowedCountryIds,this.allowCorporateInfo=e.allowCorporateInfo||!1,this.allowTitleChange=e.allowTitleChange||!1,this.firstNameChangeCallback=e.firstNameChangeCallback||null,this.lastNameChangeCallback=e.lastNameChangeCallback||null,o(this,{firstNameChangeCallback:!1,lastNameChangeCallback:!1}),this.fillDropdownOptions()}return Object.defineProperty(f.prototype,"firstName",{get:function(){return this.address.firstName},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"lastName",{get:function(){return this.address.lastName},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"phone",{get:function(){return this.address.phone},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"identityNumber",{get:function(){return this.address.identityNumber},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZone",{get:function(){var t,i=this;return null===(t=this.address.shippingZones)||void 0===t?void 0:t.find((function(t){var e;return t.countryId===(null===(e=i.address.country)||void 0===e?void 0:e.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneState",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZone)||void 0===t?void 0:t.states)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.state)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneCity",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZoneState)||void 0===t?void 0:t.cities)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.city)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneDistrict",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZoneCity)||void 0===t?void 0:t.districts)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.district)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"shippingZoneRegions",{get:function(){var t,i,e=this;return null===(i=null===(t=this.shippingZoneDistrict)||void 0===t?void 0:t.regions)||void 0===i?void 0:i.find((function(t){var i;return t.id===(null===(i=e.address.region)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"country",{get:function(){return this.address.country},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"state",{get:function(){return this.address.state},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"city",{get:function(){return this.address.city},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"district",{get:function(){return this.address.district},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"region",{get:function(){return this.address.region},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"countryOptions",{get:function(){var t=this.countries.map(this.modelToOption);return t.sort((function(t,i){return l(t.label,i.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"stateOptions",{get:function(){var t,i,e=this,o=this.states.map(this.modelToOption);return this.shippingZone&&!this.shippingZone.showAllStates&&(null===(i=null===(t=this.shippingZone)||void 0===t?void 0:t.states)||void 0===i?void 0:i.length)&&(o=o.filter((function(t){var i,o;return null===(o=null===(i=e.shippingZone)||void 0===i?void 0:i.states)||void 0===o?void 0:o.some((function(i){return i.id===t.value}))}))),o.sort((function(t,i){return l(t.label,i.label)})),o},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"cityOptions",{get:function(){var t,i,e,o=this,r=s(this.cities,"order").map(this.modelToOption);return this.shippingZone&&!(null===(t=this.shippingZoneState)||void 0===t?void 0:t.showAllCities)&&(null===(e=null===(i=this.shippingZoneState)||void 0===i?void 0:i.cities)||void 0===e?void 0:e.length)&&(r=r.filter((function(t){var i,e;return null===(e=null===(i=o.shippingZoneState)||void 0===i?void 0:i.cities)||void 0===e?void 0:e.some((function(i){return i.id===t.value}))}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"districtOptions",{get:function(){var t,i,o,s=this,r=this.districts.map((function(t){return e(e({},t),{name:u(t.name)})})).map(this.modelToOption);return this.shippingZone&&!(null===(t=this.shippingZoneCity)||void 0===t?void 0:t.showAllDistricts)&&(null===(o=null===(i=this.shippingZoneCity)||void 0===i?void 0:i.districts)||void 0===o?void 0:o.length)&&(r=r.filter((function(t){var i,e;return null===(e=null===(i=s.shippingZoneCity)||void 0===i?void 0:i.districts)||void 0===e?void 0:e.some((function(i){return i.id===t.value}))}))),r.sort((function(t,i){return l(t.label,i.label)})),r},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"regionOptions",{get:function(){var t,i,e=(null===(i=null===(t=this.shippingZoneDistrict)||void 0===t?void 0:t.regions)||void 0===i?void 0:i.map(this.modelToOption))||[];return e.sort((function(t,i){return l(t.label,i.label)})),e},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isFreeTextCity",{get:function(){var t=this;return c.some((function(i){var e,o;return(null===(o=null===(e=t.address.country)||void 0===e?void 0:e.iso2)||void 0===o?void 0:o.toLowerCase())===i.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isDistrictHidden",{get:function(){var t=this;return m.some((function(i){var e,o;return(null===(o=null===(e=t.address.country)||void 0===e?void 0:e.iso2)||void 0===o?void 0:o.toLowerCase())===i.toLowerCase()}))},enumerable:!1,configurable:!0}),f}();export{f as default};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";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{IkasProductOptionType as a}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/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/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/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"../../../../../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{formatDate as i}from"../../../../../utils/helper.js";import"@ikas/storefront-config";import{useTranslation as o}from"../../../../../utils/i18n.js";import{Modal as r}from"../../modal/index.js";import{BundleProductItem as s}from"./bundle-product-item/index.js";import m from"./svg/arrow-right.js";import n from"./svg/arrow-down.js";import d from"./style.module.scss.js";var l=t((function(t){var l,c,u,p,v;t.vm,t.currencyCode;var j=t.cartItem,x=t.stockErrorItem,f=t.onChange,g=t.isSuccessPageSummary,E=o().t,N=!x,y=e.useRef(null),h=e.useState(0),P=h[0],b=h[1],C=e.useState(!1),k=C[0],O=C[1],w=e.useState(!1),T=w[0],I=w[1];e.useEffect((function(){if(y.current){var e=24;Array.from(y.current.children).map((function(t){return e=e+t.clientHeight+12})),b(e)}}),[]),e.useEffect((function(){y.current&&(y.current.style.maxHeight=T?"".concat(P,"px"):"0")}),[T]);var R=e.useMemo((function(){var t;return e.createElement("div",null,null===(t=j.options)||void 0===t?void 0:t.map((function(t){switch(t.type){case a.TEXT:case a.TEXT_AREA:case a.CHOICE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return e.name||e.value})).join(", ")));case a.DATE_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,(a=i(new Date(t)).split(" ")).splice(-1),a.join(" ");var t,a})).join(", ")));case a.FILE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,decodeURIComponent(t.split("/")[t.split("/").length-1]);var t})).join(", ")));case a.CHECKBOX:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.length&&"true"===t.values[0].value?E("checkout-page:yes"):E("checkout-page:no")));case a.COLOR_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionsHorContainer},t.values.map((function(t,a){return e.createElement("div",{key:a,className:d.OptionColorValue,style:{backgroundColor:t.value}})}))))}})))}),[]),S=[d.BundleProductsContainer,T?d.VisibleBundleProducts:""].join(" "),Q=(null===(l=j.variant.bundleProducts)||void 0===l?void 0:l.reduce((function(e,t){return e+t.quantity}),0))||0;return e.createElement(e.Fragment,null,e.createElement("div",{className:d.CheckoutItem},e.createElement("div",{className:[d.ImageContainer,g?d.SuccessPageImageContainer:""].join(" ")},e.createElement("img",{className:d.Image,src:null===(c=j.variant.mainImage)||void 0===c?void 0:c.thumbnailSrc}),e.createElement("div",{className:d.QuantityCircle},j.quantity)),e.createElement("div",{className:d.Center},!!x&&e.createElement("div",{className:d.StockErrorItemMain},e.createElement("span",null,j.quantity," ",E("checkout-page:quantity")),e.createElement("span",null,e.createElement(m,null)),e.createElement("span",null,x.stockCount<0?0:x.stockCount," ",E("checkout-page:quantity"))),e.createElement("div",{className:[d.Name,g?d.SuccessPageName:""].join(" ")},j.variant.name),e.createElement("div",{className:[d.LightText,g?"":d.Small].join(" ")},null===(u=j.variant.variantValues)||void 0===u?void 0:u.map((function(e){return e.variantValueName})).join(" / ")),!!g&&N&&e.createElement("div",{className:[d.Right,g?d.SuccessPagePriceMain:""].join(" ")},e.createElement("div",{className:d.Price},!!j.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},j.formattedOverridenPriceWithQuantity),e.createElement("span",{className:d.FinalPrice},j.formattedFinalPriceWithQuantity)),j.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},j.unitPriceText)),!!(null===(p=j.options)||void 0===p?void 0:p.length)&&e.createElement("div",{className:d.OptionsText,onClick:function(){return O(!0)}},E("checkout-page:customizedProduct")),j.variant.bundleProducts&&0!==j.variant.bundleProducts.length&&e.createElement("div",{className:d.BundleProducts,onClick:function(){I(!T),f&&setTimeout((function(){f(!T)}),200)}},E("checkout-page:bundleProductsQuantity",{value:Q}),e.createElement("span",{style:{paddingTop:2,transform:T?void 0:"rotate(180deg)"}},e.createElement(n,null))),!!k&&e.createElement(r,{title:j.variant.name,modalContent:R,onClose:function(){return O(!1)}})),N&&!g&&e.createElement("div",{className:d.Right},e.createElement("div",{className:d.Price},!!j.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},j.formattedOverridenPriceWithQuantity),j.formattedFinalPriceWithQuantity),j.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},j.unitPriceText))),e.createElement("div",{ref:y,className:S},null===(v=j.variant.bundleProducts)||void 0===v?void 0:v.map((function(t){return e.createElement(s,{bundleProduct:t})}))))}));export{l as CartItem};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";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{IkasProductOptionType as a}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"../../../../../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/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/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"../../../../../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{formatDate as i}from"../../../../../utils/helper.js";import"@ikas/storefront-config";import{useTranslation as o}from"../../../../../utils/i18n.js";import{Modal as r}from"../../modal/index.js";import{BundleProductItem as s}from"./bundle-product-item/index.js";import m from"./svg/arrow-right.js";import n from"./svg/arrow-down.js";import d from"./style.module.scss.js";var l=t((function(t){var l,c,u,p,v;t.vm,t.currencyCode;var j=t.cartItem,x=t.stockErrorItem,f=t.onChange,g=t.isSuccessPageSummary,E=o().t,N=!x,y=e.useRef(null),h=e.useState(0),P=h[0],b=h[1],C=e.useState(!1),k=C[0],O=C[1],w=e.useState(!1),T=w[0],I=w[1];e.useEffect((function(){if(y.current){var e=24;Array.from(y.current.children).map((function(t){return e=e+t.clientHeight+12})),b(e)}}),[]),e.useEffect((function(){y.current&&(y.current.style.maxHeight=T?"".concat(P,"px"):"0")}),[T]);var R=e.useMemo((function(){var t;return e.createElement("div",null,null===(t=j.options)||void 0===t?void 0:t.map((function(t){switch(t.type){case a.TEXT:case a.TEXT_AREA:case a.CHOICE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return e.name||e.value})).join(", ")));case a.DATE_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,(a=i(new Date(t)).split(" ")).splice(-1),a.join(" ");var t,a})).join(", ")));case a.FILE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,decodeURIComponent(t.split("/")[t.split("/").length-1]);var t})).join(", ")));case a.CHECKBOX:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.length&&"true"===t.values[0].value?E("checkout-page:yes"):E("checkout-page:no")));case a.COLOR_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionsHorContainer},t.values.map((function(t,a){return e.createElement("div",{key:a,className:d.OptionColorValue,style:{backgroundColor:t.value}})}))))}})))}),[]),S=[d.BundleProductsContainer,T?d.VisibleBundleProducts:""].join(" "),Q=(null===(l=j.variant.bundleProducts)||void 0===l?void 0:l.reduce((function(e,t){return e+t.quantity}),0))||0;return e.createElement(e.Fragment,null,e.createElement("div",{className:d.CheckoutItem},e.createElement("div",{className:[d.ImageContainer,g?d.SuccessPageImageContainer:""].join(" ")},e.createElement("img",{className:d.Image,src:null===(c=j.variant.mainImage)||void 0===c?void 0:c.thumbnailSrc}),e.createElement("div",{className:d.QuantityCircle},j.quantity)),e.createElement("div",{className:d.Center},!!x&&e.createElement("div",{className:d.StockErrorItemMain},e.createElement("span",null,j.quantity," ",E("checkout-page:quantity")),e.createElement("span",null,e.createElement(m,null)),e.createElement("span",null,x.stockCount<0?0:x.stockCount," ",E("checkout-page:quantity"))),e.createElement("div",{className:[d.Name,g?d.SuccessPageName:""].join(" ")},j.variant.name),e.createElement("div",{className:[d.LightText,g?"":d.Small].join(" ")},null===(u=j.variant.variantValues)||void 0===u?void 0:u.map((function(e){return e.variantValueName})).join(" / ")),!!g&&N&&e.createElement("div",{className:[d.Right,g?d.SuccessPagePriceMain:""].join(" ")},e.createElement("div",{className:d.Price},!!j.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},j.formattedOverridenPriceWithQuantity),e.createElement("span",{className:d.FinalPrice},j.formattedFinalPriceWithQuantity)),j.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},j.unitPriceText)),!!(null===(p=j.options)||void 0===p?void 0:p.length)&&e.createElement("div",{className:d.OptionsText,onClick:function(){return O(!0)}},E("checkout-page:customizedProduct")),j.variant.bundleProducts&&0!==j.variant.bundleProducts.length&&e.createElement("div",{className:d.BundleProducts,onClick:function(){I(!T),f&&setTimeout((function(){f(!T)}),200)}},E("checkout-page:bundleProductsQuantity",{value:Q}),e.createElement("span",{style:{paddingTop:2,transform:T?void 0:"rotate(180deg)"}},e.createElement(n,null))),!!k&&e.createElement(r,{title:j.variant.name,modalContent:R,onClose:function(){return O(!1)}})),N&&!g&&e.createElement("div",{className:d.Right},e.createElement("div",{className:d.Price},!!j.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},j.formattedOverridenPriceWithQuantity),j.formattedFinalPriceWithQuantity),j.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},j.unitPriceText))),e.createElement("div",{ref:y,className:S},null===(v=j.variant.bundleProducts)||void 0===v?void 0:v.map((function(t){return e.createElement(s,{bundleProduct:t})}))))}));export{l as CartItem};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as o}from"mobx-react-lite";import a from"lodash/sortBy";import c from"../input-with-button/index.js";import l from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as u}from"../../../../utils/currency.js";import{useTranslation as s}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import C from"../svg/arrow-down.js";import h from"../svg/cross.js";import v from"../svg/gift.js";import f from"../../styles/common.module.scss.js";import g from"./style.module.scss.js";import k from"../svg/ikas.js";import{Button as N}from"../button/index.js";var y;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS"}(y||(y={}));var S=o((function(e){var t,o,a=e.vm,c=e.allowExpand,d=e.isSuccessPageSummary,p=a.checkout,E=s().t,h=n.useState(!c),v=h[0],f=h[1],N=n.useState(!1),S=N[0],j=N[1],I=n.useState(null),_=I[0],w=I[1],A=n.useState(0),D=A[0],R=A[1],L=n.useState(null),U=L[0],B=L[1],F=n.useState(!1),M=F[0],V=F[1],X=n.useState(!1),G=X[0],q=X[1],H=n.useState(!1),z=H[0],$=H[1];n.useEffect((function(){c&&(v?U&&R(U.getBoundingClientRect().height):R(0))}),[v,U,c,M,G,S,z]);var K=n.useMemo((function(){switch(_){case y.COUPON_CODE_NOT_EXIST:return E("checkout-page:giftCodeErrorDescription");case y.COUPON_CODE_NOT_EXIST_FOR_GUESS:return E("checkout-page:mustBeSignInToApplyCampaign");default:return""}}),[_]),Q=[g.CartSummary,c?g.HideOnDesktop:"",d?g.SuccessPageCartSummary:""].join(" "),J=c?{height:D+"px"}:void 0,W=[g.ArrowDown,v?g.Rotated:""].join(" ");return p?n.createElement(n.Fragment,null,!!c&&n.createElement(n.Fragment,null,n.createElement("div",{id:"checkout-mobile-summary-header"}),n.createElement("div",{className:g.ExpandHeader,onClick:function(){if(!v){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}f(!v)}},n.createElement("div",{className:g.Left},E("checkout-page:summary")),n.createElement("div",{className:g.Price},n.createElement("span",{className:g.PriceText},"".concat(u(a.finalPrice||0,p.currencyCode,p.currencySymbol)," (").concat(p.itemQuantity," ").concat(E("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:W},n.createElement(C,null))))),n.createElement("div",{className:Q},n.createElement("div",{className:[g.DetailsContainer,d?g.SuccessPageDetailContainer:""].join(" "),style:J},n.createElement("div",{className:g.Details,ref:B},n.createElement("div",{className:g.ItemsContainer},n.createElement("div",null,p.items.map((function(e,t){return n.createElement(m,{key:t,vm:a,cartItem:e,currencyCode:p.currencyCode,onChange:$,isSuccessPageSummary:d})})))),n.createElement("div",{className:g.Divider}),n.createElement("div",{className:g.SubTotalInfo},S&&n.createElement("div",{className:g.NotificationContainer},n.createElement(l,{type:"warning",title:E("checkout-page:giftCodeErrorTitle"),content:K,onClose:function(){j(!1),w(null)}})),n.createElement(T,{label:E("checkout-page:subtotal"),value:p.formattedTotalPrice,tooltipText:E("checkout-page:subtotalTooltip"),hideMarginBottom:!a.isCouponCodeVisible}),!!(null===(t=p.shippingLines)||void 0===t?void 0:t.length)&&n.createElement(T,{label:E("checkout-page:cartShippingTitle"),value:p.shippingTotal?p.formattedShippingTotal:E("checkout-page:free")}),!!a.installmentExtraPrice&&n.createElement(T,{label:E("checkout-page:cartInterest"),value:u(a.installmentExtraPrice,p.currencyCode,p.currencySymbol)}),n.createElement(b,{vm:a}),n.createElement(x,{vm:a}),(a.step===r.SUCCESS&&(!!a.checkout.note||!!a.checkout.appliedCouponCode)||a.step!==r.SUCCESS)&&a.isCouponCodeVisible&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(O,{vm:a,isAddingCoupon:G,setAddingCoupon:q,setCouponError:j,setCouponErrorCode:w}),n.createElement(P,{vm:a,isAddingNote:M,setAddingNote:V})),n.createElement("div",{className:[g.TotalContainer,d?g.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},E("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:g.TotalPricesContainer},n.createElement("div",{className:g.TotalPrice},u(a.finalPrice||0,p.currencyCode,p.currencySymbol)),!!p.$totalTax&&!!(null===(o=a.customizationProps)||void 0===o?void 0:o.showTax)&&n.createElement("div",{className:[g.TotalTax].join(" ")},E("checkout-page:cartTaxTitle")+" "+p.$formattedTotalTax)))),!d&&n.createElement("div",{className:g.PoweredBy},n.createElement("span",null,"powered by"),n.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},n.createElement(k,null))))))):null})),T=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,c=e.hideMarginBottom;return n.createElement("div",{className:[g.InfoRow,c?g.hideMb:""].join(" ")},n.createElement("div",{className:g.Label},n.createElement("span",null,t),!!a&&n.createElement(E,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:g.Value},o))})),b=o((function(e){var t=e.vm,o=s().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").map((function(e,a){return n.createElement("div",{className:g.InfoRow,key:a},n.createElement("div",{className:g.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),x=o((function(e){var t,o,a=e.vm,c=s().t;return a.checkout?n.createElement(n.Fragment,null,a.step!==r.SUCCESS&&((null===(t=a.checkout.selectedPaymentGateway)||void 0===t?void 0:t.getCalculatedAdditionalPrices(a.checkout.totalFinalPrice||0,a.checkout.shippingLines||null))||[]).filter((function(e){return 0!==e.amount})).map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,a.checkout.currencyCode,a.checkout.currencySymbol))))})),null===(o=a.checkout.giftPackageLines)||void 0===o?void 0:o.map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},n.createElement("div",{className:g.GiftLabel},n.createElement(v,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,c("checkout-page:giftPackage")))),n.createElement("div",{className:g.Value},n.createElement("span",null,u(e.price,a.checkout.currencyCode,a.checkout.currencySymbol))))}))):null})),O=o((function(o){var a=o.vm,l=o.isAddingCoupon,i=o.setAddingCoupon,m=o.setCouponError,E=o.setCouponErrorCode,C=o.isOpenCouponCode,v=s().t,k=n.useState(""),y=k[0],S=k[1],T=n.useState(!1),b=T[0],x=T[1],O=n.useRef(null);n.useEffect((function(){l&&O.current&&O.current.focus()}),[l]);var P=function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=y,x(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),x(!1),S(""),!a.checkout.appliedCouponCode||a.couponError?[3,3]:(i(!1),m(!1),E(null),[4,a.reInitPaymentMethod()]);case 2:return e.sent(),[3,4];case 3:a.checkout.couponCode=null,m(!0),E(a.couponError),e.label=4;case 4:return[2]}}))}))},j=function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=null,x(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),x(!1),[2]}}))}))},I=a.step===r.SUCCESS,_=a.step===r.SHIPPING;if(I&&!a.checkout.appliedCouponCode)return null;var w=a.checkout.couponAdjustment,A=!(!a.checkout.appliedCouponCode||l),D=!!a.checkout.appliedCouponCode&&C;return n.createElement(n.Fragment,null,!!C&&n.createElement(n.Fragment,null,n.createElement("div",{className:[g.CartSummary,g.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:f.FormSectionTitle},n.createElement("div",{style:{paddingBottom:D?0:6},className:f.Title},v("checkout-page:couponCode")),D&&n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline,g.Light].join(" ")},n.createElement("span",{className:[g.AppliedCoupon,g.AppliedCouponBgGray].join(" ")},n.createElement("span",{className:g.CouponCode},a.checkout.appliedCouponCode),!I&&n.createElement("span",{className:g.ClearCoupon,onClick:j},n.createElement(h,null))))))),A&&!_&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:g.InfoRow},!a.checkout.appliedCouponCode&&!l&&a.isCouponCodeVisible&&n.createElement("div",{className:g.ActionTextBtn,onClick:function(){return i(!0)}},v("checkout-page:addCouponCode")),l&&!C&&n.createElement(c,{value:y,placeholder:v("checkout-page:couponCode"),buttonLabel:v("checkout-page:actions.apply"),inputRef:O,onClick:P,isLoading:b,onChange:S}),C&&!D&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&P()},className:g.OpenCouponCodeMain},n.createElement(d,{label:v("checkout-page:couponCode"),type:p.TEXT,value:y,onChange:S}),n.createElement(N,{style:{width:"33%"},text:v("checkout-page:actions.apply"),isLoading:b,onClick:P})),A&&n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline,g.Light].join(" ")},v("checkout-page:couponCode"),n.createElement("span",{className:[g.AppliedCoupon,a.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},n.createElement("span",{className:g.CouponCode},a.checkout.appliedCouponCode),a.step!==r.SUCCESS&&a.isCouponCodeRequirementDefult&&n.createElement("span",{className:g.ClearCoupon,onClick:j},n.createElement(h,null)))),A&&n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===(null==w?void 0:w.type)?"- ":"")," ",n.createElement("span",null,u((null==w?void 0:w.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)))))})),P=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,c=s().t,l=n.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),u=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===r.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:g.InfoRow},!o&&!m&&n.createElement("div",{className:g.ActionTextBtn,onClick:i},l),(o||m)&&n.createElement("div",{className:[g.CheckoutNoteContainer,m?g.Success:""].join(" ")},n.createElement("div",{className:g.Title},c("checkout-page:orderNote")),m?n.createElement("div",{className:g.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:u,maxLength:320})))}));export{S as CartSummary,O as Coupon,y as CouponErrorCode};
1
+ import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as o}from"mobx-react-lite";import a from"lodash/sortBy";import c from"../input-with-button/index.js";import l from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as u}from"../../../../utils/currency.js";import{useTranslation as s}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import C from"../svg/arrow-down.js";import h from"../svg/cross.js";import v from"../svg/gift.js";import f from"../../styles/common.module.scss.js";import g from"./style.module.scss.js";import k from"../svg/ikas.js";import{Button as N}from"../button/index.js";var y;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS"}(y||(y={}));var S=o((function(e){var t,o,a=e.vm,c=e.allowExpand,d=e.isSuccessPageSummary,p=a.checkout,E=s().t,h=n.useState(!c),v=h[0],f=h[1],N=n.useState(!1),S=N[0],j=N[1],I=n.useState(null),_=I[0],w=I[1],A=n.useState(0),D=A[0],R=A[1],B=n.useState(null),L=B[0],U=B[1],F=n.useState(!1),M=F[0],V=F[1],X=n.useState(!1),G=X[0],H=X[1],q=n.useState(!1),z=q[0],$=q[1];n.useEffect((function(){c&&(v?L&&R(L.getBoundingClientRect().height):R(0))}),[v,L,c,M,G,S,z]);var K=n.useMemo((function(){switch(_){case y.COUPON_CODE_NOT_EXIST:return E("checkout-page:giftCodeErrorDescription");case y.COUPON_CODE_NOT_EXIST_FOR_GUESS:return E("checkout-page:mustBeSignInToApplyCampaign");default:return""}}),[_]),Q=[g.CartSummary,c?g.HideOnDesktop:"",d?g.SuccessPageCartSummary:""].join(" "),J=c?{height:D+"px"}:void 0,W=[g.ArrowDown,v?g.Rotated:""].join(" ");return p?n.createElement(n.Fragment,null,!!c&&n.createElement(n.Fragment,null,n.createElement("div",{id:"checkout-mobile-summary-header"}),n.createElement("div",{className:g.ExpandHeader,onClick:function(){if(!v){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}f(!v)}},n.createElement("div",{className:g.Left},E("checkout-page:summary")),n.createElement("div",{className:g.Price},n.createElement("span",{className:g.PriceText},"".concat(u(a.finalPrice||0,p.currencyCode,p.currencySymbol)," (").concat(p.itemQuantity," ").concat(E("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:W},n.createElement(C,null))))),n.createElement("div",{className:Q},n.createElement("div",{className:[g.DetailsContainer,d?g.SuccessPageDetailContainer:""].join(" "),style:J},n.createElement("div",{className:g.Details,ref:U},n.createElement("div",{className:g.ItemsContainer},n.createElement("div",null,p.items.map((function(e,t){return n.createElement(m,{key:t,vm:a,cartItem:e,currencyCode:p.currencyCode,onChange:$,isSuccessPageSummary:d})})))),n.createElement("div",{className:g.Divider}),n.createElement("div",{className:g.SubTotalInfo},S&&n.createElement("div",{className:g.NotificationContainer},n.createElement(l,{type:"warning",title:E("checkout-page:giftCodeErrorTitle"),content:K,onClose:function(){j(!1),w(null)}})),n.createElement(T,{label:E("checkout-page:subtotal"),value:p.formattedTotalPrice,tooltipText:E("checkout-page:subtotalTooltip"),hideMarginBottom:!a.isCouponCodeVisible}),!!(null===(t=p.shippingLines)||void 0===t?void 0:t.length)&&n.createElement(T,{label:E("checkout-page:cartShippingTitle"),value:p.shippingTotal?p.formattedShippingTotal:E("checkout-page:free")}),!!a.installmentExtraPrice&&n.createElement(T,{label:E("checkout-page:cartInterest"),value:u(a.installmentExtraPrice,p.currencyCode,p.currencySymbol)}),n.createElement(b,{vm:a}),n.createElement(x,{vm:a}),(a.step===r.SUCCESS&&(!!a.checkout.note||!!a.checkout.appliedCouponCode)||a.step!==r.SUCCESS)&&a.isCouponCodeVisible&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(O,{vm:a,isAddingCoupon:G,setAddingCoupon:H,setCouponError:j,setCouponErrorCode:w}),n.createElement(P,{vm:a,isAddingNote:M,setAddingNote:V})),n.createElement("div",{className:[g.TotalContainer,d?g.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},E("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:g.TotalPricesContainer},n.createElement("div",{className:g.TotalPrice},u(a.finalPrice||0,p.currencyCode,p.currencySymbol)),!!p.$totalTax&&!!(null===(o=a.customizationProps)||void 0===o?void 0:o.showTax)&&n.createElement("div",{className:[g.TotalTax].join(" ")},E("checkout-page:cartTaxTitle")+" "+p.$formattedTotalTax)))),!d&&!a.isPoweredByHidden&&n.createElement("div",{className:g.PoweredBy},n.createElement("span",null,"powered by"),n.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},n.createElement(k,null))))))):null})),T=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,c=e.hideMarginBottom;return n.createElement("div",{className:[g.InfoRow,c?g.hideMb:""].join(" ")},n.createElement("div",{className:g.Label},n.createElement("span",null,t),!!a&&n.createElement(E,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:g.Value},o))})),b=o((function(e){var t=e.vm,o=s().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").map((function(e,a){return n.createElement("div",{className:g.InfoRow,key:a},n.createElement("div",{className:g.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),x=o((function(e){var t,o,a=e.vm,c=s().t;return a.checkout?n.createElement(n.Fragment,null,a.step!==r.SUCCESS&&((null===(t=a.checkout.selectedPaymentGateway)||void 0===t?void 0:t.getCalculatedAdditionalPrices(a.checkout.totalFinalPrice||0,a.checkout.shippingLines||null))||[]).filter((function(e){return 0!==e.amount})).map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,a.checkout.currencyCode,a.checkout.currencySymbol))))})),null===(o=a.checkout.giftPackageLines)||void 0===o?void 0:o.map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},n.createElement("div",{className:g.GiftLabel},n.createElement(v,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,c("checkout-page:giftPackage")))),n.createElement("div",{className:g.Value},n.createElement("span",null,u(e.price,a.checkout.currencyCode,a.checkout.currencySymbol))))}))):null})),O=o((function(o){var a=o.vm,l=o.isAddingCoupon,i=o.setAddingCoupon,m=o.setCouponError,E=o.setCouponErrorCode,C=o.isOpenCouponCode,v=s().t,k=n.useState(""),y=k[0],S=k[1],T=n.useState(!1),b=T[0],x=T[1],O=n.useRef(null);n.useEffect((function(){l&&O.current&&O.current.focus()}),[l]);var P=function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=y,x(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),x(!1),S(""),!a.checkout.appliedCouponCode||a.couponError?[3,3]:(i(!1),m(!1),E(null),[4,a.reInitPaymentMethod()]);case 2:return e.sent(),[3,4];case 3:a.checkout.couponCode=null,m(!0),E(a.couponError),e.label=4;case 4:return[2]}}))}))},j=function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=null,x(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),x(!1),[2]}}))}))},I=a.step===r.SUCCESS,_=a.step===r.SHIPPING;if(I&&!a.checkout.appliedCouponCode)return null;var w=a.checkout.couponAdjustment,A=!(!a.checkout.appliedCouponCode||l),D=!!a.checkout.appliedCouponCode&&C;return n.createElement(n.Fragment,null,!!C&&n.createElement(n.Fragment,null,n.createElement("div",{className:[g.CartSummary,g.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:f.FormSectionTitle},n.createElement("div",{style:{paddingBottom:D?0:6},className:f.Title},v("checkout-page:couponCode")),D&&n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline,g.Light].join(" ")},n.createElement("span",{className:[g.AppliedCoupon,g.AppliedCouponBgGray].join(" ")},n.createElement("span",{className:g.CouponCode},a.checkout.appliedCouponCode),!I&&n.createElement("span",{className:g.ClearCoupon,onClick:j},n.createElement(h,null))))))),A&&!_&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:g.InfoRow},!a.checkout.appliedCouponCode&&!l&&a.isCouponCodeVisible&&n.createElement("div",{className:g.ActionTextBtn,onClick:function(){return i(!0)}},v("checkout-page:addCouponCode")),l&&!C&&n.createElement(c,{value:y,placeholder:v("checkout-page:couponCode"),buttonLabel:v("checkout-page:actions.apply"),inputRef:O,onClick:P,isLoading:b,onChange:S}),C&&!D&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&P()},className:g.OpenCouponCodeMain},n.createElement(d,{label:v("checkout-page:couponCode"),type:p.TEXT,value:y,onChange:S}),n.createElement(N,{style:{width:"33%"},text:v("checkout-page:actions.apply"),isLoading:b,onClick:P})),A&&n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline,g.Light].join(" ")},v("checkout-page:couponCode"),n.createElement("span",{className:[g.AppliedCoupon,a.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},n.createElement("span",{className:g.CouponCode},a.checkout.appliedCouponCode),a.step!==r.SUCCESS&&a.isCouponCodeRequirementDefult&&n.createElement("span",{className:g.ClearCoupon,onClick:j},n.createElement(h,null)))),A&&n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===(null==w?void 0:w.type)?"- ":"")," ",n.createElement("span",null,u((null==w?void 0:w.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)))))})),P=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,c=s().t,l=n.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),u=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===r.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:g.InfoRow},!o&&!m&&n.createElement("div",{className:g.ActionTextBtn,onClick:i},l),(o||m)&&n.createElement("div",{className:[g.CheckoutNoteContainer,m?g.Success:""].join(" ")},n.createElement("div",{className:g.Title},c("checkout-page:orderNote")),m?n.createElement("div",{className:g.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:u,maxLength:320})))}));export{S as CartSummary,O as Coupon,y as CouponErrorCode};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/cloneDeep";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"@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{IkasCustomerAddress as d}from"../../../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as o}from"../../../../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/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/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/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"../../../../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";var r=function(){function r(r,a){var m=this;this.editingCustomerAddress=null,this.isDeleteAddressLoading=!1,this.isEditAddressLoading=!1,this.isEditAddressErrorsVisible=!1,this.onAddressSelect=function(e){("shipping"===m.addressType?m.vm.onSelectedShippingAddressIdChange:m.vm.onSelectedBillingAddressIdChange)((null==e?void 0:e.id)||"-1")},this.onEditAddressClick=function(e){var t=new o(i(e));t.countrySettings=m.vm.countrySettings,t.checkoutSettings=m.vm.checkoutSettings,m.editingCustomerAddress=t},this.onCancelEditAddressClick=function(){m.isDeleteAddressLoading||m.isEditAddressLoading||(m.editingCustomerAddress=null)},this.onDeleteAddressClick=function(){return e(m,void 0,void 0,(function(){var e,s,d,o,r,a=this;return t(this,(function(t){switch(t.label){case 0:if(-1===(e=null===(o=null===(d=this.vm.store.customerStore.customer)||void 0===d?void 0:d.addresses)||void 0===o?void 0:o.findIndex((function(e){var t;return e.id===(null===(t=a.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];s=i(this.vm.store.customerStore.customer),null===(r=s.addresses)||void 0===r||r.splice(e,1),t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isDeleteAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(this.editingCustomerAddress=null),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isDeleteAddressLoading=!1,[7];case 5:return[2]}}))}))},this.onSaveAddressClick=function(){return e(m,void 0,void 0,(function(){var e,s,o,r,a,m,n,l=this;return t(this,(function(t){switch(t.label){case 0:if(this.isDeleteAddressLoading||this.isEditAddressLoading)return[2];if(!(null===(o=this.editingCustomerAddress)||void 0===o?void 0:o.isValidAddress))return this.isEditAddressErrorsVisible=!0,[2];if(-1===(e=null===(a=null===(r=this.vm.store.customerStore.customer)||void 0===r?void 0:r.addresses)||void 0===a?void 0:a.findIndex((function(e){var t;return e.id===(null===(t=l.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];(s=i(this.vm.store.customerStore.customer)).addresses[e]=new d(i(this.editingCustomerAddress)),t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isEditAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(null===(n=null===(m=this.vm.store.customerStore.customer)||void 0===m?void 0:m.addresses)||void 0===n||n.forEach((function(e){return e.checkoutSettings=l.vm.checkoutSettings})),this.onAddressSelect(this.editingCustomerAddress),this.editingCustomerAddress=null,this.isEditAddressErrorsVisible=!1),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isEditAddressLoading=!1,[7];case 5:return[2]}}))}))},this.firstNameChangeCallback=function(e){(!m.vm.checkout.hasCustomer&&"shipping"===m.addressType||m.vm.isDigitalOnly)&&(m.vm.checkout.customer.firstName=e)},this.lastNameChangeCallback=function(e){(!m.vm.checkout.hasCustomer&&"shipping"===m.addressType||m.vm.isDigitalOnly)&&(m.vm.checkout.customer.lastName=e)},this.vm=r,this.addressType=a,s(this)}return Object.defineProperty(r.prototype,"address",{get:function(){return"shipping"===this.addressType?this.vm.checkout.shippingAddress:this.vm.checkout.billingAddress},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"selectedAddressId",{get:function(){return"shipping"===this.addressType?this.vm.selectedShippingAddressId:this.vm.selectedBillingAddressId},enumerable:!1,configurable:!0}),r}();export{r as default};
1
+ import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/cloneDeep";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"@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{IkasCustomerAddress as d}from"../../../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as o}from"../../../../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"../../../../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/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/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"../../../../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";var r=function(){function r(r,a){var m=this;this.editingCustomerAddress=null,this.isDeleteAddressLoading=!1,this.isEditAddressLoading=!1,this.isEditAddressErrorsVisible=!1,this.onAddressSelect=function(e){("shipping"===m.addressType?m.vm.onSelectedShippingAddressIdChange:m.vm.onSelectedBillingAddressIdChange)((null==e?void 0:e.id)||"-1")},this.onEditAddressClick=function(e){var t=new o(i(e));t.countrySettings=m.vm.countrySettings,t.checkoutSettings=m.vm.checkoutSettings,m.editingCustomerAddress=t},this.onCancelEditAddressClick=function(){m.isDeleteAddressLoading||m.isEditAddressLoading||(m.editingCustomerAddress=null)},this.onDeleteAddressClick=function(){return e(m,void 0,void 0,(function(){var e,s,d,o,r,a=this;return t(this,(function(t){switch(t.label){case 0:if(-1===(e=null===(o=null===(d=this.vm.store.customerStore.customer)||void 0===d?void 0:d.addresses)||void 0===o?void 0:o.findIndex((function(e){var t;return e.id===(null===(t=a.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];s=i(this.vm.store.customerStore.customer),null===(r=s.addresses)||void 0===r||r.splice(e,1),t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isDeleteAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(this.editingCustomerAddress=null),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isDeleteAddressLoading=!1,[7];case 5:return[2]}}))}))},this.onSaveAddressClick=function(){return e(m,void 0,void 0,(function(){var e,s,o,r,a,m,n,l=this;return t(this,(function(t){switch(t.label){case 0:if(this.isDeleteAddressLoading||this.isEditAddressLoading)return[2];if(!(null===(o=this.editingCustomerAddress)||void 0===o?void 0:o.isValidAddress))return this.isEditAddressErrorsVisible=!0,[2];if(-1===(e=null===(a=null===(r=this.vm.store.customerStore.customer)||void 0===r?void 0:r.addresses)||void 0===a?void 0:a.findIndex((function(e){var t;return e.id===(null===(t=l.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];(s=i(this.vm.store.customerStore.customer)).addresses[e]=new d(i(this.editingCustomerAddress)),t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isEditAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(null===(n=null===(m=this.vm.store.customerStore.customer)||void 0===m?void 0:m.addresses)||void 0===n||n.forEach((function(e){return e.checkoutSettings=l.vm.checkoutSettings})),this.onAddressSelect(this.editingCustomerAddress),this.editingCustomerAddress=null,this.isEditAddressErrorsVisible=!1),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isEditAddressLoading=!1,[7];case 5:return[2]}}))}))},this.firstNameChangeCallback=function(e){(!m.vm.checkout.hasCustomer&&"shipping"===m.addressType||m.vm.isDigitalOnly)&&(m.vm.checkout.customer.firstName=e)},this.lastNameChangeCallback=function(e){(!m.vm.checkout.hasCustomer&&"shipping"===m.addressType||m.vm.isDigitalOnly)&&(m.vm.checkout.customer.lastName=e)},this.vm=r,this.addressType=a,s(this)}return Object.defineProperty(r.prototype,"address",{get:function(){return"shipping"===this.addressType?this.vm.checkout.shippingAddress:this.vm.checkout.billingAddress},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"selectedAddressId",{get:function(){return"shipping"===this.addressType?this.vm.selectedShippingAddressId:this.vm.selectedBillingAddressId},enumerable:!1,configurable:!0}),r}();export{r as default};
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import { CheckoutError } from "../../../../../components/checkout/model";
3
+ declare type Props = {
4
+ error?: CheckoutError | null;
5
+ onClose: () => void;
6
+ };
7
+ export declare const ArgumentValidationError: React.FC<Props>;
8
+ export {};
@@ -0,0 +1 @@
1
+ import*as o from"react";import{observer as r}from"mobx-react-lite";import i from"../../notification-box/index.js";import"@ikas/storefront-config";import{useTranslation as t}from"../../../../../utils/i18n.js";var n=r((function(r){var n=r.error,e=r.onClose,l=t().t,a=o.useMemo((function(){var o,r,i;if(null===(o=null==n?void 0:n.data)||void 0===o?void 0:o.length){var t=null==n?void 0:n.data[0];if(null===(r=t.children)||void 0===r?void 0:r.length)if(null===(i=t.children[0].constraints)||void 0===i?void 0:i.isEmail)return!0}return!1}),[n]);return o.createElement(i,{type:"error",content:l(a?"checkout-page:emailError":"checkout-page:errorUnknown"),onClose:e})}));export{n as ArgumentValidationError};