@ikas/storefront 4.5.0-beta.23 → 4.5.0-beta.26

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.
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import CheckoutViewModel from "../../model";
3
+ declare type Props = {
4
+ vm: CheckoutViewModel;
5
+ };
6
+ export declare const PayPal: React.FC<Props>;
7
+ export {};
@@ -0,0 +1 @@
1
+ import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as n}from"mobx-react-lite";import{PayPalScriptProvider as o,PayPalButtons as i}from"@paypal/react-paypal-js";import a from"../../../../store/checkout/index.js";var c=n((function(n){var c=n.vm;if(!c.payPalClientIdResponse)return null;var l={"client-id":c.payPalClientIdResponse.clientId,currency:c.checkout.currencyCode};return r.createElement("div",null,r.createElement(o,{options:l},r.createElement(i,{style:{layout:"horizontal"},onClick:function(r,n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,c.onCompletePaymentClick()];case 1:return e.sent(),c.isErrorsVisible?[2,n.reject()]:[2,n.resolve()]}}))}))},onCancel:function(e,t){c.isStepLoading=!1},createOrder:function(r,n){return e(void 0,void 0,void 0,(function(){var e,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,a.createPayPalOrder({input:{cartId:c.checkout.id,paymentGatewayId:(null===(r=c.checkout.selectedPaymentGateway)||void 0===r?void 0:r.id)||""}})];case 1:return(e=t.sent()).data&&(c.paypalOrderResponse=e.data),[2,e&&(null===(n=e.data)||void 0===n?void 0:n.sessionToken)||""]}}))}))},onApprove:function(r,n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){return c.paypalOrderResponse&&(window.location.href="".concat(c.paypalOrderResponse.returnUrl)),[2]}))}))}})))}));export{c as PayPal};
@@ -9,7 +9,7 @@ import { TFunction } from "../../utils/i18n";
9
9
  import { IkasCheckoutCustomizationProps } from ".";
10
10
  import MasterPassModel from "./modelMasterPass";
11
11
  import { APIResponse } from "@ikas/fe-api-client";
12
- import { CreateStripePaymentIntentResponse, RetrieveInstallmentInfoResponse, UpdateCartCampaignOfferInput, CreateKlarnaTokenResponse, CreateAdyenSessionResponse } from "@ikas/storefront-api";
12
+ import { CreateStripePaymentIntentResponse, RetrieveInstallmentInfoResponse, UpdateCartCampaignOfferInput, CreateKlarnaTokenResponse, CreateAdyenSessionResponse, GetPaypalClientIdResponse, CreatePaypalOrderResponse } from "@ikas/storefront-api";
13
13
  import { IkasBaseStore } from "../../store";
14
14
  import { RetrieveInstallmentInfoQueryParams, SaveCartInput } from "@ikas/storefront-api";
15
15
  import { LocalizedAddressModel } from "@ikas/localized-address";
@@ -47,6 +47,8 @@ export default class CheckoutViewModel {
47
47
  isKlarnaPaymentCompleted: boolean;
48
48
  adyenResponse: CreateAdyenSessionResponse | null;
49
49
  adyenDropinElement: any;
50
+ payPalClientIdResponse: GetPaypalClientIdResponse | null;
51
+ paypalOrderResponse: CreatePaypalOrderResponse | null;
50
52
  checkoutCampaignOffer: CampaignOfferType | undefined;
51
53
  postCheckoutCampaignOffer: CampaignOfferType | undefined;
52
54
  countrySettings: LocalizedAddressModel;
@@ -89,9 +91,12 @@ export default class CheckoutViewModel {
89
91
  get klarnaPaymentGatewayIndex(): number;
90
92
  get adyenPaymentGateway(): IkasPaymentGateway | undefined;
91
93
  get adyenPaymentGatewayIndex(): number;
94
+ get payPalPaymentGateway(): IkasPaymentGateway | undefined;
95
+ get payPalPaymentGatewayIndex(): number;
92
96
  get isCustomFlowStripe(): false | import("../../models").IkasPaymentGatewaySettings | null | undefined;
93
97
  get isKlarna(): boolean | null | undefined;
94
98
  get isAdyen(): boolean | null | undefined;
99
+ get isPayPal(): boolean | null | undefined;
95
100
  get store(): IkasBaseStore;
96
101
  get canPerformPayment(): boolean | undefined;
97
102
  get isDigitalOnly(): boolean;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign 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{IkasPaymentMethodType as o,IkasPaymentGatewayType as a,IkasOrderShippingMethod as c,IkasCartCreatedBy as d,IkasTransactionStatus as u,IkasCartCampaignOfferStatus as l,IkasCampaignOfferTargetPageType as h}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 p}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{IkasCustomerAddress as m}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as f}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as g}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as v}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/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/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as y}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as S}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 k from"./components/credit-card-form/model.js";import b from"../../store/customer/api.js";import C from"../../store/checkout/index.js";import I from"../../store/cart/api.js";import A,{MFS_ELEMENT_ID as P,MFS_SCRIPT_URL as w}from"./modelMasterPass.js";import N from"../../store/product/index.js";import{IkasBaseStore as E}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as O}from"@ikas/storefront-config";import{Analytics as j}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as R,CheckStocksLineInput as D}from"@ikas/storefront-api";import x from"../../models/data/order/address/ikas-localized-order-address.js";var T,G,M=/^\d+$/,L="undefined"==typeof localStorage,_=function(){function M(c,d,f,g,M,_,K,F,B,H){var Y=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=T.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],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.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,E.getInstance().customerStore.waitUntilInitialized()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(O.getIsEditor())return this.step=T.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===T.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(T.INFO)];if(this.step!==T.PAYMENT||this.canProceedToPayment){if(this.step===T.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(T.INFO)];if(![T.INFO,T.SUCCESS,T.SHIPPING,T.PAYMENT].includes(this.step))return[2,this.changeStep(T.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(T.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:G.PAYMENT_ERROR,data:n||null}),this.step!==T.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==T.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=T.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==T.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==T.PAYMENT&&this.step!==T.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:G.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:G.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===T.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(T.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,j.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,b.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[t.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new R(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==T.INFO&&this.step!==T.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,I.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:G.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:G.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(Y,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.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(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;return e(this,(function(e){switch(e.label){case 0:return this.isManualOrder?[2]:(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,C.checkStocks({lines:t.map((function(t){return new D(t)})),stockLocationIdList:(null===(u=O.getStockLocationIds())||void 0===u?void 0:u.length)?O.getStockLocationIds():null})]);case 1:if(!(i=e.sent()).isSuccess)throw{type:G.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:G.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,E.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,C.getAvailableShippingCountries({salesChannelId:O.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return O.getPickupStockLocationIds()?[4,C.listStockLocation({id:{in:O.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:G.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return O.getPickupStockLocationIds()?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,C.getAvailableStockLocations({lines:t.map((function(t){return new D(t)})),stockLocationIdList:O.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:G.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=Y.shippingCountryIds)||void 0===t?void 0:t.length)||(Y.error={type:G.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(Y.checkout.stockLocationId=null),Y.deliveryMethod=t,Y.isErrorsVisible=!1},this.initialStockCheck=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,l,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=O.getPaymentGateways().map((function(t){return t.id})),[4,C.listPaymentGateway({id:t?void 0:{in:i},locale:O.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=e.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===T.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(o.iso2||"")})))),a=[],r(O.getPaymentGateways(),"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===T.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=P,d.src=w,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:E.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:G.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,C.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;Y.store.customerStore.customer?(null===(t=Y.customerAddresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=Y.checkoutSettings})),Y.checkout.customer=new v(Y.store.customerStore.customer)):Y.checkout.customer=new v(Y.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings,Y.checkout.shippingAddress.countrySettings=Y.countrySettings)},this.setCheckoutBillingAddressSettings=function(){Y.checkout.billingAddress&&(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings,Y.checkout.billingAddress.countrySettings=Y.countrySettings)},this.createShippingAddress=function(){if(!Y.isDigitalOnly)if(Y.isInStoreDelivery)Y.setCheckoutShippingAddressSettings();else if(Y.checkout.shippingAddress){if(Y.store.customerStore.customer){var t=null==(e=Y.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=Y.checkout.shippingAddress)||void 0===e?void 0:e.id)}));if(t)return Y.onSelectedShippingAddressIdChange(t.id||"-1"),void Y.setCheckoutShippingAddressSettings()}Y.checkout.shippingAddress=new x(n(Y.checkout.shippingAddress)||{}),Y.setCheckoutShippingAddressSettings()}else if(Y.store.customerStore.customer){var e=Y.customerAddresses;Y.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else Y.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(Y.useDifferentAddress=!!localStorage.getItem("sAddr"),Y.checkout.billingAddress){if(Y.store.customerStore.customer){var t=null==(e=Y.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=Y.checkout.billingAddress)||void 0===e?void 0:e.id)}));if(t)return Y.onSelectedBillingAddressIdChange(t.id||"-1"),void Y.setCheckoutBillingAddressSettings()}Y.checkout.billingAddress=new x(n(Y.checkout.billingAddress)||{}),Y.setCheckoutBillingAddressSettings()}else if(Y.store.customerStore.customer){var e=Y.customerAddresses;Y.onSelectedBillingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1"),(null==e?void 0:e.length)||Y.useDifferentAddress||!Y.checkout.shippingAddress||Y.isInStoreDelivery||(Y.checkout.billingAddress=new x(n(Y.checkout.shippingAddress)),Y.setCheckoutBillingAddressSettings())}else Y.onSelectedBillingAddressIdChange("-1"),Y.useDifferentAddress||!Y.checkout.shippingAddress||Y.isInStoreDelivery||(Y.checkout.billingAddress=new x(n(Y.checkout.shippingAddress)),Y.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new p(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(Y,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,I.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data?(s=t.data,n=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===T.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),e.label=4;case 4:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(Y.selectedShippingAddressId=t,"-1"===t)Y.checkout.shippingAddress=new x,Y.checkout.shippingAddress.countrySettings=Y.countrySettings;else{var i=null===(e=Y.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(Y.checkout.shippingAddress=new x(i),Y.checkout.shippingAddress.countrySettings=Y.countrySettings)}Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(Y.selectedBillingAddressId=t,"-1"===t)Y.checkout.billingAddress=new x,Y.checkout.billingAddress.countrySettings=Y.countrySettings;else{var i=null===(e=Y.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(Y.checkout.billingAddress=new x(i),Y.checkout.billingAddress.countrySettings=Y.countrySettings)}Y.checkout.billingAddress&&(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){Y.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(Y.cardData&&(!(t.length>Y.cardData.cardNumber.length)||U(t))){var e=(Y.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!Y.installmentInfo?Y.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:Y.checkout.selectedPaymentGateway.id,price:Y.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(Y.cardData.installmentCount=1,Y.installmentInfo=void 0),Y.cardData.cardNumber=V(i,4).join(" "))}},this.onCardHolderNameChange=function(t){Y.cardData&&(Y.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(Y.cardData&&(!(t.length>Y.cardData.expirationDate.length)||U(t))){if(0===(null===(e=Y.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.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(Y.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(Y.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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=t.split(" / ").join("");d.length>4||(Y.cardData.expirationDate=V(d,2).join(" / "))}},this.onCvcChange=function(t){Y.cardData&&(t.length>Y.cardData.cvv.length&&!U(t)||t.length>4||(Y.cardData.cvv=t))},this.saveAddress=function(s){return t(Y,void 0,void 0,(function(){var t,r,o,a,c,d,u,l,h,p,f,g,v=this;return e(this,(function(e){switch(e.label){case 0:return e.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(t){return t.id})),o=new m(i(i({},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:e.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(t){return t.checkoutSettings=v.checkoutSettings})),c=null===(g=this.customerAddresses)||void 0===g?void 0:g.map((function(t){return t.id})),d=null==c?void 0:c.filter((function(t){return!(null==r?void 0:r.includes(t))})),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"),e.label=2;case 2:return[3,4];case 3:return l=e.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){Y.router.push("/cart")},this.onBackToShoppingClick=function(){Y.router.push("/")},this.onGoToLoginClick=function(){Y.router.push("/account/login")},this.onProceedToShippingClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(T.SHIPPING):this.changeStep(T.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.changeStep(T.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(T.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:e.sent(),e.label=5;case 5:return[4,this.saveCart()];case 6:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):[4,this.createSaleTransaction()];case 7:return e.sent(),[3,9];case 8:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:G.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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 e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCart()];case 4:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(i=e.sent()).type?this.error=i:this.error={type:G.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,c,d,l,h,p,m,f,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,C.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.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===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,C.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===o.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===a.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,c=r&&[u.SUCCESS,u.AUTHORIZED].includes(r),d=r===u.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:G.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(T.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){Y.changeStep(T.INFO)},this.onBackToShippingClick=function(){Y.changeStep(T.SHIPPING)},this.setCustomerConsentGranted=function(t){Y.checkout.customer&&(Y.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){Y.useDifferentAddress=t,Y.useDifferentAddress?(localStorage.setItem("sAddr","1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new x,Y.checkout.billingAddress.countrySettings=Y.countrySettings):(localStorage.removeItem("sAddr"),Y.checkout.billingAddress=Y.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){Y.shouldSaveAddress=t},this.setAddressTitle=function(t){Y.addressTitle=t},this.setPaymentGateway=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))||this.stripeResponse?[3,2]:[4,C.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,C.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return"ADYEN"!==t.code||this.adyenResponse?[3,6]:[4,C.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 5:(s=e.sent()).isSuccess&&s.data&&(this.adyenResponse=s.data),e.label=6;case 6:return this.checkout.selectedPaymentGateway=t,this.step!==T.SUCCESS&&(t.paymentMethodType===o.CREDIT_CARD&&t.type===a.INTERNAL&&(this.cardData=new k,t.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){Y.cardData&&(Y.cardData.installmentCount=t)},this.changeStep=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return L||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){Y.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(Y,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===l.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,N.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;t.hasStock&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return t.hasStock}))),a.length))return[2,{value:{product:new y(o),variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(h.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(h.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,I.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data&&(this.checkout=new p(t.data,this.countrySettings),i.accepted&&this.step===T.SUCCESS?this.changeStep(T.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return t(Y,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(e){switch(e.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,b.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,e.sent()];case 2:return[2]}}))}))},this.checkout=c,this.checkoutSettings=d,this.router=f,this.returnPolicy=g,this.privacyPolicy=M,this.termsOfService=_,this.imprint=K,this.shippingPolicy=F,this.t=B,this.customizationProps=H,this.mpVM=new A,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new S({currentLocale:O.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(M.prototype,"merchantSettings",{get:function(){return new g(O.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=E.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"finalPrice",{get:function(){return this.step===T.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===G.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToShipping",{get:function(){var t,e,i;return(this.isDigitalOnly?null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValidAddress:null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==G.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"adyenPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isAdyen",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"ADYEN"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"store",{get:function(){return E.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValidAddress),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===o.CREDIT_CARD&&i.type===a.INTERNAL?!!this.isCustomFlowStripe||(!!this.isKlarna||(null===(e=this.cardData)||void 0===e?void 0:e.isValid)):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===c.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddresses",{get:function(){var t,e,s=this;return null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){var e=new f(i({countrySettings:s.countrySettings},t));return e.checkoutSettings=s.checkoutSettings,e}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),M.prototype.setAdyenDropinElement=function(t){this.adyenDropinElement=t},M}();function V(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function U(t){return t&&M.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(T||(T={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(G||(G={}));export{T as CheckoutStep,G as ErrorType,_ as default};
1
+ import{__awaiter as t,__generator as e,__assign 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{IkasPaymentMethodType as o,IkasPaymentGatewayType as a,IkasOrderShippingMethod as c,IkasCartCreatedBy as d,IkasTransactionStatus as u,IkasCartCampaignOfferStatus as l,IkasCampaignOfferTargetPageType as h}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 p}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{IkasCustomerAddress as m}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as f}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as g}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as v}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/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/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as y}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as S}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 k from"./components/credit-card-form/model.js";import b from"../../store/customer/api.js";import C from"../../store/checkout/index.js";import I from"../../store/cart/api.js";import P,{MFS_ELEMENT_ID as A,MFS_SCRIPT_URL as w}from"./modelMasterPass.js";import N from"../../store/product/index.js";import{IkasBaseStore as O}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as j}from"@ikas/storefront-config";import{Analytics as E}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as R,CheckStocksLineInput as x}from"@ikas/storefront-api";import D from"../../models/data/order/address/ikas-localized-order-address.js";var T,G,L=/^\d+$/,M="undefined"==typeof localStorage,_=function(){function L(c,d,f,g,L,_,K,F,Y,B){var H=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=T.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],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.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return t(H,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,O.getInstance().customerStore.waitUntilInitialized()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(H,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(j.getIsEditor())return this.step=T.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===T.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(T.INFO)];if(this.step!==T.PAYMENT||this.canProceedToPayment){if(this.step===T.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(T.INFO)];if(![T.INFO,T.SUCCESS,T.SHIPPING,T.PAYMENT].includes(this.step))return[2,this.changeStep(T.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(T.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:G.PAYMENT_ERROR,data:n||null}),this.step!==T.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==T.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=T.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==T.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==T.PAYMENT&&this.step!==T.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:G.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:G.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===T.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(T.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,E.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(H,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,b.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[t.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return t(H,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new R(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==T.INFO&&this.step!==T.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,I.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:G.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:G.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(H,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.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(H,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;return e(this,(function(e){switch(e.label){case 0:return this.isManualOrder?[2]:(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,C.checkStocks({lines:t.map((function(t){return new x(t)})),stockLocationIdList:(null===(u=j.getStockLocationIds())||void 0===u?void 0:u.length)?j.getStockLocationIds():null})]);case 1:if(!(i=e.sent()).isSuccess)throw{type:G.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:G.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(H,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(H,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,O.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(H,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,C.getAvailableShippingCountries({salesChannelId:j.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(H,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return j.getPickupStockLocationIds()?[4,C.listStockLocation({id:{in:j.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:G.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(H,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return j.getPickupStockLocationIds()?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,C.getAvailableStockLocations({lines:t.map((function(t){return new x(t)})),stockLocationIdList:j.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:G.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=H.shippingCountryIds)||void 0===t?void 0:t.length)||(H.error={type:G.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(H.checkout.stockLocationId=null),H.deliveryMethod=t,H.isErrorsVisible=!1},this.initialStockCheck=function(){return t(H,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(H,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,l,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=j.getPaymentGateways().map((function(t){return t.id})),[4,C.listPaymentGateway({id:t?void 0:{in:i},locale:j.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=e.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===T.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(o.iso2||"")})))),a=[],r(j.getPaymentGateways(),"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===T.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=A,d.src=w,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:O.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:G.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(H,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,C.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;H.store.customerStore.customer?(null===(t=H.customerAddresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=H.checkoutSettings})),H.checkout.customer=new v(H.store.customerStore.customer)):H.checkout.customer=new v(H.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.countrySettings=H.countrySettings)},this.setCheckoutBillingAddressSettings=function(){H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.countrySettings=H.countrySettings)},this.createShippingAddress=function(){if(!H.isDigitalOnly)if(H.isInStoreDelivery)H.setCheckoutShippingAddressSettings();else if(H.checkout.shippingAddress){if(H.store.customerStore.customer){var t=null==(e=H.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=H.checkout.shippingAddress)||void 0===e?void 0:e.id)}));if(t)return H.onSelectedShippingAddressIdChange(t.id||"-1"),void H.setCheckoutShippingAddressSettings()}H.checkout.shippingAddress=new D(n(H.checkout.shippingAddress)||{}),H.setCheckoutShippingAddressSettings()}else if(H.store.customerStore.customer){var e=H.customerAddresses;H.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else H.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(H.useDifferentAddress=!!localStorage.getItem("sAddr"),H.checkout.billingAddress){if(H.store.customerStore.customer){var t=null==(e=H.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=H.checkout.billingAddress)||void 0===e?void 0:e.id)}));if(t)return H.onSelectedBillingAddressIdChange(t.id||"-1"),void H.setCheckoutBillingAddressSettings()}H.checkout.billingAddress=new D(n(H.checkout.billingAddress)||{}),H.setCheckoutBillingAddressSettings()}else if(H.store.customerStore.customer){var e=H.customerAddresses;H.onSelectedBillingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1"),(null==e?void 0:e.length)||H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())}else H.onSelectedBillingAddressIdChange("-1"),H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return t(H,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new p(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(H,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(H,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,I.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data?(s=t.data,n=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===T.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),e.label=4;case 4:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(H.selectedShippingAddressId=t,"-1"===t)H.checkout.shippingAddress=new D,H.checkout.shippingAddress.countrySettings=H.countrySettings;else{var i=null===(e=H.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(H.checkout.shippingAddress=new D(i),H.checkout.shippingAddress.countrySettings=H.countrySettings)}H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(H.selectedBillingAddressId=t,"-1"===t)H.checkout.billingAddress=new D,H.checkout.billingAddress.countrySettings=H.countrySettings;else{var i=null===(e=H.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(H.checkout.billingAddress=new D(i),H.checkout.billingAddress.countrySettings=H.countrySettings)}H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){H.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(H.cardData&&(!(t.length>H.cardData.cardNumber.length)||U(t))){var e=(H.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!H.installmentInfo?H.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:H.checkout.selectedPaymentGateway.id,price:H.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(H.cardData.installmentCount=1,H.installmentInfo=void 0),H.cardData.cardNumber=V(i,4).join(" "))}},this.onCardHolderNameChange=function(t){H.cardData&&(H.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(H.cardData&&(!(t.length>H.cardData.expirationDate.length)||U(t))){if(0===(null===(e=H.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.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(H.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(H.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(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=t.split(" / ").join("");d.length>4||(H.cardData.expirationDate=V(d,2).join(" / "))}},this.onCvcChange=function(t){H.cardData&&(t.length>H.cardData.cvv.length&&!U(t)||t.length>4||(H.cardData.cvv=t))},this.saveAddress=function(s){return t(H,void 0,void 0,(function(){var t,r,o,a,c,d,u,l,h,p,f,g,v=this;return e(this,(function(e){switch(e.label){case 0:return e.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(t){return t.id})),o=new m(i(i({},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:e.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(t){return t.checkoutSettings=v.checkoutSettings})),c=null===(g=this.customerAddresses)||void 0===g?void 0:g.map((function(t){return t.id})),d=null==c?void 0:c.filter((function(t){return!(null==r?void 0:r.includes(t))})),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"),e.label=2;case 2:return[3,4];case 3:return l=e.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){H.router.push("/cart")},this.onBackToShoppingClick=function(){H.router.push("/")},this.onGoToLoginClick=function(){H.router.push("/account/login")},this.onProceedToShippingClick=function(){return t(H,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(T.SHIPPING):this.changeStep(T.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(H,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.changeStep(T.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(H,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(T.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:G.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(H,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:e.sent(),e.label=5;case 5:return[4,this.saveCart()];case 6:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return e.sent(),[3,9];case 8:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:G.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(H,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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 e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCart()];case 4:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(i=e.sent()).type?this.error=i:this.error={type:G.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(H,void 0,void 0,(function(){var t,i,s,n,r,c,d,l,h,p,m,f,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,C.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.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===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,C.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===o.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===a.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,c=r&&[u.SUCCESS,u.AUTHORIZED].includes(r),d=r===u.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:G.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(H,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(T.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){H.changeStep(T.INFO)},this.onBackToShippingClick=function(){H.changeStep(T.SHIPPING)},this.setCustomerConsentGranted=function(t){H.checkout.customer&&(H.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){H.useDifferentAddress=t,H.useDifferentAddress?(localStorage.setItem("sAddr","1"),H.checkout.billingAddress=H.checkout.billingAddress||new D,H.checkout.billingAddress.countrySettings=H.countrySettings):(localStorage.removeItem("sAddr"),H.checkout.billingAddress=H.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){H.shouldSaveAddress=t},this.setAddressTitle=function(t){H.addressTitle=t},this.setPaymentGateway=function(i){return t(H,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))||this.stripeResponse?[3,2]:[4,C.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,C.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return"ADYEN"!==t.code||this.adyenResponse?[3,6]:[4,C.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 5:(s=e.sent()).isSuccess&&s.data&&(this.adyenResponse=s.data),e.label=6;case 6:return"PAY_PAL"!==t.code||this.payPalClientIdResponse?[3,8]:[4,C.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 7:(s=e.sent()).isSuccess&&s.data&&(this.payPalClientIdResponse=s.data),e.label=8;case 8:return this.checkout.selectedPaymentGateway=t,this.step!==T.SUCCESS&&(t.paymentMethodType===o.CREDIT_CARD&&t.type===a.INTERNAL&&(this.cardData=new k,t.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){H.cardData&&(H.cardData.installmentCount=t)},this.changeStep=function(i){return t(H,void 0,void 0,(function(){return e(this,(function(t){return M||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(H,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){H.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(H,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===l.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,N.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;t.hasStock&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return t.hasStock}))),a.length))return[2,{value:{product:new y(o),variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(H,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(h.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(h.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(H,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,I.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data&&(this.checkout=new p(t.data,this.countrySettings),i.accepted&&this.step===T.SUCCESS?this.changeStep(T.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return t(H,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(e){switch(e.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,b.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,e.sent()];case 2:return[2]}}))}))},this.checkout=c,this.checkoutSettings=d,this.router=f,this.returnPolicy=g,this.privacyPolicy=L,this.termsOfService=_,this.imprint=K,this.shippingPolicy=F,this.t=Y,this.customizationProps=B,this.mpVM=new P,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new S({currentLocale:j.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(L.prototype,"merchantSettings",{get:function(){return new g(j.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=O.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"finalPrice",{get:function(){return this.step===T.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===G.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"canProceedToShipping",{get:function(){var t,e,i;return(this.isDigitalOnly?null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValidAddress:null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==G.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"adyenPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"payPalPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"PAY_PAL"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"PAY_PAL"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isAdyen",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"ADYEN"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isPayPal",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"PAY_PAL"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"store",{get:function(){return O.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValidAddress),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===o.CREDIT_CARD&&i.type===a.INTERNAL?!!this.isCustomFlowStripe||(!!this.isKlarna||(null===(e=this.cardData)||void 0===e?void 0:e.isValid)):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===c.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"customerAddresses",{get:function(){var t,e,s=this;return null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){var e=new f(i({countrySettings:s.countrySettings},t));return e.checkoutSettings=s.checkoutSettings,e}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),L.prototype.setAdyenDropinElement=function(t){this.adyenDropinElement=t},L}();function V(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function U(t){return t&&L.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(T||(T={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(G||(G={}));export{T as CheckoutStep,G as ErrorType,_ as default};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import{IkasStorefrontConfig as o}from"@ikas/storefront-config";import{Checkbox as i}from"../../components/checkbox/index.js";import n from"../../components/error/index.js";import{PaymentGateways as r}from"./payment-gateways/index.js";import{BillingAddress as a}from"./billing-address/index.js";import{Button as c}from"../../components/button/index.js";import s from"../../components/master-pass/link-card-to-client/index.js";import{createTranslationInputData as l,useTranslation as m}from"../../../../utils/i18n.js";import p from"../../components/svg/lock.js";import d from"./style.module.scss.js";var k=t((function(t){var k=t.vm,u=m().t,y=e.useCallback((function(e){e.stopPropagation(),k.policyModalTitle=u("checkout-page:privacyPolicy"),k.policyModalText=k.privacyPolicy}),[k,k.privacyPolicy]),g=e.useCallback((function(e){e.stopPropagation(),k.policyModalTitle=u("checkout-page:termsOfService"),k.policyModalText=k.termsOfService}),[k,k.termsOfService]),v=o.getTranslations()["checkout-page"],f=l(v.ackPoliciesSentence).map((function(t){return t.isVariable?e.createElement("span",{className:[d.TermsLabelSpan,k.isErrorsVisible&&!k.isTermsAndConditionsChecked?d.Error:""].join(" "),onClick:"{{ ackPrivacyPolicy }}"===t.value?y:g},"{{ ackPrivacyPolicy }}"===t.value?u("checkout-page:ackPrivacyPolicy"):u("checkout-page:ackTermsOfService")):t.value}));return e.createElement("div",{className:[d.StepPayment].join(" ")},e.createElement(n,{vm:k}),k.mpVM.isLinkCardToClientVisible&&e.createElement(s,{vm:k}),e.createElement(r,{vm:k}),e.createElement(a,{vm:k}),k.checkoutSettings.showTermsAndConditionsCheckbox&&e.createElement("div",{style:{marginTop:k.useDifferentAddress?"12px":"0px"}},e.createElement(i,{value:k.isTermsAndConditionsChecked,hasError:k.isErrorsVisible&&!k.isTermsAndConditionsChecked,label:e.createElement(e.Fragment,null,f),onChange:k.onTermsAndConditionsCheckedChange})),e.createElement(c,{style:{width:"100%",marginTop:"24px"},text:u("checkout-page:actions.completeOrder"),isLoading:k.isStepLoading,onClick:k.isDigitalOnly?k.onCompleteDigitalOnlyPaymentClick:k.onCompletePaymentClick}),!!u("checkout-page:securePaymentTooltip")&&e.createElement("div",{className:d.SecurePaymentContainer},e.createElement("span",{className:d.Lock},e.createElement(p,null)),e.createElement("span",null,u("checkout-page:securePaymentTooltip"))))}));export{k as CheckoutStepPayment};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import{IkasStorefrontConfig as o}from"@ikas/storefront-config";import{Checkbox as i}from"../../components/checkbox/index.js";import n from"../../components/error/index.js";import{PaymentGateways as a}from"./payment-gateways/index.js";import{BillingAddress as r}from"./billing-address/index.js";import{Button as c}from"../../components/button/index.js";import s from"../../components/master-pass/link-card-to-client/index.js";import{createTranslationInputData as l,useTranslation as m}from"../../../../utils/i18n.js";import p from"../../components/svg/lock.js";import d from"./style.module.scss.js";import{PayPal as y}from"../../components/paypal/index.js";var k=t((function(t){var k=t.vm,u=m().t,v=e.useCallback((function(e){e.stopPropagation(),k.policyModalTitle=u("checkout-page:privacyPolicy"),k.policyModalText=k.privacyPolicy}),[k,k.privacyPolicy]),f=e.useCallback((function(e){e.stopPropagation(),k.policyModalTitle=u("checkout-page:termsOfService"),k.policyModalText=k.termsOfService}),[k,k.termsOfService]),g=o.getTranslations()["checkout-page"],C=l(g.ackPoliciesSentence).map((function(t){return t.isVariable?e.createElement("span",{className:[d.TermsLabelSpan,k.isErrorsVisible&&!k.isTermsAndConditionsChecked?d.Error:""].join(" "),onClick:"{{ ackPrivacyPolicy }}"===t.value?v:f},"{{ ackPrivacyPolicy }}"===t.value?u("checkout-page:ackPrivacyPolicy"):u("checkout-page:ackTermsOfService")):t.value}));return e.createElement("div",{className:[d.StepPayment].join(" ")},e.createElement(n,{vm:k}),k.mpVM.isLinkCardToClientVisible&&e.createElement(s,{vm:k}),e.createElement(a,{vm:k}),e.createElement(r,{vm:k}),k.checkoutSettings.showTermsAndConditionsCheckbox&&e.createElement("div",{style:{marginTop:k.useDifferentAddress?"12px":"0px"}},e.createElement(i,{value:k.isTermsAndConditionsChecked,hasError:k.isErrorsVisible&&!k.isTermsAndConditionsChecked,label:e.createElement(e.Fragment,null,C),onChange:k.onTermsAndConditionsCheckedChange})),k.isPayPal?e.createElement("div",{className:d.PayPalContainer},e.createElement(y,{vm:k})):e.createElement(c,{style:{width:"100%",marginTop:"24px"},text:u("checkout-page:actions.completeOrder"),isLoading:k.isStepLoading,onClick:k.isDigitalOnly?k.onCompleteDigitalOnlyPaymentClick:k.onCompletePaymentClick}),!!u("checkout-page:securePaymentTooltip")&&e.createElement("div",{className:d.SecurePaymentContainer},e.createElement("span",{className:d.Lock},e.createElement(p,null)),e.createElement("span",null,u("checkout-page:securePaymentTooltip"))))}));export{k as CheckoutStepPayment};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasPaymentMethodType as a,IkasPaymentGatewayTransactionFeeType as n,IkasPaymentGatewayAdditionalPriceType as o,IkasPaymentGatewayType as r}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/index.js";import"../../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/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/state/index.js";import"../../../../../models/data/theme-json/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{CreditCardForm as m}from"../../../components/credit-card-form/index.js";import{Installments as d}from"./installments/index.js";import i from"../../../components/select-box/index.js";import l from"./style.module.scss.js";import"@ikas/storefront-config";import{formatCurrency as s}from"../../../../../utils/currency.js";import{useTranslation as c}from"../../../../../utils/i18n.js";import p from"../../../components/svg/external.js";import y from"next/dynamic";import u from"../../../components/credit-card-form/model.js";import x from"../../../components/master-pass/credit-card-form/index.js";import{Klarna as v}from"../../../components/klarna/index.js";import{Adyen as f}from"../../../components/adyen/index.js";import{Toggle as j}from"../../../components/toggle/index.js";import E from"../../../components/select-box/style.module.scss.js";import g from"../../../components/master-pass/payment-gateway/svg/master-card.js";import P from"../../../components/master-pass/payment-gateway/svg/troy.js";import w from"../../../components/master-pass/payment-gateway/svg/visa.js";var C=y((function(){return import("../../../components/stripe/index.js").then((function(e){return e.default}))})),h=t((function(t){var y=t.vm,h=c().t,k=function(t){return e.createElement("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",flexWrap:"wrap"}},t.children)},G=function(t){return e.createElement("div",{className:l.AdditionalPrice},t.children)},I=function(e){return 0===e.amount?"":"".concat(e.amountType===n.AMOUNT?s(e.amount,y.checkout.currencyCode,y.checkout.currencySymbol):" %"+e.amount).concat(e.type===o.DECREMENT?" "+h("checkout-page:paymentMethodDiscount"):" "+h("checkout-page:paymentMethodAdditionalPrice"))},N=function(e){var t;return"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))};return e.createElement(e.Fragment,null,!!y.mpVM.cards.length&&y.mpVM.cards.map((function(t,n){var o,m=y.paymentGateways.find((function(e){return e.id===t.paymentGatewayId})),s=e.createElement("button",{className:l.MasterPassSelectBoxDeleteButton,onClick:function(e){e.stopPropagation(),y.mpVM.deleteCard({store:y.store,checkout:y.checkout,card:t})}},h("checkout-page:masterPass.paymentGatewaySelectBox.delete")),c=function(e){return t.Value1.startsWith(e)},p=c("4"),x=c("5")||c("6"),v=c("9"),f=e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement("span",{className:l.MasterPassSelectBoxLabelLogo},p&&e.createElement(w,null),x&&e.createElement(g,null),v&&e.createElement(P,null)),t.Name," ",t.Value1),j=(null==m?void 0:m.id)&&m.paymentMethodType===a.CREDIT_CARD&&m.type===r.INTERNAL?y.installmentInfo&&e.createElement(d,{vm:y}):void 0;return e.createElement(i,{key:n,isSelected:(null===(o=y.mpVM.selectedCard)||void 0===o?void 0:o.UniqueId)===t.UniqueId,label:f,rightContent:s,bottomContent:j,onClick:function(){var e;(null===(e=y.mpVM.selectedCard)||void 0===e?void 0:e.UniqueId)!==t.UniqueId&&(y.checkout.selectedPaymentGateway=null,y.cardData=new u,y.installmentInfo=void 0,y.mpVM.selectedCard=t,t.Value1&&t.paymentGatewayId&&y.checkout.totalFinalPrice&&y.retrieveInstallmentInfo({input:{binNumber:t.Value1.slice(0,6),paymentGatewayId:t.paymentGatewayId,price:y.checkout.totalFinalPrice}}))}})})),y.paymentGateways.filter((function(e){return"in-store"!==y.deliveryMethod&&!y.isDigitalOnly||e.paymentMethodType!==a.CASH_ON_DELIVERY&&e.paymentMethodType!==a.CREDIT_CARD_ON_DELIVERY})).map((function(t,n){var o;if(function(e){return"KLARNA"===e.code}(t)||function(e){return"ADYEN"===e.code}(t))return null;var s=t.paymentMethodType===a.CREDIT_CARD&&t.type===r.INTERNAL?e.createElement(e.Fragment,null,N(t)?e.createElement(C,{vm:y,pg:t}):e.createElement("div",null,e.createElement(m,{vm:y}),y.isPaymentGatewayHasMasterPass&&e.createElement(x,{vm:y}),y.installmentInfo&&e.createElement(d,{vm:y}))):t.description?e.createElement(e.Fragment,null,t.type===r.EXTERNAL&&e.createElement("div",{style:{height:"52px",display:"flex",justifyContent:"center",margin:"24px 0"}},e.createElement(p,null)),e.createElement("div",{dangerouslySetInnerHTML:{__html:t.description}})):void 0;return e.createElement(i,{key:t.id,label:t.paymentMethodType===a.CREDIT_CARD&&t.type===r.INTERNAL?N(t)?" ":h("checkout-page:creditCard"):t.name,isSelected:y.selectedPaymentGatewayIndex===n,rightContent:(null===(o=t.additionalPrices)||void 0===o?void 0:o.length)?e.createElement(G,null,I(t.additionalPrices[0])):e.createElement(k,null,!!t.logoUrl&&e.createElement("div",{className:l.PaymentLogoContainer},e.createElement("img",{src:t.logoUrl}))),bottomContent:s,onClick:function(){y.selectedPaymentGatewayIndex!==n&&(y.setPaymentGateway(n),y.mpVM.selectedCard=void 0)}})})),y.klarnaPaymentGateway&&function(){var t,a=y.selectedPaymentGatewayIndex===y.klarnaPaymentGatewayIndex;return y.klarnaPaymentGateway?e.createElement("div",{className:E.SelectBoxContainer},e.createElement("div",{className:"".concat(E.SelectBox," ").concat(a?E.Selected:""),onClick:function(){y.setPaymentGateway(y.klarnaPaymentGatewayIndex),y.mpVM.selectedCard=void 0}},e.createElement("div",{className:E.TopContent},e.createElement(j,{value:a,label:y.klarnaPaymentGateway.name,removePadding:!0}),e.createElement("div",{className:E.RightContent},(null===(t=y.klarnaPaymentGateway.additionalPrices)||void 0===t?void 0:t.length)?e.createElement(G,null,I(y.klarnaPaymentGateway.additionalPrices[0])):e.createElement(k,null,!!y.klarnaPaymentGateway.logoUrl&&e.createElement("div",{className:l.PaymentLogoContainer},e.createElement("img",{src:y.klarnaPaymentGateway.logoUrl}))))),e.createElement("div",{className:"".concat(a?E.BottomContent:""," ").concat(a?"":l.Hidden)},e.createElement(v,{vm:y})))):null}(),y.adyenPaymentGateway&&function(){var t,a=y.selectedPaymentGatewayIndex===y.adyenPaymentGatewayIndex;return y.adyenPaymentGateway?e.createElement("div",{className:E.SelectBoxContainer},e.createElement("div",{className:"".concat(E.SelectBox," ").concat(a?E.Selected:""),onClick:function(){y.setPaymentGateway(y.adyenPaymentGatewayIndex),y.mpVM.selectedCard=void 0}},e.createElement("div",{className:E.TopContent},e.createElement(j,{value:a,label:y.adyenPaymentGateway.name,removePadding:!0}),e.createElement("div",{className:E.RightContent},(null===(t=y.adyenPaymentGateway.additionalPrices)||void 0===t?void 0:t.length)?e.createElement(G,null,I(y.adyenPaymentGateway.additionalPrices[0])):e.createElement(k,null,!!y.adyenPaymentGateway.logoUrl&&e.createElement("div",{className:l.PaymentLogoContainer},e.createElement("img",{src:y.adyenPaymentGateway.logoUrl}))))),e.createElement("div",{className:"".concat(a?E.BottomContent:""," ").concat(a?"":l.Hidden)},e.createElement(f,{vm:y})))):null}())}));export{h as PaymentGateways};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasPaymentMethodType as a,IkasPaymentGatewayTransactionFeeType as n,IkasPaymentGatewayAdditionalPriceType as o,IkasPaymentGatewayType as m}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/index.js";import"../../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/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/state/index.js";import"../../../../../models/data/theme-json/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{CreditCardForm as r}from"../../../components/credit-card-form/index.js";import{Installments as d}from"./installments/index.js";import l from"../../../components/select-box/index.js";import i from"./style.module.scss.js";import"@ikas/storefront-config";import{formatCurrency as s}from"../../../../../utils/currency.js";import{useTranslation as c}from"../../../../../utils/i18n.js";import p from"../../../components/svg/external.js";import y from"next/dynamic";import u from"../../../components/credit-card-form/model.js";import v from"../../../components/master-pass/credit-card-form/index.js";import{Klarna as x}from"../../../components/klarna/index.js";import{Adyen as f}from"../../../components/adyen/index.js";import{Toggle as E}from"../../../components/toggle/index.js";import P from"../../../components/select-box/style.module.scss.js";import g from"../../../components/master-pass/payment-gateway/svg/master-card.js";import j from"../../../components/master-pass/payment-gateway/svg/troy.js";import w from"../../../components/master-pass/payment-gateway/svg/visa.js";var C=y((function(){return import("../../../components/stripe/index.js").then((function(e){return e.default}))})),G=t((function(t){var y=t.vm,G=c().t,h=function(t){return e.createElement("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",flexWrap:"wrap"}},t.children)},k=function(t){return e.createElement("div",{className:i.AdditionalPrice},t.children)},I=function(e){return 0===e.amount?"":"".concat(e.amountType===n.AMOUNT?s(e.amount,y.checkout.currencyCode,y.checkout.currencySymbol):" %"+e.amount).concat(e.type===o.DECREMENT?" "+G("checkout-page:paymentMethodDiscount"):" "+G("checkout-page:paymentMethodAdditionalPrice"))},N=function(e){var t;return"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))};return e.createElement(e.Fragment,null,!!y.mpVM.cards.length&&y.mpVM.cards.map((function(t,n){var o,r=y.paymentGateways.find((function(e){return e.id===t.paymentGatewayId})),s=e.createElement("button",{className:i.MasterPassSelectBoxDeleteButton,onClick:function(e){e.stopPropagation(),y.mpVM.deleteCard({store:y.store,checkout:y.checkout,card:t})}},G("checkout-page:masterPass.paymentGatewaySelectBox.delete")),c=function(e){return t.Value1.startsWith(e)},p=c("4"),v=c("5")||c("6"),x=c("9"),f=e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement("span",{className:i.MasterPassSelectBoxLabelLogo},p&&e.createElement(w,null),v&&e.createElement(g,null),x&&e.createElement(j,null)),t.Name," ",t.Value1),E=(null==r?void 0:r.id)&&r.paymentMethodType===a.CREDIT_CARD&&r.type===m.INTERNAL?y.installmentInfo&&e.createElement(d,{vm:y}):void 0;return e.createElement(l,{key:n,isSelected:(null===(o=y.mpVM.selectedCard)||void 0===o?void 0:o.UniqueId)===t.UniqueId,label:f,rightContent:s,bottomContent:E,onClick:function(){var e;(null===(e=y.mpVM.selectedCard)||void 0===e?void 0:e.UniqueId)!==t.UniqueId&&(y.checkout.selectedPaymentGateway=null,y.cardData=new u,y.installmentInfo=void 0,y.mpVM.selectedCard=t,t.Value1&&t.paymentGatewayId&&y.checkout.totalFinalPrice&&y.retrieveInstallmentInfo({input:{binNumber:t.Value1.slice(0,6),paymentGatewayId:t.paymentGatewayId,price:y.checkout.totalFinalPrice}}))}})})),y.paymentGateways.filter((function(e){return"in-store"!==y.deliveryMethod&&!y.isDigitalOnly||e.paymentMethodType!==a.CASH_ON_DELIVERY&&e.paymentMethodType!==a.CREDIT_CARD_ON_DELIVERY})).map((function(t,n){var o;if(function(e){return"KLARNA"===e.code}(t)||function(e){return"ADYEN"===e.code}(t)||function(e){return"PAY_PAL"===e.code}(t))return null;var s=t.paymentMethodType===a.CREDIT_CARD&&t.type===m.INTERNAL?e.createElement(e.Fragment,null,N(t)?e.createElement(C,{vm:y,pg:t}):e.createElement("div",null,e.createElement(r,{vm:y}),y.isPaymentGatewayHasMasterPass&&e.createElement(v,{vm:y}),y.installmentInfo&&e.createElement(d,{vm:y}))):t.description?e.createElement(e.Fragment,null,t.type===m.EXTERNAL&&e.createElement("div",{style:{height:"52px",display:"flex",justifyContent:"center",margin:"24px 0"}},e.createElement(p,null)),e.createElement("div",{dangerouslySetInnerHTML:{__html:t.description}})):void 0;return e.createElement(l,{key:t.id,label:t.paymentMethodType===a.CREDIT_CARD&&t.type===m.INTERNAL?N(t)?" ":G("checkout-page:creditCard"):t.name,isSelected:y.selectedPaymentGatewayIndex===n,rightContent:(null===(o=t.additionalPrices)||void 0===o?void 0:o.length)?e.createElement(k,null,I(t.additionalPrices[0])):e.createElement(h,null,!!t.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:t.logoUrl}))),bottomContent:s,onClick:function(){y.selectedPaymentGatewayIndex!==n&&(y.setPaymentGateway(n),y.mpVM.selectedCard=void 0)}})})),y.klarnaPaymentGateway&&function(){var t,a=y.selectedPaymentGatewayIndex===y.klarnaPaymentGatewayIndex;return y.klarnaPaymentGateway?e.createElement("div",{className:P.SelectBoxContainer},e.createElement("div",{className:"".concat(P.SelectBox," ").concat(a?P.Selected:""),onClick:function(){y.setPaymentGateway(y.klarnaPaymentGatewayIndex),y.mpVM.selectedCard=void 0}},e.createElement("div",{className:P.TopContent},e.createElement(E,{value:a,label:y.klarnaPaymentGateway.name,removePadding:!0}),e.createElement("div",{className:P.RightContent},(null===(t=y.klarnaPaymentGateway.additionalPrices)||void 0===t?void 0:t.length)?e.createElement(k,null,I(y.klarnaPaymentGateway.additionalPrices[0])):e.createElement(h,null,!!y.klarnaPaymentGateway.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:y.klarnaPaymentGateway.logoUrl}))))),e.createElement("div",{className:"".concat(a?P.BottomContent:""," ").concat(a?"":i.Hidden)},e.createElement(x,{vm:y})))):null}(),y.adyenPaymentGateway&&function(){var t,a=y.selectedPaymentGatewayIndex===y.adyenPaymentGatewayIndex;return y.adyenPaymentGateway?e.createElement("div",{className:P.SelectBoxContainer},e.createElement("div",{className:"".concat(P.SelectBox," ").concat(a?P.Selected:""),onClick:function(){y.setPaymentGateway(y.adyenPaymentGatewayIndex),y.mpVM.selectedCard=void 0}},e.createElement("div",{className:P.TopContent},e.createElement(E,{value:a,label:y.adyenPaymentGateway.name,removePadding:!0}),e.createElement("div",{className:P.RightContent},(null===(t=y.adyenPaymentGateway.additionalPrices)||void 0===t?void 0:t.length)?e.createElement(k,null,I(y.adyenPaymentGateway.additionalPrices[0])):e.createElement(h,null,!!y.adyenPaymentGateway.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:y.adyenPaymentGateway.logoUrl}))))),e.createElement("div",{className:"".concat(a?P.BottomContent:""," ").concat(a?"":i.Hidden)},e.createElement(f,{vm:y})))):null}(),y.payPalPaymentGateway&&function(){var t,a=y.selectedPaymentGatewayIndex===y.payPalPaymentGatewayIndex;return y.payPalPaymentGateway?e.createElement("div",{className:P.SelectBoxContainer},e.createElement("div",{className:"".concat(P.SelectBox," ").concat(a?P.Selected:""),onClick:function(){y.setPaymentGateway(y.payPalPaymentGatewayIndex),y.mpVM.selectedCard=void 0}},e.createElement("div",{className:P.TopContent},e.createElement(E,{value:a,label:y.payPalPaymentGateway.name,removePadding:!0}),e.createElement("div",{className:P.RightContent},(null===(t=y.payPalPaymentGateway.additionalPrices)||void 0===t?void 0:t.length)?e.createElement(k,null,I(y.payPalPaymentGateway.additionalPrices[0])):e.createElement(h,null,!!y.payPalPaymentGateway.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:y.payPalPaymentGateway.logoUrl}))))))):null}())}));export{G as PaymentGateways};
@@ -1 +1 @@
1
- import e from'./../../../../ext/style-inject/dist/style-inject.es.js';var t={StepPayment:"style-module_StepPayment__V1Mfh",TermsLabelSpan:"style-module_TermsLabelSpan__Pnw87",Error:"style-module_Error__S-jQW",SecurePaymentContainer:"style-module_SecurePaymentContainer__PF-bW",Lock:"style-module_Lock__dj1gx"};e(".style-module_StepPayment__V1Mfh {\n margin-top: 8px;\n}\n.style-module_StepPayment__V1Mfh .style-module_TermsLabelSpan__Pnw87 {\n color: var(--checkout-primary-text-color);\n font-weight: 500;\n}\n.style-module_StepPayment__V1Mfh .style-module_TermsLabelSpan__Pnw87:hover {\n text-decoration: underline;\n}\n.style-module_StepPayment__V1Mfh .style-module_Error__S-jQW {\n color: var(--checkout-error-color);\n}\n.style-module_StepPayment__V1Mfh .style-module_SecurePaymentContainer__PF-bW {\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-top: 24px;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_StepPayment__V1Mfh .style-module_SecurePaymentContainer__PF-bW .style-module_Lock__dj1gx {\n color: #CFCED3;\n margin-right: 8px;\n display: flex;\n align-items: center;\n position: relative;\n top: -1px;\n}");export{t as default};
1
+ import e from'./../../../../ext/style-inject/dist/style-inject.es.js';var n={StepPayment:"style-module_StepPayment__V1Mfh",TermsLabelSpan:"style-module_TermsLabelSpan__Pnw87",Error:"style-module_Error__S-jQW",SecurePaymentContainer:"style-module_SecurePaymentContainer__PF-bW",Lock:"style-module_Lock__dj1gx",PayPalContainer:"style-module_PayPalContainer__Fwcuv"};e(".style-module_StepPayment__V1Mfh {\n margin-top: 8px;\n}\n.style-module_StepPayment__V1Mfh .style-module_TermsLabelSpan__Pnw87 {\n color: var(--checkout-primary-text-color);\n font-weight: 500;\n}\n.style-module_StepPayment__V1Mfh .style-module_TermsLabelSpan__Pnw87:hover {\n text-decoration: underline;\n}\n.style-module_StepPayment__V1Mfh .style-module_Error__S-jQW {\n color: var(--checkout-error-color);\n}\n.style-module_StepPayment__V1Mfh .style-module_SecurePaymentContainer__PF-bW {\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-top: 24px;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_StepPayment__V1Mfh .style-module_SecurePaymentContainer__PF-bW .style-module_Lock__dj1gx {\n color: #CFCED3;\n margin-right: 8px;\n display: flex;\n align-items: center;\n position: relative;\n top: -1px;\n}\n\n.style-module_PayPalContainer__Fwcuv {\n margin-top: 24px;\n}");export{n as default};
@@ -1,5 +1,5 @@
1
1
  import { APIResponse } from "@ikas/fe-api-client";
2
- import { CheckStocksQueryParams, CreateAdyenClientTokenParams, CreateKlarnaClientTokenParams, CreateSaleTransactionQueryParams, CreateStripePaymentIntentParams, GetAvailableShippingCountriesQueryParams, GetAvailableStockLocationQueryParams, ListCheckoutSettingsQueryParams, ListPaymentGatewayQueryParams, ListStockLocationQueryParams, RetrieveInstallmentInfoQueryParams } from "@ikas/storefront-api";
2
+ import { CheckStocksQueryParams, CreateAdyenClientTokenParams, CreateKlarnaClientTokenParams, CreateSaleTransactionQueryParams, CreateStripePaymentIntentParams, GetAvailableShippingCountriesQueryParams, GetAvailableStockLocationQueryParams, ListCheckoutSettingsQueryParams, ListPaymentGatewayQueryParams, ListStockLocationQueryParams, RetrieveInstallmentInfoQueryParams, GetPayPalClientIdTokenParams, CreatePayPalOrderParams } from "@ikas/storefront-api";
3
3
  import { IkasAvailableStockLocation, IkasCheckoutSettings, IkasPaymentGateway, IkasStockLocation } from "../../models/data";
4
4
  export default class CheckoutStore {
5
5
  static createSaleTransactionWithCart(params: CreateSaleTransactionQueryParams): Promise<APIResponse<import("@ikas/storefront-api").TransactionResponse> | APIResponse<undefined>>;
@@ -13,4 +13,6 @@ export default class CheckoutStore {
13
13
  static createStripePaymentIntent(params: CreateStripePaymentIntentParams): Promise<APIResponse<import("@ikas/storefront-api").CreateStripePaymentIntentResponse>>;
14
14
  static createKlarnaClientToken(params: CreateKlarnaClientTokenParams): Promise<APIResponse<import("@ikas/storefront-api").CreateKlarnaTokenResponse>>;
15
15
  static createAdyenClientToken(params: CreateAdyenClientTokenParams): Promise<APIResponse<import("@ikas/storefront-api").CreateAdyenSessionResponse>>;
16
+ static getPayPalClientId(params: GetPayPalClientIdTokenParams): Promise<APIResponse<import("@ikas/storefront-api").GetPaypalClientIdResponse>>;
17
+ static createPayPalOrder(params: CreatePayPalOrderParams): Promise<APIResponse<import("@ikas/storefront-api").CreatePaypalOrderResponse>>;
16
18
  }
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as i}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import{createSaleTransactionWithCart as o,listPaymentGateway as r,retrieveInstallmentInfo as a,checkStocks as n,listCheckoutSettings as s,getAvailableShippingCountries as d,listStockLocations as m,getAvailableStockLocations as l,createStripePaymentIntent as u,createKlarnaClientToken as c,createAdyenClientToken as p}from"@ikas/storefront-api";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"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{IkasCheckoutSettings as f}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import{IkasPaymentGateway as j}from"../../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/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/state/index.js";import{IkasAvailableStockLocation as v}from"../../models/data/stock-location/available/index.js";import{IkasStockLocation as x}from"../../models/data/stock-location/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";var h=function(){function h(){}return h.createSaleTransactionWithCart=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,o(i)];case 1:return[2,t.sent()]}}))}))},h.listPaymentGateway=function(o){var a;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,r(o)];case 1:return t=e.sent(),[2,new i(null===(a=t.data)||void 0===a?void 0:a.map((function(t){return new j(t)})),t.graphQLErrors)]}}))}))},h.retrieveInstallmentInfo=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a(i)];case 1:return[2,t.sent()]}}))}))},h.checkStocks=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n(i)];case 1:return[2,t.sent()]}}))}))},h.listCheckoutSettings=function(o){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s(o)];case 1:return t=e.sent(),[2,new i(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new f(t)})),t.graphQLErrors)]}}))}))},h.getAvailableShippingCountries=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,d(i)];case 1:return[2,t.sent()]}}))}))},h.listStockLocation=function(o){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,m(o)];case 1:return t=e.sent(),[2,new i(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new x(t)})),t.graphQLErrors)]}}))}))},h.getAvailableStockLocations=function(o){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,l(o)];case 1:return t=e.sent(),[2,new i(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new v(t)})),t.graphQLErrors)]}}))}))},h.createStripePaymentIntent=function(o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u(o)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},h.createKlarnaClientToken=function(o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,c(o)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},h.createAdyenClientToken=function(o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p(o)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},h}();export{h as default};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as i}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import{createSaleTransactionWithCart as r,listPaymentGateway as o,retrieveInstallmentInfo as a,checkStocks as n,listCheckoutSettings as s,getAvailableShippingCountries as d,listStockLocations as m,getAvailableStockLocations as l,createStripePaymentIntent as u,createKlarnaClientToken as c,createAdyenClientToken as p,getPayPalClientId as f,createPayPalOrder as v}from"@ikas/storefront-api";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"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{IkasCheckoutSettings as h}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import{IkasPaymentGateway as j}from"../../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/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/state/index.js";import{IkasAvailableStockLocation as x}from"../../models/data/stock-location/available/index.js";import{IkasStockLocation as b}from"../../models/data/stock-location/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";var g=function(){function g(){}return g.createSaleTransactionWithCart=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,r(i)];case 1:return[2,t.sent()]}}))}))},g.listPaymentGateway=function(r){var a;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o(r)];case 1:return t=e.sent(),[2,new i(null===(a=t.data)||void 0===a?void 0:a.map((function(t){return new j(t)})),t.graphQLErrors)]}}))}))},g.retrieveInstallmentInfo=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a(i)];case 1:return[2,t.sent()]}}))}))},g.checkStocks=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n(i)];case 1:return[2,t.sent()]}}))}))},g.listCheckoutSettings=function(r){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s(r)];case 1:return t=e.sent(),[2,new i(null===(o=t.data)||void 0===o?void 0:o.map((function(t){return new h(t)})),t.graphQLErrors)]}}))}))},g.getAvailableShippingCountries=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,d(i)];case 1:return[2,t.sent()]}}))}))},g.listStockLocation=function(r){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,m(r)];case 1:return t=e.sent(),[2,new i(null===(o=t.data)||void 0===o?void 0:o.map((function(t){return new b(t)})),t.graphQLErrors)]}}))}))},g.getAvailableStockLocations=function(r){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,l(r)];case 1:return t=e.sent(),[2,new i(null===(o=t.data)||void 0===o?void 0:o.map((function(t){return new x(t)})),t.graphQLErrors)]}}))}))},g.createStripePaymentIntent=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u(r)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},g.createKlarnaClientToken=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,c(r)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},g.createAdyenClientToken=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p(r)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},g.getPayPalClientId=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f(r)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},g.createPayPalOrder=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,v(r)];case 1:return t=e.sent(),[2,new i(t.data,t.graphQLErrors)]}}))}))},g}();export{g as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.5.0-beta.23",
3
+ "version": "4.5.0-beta.26",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,11 +17,11 @@
17
17
  "build": "rm -rf build && rollup -c"
18
18
  },
19
19
  "devDependencies": {
20
- "@ikas/storefront-api": "^4.5.0-beta.23",
21
- "@ikas/storefront-config": "^4.5.0-beta.23",
22
- "@ikas/storefront-model-functions": "^4.5.0-beta.23",
23
- "@ikas/storefront-models": "^4.5.0-beta.23",
24
- "@ikas/storefront-providers": "^4.5.0-beta.23",
20
+ "@ikas/storefront-api": "^4.5.0-beta.26",
21
+ "@ikas/storefront-config": "^4.5.0-beta.26",
22
+ "@ikas/storefront-model-functions": "^4.5.0-beta.26",
23
+ "@ikas/storefront-models": "^4.5.0-beta.26",
24
+ "@ikas/storefront-providers": "^4.5.0-beta.26",
25
25
  "@ikas/localized-address": "^1.0.0-beta.2",
26
26
  "@adyen/adyen-web": "^5.28.2",
27
27
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -50,15 +50,16 @@
50
50
  "@stripe/react-stripe-js": "^1.10.0",
51
51
  "@stripe/stripe-js": "^1.29.0",
52
52
  "react-tooltip": "^4.2.21",
53
- "libphonenumber-js": "^1.10.6"
53
+ "libphonenumber-js": "^1.10.6",
54
+ "@paypal/react-paypal-js": "^7.8.2"
54
55
  },
55
56
  "peerDependencies": {
56
57
  "@ikas/localized-address": "^1.0.0-beta.2",
57
- "@ikas/storefront-api": "^4.5.0-beta.23",
58
- "@ikas/storefront-config": "^4.5.0-beta.23",
59
- "@ikas/storefront-model-functions": "^4.5.0-beta.23",
60
- "@ikas/storefront-models": "^4.5.0-beta.23",
61
- "@ikas/storefront-providers": "^4.5.0-beta.23",
58
+ "@ikas/storefront-api": "^4.5.0-beta.26",
59
+ "@ikas/storefront-config": "^4.5.0-beta.26",
60
+ "@ikas/storefront-model-functions": "^4.5.0-beta.26",
61
+ "@ikas/storefront-models": "^4.5.0-beta.26",
62
+ "@ikas/storefront-providers": "^4.5.0-beta.26",
62
63
  "mobx": "^6.1.3",
63
64
  "mobx-react-lite": "^3.1.5",
64
65
  "next": "12.2.0",
@@ -71,6 +72,7 @@
71
72
  "@stripe/stripe-js": "^1.29.0",
72
73
  "react-tooltip": "^4.2.21",
73
74
  "libphonenumber-js": "^1.10.6",
74
- "@adyen/adyen-web": "^5.28.2"
75
+ "@adyen/adyen-web": "^5.28.2",
76
+ "@paypal/react-paypal-js": "^7.8.2"
75
77
  }
76
78
  }