@ikas/storefront 6.1.0-beta.146 → 6.1.0-beta.148

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 (25) hide show
  1. package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
  2. package/build/components/checkout/components/cart-summary/cart-item/style.module.scss.js +1 -1
  3. package/build/components/checkout/components/cart-summary/index.js +1 -1
  4. package/build/components/checkout/components/svg/subscription.d.ts +6 -0
  5. package/build/components/checkout/components/svg/subscription.js +1 -0
  6. package/build/components/page-editor/ThemeComponentEditor.js +1 -1
  7. package/build/models/data/order/line-item/index.d.ts +2 -0
  8. package/build/models/data/order/line-item/index.js +1 -1
  9. package/build/models/data/order/line-item/order-line-item-subscription-plan/index.d.ts +8 -0
  10. package/build/models/data/order/line-item/order-line-item-subscription-plan/index.js +1 -0
  11. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.d.ts +6 -0
  12. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.js +1 -0
  13. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.d.ts +14 -0
  14. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.js +1 -0
  15. package/build/models/data/product/index.d.ts +1 -0
  16. package/build/models/data/product/index.js +1 -1
  17. package/build/models/data/product/variant/index.d.ts +2 -0
  18. package/build/models/data/product/variant/index.js +1 -1
  19. package/build/models/data/product/variant/subscription-plan/index.d.ts +12 -0
  20. package/build/models/data/product/variant/subscription-plan/index.js +1 -0
  21. package/build/models/data/product/variant/subscription-plan/product-subscription-plan-discount/index.d.ts +6 -0
  22. package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.d.ts +23 -0
  23. package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.js +1 -0
  24. package/build/store/cart/index.js +1 -1
  25. package/package.json +11 -11
@@ -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/customer-form-data-input/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/region/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/order-transaction-with-prices/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/campaign-offer/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/stock-location/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/shipping-zone/state/city/district/region/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../../../models/data/storefront-popup/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/component/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../../../../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),e.createElement("span",null,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/order-transaction-with-prices/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/campaign-offer/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/stock-location/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/shipping-zone/state/city/district/region/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../../../models/data/storefront-popup/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/component/index.js";import"../../../../../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 n from"./svg/arrow-right.js";import m from"./svg/arrow-down.js";import d from"../../svg/subscription.js";import l from"./style.module.scss.js";var c=t((function(t){var c,u,p,v,j,x;t.vm,t.currencyCode;var f=t.cartItem,g=t.stockErrorItem,E=t.onChange,N=t.isSuccessPageSummary,y=o().t,h=!g,P=e.useRef(null),b=e.useState(0),C=b[0],k=b[1],O=e.useState(!1),w=O[0],T=O[1],S=e.useState(!1),I=S[0],R=S[1];e.useEffect((function(){if(P.current){var e=24;Array.from(P.current.children).map((function(t){return e=e+t.clientHeight+12})),k(e)}}),[]),e.useEffect((function(){P.current&&(P.current.style.maxHeight=I?"".concat(C,"px"):"0")}),[I]);var Q=e.useMemo((function(){var t;return e.createElement("div",null,null===(t=f.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:l.OptionRow},e.createElement("div",{className:l.OptionName},t.name),e.createElement("div",{className:l.OptionValue},t.values.map((function(e){return e.name||e.value})).join(", ")));case a.DATE_PICKER:return e.createElement("div",{className:l.OptionRow},e.createElement("div",{className:l.OptionName},t.name),e.createElement("div",{className:l.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:l.OptionRow},e.createElement("div",{className:l.OptionName},t.name),e.createElement("div",{className:l.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:l.OptionRow},e.createElement("div",{className:l.OptionName},t.name),e.createElement("div",{className:l.OptionValue},t.values.length&&"true"===t.values[0].value?y("checkout-page:yes"):y("checkout-page:no")));case a.COLOR_PICKER:return e.createElement("div",{className:l.OptionRow},e.createElement("div",{className:l.OptionName},t.name),e.createElement("div",{className:l.OptionsHorContainer},t.values.map((function(t,a){return e.createElement("div",{key:a,className:l.OptionColorValue,style:{backgroundColor:t.value}})}))))}})))}),[]),V=[l.BundleProductsContainer,I?l.VisibleBundleProducts:""].join(" "),W=(null===(c=f.variant.bundleProducts)||void 0===c?void 0:c.reduce((function(e,t){return e+t.quantity}),0))||0;return e.createElement(e.Fragment,null,e.createElement("div",{className:l.CheckoutItem},e.createElement("div",{className:[l.ImageContainer,N?l.SuccessPageImageContainer:""].join(" ")},e.createElement("img",{className:l.Image,src:null===(u=f.variant.mainImage)||void 0===u?void 0:u.thumbnailSrc}),e.createElement("div",{className:l.QuantityCircle},f.quantity)),e.createElement("div",{className:l.Center},!!g&&e.createElement("div",{className:l.StockErrorItemMain},e.createElement("span",null,f.quantity," ",y("checkout-page:quantity")),e.createElement("span",null,e.createElement(n,null)),e.createElement("span",null,g.stockCount<0?0:g.stockCount," ",y("checkout-page:quantity"))),f.subscriptionPlan&&f.subscriptionPlan.period.title&&e.createElement("div",{className:l.SubscriptionPlanTitle},e.createElement(d,null),e.createElement("span",{className:l.SubscriptionPlanTitleText},null===(p=f.subscriptionPlan)||void 0===p?void 0:p.period.title)),e.createElement("div",{className:[l.Name,N?l.SuccessPageName:""].join(" ")},f.variant.name),e.createElement("div",{className:[l.LightText,N?"":l.Small].join(" ")},null===(v=f.variant.variantValues)||void 0===v?void 0:v.map((function(e){return e.variantValueName})).join(" / ")),!!N&&h&&e.createElement("div",{className:[l.Right,N?l.SuccessPagePriceMain:""].join(" ")},e.createElement("div",{className:l.Price},!!f.overridenPriceWithQuantity&&e.createElement("span",{className:l.GrayPrice},f.formattedOverridenPriceWithQuantity),e.createElement("span",{className:l.FinalPrice},f.formattedFinalPriceWithQuantity)),f.unitPriceText&&e.createElement("div",{className:[l.LightText,l.Small].join(" ")},f.unitPriceText)),!!(null===(j=f.options)||void 0===j?void 0:j.length)&&e.createElement("div",{className:l.OptionsText,onClick:function(){return T(!0)}},y("checkout-page:customizedProduct")),f.variant.bundleProducts&&0!==f.variant.bundleProducts.length&&e.createElement("div",{className:l.BundleProducts,onClick:function(){R(!I),E&&setTimeout((function(){E(!I)}),200)}},y("checkout-page:bundleProductsQuantity",{value:W}),e.createElement("span",{style:{paddingTop:2,transform:I?void 0:"rotate(180deg)"}},e.createElement(m,null))),!!w&&e.createElement(r,{title:f.variant.name,modalContent:Q,onClose:function(){return T(!1)}})),h&&!N&&e.createElement("div",{className:l.Right},e.createElement("div",{className:l.Price},!!f.overridenPriceWithQuantity&&e.createElement("span",{className:l.GrayPrice},f.formattedOverridenPriceWithQuantity),e.createElement("span",null,f.formattedFinalPriceWithQuantity)),f.unitPriceText&&e.createElement("div",{className:[l.LightText,l.Small].join(" ")},f.unitPriceText))),e.createElement("div",{ref:P,className:V},null===(x=f.variant.bundleProducts)||void 0===x?void 0:x.map((function(t){return e.createElement(s,{bundleProduct:t})}))))}));export{c as CartItem};
@@ -1 +1 @@
1
- import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var t={CheckoutItem:"style-module_CheckoutItem__DaU-Y",ImageContainer:"style-module_ImageContainer__Nr1VF",Image:"style-module_Image__EskwT",QuantityCircle:"style-module_QuantityCircle__sv1mk",SuccessPageImageContainer:"style-module_SuccessPageImageContainer__Bzs7z",Center:"style-module_Center__ZOloc",StockErrorItemMain:"style-module_StockErrorItemMain__RprLM",Name:"style-module_Name__z-5-n",SuccessPageName:"style-module_SuccessPageName__N9QRQ",OptionsText:"style-module_OptionsText__7Gcy6",BundleProducts:"style-module_BundleProducts__fbCWu",Right:"style-module_Right__WoFoc",Price:"style-module_Price__4WmJv",GrayPrice:"style-module_GrayPrice__Gtch1",SuccessPagePriceMain:"style-module_SuccessPagePriceMain__Zl1lq",FinalPrice:"style-module_FinalPrice__beHZg",LightText:"style-module_LightText__uO43H",Small:"style-module_Small__peZjv",OptionRow:"style-module_OptionRow__lt6CJ",OptionName:"style-module_OptionName__09oij",OptionValue:"style-module_OptionValue__4fCYP",OptionsHorContainer:"style-module_OptionsHorContainer__eTmOO",OptionColorValue:"style-module_OptionColorValue__oNEyN",BundleProductsContainer:"style-module_BundleProductsContainer__em-6w",VisibleBundleProducts:"style-module_VisibleBundleProducts__YwXXL"};e(".style-module_CheckoutItem__DaU-Y {\n display: flex;\n width: 100%;\n margin-bottom: 24px;\n}\n.style-module_CheckoutItem__DaU-Y:last-child {\n margin-bottom: 0;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF {\n flex: 0 0 auto;\n width: 80px;\n height: 74px;\n position: relative;\n padding-right: 16px;\n overflow: hidden;\n padding-top: 10px;\n}\n@media only screen and (max-width: 375px) {\n .style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF {\n width: 72px;\n height: 66px;\n }\n}\n.style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF .style-module_Image__EskwT {\n object-fit: contain;\n border-radius: 8px;\n width: 64px;\n height: 64px;\n}\n@media only screen and (max-width: 375px) {\n .style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF .style-module_Image__EskwT {\n width: 56px;\n height: 56px;\n }\n}\n.style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF .style-module_QuantityCircle__sv1mk {\n width: 20px;\n height: 20px;\n border-radius: 10px;\n background-color: var(--checkout-button-bg-color);\n color: var(--checkout-button-text-color);\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 12px;\n font-weight: 500;\n position: absolute;\n top: 0px;\n right: 8px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPageImageContainer__Bzs7z {\n overflow: unset;\n width: unset;\n height: unset;\n padding-top: 8px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPageImageContainer__Bzs7z .style-module_Image__EskwT {\n object-fit: contain;\n border-radius: 4px;\n width: 72px;\n height: 72px;\n border: 1px solid var(--checkout-border-color);\n}\n@media only screen and (max-width: 375px) {\n .style-module_CheckoutItem__DaU-Y .style-module_SuccessPageImageContainer__Bzs7z .style-module_Image__EskwT {\n width: 56px;\n height: 56px;\n }\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc {\n position: relative;\n flex: 1 1 auto;\n padding-top: 10px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_StockErrorItemMain__RprLM {\n display: flex;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_StockErrorItemMain__RprLM span {\n margin-right: 6px;\n font-size: 14px;\n font-weight: 500;\n text-transform: lowercase;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_StockErrorItemMain__RprLM span:first-child {\n color: var(--checkout-button-disabled-text-color);\n text-decoration-line: line-through;\n font-weight: 400;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_Name__z-5-n {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n max-height: 40px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_SuccessPageName__N9QRQ {\n font-size: 16px;\n font-weight: 500;\n line-height: 24px;\n max-height: unset;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_OptionsText__7Gcy6 {\n font-size: 12px;\n color: var(--checkout-primary-text-color);\n line-height: 16px;\n margin-top: 2px;\n user-select: none;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_OptionsText__7Gcy6:hover {\n cursor: pointer;\n text-decoration: underline;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_BundleProducts__fbCWu {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 12px;\n color: #6f55ff;\n line-height: 16px;\n cursor: pointer;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc {\n flex: 0 0 auto;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n padding-left: 12px;\n padding-top: 10px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc .style-module_Price__4WmJv {\n font-size: 14px;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n color: var(--checkout-primary-text-color);\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc .style-module_Price__4WmJv span {\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc .style-module_GrayPrice__Gtch1 {\n font-size: 14px;\n color: var(--checkout-secondary-text-color);\n text-decoration: line-through;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPagePriceMain__Zl1lq {\n align-items: flex-start;\n padding: 0;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPagePriceMain__Zl1lq .style-module_Price__4WmJv {\n flex-direction: row;\n align-items: flex-start;\n column-gap: 8px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPagePriceMain__Zl1lq .style-module_Price__4WmJv .style-module_FinalPrice__beHZg {\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_CheckoutItem__DaU-Y .style-module_LightText__uO43H {\n font-size: 14px;\n color: var(--checkout-secondary-text-color);\n line-height: 20px;\n margin-top: 2px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_LightText__uO43H.style-module_Small__peZjv {\n font-size: 12px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ {\n display: flex;\n flex-direction: column;\n margin-bottom: 24px;\n max-width: 400px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionName__09oij {\n font-size: 14px;\n color: var(--checkout-primary-text-color);\n margin-right: 8px;\n font-weight: 500;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionValue__4fCYP {\n font-size: 14px;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionsHorContainer__eTmOO {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionColorValue__oNEyN {\n width: 24px;\n height: 24px;\n border-radius: 4px;\n margin-right: 4px;\n}\n\n.style-module_BundleProductsContainer__em-6w {\n margin-left: 32px;\n padding-left: 24px;\n border-left: 1px solid var(--checkout-border-color);\n margin-top: -8px;\n overflow: hidden;\n max-height: 0;\n transition: max-height 0.2s ease;\n}\n.style-module_BundleProductsContainer__em-6w.style-module_VisibleBundleProducts__YwXXL {\n max-height: 1000px;\n margin-bottom: 24px;\n}");export{t as default};
1
+ import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var t={CheckoutItem:"style-module_CheckoutItem__DaU-Y",ImageContainer:"style-module_ImageContainer__Nr1VF",Image:"style-module_Image__EskwT",QuantityCircle:"style-module_QuantityCircle__sv1mk",SuccessPageImageContainer:"style-module_SuccessPageImageContainer__Bzs7z",Center:"style-module_Center__ZOloc",StockErrorItemMain:"style-module_StockErrorItemMain__RprLM",Name:"style-module_Name__z-5-n",SuccessPageName:"style-module_SuccessPageName__N9QRQ",OptionsText:"style-module_OptionsText__7Gcy6",BundleProducts:"style-module_BundleProducts__fbCWu",Right:"style-module_Right__WoFoc",Price:"style-module_Price__4WmJv",GrayPrice:"style-module_GrayPrice__Gtch1",SuccessPagePriceMain:"style-module_SuccessPagePriceMain__Zl1lq",FinalPrice:"style-module_FinalPrice__beHZg",LightText:"style-module_LightText__uO43H",Small:"style-module_Small__peZjv",OptionRow:"style-module_OptionRow__lt6CJ",OptionName:"style-module_OptionName__09oij",OptionValue:"style-module_OptionValue__4fCYP",OptionsHorContainer:"style-module_OptionsHorContainer__eTmOO",OptionColorValue:"style-module_OptionColorValue__oNEyN",SubscriptionPlanTitle:"style-module_SubscriptionPlanTitle__5NneG",SubscriptionPlanTitleText:"style-module_SubscriptionPlanTitleText__PBeYV",BundleProductsContainer:"style-module_BundleProductsContainer__em-6w",VisibleBundleProducts:"style-module_VisibleBundleProducts__YwXXL"};e(".style-module_CheckoutItem__DaU-Y {\n display: flex;\n width: 100%;\n margin-bottom: 24px;\n}\n.style-module_CheckoutItem__DaU-Y:last-child {\n margin-bottom: 0;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF {\n flex: 0 0 auto;\n width: 80px;\n height: 74px;\n position: relative;\n padding-right: 16px;\n overflow: hidden;\n padding-top: 10px;\n}\n@media only screen and (max-width: 375px) {\n .style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF {\n width: 72px;\n height: 66px;\n }\n}\n.style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF .style-module_Image__EskwT {\n object-fit: contain;\n border-radius: 8px;\n width: 64px;\n height: 64px;\n}\n@media only screen and (max-width: 375px) {\n .style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF .style-module_Image__EskwT {\n width: 56px;\n height: 56px;\n }\n}\n.style-module_CheckoutItem__DaU-Y .style-module_ImageContainer__Nr1VF .style-module_QuantityCircle__sv1mk {\n width: 20px;\n height: 20px;\n border-radius: 10px;\n background-color: var(--checkout-button-bg-color);\n color: var(--checkout-button-text-color);\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 12px;\n font-weight: 500;\n position: absolute;\n top: 0px;\n right: 8px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPageImageContainer__Bzs7z {\n overflow: unset;\n width: unset;\n height: unset;\n padding-top: 8px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPageImageContainer__Bzs7z .style-module_Image__EskwT {\n object-fit: contain;\n border-radius: 4px;\n width: 72px;\n height: 72px;\n border: 1px solid var(--checkout-border-color);\n}\n@media only screen and (max-width: 375px) {\n .style-module_CheckoutItem__DaU-Y .style-module_SuccessPageImageContainer__Bzs7z .style-module_Image__EskwT {\n width: 56px;\n height: 56px;\n }\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc {\n position: relative;\n flex: 1 1 auto;\n padding-top: 10px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_StockErrorItemMain__RprLM {\n display: flex;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_StockErrorItemMain__RprLM span {\n margin-right: 6px;\n font-size: 14px;\n font-weight: 500;\n text-transform: lowercase;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_StockErrorItemMain__RprLM span:first-child {\n color: var(--checkout-button-disabled-text-color);\n text-decoration-line: line-through;\n font-weight: 400;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_Name__z-5-n {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n max-height: 40px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_SuccessPageName__N9QRQ {\n font-size: 16px;\n font-weight: 500;\n line-height: 24px;\n max-height: unset;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_OptionsText__7Gcy6 {\n font-size: 12px;\n color: var(--checkout-primary-text-color);\n line-height: 16px;\n margin-top: 2px;\n user-select: none;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_OptionsText__7Gcy6:hover {\n cursor: pointer;\n text-decoration: underline;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Center__ZOloc .style-module_BundleProducts__fbCWu {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 12px;\n color: #6f55ff;\n line-height: 16px;\n cursor: pointer;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc {\n flex: 0 0 auto;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n padding-left: 12px;\n padding-top: 10px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc .style-module_Price__4WmJv {\n font-size: 14px;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n color: var(--checkout-primary-text-color);\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc .style-module_Price__4WmJv span {\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_Right__WoFoc .style-module_GrayPrice__Gtch1 {\n font-size: 14px;\n color: var(--checkout-secondary-text-color);\n text-decoration: line-through;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPagePriceMain__Zl1lq {\n align-items: flex-start;\n padding: 0;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPagePriceMain__Zl1lq .style-module_Price__4WmJv {\n flex-direction: row;\n align-items: flex-start;\n column-gap: 8px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SuccessPagePriceMain__Zl1lq .style-module_Price__4WmJv .style-module_FinalPrice__beHZg {\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_CheckoutItem__DaU-Y .style-module_LightText__uO43H {\n font-size: 14px;\n color: var(--checkout-secondary-text-color);\n line-height: 20px;\n margin-top: 2px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_LightText__uO43H.style-module_Small__peZjv {\n font-size: 12px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ {\n display: flex;\n flex-direction: column;\n margin-bottom: 24px;\n max-width: 400px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionName__09oij {\n font-size: 14px;\n color: var(--checkout-primary-text-color);\n margin-right: 8px;\n font-weight: 500;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionValue__4fCYP {\n font-size: 14px;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionsHorContainer__eTmOO {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_OptionRow__lt6CJ .style-module_OptionColorValue__oNEyN {\n width: 24px;\n height: 24px;\n border-radius: 4px;\n margin-right: 4px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SubscriptionPlanTitle__5NneG {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 12px;\n color: #5A44D5;\n background-color: #F7F5FF;\n height: 20px;\n border-radius: 4px;\n border: 1px solid #D5CDFF;\n width: max-content;\n padding: 4px;\n}\n.style-module_CheckoutItem__DaU-Y .style-module_SubscriptionPlanTitleText__PBeYV {\n font-size: 12px;\n line-height: 18px;\n font-weight: 500;\n color: #5A44D5;\n}\n\n.style-module_BundleProductsContainer__em-6w {\n margin-left: 32px;\n padding-left: 24px;\n border-left: 1px solid var(--checkout-border-color);\n margin-top: -8px;\n overflow: hidden;\n max-height: 0;\n transition: max-height 0.2s ease;\n}\n.style-module_BundleProductsContainer__em-6w.style-module_VisibleBundleProducts__YwXXL {\n max-height: 1000px;\n margin-bottom: 24px;\n}");export{t as default};
@@ -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 r from"../notification-box/index.js";import{CheckoutStep as l}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as s}from"../../../../utils/currency.js";import{useTranslation as u}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 C from"../tooltip/index.js";import E from"../svg/arrow-down.js";import h from"../svg/cross.js";import f from"../svg/gift.js";import g from"../../styles/common.module.scss.js";import v from"./style.module.scss.js";import k from"../svg/ikas.js";import{Button as N}from"../button/index.js";import{IkasGiftCardType as y}from"@ikas/storefront-models";import S from"../../../../hooks/useDimension.js";import T from"../svg/coupon-code-tag.js";import b from"../svg/gift-cart-tag.js";import O from"../svg/store-credit-tag.js";var I;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS",e.COUPON_APPLIED_WITHOUT_DISCOUNT="COUPON_APPLIED_WITHOUT_DISCOUNT"}(I||(I={}));var x=o((function(e){var t,o,a=e.vm,c=e.allowExpand,d=e.isSuccessPageSummary,p=a.checkout,C=u().t,h=n.useState(!c),f=h[0],g=h[1],N=n.useState(!1),T=N[0],b=N[1],O=n.useState(null),x=O[0],L=O[1],R=n.useState(0),U=R[0],A=R[1],M=n.useState(null),B=M[0],F=M[1],G=n.useState(!1),V=G[0],X=G[1],H=n.useState(!1),W=H[0],q=H[1],z=n.useState(!1),$=z[0],K=z[1];S().isMobile,n.useEffect((function(){c&&(f?B&&A(B.getBoundingClientRect().height):A(0))}),[f,B,c,V,W,T,$]);var Q=n.useMemo((function(){switch(x){case I.COUPON_CODE_NOT_EXIST:return C("checkout-page:giftCodeErrorDescription");case I.COUPON_CODE_NOT_EXIST_FOR_GUESS:return C("checkout-page:mustBeSignInToApplyCampaign");case I.COUPON_APPLIED_WITHOUT_DISCOUNT:return C("checkout-page:couponInvalidForCartItems");default:return""}}),[x]),J=[v.CartSummary,c?v.HideOnDesktop:"",d?v.SuccessPageCartSummary:""].join(" "),Y=c?{height:U+"px"}:void 0,Z=[v.ArrowDown,f?v.Rotated:""].join(" "),ee=a.checkout.giftCardLines&&a.checkout.giftCardLines.length>0&&a.checkout.giftCardLines.some((function(e){return e.type===y.STORE_CREDIT||e.type===y.GIFT_CARD}));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:v.ExpandHeader,onClick:function(){if(!f){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}g(!f)}},n.createElement("div",{className:v.Left},C("checkout-page:summary")),n.createElement("div",{className:v.Price},n.createElement("span",{className:v.PriceText},"".concat(s(a.finalPrice||0,p.currencyCode,p.currencySymbol)," (").concat(p.itemQuantity," ").concat(C("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:Z},n.createElement(E,null))))),n.createElement("div",{className:J},n.createElement("div",{className:[v.DetailsContainer,d?v.SuccessPageDetailContainer:""].join(" "),style:Y},n.createElement("div",{className:v.Details,ref:F},n.createElement("div",{className:v.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:K,isSuccessPageSummary:d})})))),n.createElement("div",{className:v.Divider}),n.createElement("div",{className:v.SubTotalInfo},T&&n.createElement("div",{className:v.NotificationContainer},n.createElement(r,{type:"warning",title:C("checkout-page:giftCodeErrorTitle"),content:Q,onClose:function(){b(!1),L(null)}})),n.createElement(P,{label:C("checkout-page:subtotal"),value:p.formattedTotalPrice,tooltipText:C("checkout-page:subtotalTooltip"),hideMarginBottom:!a.isCouponCodeVisible}),!!(null===(t=p.shippingLines)||void 0===t?void 0:t.length)&&(a.step===l.SUCCESS?n.createElement(P,{label:C("checkout-page:cartShippingTitle"),value:p.shippingTotal?p.formattedShippingTotal:C("checkout-page:free")}):p.shippingLines.map((function(e,t){return n.createElement(P,{key:t,label:e.paymentMethod?e.title:C("checkout-page:cartShippingTitle"),value:e.finalPrice?s(e.finalPrice,p.currencyCode,p.currencySymbol):C("checkout-page:free")})}))),n.createElement(_,{vm:a}),n.createElement(j,{vm:a}),(a.step===l.SUCCESS&&(!!a.checkout.note||!!a.checkout.appliedCouponCode)||a.step!==l.SUCCESS)&&a.isCouponCodeVisible&&n.createElement("div",{className:v.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(D,{vm:a,isAddingCoupon:W,setAddingCoupon:q,setCouponError:b,setCouponErrorCode:L}),n.createElement(w,{vm:a,isAddingNote:V,setAddingNote:X}),!!a.installmentExtraPrice&&n.createElement(n.Fragment,null,n.createElement("div",{className:v.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(P,{label:C("checkout-page:cartInterest"),value:s(a.installmentExtraPrice,p.currencyCode,p.currencySymbol)}))),n.createElement("div",{className:[v.TotalContainer,d?v.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:v.TitleContainer},n.createElement("div",{className:v.Title},C(ee?"checkout-page:totalAmountPayable":"checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:v.TotalPricesContainer},n.createElement("div",{className:v.TotalPrice},s(a.finalPrice||0,p.currencyCode,p.currencySymbol)),!!p.$totalTax&&!!(null===(o=a.customizationProps)||void 0===o?void 0:o.showTax)&&n.createElement("div",{className:[v.TotalTax].join(" ")},C("checkout-page:cartTaxTitle")+" "+p.$formattedTotalTax)))),!d&&!a.isPoweredByHidden&&n.createElement("div",{className:v.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})),P=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,c=e.hideMarginBottom;return n.createElement("div",{className:[v.InfoRow,c?v.hideMb:""].join(" ")},n.createElement("div",{className:v.Label},n.createElement("span",null,t),!!a&&n.createElement(C,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:v.Value},o))})),_=o((function(e){var t=e.vm,o=u().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").map((function(e,a){return n.createElement("div",{className:v.InfoRow,key:a},n.createElement("div",{className:v.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:v.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,s(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),j=o((function(e){var t,o=e.vm,a=u().t;return o.checkout?n.createElement(n.Fragment,null,null===(t=o.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return n.createElement("div",{className:v.InfoRow,key:t},n.createElement("div",{className:v.Label},n.createElement("div",{className:v.GiftLabel},n.createElement(f,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,a("checkout-page:giftPackage")))),n.createElement("div",{className:v.Value},n.createElement("span",null,s(e.price,o.checkout.currencyCode,o.checkout.currencySymbol))))}))):null})),D=o((function(o){var a=o.vm,r=o.isAddingCoupon,i=o.setAddingCoupon,s=o.setCouponError,m=o.setCouponErrorCode,C=o.isOpenCouponCode,E=o.isMobile,h=o.showOnlyMobile,f=u().t,k=n.useState(""),y=k[0],S=k[1],T=n.useState(!1),b=T[0],O=T[1],I=n.useRef(null);n.useEffect((function(){r&&I.current&&I.current.focus()}),[r]);var x=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return a.checkout.couponCode=y,O(!0),[4,a.onCouponCodeApply()];case 1:return t.sent(),O(!1),S(""),e=a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length,a.couponError?[3,4]:a.checkout.appliedCouponCode||e?(s(!1),m(null),[4,a.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:a.checkout.couponCode=null,s(!0),m(a.couponError),t.label=5;case 5:return[2]}}))}))},P=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return O(!0),[4,a.removeGiftCardLine(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))};a.step,l.SUCCESS;var _=a.step===l.SHIPPING,j=!!a.checkout.appliedCouponCode||!!(a.checkout.giftCardLines&&a.checkout.giftCardLines.length>0),D=!!a.checkout.appliedCouponCode&&C,w=!r&&a.isCouponCodeVisible&&!a.isCouponCodeRequirementOpen&&a.step!==l.SUCCESS,R=j&&(!C||E);return n.createElement(n.Fragment,null,!!C&&n.createElement(n.Fragment,null,n.createElement("div",{className:[v.CartSummary,v.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:g.FormSectionTitle},n.createElement("div",{style:{paddingBottom:D?0:6},className:g.Title},f("checkout-page:couponCode"))))),j&&!_&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:v.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:w?v.InfoRow:""},w&&n.createElement("div",{className:v.ActionTextBtn,onClick:function(){return i(!0)}},f("checkout-page:addCouponCode")),r&&!C&&n.createElement("div",{style:{marginBottom:"10px"}},n.createElement(c,{value:y,placeholder:f("checkout-page:couponCode"),buttonLabel:f("checkout-page:actions.apply"),inputRef:I,onClick:x,isLoading:b,onChange:S})),C&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&x()},className:[v.OpenCouponCodeMain,R?v.OpenCouponCodeMainWithMb:""].join(" ")},n.createElement(d,{label:f("checkout-page:addCouponCode"),type:p.TEXT,value:y,onChange:S}),n.createElement(N,{style:{width:"33%"},text:f("checkout-page:actions.apply"),isLoading:b,onClick:x}))),R&&n.createElement(n.Fragment,null,!!a.checkout.appliedCouponCode&&n.createElement("div",{className:[v.InfoRow,h?v.InfoRowGiftCardMobile:""].join(" ")},n.createElement(L,{vm:a,onClearCouponCode: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,O(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))},couponCode:a.checkout.appliedCouponCode})),!!a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length&&a.checkout.giftCardLines.map((function(e){return n.createElement("div",{className:[v.InfoRow,h?v.InfoRowGiftCardMobile:""].join(" ")},n.createElement(L,{vm:a,onClearGiftCode:P,couponCode:e.code,giftCardLine:e}))}))))})),L=o((function(e){var t=e.vm,o=e.onClearCouponCode,a=e.couponCode,c=e.giftCardLine,r=e.onClearGiftCode,i=t.checkout.couponAdjustment,m=u().t,d=!c,p=(null==c?void 0:c.type)===y.STORE_CREDIT;return n.createElement(n.Fragment,null,n.createElement("div",{className:[v.ActionTextBtn,v.NoUnderline].join(" ")},c&&p&&n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},n.createElement("span",{style:{height:"20px"}},n.createElement(O,null)),n.createElement("span",{className:v.StoreCreditTag},m("checkout-page:storeCredit"))),!p&&n.createElement("span",{className:[v.AppliedCoupon,t.isCouponCodeRequirementDefult?"":v.NotClosed].join(" ")},d?n.createElement("span",{style:{height:"16px"}},n.createElement(T,null)):!p&&n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)),n.createElement("span",{className:v.CouponCode},a),t.step!==l.SUCCESS&&n.createElement("span",{className:v.ClearCoupon,onClick:function(){return c?r&&r(c.giftCardId):o&&o()}},n.createElement(h,null)))),n.createElement("div",null,c?n.createElement("div",{className:v.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==c?void 0:c.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):n.createElement("div",{className:v.Value},n.createElement("span",null,"DECREMENT"===(null==i?void 0:i.type)?"- ":"")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),w=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,c=u().t,r=n.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),s=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===l.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:v.InfoRow},!o&&!m&&n.createElement("div",{className:v.ActionTextBtn,onClick:i},r),(o||m)&&n.createElement("div",{className:[v.CheckoutNoteContainer,m?v.Success:""].join(" ")},n.createElement("div",{className:v.Title},c("checkout-page:orderNote")),m?n.createElement("div",{className:v.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:s,maxLength:320})))}));export{x as CartSummary,D as Coupon,I 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 r from"../notification-box/index.js";import{CheckoutStep as l}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as s}from"../../../../utils/currency.js";import{useTranslation as m}from"../../../../utils/i18n.js";import{CartItem as u}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import C from"../tooltip/index.js";import E from"../svg/arrow-down.js";import h from"../svg/cross.js";import f from"../svg/gift.js";import g from"../../styles/common.module.scss.js";import v from"./style.module.scss.js";import k from"../svg/ikas.js";import{Button as N}from"../button/index.js";import{IkasGiftCardType as y}from"@ikas/storefront-models";import S from"../../../../hooks/useDimension.js";import T from"../svg/coupon-code-tag.js";import b from"../svg/gift-cart-tag.js";import O from"../svg/store-credit-tag.js";var I;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS",e.COUPON_APPLIED_WITHOUT_DISCOUNT="COUPON_APPLIED_WITHOUT_DISCOUNT"}(I||(I={}));var x=o((function(e){var t,o,a=e.vm,c=e.allowExpand,d=e.isSuccessPageSummary,p=a.checkout,C=m().t,h=n.useState(!c),f=h[0],g=h[1],N=n.useState(!1),y=N[0],T=N[1],b=n.useState(null),O=b[0],x=b[1],w=n.useState(0),R=w[0],U=w[1],A=n.useState(null),M=A[0],B=A[1],F=n.useState(!1),G=F[0],V=F[1],X=n.useState(!1),H=X[0],W=X[1],q=n.useState(!1),z=q[0],$=q[1];S().isMobile,n.useEffect((function(){c&&(f?M&&U(M.getBoundingClientRect().height):U(0))}),[f,M,c,G,H,y,z]);var K=n.useMemo((function(){switch(O){case I.COUPON_CODE_NOT_EXIST:return C("checkout-page:giftCodeErrorDescription");case I.COUPON_CODE_NOT_EXIST_FOR_GUESS:return C("checkout-page:mustBeSignInToApplyCampaign");case I.COUPON_APPLIED_WITHOUT_DISCOUNT:return C("checkout-page:couponInvalidForCartItems");default:return""}}),[O]),Q=[v.CartSummary,c?v.HideOnDesktop:"",d?v.SuccessPageCartSummary:""].join(" "),J=c?{height:R+"px"}:void 0,Y=[v.ArrowDown,f?v.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:v.ExpandHeader,onClick:function(){if(!f){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}g(!f)}},n.createElement("div",{className:v.Left},C("checkout-page:summary")),n.createElement("div",{className:v.Price},n.createElement("span",{className:v.PriceText},"".concat(s(a.finalPrice||0,p.currencyCode,p.currencySymbol)," (").concat(p.itemQuantity," ").concat(C("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:Y},n.createElement(E,null))))),n.createElement("div",{className:Q},n.createElement("div",{className:[v.DetailsContainer,d?v.SuccessPageDetailContainer:""].join(" "),style:J},n.createElement("div",{className:v.Details,ref:B},n.createElement("div",{className:v.ItemsContainer},n.createElement("div",null,p.items.map((function(e,t){return n.createElement(u,{key:t,vm:a,cartItem:e,currencyCode:p.currencyCode,onChange:$,isSuccessPageSummary:d})})))),n.createElement("div",{className:v.Divider}),n.createElement("div",{className:v.SubTotalInfo},y&&n.createElement("div",{className:v.NotificationContainer},n.createElement(r,{type:"warning",title:C("checkout-page:giftCodeErrorTitle"),content:K,onClose:function(){T(!1),x(null)}})),n.createElement(P,{label:C("checkout-page:subtotal"),value:p.formattedTotalPrice,tooltipText:C("checkout-page:subtotalTooltip"),hideMarginBottom:!a.isCouponCodeVisible}),!!(null===(t=p.shippingLines)||void 0===t?void 0:t.length)&&(a.step===l.SUCCESS?n.createElement(P,{label:C("checkout-page:cartShippingTitle"),value:p.shippingTotal?p.formattedShippingTotal:C("checkout-page:free")}):p.shippingLines.map((function(e,t){return n.createElement(P,{key:t,label:e.paymentMethod?e.title:C("checkout-page:cartShippingTitle"),value:e.finalPrice?s(e.finalPrice,p.currencyCode,p.currencySymbol):C("checkout-page:free")})}))),n.createElement(_,{vm:a}),n.createElement(j,{vm:a}),(a.step===l.SUCCESS&&(!!a.checkout.note||!!a.checkout.appliedCouponCode)||a.step!==l.SUCCESS)&&a.isCouponCodeVisible&&n.createElement("div",{className:v.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(D,{vm:a,isAddingCoupon:H,setAddingCoupon:W,setCouponError:T,setCouponErrorCode:x}),n.createElement(L,{vm:a,isAddingNote:G,setAddingNote:V}),!!a.installmentExtraPrice&&n.createElement(n.Fragment,null,n.createElement("div",{className:v.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(P,{label:C("checkout-page:cartInterest"),value:s(a.installmentExtraPrice,p.currencyCode,p.currencySymbol)}))),n.createElement("div",{className:[v.TotalContainer,d?v.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:v.TitleContainer},n.createElement("div",{className:v.Title},C("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:v.TotalPricesContainer},n.createElement("div",{className:v.TotalPrice},s(a.finalPrice||0,p.currencyCode,p.currencySymbol)),!!p.$totalTax&&!!(null===(o=a.customizationProps)||void 0===o?void 0:o.showTax)&&n.createElement("div",{className:[v.TotalTax].join(" ")},C("checkout-page:cartTaxTitle")+" "+p.$formattedTotalTax)))),!d&&!a.isPoweredByHidden&&n.createElement("div",{className:v.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})),P=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,c=e.hideMarginBottom;return n.createElement("div",{className:[v.InfoRow,c?v.hideMb:""].join(" ")},n.createElement("div",{className:v.Label},n.createElement("span",null,t),!!a&&n.createElement(C,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:v.Value},o))})),_=o((function(e){var t=e.vm,o=m().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").map((function(e,a){return n.createElement("div",{className:v.InfoRow,key:a},n.createElement("div",{className:v.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:v.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,s(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),j=o((function(e){var t,o=e.vm,a=m().t;return o.checkout?n.createElement(n.Fragment,null,null===(t=o.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return n.createElement("div",{className:v.InfoRow,key:t},n.createElement("div",{className:v.Label},n.createElement("div",{className:v.GiftLabel},n.createElement(f,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,a("checkout-page:giftPackage")))),n.createElement("div",{className:v.Value},n.createElement("span",null,s(e.price,o.checkout.currencyCode,o.checkout.currencySymbol))))}))):null})),D=o((function(o){var a=o.vm,r=o.isAddingCoupon,i=o.setAddingCoupon,s=o.setCouponError,u=o.setCouponErrorCode,C=o.isOpenCouponCode,E=o.isMobile,h=o.showOnlyMobile,f=m().t,k=n.useState(""),y=k[0],S=k[1],T=n.useState(!1),b=T[0],O=T[1],I=n.useRef(null);n.useEffect((function(){r&&I.current&&I.current.focus()}),[r]);var x=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return a.checkout.couponCode=y,O(!0),[4,a.onCouponCodeApply()];case 1:return t.sent(),O(!1),S(""),e=a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length,a.couponError?[3,4]:a.checkout.appliedCouponCode||e?(s(!1),u(null),[4,a.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:a.checkout.couponCode=null,s(!0),u(a.couponError),t.label=5;case 5:return[2]}}))}))},P=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return O(!0),[4,a.removeGiftCardLine(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))};a.step,l.SUCCESS;var _=a.step===l.SHIPPING,j=!!a.checkout.appliedCouponCode||!!(a.checkout.giftCardLines&&a.checkout.giftCardLines.length>0),D=!!a.checkout.appliedCouponCode&&C,L=!r&&a.isCouponCodeVisible&&!a.isCouponCodeRequirementOpen&&a.step!==l.SUCCESS,R=j&&(!C||E);return n.createElement(n.Fragment,null,!!C&&n.createElement(n.Fragment,null,n.createElement("div",{className:[v.CartSummary,v.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:g.FormSectionTitle},n.createElement("div",{style:{paddingBottom:D?0:6},className:g.Title},f("checkout-page:couponCode"))))),j&&!_&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:v.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:L?v.InfoRow:""},L&&n.createElement("div",{className:v.ActionTextBtn,onClick:function(){return i(!0)}},f("checkout-page:addCouponCode")),r&&!C&&n.createElement("div",{style:{marginBottom:"10px"}},n.createElement(c,{value:y,placeholder:f("checkout-page:couponCode"),buttonLabel:f("checkout-page:actions.apply"),inputRef:I,onClick:x,isLoading:b,onChange:S})),C&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&x()},className:[v.OpenCouponCodeMain,R?v.OpenCouponCodeMainWithMb:""].join(" ")},n.createElement(d,{label:f("checkout-page:addCouponCode"),type:p.TEXT,value:y,onChange:S}),n.createElement(N,{style:{width:"33%"},text:f("checkout-page:actions.apply"),isLoading:b,onClick:x}))),R&&n.createElement(n.Fragment,null,!!a.checkout.appliedCouponCode&&n.createElement("div",{className:[v.InfoRow,h?v.InfoRowGiftCardMobile:""].join(" ")},n.createElement(w,{vm:a,onClearCouponCode: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,O(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))},couponCode:a.checkout.appliedCouponCode})),!!a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length&&a.checkout.giftCardLines.map((function(e){return n.createElement("div",{className:[v.InfoRow,h?v.InfoRowGiftCardMobile:""].join(" ")},n.createElement(w,{vm:a,onClearGiftCode:P,couponCode:e.code,giftCardLine:e}))}))))})),w=o((function(e){var t=e.vm,o=e.onClearCouponCode,a=e.couponCode,c=e.giftCardLine,r=e.onClearGiftCode,i=t.checkout.couponAdjustment,u=m().t,d=!c,p=(null==c?void 0:c.type)===y.STORE_CREDIT;return n.createElement(n.Fragment,null,n.createElement("div",{className:[v.ActionTextBtn,v.NoUnderline].join(" ")},c&&p&&n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},n.createElement("span",{style:{height:"20px"}},n.createElement(O,null)),n.createElement("span",{className:v.StoreCreditTag},u("checkout-page:storeCredit"))),!p&&n.createElement("span",{className:[v.AppliedCoupon,t.isCouponCodeRequirementDefult?"":v.NotClosed].join(" ")},d?n.createElement("span",{style:{height:"16px"}},n.createElement(T,null)):!p&&n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)),n.createElement("span",{className:v.CouponCode},a),t.step!==l.SUCCESS&&n.createElement("span",{className:v.ClearCoupon,onClick:function(){return c?r&&r(c.giftCardId):o&&o()}},n.createElement(h,null)))),n.createElement("div",null,c?n.createElement("div",{className:v.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==c?void 0:c.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):n.createElement("div",{className:v.Value},n.createElement("span",null,"DECREMENT"===(null==i?void 0:i.type)?"- ":"")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),L=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,c=m().t,r=n.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),s=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var u=t.step===l.SUCCESS;return u&&!t.checkout.note?null:n.createElement("div",{className:v.InfoRow},!o&&!u&&n.createElement("div",{className:v.ActionTextBtn,onClick:i},r),(o||u)&&n.createElement("div",{className:[v.CheckoutNoteContainer,u?v.Success:""].join(" ")},n.createElement("div",{className:v.Title},c("checkout-page:orderNote")),u?n.createElement("div",{className:v.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:s,maxLength:320})))}));export{x as CartSummary,D as Coupon,I as CouponErrorCode};
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ declare type Props = {
3
+ className?: string;
4
+ };
5
+ declare const SVGSubscription: React.FC<Props>;
6
+ export default SVGSubscription;
@@ -0,0 +1 @@
1
+ import*as e from"react";var t=function(t){return t.className,e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},e.createElement("path",{d:"M1 7C1 7 1.06066 7.42462 2.81802 9.18198C4.57538 10.9393 7.42462 10.9393 9.18198 9.18198C9.80462 8.55934 10.2067 7.79964 10.3881 7M1 7V10M1 7H4M11 5C11 5 10.9393 4.57538 9.18198 2.81802C7.42462 1.06066 4.57538 1.06066 2.81802 2.81802C2.19538 3.44066 1.79335 4.20036 1.61191 5M11 5V2M11 5H8",stroke:"#5A44D5","stroke-width":"1.2","stroke-linecap":"round","stroke-linejoin":"round"}))};export{t as default};
@@ -1 +1 @@
1
- import{__extends as e,__assign as o}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import{makeObservable as i,computed as n}from"mobx";import a from"../checkout/index.js";import{Observer as d}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{IkasThemeJsonPageType as s,IkasOrderLineItemStatus as m,IkasCheckoutRequirement as l,IkasCouponCodeRequirement as p,IkasThemeJsonComponentPropType as u}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as c}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as f}from"../../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{IkasOrderLineItem as j}from"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{IkasPageDataInit as g}from"../../page-data-init/index.js";import{IkasBaseStore as x}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";var h=function(h){function y(e){var o=h.call(this,e)||this;return o.state={hasError:!1},o.onMouseEnter=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseOver(r.id)},o.onMouseLeave=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseLeave(r.id)},o.onClick=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onClick(r.id)},o.ref=t.createRef(),i(o,{pageComponentPropValue:n,propValues:n,isSelected:n,isHovered:n,hasNullValue:n,rendered:n,Component:n}),o}return e(y,h),y.prototype.componentDidMount=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},y.prototype.componentDidUpdate=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},y.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(y.prototype,"pageComponentPropValue",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.initializedPropValues.find((function(e){return e.pageComponent.id===t.id}))},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"propValues",{get:function(){var e,t,r=this.props.vm,i=null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.propValues;(null===(t=r.page)||void 0===t?void 0:t.type)===s.CHECKOUT&&(i={checkout:new c({currencyCode:"TRY",currencySymbol:"₺",orderLineItems:[new j({id:"",createdAt:0,updatedAt:0,bundleProductSettings:null,currencyCode:"TRY",currencySymbol:"₺",discount:null,discountPrice:null,finalPrice:100,options:null,originalOrderLineItemId:null,price:100,quantity:1,status:m.UNFULFILLED,statusUpdatedAt:null,stockLocationId:null,taxValue:null,unitPrice:null,finalUnitPrice:null,variant:{barcodeList:null,brand:null,categories:null,fileId:null,id:null,mainImageId:null,name:"",prices:null,productId:null,sku:null,slug:null,tagIds:null,taxValue:null,type:null,weight:null,hsCode:null,variantValues:[],baseUnit:null,unit:null,tags:null,bundleProducts:null},orderedAt:0})]}),checkoutSettings:new f({createdAt:0,updatedAt:0,id:"",giftPackagePriceList:null,identityNumberRequirement:l.OPTIONAL,isAccountRequired:!1,isGiftPackageEnabled:!1,isQuickRegistrationEnabled:!1,isShowPostalCode:!0,isTermsAndConditionsDefaultChecked:null,options:null,phoneRequirement:l.OPTIONAL,postalCodeRequirement:l.OPTIONAL,showCheckoutNote:!0,showCompanyInfoInShippingAddress:null,showBillingAddressOnShippingStep:null,showTermsAndConditionsCheckbox:!0,storefrontId:"",couponCodeRequirement:p.DEFAULT,corporateInvoiceRequirement:null}),customizationProps:o({},i),returnPolicy:"",privacyPolicy:"",termsOfService:"",imprint:"",shippingPolicy:""});return i},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isSelected",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.selectedPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isHovered",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.hoveredPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"hasNullValue",{get:function(){var e,o=this;return!!(null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.props.some((function(e){var t;if(e.isRequired){var r=(o.propValues||{})[e.name],i=null===(t=o.pageComponentPropValue)||void 0===t?void 0:t.component.props.find((function(o){return o.id===e.requiredPropId}));if(i){var n=(o.propValues||{})[i.name];if(i.type===u.BOOLEAN&&!n||i.type===u.CUSTOM&&n!==e.requiredEnumOptionValue)return!1}return null===r||null==r}})))},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"rendered",{get:function(){var e,i,n=this.Component,a=this.props.vm;return this.hasNullValue||this.state.hasError?t.createElement(r,{name:null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.displayName}):t.createElement(n,o({},this.propValues,{store:x.getInstance(),settings:null===(i=a.theme)||void 0===i?void 0:i.settings,pageSpecificData:g.pageSpecificData}))},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"Component",{get:function(){var e,o=this.props,t=o.vm,r=o.pageComponent,i=v.getCurrentPageComponents();if(!i)return null;var n=i[r.componentId];return(null===(e=t.page)||void 0===e?void 0:e.type)===s.CHECKOUT&&(n=a),n},enumerable:!1,configurable:!0}),y.prototype.render=function(){var e=this;return t.createElement(d,null,(function(){var o;return e.state.hasError?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},t.createElement(r,{name:null===(o=e.pageComponentPropValue)||void 0===o?void 0:o.component.displayName})):v.getCurrentPageComponents()?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave},e.rendered):(console.error("Components for the page not found."),null)}))},y}(t.Component);export{h as ThemeEditorComponent};
1
+ import{__extends as e,__assign as o}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import{makeObservable as i,computed as n}from"mobx";import a from"../checkout/index.js";import{Observer as d}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{IkasThemeJsonPageType as s,IkasOrderLineItemStatus as m,IkasCheckoutRequirement as l,IkasCouponCodeRequirement as p,IkasThemeJsonComponentPropType as u}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as c}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as f}from"../../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{IkasOrderLineItem as j}from"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{IkasPageDataInit as g}from"../../page-data-init/index.js";import{IkasBaseStore as x}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";var h=function(h){function y(e){var o=h.call(this,e)||this;return o.state={hasError:!1},o.onMouseEnter=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseOver(r.id)},o.onMouseLeave=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseLeave(r.id)},o.onClick=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onClick(r.id)},o.ref=t.createRef(),i(o,{pageComponentPropValue:n,propValues:n,isSelected:n,isHovered:n,hasNullValue:n,rendered:n,Component:n}),o}return e(y,h),y.prototype.componentDidMount=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},y.prototype.componentDidUpdate=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},y.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(y.prototype,"pageComponentPropValue",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.initializedPropValues.find((function(e){return e.pageComponent.id===t.id}))},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"propValues",{get:function(){var e,t,r=this.props.vm,i=null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.propValues;(null===(t=r.page)||void 0===t?void 0:t.type)===s.CHECKOUT&&(i={checkout:new c({currencyCode:"TRY",currencySymbol:"₺",orderLineItems:[new j({id:"",createdAt:0,updatedAt:0,bundleProductSettings:null,currencyCode:"TRY",currencySymbol:"₺",discount:null,discountPrice:null,finalPrice:100,options:null,originalOrderLineItemId:null,price:100,quantity:1,status:m.UNFULFILLED,statusUpdatedAt:null,stockLocationId:null,taxValue:null,unitPrice:null,finalUnitPrice:null,variant:{barcodeList:null,brand:null,categories:null,fileId:null,id:null,mainImageId:null,name:"",prices:null,productId:null,sku:null,slug:null,tagIds:null,taxValue:null,type:null,weight:null,hsCode:null,variantValues:[],baseUnit:null,unit:null,tags:null,bundleProducts:null},orderedAt:0,subscriptionPlan:null})]}),checkoutSettings:new f({createdAt:0,updatedAt:0,id:"",giftPackagePriceList:null,identityNumberRequirement:l.OPTIONAL,isAccountRequired:!1,isGiftPackageEnabled:!1,isQuickRegistrationEnabled:!1,isShowPostalCode:!0,isTermsAndConditionsDefaultChecked:null,options:null,phoneRequirement:l.OPTIONAL,postalCodeRequirement:l.OPTIONAL,showCheckoutNote:!0,showCompanyInfoInShippingAddress:null,showBillingAddressOnShippingStep:null,showTermsAndConditionsCheckbox:!0,storefrontId:"",couponCodeRequirement:p.DEFAULT,corporateInvoiceRequirement:null}),customizationProps:o({},i),returnPolicy:"",privacyPolicy:"",termsOfService:"",imprint:"",shippingPolicy:""});return i},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isSelected",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.selectedPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isHovered",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.hoveredPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"hasNullValue",{get:function(){var e,o=this;return!!(null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.props.some((function(e){var t;if(e.isRequired){var r=(o.propValues||{})[e.name],i=null===(t=o.pageComponentPropValue)||void 0===t?void 0:t.component.props.find((function(o){return o.id===e.requiredPropId}));if(i){var n=(o.propValues||{})[i.name];if(i.type===u.BOOLEAN&&!n||i.type===u.CUSTOM&&n!==e.requiredEnumOptionValue)return!1}return null===r||null==r}})))},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"rendered",{get:function(){var e,i,n=this.Component,a=this.props.vm;return this.hasNullValue||this.state.hasError?t.createElement(r,{name:null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.displayName}):t.createElement(n,o({},this.propValues,{store:x.getInstance(),settings:null===(i=a.theme)||void 0===i?void 0:i.settings,pageSpecificData:g.pageSpecificData}))},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"Component",{get:function(){var e,o=this.props,t=o.vm,r=o.pageComponent,i=v.getCurrentPageComponents();if(!i)return null;var n=i[r.componentId];return(null===(e=t.page)||void 0===e?void 0:e.type)===s.CHECKOUT&&(n=a),n},enumerable:!1,configurable:!0}),y.prototype.render=function(){var e=this;return t.createElement(d,null,(function(){var o;return e.state.hasError?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},t.createElement(r,{name:null===(o=e.pageComponentPropValue)||void 0===o?void 0:o.component.displayName})):v.getCurrentPageComponents()?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave},e.rendered):(console.error("Components for the page not found."),null)}))},y}(t.Component);export{h as ThemeEditorComponent};
@@ -4,6 +4,7 @@ import { IkasOrderLineVariant } from "./variant";
4
4
  import { IkasOrderLineItemOption } from "./option";
5
5
  import { IkasOrderLineBundleProductSettings } from "./bundle-product-settings";
6
6
  import { IkasBaseModel } from "../../base";
7
+ import { IkasOrderLineItemSubscriptionPlan } from "./order-line-item-subscription-plan";
7
8
  declare type IOrderLineItemConstructorParams = {
8
9
  refundQuantity?: number;
9
10
  } & IOrderLineItem;
@@ -26,6 +27,7 @@ export declare class IkasOrderLineItem extends IkasBaseModel implements IOrderLi
26
27
  unitPrice: number | null;
27
28
  variant: IkasOrderLineVariant;
28
29
  orderedAt: number;
30
+ subscriptionPlan: IkasOrderLineItemSubscriptionPlan | null;
29
31
  private _refundQuantity;
30
32
  constructor(data: IOrderLineItemConstructorParams);
31
33
  get priceWithQuantity(): number;
@@ -1 +1 @@
1
- import{__extends as t}from'./../../../../ext/tslib/tslib.es6.js';export{IkasOrderLineItemStatus}from"@ikas/storefront-models";import{IkasOrderLineDiscount as e}from"./discount/index.js";import{IkasOrderLineVariant as i}from"./variant/index.js";import{IkasOrderLineItemOption as n}from"./option/index.js";import{IkasOrderLineBundleProductSettings as r}from"./bundle-product-settings/index.js";import{IkasBaseModel as o}from"../../base/index.js";import{makeObservable as u,observable as c,computed as a,action as l}from"mobx";import{IkasOrderLineItemFunctions as d}from"@ikas/storefront-model-functions";import{formatCurrency as s}from"../../../../utils/currency.js";import{IkasBaseStore as f}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var y=function(o){function y(t){var d,s,f,y,m,p=this;return(p=o.call(this,t)||this).bundleProductSettings=null,p.currencyCode=null,p.discount=null,p.discountPrice=null,p.finalPrice=null,p.options=null,p.originalOrderLineItemId=null,p.statusUpdatedAt=null,p.stockLocationId=null,p.taxValue=null,p._refundQuantity=null,p.bundleProductSettings=t.bundleProductSettings?new r(t.bundleProductSettings):null,p.currencyCode=t.currencyCode||null,p.currencySymbol=t.currencySymbol||null,p.discount=t.discount?new e(t.discount):null,p.discountPrice=null!==(d=t.discountPrice)&&void 0!==d?d:null,p.finalPrice=null!==(s=t.finalPrice)&&void 0!==s?s:null,p.finalUnitPrice=null!==(f=t.finalUnitPrice)&&void 0!==f?f:null,p.options=(null===(y=t.options)||void 0===y?void 0:y.map((function(t){return new n(t)})))||null,p.originalOrderLineItemId=t.originalOrderLineItemId||null,p.price=t.price,p.quantity=t.quantity,p.status=t.status,p.statusUpdatedAt=t.statusUpdatedAt,p.stockLocationId=t.stockLocationId,p.taxValue=t.taxValue,p.unitPrice=null!==(m=t.unitPrice)&&void 0!==m?m:null,p.variant=new i(t.variant),p.orderedAt=t.orderedAt,p.refundQuantity=t.refundQuantity,u(p,{bundleProductSettings:c,currencyCode:c,currencySymbol:c,discount:c,discountPrice:c,finalPrice:c,finalUnitPrice:c,options:c,originalOrderLineItemId:c,price:c,quantity:c,status:c,statusUpdatedAt:c,stockLocationId:c,taxValue:c,unitPrice:c,variant:c,orderedAt:c,_refundQuantity:c,priceWithQuantity:a,formattedPriceWithQuantity:a,overridenPriceWithQuantity:a,formattedOverridenPriceWithQuantity:a,formattedFinalPrice:a,formattedUnitPrice:a,formattedFinalUnitPrice:a,formattedDiscountPrice:a,finalPriceWithQuantity:a,formattedFinalPriceWithQuantity:a,tax:a,formattedTax:a,refundQuantity:a,editLineItem:l.bound}),p}return t(y,o),Object.defineProperty(y.prototype,"priceWithQuantity",{get:function(){return d.getPriceWithQuantity(this)},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedPriceWithQuantity",{get:function(){return s(this.priceWithQuantity,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"overridenPriceWithQuantity",{get:function(){return d.getOverridenPriceWithQuantity(this)},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedOverridenPriceWithQuantity",{get:function(){return s(this.overridenPriceWithQuantity||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedFinalPrice",{get:function(){return s(this.finalPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedUnitPrice",{get:function(){return s(this.unitPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedFinalUnitPrice",{get:function(){return s(this.finalUnitPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"unitPriceText",{get:function(){var t,e,i,n;if(null!==this.finalUnitPrice){var r=null===(t=this.variant.baseUnit)||void 0===t?void 0:t.baseAmount,o=(null===(i=null===(e=this.variant.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||(null===(n=this.variant.baseUnit)||void 0===n?void 0:n.type);return"".concat(s(this.finalUnitPrice,this.currencyCode||"",this.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(o)}},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedDiscountPrice",{get:function(){return s(this.discountPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"finalPriceWithQuantity",{get:function(){return d.getFinalPriceWithQuantity(this)},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedFinalPriceWithQuantity",{get:function(){return s(this.finalPriceWithQuantity||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"tax",{get:function(){return d.getTax(this)},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"formattedTax",{get:function(){return s(this.tax,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"hasDiscount",{get:function(){return d.hasDiscount(this)},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"refundQuantity",{get:function(){return this._refundQuantity},set:function(t){t?(t>this.quantity&&(t=this.quantity),t<=0&&(t=null),this._refundQuantity=t):this._refundQuantity=null},enumerable:!1,configurable:!0}),y.prototype.editLineItem=function(){var t,e=this.variant.href||"";e=e.includes("?")?e+"&editLineID="+this.id:e+"?editLineID="+this.id,null===(t=f.getInstance().router)||void 0===t||t.push(e)},y}(o);export{y as IkasOrderLineItem};
1
+ import{__extends as t}from'./../../../../ext/tslib/tslib.es6.js';export{IkasOrderLineItemStatus}from"@ikas/storefront-models";import{IkasOrderLineDiscount as e}from"./discount/index.js";import{IkasOrderLineVariant as i}from"./variant/index.js";import{IkasOrderLineItemOption as n}from"./option/index.js";import{IkasOrderLineBundleProductSettings as r}from"./bundle-product-settings/index.js";import{IkasBaseModel as o}from"../../base/index.js";import{makeObservable as u,observable as c,computed as a,action as l}from"mobx";import{IkasOrderLineItemFunctions as d}from"@ikas/storefront-model-functions";import{formatCurrency as s}from"../../../../utils/currency.js";import{IkasBaseStore as f}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{IkasOrderLineItemSubscriptionPlan as y}from"./order-line-item-subscription-plan/index.js";var p=function(o){function p(t){var d,s,f,p,m,b=this;return(b=o.call(this,t)||this).bundleProductSettings=null,b.currencyCode=null,b.discount=null,b.discountPrice=null,b.finalPrice=null,b.options=null,b.originalOrderLineItemId=null,b.statusUpdatedAt=null,b.stockLocationId=null,b.taxValue=null,b.subscriptionPlan=null,b._refundQuantity=null,b.bundleProductSettings=t.bundleProductSettings?new r(t.bundleProductSettings):null,b.currencyCode=t.currencyCode||null,b.currencySymbol=t.currencySymbol||null,b.discount=t.discount?new e(t.discount):null,b.discountPrice=null!==(d=t.discountPrice)&&void 0!==d?d:null,b.finalPrice=null!==(s=t.finalPrice)&&void 0!==s?s:null,b.finalUnitPrice=null!==(f=t.finalUnitPrice)&&void 0!==f?f:null,b.options=(null===(p=t.options)||void 0===p?void 0:p.map((function(t){return new n(t)})))||null,b.originalOrderLineItemId=t.originalOrderLineItemId||null,b.price=t.price,b.quantity=t.quantity,b.status=t.status,b.statusUpdatedAt=t.statusUpdatedAt,b.stockLocationId=t.stockLocationId,b.taxValue=t.taxValue,b.unitPrice=null!==(m=t.unitPrice)&&void 0!==m?m:null,b.variant=new i(t.variant),b.orderedAt=t.orderedAt,b.subscriptionPlan=t.subscriptionPlan?new y(t.subscriptionPlan):null,b.refundQuantity=t.refundQuantity,u(b,{bundleProductSettings:c,currencyCode:c,currencySymbol:c,discount:c,discountPrice:c,finalPrice:c,finalUnitPrice:c,options:c,originalOrderLineItemId:c,price:c,quantity:c,status:c,statusUpdatedAt:c,stockLocationId:c,taxValue:c,unitPrice:c,variant:c,orderedAt:c,subscriptionPlan:c,_refundQuantity:c,priceWithQuantity:a,formattedPriceWithQuantity:a,overridenPriceWithQuantity:a,formattedOverridenPriceWithQuantity:a,formattedFinalPrice:a,formattedUnitPrice:a,formattedFinalUnitPrice:a,formattedDiscountPrice:a,finalPriceWithQuantity:a,formattedFinalPriceWithQuantity:a,tax:a,formattedTax:a,refundQuantity:a,editLineItem:l.bound}),b}return t(p,o),Object.defineProperty(p.prototype,"priceWithQuantity",{get:function(){return d.getPriceWithQuantity(this)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedPriceWithQuantity",{get:function(){return s(this.priceWithQuantity,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"overridenPriceWithQuantity",{get:function(){return d.getOverridenPriceWithQuantity(this)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedOverridenPriceWithQuantity",{get:function(){return s(this.overridenPriceWithQuantity||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedFinalPrice",{get:function(){return s(this.finalPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedUnitPrice",{get:function(){return s(this.unitPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedFinalUnitPrice",{get:function(){return s(this.finalUnitPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"unitPriceText",{get:function(){var t,e,i,n;if(null!==this.finalUnitPrice){var r=null===(t=this.variant.baseUnit)||void 0===t?void 0:t.baseAmount,o=(null===(i=null===(e=this.variant.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||(null===(n=this.variant.baseUnit)||void 0===n?void 0:n.type);return"".concat(s(this.finalUnitPrice,this.currencyCode||"",this.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(o)}},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedDiscountPrice",{get:function(){return s(this.discountPrice||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"finalPriceWithQuantity",{get:function(){return d.getFinalPriceWithQuantity(this)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedFinalPriceWithQuantity",{get:function(){return s(this.finalPriceWithQuantity||0,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"tax",{get:function(){return d.getTax(this)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"formattedTax",{get:function(){return s(this.tax,this.currencyCode||"",this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"hasDiscount",{get:function(){return d.hasDiscount(this)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"refundQuantity",{get:function(){return this._refundQuantity},set:function(t){t?(t>this.quantity&&(t=this.quantity),t<=0&&(t=null),this._refundQuantity=t):this._refundQuantity=null},enumerable:!1,configurable:!0}),p.prototype.editLineItem=function(){var t,e=this.variant.href||"";e=e.includes("?")?e+"&editLineID="+this.id:e+"?editLineID="+this.id,null===(t=f.getInstance().router)||void 0===t||t.push(e)},p}(o);export{p as IkasOrderLineItem};
@@ -0,0 +1,8 @@
1
+ import { IkasOrderLineItemSubscriptionPlan as IOrderLineItemSubscriptionPlan } from "@ikas/storefront-models";
2
+ import { IkasOrderLineItemSubscriptionPlanPeriod } from "./order-line-item-subscription-plan-period";
3
+ export declare class IkasOrderLineItemSubscriptionPlan implements IOrderLineItemSubscriptionPlan {
4
+ id: string;
5
+ name: string;
6
+ period: IkasOrderLineItemSubscriptionPlanPeriod;
7
+ constructor(data: IOrderLineItemSubscriptionPlan);
8
+ }
@@ -0,0 +1 @@
1
+ import{makeAutoObservable as i}from"mobx";import{IkasOrderLineItemSubscriptionPlanPeriod as o}from"./order-line-item-subscription-plan-period/index.js";var r=function(r){this.id=r.id,this.name=r.name,this.period=new o(r.period),i(this)};export{r as IkasOrderLineItemSubscriptionPlan};
@@ -0,0 +1,6 @@
1
+ import { IkasOrderLineItemSubscriptionPlanDiscountAmountType, IkasOrderLineItemSubscriptionPlanDiscount as IOrderLineItemSubscriptionPlanDiscount } from "@ikas/storefront-models";
2
+ export declare class IkasOrderLineItemSubscriptionPlanDiscount implements IOrderLineItemSubscriptionPlanDiscount {
3
+ amount: number;
4
+ type: IkasOrderLineItemSubscriptionPlanDiscountAmountType;
5
+ constructor(data: IOrderLineItemSubscriptionPlanDiscount);
6
+ }
@@ -0,0 +1 @@
1
+ var t=function(t){this.amount=t.amount,this.type=t.type};export{t as IkasOrderLineItemSubscriptionPlanDiscount};
@@ -0,0 +1,14 @@
1
+ import { IkasOrderLineItemSubscriptionPlanPeriod as IOrderLineItemSubscriptionPlanPeriod, IkasOrderLineItemSubscriptionPlanDurationUnitType, IkasOrderLineItemSubscriptionPlanPaymentType } from "@ikas/storefront-models";
2
+ import { IkasOrderLineItemSubscriptionPlanDiscount } from "../order-line-item-subscription-plan-discount";
3
+ export declare class IkasOrderLineItemSubscriptionPlanPeriod implements IOrderLineItemSubscriptionPlanPeriod {
4
+ cutOffDay: number | null;
5
+ discount: IkasOrderLineItemSubscriptionPlanDiscount | null;
6
+ durationUnit: IkasOrderLineItemSubscriptionPlanDurationUnitType;
7
+ durationValue: number;
8
+ id: string;
9
+ maxOrders: number | null;
10
+ paymentType: IkasOrderLineItemSubscriptionPlanPaymentType;
11
+ scheduledOrderDay: number | null;
12
+ title: string;
13
+ constructor(data: IOrderLineItemSubscriptionPlanPeriod);
14
+ }
@@ -0,0 +1 @@
1
+ import{makeAutoObservable as t}from"mobx";import{IkasOrderLineItemSubscriptionPlanDiscount as i}from"../order-line-item-subscription-plan-discount/index.js";var e=function(e){this.cutOffDay=e.cutOffDay,this.discount=e.discount?new i(e.discount):null,this.durationUnit=e.durationUnit,this.durationValue=e.durationValue,this.id=e.id,this.maxOrders=e.maxOrders,this.paymentType=e.paymentType,this.scheduledOrderDay=e.scheduledOrderDay,this.title=e.title,t(this)};export{e as IkasOrderLineItemSubscriptionPlanPeriod};
@@ -88,6 +88,7 @@ export declare class IkasProduct implements IProduct {
88
88
  initBundleProducts: () => Promise<void>;
89
89
  setShowVariantsInGroup: (value: boolean) => void;
90
90
  getBundleProductsOfVariant: (variant: IkasProductVariant) => Promise<void>;
91
+ getSubscriptionPlanOfVariant: (variant: IkasProductVariant) => Promise<void>;
91
92
  setOptionRealPrices: () => void;
92
93
  private setOptionPrices;
93
94
  }
@@ -1 +1 @@
1
- import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as s}from"./variant/index.js";import{IkasProductAttributeValue as u}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductOptionPriceTypeEnum as f,IkasProductType as h}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as v}from"./option-set/index.js";import{makeObservable as m,observable as g,computed as V}from"mobx";import{IkasProductFunctions as b}from"@ikas/storefront-model-functions";import{IkasProductCampaign as y}from"./campaign/index.js";import{IkasStorefrontConfig as I}from"@ikas/storefront-config";import{IkasBaseStore as P}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as w}from"./base-unit/index.js";import{formatCurrency as S}from"../../../utils/currency.js";import"lodash/get";import T from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as C}from"./star/index.js";import{IkasProductCampaignOffer as x,IkasProductOffer as R}from"./campaign-offer/index.js";import{IkasProductGroup as L}from"./group/index.js";import{IkasImage as G}from"../image/index.js";import{IkasProductSalesChannel as E}from"./sales-channel/index.js";import{IkasProductTranslation as k}from"./translations/index.js";var A=function(){function A(b){void 0===b&&(b={});var O,G,D,U=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.translations=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.selectVariantValue=function(i,n){var r,a=U.metaData,o=U.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),s=U.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(s)U.selectedVariantValues=o;else{var u=U.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(u>0){var c=U.variantTypes.slice(0,u),d=U.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[i],!1);s=U.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(s=U.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(s=U.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!s)return;U.selectedVariantValues=s.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;"vid"!==i&&(f=e(e({},f),((n={})[i]=t,n)))})),U.variantTypes.map((function(t){delete f[decodeURIComponent(t.variantType.slug)]}));var h=t(t([],Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0),U.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return U.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0).filter((function(t){return!!t})).join("&");if(U.setOptionRealPrices(),!n){var v="/".concat(a.slug);if(h&&(v="/".concat(a.slug,"?").concat(h)),v===window.location.pathname)return;null===(r=P.getInstance().router)||void 0===r||r.replace(v,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&U.baseUnit){var r=U.baseUnit.baseAmount,a=(null===(i=null===(e=U.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(S(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=P.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,T.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:I.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=I.getPickupStockLocationIds(),[4,T.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return i(U,void 0,void 0,(function(){var i,r,a,o,s;return n(this,(function(n){switch(n.label){case 0:return i=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],i&&(null===(s=this.selectedVariant.bundleSettings)||void 0===s||s.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new j(e(e(e({},i?{}:{productId:this.id}),{locale:null==t?void 0:t.locale,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage,sortWithImagesFirst:null==t?void 0:t.sortWithImagesFirst}),i?{productIds:r}:{}))).getInitial()];case 1:return n.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,T.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),this.setOptionRealPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o;return n(this,(function(n){switch(n.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(i=null===(a=P.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===i.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:n.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,n,r;try{var a=null===(e=i.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(n=i.variant.bundleProducts)||void 0===n?void 0:n.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),n.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){U.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i,r,o,s,u,c=this;return n(this,(function(n){switch(n.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,T.searchProducts({input:{productIdList:e,perPage:200,priceListId:I.getPriceListId(),salesChannelId:I.getSalesChannelId()}})]:[3,2];case 1:(i=n.sent()).isSuccess&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){c.bundleProductCache[t.id]=t}))),n.label=2;case 2:return null===(u=t.bundleSettings)||void 0===u||u.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new A(a(e)))})),[2]}}))}))},this.setOptionRealPrices=function(){var t,e=U.selectedVariant||U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;if(t.selectSettings)t.selectSettings.values.forEach((function(t){var e;if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}));else if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}))}},this.setOptionPrices=function(){var t,e=U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var n,r;if(t.selectSettings&&t.selectSettings.values.forEach((function(t){var n,r;if(t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price})),t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price}))}},this.id=b.id||Date.now()+"",this.name=b.name||"",this.type=b.type||h.PHYSICAL,this.description=b.description||"",this.shortDescription=b.shortDescription||"",this.metaData=b.metaData?new l(b.metaData):null,this.brand=b.brand?new d(b.brand):null,this.categories=b.categories?b.categories.map((function(t){return new o(t)})):[],this.deleted=b.deleted||null,this.tags=b.tags?b.tags.map((function(t){return new p(t)})):[],this.variants=b.variants?b.variants.map((function(t){return new s(t)})):[],this.attributes=b.attributes?b.attributes.map((function(t){return new u(t)})):[],this.variantTypes=b.variantTypes?b.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=b.productOptionSetId||null,this.averageRating=null!==(O=b.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(G=b.reviewCount)&&void 0!==G?G:null,this.stars=b.stars?b.stars.map((function(t){return new C(t)})):null,this.baseUnit=b.baseUnit?new w(b.baseUnit):null,this.campaigns=(null===(D=b.campaigns)||void 0===D?void 0:D.map((function(t){return new y(t)})))||null,this.selectedVariantValues=b.selectedVariantValues||[],this.productOptionSet=b.productOptionSet?new v(b.productOptionSet):null,this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=b.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=b.dynamicPriceListIds||null,this.productVolumeDiscountId=b.productVolumeDiscountId||null,this.campaignOffers=b.campaignOffers?b.campaignOffers.map((function(t){return new x(t)})):null,this.appliedCampaignOffer=b.appliedCampaignOffer,this.offers=b.offers?b.offers.map((function(t){return new R(t)})):void 0,this.productGroup=b.productGroup?new L(b.productGroup):null,this.salesChannels=b.salesChannels?b.salesChannels.map((function(t){return new E(t)})):null,this.translations=b.translations?b.translations.map((function(t){return new k(t)})):null,this.productGroupItems=b.productGroupItems,this.variants.forEach((function(t){return t.product=U})),this.setOptionPrices(),this.setOptionRealPrices(),this.customerReviews=b.customerReviews?new j(b.customerReviews):null,m(this,{selectedVariantValues:g,isFiltered:g,isStatic:g,showVariantsInGroup:g,hasVariant:V,hasStock:V,hasValidProductOptionValues:V,href:V,productHref:V,mainVariantType:V,mainVariantValue:V,selectedVariant:V,displayedVariantTypes:V,isCustomerReviewEnabled:V,isCustomerReviewLoginRequired:V,isAddToCartEnabled:V,groupedAttributeValues:V,selectedVariantUnitPriceText:V,displayedProductGroups:V})}return Object.defineProperty(A.prototype,"hasVariant",{get:function(){return b.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:b.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"href",{get:function(){return b.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:b.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantType",{get:function(){return b.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantValue",{get:function(){return b.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?b.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewEnabled",{get:function(){return I.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewLoginRequired",{get:function(){return I.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedProductGroups",{get:function(){var e,i=this,n=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){n.includes(t.name)||n.push(t.name)}))})),n.forEach((function(e){var n,o={name:e,items:[]};i.productGroupItems=r(i.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(n=i.productGroupItems)||void 0===n||n.forEach((function(n){var r,a,s,u=n.groupValues.find((function(t){return t.name===e}));if(u&&!o.items.some((function(t){return t.value===u.value}))){var c="";if(n.productId===i.id)c=i.href;else{var d=(null===(r=i.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[u],!1),p=null===(a=i.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:n.href}o.items.push({image:n.image?new G(n.image):null,href:c,value:u.value,isSelected:(null===(s=i.productGroupItems)||void 0===s?void 0:s.some((function(t){return t.groupValues.some((function(t){return t.value===u.value}))&&t.productId===i.id})))||!1,hasStock:n.hasStock})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),A}();export{A as IkasProduct};
1
+ import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as s}from"./variant/index.js";import{IkasProductAttributeValue as u}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductOptionPriceTypeEnum as f,IkasProductType as h}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as v}from"./option-set/index.js";import{makeObservable as m,observable as g,computed as V}from"mobx";import{IkasProductFunctions as b}from"@ikas/storefront-model-functions";import{IkasProductCampaign as y}from"./campaign/index.js";import{IkasStorefrontConfig as P}from"@ikas/storefront-config";import{IkasBaseStore as I}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as w}from"./base-unit/index.js";import{formatCurrency as S}from"../../../utils/currency.js";import"lodash/get";import T from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as C}from"./star/index.js";import{IkasProductCampaignOffer as x,IkasProductOffer as R}from"./campaign-offer/index.js";import{IkasProductGroup as L}from"./group/index.js";import{IkasImage as G}from"../image/index.js";import{IkasProductSalesChannel as E}from"./sales-channel/index.js";import{IkasProductTranslation as k}from"./translations/index.js";var A=function(){function A(b){void 0===b&&(b={});var O,G,D,U=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.translations=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.selectVariantValue=function(i,n){var r,a=U.metaData,o=U.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),s=U.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(s)U.selectedVariantValues=o;else{var u=U.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(u>0){var c=U.variantTypes.slice(0,u),d=U.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[i],!1);s=U.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(s=U.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(s=U.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!s)return;U.selectedVariantValues=s.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;"vid"!==i&&(f=e(e({},f),((n={})[i]=t,n)))})),U.variantTypes.map((function(t){delete f[decodeURIComponent(t.variantType.slug)]}));var h=t(t([],Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0),U.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return U.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0).filter((function(t){return!!t})).join("&");if(U.setOptionRealPrices(),!n){var v="/".concat(a.slug);if(h&&(v="/".concat(a.slug,"?").concat(h)),v===window.location.pathname)return;null===(r=I.getInstance().router)||void 0===r||r.replace(v,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&U.baseUnit){var r=U.baseUnit.baseAmount,a=(null===(i=null===(e=U.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(S(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=I.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,T.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:P.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=P.getPickupStockLocationIds(),[4,T.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return i(U,void 0,void 0,(function(){var i,r,a,o,s;return n(this,(function(n){switch(n.label){case 0:return i=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],i&&(null===(s=this.selectedVariant.bundleSettings)||void 0===s||s.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new j(e(e(e({},i?{}:{productId:this.id}),{locale:null==t?void 0:t.locale,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage,sortWithImagesFirst:null==t?void 0:t.sortWithImagesFirst}),i?{productIds:r}:{}))).getInitial()];case 1:return n.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,T.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),this.setOptionRealPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o;return n(this,(function(n){switch(n.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(i=null===(a=I.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===i.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:n.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,n,r;try{var a=null===(e=i.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(n=i.variant.bundleProducts)||void 0===n?void 0:n.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),n.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){U.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i,r,o,s,u,c=this;return n(this,(function(n){switch(n.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,T.searchProducts({input:{productIdList:e,perPage:200,priceListId:P.getPriceListId(),salesChannelId:P.getSalesChannelId()}})]:[3,2];case 1:(i=n.sent()).isSuccess&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){c.bundleProductCache[t.id]=t}))),n.label=2;case 2:return null===(u=t.bundleSettings)||void 0===u||u.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new A(a(e)))})),[2]}}))}))},this.getSubscriptionPlanOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i=this;return n(this,(function(n){return null===(e=t.subscriptionPlan)||void 0===e||e.periods.forEach((function(t,e){t.setProduct(i),0===e&&(t.isSelected=!0)})),[2]}))}))},this.setOptionRealPrices=function(){var t,e=U.selectedVariant||U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;if(t.selectSettings)t.selectSettings.values.forEach((function(t){var e;if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}));else if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}))}},this.setOptionPrices=function(){var t,e=U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var n,r;if(t.selectSettings&&t.selectSettings.values.forEach((function(t){var n,r;if(t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price})),t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price}))}},this.id=b.id||Date.now()+"",this.name=b.name||"",this.type=b.type||h.PHYSICAL,this.description=b.description||"",this.shortDescription=b.shortDescription||"",this.metaData=b.metaData?new l(b.metaData):null,this.brand=b.brand?new d(b.brand):null,this.categories=b.categories?b.categories.map((function(t){return new o(t)})):[],this.deleted=b.deleted||null,this.tags=b.tags?b.tags.map((function(t){return new p(t)})):[],this.variants=b.variants?b.variants.map((function(t){return new s(t)})):[],this.attributes=b.attributes?b.attributes.map((function(t){return new u(t)})):[],this.variantTypes=b.variantTypes?b.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=b.productOptionSetId||null,this.averageRating=null!==(O=b.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(G=b.reviewCount)&&void 0!==G?G:null,this.stars=b.stars?b.stars.map((function(t){return new C(t)})):null,this.baseUnit=b.baseUnit?new w(b.baseUnit):null,this.campaigns=(null===(D=b.campaigns)||void 0===D?void 0:D.map((function(t){return new y(t)})))||null,this.selectedVariantValues=b.selectedVariantValues||[],this.productOptionSet=b.productOptionSet?new v(b.productOptionSet):null,this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=b.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=b.dynamicPriceListIds||null,this.productVolumeDiscountId=b.productVolumeDiscountId||null,this.campaignOffers=b.campaignOffers?b.campaignOffers.map((function(t){return new x(t)})):null,this.appliedCampaignOffer=b.appliedCampaignOffer,this.offers=b.offers?b.offers.map((function(t){return new R(t)})):void 0,this.productGroup=b.productGroup?new L(b.productGroup):null,this.salesChannels=b.salesChannels?b.salesChannels.map((function(t){return new E(t)})):null,this.translations=b.translations?b.translations.map((function(t){return new k(t)})):null,this.productGroupItems=b.productGroupItems,this.variants.forEach((function(t){return t.product=U})),this.setOptionPrices(),this.setOptionRealPrices(),this.customerReviews=b.customerReviews?new j(b.customerReviews):null,m(this,{selectedVariantValues:g,isFiltered:g,isStatic:g,showVariantsInGroup:g,hasVariant:V,hasStock:V,hasValidProductOptionValues:V,href:V,productHref:V,mainVariantType:V,mainVariantValue:V,selectedVariant:V,displayedVariantTypes:V,isCustomerReviewEnabled:V,isCustomerReviewLoginRequired:V,isAddToCartEnabled:V,groupedAttributeValues:V,selectedVariantUnitPriceText:V,displayedProductGroups:V})}return Object.defineProperty(A.prototype,"hasVariant",{get:function(){return b.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:b.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"href",{get:function(){return b.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:b.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantType",{get:function(){return b.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantValue",{get:function(){return b.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?b.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewEnabled",{get:function(){return P.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewLoginRequired",{get:function(){return P.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedProductGroups",{get:function(){var e,i=this,n=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){n.includes(t.name)||n.push(t.name)}))})),n.forEach((function(e){var n,o={name:e,items:[]};i.productGroupItems=r(i.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(n=i.productGroupItems)||void 0===n||n.forEach((function(n){var r,a,s,u=n.groupValues.find((function(t){return t.name===e}));if(u&&!o.items.some((function(t){return t.value===u.value}))){var c="";if(n.productId===i.id)c=i.href;else{var d=(null===(r=i.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[u],!1),p=null===(a=i.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:n.href}o.items.push({image:n.image?new G(n.image):null,href:c,value:u.value,isSelected:(null===(s=i.productGroupItems)||void 0===s?void 0:s.some((function(t){return t.groupValues.some((function(t){return t.value===u.value}))&&t.productId===i.id})))||!1,hasStock:n.hasStock})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),A}();export{A as IkasProduct};
@@ -7,6 +7,7 @@ import { IkasBundleSettings } from "./bundle-settings";
7
7
  import { IkasCampaignType, IkasProductVariant as IProductVariant } from "@ikas/storefront-models";
8
8
  import { IkasProductVariantUnit } from "./unit";
9
9
  import { IkasProduct } from "..";
10
+ import { IkasProductSubscriptionPlan } from "./subscription-plan";
10
11
  export declare class IkasProductVariant implements IProductVariant {
11
12
  id: string;
12
13
  sku: string | null;
@@ -17,6 +18,7 @@ export declare class IkasProductVariant implements IProductVariant {
17
18
  attributes: IkasProductAttributeValue[];
18
19
  prices: IkasProductPrice[];
19
20
  stock: number;
21
+ subscriptionPlan: IkasProductSubscriptionPlan | null;
20
22
  isActive: boolean;
21
23
  productId: string;
22
24
  sellIfOutOfStock: boolean;
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as u}from"../image/index.js";import{IkasBundleSettings as c}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as l,IkasCampaignType as a,IkasCampaignFilterType as s,IkasCampaignApplicablePrice as d,IkasCustomerPriceListRuleFilterType as p}from"@ikas/storefront-models";import{IkasProductVariantFunctions as f,IkasProductPriceFunctions as m}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{saveProductBackInStockRemind as v,listProductBackInStockRemind as h}from"@ikas/storefront-api";import g from"lodash/groupBy";import y from"lodash/sortBy";import{IkasProductVariantUnit as P}from"./unit/index.js";import{formatCurrency as I}from"../../../../utils/currency.js";import{makeAutoObservable as S}from"mobx";import{IkasBaseStore as O}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var j=function(){function j(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new c(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new u(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new P(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=y(this.images,"order"),S(this)}return Object.defineProperty(j.prototype,"mainImage",{get:function(){var e=f.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasStock",{get:function(){return f.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockEnabled",{get:function(){return b.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return b.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"groupedAttributeValues",{get:function(){var e,t=g(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=O.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===p.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===p.PRODUCT)return u=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===p.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return u}if(e.type===p.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var l=c[u];if(l.shouldMatchAllFilters?null===(e=l.filters)||void 0===e?void 0:e.every(o):null===(t=l.filters)||void 0===t?void 0:t.some(o))return l}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"price",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"bundlePrice",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?e=m.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=m.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case l.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case l.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case l.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedFinalPrice",{get:function(){return I(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"sellPrice",{get:function(){return this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedSellPrice",{get:function(){return I(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedBuyPrice",{get:function(){return I(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,u=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var c=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=u.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!c)return null;var l={type:c.type,formattedPrice:null,discountPercentage:null},s=c.tieredDiscount&&c.tieredDiscount.rules&&c.tieredDiscount.rules.length>0&&c.tieredDiscount.rules[0].amount;return c.type===a.FIXED_AMOUNT&&(l.formattedPrice=I(c.fixedDiscount?(null===(n=c.fixedDiscount)||void 0===n?void 0:n.amount)||0:s||0,this.price.currency||"",this.price.currencySymbol||"")),c.type===a.RATIO&&(l.discountPercentage=c.fixedDiscount?(null===(o=c.fixedDiscount.amount)||void 0===o?void 0:o.toString())||null:s?s.toString():null),l},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedCampaignPrice",{get:function(){return I(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedDiscountPrice",{get:function(){return I(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return I(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return I(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"campaignOffersDiscountPercentage",{get:function(){return this.finalPriceWithCampaignOffers!==this.sellPriceWithCampaignOffers?(100-100*this.finalPriceWithCampaignOffers/this.sellPriceWithCampaignOffers).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"tieredDiscountProducts",{get:function(){var e,t,i,r,n=this,o=null===(i=null===(t=null===(e=this.product)||void 0===e?void 0:e.campaigns)||void 0===t?void 0:t.find((function(e){return!!e.campaign.tieredDiscount})))||void 0===i?void 0:i.campaign,u=null===(r=null==o?void 0:o.tieredDiscount)||void 0===r?void 0:r.filters;if(u){var c=u.find((function(e){return e.type===s.PRODUCT_AND_VARIANT}));if(c){var l=[];if(c.idList.map((function(e){l.push(e.replace("p:","").replace("v:",""))})),!l.some((function(e){return n.id===e||n.productId===e})))return[]}}return o&&o.tieredDiscount?o.tieredDiscount.rules.every((function(e){return!e.lineItemQuantityRange}))?[]:o.tieredDiscount.rules.map((function(e){var t,i,r,u,c=o.applicablePrice===d.SELL_PRICE?n.sellPrice:n.finalPrice,l=c*((null===(t=e.lineItemQuantityRange)||void 0===t?void 0:t.min)||1),s=I(c,n.price.currency||"",n.price.currencySymbol||""),p=I(l,n.price.currency||"",n.price.currencySymbol||""),f=o.type===a.RATIO?c-c*(e.amount||1)/100:c,m=f*((null===(i=e.lineItemQuantityRange)||void 0===i?void 0:i.min)||1)-(o.type===a.FIXED_AMOUNT&&e.amount||0),b=I(f,n.price.currency||"",n.price.currencySymbol||""),v=I(m,n.price.currency||"",n.price.currencySymbol||"");return{amount:e.amount,lineItemQuantityRange:{min:(null===(r=e.lineItemQuantityRange)||void 0===r?void 0:r.min)||0,max:(null===(u=e.lineItemQuantityRange)||void 0===u?void 0:u.max)||0},type:o.type,sellPrice:c,finalPrice:f,sellPriceWithQuantity:l,finalPriceWithQuantity:m,formattedSellPrice:s,formattedSellPriceWithQuantity:p,formattedFinalPrice:b,formattedFinalPriceWithQuantity:v,salesChannelIds:o.salesChannelIds}})):[]},enumerable:!1,configurable:!0}),j.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,h({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,v({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},j.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},j}();export{j as IkasProductVariant};
1
+ import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as u}from"../image/index.js";import{IkasBundleSettings as c}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as l,IkasCampaignType as s,IkasCampaignFilterType as a,IkasCampaignApplicablePrice as d,IkasCustomerPriceListRuleFilterType as p}from"@ikas/storefront-models";import{IkasProductVariantFunctions as f,IkasProductPriceFunctions as m}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{saveProductBackInStockRemind as v,listProductBackInStockRemind as h}from"@ikas/storefront-api";import g from"lodash/groupBy";import y from"lodash/sortBy";import{IkasProductVariantUnit as P}from"./unit/index.js";import{formatCurrency as I}from"../../../../utils/currency.js";import{makeAutoObservable as S}from"mobx";import{IkasBaseStore as O}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{IkasProductSubscriptionPlan as j}from"./subscription-plan/index.js";var k=function(){function k(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new c(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new u(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.subscriptionPlan=e.subscriptionPlan?new j(e.subscriptionPlan):null,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new P(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=y(this.images,"order"),S(this)}return Object.defineProperty(k.prototype,"mainImage",{get:function(){var e=f.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasStock",{get:function(){return f.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isBackInStockEnabled",{get:function(){return b.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return b.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"groupedAttributeValues",{get:function(){var e,t=g(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=O.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===p.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===p.PRODUCT)return u=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===p.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return u}if(e.type===p.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var l=c[u];if(l.shouldMatchAllFilters?null===(e=l.filters)||void 0===e?void 0:e.every(o):null===(t=l.filters)||void 0===t?void 0:t.some(o))return l}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"price",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"bundlePrice",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?e=m.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=m.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case l.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case l.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case l.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedFinalPrice",{get:function(){return I(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"sellPrice",{get:function(){return this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedSellPrice",{get:function(){return I(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedBuyPrice",{get:function(){return I(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,u=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var c=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=u.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!c)return null;var l={type:c.type,formattedPrice:null,discountPercentage:null},a=c.tieredDiscount&&c.tieredDiscount.rules&&c.tieredDiscount.rules.length>0&&c.tieredDiscount.rules[0].amount;return c.type===s.FIXED_AMOUNT&&(l.formattedPrice=I(c.fixedDiscount?(null===(n=c.fixedDiscount)||void 0===n?void 0:n.amount)||0:a||0,this.price.currency||"",this.price.currencySymbol||"")),c.type===s.RATIO&&(l.discountPercentage=c.fixedDiscount?(null===(o=c.fixedDiscount.amount)||void 0===o?void 0:o.toString())||null:a?a.toString():null),l},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedCampaignPrice",{get:function(){return I(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedDiscountPrice",{get:function(){return I(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return I(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return I(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"campaignOffersDiscountPercentage",{get:function(){return this.finalPriceWithCampaignOffers!==this.sellPriceWithCampaignOffers?(100-100*this.finalPriceWithCampaignOffers/this.sellPriceWithCampaignOffers).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"tieredDiscountProducts",{get:function(){var e,t,i,r,n=this,o=null===(i=null===(t=null===(e=this.product)||void 0===e?void 0:e.campaigns)||void 0===t?void 0:t.find((function(e){return!!e.campaign.tieredDiscount})))||void 0===i?void 0:i.campaign,u=null===(r=null==o?void 0:o.tieredDiscount)||void 0===r?void 0:r.filters;if(u){var c=u.find((function(e){return e.type===a.PRODUCT_AND_VARIANT}));if(c){var l=[];if(c.idList.map((function(e){l.push(e.replace("p:","").replace("v:",""))})),!l.some((function(e){return n.id===e||n.productId===e})))return[]}}return o&&o.tieredDiscount?o.tieredDiscount.rules.every((function(e){return!e.lineItemQuantityRange}))?[]:o.tieredDiscount.rules.map((function(e){var t,i,r,u,c=o.applicablePrice===d.SELL_PRICE?n.sellPrice:n.finalPrice,l=c*((null===(t=e.lineItemQuantityRange)||void 0===t?void 0:t.min)||1),a=I(c,n.price.currency||"",n.price.currencySymbol||""),p=I(l,n.price.currency||"",n.price.currencySymbol||""),f=o.type===s.RATIO?c-c*(e.amount||1)/100:c,m=f*((null===(i=e.lineItemQuantityRange)||void 0===i?void 0:i.min)||1)-(o.type===s.FIXED_AMOUNT&&e.amount||0),b=I(f,n.price.currency||"",n.price.currencySymbol||""),v=I(m,n.price.currency||"",n.price.currencySymbol||"");return{amount:e.amount,lineItemQuantityRange:{min:(null===(r=e.lineItemQuantityRange)||void 0===r?void 0:r.min)||0,max:(null===(u=e.lineItemQuantityRange)||void 0===u?void 0:u.max)||0},type:o.type,sellPrice:c,finalPrice:f,sellPriceWithQuantity:l,finalPriceWithQuantity:m,formattedSellPrice:a,formattedSellPriceWithQuantity:p,formattedFinalPrice:b,formattedFinalPriceWithQuantity:v,salesChannelIds:o.salesChannelIds}})):[]},enumerable:!1,configurable:!0}),k.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,h({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,v({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},k.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},k}();export{k as IkasProductVariant};
@@ -0,0 +1,12 @@
1
+ import { IkasSubscriptionPlanStatus, IkasSubscriptionPlanTranslation, IkasProductSubscriptionPlan as IProductSubscriptionPlan } from "@ikas/storefront-models";
2
+ import { IkasProductSubscriptionPlanPeriod } from "./product-subscription-plan-period";
3
+ export declare class IkasProductSubscriptionPlan implements IProductSubscriptionPlan {
4
+ name: string;
5
+ periods: IkasProductSubscriptionPlanPeriod[];
6
+ status: IkasSubscriptionPlanStatus;
7
+ subscriptionPlanId: string;
8
+ translations: IkasSubscriptionPlanTranslation[] | null;
9
+ isSelected: boolean;
10
+ constructor(data: IProductSubscriptionPlan);
11
+ setSelectedPeriod: (period: IkasProductSubscriptionPlanPeriod, isSelected: boolean) => void;
12
+ }
@@ -0,0 +1 @@
1
+ import{makeAutoObservable as t}from"mobx";import{IkasProductSubscriptionPlanPeriod as i}from"./product-subscription-plan-period/index.js";var s=function(s){var e=this;this.isSelected=!1,this.setSelectedPeriod=function(t,i){e.periods.forEach((function(t){t.isSelected=!1})),t.isSelected=i},this.name=s.name,this.periods=s.periods.map((function(t){return new i(t)})),this.status=s.status,this.subscriptionPlanId=s.subscriptionPlanId,this.translations=s.translations,this.isSelected=s.isSelected||!1,t(this)};export{s as IkasProductSubscriptionPlan};
@@ -0,0 +1,6 @@
1
+ import { IkasOrderAmountType, IkasProductSubscriptionPlanDiscount as IProductSubscriptionPlanDiscount } from "@ikas/storefront-models";
2
+ export declare class IkasProductSubscriptionPlanDiscount implements IProductSubscriptionPlanDiscount {
3
+ amount: number;
4
+ type: IkasOrderAmountType;
5
+ constructor(data: IProductSubscriptionPlanDiscount);
6
+ }
@@ -0,0 +1,23 @@
1
+ import { IkasSubscriptionPlanDurationUnitType, IkasSubscriptionPlanPaymentType, IkasSubscriptionPlanStatus, IkasProductSubscriptionPlanPeriod as IProductSubscriptionPlanPeriod } from "@ikas/storefront-models";
2
+ import { IkasProductSubscriptionPlanDiscount } from "../product-subscription-plan-discount";
3
+ import { IkasProduct } from "../../..";
4
+ export declare class IkasProductSubscriptionPlanPeriod implements IProductSubscriptionPlanPeriod {
5
+ cutOffDay: number | null;
6
+ discount: IkasProductSubscriptionPlanDiscount | null;
7
+ durationUnit: IkasSubscriptionPlanDurationUnitType;
8
+ durationValue: number;
9
+ id: string;
10
+ maxOrders: number | null;
11
+ paymentType: IkasSubscriptionPlanPaymentType;
12
+ scheduledOrderDay: number | null;
13
+ status: IkasSubscriptionPlanStatus;
14
+ title: string;
15
+ isSelected: boolean;
16
+ product: IkasProduct | null;
17
+ constructor(data: IProductSubscriptionPlanPeriod);
18
+ get periodPrice(): number;
19
+ get formattedPeriodPrice(): string;
20
+ get totalPeriodPrice(): number;
21
+ get formattedTotalPeriodPrice(): string;
22
+ setProduct: (product: IkasProduct) => void;
23
+ }
@@ -0,0 +1 @@
1
+ import{IkasOrderAmountType as t,IkasSubscriptionPlanPaymentType as e}from"@ikas/storefront-models";import{makeAutoObservable as i}from"mobx";import{formatCurrency as r}from"../../../../../../utils/currency.js";var o=function(){function o(t){var e=this;this.isSelected=!1,this.product=null,this.setProduct=function(t){e.product=t,e.product.selectedVariantValues=e.product.variants[0].variantValues},this.cutOffDay=t.cutOffDay,this.discount=t.discount,this.durationUnit=t.durationUnit,this.durationValue=t.durationValue,this.id=t.id,this.maxOrders=t.maxOrders,this.paymentType=t.paymentType,this.scheduledOrderDay=t.scheduledOrderDay,this.status=t.status,this.title=t.title,this.isSelected=t.isSelected||!1,i(this)}return Object.defineProperty(o.prototype,"periodPrice",{get:function(){var e,i,r=null!==(i=null===(e=this.product)||void 0===e?void 0:e.selectedVariant.finalPrice)&&void 0!==i?i:0;return r-(this.discount?this.discount.type===t.AMOUNT?this.discount.amount:r*(this.discount.amount/100):0)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"formattedPeriodPrice",{get:function(){var t,e;return r(this.periodPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"totalPeriodPrice",{get:function(){return this.periodPrice*(this.paymentType===e.POST_PAID?1:this.maxOrders||1)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"formattedTotalPeriodPrice",{get:function(){var t,e;return r(this.totalPeriodPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),o}();export{o as IkasProductSubscriptionPlanPeriod};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import r from"./api.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as n}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{Analytics as o}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as s}from"@ikas/storefront-api";import{getCookieValue as d}from"../../utils/helper.js";var u,c="cartId",l=function(){function c(c){var l=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(i,n,s){return void 0===s&&(s=1),t(l,void 0,void 0,(function(){var t,c,l,m,p,f,v,h,I,g,C,b,S,j,y,x;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),n.productOptionSetId&&!n.productOptionSet&&this.baseStore.router?(this.baseStore.router.push(n.productHref),[2,{success:!1,validationError:u.INVALID_PRODUCT_OPTION_VALUES}]):n.hasValidProductOptionValues?i.hasStock||i.sellIfOutOfStock?[4,this.beforeCartOperationCheck()]:[2,{success:!1,validationError:u.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:u.INVALID_PRODUCT_OPTION_VALUES}];case 1:if(e.sent(),t=void 0,this.cart&&(t=this.findExistingItem(i,n))){if(null===(g=n.productOptionSet)||void 0===g||g.initOptionValues(),!i.bundleSettings)return[2,this.changeItemQuantity(t,t.quantity+1,n.offers,n)];if(!this.getEditLineID())return[2,this.changeItemQuantity(t,t.quantity+1,n.offers,n)]}return c=this.getOptionValues(n),l=s,(null==(m=null===(C=n.salesChannels)||void 0===C?void 0:C.find((function(t){return t.id===a.getSalesChannelId()})))?void 0:m.minQuantityPerCart)&&s<m.minQuantityPerCart&&(l=m.minQuantityPerCart),(null==m?void 0:m.maxQuantityPerCart)&&s>m.maxQuantityPerCart&&(l=m.maxQuantityPerCart),p=(null===(b=this.cart)||void 0===b?void 0:b.id)||localStorage.getItem("cartId"),[4,r.addItemToCart({input:{cartId:p,item:{id:null!==(S=null==t?void 0:t.id)&&void 0!==S?S:null,quantity:null!==(j=null==t?void 0:t.quantity)&&void 0!==j?j:l,variant:{id:i.id,name:n.name,bundleProducts:null===(y=i.bundleSettings)||void 0===y?void 0:y.products.map((function(t){var e,i,r;return{id:t.id,productId:(null===(e=t.product)||void 0===e?void 0:e.id)||"",variantId:(null===(r=null===(i=t.product)||void 0===i?void 0:i.selectedVariant)||void 0===r?void 0:r.id)||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(n.offers),options:c.length?c:null,priceListId:a.getPriceListId()||null,salesChannelId:a.getSalesChannelId(),storefrontThemeId:a.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc"),_ga:d("_ga")}}})];case 2:return(f=e.sent()).isSuccess&&f.data?[4,this.setCart(f.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(v="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(h=this.cart.items.find((function(t){return t.variant.id===i.id})))&&o.addToCart(h,s,v,this.cart,n)),null===(x=n.productOptionSet)||void 0===x||x.initOptionValues(),[2,{success:f.isSuccess,response:f}];case 5:return I=e.sent(),console.log(I),[2,{success:!1}];case 6:return[2]}}))}))},this.changeItemQuantity=function(i,n,s,u){return t(l,void 0,void 0,(function(){var t,c,l,m,p,f;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),[4,r.addItemToCart({input:{cartId:(null===(p=this.cart)||void 0===p?void 0:p.id)||null,item:{id:i.id,quantity:n,variant:{id:i.variant.id,name:i.variant.name,bundleProducts:null===(f=i.variant.bundleProducts)||void 0===f?void 0:f.map((function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(s),options:this.createCartLineOptions(i),priceListId:a.getPriceListId()||null,salesChannelId:a.getSalesChannelId(),storefrontThemeId:a.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc"),_ga:d("_ga")}}})];case 2:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(c="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(l=i.quantity)>n?o.removeFromCart(i,l-n,this.cart):o.addToCart(i,n-l,c,this.cart,u)),this.removeCardIfEmpty(),[2,{success:t.isSuccess,response:t}];case 5:return m=e.sent(),console.log(m),[2,{success:!1}];case 6:return[2]}}))}))},this.createCart=function(i){return t(l,void 0,void 0,(function(){var t,n=this;return e(this,(function(e){switch(e.label){case 0:return[4,r.createCart({input:{items:i.variantLines.map((function(t){return{variant:{id:t.variantId},quantity:t.quantity}})),couponCode:i.couponCode,salesChannelId:a.getSalesChannelId(),storefrontThemeId:a.getStorefrontThemeId()}})];case 1:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return i.variantLines.forEach((function(t){if(n.cart){var e="".concat(n.cart.id,"-").concat(n.cart.updatedAt),i=n.cart.items.find((function(e){return e.variant.id===t.variantId}));i&&o.addToCart(i,t.quantity,e,n.cart)}})),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeItem=function(i){return t(l,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return[2,t.sent()]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),l.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){l.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.getEditLineID=function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""},this.findExistingItem=function(t,e){var i,r,n,a,o,s;if(!e.productOptionSetId&&!t.bundleSettings)return null===(i=l.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));if(t.bundleSettings){var d=l.getEditLineID();if(d)if(S=null===(r=l.cart)||void 0===r?void 0:r.orderLineItems.find((function(t){return t.id===d})))return S}var u=(null===(n=l.cart)||void 0===n?void 0:n.orderLineItems.filter((function(e){return e.variant.id===t.id})))||[];if(e.productOptionSetId)for(var c=l.getOptionValues(e),m=u.filter((function(t){var e;return(null===(e=t.options)||void 0===e?void 0:e.length)===c.length}))||[],p=0,f=m;p<f.length;p++){if((S=f[p]).options){for(var v=!0,h=function(t){var i=t.values.map((function(t){return t.value})),r=null===(s=null===(o=null===(a=e.productOptionSet)||void 0===a?void 0:a.options)||void 0===o?void 0:o.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(v=v&&i.length===(null==r?void 0:r.length)&&i.every((function(t){return null==r?void 0:r.includes(t)}))))return"break"},I=0,g=S.options;I<g.length;I++){if("break"===h(g[I]))break}if(v){if(!t.bundleSettings)return S;if(l.isSameBundleItem(t,S))return S}}}else if(t.bundleSettings)for(var C=0,b=u;C<b.length;C++){var S=b[C];if(l.isSameBundleItem(t,S))return S}},this.isSameBundleItem=function(t,e){var i,r=null===(i=t.bundleSettings)||void 0===i?void 0:i.products,n=e.variant.bundleProducts;return!!r&&((null==r?void 0:r.length)===(null==n?void 0:n.length)&&(null==r?void 0:r.every((function(t){return!!(null==n?void 0:n.find((function(e){var i;return e.id===t.id&&e.quantity===t.quantity&&e.variant.id===(null===(i=t.product)||void 0===i?void 0:i.selectedVariant.id)})))}))))},this.saveCouponCode=function(i){return t(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,r.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,{success:!1,validationError:u.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeCouponCode=function(){return t(l,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.removeGiftCardLine=function(i){return t(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,r.removeGiftCardFromCart({cartId:this.cart.id,giftCardId:i})]:[2,{success:!1,validationError:u.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.saveCart=function(i){return t(l,void 0,void 0,(function(){var t,a;return e(this,(function(e){switch(e.label){case 0:return(t=new s(i)).customer&&this.baseStore.customerStore.customer&&(t.customer.notificationsAccepted=this.baseStore.customerStore.customer.subscriptionStatus===n.SUBSCRIBED),[4,r.saveCart({input:t})];case 1:return[2,{success:(a=e.sent()).isSuccess,response:a}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=l.cart)||void 0===t?void 0:t.itemCount)&&l.removeCart()},this.getCart=function(){return t(l,void 0,void 0,(function(){var t,i,n,a,o,s;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(o=this.baseStore.customerStore.customer)||void 0===o?void 0:o.id,(i=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,r.getCartById({id:i})]:[2];case 2:return(n=e.sent()).isSuccess&&n.data?[4,this.setCart(n.data)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return a=e.sent(),console.log(a),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(l,void 0,void 0,(function(){return e(this,(function(t){return localStorage.setItem("cartId",i.id),this.cart=i,[2]}))}))},this.beforeCartOperationCheck=function(){return t(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,r=t.options;i<r.length;i++){var n=r[i],a={productOptionId:n.productOptionId,productOptionsSetId:n.productOptionsSetId,values:n.values.map((function(t){return t.value}))};e.push(a)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),i},this._windowAddToCart=function(i){return t(l,void 0,void 0,(function(){var t,n,s,u,c,l,m,p,f,v,h;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),t=i.itemId?null===(f=this.cart)||void 0===f?void 0:f.items.find((function(t){return t.id===i.itemId})):null,[4,r.addItemToCart({input:{cartId:(null===(v=this.cart)||void 0===v?void 0:v.id)||null,item:{id:i.itemId||null,quantity:i.quantity,variant:{id:i.variantId}},priceListId:a.getPriceListId()||null,salesChannelId:a.getSalesChannelId(),storefrontThemeId:a.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc"),_ga:d("_ga")}}})];case 2:return(n=e.sent()).isSuccess&&n.data?(i.itemId||(s=(null===(h=this.cart)||void 0===h?void 0:h.items.map((function(t){return t.id})))||[],u=n.data.items.map((function(t){return t.id})),(c=u.find((function(t){return!s.includes(t)})))&&(t=n.data.items.find((function(t){return t.id===c})))),[4,this.setCart(n.data)]):[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&t&&(l="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(m=i.quantity)>i.quantity?o.removeFromCart(t,m-i.quantity,this.cart):o.addToCart(t,i.quantity-m,l,this.cart)),this.removeCardIfEmpty(),[2,{success:n.isSuccess,response:n}];case 5:return p=e.sent(),console.log(p),[2,{success:!1}];case 6:return[2]}}))}))},this.baseStore=c,i(this)}return Object.defineProperty(c.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout?id=".concat(this.checkoutId,"&step=info")},enumerable:!1,configurable:!0}),c.prototype.getAcceptedOffers=function(t){var e=(null==t?void 0:t.filter((function(t){return t.isSelected&&!t.isAccepted})).map((function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:t.product.selectedVariant.id}})))||[];return e.length?e:void 0},c}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(u||(u={}));export{c as CART_LS_KEY,u as IkasCartOperationValidationError,l as IkasCartStore};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import n from"./api.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as a}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasStorefrontConfig as o}from"@ikas/storefront-config";import{Analytics as s}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as d}from"@ikas/storefront-api";import{getCookieValue as u}from"../../utils/helper.js";var c,l="cartId",p=function(){function l(l){var p=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(r,a,d){return void 0===d&&(d=1),t(p,void 0,void 0,(function(){var t,l,p,m,f,v,h,I,g,C,b,S,j,y,x,O,P;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),a.productOptionSetId&&!a.productOptionSet&&this.baseStore.router?(this.baseStore.router.push(a.productHref),[2,{success:!1,validationError:c.INVALID_PRODUCT_OPTION_VALUES}]):a.hasValidProductOptionValues?r.hasStock||r.sellIfOutOfStock?[4,this.beforeCartOperationCheck()]:[2,{success:!1,validationError:c.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:c.INVALID_PRODUCT_OPTION_VALUES}];case 1:if(e.sent(),t=void 0,this.cart&&(t=this.findExistingItem(r,a))){if(null===(C=a.productOptionSet)||void 0===C||C.initOptionValues(),!r.bundleSettings)return[2,this.changeItemQuantity(t,t.quantity+1,a.offers,a)];if(!this.getEditLineID())return[2,this.changeItemQuantity(t,t.quantity+1,a.offers,a)]}return l=this.getOptionValues(a),p=d,(null==(m=null===(b=a.salesChannels)||void 0===b?void 0:b.find((function(t){return t.id===o.getSalesChannelId()})))?void 0:m.minQuantityPerCart)&&d<m.minQuantityPerCart&&(p=m.minQuantityPerCart),(null==m?void 0:m.maxQuantityPerCart)&&d>m.maxQuantityPerCart&&(p=m.maxQuantityPerCart),f=(null===(S=this.cart)||void 0===S?void 0:S.id)||localStorage.getItem("cartId"),[4,n.addItemToCart({input:i({cartId:f,item:{id:null!==(j=null==t?void 0:t.id)&&void 0!==j?j:null,quantity:null!==(y=null==t?void 0:t.quantity)&&void 0!==y?y:p,variant:{id:r.id,name:a.name,bundleProducts:null===(x=r.bundleSettings)||void 0===x?void 0:x.products.map((function(t){var e,i,r;return{id:t.id,productId:(null===(e=t.product)||void 0===e?void 0:e.id)||"",variantId:(null===(r=null===(i=t.product)||void 0===i?void 0:i.selectedVariant)||void 0===r?void 0:r.id)||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(a.offers),options:l.length?l:null,priceListId:o.getPriceListId()||null,salesChannelId:o.getSalesChannelId(),storefrontThemeId:o.getStorefrontThemeId(),metadata:{_fbp:u("_fbp"),_fbc:u("_fbc"),_ga:u("_ga")}},a.selectedVariant.subscriptionPlan&&a.selectedVariant.subscriptionPlan.isSelected?{subscriptionPlanId:a.selectedVariant.subscriptionPlan.subscriptionPlanId,subscriptionPlanPeriodId:null===(O=a.selectedVariant.subscriptionPlan.periods.find((function(t){return t.isSelected})))||void 0===O?void 0:O.id}:{})})];case 2:return(v=e.sent()).isSuccess&&v.data?[4,this.setCart(v.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(h="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(I=this.cart.items.find((function(t){return t.variant.id===r.id})))&&s.addToCart(I,d,h,this.cart,a)),null===(P=a.productOptionSet)||void 0===P||P.initOptionValues(),[2,{success:v.isSuccess,response:v}];case 5:return g=e.sent(),console.log(g),[2,{success:!1}];case 6:return[2]}}))}))},this.changeItemQuantity=function(r,a,d,c){return t(p,void 0,void 0,(function(){var t,l,p,m,f,v,h,I,g;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),[4,n.addItemToCart({input:i({cartId:(null===(f=this.cart)||void 0===f?void 0:f.id)||null,item:{id:r.id,quantity:a,variant:{id:r.variant.id,name:r.variant.name,bundleProducts:null===(v=r.variant.bundleProducts)||void 0===v?void 0:v.map((function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(d),options:this.createCartLineOptions(r),priceListId:o.getPriceListId()||null,salesChannelId:o.getSalesChannelId(),storefrontThemeId:o.getStorefrontThemeId(),metadata:{_fbp:u("_fbp"),_fbc:u("_fbc"),_ga:u("_ga")}},(null===(h=null==c?void 0:c.selectedVariant)||void 0===h?void 0:h.subscriptionPlan)&&(null===(I=null==c?void 0:c.selectedVariant)||void 0===I?void 0:I.subscriptionPlan.isSelected)?{subscriptionPlanId:null==c?void 0:c.selectedVariant.subscriptionPlan.subscriptionPlanId,subscriptionPlanPeriodId:null===(g=null==c?void 0:c.selectedVariant.subscriptionPlan.periods.find((function(t){return t.isSelected})))||void 0===g?void 0:g.id}:{})})];case 2:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(l="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=r.quantity)>a?s.removeFromCart(r,p-a,this.cart):s.addToCart(r,a-p,l,this.cart,c)),this.removeCardIfEmpty(),[2,{success:t.isSuccess,response:t}];case 5:return m=e.sent(),console.log(m),[2,{success:!1}];case 6:return[2]}}))}))},this.createCart=function(i){return t(p,void 0,void 0,(function(){var t,r=this;return e(this,(function(e){switch(e.label){case 0:return[4,n.createCart({input:{items:i.variantLines.map((function(t){return{variant:{id:t.variantId},quantity:t.quantity}})),couponCode:i.couponCode,salesChannelId:o.getSalesChannelId(),storefrontThemeId:o.getStorefrontThemeId()}})];case 1:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return i.variantLines.forEach((function(t){if(r.cart){var e="".concat(r.cart.id,"-").concat(r.cart.updatedAt),i=r.cart.items.find((function(e){return e.variant.id===t.variantId}));i&&s.addToCart(i,t.quantity,e,r.cart)}})),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeItem=function(i){return t(p,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return[2,t.sent()]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),p.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){p.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.getEditLineID=function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""},this.findExistingItem=function(t,e){var i,r,n,a,o,s;if(!e.productOptionSetId&&!t.bundleSettings)return null===(i=p.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));if(t.bundleSettings){var d=p.getEditLineID();if(d)if(S=null===(r=p.cart)||void 0===r?void 0:r.orderLineItems.find((function(t){return t.id===d})))return S}var u=(null===(n=p.cart)||void 0===n?void 0:n.orderLineItems.filter((function(e){return e.variant.id===t.id})))||[];if(e.productOptionSetId)for(var c=p.getOptionValues(e),l=u.filter((function(t){var e;return(null===(e=t.options)||void 0===e?void 0:e.length)===c.length}))||[],m=0,f=l;m<f.length;m++){if((S=f[m]).options){for(var v=!0,h=function(t){var i=t.values.map((function(t){return t.value})),r=null===(s=null===(o=null===(a=e.productOptionSet)||void 0===a?void 0:a.options)||void 0===o?void 0:o.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(v=v&&i.length===(null==r?void 0:r.length)&&i.every((function(t){return null==r?void 0:r.includes(t)}))))return"break"},I=0,g=S.options;I<g.length;I++){if("break"===h(g[I]))break}if(v){if(!t.bundleSettings)return S;if(p.isSameBundleItem(t,S))return S}}}else if(t.bundleSettings)for(var C=0,b=u;C<b.length;C++){var S=b[C];if(p.isSameBundleItem(t,S))return S}},this.isSameBundleItem=function(t,e){var i,r=null===(i=t.bundleSettings)||void 0===i?void 0:i.products,n=e.variant.bundleProducts;return!!r&&((null==r?void 0:r.length)===(null==n?void 0:n.length)&&(null==r?void 0:r.every((function(t){return!!(null==n?void 0:n.find((function(e){var i;return e.id===t.id&&e.quantity===t.quantity&&e.variant.id===(null===(i=t.product)||void 0===i?void 0:i.selectedVariant.id)})))}))))},this.saveCouponCode=function(i){return t(p,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,{success:!1,validationError:c.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeCouponCode=function(){return t(p,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.removeGiftCardLine=function(i){return t(p,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.removeGiftCardFromCart({cartId:this.cart.id,giftCardId:i})]:[2,{success:!1,validationError:c.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.saveCart=function(i){return t(p,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return(t=new d(i)).customer&&this.baseStore.customerStore.customer&&(t.customer.notificationsAccepted=this.baseStore.customerStore.customer.subscriptionStatus===a.SUBSCRIBED),[4,n.saveCart({input:t})];case 1:return[2,{success:(r=e.sent()).isSuccess,response:r}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=p.cart)||void 0===t?void 0:t.itemCount)&&p.removeCart()},this.getCart=function(){return t(p,void 0,void 0,(function(){var t,i,r,a,o,s;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(o=this.baseStore.customerStore.customer)||void 0===o?void 0:o.id,(i=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,n.getCartById({id:i})]:[2];case 2:return(r=e.sent()).isSuccess&&r.data?[4,this.setCart(r.data)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return a=e.sent(),console.log(a),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(p,void 0,void 0,(function(){return e(this,(function(t){return localStorage.setItem("cartId",i.id),this.cart=i,[2]}))}))},this.beforeCartOperationCheck=function(){return t(p,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,r=t.options;i<r.length;i++){var n=r[i],a={productOptionId:n.productOptionId,productOptionsSetId:n.productOptionsSetId,values:n.values.map((function(t){return t.value}))};e.push(a)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),i},this._windowAddToCart=function(i){return t(p,void 0,void 0,(function(){var t,r,a,d,c,l,p,m,f,v,h;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),t=i.itemId?null===(f=this.cart)||void 0===f?void 0:f.items.find((function(t){return t.id===i.itemId})):null,[4,n.addItemToCart({input:{cartId:(null===(v=this.cart)||void 0===v?void 0:v.id)||null,item:{id:i.itemId||null,quantity:i.quantity,variant:{id:i.variantId}},priceListId:o.getPriceListId()||null,salesChannelId:o.getSalesChannelId(),storefrontThemeId:o.getStorefrontThemeId(),metadata:{_fbp:u("_fbp"),_fbc:u("_fbc"),_ga:u("_ga")}}})];case 2:return(r=e.sent()).isSuccess&&r.data?(i.itemId||(a=(null===(h=this.cart)||void 0===h?void 0:h.items.map((function(t){return t.id})))||[],d=r.data.items.map((function(t){return t.id})),(c=d.find((function(t){return!a.includes(t)})))&&(t=r.data.items.find((function(t){return t.id===c})))),[4,this.setCart(r.data)]):[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&t&&(l="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=i.quantity)>i.quantity?s.removeFromCart(t,p-i.quantity,this.cart):s.addToCart(t,i.quantity-p,l,this.cart)),this.removeCardIfEmpty(),[2,{success:r.isSuccess,response:r}];case 5:return m=e.sent(),console.log(m),[2,{success:!1}];case 6:return[2]}}))}))},this.baseStore=l,r(this)}return Object.defineProperty(l.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout?id=".concat(this.checkoutId,"&step=info")},enumerable:!1,configurable:!0}),l.prototype.getAcceptedOffers=function(t){var e=(null==t?void 0:t.filter((function(t){return t.isSelected&&!t.isAccepted})).map((function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:t.product.selectedVariant.id}})))||[];return e.length?e:void 0},l}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(c||(c={}));export{l as CART_LS_KEY,c as IkasCartOperationValidationError,p as IkasCartStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "6.1.0-beta.146",
3
+ "version": "6.1.0-beta.148",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -21,11 +21,11 @@
21
21
  "swiper": "11.0.6"
22
22
  },
23
23
  "devDependencies": {
24
- "@ikas/storefront-api": "^6.1.0-beta.146",
25
- "@ikas/storefront-config": "^6.1.0-beta.146",
26
- "@ikas/storefront-model-functions": "^6.1.0-beta.146",
27
- "@ikas/storefront-models": "^6.1.0-beta.146",
28
- "@ikas/storefront-providers": "^6.1.0-beta.146",
24
+ "@ikas/storefront-api": "^6.1.0-beta.148",
25
+ "@ikas/storefront-config": "^6.1.0-beta.148",
26
+ "@ikas/storefront-model-functions": "^6.1.0-beta.148",
27
+ "@ikas/storefront-models": "^6.1.0-beta.148",
28
+ "@ikas/storefront-providers": "^6.1.0-beta.148",
29
29
  "@ikas/localized-address": "1.0.0-beta.6",
30
30
  "@adyen/adyen-web": "^5.57.0",
31
31
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -60,11 +60,11 @@
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@ikas/localized-address": "1.0.0-beta.6",
63
- "@ikas/storefront-api": "^6.1.0-beta.146",
64
- "@ikas/storefront-config": "^6.1.0-beta.146",
65
- "@ikas/storefront-model-functions": "^6.1.0-beta.146",
66
- "@ikas/storefront-models": "^6.1.0-beta.146",
67
- "@ikas/storefront-providers": "^6.1.0-beta.146",
63
+ "@ikas/storefront-api": "^6.1.0-beta.148",
64
+ "@ikas/storefront-config": "^6.1.0-beta.148",
65
+ "@ikas/storefront-model-functions": "^6.1.0-beta.148",
66
+ "@ikas/storefront-models": "^6.1.0-beta.148",
67
+ "@ikas/storefront-providers": "^6.1.0-beta.148",
68
68
  "mobx": "^6.1.3",
69
69
  "mobx-react-lite": "^3.1.5",
70
70
  "next": "12.2.0",