@ikas/storefront 6.1.0-beta.321 → 6.1.0-beta.323

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.
@@ -8,7 +8,8 @@ declare type Props = {
8
8
  export declare enum CouponErrorCode {
9
9
  COUPON_CODE_NOT_EXIST = "COUPON_CODE_NOT_EXIST",
10
10
  COUPON_CODE_NOT_EXIST_FOR_GUESS = "COUPON_CODE_NOT_EXIST_FOR_GUESS",
11
- COUPON_APPLIED_WITHOUT_DISCOUNT = "COUPON_APPLIED_WITHOUT_DISCOUNT"
11
+ COUPON_APPLIED_WITHOUT_DISCOUNT = "COUPON_APPLIED_WITHOUT_DISCOUNT",
12
+ COUPON_PERIOD_USAGE_LIMIT_EXCEEDED = "COUPON_PERIOD_USAGE_LIMIT_EXCEEDED"
12
13
  }
13
14
  export declare const CartSummary: React.FC<Props>;
14
15
  declare type CommonProps = {
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as n}from'./../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import a from"lodash/sortBy";import l from"../input-with-button/index.js";import s from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as d}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as y}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import v from"../tooltip/index.js";import E from"../svg/arrow-down.js";import g from"../svg/cross.js";import f from"../svg/gift.js";import h from"../../styles/common.module.scss.js";import C from"./style.module.scss.js";import L from"../svg/ikas.js";import{Button as P}from"../button/index.js";import{IkasCartCreatedBy as k,IkasCampaignCreatedFor as N,IkasGiftCardType as S}from"@ikas/storefront-models";import I from"../../../../hooks/useDimension.js";import M from"../svg/coupon-code-tag.js";import x from"../svg/gift-cart-tag.js";import T from"../svg/store-credit-tag.js";import j from"../svg/gift-loyalty.js";import b from"../svg/package-loyalty.js";import w from"../svg/percentage-loyalty.js";import O from"../svg/arrow-loyalty.js";import A from"../svg/star-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as D,searchProducts as F,useLoyaltyPoints as R}from"@ikas/storefront-api";import _ from"../svg/left-arrow-loyalty.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"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{IkasCheckout as V}from"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/region/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/customer-form-data-input/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import{IkasImage as U}from"../../../../models/data/image/index.js";import"../../../../models/data/order/address/region/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/order-transaction-with-prices/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/campaign-offer/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/stock-location/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../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-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 H from"../svg/arrow-right-loyalty.js";var B;!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"}(B||(B={}));var G=i((function(e){var t,n,i,a,l,y,p,v,g,f,h,P,N=e.vm,S=e.allowExpand,M=e.isSuccessPageSummary,x=N.checkout,T=u().t,j=o.useState(!S),b=j[0],w=j[1],O=o.useState(!1),A=O[0],D=O[1],F=o.useState(null),R=F[0],_=F[1],V=o.useState(0),U=V[0],H=V[1],G=o.useState(null),Y=G[0],$=G[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(!1),oe=ne[0],ie=ne[1],ae=o.useState(!1),le=ae[0],se=ae[1],re=I().isMobile;o.useEffect((function(){S&&(b?Y&&H(Y.getBoundingClientRect().height):H(0))}),[b,Y,S,ee,oe,A,le]);var ce=o.useMemo((function(){switch(R){case B.COUPON_CODE_NOT_EXIST:return T("checkout-page:giftCodeErrorDescription");case B.COUPON_CODE_NOT_EXIST_FOR_GUESS:return T("checkout-page:mustBeSignInToApplyCampaign");case B.COUPON_APPLIED_WITHOUT_DISCOUNT:return T("checkout-page:couponInvalidForCartItems");default:return""}}),[R]),de=[C.CartSummary,S?C.HideOnDesktop:"",M?C.SuccessPageCartSummary:""].join(" "),ue=S?{height:U+"px"}:void 0,me=[C.ArrowDown,b?C.Rotated:""].join(" "),ye=!!(null===(t=N.loyaltySpendingMethods)||void 0===t?void 0:t.length)&&(null===(n=N.loyaltySpendingMethods)||void 0===n?void 0:n.length)>0&&!re&&!!(null===(i=N.customizationProps)||void 0===i?void 0:i.showLoyaltyPoints)&&!N.isOpenEditOrderWithTransaction&&!(N.checkout.createdBy===k.UPSELL||N.checkout.createdBy===k.ADMIN);return x?o.createElement(o.Fragment,null,!!S&&o.createElement(o.Fragment,null,o.createElement("div",{id:"checkout-mobile-summary-header"}),o.createElement("div",{className:C.ExpandHeader,onClick:function(){if(!b){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}w(!b)}},o.createElement("div",{className:C.Left},T("checkout-page:summary")),o.createElement("div",{className:C.Price},o.createElement("span",{className:C.PriceText},"".concat(d(N.finalPrice||0,x.currencyCode,x.currencySymbol)," (").concat(x.itemQuantity," ").concat(T("checkout-page:cartItemProduct"),")")),o.createElement("span",{className:me},o.createElement(E,null))))),o.createElement("div",{className:de},o.createElement("div",{className:[C.DetailsContainer,M?C.SuccessPageDetailContainer:""].join(" "),style:ue},o.createElement("div",{className:C.Details,ref:$},o.createElement("div",{className:C.ItemsContainer},o.createElement("div",null,x.items.map((function(e,t){return o.createElement(m,{key:t,vm:N,cartItem:e,currencyCode:x.currencyCode,onChange:se,isSuccessPageSummary:M})})))),o.createElement("div",{className:C.Divider}),o.createElement("div",{className:C.SubTotalInfo},A&&o.createElement("div",{className:C.NotificationContainer},o.createElement(s,{type:"warning",title:T("checkout-page:giftCodeErrorTitle"),content:ce,onClose:function(){D(!1),_(null)}})),o.createElement(X,{label:T("checkout-page:subtotal"),value:x.formattedTotalPrice,tooltipText:T("checkout-page:subtotalTooltip"),hideMarginBottom:!(N.isCouponCodeVisible||(null===(a=N.checkout.giftCardLines)||void 0===a?void 0:a.length)||(null===(l=N.checkout.loyaltyLines)||void 0===l?void 0:l.length)||(null===(y=N.checkout.nonCouponAdjustments)||void 0===y?void 0:y.length))}),!!(null===(p=x.shippingLines)||void 0===p?void 0:p.length)&&(N.step===r.SUCCESS?o.createElement(X,{label:T("checkout-page:cartShippingTitle"),value:x.shippingTotal?x.formattedShippingTotal:T("checkout-page:free")}):x.shippingLines.map((function(e,t){return o.createElement(X,{key:t,label:e.paymentMethod?e.title:T("checkout-page:cartShippingTitle"),value:e.finalPrice?d(e.finalPrice,x.currencyCode,x.currencySymbol):T("checkout-page:free")})}))),o.createElement(W,{vm:N}),o.createElement(z,{vm:N}),(N.step===r.SUCCESS&&(!!N.checkout.note||!!N.checkout.appliedCouponCode)||N.step!==r.SUCCESS)&&N.isCouponCodeVisible&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),ye&&o.createElement(K,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible,isMobile:re}),o.createElement(Q,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible}),o.createElement(q,{vm:N,isAddingCoupon:oe,setAddingCoupon:ie,setCouponError:D,setCouponErrorCode:_}),o.createElement(J,{vm:N,isAddingNote:ee,setAddingNote:te}),!!N.installmentExtraPrice&&N.installmentExtraPrice>0&&o.createElement(o.Fragment,null,o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement(X,{label:T("checkout-page:cartInterest"),value:d(N.installmentExtraPrice,x.currencyCode,x.currencySymbol)}))),N.isOpenEditOrderWithTransaction&&o.createElement("div",{className:C.SubTotalInfo,style:{}},!!(null===(v=N.openEditOrderTransaction)||void 0===v?void 0:v.chargedAmount)&&o.createElement(X,{label:T("checkout-page:chargedAmount"),value:d((null===(g=N.openEditOrderTransaction)||void 0===g?void 0:g.chargedAmount)||0,x.currencyCode,x.currencySymbol)}),!!(null===(f=N.openEditOrderTransaction)||void 0===f?void 0:f.refundedAmount)&&o.createElement(X,{label:T("checkout-page:refundedAmount"),value:d((null===(h=N.openEditOrderTransaction)||void 0===h?void 0:h.refundedAmount)||0,x.currencyCode,x.currencySymbol)})),o.createElement("div",{className:[C.TotalContainer,M?C.SuccessPageTotalContainer:""].join(" ")},o.createElement("div",{className:C.TitleContainer},o.createElement("div",{className:C.Title},N.isOpenEditOrderWithTransaction?T("checkout-page:totalAmountPayable"):T("checkout-page:total"))),o.createElement("div",null,o.createElement("div",{className:C.TotalPricesContainer},o.createElement("div",{className:C.TotalPrice},d(N.finalPrice||0,x.currencyCode,x.currencySymbol)),!!x.$totalTax&&!!(null===(P=N.customizationProps)||void 0===P?void 0:P.showTax)&&o.createElement("div",{className:[C.TotalTax].join(" ")},T("checkout-page:cartTaxTitle")+" "+x.$formattedTotalTax)))),!!N.loyaltyEarningMethod&&!!N.loyaltyCustomerInfo&&o.createElement("div",{className:C.LoyaltyEarningMethod},o.createElement("div",{className:C.LoyaltyEarningMethodTitle},T("checkout-page:loyaltyEarningMethodTitle",{value:(N.loyaltyEarningMethod.pointsEarned/(N.loyaltyEarningMethod.amountPerPointsEarned||1)*N.finalPrice).toFixed(2)}))),!M&&!N.isPoweredByHidden&&o.createElement("div",{className:C.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(L,null))))))):null})),X=i((function(e){var t=e.label,n=e.value,i=e.tooltipText,a=e.hideMarginBottom;return o.createElement("div",{className:[C.InfoRow,a?C.hideMb:""].join(" ")},o.createElement("div",{className:C.Label},o.createElement("span",null,t),!!i&&o.createElement(v,{text:i,style:{marginLeft:"8px"}})),o.createElement("div",{className:C.Value},n))})),W=i((function(e){var t=e.vm,n=u().t;return t.checkout?o.createElement(o.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==N.LOYALTY_SPEND})).map((function(e,i){return o.createElement("div",{className:C.InfoRow,key:i},o.createElement("div",{className:C.Label},"INTEREST"===e.name?n("checkout-page:cartInterest"):e.name),o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",o.createElement("span",null,d(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),z=i((function(e){var t,n=e.vm,i=u().t;return n.checkout?o.createElement(o.Fragment,null,null===(t=n.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return o.createElement("div",{className:C.InfoRow,key:t},o.createElement("div",{className:C.Label},o.createElement("div",{className:C.GiftLabel},o.createElement(f,{style:{position:"relative",top:"-1px"}}),o.createElement("span",null,i("checkout-page:giftPackage")))),o.createElement("div",{className:C.Value},o.createElement("span",null,d(e.price,n.checkout.currencyCode,n.checkout.currencySymbol))))}))):null})),q=i((function(n){var i=n.vm,a=n.isAddingCoupon,s=n.setAddingCoupon,c=n.setCouponError,d=n.setCouponErrorCode,m=n.isOpenCouponCode,v=n.isMobile,E=n.showOnlyMobile,g=u().t,f=o.useState(""),L=f[0],k=f[1],N=o.useState(!1),S=N[0],I=N[1],M=o.useRef(null);o.useEffect((function(){a&&M.current&&M.current.focus()}),[a]);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 i.checkout.couponCode=L,I(!0),[4,i.onCouponCodeApply(!0)];case 1:return t.sent(),I(!1),k(""),e=i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length,i.couponError?[3,4]:i.checkout.appliedCouponCode||e?(c(!1),d(null),[4,i.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:i.checkout.couponCode=null,c(!0),d(i.couponError),t.label=5;case 5:return[2]}}))}))},T=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return I(!0),[4,i.removeGiftCardLine(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))},j=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return I(!0),[4,i.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))};i.step,r.SUCCESS;var b=i.step===r.SHIPPING,w=!!i.checkout.appliedCouponCode||!!(i.checkout.giftCardLines&&i.checkout.giftCardLines.length>0)||!!(i.checkout.loyaltyLines&&i.checkout.loyaltyLines.length>0),O=!!i.checkout.appliedCouponCode&&m,A=!a&&i.isCouponCodeVisible&&!i.isCouponCodeRequirementOpen&&i.step!==r.SUCCESS,D=w&&(!m||v);return o.createElement(o.Fragment,null,!!m&&o.createElement(o.Fragment,null,o.createElement("div",{className:[C.CartSummary,C.OpenCouponCodeSummary].join(" ")},o.createElement("div",{className:h.FormSectionTitle},o.createElement("div",{style:{paddingBottom:O?0:6},className:h.Title},g("checkout-page:couponCode"))))),w&&!b&&!i.isCouponCodeRequirementDefult&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement("div",{className:A?C.InfoRow:""},A&&o.createElement("div",{className:C.ActionTextBtn,onClick:function(){return s(!0)}},g("checkout-page:addCouponCode")),a&&!m&&o.createElement("div",{style:{marginBottom:"10px"}},o.createElement(l,{value:L,placeholder:g("checkout-page:couponCode"),buttonLabel:g("checkout-page:actions.apply"),inputRef:M,onClick:x,isLoading:S,onChange:k})),m&&o.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&x()},className:[C.OpenCouponCodeMain,D?C.OpenCouponCodeMainWithMb:""].join(" ")},o.createElement(y,{name:"couponCode",label:g("checkout-page:addCouponCode"),type:p.TEXT,value:L,onChange:k}),o.createElement(P,{style:{width:"33%"},text:g("checkout-page:actions.apply"),isLoading:S,onClick:x}))),D&&o.createElement(o.Fragment,null,!!i.checkout.appliedCouponCode&&o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(Y,{vm:i,onClearCouponCode:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return i.checkout.couponCode=null,I(!0),[4,i.onCouponCodeApply(!1)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))},couponCode:i.checkout.appliedCouponCode})),!!i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length&&i.checkout.giftCardLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(Y,{vm:i,onClearGiftCode:T,couponCode:e.code,giftCardLine:e}))})),!!i.checkout.loyaltyLines&&!!i.checkout.loyaltyLines.length&&i.checkout.loyaltyLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement($,{vm:i,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),Y=i((function(e){var t=e.vm,n=e.onClearCouponCode,i=e.couponCode,a=e.giftCardLine,l=e.onClearGiftCode,s=t.checkout.couponAdjustment,c=u().t,m=!a,y=(null==a?void 0:a.type)===S.STORE_CREDIT;return o.createElement(o.Fragment,null,o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},a&&y&&o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},o.createElement("span",{style:{height:"20px"}},o.createElement(T,null)),o.createElement("span",{className:C.StoreCreditTag},c("checkout-page:storeCredit"))),!y&&o.createElement("span",{className:[C.AppliedCoupon,t.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},m?o.createElement("span",{style:{height:"16px"}},o.createElement(M,null)):!y&&o.createElement("span",{style:{height:"16px"}},o.createElement(x,null)),o.createElement("span",{className:C.CouponCode},i),t.step!==r.SUCCESS&&!t.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCoupon,onClick:function(){return a?l&&l(a.giftCardId):n&&n()}},o.createElement(g,null)))),o.createElement("div",null,a?o.createElement("div",{className:C.Value},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==a?void 0:a.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===(null==s?void 0:s.type)?"- ":"")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),$=i((function(e){var t,n,i=e.vm,a=e.onClearLoyaltyPoints,l=e.loyaltyPointsLine,s=null===(t=i.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===l.id})),c=u().t,m=null===(n=i.loyaltySpendingMethodsAll)||void 0===n?void 0:n.find((function(e){return e.id===l.loyaltySpendingMethodId})),y=function(){return m?m.type===D.FREE_PRODUCT?{icon:o.createElement(j,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:m.type===D.FREE_SHIPPING?{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:o.createElement(w,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)})}:{icon:o.createElement(w,null),title:c("checkout-page:loyaltyPoints")}};return o.createElement(o.Fragment,null,o.createElement("div",{className:C.LoyaltyPointsLineContainer},o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},o.createElement("span",{className:[C.AppliedCouponLoyalty,i.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},o.createElement("div",{style:{width:"16px",height:"16px"},className:C.LoyaltyPointsLineIcon},y().icon),o.createElement("span",{className:C.CouponCode},y().title),i.step!==r.SUCCESS&&!i.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCouponLoyalty,onClick:function(){return a&&a(l.loyaltySpendingMethodId)}},o.createElement(g,null)))),o.createElement("span",{className:C.LoyaltyPointSpending},"(",c("checkout-page:loyaltyPointSpending",{point:l.amount}),")")),m?m.type!==D.FREE_PRODUCT&&m.type!==D.FREE_SHIPPING?o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))):null:o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))))})),K=i((function(e){var t,n,i,a,l,s,r,c,m,y=e.vm;e.isVisibleLoyaltyPoints;var p=e.setIsVisibleLoyaltyPoints,v=e.isMobile,E=o.useState("undefined"!=typeof window?window.innerWidth:1500),g=E[0],f=E[1];o.useEffect((function(){var e=function(){return f(window.innerWidth)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var h=null===(t=y.loyaltySpendingMethods)||void 0===t?void 0:t.filter((function(e){return e.type===D.FREE_PRODUCT})),L=null!==(n=null==h?void 0:h.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==n?n:[],P=L.length?Math.min.apply(Math,L):null,k=L.length?Math.max.apply(Math,L):null,N=1===(null===(i=y.loyaltySpendingMethods)||void 0===i?void 0:i.length),S=function(e){var t,n,i,a,l,s="",r=null;return e.type===D.FIXED_AMOUNT&&e.isDynamic&&(s=N?"".concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount")," (").concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0,amount:d((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),")"):I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),r=o.createElement(w,null)),e.type===D.FREE_SHIPPING&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),r=o.createElement(b,null)),e.type!==D.FIXED_AMOUNT||e.isDynamic||(s=N?I("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmountOneRow",{value:d((null===(i=e.discountSettings)||void 0===i?void 0:i.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}):I("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(a=e.discountSettings)||void 0===a?void 0:a.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),r=o.createElement(w,null)),e.type===D.FREE_PRODUCT&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),r=o.createElement(j,null)),e.type===D.RATIO&&(s="".concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(l=e.discountSettings)||void 0===l?void 0:l.discountAmount)||0,")"),r=o.createElement(w,null)),{title:s,icon:r}},I=u().t,M=null!==(l=null===(a=y.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type!==D.FREE_PRODUCT})))&&void 0!==l?l:[],x=g>1380||v?h&&h.length>0?2:3:g<1100?h&&h.length>0?0:1:h&&h.length>0?1:2,T=M.slice(0,Math.min(x,M.length));return 1===(null===(s=y.loyaltySpendingMethods)||void 0===s?void 0:s.length)?o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsLineOneRow,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineOneRowTitle},S(null===(r=y.loyaltySpendingMethods)||void 0===r?void 0:r[0]).icon&&S(null===(c=y.loyaltySpendingMethods)||void 0===c?void 0:c[0]).icon,o.createElement("span",{className:C.LoyaltyPointsLineOneRowTitleText},S(null===(m=y.loyaltySpendingMethods)||void 0===m?void 0:m[0]).title)),o.createElement(O,null))):o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsTitle},I("checkout-page:loyaltyPointsTitle")),o.createElement("div",{className:C.LoyaltyPointsLines},T.map((function(e){var t;return o.createElement("div",{key:e.id,className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},S(e).icon&&S(e).icon,o.createElement("span",{className:C.LoyaltyPointsLineTitleText},S(e).title)),o.createElement("span",{className:C.LoyaltyPointsLineValue},(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0," ",I("checkout-page:loyaltyPoint")))})),h&&h.length>0&&o.createElement("div",{className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},o.createElement(j,null),o.createElement("span",{className:C.LoyaltyPointsLineTitleText},I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"))),o.createElement("span",{className:C.LoyaltyPointsLineValue},P&&k?"".concat(P," ~ ").concat(k):""," ",I("checkout-page:loyaltyPoint"))),o.createElement("div",{className:[C.LoyaltyPointsLine,C.LoyaltyPointsLineAllMain].join(" "),onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineAllContainer},o.createElement("span",{className:C.LoyaltyPointsLineAll},I("checkout-page:loyaltyPointsViewAll")),o.createElement(O,null)))))})),Q=i((function(i){var a,l,s,r,m,y,p,v,E,f,h,L,k,N=i.vm,S=i.isVisibleLoyaltyPoints,I=i.setIsVisibleLoyaltyPoints,M=o.useState(!1),x=M[0],T=M[1],O=o.useState(!1),B=O[0],G=O[1],X=o.useState(!1),W=X[0],z=X[1],q=o.useState(!1),Y=q[0],$=q[1],K=o.useState(!1),Q=K[0],J=K[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(null),oe=ne[0],ie=ne[1],ae=o.useState(0),le=ae[0],se=ae[1];o.useEffect((function(){if(S&&!Q){var e=requestAnimationFrame((function(){requestAnimationFrame((function(){return te(!0)}))}));return function(){return cancelAnimationFrame(e)}}S||te(!1)}),[S,Q]),o.useEffect((function(){if(Q){var e=setTimeout((function(){I(!1),J(!1)}),250);return function(){return clearTimeout(e)}}}),[Q]);var re=o.useCallback((function(){J(!0)}),[]),ce=o.useCallback((function(){G(!0)}),[]),de=o.useCallback((function(){$(!0)}),[]);o.useEffect((function(){if(B){var e=setTimeout((function(){T(!1),G(!1)}),180);return function(){return clearTimeout(e)}}}),[B]),o.useEffect((function(){if(Y){var e=setTimeout((function(){z(!1),ie(null),$(!1)}),180);return function(){return clearTimeout(e)}}}),[Y]),o.useEffect((function(){var e,t;if(oe){var n=(null===(e=oe.discountSettings)||void 0===e?void 0:e.point)||1,o=null===(t=oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit;se("number"==typeof o&&o>0?o:n)}}),[oe]);var ue=null===(a=N.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type===D.FREE_PRODUCT})),me=o.useState("undefined"!=typeof window?window.innerHeight:1200),ye=me[0],pe=me[1];o.useEffect((function(){var e=function(){return pe(window.innerHeight)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),o.useEffect((function(){S&&fe((null==ue?void 0:ue.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)||""})))||[])}),[S]);var ve=o.useState([]),Ee=ve[0],ge=ve[1],fe=function(n){return e(void 0,void 0,void 0,(function(){var e,o,i;return t(this,(function(t){switch(t.label){case 0:return(null==n?void 0:n.length)?[4,F({input:{productIdList:n,page:1,perPage:n.length,priceListId:c.getPriceListId(),salesChannelId:c.getSalesChannelId()}},[])]:[2,[]];case 1:return e=t.sent(),o=(null===(i=e.data)||void 0===i?void 0:i.data)||[],ge(o.map((function(e){var t,n,o,i,a,l;return{id:e.id,name:e.name,mainImageSrc:new U({id:(null===(a=null===(i=null===(o=null===(n=null===(t=e.variants)||void 0===t?void 0:t[0])||void 0===n?void 0:n.images)||void 0===o?void 0:o.find((function(e){return e.isMain})))||void 0===i?void 0:i.image)||void 0===a?void 0:a.id)||null,isVideo:!1}).thumbnailSrc,variants:(null===(l=e.variants)||void 0===l?void 0:l.map((function(e){var t,n,o,i;return{id:e.id,mainImageSrc:new U({id:(null===(o=null===(n=null===(t=e.images)||void 0===t?void 0:t.find((function(e){return e.isMain})))||void 0===n?void 0:n.image)||void 0===o?void 0:o.id)||null,isVideo:!1}).thumbnailSrc,variantText:(null===(i=e.variantValues)||void 0===i?void 0:i.map((function(e){return e.name})).join(" / "))||null}})))||[]}}))),[2]}}))}))},he=null!==(l=null==ue?void 0:ue.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==l?l:[],Ce=he.length?Math.min.apply(Math,he):null,Le=he.length?Math.max.apply(Math,he):null,Pe=function(e){var t,n,i="",a=null;return e.type===D.FIXED_AMOUNT&&e.isDynamic&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),a=o.createElement(w,null)),e.type===D.FREE_SHIPPING&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),a=o.createElement(b,null)),e.type!==D.FIXED_AMOUNT||e.isDynamic||(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(t=e.discountSettings)||void 0===t?void 0:t.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}),a=o.createElement(w,null)),e.type===D.FREE_PRODUCT&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),a=o.createElement(j,null)),e.type===D.RATIO&&(i="".concat(Me("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,")"),a=o.createElement(w,null)),{title:i,icon:a}},ke=null===(s=N.loyaltySpendingMethods)||void 0===s?void 0:s.filter((function(e){return e.type!==D.FREE_PRODUCT})),Ne=1===(null==ke?void 0:ke.length),Se=function(e,t){var n,o,i,a,l=null!==(o=null===(n=N.loyaltyCustomerInfo)||void 0===n?void 0:n.totalPoint)&&void 0!==o?o:0;return(null==t?void 0:t.type)===D.FIXED_AMOUNT&&(null==t?void 0:t.isDynamic)?!!((null===(i=t.pointUsageLimit)||void 0===i?void 0:i.minPointLimit)&&(null===(a=t.pointUsageLimit)||void 0===a?void 0:a.minPointLimit)>l):!l||l<e},Ie=function(o,i,a){return e(void 0,void 0,void 0,(function(){var e,l;return t(this,(function(t){switch(t.label){case 0:return[4,R({input:n({cartId:N.checkout.id,loyaltyProgramId:o,loyaltySpendingMethodId:i},a?{amount:a}:{})})];case 1:return(e=t.sent()).isSuccess?(re(),l=e.data,N.checkout=new V(n(n({},l),{shippingAddress:N.checkout.shippingAddress,billingAddress:N.checkout.billingAddress,customer:N.checkout.customer,selectedPaymentGateway:N.checkout.selectedPaymentGateway}),N.countrySettings),[4,N.getLoyaltyCustomerInfo()]):[3,4];case 2:return t.sent(),[4,N.listSpendingMethodsByCartId()];case 3:t.sent(),t.label=4;case 4:return[2,e]}}))}))},Me=u().t;if(!S&&!Q)return null;var xe=[C.LoyaltyPointsLinesModalContainer,ee&&!Q&&C.LoyaltyPointsLinesModalContainerVisible,Q&&C.LoyaltyPointsLinesModalContainerClosing].filter(Boolean).join(" ");return o.createElement("div",{className:xe,onClick:re,role:"presentation"},o.createElement("div",{className:C.LoyaltyPointsLinesModal,onClick:function(e){return e.stopPropagation()},role:"dialog","aria-modal":"true"},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(g,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderTitle},Me("checkout-page:loyaltyPointsLinesModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsLinesModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:W?{maxHeight:"316px",height:"316px"}:{maxHeight:ye<748?ye-140+"px":650}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(r=N.loyaltyCustomerInfo)||void 0===r?void 0:r.totalPoint)||0," ",Me("checkout-page:loyaltyPoint")))),null==ke?void 0:ke.map((function(n,i){var a,l,s,r;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i===((null==ke?void 0:ke.length)||0)-1&&!ue||Ne&&0===i?C.LoyaltyPointsLinesModalContentItemsLast:""].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},Pe(n).icon&&Pe(n).icon),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Pe(n).title),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},n.type===D.FIXED_AMOUNT&&n.isDynamic?Me("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(a=n.discountSettings)||void 0===a?void 0:a.point)||0,amount:d((null===(l=n.discountSettings)||void 0===l?void 0:l.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}):"".concat((null===(s=n.discountSettings)||void 0===s?void 0:s.point)||0," ").concat(Me("checkout-page:loyaltyPoint"))))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:Se((null===(r=n.discountSettings)||void 0===r?void 0:r.point)||0,n),onClick:function(){return e(void 0,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:return e=(null===(o=n.discountSettings)||void 0===o?void 0:o.point)||0,Se(e,n)?[2]:n.type===D.FIXED_AMOUNT&&n.isDynamic?(ie(n),z(!0),[3,3]):[3,1];case 1:return[4,Ie(n.loyaltyProgramId,n.id)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Me("checkout-page:loyaltyPointsLineItemButtonApply")))))})),ue&&ue.length>0&&o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,C.LoyaltyPointsLinesModalContentItemsLast].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},o.createElement(j,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct")),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},Ce&&Le?"".concat(Ce," ~ ").concat(Le):""," ",Me("checkout-page:loyaltyPoint")))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;return!n||n<(null!=Ce?Ce:0)}(),className:C.LoyaltyPointsLinesModalContentItemButton,onClick:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;!n||n<(null!=Ce?Ce:0)||T(!0)}},Me("checkout-page:loyaltyPointsLineItemButtonSelectGift")))))),(x||B)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,B&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(g,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:ce,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(_,null),Me("checkout-page:loyaltyPointsGiftModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsGiftModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(m=N.loyaltyCustomerInfo)||void 0===m?void 0:m.totalPoint)||0," ",Me("checkout-page:loyaltyPoint")))),null==Ee?void 0:Ee.map((function(n,i){var a,l,s,r,c,d;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItemFreeProduct,C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i===((null==Ee?void 0:Ee.length)||0)-1?C.LoyaltyPointsLinesModalContentItemsLast:""].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconImage},n.mainImageSrc&&o.createElement("img",{src:n.mainImageSrc,alt:n.name})),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},n.name),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},(null===(l=null===(a=n.variants)||void 0===a?void 0:a.find((function(e){var t,o;return e.id===(null===(o=null===(t=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===t?void 0:t.discountSettings)||void 0===o?void 0:o.freeProductVariantId)})))||void 0===l?void 0:l.variantText)||""),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPoint},(null===(r=null===(s=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===s?void 0:s.discountSettings)||void 0===r?void 0:r.point)||0," ",Me("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemButtonContainerMobile},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPointMobile},(null===(d=null===(c=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===c?void 0:c.discountSettings)||void 0===d?void 0:d.point)||0," ",Me("checkout-page:loyaltyPoint")),function(){var i,a=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})),l=(null===(i=null==a?void 0:a.discountSettings)||void 0===i?void 0:i.point)||0,s=Se(l,a);return o.createElement("button",{type:"button",disabled:s,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return s||!a?[2]:[4,Ie(a.loyaltyProgramId,a.id)];case 1:return e.sent(),[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Me("checkout-page:loyaltyPointsLineItemButtonAddFree"))}())))}))))),(W&&oe||Y)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,Y&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(g,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:de,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(_,null),Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(y=null==oe?void 0:oe.discountSettings)||void 0===y?void 0:y.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)})),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(p=null==oe?void 0:oe.discountSettings)||void 0===p?void 0:p.point)||0,amount:d((null===(v=null==oe?void 0:oe.discountSettings)||void 0===v?void 0:v.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:{maxHeight:"316px",overflow:"hidden"}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(E=N.loyaltyCustomerInfo)||void 0===E?void 0:E.totalPoint)||0," ",Me("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfo},o.createElement("span",null,le," ",Me("checkout-page:loyaltyPoint")),o.createElement(H,null),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoValue},o.createElement(w,null),o.createElement("span",null,d(le/((null===(f=null==oe?void 0:oe.discountSettings)||void 0===f?void 0:f.point)||1)*((null===(h=null==oe?void 0:oe.discountSettings)||void 0===h?void 0:h.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)))),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},function(){var e,t,n,i,a,l,s,r=(null===(e=null==oe?void 0:oe.discountSettings)||void 0===e?void 0:e.point)||1,c=null!==(n=null===(t=null==oe?void 0:oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit)&&void 0!==n?n:r,d=null!==(s=null!==(a=null===(i=null==oe?void 0:oe.pointUsageLimit)||void 0===i?void 0:i.maxPointLimit)&&void 0!==a?a:null===(l=N.loyaltyCustomerInfo)||void 0===l?void 0:l.totalPoint)&&void 0!==s?s:r,u=Math.max(d-c,0),m=u>0?(le-c)/u*100:0,y=Math.min(100,Math.max(0,m));return o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValue}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueText,style:{width:"".concat(y,"%")}}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueTextValue,style:{left:"".concat(y,"%")}}),o.createElement("input",{type:"range",min:c,max:d,step:r,className:C.LoyaltyPointsLinesModalSliderInput,value:le,onChange:function(e){return se(Number(e.target.value))}}))}())),o.createElement("div",{style:{display:"flex",width:"100%",marginTop:"24px",marginBottom:"24px"}},o.createElement(P,{onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Ie(oe.loyaltyProgramId,oe.id,le)];case 1:return e.sent(),[2]}}))}))},style:{width:"100%"},text:Me("checkout-page:loyaltyPointsLineItemButtonApplyAmount",{amount:d(le/((null===(L=null==oe?void 0:oe.discountSettings)||void 0===L?void 0:L.point)||1)*((null===(k=null==oe?void 0:oe.discountSettings)||void 0===k?void 0:k.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)})})))))))})),J=i((function(e){var t=e.vm,n=e.isAddingNote,i=e.setAddingNote,a=u().t,l=o.useState(t.checkout.note?a("checkout-page:editOrderNote"):a("checkout-page:addOrderNote"))[0],s=o.useCallback((function(){i(!0)}),[]),c=o.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var d=t.step===r.SUCCESS;return d&&!t.checkout.note?null:o.createElement("div",{className:C.InfoRow},!n&&!d&&o.createElement("div",{className:C.ActionTextBtn,onClick:s},l),(n||d)&&o.createElement("div",{className:[C.CheckoutNoteContainer,d?C.Success:""].join(" ")},o.createElement("div",{className:C.Title},a("checkout-page:orderNote")),d?o.createElement("div",{className:C.CheckoutNoteDisplay},t.checkout.note):o.createElement(y,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:c,maxLength:320})))}));export{G as CartSummary,q as Coupon,B as CouponErrorCode,K as LoyaltyPointsLine};
1
+ import{__awaiter as e,__generator as t,__assign as n}from'./../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import a from"lodash/sortBy";import l from"../input-with-button/index.js";import s from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as d}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as y}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import v from"../tooltip/index.js";import E from"../svg/arrow-down.js";import g from"../svg/cross.js";import f from"../svg/gift.js";import h from"../../styles/common.module.scss.js";import C from"./style.module.scss.js";import L from"../svg/ikas.js";import{Button as P}from"../button/index.js";import{IkasCartCreatedBy as k,IkasCampaignCreatedFor as N,IkasGiftCardType as I}from"@ikas/storefront-models";import S from"../../../../hooks/useDimension.js";import M from"../svg/coupon-code-tag.js";import x from"../svg/gift-cart-tag.js";import T from"../svg/store-credit-tag.js";import j from"../svg/gift-loyalty.js";import b from"../svg/package-loyalty.js";import O from"../svg/percentage-loyalty.js";import w from"../svg/arrow-loyalty.js";import A from"../svg/star-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as D,searchProducts as _,useLoyaltyPoints as R}from"@ikas/storefront-api";import F from"../svg/left-arrow-loyalty.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"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{IkasCheckout as U}from"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/region/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/customer-form-data-input/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import{IkasImage as V}from"../../../../models/data/image/index.js";import"../../../../models/data/order/address/region/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/order-transaction-with-prices/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/campaign-offer/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/stock-location/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../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-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 H from"../svg/arrow-right-loyalty.js";var B;!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",e.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED="COUPON_PERIOD_USAGE_LIMIT_EXCEEDED"}(B||(B={}));var G=i((function(e){var t,n,i,a,l,y,p,v,g,f,h,P,N=e.vm,I=e.allowExpand,M=e.isSuccessPageSummary,x=N.checkout,T=u().t,j=o.useState(!I),b=j[0],O=j[1],w=o.useState(!1),A=w[0],D=w[1],_=o.useState(null),R=_[0],F=_[1],U=o.useState(0),V=U[0],H=U[1],G=o.useState(null),Y=G[0],$=G[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(!1),oe=ne[0],ie=ne[1],ae=o.useState(!1),le=ae[0],se=ae[1],re=S().isMobile;o.useEffect((function(){I&&(b?Y&&H(Y.getBoundingClientRect().height):H(0))}),[b,Y,I,ee,oe,A,le]);var ce=o.useMemo((function(){switch(R){case B.COUPON_CODE_NOT_EXIST:return T("checkout-page:giftCodeErrorDescription");case B.COUPON_CODE_NOT_EXIST_FOR_GUESS:return T("checkout-page:mustBeSignInToApplyCampaign");case B.COUPON_APPLIED_WITHOUT_DISCOUNT:return T("checkout-page:couponInvalidForCartItems");case B.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED:return T("checkout-page:couponPeriodUsageLimitExceeded");default:return""}}),[R]),de=[C.CartSummary,I?C.HideOnDesktop:"",M?C.SuccessPageCartSummary:""].join(" "),ue=I?{height:V+"px"}:void 0,me=[C.ArrowDown,b?C.Rotated:""].join(" "),ye=!!(null===(t=N.loyaltySpendingMethods)||void 0===t?void 0:t.length)&&(null===(n=N.loyaltySpendingMethods)||void 0===n?void 0:n.length)>0&&!re&&!!(null===(i=N.customizationProps)||void 0===i?void 0:i.showLoyaltyPoints)&&!N.isOpenEditOrderWithTransaction&&!(N.checkout.createdBy===k.UPSELL||N.checkout.createdBy===k.ADMIN);return x?o.createElement(o.Fragment,null,!!I&&o.createElement(o.Fragment,null,o.createElement("div",{id:"checkout-mobile-summary-header"}),o.createElement("div",{className:C.ExpandHeader,onClick:function(){if(!b){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}O(!b)}},o.createElement("div",{className:C.Left},T("checkout-page:summary")),o.createElement("div",{className:C.Price},o.createElement("span",{className:C.PriceText},"".concat(d(N.finalPrice||0,x.currencyCode,x.currencySymbol)," (").concat(x.itemQuantity," ").concat(T("checkout-page:cartItemProduct"),")")),o.createElement("span",{className:me},o.createElement(E,null))))),o.createElement("div",{className:de},o.createElement("div",{className:[C.DetailsContainer,M?C.SuccessPageDetailContainer:""].join(" "),style:ue},o.createElement("div",{className:C.Details,ref:$},o.createElement("div",{className:C.ItemsContainer},o.createElement("div",null,x.items.map((function(e,t){return o.createElement(m,{key:t,vm:N,cartItem:e,currencyCode:x.currencyCode,onChange:se,isSuccessPageSummary:M})})))),o.createElement("div",{className:C.Divider}),o.createElement("div",{className:C.SubTotalInfo},A&&o.createElement("div",{className:C.NotificationContainer},o.createElement(s,{type:"warning",title:T("checkout-page:giftCodeErrorTitle"),content:ce,onClose:function(){D(!1),F(null)}})),o.createElement(X,{label:T("checkout-page:subtotal"),value:x.formattedTotalPrice,tooltipText:T("checkout-page:subtotalTooltip"),hideMarginBottom:!(N.isCouponCodeVisible||(null===(a=N.checkout.giftCardLines)||void 0===a?void 0:a.length)||(null===(l=N.checkout.loyaltyLines)||void 0===l?void 0:l.length)||(null===(y=N.checkout.nonCouponAdjustments)||void 0===y?void 0:y.length))}),!!(null===(p=x.shippingLines)||void 0===p?void 0:p.length)&&(N.step===r.SUCCESS?o.createElement(X,{label:T("checkout-page:cartShippingTitle"),value:x.shippingTotal?x.formattedShippingTotal:T("checkout-page:free")}):x.shippingLines.map((function(e,t){return o.createElement(X,{key:t,label:e.paymentMethod?e.title:T("checkout-page:cartShippingTitle"),value:e.finalPrice?d(e.finalPrice,x.currencyCode,x.currencySymbol):T("checkout-page:free")})}))),o.createElement(W,{vm:N}),o.createElement(z,{vm:N}),(N.step===r.SUCCESS&&(!!N.checkout.note||!!N.checkout.appliedCouponCode)||N.step!==r.SUCCESS)&&N.isCouponCodeVisible&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),ye&&o.createElement(K,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible,isMobile:re}),o.createElement(Q,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible}),o.createElement(q,{vm:N,isAddingCoupon:oe,setAddingCoupon:ie,setCouponError:D,setCouponErrorCode:F}),o.createElement(J,{vm:N,isAddingNote:ee,setAddingNote:te}),!!N.installmentExtraPrice&&N.installmentExtraPrice>0&&o.createElement(o.Fragment,null,o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement(X,{label:T("checkout-page:cartInterest"),value:d(N.installmentExtraPrice,x.currencyCode,x.currencySymbol)}))),N.isOpenEditOrderWithTransaction&&o.createElement("div",{className:C.SubTotalInfo,style:{}},!!(null===(v=N.openEditOrderTransaction)||void 0===v?void 0:v.chargedAmount)&&o.createElement(X,{label:T("checkout-page:chargedAmount"),value:d((null===(g=N.openEditOrderTransaction)||void 0===g?void 0:g.chargedAmount)||0,x.currencyCode,x.currencySymbol)}),!!(null===(f=N.openEditOrderTransaction)||void 0===f?void 0:f.refundedAmount)&&o.createElement(X,{label:T("checkout-page:refundedAmount"),value:d((null===(h=N.openEditOrderTransaction)||void 0===h?void 0:h.refundedAmount)||0,x.currencyCode,x.currencySymbol)})),o.createElement("div",{className:[C.TotalContainer,M?C.SuccessPageTotalContainer:""].join(" ")},o.createElement("div",{className:C.TitleContainer},o.createElement("div",{className:C.Title},N.isOpenEditOrderWithTransaction?T("checkout-page:totalAmountPayable"):T("checkout-page:total"))),o.createElement("div",null,o.createElement("div",{className:C.TotalPricesContainer},o.createElement("div",{className:C.TotalPrice},d(N.finalPrice||0,x.currencyCode,x.currencySymbol)),!!x.$totalTax&&!!(null===(P=N.customizationProps)||void 0===P?void 0:P.showTax)&&o.createElement("div",{className:[C.TotalTax].join(" ")},T("checkout-page:cartTaxTitle")+" "+x.$formattedTotalTax)))),!!N.loyaltyEarningMethod&&!!N.loyaltyCustomerInfo&&o.createElement("div",{className:C.LoyaltyEarningMethod},o.createElement("div",{className:C.LoyaltyEarningMethodTitle},T("checkout-page:loyaltyEarningMethodTitle",{value:(N.loyaltyEarningMethod.pointsEarned/(N.loyaltyEarningMethod.amountPerPointsEarned||1)*N.finalPrice).toFixed(2)}))),!M&&!N.isPoweredByHidden&&o.createElement("div",{className:C.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(L,null))))))):null})),X=i((function(e){var t=e.label,n=e.value,i=e.tooltipText,a=e.hideMarginBottom;return o.createElement("div",{className:[C.InfoRow,a?C.hideMb:""].join(" ")},o.createElement("div",{className:C.Label},o.createElement("span",null,t),!!i&&o.createElement(v,{text:i,style:{marginLeft:"8px"}})),o.createElement("div",{className:C.Value},n))})),W=i((function(e){var t=e.vm,n=u().t;return t.checkout?o.createElement(o.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==N.LOYALTY_SPEND})).map((function(e,i){return o.createElement("div",{className:C.InfoRow,key:i},o.createElement("div",{className:C.Label},"INTEREST"===e.name?n("checkout-page:cartInterest"):e.name),o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",o.createElement("span",null,d(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),z=i((function(e){var t,n=e.vm,i=u().t;return n.checkout?o.createElement(o.Fragment,null,null===(t=n.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return o.createElement("div",{className:C.InfoRow,key:t},o.createElement("div",{className:C.Label},o.createElement("div",{className:C.GiftLabel},o.createElement(f,{style:{position:"relative",top:"-1px"}}),o.createElement("span",null,i("checkout-page:giftPackage")))),o.createElement("div",{className:C.Value},o.createElement("span",null,d(e.price,n.checkout.currencyCode,n.checkout.currencySymbol))))}))):null})),q=i((function(n){var i=n.vm,a=n.isAddingCoupon,s=n.setAddingCoupon,c=n.setCouponError,d=n.setCouponErrorCode,m=n.isOpenCouponCode,v=n.isMobile,E=n.showOnlyMobile,g=u().t,f=o.useState(""),L=f[0],k=f[1],N=o.useState(!1),I=N[0],S=N[1],M=o.useRef(null);o.useEffect((function(){a&&M.current&&M.current.focus()}),[a]);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 i.checkout.couponCode=L,S(!0),[4,i.onCouponCodeApply(!0)];case 1:return t.sent(),S(!1),k(""),e=i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length,i.couponError?[3,4]:i.checkout.appliedCouponCode||e?(c(!1),d(null),[4,i.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:i.checkout.couponCode=null,c(!0),d(i.couponError),t.label=5;case 5:return[2]}}))}))},T=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return S(!0),[4,i.removeGiftCardLine(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),S(!1),[2]}}))}))},j=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return S(!0),[4,i.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),S(!1),[2]}}))}))};i.step,r.SUCCESS;var b=i.step===r.SHIPPING,O=!!i.checkout.appliedCouponCode||!!(i.checkout.giftCardLines&&i.checkout.giftCardLines.length>0)||!!(i.checkout.loyaltyLines&&i.checkout.loyaltyLines.length>0),w=!!i.checkout.appliedCouponCode&&m,A=!a&&i.isCouponCodeVisible&&!i.isCouponCodeRequirementOpen&&i.step!==r.SUCCESS,D=O&&(!m||v);return o.createElement(o.Fragment,null,!!m&&o.createElement(o.Fragment,null,o.createElement("div",{className:[C.CartSummary,C.OpenCouponCodeSummary].join(" ")},o.createElement("div",{className:h.FormSectionTitle},o.createElement("div",{style:{paddingBottom:w?0:6},className:h.Title},g("checkout-page:couponCode"))))),O&&!b&&!i.isCouponCodeRequirementDefult&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement("div",{className:A?C.InfoRow:""},A&&o.createElement("div",{className:C.ActionTextBtn,onClick:function(){return s(!0)}},g("checkout-page:addCouponCode")),a&&!m&&o.createElement("div",{style:{marginBottom:"10px"}},o.createElement(l,{value:L,placeholder:g("checkout-page:couponCode"),buttonLabel:g("checkout-page:actions.apply"),inputRef:M,onClick:x,isLoading:I,onChange:k})),m&&o.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&x()},className:[C.OpenCouponCodeMain,D?C.OpenCouponCodeMainWithMb:""].join(" ")},o.createElement(y,{name:"couponCode",label:g("checkout-page:addCouponCode"),type:p.TEXT,value:L,onChange:k}),o.createElement(P,{style:{width:"33%"},text:g("checkout-page:actions.apply"),isLoading:I,onClick:x}))),D&&o.createElement(o.Fragment,null,!!i.checkout.appliedCouponCode&&o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(Y,{vm:i,onClearCouponCode:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return i.checkout.couponCode=null,S(!0),[4,i.onCouponCodeApply(!1)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),S(!1),[2]}}))}))},couponCode:i.checkout.appliedCouponCode})),!!i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length&&i.checkout.giftCardLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(Y,{vm:i,onClearGiftCode:T,couponCode:e.code,giftCardLine:e}))})),!!i.checkout.loyaltyLines&&!!i.checkout.loyaltyLines.length&&i.checkout.loyaltyLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement($,{vm:i,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),Y=i((function(e){var t=e.vm,n=e.onClearCouponCode,i=e.couponCode,a=e.giftCardLine,l=e.onClearGiftCode,s=t.checkout.couponAdjustment,c=u().t,m=!a,y=(null==a?void 0:a.type)===I.STORE_CREDIT;return o.createElement(o.Fragment,null,o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},a&&y&&o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},o.createElement("span",{style:{height:"20px"}},o.createElement(T,null)),o.createElement("span",{className:C.StoreCreditTag},c("checkout-page:storeCredit"))),!y&&o.createElement("span",{className:[C.AppliedCoupon,t.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},m?o.createElement("span",{style:{height:"16px"}},o.createElement(M,null)):!y&&o.createElement("span",{style:{height:"16px"}},o.createElement(x,null)),o.createElement("span",{className:C.CouponCode},i),t.step!==r.SUCCESS&&!t.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCoupon,onClick:function(){return a?l&&l(a.giftCardId):n&&n()}},o.createElement(g,null)))),o.createElement("div",null,a?o.createElement("div",{className:C.Value},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==a?void 0:a.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===(null==s?void 0:s.type)?"- ":"")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),$=i((function(e){var t,n,i=e.vm,a=e.onClearLoyaltyPoints,l=e.loyaltyPointsLine,s=null===(t=i.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===l.id})),c=u().t,m=null===(n=i.loyaltySpendingMethodsAll)||void 0===n?void 0:n.find((function(e){return e.id===l.loyaltySpendingMethodId})),y=function(){return m?m.type===D.FREE_PRODUCT?{icon:o.createElement(j,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:m.type===D.FREE_SHIPPING?{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:o.createElement(O,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)})}:{icon:o.createElement(O,null),title:c("checkout-page:loyaltyPoints")}};return o.createElement(o.Fragment,null,o.createElement("div",{className:C.LoyaltyPointsLineContainer},o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},o.createElement("span",{className:[C.AppliedCouponLoyalty,i.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},o.createElement("div",{style:{width:"16px",height:"16px"},className:C.LoyaltyPointsLineIcon},y().icon),o.createElement("span",{className:C.CouponCode},y().title),i.step!==r.SUCCESS&&!i.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCouponLoyalty,onClick:function(){return a&&a(l.loyaltySpendingMethodId)}},o.createElement(g,null)))),o.createElement("span",{className:C.LoyaltyPointSpending},"(",c("checkout-page:loyaltyPointSpending",{point:l.amount}),")")),m?m.type!==D.FREE_PRODUCT&&m.type!==D.FREE_SHIPPING?o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))):null:o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))))})),K=i((function(e){var t,n,i,a,l,s,r,c,m,y=e.vm;e.isVisibleLoyaltyPoints;var p=e.setIsVisibleLoyaltyPoints,v=e.isMobile,E=o.useState("undefined"!=typeof window?window.innerWidth:1500),g=E[0],f=E[1];o.useEffect((function(){var e=function(){return f(window.innerWidth)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var h=null===(t=y.loyaltySpendingMethods)||void 0===t?void 0:t.filter((function(e){return e.type===D.FREE_PRODUCT})),L=null!==(n=null==h?void 0:h.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==n?n:[],P=L.length?Math.min.apply(Math,L):null,k=L.length?Math.max.apply(Math,L):null,N=1===(null===(i=y.loyaltySpendingMethods)||void 0===i?void 0:i.length),I=function(e){var t,n,i,a,l,s="",r=null;return e.type===D.FIXED_AMOUNT&&e.isDynamic&&(s=N?"".concat(S("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount")," (").concat(S("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0,amount:d((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),")"):S("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),r=o.createElement(O,null)),e.type===D.FREE_SHIPPING&&(s=S("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),r=o.createElement(b,null)),e.type!==D.FIXED_AMOUNT||e.isDynamic||(s=N?S("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmountOneRow",{value:d((null===(i=e.discountSettings)||void 0===i?void 0:i.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}):S("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(a=e.discountSettings)||void 0===a?void 0:a.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),r=o.createElement(O,null)),e.type===D.FREE_PRODUCT&&(s=S("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),r=o.createElement(j,null)),e.type===D.RATIO&&(s="".concat(S("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(l=e.discountSettings)||void 0===l?void 0:l.discountAmount)||0,")"),r=o.createElement(O,null)),{title:s,icon:r}},S=u().t,M=null!==(l=null===(a=y.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type!==D.FREE_PRODUCT})))&&void 0!==l?l:[],x=g>1380||v?h&&h.length>0?2:3:g<1100?h&&h.length>0?0:1:h&&h.length>0?1:2,T=M.slice(0,Math.min(x,M.length));return 1===(null===(s=y.loyaltySpendingMethods)||void 0===s?void 0:s.length)?o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsLineOneRow,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineOneRowTitle},I(null===(r=y.loyaltySpendingMethods)||void 0===r?void 0:r[0]).icon&&I(null===(c=y.loyaltySpendingMethods)||void 0===c?void 0:c[0]).icon,o.createElement("span",{className:C.LoyaltyPointsLineOneRowTitleText},I(null===(m=y.loyaltySpendingMethods)||void 0===m?void 0:m[0]).title)),o.createElement(w,null))):o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsTitle},S("checkout-page:loyaltyPointsTitle")),o.createElement("div",{className:C.LoyaltyPointsLines},T.map((function(e){var t;return o.createElement("div",{key:e.id,className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},I(e).icon&&I(e).icon,o.createElement("span",{className:C.LoyaltyPointsLineTitleText},I(e).title)),o.createElement("span",{className:C.LoyaltyPointsLineValue},(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0," ",S("checkout-page:loyaltyPoint")))})),h&&h.length>0&&o.createElement("div",{className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},o.createElement(j,null),o.createElement("span",{className:C.LoyaltyPointsLineTitleText},S("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"))),o.createElement("span",{className:C.LoyaltyPointsLineValue},P&&k?"".concat(P," ~ ").concat(k):""," ",S("checkout-page:loyaltyPoint"))),o.createElement("div",{className:[C.LoyaltyPointsLine,C.LoyaltyPointsLineAllMain].join(" "),onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineAllContainer},o.createElement("span",{className:C.LoyaltyPointsLineAll},S("checkout-page:loyaltyPointsViewAll")),o.createElement(w,null)))))})),Q=i((function(i){var a,l,s,r,m,y,p,v,E,f,h,L,k,N=i.vm,I=i.isVisibleLoyaltyPoints,S=i.setIsVisibleLoyaltyPoints,M=o.useState(!1),x=M[0],T=M[1],w=o.useState(!1),B=w[0],G=w[1],X=o.useState(!1),W=X[0],z=X[1],q=o.useState(!1),Y=q[0],$=q[1],K=o.useState(!1),Q=K[0],J=K[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(null),oe=ne[0],ie=ne[1],ae=o.useState(0),le=ae[0],se=ae[1];o.useEffect((function(){if(I&&!Q){var e=requestAnimationFrame((function(){requestAnimationFrame((function(){return te(!0)}))}));return function(){return cancelAnimationFrame(e)}}I||te(!1)}),[I,Q]),o.useEffect((function(){if(Q){var e=setTimeout((function(){S(!1),J(!1)}),250);return function(){return clearTimeout(e)}}}),[Q]);var re=o.useCallback((function(){J(!0)}),[]),ce=o.useCallback((function(){G(!0)}),[]),de=o.useCallback((function(){$(!0)}),[]);o.useEffect((function(){if(B){var e=setTimeout((function(){T(!1),G(!1)}),180);return function(){return clearTimeout(e)}}}),[B]),o.useEffect((function(){if(Y){var e=setTimeout((function(){z(!1),ie(null),$(!1)}),180);return function(){return clearTimeout(e)}}}),[Y]),o.useEffect((function(){var e,t;if(oe){var n=(null===(e=oe.discountSettings)||void 0===e?void 0:e.point)||1,o=null===(t=oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit;se("number"==typeof o&&o>0?o:n)}}),[oe]);var ue=null===(a=N.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type===D.FREE_PRODUCT})),me=o.useState("undefined"!=typeof window?window.innerHeight:1200),ye=me[0],pe=me[1];o.useEffect((function(){var e=function(){return pe(window.innerHeight)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),o.useEffect((function(){I&&fe((null==ue?void 0:ue.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)||""})))||[])}),[I]);var ve=o.useState([]),Ee=ve[0],ge=ve[1],fe=function(n){return e(void 0,void 0,void 0,(function(){var e,o,i;return t(this,(function(t){switch(t.label){case 0:return(null==n?void 0:n.length)?[4,_({input:{productIdList:n,page:1,perPage:n.length,priceListId:c.getPriceListId(),salesChannelId:c.getSalesChannelId()}},[])]:[2,[]];case 1:return e=t.sent(),o=(null===(i=e.data)||void 0===i?void 0:i.data)||[],ge(o.map((function(e){var t,n,o,i,a,l;return{id:e.id,name:e.name,mainImageSrc:new V({id:(null===(a=null===(i=null===(o=null===(n=null===(t=e.variants)||void 0===t?void 0:t[0])||void 0===n?void 0:n.images)||void 0===o?void 0:o.find((function(e){return e.isMain})))||void 0===i?void 0:i.image)||void 0===a?void 0:a.id)||null,isVideo:!1}).thumbnailSrc,variants:(null===(l=e.variants)||void 0===l?void 0:l.map((function(e){var t,n,o,i;return{id:e.id,mainImageSrc:new V({id:(null===(o=null===(n=null===(t=e.images)||void 0===t?void 0:t.find((function(e){return e.isMain})))||void 0===n?void 0:n.image)||void 0===o?void 0:o.id)||null,isVideo:!1}).thumbnailSrc,variantText:(null===(i=e.variantValues)||void 0===i?void 0:i.map((function(e){return e.name})).join(" / "))||null}})))||[]}}))),[2]}}))}))},he=null!==(l=null==ue?void 0:ue.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==l?l:[],Ce=he.length?Math.min.apply(Math,he):null,Le=he.length?Math.max.apply(Math,he):null,Pe=function(e){var t,n,i="",a=null;return e.type===D.FIXED_AMOUNT&&e.isDynamic&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),a=o.createElement(O,null)),e.type===D.FREE_SHIPPING&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),a=o.createElement(b,null)),e.type!==D.FIXED_AMOUNT||e.isDynamic||(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(t=e.discountSettings)||void 0===t?void 0:t.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}),a=o.createElement(O,null)),e.type===D.FREE_PRODUCT&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),a=o.createElement(j,null)),e.type===D.RATIO&&(i="".concat(Me("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,")"),a=o.createElement(O,null)),{title:i,icon:a}},ke=null===(s=N.loyaltySpendingMethods)||void 0===s?void 0:s.filter((function(e){return e.type!==D.FREE_PRODUCT})),Ne=1===(null==ke?void 0:ke.length),Ie=function(e,t){var n,o,i,a,l=null!==(o=null===(n=N.loyaltyCustomerInfo)||void 0===n?void 0:n.totalPoint)&&void 0!==o?o:0;return(null==t?void 0:t.type)===D.FIXED_AMOUNT&&(null==t?void 0:t.isDynamic)?!!((null===(i=t.pointUsageLimit)||void 0===i?void 0:i.minPointLimit)&&(null===(a=t.pointUsageLimit)||void 0===a?void 0:a.minPointLimit)>l):!l||l<e},Se=function(o,i,a){return e(void 0,void 0,void 0,(function(){var e,l;return t(this,(function(t){switch(t.label){case 0:return[4,R({input:n({cartId:N.checkout.id,loyaltyProgramId:o,loyaltySpendingMethodId:i},a?{amount:a}:{})})];case 1:return(e=t.sent()).isSuccess?(re(),l=e.data,N.checkout=new U(n(n({},l),{shippingAddress:N.checkout.shippingAddress,billingAddress:N.checkout.billingAddress,customer:N.checkout.customer,selectedPaymentGateway:N.checkout.selectedPaymentGateway}),N.countrySettings),[4,N.getLoyaltyCustomerInfo()]):[3,4];case 2:return t.sent(),[4,N.listSpendingMethodsByCartId()];case 3:t.sent(),t.label=4;case 4:return[2,e]}}))}))},Me=u().t;if(!I&&!Q)return null;var xe=[C.LoyaltyPointsLinesModalContainer,ee&&!Q&&C.LoyaltyPointsLinesModalContainerVisible,Q&&C.LoyaltyPointsLinesModalContainerClosing].filter(Boolean).join(" ");return o.createElement("div",{className:xe,onClick:re,role:"presentation"},o.createElement("div",{className:C.LoyaltyPointsLinesModal,onClick:function(e){return e.stopPropagation()},role:"dialog","aria-modal":"true"},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(g,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderTitle},Me("checkout-page:loyaltyPointsLinesModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsLinesModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:W?{maxHeight:"316px",height:"316px"}:{maxHeight:ye<748?ye-140+"px":650}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(r=N.loyaltyCustomerInfo)||void 0===r?void 0:r.totalPoint)||0," ",Me("checkout-page:loyaltyPoint")))),null==ke?void 0:ke.map((function(n,i){var a,l,s,r;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i===((null==ke?void 0:ke.length)||0)-1&&!ue||Ne&&0===i?C.LoyaltyPointsLinesModalContentItemsLast:""].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},Pe(n).icon&&Pe(n).icon),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Pe(n).title),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},n.type===D.FIXED_AMOUNT&&n.isDynamic?Me("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(a=n.discountSettings)||void 0===a?void 0:a.point)||0,amount:d((null===(l=n.discountSettings)||void 0===l?void 0:l.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}):"".concat((null===(s=n.discountSettings)||void 0===s?void 0:s.point)||0," ").concat(Me("checkout-page:loyaltyPoint"))))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:Ie((null===(r=n.discountSettings)||void 0===r?void 0:r.point)||0,n),onClick:function(){return e(void 0,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:return e=(null===(o=n.discountSettings)||void 0===o?void 0:o.point)||0,Ie(e,n)?[2]:n.type===D.FIXED_AMOUNT&&n.isDynamic?(ie(n),z(!0),[3,3]):[3,1];case 1:return[4,Se(n.loyaltyProgramId,n.id)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Me("checkout-page:loyaltyPointsLineItemButtonApply")))))})),ue&&ue.length>0&&o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,C.LoyaltyPointsLinesModalContentItemsLast].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},o.createElement(j,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct")),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},Ce&&Le?"".concat(Ce," ~ ").concat(Le):""," ",Me("checkout-page:loyaltyPoint")))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;return!n||n<(null!=Ce?Ce:0)}(),className:C.LoyaltyPointsLinesModalContentItemButton,onClick:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;!n||n<(null!=Ce?Ce:0)||T(!0)}},Me("checkout-page:loyaltyPointsLineItemButtonSelectGift")))))),(x||B)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,B&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(g,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:ce,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(F,null),Me("checkout-page:loyaltyPointsGiftModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsGiftModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(m=N.loyaltyCustomerInfo)||void 0===m?void 0:m.totalPoint)||0," ",Me("checkout-page:loyaltyPoint")))),null==Ee?void 0:Ee.map((function(n,i){var a,l,s,r,c,d;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItemFreeProduct,C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i===((null==Ee?void 0:Ee.length)||0)-1?C.LoyaltyPointsLinesModalContentItemsLast:""].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconImage},n.mainImageSrc&&o.createElement("img",{src:n.mainImageSrc,alt:n.name})),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},n.name),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},(null===(l=null===(a=n.variants)||void 0===a?void 0:a.find((function(e){var t,o;return e.id===(null===(o=null===(t=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===t?void 0:t.discountSettings)||void 0===o?void 0:o.freeProductVariantId)})))||void 0===l?void 0:l.variantText)||""),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPoint},(null===(r=null===(s=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===s?void 0:s.discountSettings)||void 0===r?void 0:r.point)||0," ",Me("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemButtonContainerMobile},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPointMobile},(null===(d=null===(c=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===c?void 0:c.discountSettings)||void 0===d?void 0:d.point)||0," ",Me("checkout-page:loyaltyPoint")),function(){var i,a=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})),l=(null===(i=null==a?void 0:a.discountSettings)||void 0===i?void 0:i.point)||0,s=Ie(l,a);return o.createElement("button",{type:"button",disabled:s,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return s||!a?[2]:[4,Se(a.loyaltyProgramId,a.id)];case 1:return e.sent(),[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Me("checkout-page:loyaltyPointsLineItemButtonAddFree"))}())))}))))),(W&&oe||Y)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,Y&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(g,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:de,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(F,null),Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(y=null==oe?void 0:oe.discountSettings)||void 0===y?void 0:y.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)})),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(p=null==oe?void 0:oe.discountSettings)||void 0===p?void 0:p.point)||0,amount:d((null===(v=null==oe?void 0:oe.discountSettings)||void 0===v?void 0:v.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:{maxHeight:"316px",overflow:"hidden"}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(E=N.loyaltyCustomerInfo)||void 0===E?void 0:E.totalPoint)||0," ",Me("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfo},o.createElement("span",null,le," ",Me("checkout-page:loyaltyPoint")),o.createElement(H,null),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoValue},o.createElement(O,null),o.createElement("span",null,d(le/((null===(f=null==oe?void 0:oe.discountSettings)||void 0===f?void 0:f.point)||1)*((null===(h=null==oe?void 0:oe.discountSettings)||void 0===h?void 0:h.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)))),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},function(){var e,t,n,i,a,l,s,r=(null===(e=null==oe?void 0:oe.discountSettings)||void 0===e?void 0:e.point)||1,c=null!==(n=null===(t=null==oe?void 0:oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit)&&void 0!==n?n:r,d=null!==(s=null!==(a=null===(i=null==oe?void 0:oe.pointUsageLimit)||void 0===i?void 0:i.maxPointLimit)&&void 0!==a?a:null===(l=N.loyaltyCustomerInfo)||void 0===l?void 0:l.totalPoint)&&void 0!==s?s:r,u=Math.max(d-c,0),m=u>0?(le-c)/u*100:0,y=Math.min(100,Math.max(0,m));return o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValue}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueText,style:{width:"".concat(y,"%")}}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueTextValue,style:{left:"".concat(y,"%")}}),o.createElement("input",{type:"range",min:c,max:d,step:r,className:C.LoyaltyPointsLinesModalSliderInput,value:le,onChange:function(e){return se(Number(e.target.value))}}))}())),o.createElement("div",{style:{display:"flex",width:"100%",marginTop:"24px",marginBottom:"24px"}},o.createElement(P,{onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Se(oe.loyaltyProgramId,oe.id,le)];case 1:return e.sent(),[2]}}))}))},style:{width:"100%"},text:Me("checkout-page:loyaltyPointsLineItemButtonApplyAmount",{amount:d(le/((null===(L=null==oe?void 0:oe.discountSettings)||void 0===L?void 0:L.point)||1)*((null===(k=null==oe?void 0:oe.discountSettings)||void 0===k?void 0:k.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)})})))))))})),J=i((function(e){var t=e.vm,n=e.isAddingNote,i=e.setAddingNote,a=u().t,l=o.useState(t.checkout.note?a("checkout-page:editOrderNote"):a("checkout-page:addOrderNote"))[0],s=o.useCallback((function(){i(!0)}),[]),c=o.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var d=t.step===r.SUCCESS;return d&&!t.checkout.note?null:o.createElement("div",{className:C.InfoRow},!n&&!d&&o.createElement("div",{className:C.ActionTextBtn,onClick:s},l),(n||d)&&o.createElement("div",{className:[C.CheckoutNoteContainer,d?C.Success:""].join(" ")},o.createElement("div",{className:C.Title},a("checkout-page:orderNote")),d?o.createElement("div",{className:C.CheckoutNoteDisplay},t.checkout.note):o.createElement(y,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:c,maxLength:320})))}));export{G as CartSummary,q as Coupon,B as CouponErrorCode,K as LoyaltyPointsLine};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import n from"react-tooltip";import a,{CheckoutStep as s}from"./model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as l}from"../../utils/currency.js";import{useTranslation as m}from"../../utils/i18n.js";import d from"./steps/step-info/index.js";import{CheckoutStepShipping as p}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as u}from"./steps/step-payment/index.js";import{CouponErrorCode as f,Coupon as g,CartSummary as v}from"./components/cart-summary/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as h}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-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{ContactForm as E}from"../../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{StepSuccess as y}from"./steps/step-success/index.js";import{Modal as x}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import j from"./components/master-pass/modal-success/index.js";import{Image as P}from"../image/index.js";import N,{Step as O}from"./components/step-container/index.js";import{StockError as b}from"./components/error/stock-error/index.js";import{FullscreenLoading as S}from"./components/fullscreen-loading/index.js";import M from"./components/notification-box/index.js";import{FormItem as F}from"./components/form-item/index.js";import{FormItemType as T}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as I}from"../page/head.js";import A from"./components/offer-product/index.js";import L from"./components/offer-product/placeholder-offer-product.js";import B from"./components/svg/ikas.js";import D from"./style.module.scss.js";import{Analytics as V}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import R from"./components/svg/success-circle.js";import U from"./components/offer-product/offer-dots/index.js";import z from"./components/offer-product/offer-arrows/index.js";import _ from"./components/offer-product/useCampaignOffer.js";import H from"../../hooks/useDimension.js";var W=i((function(e){var t,i,l,d,p,u,f,g=e.checkout,E=e.checkoutSettings,N=e.customizationProps,O=e.returnPolicy,M=e.privacyPolicy,F=e.termsOfService,T=e.imprint,A=e.shippingPolicy,U=m().t,z=r(),H=o.useState(Date.now()),W=H[0],X=H[1],K=o.useState((function(){return new a(g,E,z,O,M,F,T,A,U,N||{})}))[0];o.useEffect((function(){X(Date.now())}),[g.campaignOffers,K.campaignOffers,K.isCampaignOfferLoaded]);var ee=_(K),te=ee.setShowDetailPage,oe=ee.isPopupShowIndexPage,ie=ee.isShowSuccessPageMiddlePhase;o.useMemo((function(){return Date.now()}),[]);return K.step,s.PAYMENT,o.useEffect((function(){var e;K.checkoutSettings.isAccountRequired&&!K.checkout.hasCustomer&&z.push("/account/login?redirect="+encodeURIComponent(K.checkoutUrl)),new URLSearchParams(window.location.search).get("step")!==s.SUCCESS&&(K.checkoutSettings.isAccountRequired&&(null===(e=K.checkout.customer)||void 0===e?void 0:e.isGuestCheckout)||V.beginCheckout(K.checkout)),V.pageView(h.CHECKOUT)}),[]),o.useEffect((function(){K.customizationProps=N,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED"),document.documentElement.style.setProperty("--checkout-secondary-button-bg-color",(null==e?void 0:e.secondaryButtonBgColor)||"#ffffff0"),document.documentElement.style.setProperty("--checkout-secondary-button-text-color",(null==e?void 0:e.secondaryButtonTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-button-border-color",(null==e?void 0:e.secondaryButtonBorderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-campaign-title-color",(null==e?void 0:e.campaignOffersTitleColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-description-color",(null==e?void 0:e.campaignOffersDescriptionColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-container-bg-color",(null==e?void 0:e.campaignOffersContainerBgColor)||"#ffffff"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-color",(null==e?void 0:e.campaignOffersDiscountPercentageColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-bg-color",(null==e?void 0:e.campaignOffersDiscountPercentageBgColor)||"#FFF1BD"),document.documentElement.style.setProperty("--checkout-campaign-countdown-text-color",(null==e?void 0:e.campaignOffersCountdownTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-countdown-time-color",(null==e?void 0:e.campaignOffersCountdownTimeColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-campaign-countdown-bg-color",(null==e?void 0:e.campaignOffersCountdownBgColor)||"#FFF5F6"),document.documentElement.style.setProperty("--checkout-campaign-middle-phase-overlay-color",(null==e?void 0:e.campaignOffersMiddlePhaseOverlayColor)||"#292727ad")}(N)}),[N]),o.useEffect((function(){var e=document.querySelector(".ikas-storefront-widget");e&&e.remove()}),[]),K.isCheckoutLoaded&&K.store.customerStore.initialized?K.checkout.hasCustomer&&(null===(t=K.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(i=K.checkout.customer)||void 0===i?void 0:i.id)?(z.push("/account/login?redirect="+encodeURIComponent(K.checkoutUrl)),null):o.createElement(o.Fragment,null,o.createElement(I,{pageType:h.CHECKOUT,pageTitle:((null===(l=K.merchantSettings)||void 0===l?void 0:l.merchantName)||"")+" - "+U("checkout-page:securePayment"),pageDescription:U("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:D.CheckoutPage},ie?o.createElement("div",{className:D.FullPageOfferMain},o.createElement("div",{className:D.FullPageOfferContainer},o.createElement("div",{className:D.LogoMain},(null===(d=K.customizationProps)||void 0===d?void 0:d.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:K.customizationProps.logo,sizes:"360px"})):(null===(p=K.merchantSettings)||void 0===p?void 0:p.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:K.merchantSettings.logo,sizes:"360px"})):(null===(u=K.merchantSettings)||void 0===u?void 0:u.merchantName)||""),o.createElement("div",{className:D.OfferSuccessInfo},o.createElement("div",null,o.createElement("div",{className:D.OfferSuccessHeader},o.createElement(R,{className:D.SuccessCircle}),o.createElement("span",{className:D.SuccessTitle},U("checkout-page:orderSuccessShortTitle"))),o.createElement("div",{className:D.OfferOrderInfoMain},o.createElement("div",{className:D.InfoTitle},U("checkout-page:orderNoAndDate"),":"),o.createElement("div",{className:D.InfoText},"#"+(K.checkout.orderNumber||"")," ",K.checkout.dateStr))),o.createElement("div",null,o.createElement(w,{classes:D.OfferButton,isLine:!0,text:U("checkout-page:actions.goOrderDetailPage"),onClick:function(){te(!1)}}))),o.createElement("div",null,o.createElement(Z,{vm:K,key:W})))):null,o.createElement(n,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:D.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[D.Left].join(" ")},o.createElement("div",{className:D.LeftContent},o.createElement("div",null,o.createElement(G,{vm:K}),K.hasStockError&&o.createElement("div",{className:D.ErrorContainer},o.createElement(b,{vm:K,error:K.error})),!K.hasStockError&&o.createElement(o.Fragment,null,K.step!==s.SUCCESS&&o.createElement(v,{vm:K,allowExpand:!0}),K.step===s.SUCCESS?o.createElement(y,{vm:K}):o.createElement(o.Fragment,null,!!(null===(f=K.customizationProps)||void 0===f?void 0:f.showCampaignOffersDesign)&&c.getIsEditor()&&o.createElement(L,{vm:K}),oe&&o.createElement("div",{className:[D.MiddlePhaseOverlay,oe?D.MiddlePhaseOverlayPopup:""].join(" ")}),K.campaignOffers&&!!K.campaignOffers.length&&K.isCampaignOfferLoaded&&o.createElement($,{key:W,vm:K}),K.isCouponCodeRequirementOpen&&o.createElement(q,{vm:K}),o.createElement(Y,{vm:K}))),o.createElement("div",{className:D.Space})),o.createElement(J,{vm:K}))),o.createElement("div",{className:D.Right},o.createElement("div",{className:D.RightContent},o.createElement(v,{vm:K}),!K.isPoweredByHidden&&o.createElement("div",{className:D.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!K.policyModalText&&o.createElement(x,{title:K.policyModalTitle,modalContent:K.policyModalText,onClose:function(){K.policyModalText=""},isPolicyModal:!0}),K.isContactModalVisible&&o.createElement(Q,{vm:K,setVisible:K.setContactModalVisible}),K.mpVM.isOtpModalVisible&&o.createElement(k,{vm:K,visible:K.mpVM.isOtpModalVisible,type:K.mpVM.otpModalType,onClose:K.mpVM.hideOtpModal}),K.mpVM.isResponseModalVisible&&o.createElement(C,{visible:K.mpVM.isResponseModalVisible,text:K.mpVM.mfsResponseModalText,onClose:K.mpVM.onResponseModalClose}),K.mpVM.isSuccessModalVisible&&o.createElement(j,{visible:K.mpVM.isSuccessModalVisible,type:K.mpVM.successModalType,onClose:K.mpVM.onSuccessModalClose}))):o.createElement(S,null)})),G=i((function(e){var t,i,r,n,a=e.vm,s=c.getCurrentRouting(),l=(null==s?void 0:s.path)?"/".concat(s.path):"/",d=m().t;return o.createElement("div",{className:D.Header},o.createElement("a",{href:l},(null===(t=a.customizationProps)||void 0===t?void 0:t.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:a.customizationProps.logo,sizes:"360px"})):(null===(i=a.merchantSettings)||void 0===i?void 0:i.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:a.merchantSettings.logo,sizes:"360px"})):(null===(r=a.merchantSettings)||void 0===r?void 0:r.merchantName)||""),!a.checkout.hasCustomer&&!a.isOpenEditOrderWithTransaction&&!a.checkout.edited&&o.createElement("div",{className:D.LoginText},o.createElement("span",{className:D.LoginCta},d("checkout-page:alreadyHaveAnAccount")),o.createElement("a",{href:a.getGoToLoginHref(),className:D.LoginBtn},d("checkout-page:actions.login"))),(a.checkout.hasCustomer||a.isOpenEditOrderWithTransaction||a.checkout.edited)&&o.createElement("div",{className:D.CustomerInfo},o.createElement("div",{className:D.Name},a.checkout.customerFullName),o.createElement("div",{className:D.Email},null===(n=a.checkout.customer)||void 0===n?void 0:n.email)))})),q=i((function(e){var t=e.vm,i=m().t,r=o.useState(!1),n=r[0],a=r[1],s=o.useState(null),c=s[0],l=s[1],d=H().isMobile,p=o.useMemo((function(){switch(c){case f.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case f.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");case f.COUPON_APPLIED_WITHOUT_DISCOUNT:return i("checkout-page:couponInvalidForCartItems");default:return""}}),[c]);return o.createElement("div",{className:D.CouponContainer},n&&o.createElement("div",{className:D.NotificationContainer},o.createElement(M,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:p,onClose:function(){a(!1),l(null)},ignoreScroll:!0})),o.createElement("div",{style:{marginTop:n?12:0}},o.createElement(g,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:function(){},setCouponError:a,setCouponErrorCode:l,showOnlyMobile:!0,isMobile:d})))})),Y=i((function(e){var t=e.vm,i=m().t,r=o.useMemo((function(){switch(t.step){case s.INFO:return o.createElement(d,{vm:t});case s.SHIPPING:return o.createElement(p,{vm:t});case s.PAYMENT:return o.createElement(u,{vm:t});case s.SUCCESS:return o.createElement(y,{vm:t})}}),[t,t.step]),n=H().isMobile,a=[new O(i("checkout-page:address"),t.step===s.INFO,t.step!==s.INFO,t.step!==s.INFO?o.createElement("div",{className:D.AdressStepInfo},o.createElement(X,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&o.createElement("div",{className:D.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==s.INFO?o.createElement("div",{className:D.AddressStepInfoMobile},o.createElement(X,{vm:t})):void 0),new O(i("checkout-page:payment"),t.step===s.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new O(i("checkout-page:shipping"),t.step===s.SHIPPING,t.step===s.PAYMENT,t.step===s.PAYMENT?o.createElement("div",{className:D.AdressStepInfo},o.createElement(K,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&!t.isManualOrderWithShippingLines&&(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:D.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===s.PAYMENT?o.createElement("div",{className:D.AddressStepInfoMobile},o.createElement(K,{vm:t})):void 0)),o.createElement(N,{steps:a,stepContent:r,step:t.step,hasTopMargin:t.isCouponCodeRequirementOpen||t.campaignOffers&&!!t.campaignOffers.length&&t.isCampaignOfferLoaded,vm:t,isMobile:n})})),X=i((function(e){var t,i,r,n,a,s,c,l,d,p=e.vm,u=m().t,f=p.isDigitalOnly?((null===(t=p.checkout.billingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(i=p.checkout.billingAddress)||void 0===i?void 0:i.lastName)||""):((null===(r=p.checkout.shippingAddress)||void 0===r?void 0:r.firstName)||"")+" "+((null===(n=p.checkout.shippingAddress)||void 0===n?void 0:n.lastName)||"");return o.createElement("div",{className:D.Address},o.createElement("div",{className:[D.Text,D.WithMBottom].join(" ")},(null===(a=p.checkout.customer)||void 0===a?void 0:a.email)||""),"address"===p.deliveryMethod?o.createElement("div",{className:D.Text},f):o.createElement(o.Fragment,null,o.createElement("div",{className:D.Text},u("checkout-page:receiver")),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},f)),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},p.isDigitalOnly?null===(s=p.checkout.billingAddress)||void 0===s?void 0:s.phone:null===(c=p.checkout.shippingAddress)||void 0===c?void 0:c.phone),"in-store"===p.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[D.Text,D.WithMTop].join(" ")},u("checkout-page:pickUpLocation"))),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},p.isDigitalOnly?null===(l=p.checkout.billingAddress)||void 0===l?void 0:l.addressText:null===(d=p.checkout.shippingAddress)||void 0===d?void 0:d.addressText))})),K=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:D.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:D.LightText}," / "+(0===t.checkout.shippingLines[0].finalPrice?i("checkout-page:free"):l(t.checkout.shippingLines[0].finalPrice,t.checkout.currencyCode,t.checkout.currencySymbol)))):i("checkout-page:standartShipping"))})),J=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:D.Footer},o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},i("checkout-page:termsOfService")),t.imprint&&o.createElement(o.Fragment,null,o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint}},i("checkout-page:imprint"))),t.shippingPolicy&&o.createElement(o.Fragment,null,o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),Q=i((function(i){var r,n,a,s=i.vm,c=i.setVisible,l=m().t,d=o.useState(!1),p=d[0],u=d[1],f=o.useState(!1),g=f[0],v=f[1],h=o.useState(new E({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];h.email=(null===(r=s.checkout.customer)||void 0===r?void 0:r.email)||"",h.firstName=(null===(n=s.checkout.customer)||void 0===n?void 0:n.firstName)||"",h.lastName=(null===(a=s.checkout.customer)||void 0===a?void 0:a.lastName)||"";var y=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return g?[2,c(!1)]:(u(!0),[4,h.saveContactForm()]);case 1:return e.sent()&&v(!0),u(!1),[2]}}))}))}),[p]);return o.createElement(x,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,g&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(M,{type:"success",title:l("checkout-page:contactFormSent"),content:l("checkout-page:contactFormDescription")})),o.createElement(F,{name:"message",type:T.TEXT_AREA,label:"",value:h.message||"",onChange:h.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:l(g?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:p,isDisabled:!h.message,onClick:y})),onClose:function(){return c(!1)}})})),Z=i((function(e){var t=e.vm,i=_(t),r=i.setActiveIndex,n=i.handlePrev,a=i.handleNext,s=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:D.CampaignOfferMain},o.createElement("div",{className:D.OfferSlider},t.campaignOffers.map((function(e,i){var c;return o.createElement(A,{vm:t,campaignOffer:e,index:i,activeIndex:s,offersLength:(null===(c=t.campaignOffers)||void 0===c?void 0:c.length)||0,handlePrev:n,handleNext:a,setActiveIndex:function(e){return r(e)},desktopMiddlePhase:!0,step:t.step})}))),t.campaignOffers.length>1&&o.createElement(z,{handlePrev:n,handleNext:a}),t.campaignOffers.length>1&&o.createElement(U,{vm:t,activeIndex:s})):null})),$=i((function(e){var t=e.vm,i=_(t),r=i.setActiveIndex,n=i.setIsActiveOverlay,a=i.handlePrev,s=i.handleNext,c=i.isPopupClosedIndexPage,l=i.isPopupShowIndexPage,m=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:[D.CampaignOfferMain,l?D.OverlayPopupMain:""].join(" ")},o.createElement("div",{className:D.OfferSlider},t.campaignOffers.map((function(e,i){var d;return o.createElement(A,{vm:t,campaignOffer:e,index:i,activeIndex:m,offersLength:(null===(d=t.campaignOffers)||void 0===d?void 0:d.length)||0,handlePrev:a,handleNext:s,setActiveIndex:function(e){return r(e)},step:t.step,isPopupClosed:c,isPopupShow:l,closePopup:function(){return n(!1)},showPopup:function(){return n(!0)}})}))),t.campaignOffers.length>1&&o.createElement(z,{handlePrev:a,handleNext:s}),t.campaignOffers.length>1&&o.createElement(U,{isPopupShow:l,vm:t,activeIndex:m})):null}));export{W as default};
1
+ import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import n from"react-tooltip";import a,{CheckoutStep as s}from"./model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as l}from"../../utils/currency.js";import{useTranslation as m}from"../../utils/i18n.js";import d from"./steps/step-info/index.js";import{CheckoutStepShipping as p}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as u}from"./steps/step-payment/index.js";import{CouponErrorCode as f,Coupon as g,CartSummary as v}from"./components/cart-summary/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as h}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-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{ContactForm as E}from"../../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{StepSuccess as y}from"./steps/step-success/index.js";import{Modal as x}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import j from"./components/master-pass/modal-success/index.js";import{Image as P}from"../image/index.js";import N,{Step as O}from"./components/step-container/index.js";import{StockError as b}from"./components/error/stock-error/index.js";import{FullscreenLoading as S}from"./components/fullscreen-loading/index.js";import M from"./components/notification-box/index.js";import{FormItem as F}from"./components/form-item/index.js";import{FormItemType as T}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as I}from"../page/head.js";import A from"./components/offer-product/index.js";import L from"./components/offer-product/placeholder-offer-product.js";import B from"./components/svg/ikas.js";import D from"./style.module.scss.js";import{Analytics as U}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import V from"./components/svg/success-circle.js";import R from"./components/offer-product/offer-dots/index.js";import _ from"./components/offer-product/offer-arrows/index.js";import z from"./components/offer-product/useCampaignOffer.js";import G from"../../hooks/useDimension.js";var H=i((function(e){var t,i,l,d,p,u,f,g=e.checkout,E=e.checkoutSettings,N=e.customizationProps,O=e.returnPolicy,M=e.privacyPolicy,F=e.termsOfService,T=e.imprint,A=e.shippingPolicy,R=m().t,_=r(),G=o.useState(Date.now()),H=G[0],X=G[1],K=o.useState((function(){return new a(g,E,_,O,M,F,T,A,R,N||{})}))[0];o.useEffect((function(){X(Date.now())}),[g.campaignOffers,K.campaignOffers,K.isCampaignOfferLoaded]);var ee=z(K),te=ee.setShowDetailPage,oe=ee.isPopupShowIndexPage,ie=ee.isShowSuccessPageMiddlePhase;o.useMemo((function(){return Date.now()}),[]);return K.step,s.PAYMENT,o.useEffect((function(){var e;K.checkoutSettings.isAccountRequired&&!K.checkout.hasCustomer&&_.push("/account/login?redirect="+encodeURIComponent(K.checkoutUrl)),new URLSearchParams(window.location.search).get("step")!==s.SUCCESS&&(K.checkoutSettings.isAccountRequired&&(null===(e=K.checkout.customer)||void 0===e?void 0:e.isGuestCheckout)||U.beginCheckout(K.checkout)),U.pageView(h.CHECKOUT)}),[]),o.useEffect((function(){K.customizationProps=N,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED"),document.documentElement.style.setProperty("--checkout-secondary-button-bg-color",(null==e?void 0:e.secondaryButtonBgColor)||"#ffffff0"),document.documentElement.style.setProperty("--checkout-secondary-button-text-color",(null==e?void 0:e.secondaryButtonTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-button-border-color",(null==e?void 0:e.secondaryButtonBorderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-campaign-title-color",(null==e?void 0:e.campaignOffersTitleColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-description-color",(null==e?void 0:e.campaignOffersDescriptionColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-container-bg-color",(null==e?void 0:e.campaignOffersContainerBgColor)||"#ffffff"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-color",(null==e?void 0:e.campaignOffersDiscountPercentageColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-bg-color",(null==e?void 0:e.campaignOffersDiscountPercentageBgColor)||"#FFF1BD"),document.documentElement.style.setProperty("--checkout-campaign-countdown-text-color",(null==e?void 0:e.campaignOffersCountdownTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-countdown-time-color",(null==e?void 0:e.campaignOffersCountdownTimeColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-campaign-countdown-bg-color",(null==e?void 0:e.campaignOffersCountdownBgColor)||"#FFF5F6"),document.documentElement.style.setProperty("--checkout-campaign-middle-phase-overlay-color",(null==e?void 0:e.campaignOffersMiddlePhaseOverlayColor)||"#292727ad")}(N)}),[N]),o.useEffect((function(){var e=document.querySelector(".ikas-storefront-widget");e&&e.remove()}),[]),K.isCheckoutLoaded&&K.store.customerStore.initialized?K.checkout.hasCustomer&&(null===(t=K.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(i=K.checkout.customer)||void 0===i?void 0:i.id)?(_.push("/account/login?redirect="+encodeURIComponent(K.checkoutUrl)),null):o.createElement(o.Fragment,null,o.createElement(I,{pageType:h.CHECKOUT,pageTitle:((null===(l=K.merchantSettings)||void 0===l?void 0:l.merchantName)||"")+" - "+R("checkout-page:securePayment"),pageDescription:R("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:D.CheckoutPage},ie?o.createElement("div",{className:D.FullPageOfferMain},o.createElement("div",{className:D.FullPageOfferContainer},o.createElement("div",{className:D.LogoMain},(null===(d=K.customizationProps)||void 0===d?void 0:d.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:K.customizationProps.logo,sizes:"360px"})):(null===(p=K.merchantSettings)||void 0===p?void 0:p.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:K.merchantSettings.logo,sizes:"360px"})):(null===(u=K.merchantSettings)||void 0===u?void 0:u.merchantName)||""),o.createElement("div",{className:D.OfferSuccessInfo},o.createElement("div",null,o.createElement("div",{className:D.OfferSuccessHeader},o.createElement(V,{className:D.SuccessCircle}),o.createElement("span",{className:D.SuccessTitle},R("checkout-page:orderSuccessShortTitle"))),o.createElement("div",{className:D.OfferOrderInfoMain},o.createElement("div",{className:D.InfoTitle},R("checkout-page:orderNoAndDate"),":"),o.createElement("div",{className:D.InfoText},"#"+(K.checkout.orderNumber||"")," ",K.checkout.dateStr))),o.createElement("div",null,o.createElement(w,{classes:D.OfferButton,isLine:!0,text:R("checkout-page:actions.goOrderDetailPage"),onClick:function(){te(!1)}}))),o.createElement("div",null,o.createElement(Z,{vm:K,key:H})))):null,o.createElement(n,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:D.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[D.Left].join(" ")},o.createElement("div",{className:D.LeftContent},o.createElement("div",null,o.createElement(W,{vm:K}),K.hasStockError&&o.createElement("div",{className:D.ErrorContainer},o.createElement(b,{vm:K,error:K.error})),!K.hasStockError&&o.createElement(o.Fragment,null,K.step!==s.SUCCESS&&o.createElement(v,{vm:K,allowExpand:!0}),K.step===s.SUCCESS?o.createElement(y,{vm:K}):o.createElement(o.Fragment,null,!!(null===(f=K.customizationProps)||void 0===f?void 0:f.showCampaignOffersDesign)&&c.getIsEditor()&&o.createElement(L,{vm:K}),oe&&o.createElement("div",{className:[D.MiddlePhaseOverlay,oe?D.MiddlePhaseOverlayPopup:""].join(" ")}),K.campaignOffers&&!!K.campaignOffers.length&&K.isCampaignOfferLoaded&&o.createElement($,{key:H,vm:K}),K.isCouponCodeRequirementOpen&&o.createElement(q,{vm:K}),o.createElement(Y,{vm:K}))),o.createElement("div",{className:D.Space})),o.createElement(J,{vm:K}))),o.createElement("div",{className:D.Right},o.createElement("div",{className:D.RightContent},o.createElement(v,{vm:K}),!K.isPoweredByHidden&&o.createElement("div",{className:D.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!K.policyModalText&&o.createElement(x,{title:K.policyModalTitle,modalContent:K.policyModalText,onClose:function(){K.policyModalText=""},isPolicyModal:!0}),K.isContactModalVisible&&o.createElement(Q,{vm:K,setVisible:K.setContactModalVisible}),K.mpVM.isOtpModalVisible&&o.createElement(k,{vm:K,visible:K.mpVM.isOtpModalVisible,type:K.mpVM.otpModalType,onClose:K.mpVM.hideOtpModal}),K.mpVM.isResponseModalVisible&&o.createElement(C,{visible:K.mpVM.isResponseModalVisible,text:K.mpVM.mfsResponseModalText,onClose:K.mpVM.onResponseModalClose}),K.mpVM.isSuccessModalVisible&&o.createElement(j,{visible:K.mpVM.isSuccessModalVisible,type:K.mpVM.successModalType,onClose:K.mpVM.onSuccessModalClose}))):o.createElement(S,null)})),W=i((function(e){var t,i,r,n,a=e.vm,s=c.getCurrentRouting(),l=(null==s?void 0:s.path)?"/".concat(s.path):"/",d=m().t;return o.createElement("div",{className:D.Header},o.createElement("a",{href:l},(null===(t=a.customizationProps)||void 0===t?void 0:t.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:a.customizationProps.logo,sizes:"360px"})):(null===(i=a.merchantSettings)||void 0===i?void 0:i.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:a.merchantSettings.logo,sizes:"360px"})):(null===(r=a.merchantSettings)||void 0===r?void 0:r.merchantName)||""),!a.checkout.hasCustomer&&!a.isOpenEditOrderWithTransaction&&!a.checkout.edited&&o.createElement("div",{className:D.LoginText},o.createElement("span",{className:D.LoginCta},d("checkout-page:alreadyHaveAnAccount")),o.createElement("a",{href:a.getGoToLoginHref(),className:D.LoginBtn},d("checkout-page:actions.login"))),(a.checkout.hasCustomer||a.isOpenEditOrderWithTransaction||a.checkout.edited)&&o.createElement("div",{className:D.CustomerInfo},o.createElement("div",{className:D.Name},a.checkout.customerFullName),o.createElement("div",{className:D.Email},null===(n=a.checkout.customer)||void 0===n?void 0:n.email)))})),q=i((function(e){var t=e.vm,i=m().t,r=o.useState(!1),n=r[0],a=r[1],s=o.useState(null),c=s[0],l=s[1],d=G().isMobile,p=o.useMemo((function(){switch(c){case f.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case f.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");case f.COUPON_APPLIED_WITHOUT_DISCOUNT:return i("checkout-page:couponInvalidForCartItems");case f.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED:return i("checkout-page:couponPeriodUsageLimitExceeded");default:return""}}),[c]);return o.createElement("div",{className:D.CouponContainer},n&&o.createElement("div",{className:D.NotificationContainer},o.createElement(M,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:p,onClose:function(){a(!1),l(null)},ignoreScroll:!0})),o.createElement("div",{style:{marginTop:n?12:0}},o.createElement(g,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:function(){},setCouponError:a,setCouponErrorCode:l,showOnlyMobile:!0,isMobile:d})))})),Y=i((function(e){var t=e.vm,i=m().t,r=o.useMemo((function(){switch(t.step){case s.INFO:return o.createElement(d,{vm:t});case s.SHIPPING:return o.createElement(p,{vm:t});case s.PAYMENT:return o.createElement(u,{vm:t});case s.SUCCESS:return o.createElement(y,{vm:t})}}),[t,t.step]),n=G().isMobile,a=[new O(i("checkout-page:address"),t.step===s.INFO,t.step!==s.INFO,t.step!==s.INFO?o.createElement("div",{className:D.AdressStepInfo},o.createElement(X,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&o.createElement("div",{className:D.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==s.INFO?o.createElement("div",{className:D.AddressStepInfoMobile},o.createElement(X,{vm:t})):void 0),new O(i("checkout-page:payment"),t.step===s.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new O(i("checkout-page:shipping"),t.step===s.SHIPPING,t.step===s.PAYMENT,t.step===s.PAYMENT?o.createElement("div",{className:D.AdressStepInfo},o.createElement(K,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&!t.isManualOrderWithShippingLines&&(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:D.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===s.PAYMENT?o.createElement("div",{className:D.AddressStepInfoMobile},o.createElement(K,{vm:t})):void 0)),o.createElement(N,{steps:a,stepContent:r,step:t.step,hasTopMargin:t.isCouponCodeRequirementOpen||t.campaignOffers&&!!t.campaignOffers.length&&t.isCampaignOfferLoaded,vm:t,isMobile:n})})),X=i((function(e){var t,i,r,n,a,s,c,l,d,p=e.vm,u=m().t,f=p.isDigitalOnly?((null===(t=p.checkout.billingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(i=p.checkout.billingAddress)||void 0===i?void 0:i.lastName)||""):((null===(r=p.checkout.shippingAddress)||void 0===r?void 0:r.firstName)||"")+" "+((null===(n=p.checkout.shippingAddress)||void 0===n?void 0:n.lastName)||"");return o.createElement("div",{className:D.Address},o.createElement("div",{className:[D.Text,D.WithMBottom].join(" ")},(null===(a=p.checkout.customer)||void 0===a?void 0:a.email)||""),"address"===p.deliveryMethod?o.createElement("div",{className:D.Text},f):o.createElement(o.Fragment,null,o.createElement("div",{className:D.Text},u("checkout-page:receiver")),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},f)),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},p.isDigitalOnly?null===(s=p.checkout.billingAddress)||void 0===s?void 0:s.phone:null===(c=p.checkout.shippingAddress)||void 0===c?void 0:c.phone),"in-store"===p.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[D.Text,D.WithMTop].join(" ")},u("checkout-page:pickUpLocation"))),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},p.isDigitalOnly?null===(l=p.checkout.billingAddress)||void 0===l?void 0:l.addressText:null===(d=p.checkout.shippingAddress)||void 0===d?void 0:d.addressText))})),K=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:D.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:D.LightText}," / "+(0===t.checkout.shippingLines[0].finalPrice?i("checkout-page:free"):l(t.checkout.shippingLines[0].finalPrice,t.checkout.currencyCode,t.checkout.currencySymbol)))):i("checkout-page:standartShipping"))})),J=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:D.Footer},o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},i("checkout-page:termsOfService")),t.imprint&&o.createElement(o.Fragment,null,o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint}},i("checkout-page:imprint"))),t.shippingPolicy&&o.createElement(o.Fragment,null,o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),Q=i((function(i){var r,n,a,s=i.vm,c=i.setVisible,l=m().t,d=o.useState(!1),p=d[0],u=d[1],f=o.useState(!1),g=f[0],v=f[1],h=o.useState(new E({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];h.email=(null===(r=s.checkout.customer)||void 0===r?void 0:r.email)||"",h.firstName=(null===(n=s.checkout.customer)||void 0===n?void 0:n.firstName)||"",h.lastName=(null===(a=s.checkout.customer)||void 0===a?void 0:a.lastName)||"";var y=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return g?[2,c(!1)]:(u(!0),[4,h.saveContactForm()]);case 1:return e.sent()&&v(!0),u(!1),[2]}}))}))}),[p]);return o.createElement(x,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,g&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(M,{type:"success",title:l("checkout-page:contactFormSent"),content:l("checkout-page:contactFormDescription")})),o.createElement(F,{name:"message",type:T.TEXT_AREA,label:"",value:h.message||"",onChange:h.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:l(g?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:p,isDisabled:!h.message,onClick:y})),onClose:function(){return c(!1)}})})),Z=i((function(e){var t=e.vm,i=z(t),r=i.setActiveIndex,n=i.handlePrev,a=i.handleNext,s=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:D.CampaignOfferMain},o.createElement("div",{className:D.OfferSlider},t.campaignOffers.map((function(e,i){var c;return o.createElement(A,{vm:t,campaignOffer:e,index:i,activeIndex:s,offersLength:(null===(c=t.campaignOffers)||void 0===c?void 0:c.length)||0,handlePrev:n,handleNext:a,setActiveIndex:function(e){return r(e)},desktopMiddlePhase:!0,step:t.step})}))),t.campaignOffers.length>1&&o.createElement(_,{handlePrev:n,handleNext:a}),t.campaignOffers.length>1&&o.createElement(R,{vm:t,activeIndex:s})):null})),$=i((function(e){var t=e.vm,i=z(t),r=i.setActiveIndex,n=i.setIsActiveOverlay,a=i.handlePrev,s=i.handleNext,c=i.isPopupClosedIndexPage,l=i.isPopupShowIndexPage,m=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:[D.CampaignOfferMain,l?D.OverlayPopupMain:""].join(" ")},o.createElement("div",{className:D.OfferSlider},t.campaignOffers.map((function(e,i){var d;return o.createElement(A,{vm:t,campaignOffer:e,index:i,activeIndex:m,offersLength:(null===(d=t.campaignOffers)||void 0===d?void 0:d.length)||0,handlePrev:a,handleNext:s,setActiveIndex:function(e){return r(e)},step:t.step,isPopupClosed:c,isPopupShow:l,closePopup:function(){return n(!1)},showPopup:function(){return n(!0)}})}))),t.campaignOffers.length>1&&o.createElement(_,{handlePrev:a,handleNext:s}),t.campaignOffers.length>1&&o.createElement(R,{isPopupShow:l,vm:t,activeIndex:m})):null}));export{H as default};
@@ -1 +1 @@
1
- import{__assign as e,__awaiter as t,__generator as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCartCreatedBy as o,IkasCouponCodeRequirement as a,IkasCorporateInvoiceRequirement as c,IkasPaymentMethodType as d,IkasPaymentGatewayType as u,IkasOrderShippingMethod as l,IkasOrderStatus as h,IkasCustomerEmailSubscriptionStatus as p,IkasOrderPaymentStatus as m,IkasTransactionStatus as f,IkasCartCampaignOfferStatus as g,IkasCampaignOfferTargetPageType as y,IkasOrderLineItemStatus as v,IkasAmountType as S,IkasCampaignOfferProductApplicablePriceEnum as b}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 k}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as P}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{IkasCustomerAddress as I}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as C}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as A}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as w}from"../../models/data/order/customer/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{IkasProductPrice as O}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as E}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as R}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/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{LocalizedAddressModel as N}from"@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 T from"./components/credit-card-form/model.js";import M from"../../store/customer/api.js";import j from"../../store/checkout/index.js";import L from"../../store/cart/api.js";import G,{MFS_ELEMENT_ID as D,MFS_SCRIPT_URL as x}from"./modelMasterPass.js";import _ from"../../store/product/index.js";import{TransactionCardAssociationEnum as V,SaveCartInput as F,CheckStocksLineInput as U,getLoyaltyCustomerInfo as B,listSpendingMethodsByCartId as H,LoyaltyProgramPointEarningTypeEnum as Y,listEarningMethods as K,getMilesSmilesDetails as Z,RewardSourceEnum as z,CampaignOfferTargetPageTypeEnum as W}from"@ikas/storefront-api";import{IkasBaseStore as q}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as Q}from"@ikas/storefront-config";import{Analytics as X}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import J from"../../models/data/order/address/ikas-localized-order-address.js";import $ from"../../store/location/index.js";import{isEqual as ee,getCookieValue as te}from"../../utils/helper.js";import ie from"../../analytics/ikasV3.js";var se,ne,re=/^\d+$/,oe=/^3[47]/,ae="undefined"==typeof localStorage,ce={TRY:.25,USD:.0065,EUR:.006},de=function(){function re(o,c,h,C,A,V,re,oe,ce,de){var he=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isPaymentMethodVisible=!0,this.step=se.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.useMilesSmiles=!1,this.milesToRedeem=0,this.milesSmilesDetails=null,this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.hepsipayFrameInitResponse=null,this.iyzicoResponse=null,this.isIyzicoLoading=!1,this.showIyzicoContainer=!1,this.stripeExpressCheckoutSessionResponse=null,this.isStripeExpressCheckoutSessionVisible=!1,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.storeCreditBalance=null,this.loyaltyCustomerInfo=null,this.loyaltySpendingMethods=null,this.loyaltySpendingMethodsAll=null,this.loyaltyEarningMethod=null,this.isLoyaltyPointsVisible=!1,this.showTestModal=!1,this.openEditOrderTransaction=null,this.previousRawValue="",this.previousBin=null,this.init=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,q.getInstance().customerStore.waitUntilInitialized()];case 2:return t.sent(),(e=this.isOpenEditOrder||this.checkout.edited)?[4,this.getOpenEditOrderTransaction()]:[3,4];case 3:t.sent(),t.label=4;case 4:return e&&(this.openEditOrderTransaction||this.checkout.edited)||this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 5:return t.sent(),[2]}}))}))},this.initStep=function(){return t(he,void 0,void 0,(function(){var t,s,n,r,o,c,d;return i(this,(function(i){switch(i.label){case 0:if(Q.getIsEditor())return this.step=se.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),s=t.get("step"),n=t.get("failed"),r=t.get("error"),s){if(this.step=s,this.step===se.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(se.INFO)];if(this.step!==se.PAYMENT||this.canProceedToPayment){if(this.step===se.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(se.INFO)];if(![se.INFO,se.SUCCESS,se.SHIPPING,se.PAYMENT].includes(this.step))return[2,this.changeStep(se.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings||this.isManualOrderWithoutShippingLines?[2,this.changeStep(se.INFO)]:[2,this.changeStep(se.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return i.sent(),this.step!==se.SHIPPING&&this.step!==se.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new P(e(e({},this.checkoutSettings),{couponCodeRequirement:a.DEFAULT}))),this.step!==se.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return i.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:i.sent(),this.checkShippingCountries(),i.label=4;case 4:return[4,this.getStockLocations()];case 5:return i.sent(),[4,this.getAvailableStockLocations()];case 6:i.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),i.label=7;case 7:return this.step!==se.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=se.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==se.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==se.SUCCESS||this.checkout.orderPaymentStatus!==m.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:ne.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:i.sent(),i.label=9;case 9:return this.step!==se.PAYMENT&&this.step!==se.SUCCESS?[3,15]:[4,this.listPaymentGateways()];case 10:return i.sent(),this.checkout.hasCustomer?[4,this.getStoreCreditBalance()]:[3,12];case 11:i.sent(),i.label=12;case 12:return this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,14];case 13:i.sent(),i.label=14;case 14:if(!this.paymentGateways.length&&!this.isFree)return this.error={type:ne.NO_SHIPPING_ERROR},this.isMinTransactionError&&(this.error={type:ne.API_ERROR,data:this.t("checkout-page:minTransactionErrorMessage",{value:200})}),this.isCheckoutLoaded=!0,[2];i.label=15;case 15:return this.step===se.SUCCESS?[3,23]:this.isOpenEditOrder?[3,18]:this.checkout.isComplete?[2,this.changeStep(se.SUCCESS)]:[3,16];case 16:return[4,this.initialStockCheck()];case 17:i.sent(),i.label=18;case 18:return this.checkout.hasCustomer?[4,this.getLoyaltyCustomerInfo()]:[3,22];case 19:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 20:return i.sent(),[4,this.listEarningMethods()];case 21:i.sent(),i.label=22;case 22:return[3,25];case 23:return[4,this.getSuccessTransaction()];case 24:i.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),i.label=25;case 25:return n&&(this.error={type:ne.PAYMENT_ERROR,data:r||null}),this.isCheckoutLoaded=!0,X.checkoutStep(this.checkout,this.step,this.checkoutSettings),[2]}}))}))},this.getOpenEditOrderTransaction=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,M.listOrderTransactionsWithPrices({input:{orderId:this.checkout.id}})];case 1:return(e=t.sent()).isSuccess&&e.data&&e.data.chargedAmount&&(this.openEditOrderTransaction=e.data),[2]}}))}))},this.getSuccessTransaction=function(){return t(he,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return[4,M.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=i.sent(),this.successTransactions=e.isSuccess&&(null===(t=e.data)||void 0===t?void 0:t.length)?e.data:[],this.successTransaction=e.isSuccess&&(null===(s=e.data)||void 0===s?void 0:s.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,l,h,m,f,g,y,v;return i(this,(function(i){switch(i.label){case 0:return e=new F(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=i.sent(),i.label=2;case 2:return this.step!==se.INFO&&this.step!==se.SHIPPING&&this.step!==se.PAYMENT||this.isDigitalOnly||(this.isShowBillingAddressOnShippingStep||this.step===se.PAYMENT||(e.billingAddress=null),e.billingAddress&&(this.isShowBillingAddressOnShippingStep&&this.useDifferentAddress||this.useDifferentAddress&&!this.isShowBillingAddressOnShippingStep&&this.checkoutSettings.showCompanyInfoInShippingAddress)&&(e.billingAddress.company=(null===(n=e.shippingAddress)||void 0===n?void 0:n.company)||null,e.billingAddress.taxNumber=(null===(r=e.shippingAddress)||void 0===r?void 0:r.taxNumber)||null,e.billingAddress.taxOffice=(null===(o=e.shippingAddress)||void 0===o?void 0:o.taxOffice)||null)),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===p.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),null===(null===(c=null===(a=e.shippingAddress)||void 0===a?void 0:a.city)||void 0===c?void 0:c.code)&&""===(null===(u=null===(d=e.shippingAddress)||void 0===d?void 0:d.city)||void 0===u?void 0:u.name)&&(e.shippingAddress.city.name="-"),null===(null===(h=null===(l=e.billingAddress)||void 0===l?void 0:l.city)||void 0===h?void 0:h.code)&&""===(null===(f=null===(m=e.billingAddress)||void 0===m?void 0:m.city)||void 0===f?void 0:f.name)&&(e.billingAddress.city.name="-"),[4,L.saveCart({input:e})];case 3:if((null==(t=i.sent())?void 0:t.graphQLErrors)&&t.graphQLErrors.length)throw s=t.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(g=s.extensions)||void 0===g?void 0:g.code)?{type:ne.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(y=s.extensions)||void 0===y?void 0:y.code)?{type:ne.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(v=s.extensions)||void 0===v?void 0:v.code)?{type:ne.ARGUMENT_VALIDATION_ERROR,data:s.extensions.validationErrors}:{type:ne.API_ERROR,data:t.firstErrorMessage};return[2,t.data]}}))}))},this.inStockDeliveryInputData=function(e){return t(he,void 0,void 0,(function(){var t,s,n=this;return i(this,(function(i){return t=e,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,h,p,m,f;return i(this,(function(i){switch(i.label){case 0:return this.isManualOrder||this.isOpenEditOrderWithTransaction?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===l.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(p=Q.getStockLocationIds())||void 0===p?void 0:p.length)?Q.getStockLocationIds():null,[4,j.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(t=i.sent()).isSuccess)throw s="UPSELL"===this.checkout.createdBy,n=s?this.t("checkout-page:upsellTimeErrorMessage"):t.firstErrorMessage,{type:ne.API_ERROR,data:n};if(null==(r=null===(f=null===(m=t.data)||void 0===m?void 0:m.lines)||void 0===f?void 0:f.filter((function(e){return!e.isAvailable})))?void 0:r.length){for(o=[],a=function(e){var t=c.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&o.push({item:t,stockCount:e.stockCount})},c=this,d=0,u=r;d<u.length;d++)h=u[d],a(h);throw{type:ne.STOCK_ERROR,data:o}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(e){return t(he,void 0,void 0,(function(){return i(this,(function(t){return this.isKlarnaPaymentCompleted=e,[2]}))}))},this.setIsLoyaltyPointsVisible=function(e){he.isLoyaltyPointsVisible=e},this.removeUnavailableItems=function(e){return t(he,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:t=0,s=e,i.label=1;case 1:return t<s.length?(n=s[t],[4,q.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:i.sent(),i.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,j.getAvailableShippingCountries({salesChannelId:Q.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return t(he,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return Q.getPickupStockLocationIds()?[4,j.listStockLocation({id:{in:Q.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=i.sent()).isSuccess||!(null===(t=e.data)||void 0===t?void 0:t.length))return this.error={type:ne.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,i.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(he,void 0,void 0,(function(){var e,t,s,n=this;return i(this,(function(i){switch(i.label){case 0:return Q.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,j.getAvailableStockLocations({lines:e.map((function(e){return new U(e)})),stockLocationIdList:Q.getPickupStockLocationIds(),cartId:this.checkout.id})]):[3,2];case 1:if(!(t=i.sent()).isSuccess)return this.error={type:ne.API_ERROR},[2];s=Q.getCurrentRouting(),this.availableStockLocations=(t.data||[]).filter((function(e){var t,i,r,o;return(null===(i=null===(t=e.address)||void 0===t?void 0:t.country)||void 0===i?void 0:i.id)&&e.address.country.iso2&&(null===(r=n.shippingCountryIds)||void 0===r?void 0:r.includes(e.address.country.id))&&(!(null===(o=null==s?void 0:s.countryCodes)||void 0===o?void 0:o.length)||s.countryCodes.includes(e.address.country.iso2))})),i.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=he.shippingCountryIds)||void 0===e?void 0:e.length)||(he.error={type:ne.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;he.deliveryMethod!==e&&("address"===e&&(he.checkout.stockLocationId=null,(null===(t=he.customerAddresses)||void 0===t?void 0:t.length)?he.onSelectedShippingAddressIdChange(he.customerAddresses[0].id||"-1"):(he.checkout.shippingAddress=new J,he.checkout.shippingAddress.countrySettings=he.countrySettings,he.checkout.shippingAddress.checkoutSettings=he.checkoutSettings,he.checkout.shippingAddress.shippingZones=he.shippingZones)),he.deliveryMethod=e,he.isErrorsVisible=!1)},this.initialStockCheck=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,j.getStoreCreditBalance()];case 1:return e=t.sent(),this.storeCreditBalance=e.data,[2]}}))}))},this.getLoyaltyCustomerInfo=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,B({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyCustomerInfo=e.data),[2]}}))}))},this.listSpendingMethodsByCartId=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,H({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltySpendingMethods=e.data.filter((function(e){return e.isAvailable})),this.loyaltySpendingMethodsAll=e.data),[2]}}))}))},this.listEarningMethods=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,K()];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyEarningMethod=e.data.find((function(e){return"ORDER_CREATE"===e.methodType&&e.pointEarningType===Y.DYNAMIC_ORDER_AMOUNT}))),[2]}}))}))},this.listPaymentGateways=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,o,a,c,d,u,l,h,p,m,f,g,y,v,S,b=this;return i(this,(function(i){switch(i.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,t=Q.getPaymentGateways().map((function(e){return e.id})),[4,j.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:t},locale:Q.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=i.sent()).isSuccess?(null===(g=s.data)||void 0===g?void 0:g.length)||this.isFree?(this.error=void 0,n=null===(y=s.data)||void 0===y?void 0:y.some((function(e){return"IKAS_WALLET"===e.code})),this.isMinTransactionError=n&&this.finalPrice<200&&!this.isDigitalOnly,this.isMinTransactionError?[2]:(o=s.data||[],this.step===se.PAYMENT&&(o=o.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(b.checkout.currencyCode)})),(a=null===(v=this.checkout.shippingAddress)||void 0===v?void 0:v.country)&&a.iso2&&(o=o.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(a.iso2||"")}))),c=null===(S=this.checkout.billingAddress)||void 0===S?void 0:S.country,!a&&c&&c.iso2&&(o=o.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(c.iso2||"")})))),d=[],r(Q.getPaymentGateways(),"order").forEach((function(e){var t=null==o?void 0:o.find((function(t){return t.id===e.id}));t&&d.push(t)})),this.paymentGateways=e?o:d,u=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.checkout.selectedPaymentGateway&&this.paymentGateways.some((function(e){var t;return e.id===(null===(t=b.checkout.selectedPaymentGateway)||void 0===t?void 0:t.id)}))?[3,2]:(this.setPaymentGateway(-1!==u?u:0),[3,4]))):(this.error={type:ne.NO_SHIPPING_ERROR},[2]):(this.error={type:ne.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==se.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:i.sent(),i.label=4;case 4:return this.step===se.PAYMENT&&(l=o.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=l,(h=document.createElement("script")).id=D,h.src=x,h.onload=function(){b.mpVM.checkMasterPass({checkout:b.checkout,store:q.getInstance()})},document.head.appendChild(h)),Q.isMilesSmilesActive()?[4,Z()]:[3,6];case 5:if(!(p=i.sent()).isSuccess&&["UNAUTHORIZED","MILES_SMILES_LOGIN_REQUIRED"].some((function(e){return p.errorCodes.includes(e)})))return m=this.getRoutingPath(),f="".concat(m,"/checkout?id=").concat(this.checkout.id,"&step=payment"),window.location.href="".concat(m,"/account/login?redirect=").concat(f,"&ms_login_required=true"),[2];p.isSuccess&&p.data&&(this.milesSmilesDetails=p.data),i.label=6;case 6:return[2]}}))}))},this.retrieveInstallmentInfo=function(e){return t(he,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return[4,j.retrieveInstallmentInfo(e)];case 1:return t=i.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;he.store.customerStore.customer?(null===(t=he.customerAddresses)||void 0===t||t.forEach((function(e){e.checkoutSettings=he.checkoutSettings,e.shippingZones=he.shippingZones})),he.checkout.customer=new w(e(e({},he.store.customerStore.customer),{notificationsAccepted:he.store.customerStore.customer.subscriptionStatus===p.SUBSCRIBED}))):he.checkout.customer=new w(he.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){he.checkout.shippingAddress&&(he.checkout.shippingAddress.checkoutSettings=he.checkoutSettings,he.checkout.shippingAddress.shippingZones=he.shippingZones,he.checkout.shippingAddress.countrySettings=he.countrySettings,he.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){he.checkout.billingAddress&&(he.checkout.billingAddress.checkoutSettings=he.checkoutSettings,he.checkout.billingAddress.shippingZones=he.shippingZones,he.checkout.billingAddress.countrySettings=he.countrySettings,he.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!he.isDigitalOnly)if(he.isInStoreDelivery)he.setCheckoutShippingAddressSettings();else if(he.checkout.shippingAddress){if(he.store.customerStore.customer){var e=null==(t=he.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=he.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return he.onSelectedShippingAddressIdChange(e.id||"-1"),void he.setCheckoutShippingAddressSettings()}he.checkout.shippingAddress=new J(n(he.checkout.shippingAddress)||{}),he.setCheckoutShippingAddressSettings()}else if(he.store.customerStore.customer){var t=he.customerAddresses;he.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else he.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(he.useDifferentAddress=!!localStorage.getItem("sAddr"),he.checkout.billingAddress){if(he.store.customerStore.customer){var e=null==(t=he.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=he.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return he.onSelectedBillingAddressIdChange(e.id||"-1"),void he.setCheckoutBillingAddressSettings()}he.checkout.billingAddress=new J(n(he.checkout.billingAddress)||{}),he.setCheckoutBillingAddressSettings()}else if(he.store.customerStore.customer){var t=he.customerAddresses;he.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||he.useDifferentAddress||!he.checkout.shippingAddress||he.isInStoreDelivery||(he.checkout.billingAddress=new J(n(he.checkout.shippingAddress)),he.setCheckoutBillingAddressSettings())}else he.onSelectedBillingAddressIdChange("-1"),he.useDifferentAddress||!he.checkout.shippingAddress||he.isInStoreDelivery||(he.checkout.billingAddress=new J(n(he.checkout.shippingAddress)),he.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=e.shippingSettingsId,this.checkout.shippingZoneRateId=e.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=i.sent())&&(this.checkout=new k(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(e){return t(he,void 0,void 0,(function(){return i(this,(function(t){return this.checkout.stockLocationId=e.id,[2]}))}))},this.onCouponCodeApply=function(s){return t(he,void 0,void 0,(function(){var t,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,L.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(c=null===(a=this.cardData)||void 0===a?void 0:a.cardNumber)||void 0===c?void 0:c.split(" ").join(""),this.couponError=null,this.step===se.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(o=this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==se.PAYMENT||this.checkout.totalFinalPrice===o.totalFinalPrice&&!this.checkout.giftCardLines?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,s?X.addCouponCode(n):X.removeCouponCode(n),i.label=7;case 7:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeGiftCardLine=function(s){return t(he,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,L.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===se.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==se.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,i.label=7;case 7:return[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeLoyaltyPointsFromCart=function(s){return t(he,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),[4,L.removeLoyaltyPointsFromCart({cartId:this.checkout.id,loyaltySpendingMethodId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===se.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,9];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==se.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,9];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:return i.sent(),this.isCampaignOfferLoaded=!0,X.removeLoyaltyPoints(n),[4,this.getLoyaltyCustomerInfo()];case 7:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:return i.sent(),[3,11];case 11:return[2]}}))}))},this.getAvailableShippingZones=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,$.getAvailableShippingZones({salesChannelId:Q.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(he.selectedShippingAddressId=e,"-1"===e)he.checkout.shippingAddress=new J,he.checkout.shippingAddress.countrySettings=he.countrySettings;else{var i=null===(t=he.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(he.checkout.shippingAddress=new J(i),he.checkout.shippingAddress.countrySettings=he.countrySettings)}he.checkout.shippingAddress&&(he.checkout.shippingAddress.checkoutSettings=he.checkoutSettings,he.checkout.shippingAddress.shippingZones=he.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(he.selectedBillingAddressId=e,"-1"===e)he.checkout.billingAddress=new J,he.checkout.billingAddress.countrySettings=he.countrySettings;else{var i=null===(t=he.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(he.checkout.billingAddress=new J(i),he.checkout.billingAddress.countrySettings=he.countrySettings)}he.checkout.billingAddress&&(he.checkout.billingAddress.checkoutSettings=he.checkoutSettings,he.checkout.billingAddress.shippingZones=he.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){he.isTermsAndConditionsChecked=e,he.isIyzico&&(he.showIyzicoContainer=e)},this.onCardNumberChange=function(e){if(he.cardData){var t=(e||"").replace(/\D/g,""),i=he.previousRawValue,s=t.slice(0,8),n=he.previousBin;if(!(t.length>16)){var r=i.length<8&&t.length>=8,o=8===s.length&&s!==n;(r||o)&&8===s.length&&(he.getRetrieveInstallmentInfo(t),he.previousBin=s),t.length<8&&i.length>=8&&(he.cardData.installmentCount=1,he.installmentInfo=void 0,he.previousBin=null),he.isAmexCard(t)?he.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(t).join(" "):he.cardData.cardNumber=ue(t,4).join(" "),he.previousRawValue=t}}},this.getRetrieveInstallmentInfo=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:e.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return i.sent(),(null===(t=this.cardData)||void 0===t?void 0:t.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){he.cardData&&(he.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(he.cardData&&(!(e.length>he.cardData.expirationDate.length)||le(e))){if(0===(null===(t=he.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(he.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(he.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(he.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(he.cardData.expirationDate=ue(d,2).join(" / "))}},this.onCvcChange=function(e){if(he.cardData&&(!(e.length>he.cardData.cvv.length)||le(e))){if(he.isAmexCard()){if(e.length>4)return}else if(e.length>3)return;he.cardData.cvv=e}},this.saveAddress=function(s){return t(he,void 0,void 0,(function(){var t,r,o,a,c,d,u,l,h,p,m,f,g=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new I(e(e({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:i.sent(),null===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),i.label=2;case 2:return[3,4];case 3:return l=i.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.getRoutingPath=function(){var e=Q.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):""},this.getGoToCartHref=function(){var e=he.getRoutingPath();return"".concat(e,"/cart")},this.getBackToShoppingHref=function(){var e=he.getRoutingPath();return"".concat(e,"/")},this.getGoToLoginHref=function(){var e=he.getRoutingPath();return"".concat(e)+"/account/login?redirect="+encodeURIComponent(he.checkoutUrl)},this.onHandleBillingAddressOnShippingStep=function(){return t(he,void 0,void 0,(function(){return i(this,(function(t){return this.isShowBillingAddressOnShippingStep&&!this.useDifferentAddress&&("address"===this.deliveryMethod&&this.checkout.shippingAddress?this.checkout.billingAddress=new J(e({},this.checkout.shippingAddress)):this.checkout.billingAddress=new J(e({},this.checkout.billingAddress))),[2]}))}))},this.onProceedToShippingClick=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,10,,11]),this.isStepLoading=!0,"address"!==this.deliveryMethod||this.isShowBillingAddressOnShippingStep?[3,5]:[4,this.saveAddress("shipping")];case 4:t.sent(),t.label=5;case 5:return this.isShowBillingAddressOnShippingStep?[4,this.saveAddress("billing")]:[3,7];case 6:t.sent(),t.label=7;case 7:return[4,this.checkStocks()];case 8:return t.sent(),[4,this.saveCart()];case 9:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(se.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(se.SHIPPING):this.changeStep(se.PAYMENT),[3,11]);case 10:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),this.isStepLoading=!1,[3,11];case 11:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,6,,7]),this.isStepLoading=!0,[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.changeStep(se.PAYMENT),[3,7];case 6:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(se.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!he.canPerformPayment||(he.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){he.error={type:e,data:t}},this.onCompletePaymentClick=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return this.isFree||!this.isIyzico?[3,4]:[4,this.saveCart()];case 3:return i.sent(),[2];case 4:if(this.isFree||!this.isHepsiPay)return[3,11];i.label=5;case 5:return i.trys.push([5,9,,10]),window.HepsipaySdk&&(null===(o=this.hepsipayFrameInitResponse)||void 0===o?void 0:o.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,7];case 6:return i.sent(),window.HepsipaySdk.initPayment(),[3,8];case 7:console.error("HepsipaySdk is not available"),i.label=8;case 8:return[3,10];case 9:return i.sent(),this.isStepLoading=!1,[2];case 10:return[2];case 11:return i.trys.push([11,17,,18]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 12:return i.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,14];case 13:i.sent(),i.label=14;case 14:return[4,this.saveCart()];case 15:return e=i.sent(),this.checkout.shippingMethod===l.SHIPMENT&&(t=null!==(a=null==e?void 0:e.availableShippingMethods)&&void 0!==a?a:[],s=null!==(c=this.checkout.availableShippingMethods)&&void 0!==c?c:[],!ee(t,s))?(this.changeStep(se.SHIPPING),[2]):!this.isFree&&this.isCustomFlowStripe?((n=document.querySelector("#stripe-form-btn"))&&n.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 16:return i.sent(),[3,18];case 17:return void 0!==typeof(r=i.sent()).type?this.error=r:this.error={type:ne.UNKNOWN},this.isStepLoading=!1,[3,18];case 18:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(he,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:if(this.isFree||!this.isHepsiPay)return[3,9];i.label=3;case 3:return i.trys.push([3,7,,8]),window.HepsipaySdk&&(null===(s=this.hepsipayFrameInitResponse)||void 0===s?void 0:s.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,5];case 4:return i.sent(),window.HepsipaySdk.initPayment(),[3,6];case 5:console.error("HepsipaySdk is not available"),i.label=6;case 6:return[3,8];case 7:return i.sent(),this.isStepLoading=!1,[2];case 8:return[2];case 9:return i.trys.push([9,13,,14]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 10:return i.sent(),[4,this.saveCart()];case 11:return i.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 12:return i.sent(),[3,14];case 13:return(t=i.sent()).type?this.error=t:this.error={type:ne.UNKNOWN},this.isStepLoading=!1,[3,14];case 14:return[2]}}))}))},this.createSaleTransaction=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,l,h,p,m,g,y,v,S,b,k,P,I,C,A,w,O;return i(this,(function(i){switch(i.label){case 0:return t=this.mpVM.selectedCard,n=this.useMilesSmiles?{point:this.milesToRedeem||(null===(h=this.milesSmilesDetails)||void 0===h?void 0:h.availableMiles)||0,source:z.MILES_SMILES}:void 0,!this.isFree&&t&&(null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name)?((r=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=r),void 0===(null===(m=this.cardData)||void 0===m?void 0:m.installmentCount)?[2]:[4,j.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name},paymentGatewayId:null===(y=this.mpVM.selectedCard)||void 0===y?void 0:y.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(v=this.cardData)||void 0===v?void 0:v.threeDSecure)},metadata:{_fbp:te("_fbp"),_fbc:te("_fbc"),_ga:te("_ga")},reward:n}})]):[3,2];case 1:return s=i.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway||this.isFree?[4,j.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:t&&e?{phoneNumber:e,savedCardName:null===(S=this.mpVM.selectedCard)||void 0===S?void 0:S.Name}:void 0,paymentGatewayId:this.isFree?"9d41af41-4793-4879-a19c-e9a66c929726":null===(b=this.checkout.selectedPaymentGateway)||void 0===b?void 0:b.id,paymentMethodDetail:this.isFree||t?void 0:(null===(k=this.checkout.selectedPaymentGateway)||void 0===k?void 0:k.paymentMethodType)===d.CREDIT_CARD&&(null===(P=this.checkout.selectedPaymentGateway)||void 0===P?void 0:P.type)===u.INTERNAL&&this.cardData?this.cardData.toInput():void 0,metadata:{_fbp:te("_fbp"),_fbc:te("_fbc"),_ga:te("_ga")},reward:n}})]:[2];case 3:s=i.sent(),i.label=4;case 4:return o=null===(I=null==s?void 0:s.data)||void 0===I?void 0:I.transactionStatus,a=o&&[f.SUCCESS,f.AUTHORIZED].includes(o),c=o===f.PENDING,a?[4,this.getSuccessTransaction()]:[3,7];case 5:return i.sent(),[4,this.onCheckoutTransactionSuccess((null===(C=null==s?void 0:s.data)||void 0===C?void 0:C.orderId)||void 0)];case 6:return i.sent(),[3,8];case 7:if(!c||!(null===(A=null==s?void 0:s.data)||void 0===A?void 0:A.returnSlug))throw l=s.firstErrorMessage,"IKAS_WALLET_501"===(null===(O=null===(w=s.data)||void 0===w?void 0:w.error)||void 0===O?void 0:O.code)&&(l=this.t("checkout-page:errorContactStore")),{data:l,type:ne.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,i.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(e){return t(he,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:i.sent(),i.label=2;case 2:return ie.refreshJourneyId(),this.changeStep(se.SUCCESS,e),[2]}}))}))},this.onBackToInfoClick=function(){he.changeStep(se.INFO)},this.onBackToShippingClick=function(){he.changeStep(se.SHIPPING)},this.setCustomerConsentGranted=function(e){he.checkout.customer&&(he.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(t,i){var s;he.useDifferentAddress=t,he.useDifferentAddress?(localStorage.setItem("sAddr","1"),he.checkout.billingAddress=he.checkout.billingAddress||new J,he.checkout.billingAddress.countrySettings=he.countrySettings):(localStorage.removeItem("sAddr"),he.checkout.billingAddress=new J(e({},he.checkout.shippingAddress)),he.store.customerStore.customer&&(null===(s=he.customerAddresses)||void 0===s?void 0:s.length)&&i&&he.isShowBillingAddressOnShippingStep&&he.onSelectedBillingAddressIdChange(he.checkout.billingAddress.id||"-1"))},this.setShouldSaveAddress=function(e){he.shouldSaveAddress=e},this.setAddressTitle=function(e){he.addressTitle=e},this.reInitPaymentMethod=function(){return t(he,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,10];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return this.isHepsiPay?[4,this.hepsipayFrameInit(this.checkout.selectedPaymentGateway)]:[3,8];case 7:e.sent(),e.label=8;case 8:return this.isIyzico?[4,this.createIyzicoCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,10];case 9:e.sent(),e.label=10;case 10:return[2]}}))}))},this.createStripePaymentIntent=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.stripeResponse=t.data,this.stripeError=null):this.stripeError={type:ne.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.klarnaResponse=t.data,this.klarnaError=null):this.klarnaError={type:ne.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.adyenResponse=t.data),[2]}}))}))},this.getPayPalClientId=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.payPalClientIdResponse=t.data),[2]}}))}))},this.hepsipayFrameInit=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.hepsipayFrameInit({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.hepsipayFrameInitResponse=t.data),[2]}}))}))},this.createIyzicoCheckoutForm=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this.isIyzicoLoading=!0,[4,j.createIyzicoCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.iyzicoResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return this.isIyzicoLoading=!1,[7];case 4:return[2]}}))}))},this.createStripeExpressCheckoutSession=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,j.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.stripeExpressCheckoutSessionResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return[7];case 4:return[2]}}))}))},this.updateStripeExpressCheckoutSession=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:if(!this.stripeExpressCheckoutSessionResponse)return[2,null];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,j.updateStripeExpressCheckoutSession({input:{cartId:this.checkout.id,sessionId:"",transactionId:"",address:e.address||null,shippingSettingsId:e.shippingSettingsId||null,shippingZoneRateId:e.shippingZoneRateId||null}})];case 2:return(t=i.sent()).isSuccess&&t.data?[2,t.data]:[2,null];case 3:return i.sent(),[2,null];case 4:return[2]}}))}))},this.setShowIyzicoContainer=function(e){he.showIyzicoContainer=e},this.setPaymentGateway=function(e){return t(he,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return this.paymentGateways.length?(t=this.paymentGateways[e],s=!0,this.step!==se.PAYMENT?[3,7]:this.checkout.selectedPaymentGateway?[3,3]:"CUSTOM"!==t.code?[3,2]:[4,this.updatePaymentGateway(t)]):[2];case 1:s=i.sent(),i.label=2;case 2:return[3,7];case 3:return"CUSTOM"!==this.checkout.selectedPaymentGateway.code?[3,5]:[4,this.updatePaymentGateway(t)];case 4:return s=i.sent(),[3,7];case 5:return"CUSTOM"!==t.code?[3,7]:[4,this.updatePaymentGateway(t)];case 6:s=i.sent(),i.label=7;case 7:return s?"STRIPE"!==t.code&&"STRIPE_EU"!==t.code||this.stripeResponse?[3,9]:[4,this.createStripePaymentIntent(t)]:[2];case 8:i.sent(),i.label=9;case 9:return"KLARNA"!==t.code||this.klarnaResponse?[3,11]:[4,this.createKlarnaClientToken(t)];case 10:i.sent(),i.label=11;case 11:return"ADYEN_PLATFORM"!==t.code||this.adyenResponse?[3,13]:[4,this.createAdyenBalancePlatformPaymentSession(t)];case 12:i.sent(),i.label=13;case 13:return"PAYPAL"!==t.code||this.payPalClientIdResponse?[3,15]:[4,this.getPayPalClientId(t)];case 14:i.sent(),i.label=15;case 15:return"HEPSIPAY"!==t.code||this.hepsipayFrameInitResponse?[3,17]:[4,this.hepsipayFrameInit(t)];case 16:i.sent(),i.label=17;case 17:return"IYZICO"!==t.code||this.iyzicoResponse?[3,19]:[4,this.createIyzicoCheckoutForm(t)];case 18:i.sent(),i.label=19;case 19:return this.checkout.selectedPaymentGateway=t,this.step!==se.SUCCESS&&(t.paymentMethodType===d.CREDIT_CARD&&t.type===u.INTERNAL&&(this.cardData=new T,this.previousRawValue="",this.previousBin=null,t.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0),[2]}}))}))},this.updatePaymentGateway=function(s){return t(he,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.isPaymentMethodVisible=!1,[4,L.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id,targetPageType:W.CHECKOUT})];case 1:return(t=i.sent()).isSuccess?((n=t.data)&&(r=this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),this.isPaymentMethodVisible=!0,[2,!0]):(this.isPaymentMethodVisible=!0,[2,!1])}}))}))},this.setInstallmentCount=function(e){he.cardData&&(he.cardData.installmentCount=e)},this.changeStep=function(e,s){return t(he,void 0,void 0,(function(){return i(this,(function(t){return ae||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(e)),[2]}))}))},this.logout=function(){return t(he,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){he.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return t(he,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===g.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return t(a,void 0,void 0,(function(){var t,n,r,o,a,c,d,u,l;return i(this,(function(i){switch(i.label){case 0:return(t=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})))?(n=[t.productId],[4,_.searchProducts({input:{productIdList:n,priceListId:Q.getPriceListId(),salesChannelId:Q.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=i.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)?(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(t.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(i){if(!t.discountAmount)return i;var s=!1;return t.discountType===S.AMOUNT&&(s=!0),new E(e(e({},i),{prices:i.prices.map((function(i){var n=i.finalPrice,r=i.finalPrice-(s?t.discountAmount:i.finalPrice*t.discountAmount/100);return t.applicablePrice===b.SELL_PRICE&&(n=i.sellPrice,r=i.sellPrice-(s?t.discountAmount:i.sellPrice*t.discountAmount/100)),new O(e(e({},i),{sellPrice:n,discountPrice:r}))}))}))}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new R(e(e({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:t,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===se.SUCCESS?y.POST_CHECKOUT:y.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(e){return t(he,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return e.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,L.updateCartCampaignOffer({input:e})];case 1:return(t=i.sent()).isSuccess?e.accepted?(this.changeStep(this.step===se.SUCCESS?se.PAYMENT:this.step,null===(s=t.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=t.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:i.sent(),this.isCampaignOfferLoaded=!0,i.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(e){return t(he,void 0,void 0,(function(){var t,s,n,r;return i(this,(function(i){switch(i.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,M.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:e})]:[3,2]):[3,2];case 1:return[2,i.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return t(he,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==v.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,j.listProductFile({id:{in:e}})]:[3,2];case 1:(t=i.sent()).isSuccess&&(this.productFiles=t.data||[]),i.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(e){return t(he,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),(t=this.checkout.orderLineItems.find((function(t){return t.variant.id===e.variantId})))?[4,j.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:t.id})]:[3,2];case 1:s=i.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(e.name),r.click(),r.remove()),i.label=2;case 2:return[3,4];case 3:return o=i.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=o,this.checkoutSettings=c,this.router=h,this.returnPolicy=C,this.privacyPolicy=A,this.termsOfService=V,this.imprint=re,this.shippingPolicy=oe,this.t=ce,this.customizationProps=de,this.mpVM=new G,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new N({currentLocale:Q.getCurrentLocale()}),this.init(),s(this)}return re.prototype.isAmexCard=function(e){var t,i=e||this.previousRawValue;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.cardAssociation)===V.AMERICAN_EXPRESS||oe.test(i)},Object.defineProperty(re.prototype,"merchantSettings",{get:function(){return new A(Q.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=q.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"giftCardTotalPrice",{get:function(){var e;return(null===(e=this.checkout.giftCardLines)||void 0===e?void 0:e.reduce((function(e,t){return e+t.amount}),0))||0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice){var e=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){var t=this.openEditOrderTransaction;e=e-((t.chargedAmount||0)+(t.pendingAmount||0))+(t.refundedAmount||0)}else e-=this.giftCardTotalPrice;return this.installmentPrice-e}},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"finalPrice",{get:function(){if(this.step===se.SUCCESS)return this.checkout.totalFinalPrice-this.giftCardTotalPrice;var e=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){var t=this.openEditOrderTransaction;e=e-((t.chargedAmount||0)+(t.pendingAmount||0))+(t.refundedAmount||0)}else e-=this.giftCardTotalPrice;return this.installmentPrice?this.installmentPrice:e},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===ne.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly||this.isShowBillingAddressOnShippingStep?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&(this.checkout.hasCustomer||this.checkout.hasValidCustomerEmail)&&(null===(i=this.error)||void 0===i?void 0:i.type)!==ne.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)&&(!this.isShowBillingAddressOnShippingStep||this.canProceedToShipping)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isManualOrderWithoutShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&!(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hepsiPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hepsiPayPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"iyzicoPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"iyzicoPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isHepsiPay",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"HEPSIPAY"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isIyzico",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"IYZICO"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice||this.isMilesSmilesFullPayment},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"milesSmilesRedeemValue",{get:function(){if(!this.useMilesSmiles)return 0;var e=ce[this.checkout.currencyCode];return e?(this.milesToRedeem||0)*e:0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isMilesSmilesFullPayment",{get:function(){return!!this.useMilesSmiles&&(!(this.finalPrice<=0)&&this.milesSmilesRedeemValue>=this.finalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"store",{get:function(){return q.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible&&!(this.checkout.createdBy===o.UPSELL||this.checkout.createdBy===o.ADMIN)&&!this.isOpenEditOrderWithTransaction},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==c.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isShowBillingAddressOnShippingStep",{get:function(){return this.checkoutSettings.showBillingAddressOnShippingStep},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===d.CREDIT_CARD&&i.type===u.INTERNAL?!!this.isCustomFlowStripe||(!!(this.isKlarna||this.isPayPal||this.isHepsiPay)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===l.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"customerAddresses",{get:function(){var t,i,s,n=this,r=null===(t=Q.getCurrentRouting())||void 0===t?void 0:t.countryCodes;return null===(s=null===(i=this.store.customerStore.customer)||void 0===i?void 0:i.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(t){var i=new C(e({countrySettings:n.countrySettings},t));return i.checkoutSettings=n.checkoutSettings,i.shippingZones=n.shippingZones,i.getValidatedCustomerAddress(),i}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===o.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===o.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isOpenEditOrder",{get:function(){return this.checkout.status===h.OPEN&&!!this.checkout.orderNumber},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"stripeExpressPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return"STRIPE_EU"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isOpenEditOrderWithTransaction",{get:function(){var e,t;return this.checkout.status===h.OPEN&&!!this.checkout.orderNumber&&!!(null===(e=this.openEditOrderTransaction)||void 0===e?void 0:e.chargedAmount)&&(null===(t=this.openEditOrderTransaction)||void 0===t?void 0:t.chargedAmount)>0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isEPayKolayEnabled",{get:function(){var e=Q.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isPoweredByHidden",{get:function(){var e=Q.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hasEmailError",{get:function(){return this.isErrorsVisible&&!this.checkout.hasValidCustomerEmail},enumerable:!1,configurable:!0}),re.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},re}();function ue(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function le(e){return e&&re.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(se||(se={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR",e[e.ARGUMENT_VALIDATION_ERROR=7]="ARGUMENT_VALIDATION_ERROR"}(ne||(ne={}));export{se as CheckoutStep,ne as ErrorType,ce as MILES_SMILES_RATE_PER_POINT,de as default};
1
+ import{__assign as e,__awaiter as t,__generator as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCartCreatedBy as o,IkasCouponCodeRequirement as a,IkasCorporateInvoiceRequirement as c,IkasPaymentMethodType as d,IkasPaymentGatewayType as u,IkasOrderShippingMethod as l,IkasOrderStatus as h,IkasCustomerEmailSubscriptionStatus as p,IkasOrderPaymentStatus as m,IkasTransactionStatus as f,IkasCartCampaignOfferStatus as g,IkasCampaignOfferTargetPageType as y,IkasOrderLineItemStatus as v,IkasAmountType as S,IkasCampaignOfferProductApplicablePriceEnum as b}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 k}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as P}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{IkasCustomerAddress as I}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as C}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as A}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as w}from"../../models/data/order/customer/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{IkasProductPrice as O}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as E}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as R}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/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{LocalizedAddressModel as N}from"@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 T from"./components/credit-card-form/model.js";import M from"../../store/customer/api.js";import j from"../../store/checkout/index.js";import L from"../../store/cart/api.js";import G,{MFS_ELEMENT_ID as D,MFS_SCRIPT_URL as x}from"./modelMasterPass.js";import _ from"../../store/product/index.js";import{TransactionCardAssociationEnum as V,SaveCartInput as F,CheckStocksLineInput as U,getLoyaltyCustomerInfo as B,listSpendingMethodsByCartId as H,LoyaltyProgramPointEarningTypeEnum as Y,listEarningMethods as K,getMilesSmilesDetails as Z,RewardSourceEnum as z,CampaignOfferTargetPageTypeEnum as W}from"@ikas/storefront-api";import{IkasBaseStore as q}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as Q}from"@ikas/storefront-config";import{Analytics as X}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import J from"../../models/data/order/address/ikas-localized-order-address.js";import $ from"../../store/location/index.js";import{isEqual as ee,getCookieValue as te}from"../../utils/helper.js";import ie from"../../analytics/ikasV3.js";var se,ne,re=/^\d+$/,oe=/^3[47]/,ae="undefined"==typeof localStorage,ce={TRY:.25,USD:.0065,EUR:.006},de=function(){function re(o,c,h,C,A,V,re,oe,ce,de){var he=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isPaymentMethodVisible=!0,this.step=se.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.useMilesSmiles=!1,this.milesToRedeem=0,this.milesSmilesDetails=null,this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.hepsipayFrameInitResponse=null,this.iyzicoResponse=null,this.isIyzicoLoading=!1,this.showIyzicoContainer=!1,this.stripeExpressCheckoutSessionResponse=null,this.isStripeExpressCheckoutSessionVisible=!1,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.storeCreditBalance=null,this.loyaltyCustomerInfo=null,this.loyaltySpendingMethods=null,this.loyaltySpendingMethodsAll=null,this.loyaltyEarningMethod=null,this.isLoyaltyPointsVisible=!1,this.showTestModal=!1,this.openEditOrderTransaction=null,this.previousRawValue="",this.previousBin=null,this.init=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,q.getInstance().customerStore.waitUntilInitialized()];case 2:return t.sent(),(e=this.isOpenEditOrder||this.checkout.edited)?[4,this.getOpenEditOrderTransaction()]:[3,4];case 3:t.sent(),t.label=4;case 4:return e&&(this.openEditOrderTransaction||this.checkout.edited)||this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 5:return t.sent(),[2]}}))}))},this.initStep=function(){return t(he,void 0,void 0,(function(){var t,s,n,r,o,c,d;return i(this,(function(i){switch(i.label){case 0:if(Q.getIsEditor())return this.step=se.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),s=t.get("step"),n=t.get("failed"),r=t.get("error"),s){if(this.step=s,this.step===se.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(se.INFO)];if(this.step!==se.PAYMENT||this.canProceedToPayment){if(this.step===se.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(se.INFO)];if(![se.INFO,se.SUCCESS,se.SHIPPING,se.PAYMENT].includes(this.step))return[2,this.changeStep(se.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings||this.isManualOrderWithoutShippingLines?[2,this.changeStep(se.INFO)]:[2,this.changeStep(se.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return i.sent(),this.step!==se.SHIPPING&&this.step!==se.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new P(e(e({},this.checkoutSettings),{couponCodeRequirement:a.DEFAULT}))),this.step!==se.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return i.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:i.sent(),this.checkShippingCountries(),i.label=4;case 4:return[4,this.getStockLocations()];case 5:return i.sent(),[4,this.getAvailableStockLocations()];case 6:i.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),i.label=7;case 7:return this.step!==se.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=se.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==se.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==se.SUCCESS||this.checkout.orderPaymentStatus!==m.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:ne.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:i.sent(),i.label=9;case 9:return this.step!==se.PAYMENT&&this.step!==se.SUCCESS?[3,15]:[4,this.listPaymentGateways()];case 10:return i.sent(),this.checkout.hasCustomer?[4,this.getStoreCreditBalance()]:[3,12];case 11:i.sent(),i.label=12;case 12:return this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,14];case 13:i.sent(),i.label=14;case 14:if(!this.paymentGateways.length&&!this.isFree)return this.error={type:ne.NO_SHIPPING_ERROR},this.isMinTransactionError&&(this.error={type:ne.API_ERROR,data:this.t("checkout-page:minTransactionErrorMessage",{value:200})}),this.isCheckoutLoaded=!0,[2];i.label=15;case 15:return this.step===se.SUCCESS?[3,23]:this.isOpenEditOrder?[3,18]:this.checkout.isComplete?[2,this.changeStep(se.SUCCESS)]:[3,16];case 16:return[4,this.initialStockCheck()];case 17:i.sent(),i.label=18;case 18:return this.checkout.hasCustomer?[4,this.getLoyaltyCustomerInfo()]:[3,22];case 19:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 20:return i.sent(),[4,this.listEarningMethods()];case 21:i.sent(),i.label=22;case 22:return[3,25];case 23:return[4,this.getSuccessTransaction()];case 24:i.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),i.label=25;case 25:return n&&(this.error={type:ne.PAYMENT_ERROR,data:r||null}),this.isCheckoutLoaded=!0,X.checkoutStep(this.checkout,this.step,this.checkoutSettings),[2]}}))}))},this.getOpenEditOrderTransaction=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,M.listOrderTransactionsWithPrices({input:{orderId:this.checkout.id}})];case 1:return(e=t.sent()).isSuccess&&e.data&&e.data.chargedAmount&&(this.openEditOrderTransaction=e.data),[2]}}))}))},this.getSuccessTransaction=function(){return t(he,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return[4,M.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=i.sent(),this.successTransactions=e.isSuccess&&(null===(t=e.data)||void 0===t?void 0:t.length)?e.data:[],this.successTransaction=e.isSuccess&&(null===(s=e.data)||void 0===s?void 0:s.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,l,h,m,f,g,y,v;return i(this,(function(i){switch(i.label){case 0:return e=new F(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=i.sent(),i.label=2;case 2:return this.step!==se.INFO&&this.step!==se.SHIPPING&&this.step!==se.PAYMENT||this.isDigitalOnly||(this.isShowBillingAddressOnShippingStep||this.step===se.PAYMENT||(e.billingAddress=null),e.billingAddress&&(this.isShowBillingAddressOnShippingStep&&this.useDifferentAddress||this.useDifferentAddress&&!this.isShowBillingAddressOnShippingStep&&this.checkoutSettings.showCompanyInfoInShippingAddress)&&(e.billingAddress.company=(null===(n=e.shippingAddress)||void 0===n?void 0:n.company)||null,e.billingAddress.taxNumber=(null===(r=e.shippingAddress)||void 0===r?void 0:r.taxNumber)||null,e.billingAddress.taxOffice=(null===(o=e.shippingAddress)||void 0===o?void 0:o.taxOffice)||null)),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===p.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),null===(null===(c=null===(a=e.shippingAddress)||void 0===a?void 0:a.city)||void 0===c?void 0:c.code)&&""===(null===(u=null===(d=e.shippingAddress)||void 0===d?void 0:d.city)||void 0===u?void 0:u.name)&&(e.shippingAddress.city.name="-"),null===(null===(h=null===(l=e.billingAddress)||void 0===l?void 0:l.city)||void 0===h?void 0:h.code)&&""===(null===(f=null===(m=e.billingAddress)||void 0===m?void 0:m.city)||void 0===f?void 0:f.name)&&(e.billingAddress.city.name="-"),[4,L.saveCart({input:e})];case 3:if((null==(t=i.sent())?void 0:t.graphQLErrors)&&t.graphQLErrors.length)throw s=t.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(g=s.extensions)||void 0===g?void 0:g.code)?{type:ne.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(y=s.extensions)||void 0===y?void 0:y.code)?{type:ne.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(v=s.extensions)||void 0===v?void 0:v.code)?{type:ne.ARGUMENT_VALIDATION_ERROR,data:s.extensions.validationErrors}:{type:ne.API_ERROR,data:t.firstErrorMessage};return[2,t.data]}}))}))},this.inStockDeliveryInputData=function(e){return t(he,void 0,void 0,(function(){var t,s,n=this;return i(this,(function(i){return t=e,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,h,p,m,f;return i(this,(function(i){switch(i.label){case 0:return this.isManualOrder||this.isOpenEditOrderWithTransaction?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===l.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(p=Q.getStockLocationIds())||void 0===p?void 0:p.length)?Q.getStockLocationIds():null,[4,j.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(t=i.sent()).isSuccess)throw s="UPSELL"===this.checkout.createdBy,n=s?this.t("checkout-page:upsellTimeErrorMessage"):t.firstErrorMessage,{type:ne.API_ERROR,data:n};if(null==(r=null===(f=null===(m=t.data)||void 0===m?void 0:m.lines)||void 0===f?void 0:f.filter((function(e){return!e.isAvailable})))?void 0:r.length){for(o=[],a=function(e){var t=c.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&o.push({item:t,stockCount:e.stockCount})},c=this,d=0,u=r;d<u.length;d++)h=u[d],a(h);throw{type:ne.STOCK_ERROR,data:o}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(e){return t(he,void 0,void 0,(function(){return i(this,(function(t){return this.isKlarnaPaymentCompleted=e,[2]}))}))},this.setIsLoyaltyPointsVisible=function(e){he.isLoyaltyPointsVisible=e},this.removeUnavailableItems=function(e){return t(he,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:t=0,s=e,i.label=1;case 1:return t<s.length?(n=s[t],[4,q.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:i.sent(),i.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,j.getAvailableShippingCountries({salesChannelId:Q.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return t(he,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return Q.getPickupStockLocationIds()?[4,j.listStockLocation({id:{in:Q.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=i.sent()).isSuccess||!(null===(t=e.data)||void 0===t?void 0:t.length))return this.error={type:ne.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,i.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(he,void 0,void 0,(function(){var e,t,s,n=this;return i(this,(function(i){switch(i.label){case 0:return Q.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,j.getAvailableStockLocations({lines:e.map((function(e){return new U(e)})),stockLocationIdList:Q.getPickupStockLocationIds(),cartId:this.checkout.id})]):[3,2];case 1:if(!(t=i.sent()).isSuccess)return this.error={type:ne.API_ERROR},[2];s=Q.getCurrentRouting(),this.availableStockLocations=(t.data||[]).filter((function(e){var t,i,r,o;return(null===(i=null===(t=e.address)||void 0===t?void 0:t.country)||void 0===i?void 0:i.id)&&e.address.country.iso2&&(null===(r=n.shippingCountryIds)||void 0===r?void 0:r.includes(e.address.country.id))&&(!(null===(o=null==s?void 0:s.countryCodes)||void 0===o?void 0:o.length)||s.countryCodes.includes(e.address.country.iso2))})),i.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=he.shippingCountryIds)||void 0===e?void 0:e.length)||(he.error={type:ne.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;he.deliveryMethod!==e&&("address"===e&&(he.checkout.stockLocationId=null,(null===(t=he.customerAddresses)||void 0===t?void 0:t.length)?he.onSelectedShippingAddressIdChange(he.customerAddresses[0].id||"-1"):(he.checkout.shippingAddress=new J,he.checkout.shippingAddress.countrySettings=he.countrySettings,he.checkout.shippingAddress.checkoutSettings=he.checkoutSettings,he.checkout.shippingAddress.shippingZones=he.shippingZones)),he.deliveryMethod=e,he.isErrorsVisible=!1)},this.initialStockCheck=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,j.getStoreCreditBalance()];case 1:return e=t.sent(),this.storeCreditBalance=e.data,[2]}}))}))},this.getLoyaltyCustomerInfo=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,B({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyCustomerInfo=e.data),[2]}}))}))},this.listSpendingMethodsByCartId=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,H({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltySpendingMethods=e.data.filter((function(e){return e.isAvailable})),this.loyaltySpendingMethodsAll=e.data),[2]}}))}))},this.listEarningMethods=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,K()];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyEarningMethod=e.data.find((function(e){return"ORDER_CREATE"===e.methodType&&e.pointEarningType===Y.DYNAMIC_ORDER_AMOUNT}))),[2]}}))}))},this.listPaymentGateways=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,o,a,c,d,u,l,h,p,m,f,g,y,v,S,b=this;return i(this,(function(i){switch(i.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,t=Q.getPaymentGateways().map((function(e){return e.id})),[4,j.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:t},locale:Q.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=i.sent()).isSuccess?(null===(g=s.data)||void 0===g?void 0:g.length)||this.isFree?(this.error=void 0,n=null===(y=s.data)||void 0===y?void 0:y.some((function(e){return"IKAS_WALLET"===e.code})),this.isMinTransactionError=n&&this.finalPrice<200&&!this.isDigitalOnly,this.isMinTransactionError?[2]:(o=s.data||[],this.step===se.PAYMENT&&(o=o.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(b.checkout.currencyCode)})),(a=null===(v=this.checkout.shippingAddress)||void 0===v?void 0:v.country)&&a.iso2&&(o=o.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(a.iso2||"")}))),c=null===(S=this.checkout.billingAddress)||void 0===S?void 0:S.country,!a&&c&&c.iso2&&(o=o.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(c.iso2||"")})))),d=[],r(Q.getPaymentGateways(),"order").forEach((function(e){var t=null==o?void 0:o.find((function(t){return t.id===e.id}));t&&d.push(t)})),this.paymentGateways=e?o:d,u=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.checkout.selectedPaymentGateway&&this.paymentGateways.some((function(e){var t;return e.id===(null===(t=b.checkout.selectedPaymentGateway)||void 0===t?void 0:t.id)}))?[3,2]:(this.setPaymentGateway(-1!==u?u:0),[3,4]))):(this.error={type:ne.NO_SHIPPING_ERROR},[2]):(this.error={type:ne.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==se.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:i.sent(),i.label=4;case 4:return this.step===se.PAYMENT&&(l=o.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=l,(h=document.createElement("script")).id=D,h.src=x,h.onload=function(){b.mpVM.checkMasterPass({checkout:b.checkout,store:q.getInstance()})},document.head.appendChild(h)),Q.isMilesSmilesActive()?[4,Z()]:[3,6];case 5:if(!(p=i.sent()).isSuccess&&["UNAUTHORIZED","MILES_SMILES_LOGIN_REQUIRED"].some((function(e){return p.errorCodes.includes(e)})))return m=this.getRoutingPath(),f="".concat(m,"/checkout?id=").concat(this.checkout.id,"&step=payment"),window.location.href="".concat(m,"/account/login?redirect=").concat(f,"&ms_login_required=true"),[2];p.isSuccess&&p.data&&(this.milesSmilesDetails=p.data),i.label=6;case 6:return[2]}}))}))},this.retrieveInstallmentInfo=function(e){return t(he,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return[4,j.retrieveInstallmentInfo(e)];case 1:return t=i.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;he.store.customerStore.customer?(null===(t=he.customerAddresses)||void 0===t||t.forEach((function(e){e.checkoutSettings=he.checkoutSettings,e.shippingZones=he.shippingZones})),he.checkout.customer=new w(e(e({},he.store.customerStore.customer),{notificationsAccepted:he.store.customerStore.customer.subscriptionStatus===p.SUBSCRIBED}))):he.checkout.customer=new w(he.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){he.checkout.shippingAddress&&(he.checkout.shippingAddress.checkoutSettings=he.checkoutSettings,he.checkout.shippingAddress.shippingZones=he.shippingZones,he.checkout.shippingAddress.countrySettings=he.countrySettings,he.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){he.checkout.billingAddress&&(he.checkout.billingAddress.checkoutSettings=he.checkoutSettings,he.checkout.billingAddress.shippingZones=he.shippingZones,he.checkout.billingAddress.countrySettings=he.countrySettings,he.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!he.isDigitalOnly)if(he.isInStoreDelivery)he.setCheckoutShippingAddressSettings();else if(he.checkout.shippingAddress){if(he.store.customerStore.customer){var e=null==(t=he.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=he.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return he.onSelectedShippingAddressIdChange(e.id||"-1"),void he.setCheckoutShippingAddressSettings()}he.checkout.shippingAddress=new J(n(he.checkout.shippingAddress)||{}),he.setCheckoutShippingAddressSettings()}else if(he.store.customerStore.customer){var t=he.customerAddresses;he.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else he.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(he.useDifferentAddress=!!localStorage.getItem("sAddr"),he.checkout.billingAddress){if(he.store.customerStore.customer){var e=null==(t=he.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=he.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return he.onSelectedBillingAddressIdChange(e.id||"-1"),void he.setCheckoutBillingAddressSettings()}he.checkout.billingAddress=new J(n(he.checkout.billingAddress)||{}),he.setCheckoutBillingAddressSettings()}else if(he.store.customerStore.customer){var t=he.customerAddresses;he.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||he.useDifferentAddress||!he.checkout.shippingAddress||he.isInStoreDelivery||(he.checkout.billingAddress=new J(n(he.checkout.shippingAddress)),he.setCheckoutBillingAddressSettings())}else he.onSelectedBillingAddressIdChange("-1"),he.useDifferentAddress||!he.checkout.shippingAddress||he.isInStoreDelivery||(he.checkout.billingAddress=new J(n(he.checkout.shippingAddress)),he.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=e.shippingSettingsId,this.checkout.shippingZoneRateId=e.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=i.sent())&&(this.checkout=new k(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(e){return t(he,void 0,void 0,(function(){return i(this,(function(t){return this.checkout.stockLocationId=e.id,[2]}))}))},this.onCouponCodeApply=function(s){return t(he,void 0,void 0,(function(){var t,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,L.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(c=null===(a=this.cardData)||void 0===a?void 0:a.cardNumber)||void 0===c?void 0:c.split(" ").join(""),this.couponError=null,this.step===se.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(o=this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==se.PAYMENT||this.checkout.totalFinalPrice===o.totalFinalPrice&&!this.checkout.giftCardLines?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,s?X.addCouponCode(n):X.removeCouponCode(n),i.label=7;case 7:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeGiftCardLine=function(s){return t(he,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,L.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===se.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==se.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,i.label=7;case 7:return[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeLoyaltyPointsFromCart=function(s){return t(he,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),[4,L.removeLoyaltyPointsFromCart({cartId:this.checkout.id,loyaltySpendingMethodId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===se.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,9];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==se.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,9];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:return i.sent(),this.isCampaignOfferLoaded=!0,X.removeLoyaltyPoints(n),[4,this.getLoyaltyCustomerInfo()];case 7:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:return i.sent(),[3,11];case 11:return[2]}}))}))},this.getAvailableShippingZones=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,$.getAvailableShippingZones({salesChannelId:Q.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(he.selectedShippingAddressId=e,"-1"===e)he.checkout.shippingAddress=new J,he.checkout.shippingAddress.countrySettings=he.countrySettings;else{var i=null===(t=he.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(he.checkout.shippingAddress=new J(i),he.checkout.shippingAddress.countrySettings=he.countrySettings)}he.checkout.shippingAddress&&(he.checkout.shippingAddress.checkoutSettings=he.checkoutSettings,he.checkout.shippingAddress.shippingZones=he.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(he.selectedBillingAddressId=e,"-1"===e)he.checkout.billingAddress=new J,he.checkout.billingAddress.countrySettings=he.countrySettings;else{var i=null===(t=he.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(he.checkout.billingAddress=new J(i),he.checkout.billingAddress.countrySettings=he.countrySettings)}he.checkout.billingAddress&&(he.checkout.billingAddress.checkoutSettings=he.checkoutSettings,he.checkout.billingAddress.shippingZones=he.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){he.isTermsAndConditionsChecked=e,he.isIyzico&&(he.showIyzicoContainer=e)},this.onCardNumberChange=function(e){if(he.cardData){var t=(e||"").replace(/\D/g,""),i=he.previousRawValue,s=t.slice(0,8),n=he.previousBin;if(!(t.length>16)){var r=i.length<8&&t.length>=8,o=8===s.length&&s!==n;(r||o)&&8===s.length&&(he.getRetrieveInstallmentInfo(t),he.previousBin=s),t.length<8&&i.length>=8&&(he.cardData.installmentCount=1,he.installmentInfo=void 0,he.previousBin=null),he.isAmexCard(t)?he.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(t).join(" "):he.cardData.cardNumber=ue(t,4).join(" "),he.previousRawValue=t}}},this.getRetrieveInstallmentInfo=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:e.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return i.sent(),(null===(t=this.cardData)||void 0===t?void 0:t.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){he.cardData&&(he.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(he.cardData&&(!(e.length>he.cardData.expirationDate.length)||le(e))){if(0===(null===(t=he.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(he.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(he.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(he.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(he.cardData.expirationDate=ue(d,2).join(" / "))}},this.onCvcChange=function(e){if(he.cardData&&(!(e.length>he.cardData.cvv.length)||le(e))){if(he.isAmexCard()){if(e.length>4)return}else if(e.length>3)return;he.cardData.cvv=e}},this.saveAddress=function(s){return t(he,void 0,void 0,(function(){var t,r,o,a,c,d,u,l,h,p,m,f,g=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new I(e(e({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:i.sent(),null===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),i.label=2;case 2:return[3,4];case 3:return l=i.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.getRoutingPath=function(){var e=Q.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):""},this.getGoToCartHref=function(){var e=he.getRoutingPath();return"".concat(e,"/cart")},this.getBackToShoppingHref=function(){var e=he.getRoutingPath();return"".concat(e,"/")},this.getGoToLoginHref=function(){var e=he.getRoutingPath();return"".concat(e)+"/account/login?redirect="+encodeURIComponent(he.checkoutUrl)},this.onHandleBillingAddressOnShippingStep=function(){return t(he,void 0,void 0,(function(){return i(this,(function(t){return this.isShowBillingAddressOnShippingStep&&!this.useDifferentAddress&&("address"===this.deliveryMethod&&this.checkout.shippingAddress?this.checkout.billingAddress=new J(e({},this.checkout.shippingAddress)):this.checkout.billingAddress=new J(e({},this.checkout.billingAddress))),[2]}))}))},this.onProceedToShippingClick=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,10,,11]),this.isStepLoading=!0,"address"!==this.deliveryMethod||this.isShowBillingAddressOnShippingStep?[3,5]:[4,this.saveAddress("shipping")];case 4:t.sent(),t.label=5;case 5:return this.isShowBillingAddressOnShippingStep?[4,this.saveAddress("billing")]:[3,7];case 6:t.sent(),t.label=7;case 7:return[4,this.checkStocks()];case 8:return t.sent(),[4,this.saveCart()];case 9:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(se.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(se.SHIPPING):this.changeStep(se.PAYMENT),[3,11]);case 10:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),this.isStepLoading=!1,[3,11];case 11:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,6,,7]),this.isStepLoading=!0,[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.changeStep(se.PAYMENT),[3,7];case 6:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(se.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ne.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!he.canPerformPayment||(he.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){he.error={type:e,data:t}},this.onCompletePaymentClick=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return this.isFree||!this.isIyzico?[3,4]:[4,this.saveCart()];case 3:return i.sent(),[2];case 4:if(this.isFree||!this.isHepsiPay)return[3,11];i.label=5;case 5:return i.trys.push([5,9,,10]),window.HepsipaySdk&&(null===(o=this.hepsipayFrameInitResponse)||void 0===o?void 0:o.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,7];case 6:return i.sent(),window.HepsipaySdk.initPayment(),[3,8];case 7:console.error("HepsipaySdk is not available"),i.label=8;case 8:return[3,10];case 9:return i.sent(),this.isStepLoading=!1,[2];case 10:return[2];case 11:return i.trys.push([11,17,,18]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 12:return i.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,14];case 13:i.sent(),i.label=14;case 14:return[4,this.saveCart()];case 15:return e=i.sent(),this.checkout.shippingMethod===l.SHIPMENT&&(t=null!==(a=null==e?void 0:e.availableShippingMethods)&&void 0!==a?a:[],s=null!==(c=this.checkout.availableShippingMethods)&&void 0!==c?c:[],!ee(t,s))?(this.changeStep(se.SHIPPING),[2]):!this.isFree&&this.isCustomFlowStripe?((n=document.querySelector("#stripe-form-btn"))&&n.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 16:return i.sent(),[3,18];case 17:return void 0!==typeof(r=i.sent()).type?this.error=r:this.error={type:ne.UNKNOWN},this.isStepLoading=!1,[3,18];case 18:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(he,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:if(this.isFree||!this.isHepsiPay)return[3,9];i.label=3;case 3:return i.trys.push([3,7,,8]),window.HepsipaySdk&&(null===(s=this.hepsipayFrameInitResponse)||void 0===s?void 0:s.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,5];case 4:return i.sent(),window.HepsipaySdk.initPayment(),[3,6];case 5:console.error("HepsipaySdk is not available"),i.label=6;case 6:return[3,8];case 7:return i.sent(),this.isStepLoading=!1,[2];case 8:return[2];case 9:return i.trys.push([9,13,,14]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 10:return i.sent(),[4,this.saveCart()];case 11:return i.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 12:return i.sent(),[3,14];case 13:return(t=i.sent()).type?this.error=t:this.error={type:ne.UNKNOWN},this.isStepLoading=!1,[3,14];case 14:return[2]}}))}))},this.createSaleTransaction=function(){return t(he,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,l,h,p,m,g,y,v,S,b,k,P,I,C,A,w,O;return i(this,(function(i){switch(i.label){case 0:return t=this.mpVM.selectedCard,n=this.useMilesSmiles?{point:this.milesToRedeem||(null===(h=this.milesSmilesDetails)||void 0===h?void 0:h.availableMiles)||0,source:z.MILES_SMILES}:void 0,!this.isFree&&t&&(null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name)?((r=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=r),void 0===(null===(m=this.cardData)||void 0===m?void 0:m.installmentCount)?[2]:[4,j.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name},paymentGatewayId:null===(y=this.mpVM.selectedCard)||void 0===y?void 0:y.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(v=this.cardData)||void 0===v?void 0:v.threeDSecure)},metadata:{_fbp:te("_fbp"),_fbc:te("_fbc"),_ga:te("_ga")},reward:n}})]):[3,2];case 1:return s=i.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway||this.isFree?[4,j.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:t&&e?{phoneNumber:e,savedCardName:null===(S=this.mpVM.selectedCard)||void 0===S?void 0:S.Name}:void 0,paymentGatewayId:this.isFree&&!this.isMilesSmilesFullPayment?"9d41af41-4793-4879-a19c-e9a66c929726":null===(b=this.checkout.selectedPaymentGateway)||void 0===b?void 0:b.id,paymentMethodDetail:this.isFree||t?void 0:(null===(k=this.checkout.selectedPaymentGateway)||void 0===k?void 0:k.paymentMethodType)===d.CREDIT_CARD&&(null===(P=this.checkout.selectedPaymentGateway)||void 0===P?void 0:P.type)===u.INTERNAL&&this.cardData?this.cardData.toInput():void 0,metadata:{_fbp:te("_fbp"),_fbc:te("_fbc"),_ga:te("_ga")},reward:n}})]:[2];case 3:s=i.sent(),i.label=4;case 4:return o=null===(I=null==s?void 0:s.data)||void 0===I?void 0:I.transactionStatus,a=o&&[f.SUCCESS,f.AUTHORIZED].includes(o),c=o===f.PENDING,a?[4,this.getSuccessTransaction()]:[3,7];case 5:return i.sent(),[4,this.onCheckoutTransactionSuccess((null===(C=null==s?void 0:s.data)||void 0===C?void 0:C.orderId)||void 0)];case 6:return i.sent(),[3,8];case 7:if(!c||!(null===(A=null==s?void 0:s.data)||void 0===A?void 0:A.returnSlug))throw l=s.firstErrorMessage,"IKAS_WALLET_501"===(null===(O=null===(w=s.data)||void 0===w?void 0:w.error)||void 0===O?void 0:O.code)&&(l=this.t("checkout-page:errorContactStore")),{data:l,type:ne.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,i.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(e){return t(he,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:i.sent(),i.label=2;case 2:return ie.refreshJourneyId(),this.changeStep(se.SUCCESS,e),[2]}}))}))},this.onBackToInfoClick=function(){he.changeStep(se.INFO)},this.onBackToShippingClick=function(){he.changeStep(se.SHIPPING)},this.setCustomerConsentGranted=function(e){he.checkout.customer&&(he.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(t,i){var s;he.useDifferentAddress=t,he.useDifferentAddress?(localStorage.setItem("sAddr","1"),he.checkout.billingAddress=he.checkout.billingAddress||new J,he.checkout.billingAddress.countrySettings=he.countrySettings):(localStorage.removeItem("sAddr"),he.checkout.billingAddress=new J(e({},he.checkout.shippingAddress)),he.store.customerStore.customer&&(null===(s=he.customerAddresses)||void 0===s?void 0:s.length)&&i&&he.isShowBillingAddressOnShippingStep&&he.onSelectedBillingAddressIdChange(he.checkout.billingAddress.id||"-1"))},this.setShouldSaveAddress=function(e){he.shouldSaveAddress=e},this.setAddressTitle=function(e){he.addressTitle=e},this.reInitPaymentMethod=function(){return t(he,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,10];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return this.isHepsiPay?[4,this.hepsipayFrameInit(this.checkout.selectedPaymentGateway)]:[3,8];case 7:e.sent(),e.label=8;case 8:return this.isIyzico?[4,this.createIyzicoCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,10];case 9:e.sent(),e.label=10;case 10:return[2]}}))}))},this.createStripePaymentIntent=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.stripeResponse=t.data,this.stripeError=null):this.stripeError={type:ne.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.klarnaResponse=t.data,this.klarnaError=null):this.klarnaError={type:ne.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.adyenResponse=t.data),[2]}}))}))},this.getPayPalClientId=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.payPalClientIdResponse=t.data),[2]}}))}))},this.hepsipayFrameInit=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,j.hepsipayFrameInit({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.hepsipayFrameInitResponse=t.data),[2]}}))}))},this.createIyzicoCheckoutForm=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this.isIyzicoLoading=!0,[4,j.createIyzicoCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.iyzicoResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return this.isIyzicoLoading=!1,[7];case 4:return[2]}}))}))},this.createStripeExpressCheckoutSession=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,j.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.stripeExpressCheckoutSessionResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return[7];case 4:return[2]}}))}))},this.updateStripeExpressCheckoutSession=function(e){return t(he,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:if(!this.stripeExpressCheckoutSessionResponse)return[2,null];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,j.updateStripeExpressCheckoutSession({input:{cartId:this.checkout.id,sessionId:"",transactionId:"",address:e.address||null,shippingSettingsId:e.shippingSettingsId||null,shippingZoneRateId:e.shippingZoneRateId||null}})];case 2:return(t=i.sent()).isSuccess&&t.data?[2,t.data]:[2,null];case 3:return i.sent(),[2,null];case 4:return[2]}}))}))},this.setShowIyzicoContainer=function(e){he.showIyzicoContainer=e},this.setPaymentGateway=function(e){return t(he,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return this.paymentGateways.length?(t=this.paymentGateways[e],s=!0,this.step!==se.PAYMENT?[3,7]:this.checkout.selectedPaymentGateway?[3,3]:"CUSTOM"!==t.code?[3,2]:[4,this.updatePaymentGateway(t)]):[2];case 1:s=i.sent(),i.label=2;case 2:return[3,7];case 3:return"CUSTOM"!==this.checkout.selectedPaymentGateway.code?[3,5]:[4,this.updatePaymentGateway(t)];case 4:return s=i.sent(),[3,7];case 5:return"CUSTOM"!==t.code?[3,7]:[4,this.updatePaymentGateway(t)];case 6:s=i.sent(),i.label=7;case 7:return s?"STRIPE"!==t.code&&"STRIPE_EU"!==t.code||this.stripeResponse?[3,9]:[4,this.createStripePaymentIntent(t)]:[2];case 8:i.sent(),i.label=9;case 9:return"KLARNA"!==t.code||this.klarnaResponse?[3,11]:[4,this.createKlarnaClientToken(t)];case 10:i.sent(),i.label=11;case 11:return"ADYEN_PLATFORM"!==t.code||this.adyenResponse?[3,13]:[4,this.createAdyenBalancePlatformPaymentSession(t)];case 12:i.sent(),i.label=13;case 13:return"PAYPAL"!==t.code||this.payPalClientIdResponse?[3,15]:[4,this.getPayPalClientId(t)];case 14:i.sent(),i.label=15;case 15:return"HEPSIPAY"!==t.code||this.hepsipayFrameInitResponse?[3,17]:[4,this.hepsipayFrameInit(t)];case 16:i.sent(),i.label=17;case 17:return"IYZICO"!==t.code||this.iyzicoResponse?[3,19]:[4,this.createIyzicoCheckoutForm(t)];case 18:i.sent(),i.label=19;case 19:return this.checkout.selectedPaymentGateway=t,this.step!==se.SUCCESS&&(t.paymentMethodType===d.CREDIT_CARD&&t.type===u.INTERNAL&&(this.cardData=new T,this.previousRawValue="",this.previousBin=null,t.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0),[2]}}))}))},this.updatePaymentGateway=function(s){return t(he,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.isPaymentMethodVisible=!1,[4,L.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id,targetPageType:W.CHECKOUT})];case 1:return(t=i.sent()).isSuccess?((n=t.data)&&(r=this.checkout,this.checkout=new k(e(e({},n),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),this.isPaymentMethodVisible=!0,[2,!0]):(this.isPaymentMethodVisible=!0,[2,!1])}}))}))},this.setInstallmentCount=function(e){he.cardData&&(he.cardData.installmentCount=e)},this.changeStep=function(e,s){return t(he,void 0,void 0,(function(){return i(this,(function(t){return ae||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(e)),[2]}))}))},this.logout=function(){return t(he,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){he.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return t(he,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===g.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return t(a,void 0,void 0,(function(){var t,n,r,o,a,c,d,u,l;return i(this,(function(i){switch(i.label){case 0:return(t=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})))?(n=[t.productId],[4,_.searchProducts({input:{productIdList:n,priceListId:Q.getPriceListId(),salesChannelId:Q.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=i.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)?(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(t.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(i){if(!t.discountAmount)return i;var s=!1;return t.discountType===S.AMOUNT&&(s=!0),new E(e(e({},i),{prices:i.prices.map((function(i){var n=i.finalPrice,r=i.finalPrice-(s?t.discountAmount:i.finalPrice*t.discountAmount/100);return t.applicablePrice===b.SELL_PRICE&&(n=i.sellPrice,r=i.sellPrice-(s?t.discountAmount:i.sellPrice*t.discountAmount/100)),new O(e(e({},i),{sellPrice:n,discountPrice:r}))}))}))}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new R(e(e({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:t,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return t(he,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===se.SUCCESS?y.POST_CHECKOUT:y.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(e){return t(he,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return e.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,L.updateCartCampaignOffer({input:e})];case 1:return(t=i.sent()).isSuccess?e.accepted?(this.changeStep(this.step===se.SUCCESS?se.PAYMENT:this.step,null===(s=t.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=t.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:i.sent(),this.isCampaignOfferLoaded=!0,i.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(e){return t(he,void 0,void 0,(function(){var t,s,n,r;return i(this,(function(i){switch(i.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,M.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:e})]:[3,2]):[3,2];case 1:return[2,i.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return t(he,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==v.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,j.listProductFile({id:{in:e}})]:[3,2];case 1:(t=i.sent()).isSuccess&&(this.productFiles=t.data||[]),i.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(e){return t(he,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),(t=this.checkout.orderLineItems.find((function(t){return t.variant.id===e.variantId})))?[4,j.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:t.id})]:[3,2];case 1:s=i.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(e.name),r.click(),r.remove()),i.label=2;case 2:return[3,4];case 3:return o=i.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=o,this.checkoutSettings=c,this.router=h,this.returnPolicy=C,this.privacyPolicy=A,this.termsOfService=V,this.imprint=re,this.shippingPolicy=oe,this.t=ce,this.customizationProps=de,this.mpVM=new G,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new N({currentLocale:Q.getCurrentLocale()}),this.init(),s(this)}return re.prototype.isAmexCard=function(e){var t,i=e||this.previousRawValue;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.cardAssociation)===V.AMERICAN_EXPRESS||oe.test(i)},Object.defineProperty(re.prototype,"merchantSettings",{get:function(){return new A(Q.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=q.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"giftCardTotalPrice",{get:function(){var e;return(null===(e=this.checkout.giftCardLines)||void 0===e?void 0:e.reduce((function(e,t){return e+t.amount}),0))||0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice){var e=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){var t=this.openEditOrderTransaction;e=e-((t.chargedAmount||0)+(t.pendingAmount||0))+(t.refundedAmount||0)}else e-=this.giftCardTotalPrice;return this.installmentPrice-e}},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"finalPrice",{get:function(){if(this.step===se.SUCCESS)return this.checkout.totalFinalPrice-this.giftCardTotalPrice;var e=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){var t=this.openEditOrderTransaction;e=e-((t.chargedAmount||0)+(t.pendingAmount||0))+(t.refundedAmount||0)}else e-=this.giftCardTotalPrice;return this.installmentPrice?this.installmentPrice:e},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===ne.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly||this.isShowBillingAddressOnShippingStep?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&(this.checkout.hasCustomer||this.checkout.hasValidCustomerEmail)&&(null===(i=this.error)||void 0===i?void 0:i.type)!==ne.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)&&(!this.isShowBillingAddressOnShippingStep||this.canProceedToShipping)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isManualOrderWithoutShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&!(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hepsiPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hepsiPayPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"iyzicoPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"iyzicoPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isHepsiPay",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"HEPSIPAY"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isIyzico",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"IYZICO"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice||this.isMilesSmilesFullPayment},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"milesSmilesRedeemValue",{get:function(){if(!this.useMilesSmiles)return 0;var e=ce[this.checkout.currencyCode];return e?(this.milesToRedeem||0)*e:0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isMilesSmilesFullPayment",{get:function(){return!!this.useMilesSmiles&&(!(this.finalPrice<=0)&&this.milesSmilesRedeemValue>=this.finalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"store",{get:function(){return q.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible&&!(this.checkout.createdBy===o.UPSELL||this.checkout.createdBy===o.ADMIN)&&!this.isOpenEditOrderWithTransaction},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==c.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isShowBillingAddressOnShippingStep",{get:function(){return this.checkoutSettings.showBillingAddressOnShippingStep},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===d.CREDIT_CARD&&i.type===u.INTERNAL?!!this.isCustomFlowStripe||(!!(this.isKlarna||this.isPayPal||this.isHepsiPay)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===l.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"customerAddresses",{get:function(){var t,i,s,n=this,r=null===(t=Q.getCurrentRouting())||void 0===t?void 0:t.countryCodes;return null===(s=null===(i=this.store.customerStore.customer)||void 0===i?void 0:i.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(t){var i=new C(e({countrySettings:n.countrySettings},t));return i.checkoutSettings=n.checkoutSettings,i.shippingZones=n.shippingZones,i.getValidatedCustomerAddress(),i}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===o.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===o.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isOpenEditOrder",{get:function(){return this.checkout.status===h.OPEN&&!!this.checkout.orderNumber},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"stripeExpressPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return"STRIPE_EU"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isOpenEditOrderWithTransaction",{get:function(){var e,t;return this.checkout.status===h.OPEN&&!!this.checkout.orderNumber&&!!(null===(e=this.openEditOrderTransaction)||void 0===e?void 0:e.chargedAmount)&&(null===(t=this.openEditOrderTransaction)||void 0===t?void 0:t.chargedAmount)>0},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isEPayKolayEnabled",{get:function(){var e=Q.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"isPoweredByHidden",{get:function(){var e=Q.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hasEmailError",{get:function(){return this.isErrorsVisible&&!this.checkout.hasValidCustomerEmail},enumerable:!1,configurable:!0}),re.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},re}();function ue(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function le(e){return e&&re.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(se||(se={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR",e[e.ARGUMENT_VALIDATION_ERROR=7]="ARGUMENT_VALIDATION_ERROR"}(ne||(ne={}));export{se as CheckoutStep,ne as ErrorType,ce as MILES_SMILES_RATE_PER_POINT,de as default};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as l}from"mobx-react-lite";import{MILES_SMILES_RATE_PER_POINT as i}from"../../../../model.js";import"@ikas/storefront-config";import{formatCurrency as t}from"../../../../../../utils/currency.js";import{useTranslation as s}from"../../../../../../utils/i18n.js";import a from"./style.module.scss.js";import m from"./thy-logo.js";import{RewardSourceEnum as r}from"@ikas/storefront-api";var n=function(e){return e?e.toLocaleString("en-US"):""},c=l((function(l){var c,u=l.vm,d=s().t,p=(null===(c=u.milesSmilesDetails)||void 0===c?void 0:c.availableMiles)||0,S=u.checkout.currencyCode,v=i[S],M=u.finalPrice||0,f=v&&M>0?Math.ceil(M/v):1/0,E=v?(u.milesToRedeem||0)*v:0,g=u.milesToRedeem>p;return e.createElement("div",{className:a.MilesSmiles},e.createElement("div",{className:a.MilesSmilesHeader},e.createElement("div",{className:a.MilesSmilesHeaderLeft},e.createElement(m,{className:a.MilesSmilesLogo}),e.createElement("div",{className:a.MilesSmilesTitleWrapper},e.createElement("div",{className:a.MilesSmilesTitle},e.createElement("span",{className:a.MilesSmilesTitleBold},"Miles & Smiles")," ",e.createElement("span",null,d("checkout-page:milesSmilesUseMyMiles"))),e.createElement("div",{className:a.MilesSmilesSubtitle},d("checkout-page:milesSmilesAvailableTotal",{miles:n(p)})))),e.createElement(o,{value:u.useMilesSmiles,onChange:function(e){if(u.useMilesSmiles=e,e){var l=u.paymentGateways.filter((function(e){var l;return null===(l=e.enabledRewardSources)||void 0===l?void 0:l.includes(r.MILES_SMILES)}));if(l.length){var i=l[0].id,t=u.paymentGateways.findIndex((function(e){return e.id===i}));if(u.selectedPaymentGatewayIndex===t)return;u.setPaymentGateway(t),u.mpVM.selectedCard=void 0}}e&&!u.milesToRedeem&&(u.milesToRedeem=Math.min(p,f))}})),u.useMilesSmiles&&e.createElement(e.Fragment,null,e.createElement("div",{className:a.MilesSmilesInputRow},e.createElement("div",{className:[a.MilesSmilesInputWrapper,g?a.MilesSmilesInputError:""].join(" ")},e.createElement("input",{className:a.MilesSmilesInput,type:"text",inputMode:"numeric",value:n(u.milesToRedeem),onChange:function(e){var l=e.target.value.replace(/[^\d]/g,"");u.milesToRedeem=l?parseInt(l,10):0},onBlur:function(){var e=Math.min(p,f);u.milesToRedeem>e&&(u.milesToRedeem=e)}}),e.createElement("span",{className:a.MilesSmilesInputUnit},d("checkout-page:milesSmilesUnit"))),e.createElement("span",{className:a.MilesSmilesApprox},"≈"),e.createElement("div",{className:a.MilesSmilesPriceBox},t(E,u.checkout.currencyCode,u.checkout.currencySymbol))),g&&e.createElement("div",{className:a.MilesSmilesErrorText},d("checkout-page:milesSmilesExceedError"))))})),o=function(l){var i=l.value,t=l.onChange;return e.createElement("div",{onClick:function(){t(!i)},className:[a.ToggleSwitch,i?a.ToggleSwitchActive:""].join(" ")},e.createElement("div",{className:[a.ToggleSwitchThumb,i?a.ToggleSwitchThumbActive:""].join(" ")}))};export{c as MilesSmiles};
1
+ import{__awaiter as e,__generator as l}from'./../../../../../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as t}from"mobx-react-lite";import{MILES_SMILES_RATE_PER_POINT as s}from"../../../../model.js";import"@ikas/storefront-config";import{formatCurrency as a}from"../../../../../../utils/currency.js";import{useTranslation as m}from"../../../../../../utils/i18n.js";import r from"./style.module.scss.js";import n from"./thy-logo.js";import{RewardSourceEnum as c}from"@ikas/storefront-api";var o=function(e){return e?e.toLocaleString("en-US"):""},u=t((function(t){var u,p=t.vm,v=m().t,S=(null===(u=p.milesSmilesDetails)||void 0===u?void 0:u.availableMiles)||0,M=p.checkout.currencyCode,f=s[M],E=f?(p.milesToRedeem||0)*f:0,g=p.milesToRedeem>S,h=function(){var e=p.finalPrice||0;return f&&e>0?Math.ceil(e/f):1/0};return i.createElement("div",{className:r.MilesSmiles},i.createElement("div",{className:r.MilesSmilesHeader},i.createElement("div",{className:r.MilesSmilesHeaderLeft},i.createElement(n,{className:r.MilesSmilesLogo}),i.createElement("div",{className:r.MilesSmilesTitleWrapper},i.createElement("div",{className:r.MilesSmilesTitle},i.createElement("span",{className:r.MilesSmilesTitleBold},"Miles & Smiles")," ",i.createElement("span",null,v("checkout-page:milesSmilesUseMyMiles"))),i.createElement("div",{className:r.MilesSmilesSubtitle},v("checkout-page:milesSmilesAvailableTotal",{miles:o(S)})))),i.createElement(d,{value:p.useMilesSmiles,onChange:function(i){return e(void 0,void 0,void 0,(function(){var e,t,s,a;return l(this,(function(l){switch(l.label){case 0:return p.useMilesSmiles=i,i?(e=p.paymentGateways.filter((function(e){var l;return null===(l=e.enabledRewardSources)||void 0===l?void 0:l.includes(c.MILES_SMILES)})),e.length?(t=e[0].id,s=p.paymentGateways.findIndex((function(e){return e.id===t})),p.selectedPaymentGatewayIndex===s?[3,2]:[4,p.setPaymentGateway(s)]):[3,2]):[3,2];case 1:l.sent(),p.mpVM.selectedCard=void 0,l.label=2;case 2:return i&&!p.milesToRedeem&&(a=h(),p.milesToRedeem=Math.min(S,a)),i||(p.milesToRedeem=0),[2]}}))}))}})),p.useMilesSmiles&&i.createElement(i.Fragment,null,i.createElement("div",{className:r.MilesSmilesInputRow},i.createElement("div",{className:[r.MilesSmilesInputWrapper,g?r.MilesSmilesInputError:""].join(" ")},i.createElement("input",{className:r.MilesSmilesInput,type:"text",inputMode:"numeric",value:o(p.milesToRedeem),onChange:function(e){var l=e.target.value.replace(/[^\d]/g,"");p.milesToRedeem=l?parseInt(l,10):0},onBlur:function(){var e=h(),l=Math.min(S,e);p.milesToRedeem>l&&(p.milesToRedeem=l)}}),i.createElement("span",{className:r.MilesSmilesInputUnit},v("checkout-page:milesSmilesUnit"))),i.createElement("span",{className:r.MilesSmilesApprox},"≈"),i.createElement("div",{className:r.MilesSmilesPriceBox},a(E,p.checkout.currencyCode,p.checkout.currencySymbol))),g&&i.createElement("div",{className:r.MilesSmilesErrorText},v("checkout-page:milesSmilesExceedError"))))})),d=function(e){var l=e.value,t=e.onChange;return i.createElement("div",{onClick:function(){t(!l)},className:[r.ToggleSwitch,l?r.ToggleSwitchActive:""].join(" ")},i.createElement("div",{className:[r.ToggleSwitchThumb,l?r.ToggleSwitchThumbActive:""].join(" ")}))};export{u as MilesSmiles};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "6.1.0-beta.321",
3
+ "version": "6.1.0-beta.323",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -23,11 +23,11 @@
23
23
  "swiper": "11.0.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@ikas/storefront-api": "^6.1.0-beta.321",
27
- "@ikas/storefront-config": "^6.1.0-beta.321",
28
- "@ikas/storefront-model-functions": "^6.1.0-beta.321",
29
- "@ikas/storefront-models": "^6.1.0-beta.321",
30
- "@ikas/storefront-providers": "^6.1.0-beta.321",
26
+ "@ikas/storefront-api": "^6.1.0-beta.323",
27
+ "@ikas/storefront-config": "^6.1.0-beta.323",
28
+ "@ikas/storefront-model-functions": "^6.1.0-beta.323",
29
+ "@ikas/storefront-models": "^6.1.0-beta.323",
30
+ "@ikas/storefront-providers": "^6.1.0-beta.323",
31
31
  "@ikas/localized-address": "1.0.0-beta.6",
32
32
  "@adyen/adyen-web": "^5.57.0",
33
33
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -62,11 +62,11 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@ikas/localized-address": "1.0.0-beta.6",
65
- "@ikas/storefront-api": "^6.1.0-beta.321",
66
- "@ikas/storefront-config": "^6.1.0-beta.321",
67
- "@ikas/storefront-model-functions": "^6.1.0-beta.321",
68
- "@ikas/storefront-models": "^6.1.0-beta.321",
69
- "@ikas/storefront-providers": "^6.1.0-beta.321",
65
+ "@ikas/storefront-api": "^6.1.0-beta.323",
66
+ "@ikas/storefront-config": "^6.1.0-beta.323",
67
+ "@ikas/storefront-model-functions": "^6.1.0-beta.323",
68
+ "@ikas/storefront-models": "^6.1.0-beta.323",
69
+ "@ikas/storefront-providers": "^6.1.0-beta.323",
70
70
  "mobx": "^6.1.3",
71
71
  "mobx-react-lite": "^3.1.5",
72
72
  "next": "12.2.0",