@ikas/storefront 5.0.5 → 5.0.6

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.
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasProductOptionType as a}from"@ikas/storefront-models";import"mobx";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import"../../../../../models/data/checkout/index.js";import"../../../../../models/data/checkout-settings/index.js";import"../../../../../models/data/city/index.js";import"../../../../../models/data/country/index.js";import"../../../../../models/data/customer/address/region/index.js";import"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/region/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/campaign-offer/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/stock-location/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/shipping-zone/state/city/district/region/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/component/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/product-attribute-detail/index.js";import"../../../../../models/ui/product-attribute-list/index.js";import"../../../../../models/ui/customer-review-list/index.js";import"../../../../../models/ui/customer-review-summary-list/index.js";import"../../../../../models/ui/validator/index.js";import"../../../../../models/ui/validator/rules/index.js";import"../../../../../models/ui/validator/form/login.js";import"../../../../../models/ui/validator/form/address.js";import"../../../../../models/ui/validator/form/ikas-address.js";import"../../../../../models/ui/validator/form/register.js";import"../../../../../models/ui/validator/form/contact-form.js";import"../../../../../models/ui/validator/form/forgot-password.js";import"../../../../../models/ui/validator/form/recover-password.js";import"../../../../../models/ui/validator/form/account-info.js";import"../../../../../models/ui/validator/form/raffle-form.js";import"../../../../../models/ui/validator/form/customer-review.js";import"../../../../../models/ui/raffle-list/index.js";import{formatDate as i}from"../../../../../utils/helper.js";import"@ikas/storefront-config";import{useTranslation as o}from"../../../../../utils/i18n.js";import{Modal as r}from"../../modal/index.js";import{BundleProductItem as s}from"./bundle-product-item/index.js";import m from"./svg/arrow-right.js";import n from"./svg/arrow-down.js";import d from"./style.module.scss.js";var l=t((function(t){var l,c,u,p;t.vm,t.currencyCode;var v=t.cartItem,j=t.stockErrorItem,x=t.onChange,f=t.isSuccessPageSummary,g=o().t,E=!j,N=e.useRef(null),h=e.useState(0),y=h[0],P=h[1],b=e.useState(!1),C=b[0],k=b[1],O=e.useState(!1),w=O[0],T=O[1];e.useEffect((function(){if(N.current){var e=24;Array.from(N.current.children).map((function(t){return e=e+t.clientHeight+12})),P(e)}}),[]),e.useEffect((function(){N.current&&(N.current.style.maxHeight=w?"".concat(y,"px"):"0")}),[w]);var I=e.useMemo((function(){var t;return e.createElement("div",null,null===(t=v.options)||void 0===t?void 0:t.map((function(t){switch(t.type){case a.TEXT:case a.TEXT_AREA:case a.CHOICE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return e.name||e.value})).join(", ")));case a.DATE_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,(a=i(new Date(t)).split(" ")).splice(-1),a.join(" ");var t,a})).join(", ")));case a.FILE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,decodeURIComponent(t.split("/")[t.split("/").length-1]);var t})).join(", ")));case a.CHECKBOX:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.length&&"true"===t.values[0].value?g("checkout-page:yes"):g("checkout-page:no")));case a.COLOR_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionsHorContainer},t.values.map((function(t,a){return e.createElement("div",{key:a,className:d.OptionColorValue,style:{backgroundColor:t.value}})}))))}})))}),[]),R=[d.BundleProductsContainer,w?d.VisibleBundleProducts:""].join(" ");return e.createElement(e.Fragment,null,e.createElement("div",{className:d.CheckoutItem},e.createElement("div",{className:[d.ImageContainer,f?d.SuccessPageImageContainer:""].join(" ")},e.createElement("img",{className:d.Image,src:null===(l=v.variant.mainImage)||void 0===l?void 0:l.thumbnailSrc}),e.createElement("div",{className:d.QuantityCircle},v.quantity)),e.createElement("div",{className:d.Center},!!j&&e.createElement("div",{className:d.StockErrorItemMain},e.createElement("span",null,v.quantity," ",g("checkout-page:quantity")),e.createElement("span",null,e.createElement(m,null)),e.createElement("span",null,j.stockCount<0?0:j.stockCount," ",g("checkout-page:quantity"))),e.createElement("div",{className:[d.Name,f?d.SuccessPageName:""].join(" ")},v.variant.name),e.createElement("div",{className:[d.LightText,f?"":d.Small].join(" ")},null===(c=v.variant.variantValues)||void 0===c?void 0:c.map((function(e){return e.variantValueName})).join(" / ")),!!f&&E&&e.createElement("div",{className:[d.Right,f?d.SuccessPagePriceMain:""].join(" ")},e.createElement("div",{className:d.Price},!!v.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},v.formattedOverridenPriceWithQuantity),e.createElement("span",{className:d.FinalPrice},v.formattedFinalPriceWithQuantity)),v.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},v.unitPriceText)),!!(null===(u=v.options)||void 0===u?void 0:u.length)&&e.createElement("div",{className:d.OptionsText,onClick:function(){return k(!0)}},g("checkout-page:customizedProduct")),v.variant.bundleProducts&&0!==v.variant.bundleProducts.length&&e.createElement("div",{className:d.BundleProducts,onClick:function(){T(!w),x&&setTimeout((function(){x(!w)}),200)}},g("checkout-page:bundleProductsQuantity",{value:v.variant.bundleProducts.length}),e.createElement("span",{style:{paddingTop:2,transform:w?void 0:"rotate(180deg)"}},e.createElement(n,null))),!!C&&e.createElement(r,{title:v.variant.name,modalContent:I,onClose:function(){return k(!1)}})),E&&!f&&e.createElement("div",{className:d.Right},e.createElement("div",{className:d.Price},!!v.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},v.formattedOverridenPriceWithQuantity),v.formattedFinalPriceWithQuantity),v.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},v.unitPriceText))),e.createElement("div",{ref:N,className:R},null===(p=v.variant.bundleProducts)||void 0===p?void 0:p.map((function(t){return e.createElement(s,{bundleProduct:t})}))))}));export{l as CartItem};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasProductOptionType as a}from"@ikas/storefront-models";import"mobx";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import"../../../../../models/data/checkout/index.js";import"../../../../../models/data/checkout-settings/index.js";import"../../../../../models/data/city/index.js";import"../../../../../models/data/country/index.js";import"../../../../../models/data/customer/address/region/index.js";import"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/region/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/campaign-offer/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/stock-location/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/shipping-zone/state/city/district/region/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/component/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/product-attribute-detail/index.js";import"../../../../../models/ui/product-attribute-list/index.js";import"../../../../../models/ui/customer-review-list/index.js";import"../../../../../models/ui/customer-review-summary-list/index.js";import"../../../../../models/ui/validator/index.js";import"../../../../../models/ui/validator/rules/index.js";import"../../../../../models/ui/validator/form/login.js";import"../../../../../models/ui/validator/form/address.js";import"../../../../../models/ui/validator/form/ikas-address.js";import"../../../../../models/ui/validator/form/register.js";import"../../../../../models/ui/validator/form/contact-form.js";import"../../../../../models/ui/validator/form/forgot-password.js";import"../../../../../models/ui/validator/form/recover-password.js";import"../../../../../models/ui/validator/form/account-info.js";import"../../../../../models/ui/validator/form/raffle-form.js";import"../../../../../models/ui/validator/form/customer-review.js";import"../../../../../models/ui/raffle-list/index.js";import{formatDate as i}from"../../../../../utils/helper.js";import"@ikas/storefront-config";import{useTranslation as o}from"../../../../../utils/i18n.js";import{Modal as r}from"../../modal/index.js";import{BundleProductItem as s}from"./bundle-product-item/index.js";import m from"./svg/arrow-right.js";import n from"./svg/arrow-down.js";import d from"./style.module.scss.js";var l=t((function(t){var l,c,u,p,v;t.vm,t.currencyCode;var j=t.cartItem,x=t.stockErrorItem,f=t.onChange,g=t.isSuccessPageSummary,E=o().t,N=!x,y=e.useRef(null),h=e.useState(0),P=h[0],b=h[1],C=e.useState(!1),k=C[0],O=C[1],w=e.useState(!1),T=w[0],I=w[1];e.useEffect((function(){if(y.current){var e=24;Array.from(y.current.children).map((function(t){return e=e+t.clientHeight+12})),b(e)}}),[]),e.useEffect((function(){y.current&&(y.current.style.maxHeight=T?"".concat(P,"px"):"0")}),[T]);var R=e.useMemo((function(){var t;return e.createElement("div",null,null===(t=j.options)||void 0===t?void 0:t.map((function(t){switch(t.type){case a.TEXT:case a.TEXT_AREA:case a.CHOICE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return e.name||e.value})).join(", ")));case a.DATE_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,(a=i(new Date(t)).split(" ")).splice(-1),a.join(" ");var t,a})).join(", ")));case a.FILE:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.map((function(e){return t=e.value,decodeURIComponent(t.split("/")[t.split("/").length-1]);var t})).join(", ")));case a.CHECKBOX:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionValue},t.values.length&&"true"===t.values[0].value?E("checkout-page:yes"):E("checkout-page:no")));case a.COLOR_PICKER:return e.createElement("div",{className:d.OptionRow},e.createElement("div",{className:d.OptionName},t.name),e.createElement("div",{className:d.OptionsHorContainer},t.values.map((function(t,a){return e.createElement("div",{key:a,className:d.OptionColorValue,style:{backgroundColor:t.value}})}))))}})))}),[]),S=[d.BundleProductsContainer,T?d.VisibleBundleProducts:""].join(" "),Q=(null===(l=j.variant.bundleProducts)||void 0===l?void 0:l.reduce((function(e,t){return e+t.quantity}),0))||0;return e.createElement(e.Fragment,null,e.createElement("div",{className:d.CheckoutItem},e.createElement("div",{className:[d.ImageContainer,g?d.SuccessPageImageContainer:""].join(" ")},e.createElement("img",{className:d.Image,src:null===(c=j.variant.mainImage)||void 0===c?void 0:c.thumbnailSrc}),e.createElement("div",{className:d.QuantityCircle},j.quantity)),e.createElement("div",{className:d.Center},!!x&&e.createElement("div",{className:d.StockErrorItemMain},e.createElement("span",null,j.quantity," ",E("checkout-page:quantity")),e.createElement("span",null,e.createElement(m,null)),e.createElement("span",null,x.stockCount<0?0:x.stockCount," ",E("checkout-page:quantity"))),e.createElement("div",{className:[d.Name,g?d.SuccessPageName:""].join(" ")},j.variant.name),e.createElement("div",{className:[d.LightText,g?"":d.Small].join(" ")},null===(u=j.variant.variantValues)||void 0===u?void 0:u.map((function(e){return e.variantValueName})).join(" / ")),!!g&&N&&e.createElement("div",{className:[d.Right,g?d.SuccessPagePriceMain:""].join(" ")},e.createElement("div",{className:d.Price},!!j.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},j.formattedOverridenPriceWithQuantity),e.createElement("span",{className:d.FinalPrice},j.formattedFinalPriceWithQuantity)),j.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},j.unitPriceText)),!!(null===(p=j.options)||void 0===p?void 0:p.length)&&e.createElement("div",{className:d.OptionsText,onClick:function(){return O(!0)}},E("checkout-page:customizedProduct")),j.variant.bundleProducts&&0!==j.variant.bundleProducts.length&&e.createElement("div",{className:d.BundleProducts,onClick:function(){I(!T),f&&setTimeout((function(){f(!T)}),200)}},E("checkout-page:bundleProductsQuantity",{value:Q}),e.createElement("span",{style:{paddingTop:2,transform:T?void 0:"rotate(180deg)"}},e.createElement(n,null))),!!k&&e.createElement(r,{title:j.variant.name,modalContent:R,onClose:function(){return O(!1)}})),N&&!g&&e.createElement("div",{className:d.Right},e.createElement("div",{className:d.Price},!!j.overridenPriceWithQuantity&&e.createElement("span",{className:d.GrayPrice},j.formattedOverridenPriceWithQuantity),j.formattedFinalPriceWithQuantity),j.unitPriceText&&e.createElement("div",{className:[d.LightText,d.Small].join(" ")},j.unitPriceText))),e.createElement("div",{ref:y,className:S},null===(v=j.variant.bundleProducts)||void 0===v?void 0:v.map((function(t){return e.createElement(s,{bundleProduct:t})}))))}));export{l as CartItem};
@@ -1 +1 @@
1
- import*as e from"react";import{runInAction as t}from"mobx";import{observer as n}from"mobx-react-lite";import o,{FormItemType as r}from"./model.js";import a from"./caret-down.js";import u from"./style.module.scss.js";import"@ikas/storefront-config";import{useTranslation as l}from"../../../../utils/i18n.js";import i from"react-tooltip";import{PhoneNumberInput as c}from"../phone-number-input/index.js";var s=n((function(n){var a=l().t,s=e.useState((function(){return new o(n)})),d=s[0],E=s[1];return e.useEffect((function(){i.rebuild()}),[]),e.useEffect((function(){t((function(){d.type=n.type}))}),[n.type]),e.useEffect((function(){t((function(){d.inputType=n.inputType}))}),[n.inputType]),e.useEffect((function(){t((function(){d.inputMode=n.inputMode}))}),[n.inputMode]),e.useEffect((function(){t((function(){d.value=n.value}))}),[n.value]),e.useEffect((function(){t((function(){d.options=n.options}))}),[n.options]),e.useEffect((function(){t((function(){d.label=n.label}))}),[n.label]),e.useEffect((function(){t((function(){d.hasError=n.hasError}))}),[n.hasError]),e.useEffect((function(){t((function(){d.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){d.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){d.textAreaPlaceholder=n.textAreaPlaceholder}))}),[n.textAreaPlaceholder]),e.useEffect((function(){t((function(){d.rightContent=n.rightContent}))}),[n.rightContent]),e.useEffect((function(){t((function(){d.disableResize=n.disableResize}))}),[n.disableResize]),e.useEffect((function(){t((function(){E(new o(n))}))}),[n.onChange]),e.useEffect((function(){!d.country&&n.currentCountryCode&&d.onCountryChange(n.currentCountryCode)}),[n.currentCountryCode]),e.createElement("div",{className:d.formItemStyle,style:n.style},e.createElement("div",{className:u.FormItemWrapper},e.createElement("div",{className:u.FormItemInputWrapper},e.createElement("label",{className:d.labelStyle},d.label),d.type===r.TEXT&&e.createElement(m,{vm:d,type:d.inputType,disabled:d.disabled,required:n.required,pattern:n.pattern,autocomplete:n.autocomplete,name:n.name}),d.type===r.TEL&&e.createElement(c,{key:n.currentCountryCode||"1",disabled:d.disabled,defaultCountry:n.currentCountryCode,placeholder:a("checkout-page:enterPhoneNumber"),value:d.value?d.value:"",onChange:d.onPhoneChange}),d.type===r.TEXT_AREA&&e.createElement(f,{vm:d}),d.type===r.SELECT&&e.createElement(p,{vm:d,autocomplete:n.autocomplete})),!!d.hasError&&e.createElement("div",{className:u.ErrorMsg},d.errorText||""),!!n.tooltipText&&e.createElement("div",{className:u.FormItemTooltipContainer,"data-tip":n.tooltipText,"data-event":"touchstart focus mouseover","data-event-off":"mouseout"},"?"),!!d.rightContent&&e.createElement("div",{className:u.RightContent},d.rightContent)))})),m=n((function(t){var n=t.vm,o=t.name,r=t.autocomplete,a=t.type,u=t.pattern,l=t.required,i=t.disabled;return e.createElement("input",{required:l,type:a||"text",name:o,pattern:u,disabled:i,autoComplete:r,inputMode:n.inputMode||"text",className:n.inputStyle,value:n.value,onChange:n.onValueChange})})),f=n((function(t){var n=t.vm;return e.createElement("textarea",{style:{resize:n.disableResize?"none":"initial"},value:n.value,disabled:n.disabled,onChange:n.onTextAreaValueChange,placeholder:n.textAreaPlaceholder||"",maxLength:n.maxLength})})),p=n((function(t){var n,o=t.vm,r=t.autocomplete;return e.createElement(e.Fragment,null,e.createElement("select",{className:o.inputStyle,disabled:o.disabled,autoComplete:r,onChange:o.onSelectChange},!o.value&&e.createElement("option",{selected:!0,disabled:!0,key:-1}),null===(n=o.options)||void 0===n?void 0:n.map((function(t,n){return e.createElement("option",{key:n+t.value,value:t.label,selected:o.value===t.value},t.label)}))),e.createElement("div",{className:u.ArrowContainer},e.createElement(a,null)))}));export{s as FormItem};
1
+ import*as e from"react";import{runInAction as t}from"mobx";import{observer as n}from"mobx-react-lite";import o,{FormItemType as r}from"./model.js";import a from"./caret-down.js";import l from"./style.module.scss.js";import"@ikas/storefront-config";import{useTranslation as u}from"../../../../utils/i18n.js";import i from"react-tooltip";import{PhoneNumberInput as c}from"../phone-number-input/index.js";var m=n((function(n){var a=u().t,m=e.useState((function(){return new o(n)})),d=m[0],E=m[1];return e.useEffect((function(){i.rebuild()}),[]),e.useEffect((function(){t((function(){d.type=n.type}))}),[n.type]),e.useEffect((function(){t((function(){d.inputType=n.inputType}))}),[n.inputType]),e.useEffect((function(){t((function(){d.inputMode=n.inputMode}))}),[n.inputMode]),e.useEffect((function(){t((function(){d.value=n.value}))}),[n.value]),e.useEffect((function(){t((function(){d.options=n.options}))}),[n.options]),e.useEffect((function(){t((function(){d.label=n.label}))}),[n.label]),e.useEffect((function(){t((function(){d.hasError=n.hasError}))}),[n.hasError]),e.useEffect((function(){t((function(){d.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){d.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){d.textAreaPlaceholder=n.textAreaPlaceholder}))}),[n.textAreaPlaceholder]),e.useEffect((function(){t((function(){d.rightContent=n.rightContent}))}),[n.rightContent]),e.useEffect((function(){t((function(){d.disableResize=n.disableResize}))}),[n.disableResize]),e.useEffect((function(){t((function(){E(new o(n))}))}),[n.onChange]),e.useEffect((function(){!d.country&&n.currentCountryCode&&d.onCountryChange(n.currentCountryCode)}),[n.currentCountryCode]),e.createElement("div",{className:d.formItemStyle,style:n.style},e.createElement("div",{className:l.FormItemWrapper},e.createElement("div",{className:l.FormItemInputWrapper},e.createElement("label",{className:d.labelStyle},d.label),d.type===r.TEXT&&e.createElement(s,{vm:d,type:d.inputType,disabled:d.disabled,required:n.required,pattern:n.pattern,autocomplete:n.autocomplete,name:n.name}),d.type===r.TEL&&e.createElement(c,{key:n.currentCountryCode||"1",disabled:d.disabled,defaultCountry:n.currentCountryCode,placeholder:a("checkout-page:enterPhoneNumber"),value:d.value?d.value:"",onChange:d.onPhoneChange}),d.type===r.TEXT_AREA&&e.createElement(f,{vm:d}),d.type===r.SELECT&&e.createElement(p,{vm:d,autocomplete:n.autocomplete})),!!d.hasError&&e.createElement("div",{className:l.ErrorMsg},d.errorText||""),!!n.tooltipText&&e.createElement("div",{className:l.FormItemTooltipContainer,"data-tip":n.tooltipText,"data-event":"touchstart focus mouseover","data-event-off":"mouseout"},"?"),!!d.rightContent&&e.createElement("div",{className:l.RightContent},d.rightContent)))})),s=n((function(t){var n=t.vm,o=t.name,r=t.autocomplete,a=t.type,l=t.pattern,u=t.required,i=t.disabled;return e.createElement("input",{required:u,type:a||"text",name:o,pattern:l,disabled:i,autoComplete:r,inputMode:n.inputMode||"text",className:n.inputStyle,value:n.value,onChange:n.onValueChange})})),f=n((function(t){var n,o=t.vm;return e.createElement(e.Fragment,null,e.createElement("textarea",{style:{resize:o.disableResize?"none":"initial"},value:o.value,disabled:o.disabled,onChange:o.onTextAreaValueChange,placeholder:o.textAreaPlaceholder||"",maxLength:o.maxLength}),o.maxLength&&e.createElement("div",{className:l.TextareaInfo},(null===(n=o.value)||void 0===n?void 0:n.length)||0," / ",o.maxLength))})),p=n((function(t){var n,o=t.vm,r=t.autocomplete;return e.createElement(e.Fragment,null,e.createElement("select",{className:o.inputStyle,disabled:o.disabled,autoComplete:r,onChange:o.onSelectChange},!o.value&&e.createElement("option",{selected:!0,disabled:!0,key:-1}),null===(n=o.options)||void 0===n?void 0:n.map((function(t,n){return e.createElement("option",{key:n+t.value,value:t.label,selected:o.value===t.value},t.label)}))),e.createElement("div",{className:l.ArrowContainer},e.createElement(a,null)))}));export{m as FormItem};
@@ -1 +1 @@
1
- import e from'./../../../../ext/style-inject/dist/style-inject.es.js';var t={FormSectionTitle:"style-module_FormSectionTitle__VB-M-",Title:"style-module_Title__vKJBI",WithSubTitle:"style-module_WithSubTitle__D0bIa",SubTitle:"style-module_SubTitle__QOgiQ",Grid:"style-module_Grid__zW07u",Grid2:"style-module_Grid2__ngFn-",Grid3:"style-module_Grid3__WkRIF",FormItem:"style-module_FormItem__Uk50U",FormItemWrapper:"style-module_FormItemWrapper__7lb91",RightContent:"style-module_RightContent__mPnNX",FormItemInputWrapper:"style-module_FormItemInputWrapper__-bMzj",FieldLabel:"style-module_FieldLabel__FLtYi",FieldLabelTop:"style-module_FieldLabelTop__-neJm",Bottom:"style-module_Bottom__Syp-M",Error:"style-module_Error__TxUpM",WithTooltip:"style-module_WithTooltip__vErQH",ArrowContainer:"style-module_ArrowContainer__4GCN2",ErrorMsg:"style-module_ErrorMsg__AL-SH",fadeInFromRight:"style-module_fadeInFromRight__jtf8N",PhoneError:"style-module_PhoneError__Jl0Ig",FormItemTooltipContainer:"style-module_FormItemTooltipContainer__Het-k"};e('.style-module_FormSectionTitle__VB-M- {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n.style-module_FormSectionTitle__VB-M- .style-module_Title__vKJBI {\n flex: 1 1 auto;\n padding-bottom: 16px;\n color: var(--checkout-primary-text-color);\n font-size: 20px;\n line-height: 32px;\n}\n.style-module_FormSectionTitle__VB-M- .style-module_Title__vKJBI.style-module_WithSubTitle__D0bIa {\n line-height: auto;\n padding-bottom: 0;\n}\n\n.style-module_SubTitle__QOgiQ {\n color: var(--checkout-secondary-text-color);\n font-size: 14px;\n padding-bottom: 16px;\n padding-top: 2px;\n}\n\n.style-module_Grid__zW07u {\n display: grid;\n grid-gap: 16px;\n grid-template-columns: 1fr;\n}\n.style-module_Grid__zW07u.style-module_Grid2__ngFn- {\n grid-template-columns: repeat(2, 1fr);\n}\n.style-module_Grid__zW07u.style-module_Grid3__WkRIF {\n grid-template-columns: repeat(3, 1fr);\n}\n@media only screen and (max-width: 768px) {\n .style-module_Grid__zW07u {\n grid-template-columns: 1fr !important;\n }\n}\n\n@keyframes style-module_fadeInFromRight__jtf8N {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n.style-module_FormItem__Uk50U {\n width: 100%;\n}\n.style-module_FormItemWrapper__7lb91 {\n width: 100%;\n position: relative;\n}\n.style-module_FormItemWrapper__7lb91 .style-module_RightContent__mPnNX {\n position: absolute;\n height: 100%;\n top: 0;\n right: 0;\n}\n.style-module_FormItemInputWrapper__-bMzj {\n position: relative;\n width: 100%;\n}\n.style-module_FormItemInputWrapper__-bMzj label.style-module_FieldLabel__FLtYi {\n color: var(--checkout-secondary-text-color);\n position: absolute;\n top: 0;\n left: 17px;\n width: 100%;\n z-index: 1;\n user-select: none;\n pointer-events: none;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n transition: transform 0.1s;\n transform: translateY(18px);\n font-size: 0.85em;\n line-height: 22px;\n}\n.style-module_FormItemInputWrapper__-bMzj label.style-module_FieldLabelTop__-neJm {\n transform: translateY(8px);\n font-size: 0.7em;\n}\n.style-module_FormItemInputWrapper__-bMzj input,\n.style-module_FormItemInputWrapper__-bMzj select,\n.style-module_FormItemInputWrapper__-bMzj textarea {\n border: 1px solid var(--checkout-border-color);\n background-color: var(--checkout-primary-bg-color);\n color: var(--checkout-primary-text-color);\n background-clip: padding-box;\n border-radius: 8px;\n display: block;\n width: 100%;\n height: 56px;\n padding: 8px 16px;\n outline: none;\n transition: padding 0.1s, border-color 0.5s, box-shadow 0.5s;\n box-shadow: 0 0 0 1px transparent;\n -moz-appearance: none;\n -webkit-appearance: none;\n}\n.style-module_FormItemInputWrapper__-bMzj input:focus,\n.style-module_FormItemInputWrapper__-bMzj select:focus,\n.style-module_FormItemInputWrapper__-bMzj textarea:focus {\n box-shadow: 0 0 0 1px var(--checkout-button-bg-color);\n border-color: var(--checkout-button-bg-color);\n}\n.style-module_FormItemInputWrapper__-bMzj input.style-module_Bottom__Syp-M,\n.style-module_FormItemInputWrapper__-bMzj select.style-module_Bottom__Syp-M,\n.style-module_FormItemInputWrapper__-bMzj textarea.style-module_Bottom__Syp-M {\n padding-top: 1.2em;\n padding-bottom: 0.2em;\n}\n.style-module_FormItemInputWrapper__-bMzj input.style-module_Error__TxUpM,\n.style-module_FormItemInputWrapper__-bMzj select.style-module_Error__TxUpM,\n.style-module_FormItemInputWrapper__-bMzj textarea.style-module_Error__TxUpM {\n box-shadow: 0 0 0 1px var(--checkout-error-color);\n border-color: var(--checkout-error-color);\n}\n.style-module_FormItemInputWrapper__-bMzj input.style-module_WithTooltip__vErQH,\n.style-module_FormItemInputWrapper__-bMzj select.style-module_WithTooltip__vErQH,\n.style-module_FormItemInputWrapper__-bMzj textarea.style-module_WithTooltip__vErQH {\n padding-right: 40px;\n}\n.style-module_FormItemInputWrapper__-bMzj input::-ms-expand,\n.style-module_FormItemInputWrapper__-bMzj select::-ms-expand,\n.style-module_FormItemInputWrapper__-bMzj textarea::-ms-expand {\n display: none;\n}\n.style-module_FormItemInputWrapper__-bMzj input::placeholder,\n.style-module_FormItemInputWrapper__-bMzj select::placeholder,\n.style-module_FormItemInputWrapper__-bMzj textarea::placeholder {\n color: var(--checkout-secondary-text-color) !important;\n}\n.style-module_FormItemInputWrapper__-bMzj textarea {\n min-height: 120px;\n}\n.style-module_FormItemInputWrapper__-bMzj .style-module_ArrowContainer__4GCN2 {\n position: absolute;\n right: 1px;\n padding-right: 0.5em;\n top: 1px;\n height: calc(100% - 2px);\n display: flex;\n align-items: center;\n color: var(--checkout-secondary-text-color);\n background-color: var(--checkout-primary-bg-color);\n z-index: 2;\n border-radius: 6px;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInput {\n display: flex;\n align-items: center;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputInput {\n padding-left: 64px;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputInput:disabled {\n color: var(--checkout-button-disabled-text-color) !important;\n background-color: var(--checkout-button-disabled-bg-color) !important;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputInput::placeholder {\n color: var(--checkout-secondary-text-color) !important;\n font-size: 14px !important;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountry {\n position: absolute;\n align-self: stretch;\n display: flex;\n align-items: center;\n top: 26px;\n left: 16px;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountrySelect {\n border: none;\n display: inline-flex;\n width: 60px;\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n z-index: 1;\n border: 0;\n opacity: 0;\n cursor: pointer;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountryIcon {\n width: 1.5em;\n height: 1em;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountrySelectArrow {\n display: block;\n content: "";\n width: 0.3em;\n height: 0.3em;\n margin-left: 0.35em;\n border-style: solid;\n border-color: inherit;\n border-top-width: 0;\n border-bottom-width: 1px;\n border-left-width: 0;\n border-right-width: 1px;\n transform: rotate(45deg);\n opacity: 0.45;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountryIconImg {\n width: 24px;\n}\n.style-module_FormItem__Uk50U .style-module_ErrorMsg__AL-SH {\n color: var(--checkout-error-color);\n font-size: 12px;\n margin-top: 8px;\n animation-name: style-module_fadeInFromRight__jtf8N;\n animation-duration: 0.3s;\n}\n.style-module_FormItem__Uk50U.style-module_PhoneError__Jl0Ig input {\n box-shadow: 0 0 0 1px var(--checkout-error-color) !important;\n border-color: var(--checkout-error-color) !important;\n}\n\n.style-module_FormItemWrapper__7lb91 {\n position: relative;\n}\n\n.style-module_FormItemTooltipContainer__Het-k {\n width: 16px;\n height: 16px;\n border-radius: 100%;\n color: white;\n background-color: var(--checkout-secondary-text-color);\n position: absolute;\n top: 20px;\n right: 16px;\n margin: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 12px !important;\n line-height: 16px !important;\n cursor: pointer;\n}');export{t as default};
1
+ import e from'./../../../../ext/style-inject/dist/style-inject.es.js';var t={FormSectionTitle:"style-module_FormSectionTitle__VB-M-",Title:"style-module_Title__vKJBI",WithSubTitle:"style-module_WithSubTitle__D0bIa",SubTitle:"style-module_SubTitle__QOgiQ",Grid:"style-module_Grid__zW07u",Grid2:"style-module_Grid2__ngFn-",Grid3:"style-module_Grid3__WkRIF",FormItem:"style-module_FormItem__Uk50U",FormItemWrapper:"style-module_FormItemWrapper__7lb91",RightContent:"style-module_RightContent__mPnNX",FormItemInputWrapper:"style-module_FormItemInputWrapper__-bMzj",FieldLabel:"style-module_FieldLabel__FLtYi",FieldLabelTop:"style-module_FieldLabelTop__-neJm",Bottom:"style-module_Bottom__Syp-M",Error:"style-module_Error__TxUpM",WithTooltip:"style-module_WithTooltip__vErQH",ArrowContainer:"style-module_ArrowContainer__4GCN2",ErrorMsg:"style-module_ErrorMsg__AL-SH",fadeInFromRight:"style-module_fadeInFromRight__jtf8N",PhoneError:"style-module_PhoneError__Jl0Ig",FormItemTooltipContainer:"style-module_FormItemTooltipContainer__Het-k",TextareaInfo:"style-module_TextareaInfo__MkOI-"};e('.style-module_FormSectionTitle__VB-M- {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n.style-module_FormSectionTitle__VB-M- .style-module_Title__vKJBI {\n flex: 1 1 auto;\n padding-bottom: 16px;\n color: var(--checkout-primary-text-color);\n font-size: 20px;\n line-height: 32px;\n}\n.style-module_FormSectionTitle__VB-M- .style-module_Title__vKJBI.style-module_WithSubTitle__D0bIa {\n line-height: auto;\n padding-bottom: 0;\n}\n\n.style-module_SubTitle__QOgiQ {\n color: var(--checkout-secondary-text-color);\n font-size: 14px;\n padding-bottom: 16px;\n padding-top: 2px;\n}\n\n.style-module_Grid__zW07u {\n display: grid;\n grid-gap: 16px;\n grid-template-columns: 1fr;\n}\n.style-module_Grid__zW07u.style-module_Grid2__ngFn- {\n grid-template-columns: repeat(2, 1fr);\n}\n.style-module_Grid__zW07u.style-module_Grid3__WkRIF {\n grid-template-columns: repeat(3, 1fr);\n}\n@media only screen and (max-width: 768px) {\n .style-module_Grid__zW07u {\n grid-template-columns: 1fr !important;\n }\n}\n\n@keyframes style-module_fadeInFromRight__jtf8N {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n.style-module_FormItem__Uk50U {\n width: 100%;\n}\n.style-module_FormItemWrapper__7lb91 {\n width: 100%;\n position: relative;\n}\n.style-module_FormItemWrapper__7lb91 .style-module_RightContent__mPnNX {\n position: absolute;\n height: 100%;\n top: 0;\n right: 0;\n}\n.style-module_FormItemInputWrapper__-bMzj {\n position: relative;\n width: 100%;\n}\n.style-module_FormItemInputWrapper__-bMzj label.style-module_FieldLabel__FLtYi {\n color: var(--checkout-secondary-text-color);\n position: absolute;\n top: 0;\n left: 17px;\n width: 100%;\n z-index: 1;\n user-select: none;\n pointer-events: none;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n transition: transform 0.1s;\n transform: translateY(18px);\n font-size: 0.85em;\n line-height: 22px;\n}\n.style-module_FormItemInputWrapper__-bMzj label.style-module_FieldLabelTop__-neJm {\n transform: translateY(8px);\n font-size: 0.7em;\n}\n.style-module_FormItemInputWrapper__-bMzj input,\n.style-module_FormItemInputWrapper__-bMzj select,\n.style-module_FormItemInputWrapper__-bMzj textarea {\n border: 1px solid var(--checkout-border-color);\n background-color: var(--checkout-primary-bg-color);\n color: var(--checkout-primary-text-color);\n background-clip: padding-box;\n border-radius: 8px;\n display: block;\n width: 100%;\n height: 56px;\n padding: 8px 16px;\n outline: none;\n transition: padding 0.1s, border-color 0.5s, box-shadow 0.5s;\n box-shadow: 0 0 0 1px transparent;\n -moz-appearance: none;\n -webkit-appearance: none;\n}\n.style-module_FormItemInputWrapper__-bMzj input:focus,\n.style-module_FormItemInputWrapper__-bMzj select:focus,\n.style-module_FormItemInputWrapper__-bMzj textarea:focus {\n box-shadow: 0 0 0 1px var(--checkout-button-bg-color);\n border-color: var(--checkout-button-bg-color);\n}\n.style-module_FormItemInputWrapper__-bMzj input.style-module_Bottom__Syp-M,\n.style-module_FormItemInputWrapper__-bMzj select.style-module_Bottom__Syp-M,\n.style-module_FormItemInputWrapper__-bMzj textarea.style-module_Bottom__Syp-M {\n padding-top: 1.2em;\n padding-bottom: 0.2em;\n}\n.style-module_FormItemInputWrapper__-bMzj input.style-module_Error__TxUpM,\n.style-module_FormItemInputWrapper__-bMzj select.style-module_Error__TxUpM,\n.style-module_FormItemInputWrapper__-bMzj textarea.style-module_Error__TxUpM {\n box-shadow: 0 0 0 1px var(--checkout-error-color);\n border-color: var(--checkout-error-color);\n}\n.style-module_FormItemInputWrapper__-bMzj input.style-module_WithTooltip__vErQH,\n.style-module_FormItemInputWrapper__-bMzj select.style-module_WithTooltip__vErQH,\n.style-module_FormItemInputWrapper__-bMzj textarea.style-module_WithTooltip__vErQH {\n padding-right: 40px;\n}\n.style-module_FormItemInputWrapper__-bMzj input::-ms-expand,\n.style-module_FormItemInputWrapper__-bMzj select::-ms-expand,\n.style-module_FormItemInputWrapper__-bMzj textarea::-ms-expand {\n display: none;\n}\n.style-module_FormItemInputWrapper__-bMzj input::placeholder,\n.style-module_FormItemInputWrapper__-bMzj select::placeholder,\n.style-module_FormItemInputWrapper__-bMzj textarea::placeholder {\n color: var(--checkout-secondary-text-color) !important;\n}\n.style-module_FormItemInputWrapper__-bMzj textarea {\n min-height: 120px;\n}\n.style-module_FormItemInputWrapper__-bMzj .style-module_ArrowContainer__4GCN2 {\n position: absolute;\n right: 1px;\n padding-right: 0.5em;\n top: 1px;\n height: calc(100% - 2px);\n display: flex;\n align-items: center;\n color: var(--checkout-secondary-text-color);\n background-color: var(--checkout-primary-bg-color);\n z-index: 2;\n border-radius: 6px;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInput {\n display: flex;\n align-items: center;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputInput {\n padding-left: 64px;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputInput:disabled {\n color: var(--checkout-button-disabled-text-color) !important;\n background-color: var(--checkout-button-disabled-bg-color) !important;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputInput::placeholder {\n color: var(--checkout-secondary-text-color) !important;\n font-size: 14px !important;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountry {\n position: absolute;\n align-self: stretch;\n display: flex;\n align-items: center;\n top: 26px;\n left: 16px;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountrySelect {\n border: none;\n display: inline-flex;\n width: 60px;\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n z-index: 1;\n border: 0;\n opacity: 0;\n cursor: pointer;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountryIcon {\n width: 1.5em;\n height: 1em;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountrySelectArrow {\n display: block;\n content: "";\n width: 0.3em;\n height: 0.3em;\n margin-left: 0.35em;\n border-style: solid;\n border-color: inherit;\n border-top-width: 0;\n border-bottom-width: 1px;\n border-left-width: 0;\n border-right-width: 1px;\n transform: rotate(45deg);\n opacity: 0.45;\n}\n.style-module_FormItemInputWrapper__-bMzj .PhoneInputCountryIconImg {\n width: 24px;\n}\n.style-module_FormItem__Uk50U .style-module_ErrorMsg__AL-SH {\n color: var(--checkout-error-color);\n font-size: 12px;\n margin-top: 8px;\n animation-name: style-module_fadeInFromRight__jtf8N;\n animation-duration: 0.3s;\n}\n.style-module_FormItem__Uk50U.style-module_PhoneError__Jl0Ig input {\n box-shadow: 0 0 0 1px var(--checkout-error-color) !important;\n border-color: var(--checkout-error-color) !important;\n}\n\n.style-module_FormItemWrapper__7lb91 {\n position: relative;\n}\n\n.style-module_FormItemTooltipContainer__Het-k {\n width: 16px;\n height: 16px;\n border-radius: 100%;\n color: white;\n background-color: var(--checkout-secondary-text-color);\n position: absolute;\n top: 20px;\n right: 16px;\n margin: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 12px !important;\n line-height: 16px !important;\n cursor: pointer;\n}\n\n.style-module_TextareaInfo__MkOI- {\n text-align: right;\n}');export{t as default};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__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{IkasCartCreatedBy as o,IkasCouponCodeRequirement as a,IkasPaymentMethodType as c,IkasPaymentGatewayType as d,IkasOrderShippingMethod as u,IkasOrderPaymentStatus as l,IkasTransactionStatus as h,IkasCartCampaignOfferStatus as p,IkasCampaignOfferTargetPageType as m,IkasOrderLineItemStatus as f,IkasCustomerEmailSubscriptionStatus as g,IkasCampaignOfferProductApplicablePriceEnum as v}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 y}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as S}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as k}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as b}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 P}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as C}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as I}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as A}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as E}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as w}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 R from"./components/credit-card-form/model.js";import O from"../../store/customer/api.js";import N from"../../store/checkout/index.js";import j from"../../store/cart/api.js";import D,{MFS_ELEMENT_ID as T,MFS_SCRIPT_URL as L}from"./modelMasterPass.js";import x from"../../store/product/index.js";import{TransactionCardAssociationEnum as M,SaveCartInput as G,CheckStocksLineInput as _}from"@ikas/storefront-api";import{IkasBaseStore as U}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as V}from"@ikas/storefront-config";import{Analytics as F}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import B from"../../models/data/order/address/ikas-localized-order-address.js";import K from"../../store/location/index.js";import{getCookieValue as Z}from"../../utils/helper.js";var Y,H,q=/^\d+$/,W="undefined"==typeof localStorage,Q=function(){function q(o,b,P,q,Q,$,J,ee,te,ie){var se=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=Y.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(se,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return e.sent(),[4,U.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 3:return e.sent(),[2]}}))}))},this.initStep=function(){return e(se,void 0,void 0,(function(){var e,s,n,r,o,c,d;return t(this,(function(t){switch(t.label){case 0:if(V.getIsEditor())return this.step=Y.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),s=e.get("step"),n=e.get("failed"),r=e.get("error"),s){if(this.step=s,this.step===Y.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(Y.INFO)];if(this.step!==Y.PAYMENT||this.canProceedToPayment){if(this.step===Y.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(Y.INFO)];if(![Y.INFO,Y.SUCCESS,Y.SHIPPING,Y.PAYMENT].includes(this.step))return[2,this.changeStep(Y.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(Y.INFO)]:[2,this.changeStep(Y.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:H.PAYMENT_ERROR,data:r||null}),this.step!==Y.SHIPPING&&this.step!==Y.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new S(i(i({},this.checkoutSettings),{couponCodeRequirement:a.DEFAULT}))),this.step!==Y.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:t.sent(),this.checkShippingCountries(),t.label=4;case 4:return[4,this.getStockLocations()];case 5:return t.sent(),[4,this.getAvailableStockLocations()];case 6:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=7;case 7:return this.step!==Y.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=Y.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==Y.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==Y.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==Y.PAYMENT&&this.step!==Y.SUCCESS?[3,13]:[4,this.listPaymentGateways()];case 10:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,12];case 11:t.sent(),t.label=12;case 12:if(!this.paymentGateways.length)return this.error={type:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===Y.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(Y.SUCCESS)]:[3,14];case 14:return[4,this.initialStockCheck()];case 15:t.sent(),t.label=16;case 16:return[3,19];case 17:return[4,this.getSuccessTransaction()];case 18:t.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,F.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,O.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=t.sent(),this.successTransaction=e.isSuccess&&(null===(i=e.data)||void 0===i?void 0:i.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r;return t(this,(function(t){switch(t.label){case 0:return e=new G(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==Y.INFO&&this.step!==Y.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===g.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,j.saveCart({input:e})];case 3:if((null==(i=t.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:H.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(r=s.extensions)||void 0===r?void 0:r.code)?{type:H.CUSTOMER_ACCOUNT_DISABLED_ERROR}:{type:H.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(se,void 0,void 0,(function(){var e,s,n=this;return t(this,(function(t){return e=i,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),[2,e]}))}))},this.checkStocks=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===u.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=V.getStockLocationIds())||void 0===l?void 0:l.length)?V.getStockLocationIds():null,[4,N.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:H.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(p=null===(h=i.data)||void 0===h?void 0:h.lines)||void 0===p?void 0:p.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:H.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(se,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(se,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:e=0,s=i,t.label=1;case 1:return e<s.length?(n=s[e],[4,U.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.getAvailableShippingCountries({salesChannelId:V.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.getPickupStockLocationIds()?[4,N.listStockLocation({id:{in:V.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=t.sent()).isSuccess||!(null===(i=e.data)||void 0===i?void 0:i.length))return this.error={type:H.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,N.getAvailableStockLocations({lines:e.map((function(e){return new _(e)})),stockLocationIdList:V.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:H.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=se.shippingCountryIds)||void 0===e?void 0:e.length)||(se.error={type:H.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;se.deliveryMethod!==e&&("address"===e&&(se.checkout.stockLocationId=null,(null===(t=se.customerAddresses)||void 0===t?void 0:t.length)?se.onSelectedShippingAddressIdChange(se.customerAddresses[0].id||"-1"):(se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)),se.deliveryMethod=e,se.isErrorsVisible=!1)},this.initialStockCheck=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,o,a,c,d,u,l,h=this;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,i=V.getPaymentGateways().map((function(e){return e.id})),[4,N.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:e?void 0:{in:i},locale:V.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=t.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===Y.PAYMENT&&(n=n.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(o.iso2||"")})))),a=[],r(V.getPaymentGateways(),"order").forEach((function(e){var t=null==n?void 0:n.find((function(t){return t.id===e.id}));t&&a.push(t)})),this.paymentGateways=e?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===Y.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=T,d.src=L,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:U.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:H.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(se,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,N.retrieveInstallmentInfo(i)];case 1:return e=t.sent(),s=e.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var e;se.store.customerStore.customer?(null===(e=se.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=se.checkoutSettings,e.shippingZones=se.shippingZones})),se.checkout.customer=new C(se.store.customerStore.customer)):se.checkout.customer=new C(se.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones,se.checkout.billingAddress.countrySettings=se.countrySettings,se.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!se.isDigitalOnly)if(se.isInStoreDelivery)se.setCheckoutShippingAddressSettings();else if(se.checkout.shippingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedShippingAddressIdChange(e.id||"-1"),void se.setCheckoutShippingAddressSettings()}se.checkout.shippingAddress=new B(n(se.checkout.shippingAddress)||{}),se.setCheckoutShippingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else se.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(se.useDifferentAddress=!!localStorage.getItem("sAddr"),se.checkout.billingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedBillingAddressIdChange(e.id||"-1"),void se.setCheckoutBillingAddressSettings()}se.checkout.billingAddress=new B(n(se.checkout.billingAddress)||{}),se.setCheckoutBillingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())}else se.onSelectedBillingAddressIdChange("-1"),se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.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(e=t.sent())&&(this.checkout=new y(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return e(se,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(se,void 0,void 0,(function(){var e,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,j.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(e=t.sent()).isSuccess&&e.data?(s=e.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===Y.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,currencyCode:this.checkout.currencyCode}}),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,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new y(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),t.label=4;case 4:return e.isSuccess||(this.couponError=e.errorCodes[0]),[3,6];case 5:return t.sent(),[3,6];case 6:return[2]}}))}))},this.getAvailableShippingZones=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,K.getAvailableShippingZones({salesChannelId:V.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(se.selectedShippingAddressId=e,"-1"===e)se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.shippingAddress=new B(i),se.checkout.shippingAddress.countrySettings=se.countrySettings)}se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(se.selectedBillingAddressId=e,"-1"===e)se.checkout.billingAddress=new B,se.checkout.billingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.billingAddress=new B(i),se.checkout.billingAddress.countrySettings=se.countrySettings)}se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){se.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.cardNumber.length)||X(e))){var i=(se.cardData.cardNumber||"").split(" ").join(""),s=e.split(" ").join("");s.length>16||(i.length<6&&s.length>=6&&!se.installmentInfo?se.getRetrieveInstallmentInfo(s):s.length<6&&i.length>s.length&&(se.cardData.installmentCount=1,se.installmentInfo=void 0),(null===(t=se.installmentInfo)||void 0===t?void 0:t.cardAssociation)===M.AMERICAN_EXPRESS?se.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(s).join(" "):se.cardData.cardNumber=z(s,4).join(" "))}},this.getRetrieveInstallmentInfo=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,this.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return t.sent(),(null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){se.cardData&&(se.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.expirationDate.length)||X(e))){if(0===(null===(t=se.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(se.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(se.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(se.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(se.cardData.expirationDate=z(d,2).join(" / "))}},this.onCvcChange=function(e){if(se.cardData&&(!(e.length>se.cardData.cvv.length)||X(e))){if(se.installmentInfo){if(se.installmentInfo.cardAssociation===M.AMERICAN_EXPRESS&&e.length>4)return;if(se.installmentInfo.cardAssociation!==M.AMERICAN_EXPRESS&&e.length>3)return}else if(e.length>3)return;se.cardData.cvv=e}},this.saveAddress=function(s){return e(se,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,m,f,g=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new k(i(i({},e),{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:t.sent(),null===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){se.router.push("/cart")},this.onBackToShoppingClick=function(){se.router.push("/")},this.onGoToLoginClick=function(){se.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.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,t.label=1;case 1:return t.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:t.sent(),t.label=3;case 3:return[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(Y.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(Y.SHIPPING):this.changeStep(Y.PAYMENT),[3,7]);case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.changeStep(Y.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(Y.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!se.canPerformPayment||(se.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){se.error={type:e,data:t}},this.onCompletePaymentClick=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:t.sent(),t.label=5;case 5:return[4,this.saveCart()];case 6:return t.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:H.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.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 t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),[4,this.saveCart()];case 4:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return t.sent(),[3,7];case 6:return(i=t.sent()).type?this.error=i:this.error={type:H.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,u,l,p,m,f,g,v,y,S;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(l=this.cardData)||void 0===l?void 0:l.installmentCount)?[2]:[4,N.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,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)},metadata:{_fbp:Z("_fbp"),_fbc:Z("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,N.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===c.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===d.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=t.sent(),t.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,o=r&&[h.SUCCESS,h.AUTHORIZED].includes(r),a=r===h.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess((null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.orderId)||void 0)];case 6:return t.sent(),[3,8];case 7:if(!a||!(null===(S=null==s?void 0:s.data)||void 0===S?void 0:S.returnSlug))throw{data:s.firstErrorMessage,type:H.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(i){return e(se,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(Y.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){se.changeStep(Y.INFO)},this.onBackToShippingClick=function(){se.changeStep(Y.SHIPPING)},this.setCustomerConsentGranted=function(e){se.checkout.customer&&(se.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){se.useDifferentAddress=e,se.useDifferentAddress?(localStorage.setItem("sAddr","1"),se.checkout.billingAddress=se.checkout.billingAddress||new B,se.checkout.billingAddress.countrySettings=se.countrySettings):(localStorage.removeItem("sAddr"),se.checkout.billingAddress=se.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){se.shouldSaveAddress=e},this.setAddressTitle=function(e){se.addressTitle=e},this.reInitPaymentMethod=function(){return e(se,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,6];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},this.createStripePaymentIntent=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data?(this.stripeResponse=e.data,this.stripeError=null):this.stripeError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data?(this.klarnaResponse=e.data,this.klarnaError=null):this.klarnaError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.adyenResponse=e.data),[2]}}))}))},this.getPayPalClientId=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.payPalClientIdResponse=e.data),[2]}}))}))},this.setPaymentGateway=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||this.stripeResponse?[3,2]:[4,this.createStripePaymentIntent(e)]:[2];case 1:t.sent(),t.label=2;case 2:return"KLARNA"!==e.code||this.klarnaResponse?[3,4]:[4,this.createKlarnaClientToken(e)];case 3:t.sent(),t.label=4;case 4:return"ADYEN_PLATFORM"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenBalancePlatformPaymentSession(e)];case 5:t.sent(),t.label=6;case 6:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,8]:[4,this.getPayPalClientId(e)];case 7:t.sent(),t.label=8;case 8:return this.checkout.selectedPaymentGateway=e,this.step!==Y.SUCCESS&&(e.paymentMethodType===c.CREDIT_CARD&&e.type===d.INTERNAL&&(this.cardData=new R,e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(e){se.cardData&&(se.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(se,void 0,void 0,(function(){return t(this,(function(e){return W||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(se,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){se.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(se,void 0,void 0,(function(){var r,o,a=this;return t(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===p.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return e(a,void 0,void 0,(function(){var e,n,r,o,a,c,d,u,l;return t(this,(function(t){switch(t.label){case 0:return(e=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})))?(n=[e.productId],[4,x.searchProducts({input:{productIdList:n,priceListId:V.getPriceListId(),salesChannelId:V.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=t.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)?(o=r.data.data[0],(a=o.variants.filter((function(t){return t.hasStock&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){return e.discountAmount?new A(i(i({},t),{prices:t.prices.map((function(t){var s=t.finalPrice,n=t.finalPrice-t.finalPrice*e.discountAmount/100;return e.applicablePrice===v.SELL_PRICE&&(s=t.sellPrice,n=t.sellPrice-t.sellPrice*e.discountAmount/100),new I(i(i({},t),{sellPrice:s,discountPrice:n}))}))})):t}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new E(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:e,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===Y.SUCCESS?m.POST_CHECKOUT:m.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(se,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return i.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,j.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===Y.SUCCESS?Y.PAYMENT:this.step,null===(s=e.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=e.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:t.sent(),this.isCampaignOfferLoaded=!0,t.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(i){return e(se,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(t){switch(t.label){case 0:return this.checkout.customer?(e=this.checkout.customer,s=e.firstName,n=e.lastName,r=e.email,s&&n&&r?[4,O.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==f.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,N.listProductFile({id:{in:e}})]:[3,2];case 1:(i=t.sent()).isSuccess&&(this.productFiles=i.data||[]),t.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(i){return e(se,void 0,void 0,(function(){var e,s,n,r,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),(e=this.checkout.orderLineItems.find((function(e){return e.variant.id===i.variantId})))?[4,N.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})]:[3,2];case 1:s=t.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(i.name),r.click(),r.remove()),t.label=2;case 2:return[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=o,this.checkoutSettings=b,this.router=P,this.returnPolicy=q,this.privacyPolicy=Q,this.termsOfService=$,this.imprint=J,this.shippingPolicy=ee,this.t=te,this.customizationProps=ie,this.mpVM=new D,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new w({currentLocale:V.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(q.prototype,"merchantSettings",{get:function(){return new P(V.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=U.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"finalPrice",{get:function(){return this.step===Y.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===H.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==H.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"store",{get:function(){return U.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===c.CREDIT_CARD&&i.type===d.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===u.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddresses",{get:function(){var e,t,s,n=this,r=null===(e=V.getCurrentRouting())||void 0===e?void 0:e.countryCodes;return null===(s=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(e){var t=new b(i({countrySettings:n.countrySettings},e));return t.checkoutSettings=n.checkoutSettings,t.shippingZones=n.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===o.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===o.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isEPayKolayEnabled",{get:function(){var e=V.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPoweredByHidden",{get:function(){var e=V.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),q.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},q}();function z(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function X(e){return e&&q.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(Y||(Y={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR"}(H||(H={}));export{Y as CheckoutStep,H as ErrorType,Q as default};
1
+ import{__awaiter as e,__generator as t,__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{IkasCartCreatedBy as o,IkasCouponCodeRequirement as a,IkasPaymentMethodType as c,IkasPaymentGatewayType as d,IkasOrderShippingMethod as u,IkasOrderPaymentStatus as l,IkasTransactionStatus as h,IkasCartCampaignOfferStatus as p,IkasCampaignOfferTargetPageType as m,IkasOrderLineItemStatus as f,IkasCustomerEmailSubscriptionStatus as g,IkasCampaignOfferProductApplicablePriceEnum as v}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 y}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as S}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as k}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as b}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 P}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as C}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as I}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as A}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as E}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as w}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 R from"./components/credit-card-form/model.js";import O from"../../store/customer/api.js";import N from"../../store/checkout/index.js";import j from"../../store/cart/api.js";import D,{MFS_ELEMENT_ID as T,MFS_SCRIPT_URL as L}from"./modelMasterPass.js";import x from"../../store/product/index.js";import{TransactionCardAssociationEnum as M,SaveCartInput as G,CheckStocksLineInput as _}from"@ikas/storefront-api";import{IkasBaseStore as U}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as V}from"@ikas/storefront-config";import{Analytics as F}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import B from"../../models/data/order/address/ikas-localized-order-address.js";import K from"../../store/location/index.js";import{getCookieValue as Z}from"../../utils/helper.js";var Y,H,q=/^\d+$/,W="undefined"==typeof localStorage,Q=function(){function q(o,b,P,q,Q,$,J,ee,te,ie){var se=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=Y.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(se,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return e.sent(),[4,U.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 3:return e.sent(),[2]}}))}))},this.initStep=function(){return e(se,void 0,void 0,(function(){var e,s,n,r,o,c,d;return t(this,(function(t){switch(t.label){case 0:if(V.getIsEditor())return this.step=Y.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),s=e.get("step"),n=e.get("failed"),r=e.get("error"),s){if(this.step=s,this.step===Y.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(Y.INFO)];if(this.step!==Y.PAYMENT||this.canProceedToPayment){if(this.step===Y.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(Y.INFO)];if(![Y.INFO,Y.SUCCESS,Y.SHIPPING,Y.PAYMENT].includes(this.step))return[2,this.changeStep(Y.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(Y.INFO)]:[2,this.changeStep(Y.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:H.PAYMENT_ERROR,data:r||null}),this.step!==Y.SHIPPING&&this.step!==Y.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new S(i(i({},this.checkoutSettings),{couponCodeRequirement:a.DEFAULT}))),this.step!==Y.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:t.sent(),this.checkShippingCountries(),t.label=4;case 4:return[4,this.getStockLocations()];case 5:return t.sent(),[4,this.getAvailableStockLocations()];case 6:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=7;case 7:return this.step!==Y.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=Y.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==Y.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==Y.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==Y.PAYMENT&&this.step!==Y.SUCCESS?[3,13]:[4,this.listPaymentGateways()];case 10:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,12];case 11:t.sent(),t.label=12;case 12:if(!this.paymentGateways.length)return this.error={type:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===Y.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(Y.SUCCESS)]:[3,14];case 14:return[4,this.initialStockCheck()];case 15:t.sent(),t.label=16;case 16:return[3,19];case 17:return[4,this.getSuccessTransaction()];case 18:t.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,F.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,O.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=t.sent(),this.successTransaction=e.isSuccess&&(null===(i=e.data)||void 0===i?void 0:i.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r;return t(this,(function(t){switch(t.label){case 0:return e=new G(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==Y.INFO&&this.step!==Y.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===g.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,j.saveCart({input:e})];case 3:if((null==(i=t.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:H.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(r=s.extensions)||void 0===r?void 0:r.code)?{type:H.CUSTOMER_ACCOUNT_DISABLED_ERROR}:{type:H.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(se,void 0,void 0,(function(){var e,s,n=this;return t(this,(function(t){return e=i,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),[2,e]}))}))},this.checkStocks=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===u.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=V.getStockLocationIds())||void 0===l?void 0:l.length)?V.getStockLocationIds():null,[4,N.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:H.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(p=null===(h=i.data)||void 0===h?void 0:h.lines)||void 0===p?void 0:p.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:H.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(se,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(se,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:e=0,s=i,t.label=1;case 1:return e<s.length?(n=s[e],[4,U.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.getAvailableShippingCountries({salesChannelId:V.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.getPickupStockLocationIds()?[4,N.listStockLocation({id:{in:V.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=t.sent()).isSuccess||!(null===(i=e.data)||void 0===i?void 0:i.length))return this.error={type:H.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,N.getAvailableStockLocations({lines:e.map((function(e){return new _(e)})),stockLocationIdList:V.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:H.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=se.shippingCountryIds)||void 0===e?void 0:e.length)||(se.error={type:H.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;se.deliveryMethod!==e&&("address"===e&&(se.checkout.stockLocationId=null,(null===(t=se.customerAddresses)||void 0===t?void 0:t.length)?se.onSelectedShippingAddressIdChange(se.customerAddresses[0].id||"-1"):(se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)),se.deliveryMethod=e,se.isErrorsVisible=!1)},this.initialStockCheck=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,o,a,c,d,u,l,h=this;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,i=V.getPaymentGateways().map((function(e){return e.id})),[4,N.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:e?void 0:{in:i},locale:V.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=t.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===Y.PAYMENT&&(n=n.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(o.iso2||"")})))),a=[],r(V.getPaymentGateways(),"order").forEach((function(e){var t=null==n?void 0:n.find((function(t){return t.id===e.id}));t&&a.push(t)})),this.paymentGateways=e?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===Y.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=T,d.src=L,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:U.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:H.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(se,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,N.retrieveInstallmentInfo(i)];case 1:return e=t.sent(),s=e.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var e;se.store.customerStore.customer?(null===(e=se.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=se.checkoutSettings,e.shippingZones=se.shippingZones})),se.checkout.customer=new C(se.store.customerStore.customer)):se.checkout.customer=new C(se.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones,se.checkout.billingAddress.countrySettings=se.countrySettings,se.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!se.isDigitalOnly)if(se.isInStoreDelivery)se.setCheckoutShippingAddressSettings();else if(se.checkout.shippingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedShippingAddressIdChange(e.id||"-1"),void se.setCheckoutShippingAddressSettings()}se.checkout.shippingAddress=new B(n(se.checkout.shippingAddress)||{}),se.setCheckoutShippingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else se.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(se.useDifferentAddress=!!localStorage.getItem("sAddr"),se.checkout.billingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedBillingAddressIdChange(e.id||"-1"),void se.setCheckoutBillingAddressSettings()}se.checkout.billingAddress=new B(n(se.checkout.billingAddress)||{}),se.setCheckoutBillingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())}else se.onSelectedBillingAddressIdChange("-1"),se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.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(e=t.sent())&&(this.checkout=new y(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return e(se,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(se,void 0,void 0,(function(){var e,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,j.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(e=t.sent()).isSuccess&&e.data?(s=e.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===Y.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,currencyCode:this.checkout.currencyCode}}),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,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new y(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),t.label=4;case 4:return e.isSuccess||(this.couponError=e.errorCodes[0]),[3,6];case 5:return t.sent(),[3,6];case 6:return[2]}}))}))},this.getAvailableShippingZones=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,K.getAvailableShippingZones({salesChannelId:V.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(se.selectedShippingAddressId=e,"-1"===e)se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.shippingAddress=new B(i),se.checkout.shippingAddress.countrySettings=se.countrySettings)}se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(se.selectedBillingAddressId=e,"-1"===e)se.checkout.billingAddress=new B,se.checkout.billingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.billingAddress=new B(i),se.checkout.billingAddress.countrySettings=se.countrySettings)}se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){se.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.cardNumber.length)||X(e))){var i=(se.cardData.cardNumber||"").split(" ").join(""),s=e.split(" ").join("");s.length>16||(i.length<6&&s.length>=6&&!se.installmentInfo?se.getRetrieveInstallmentInfo(s):s.length<6&&i.length>s.length&&(se.cardData.installmentCount=1,se.installmentInfo=void 0),(null===(t=se.installmentInfo)||void 0===t?void 0:t.cardAssociation)===M.AMERICAN_EXPRESS?se.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(s).join(" "):se.cardData.cardNumber=z(s,4).join(" "))}},this.getRetrieveInstallmentInfo=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,this.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return t.sent(),(null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){se.cardData&&(se.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.expirationDate.length)||X(e))){if(0===(null===(t=se.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(se.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(se.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(se.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(se.cardData.expirationDate=z(d,2).join(" / "))}},this.onCvcChange=function(e){if(se.cardData&&(!(e.length>se.cardData.cvv.length)||X(e))){if(se.installmentInfo){if(se.installmentInfo.cardAssociation===M.AMERICAN_EXPRESS&&e.length>4)return;if(se.installmentInfo.cardAssociation!==M.AMERICAN_EXPRESS&&e.length>3)return}else if(e.length>3)return;se.cardData.cvv=e}},this.saveAddress=function(s){return e(se,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,m,f,g=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new k(i(i({},e),{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:t.sent(),null===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){se.router.push("/cart")},this.onBackToShoppingClick=function(){se.router.push("/")},this.onGoToLoginClick=function(){se.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.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,t.label=1;case 1:return t.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:t.sent(),t.label=3;case 3:return[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(Y.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(Y.SHIPPING):this.changeStep(Y.PAYMENT),[3,7]);case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.changeStep(Y.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(Y.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!se.canPerformPayment||(se.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){se.error={type:e,data:t}},this.onCompletePaymentClick=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:t.sent(),t.label=5;case 5:return[4,this.saveCart()];case 6:return t.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:H.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.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 t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),[4,this.saveCart()];case 4:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return t.sent(),[3,7];case 6:return(i=t.sent()).type?this.error=i:this.error={type:H.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,u,l,p,m,f,g,v,y,S;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(l=this.cardData)||void 0===l?void 0:l.installmentCount)?[2]:[4,N.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,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)},metadata:{_fbp:Z("_fbp"),_fbc:Z("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,N.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===c.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===d.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=t.sent(),t.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,o=r&&[h.SUCCESS,h.AUTHORIZED].includes(r),a=r===h.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess((null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.orderId)||void 0)];case 6:return t.sent(),[3,8];case 7:if(!a||!(null===(S=null==s?void 0:s.data)||void 0===S?void 0:S.returnSlug))throw{data:s.firstErrorMessage,type:H.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(i){return e(se,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(Y.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){se.changeStep(Y.INFO)},this.onBackToShippingClick=function(){se.changeStep(Y.SHIPPING)},this.setCustomerConsentGranted=function(e){se.checkout.customer&&(se.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){se.useDifferentAddress=e,se.useDifferentAddress?(localStorage.setItem("sAddr","1"),se.checkout.billingAddress=se.checkout.billingAddress||new B,se.checkout.billingAddress.countrySettings=se.countrySettings):(localStorage.removeItem("sAddr"),se.checkout.billingAddress=new B(i({},se.checkout.shippingAddress)))},this.setShouldSaveAddress=function(e){se.shouldSaveAddress=e},this.setAddressTitle=function(e){se.addressTitle=e},this.reInitPaymentMethod=function(){return e(se,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,6];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},this.createStripePaymentIntent=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data?(this.stripeResponse=e.data,this.stripeError=null):this.stripeError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data?(this.klarnaResponse=e.data,this.klarnaError=null):this.klarnaError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.adyenResponse=e.data),[2]}}))}))},this.getPayPalClientId=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.payPalClientIdResponse=e.data),[2]}}))}))},this.setPaymentGateway=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||this.stripeResponse?[3,2]:[4,this.createStripePaymentIntent(e)]:[2];case 1:t.sent(),t.label=2;case 2:return"KLARNA"!==e.code||this.klarnaResponse?[3,4]:[4,this.createKlarnaClientToken(e)];case 3:t.sent(),t.label=4;case 4:return"ADYEN_PLATFORM"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenBalancePlatformPaymentSession(e)];case 5:t.sent(),t.label=6;case 6:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,8]:[4,this.getPayPalClientId(e)];case 7:t.sent(),t.label=8;case 8:return this.checkout.selectedPaymentGateway=e,this.step!==Y.SUCCESS&&(e.paymentMethodType===c.CREDIT_CARD&&e.type===d.INTERNAL&&(this.cardData=new R,e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(e){se.cardData&&(se.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(se,void 0,void 0,(function(){return t(this,(function(e){return W||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(se,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){se.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(se,void 0,void 0,(function(){var r,o,a=this;return t(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===p.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return e(a,void 0,void 0,(function(){var e,n,r,o,a,c,d,u,l;return t(this,(function(t){switch(t.label){case 0:return(e=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})))?(n=[e.productId],[4,x.searchProducts({input:{productIdList:n,priceListId:V.getPriceListId(),salesChannelId:V.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=t.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)?(o=r.data.data[0],(a=o.variants.filter((function(t){return t.hasStock&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){return e.discountAmount?new A(i(i({},t),{prices:t.prices.map((function(t){var s=t.finalPrice,n=t.finalPrice-t.finalPrice*e.discountAmount/100;return e.applicablePrice===v.SELL_PRICE&&(s=t.sellPrice,n=t.sellPrice-t.sellPrice*e.discountAmount/100),new I(i(i({},t),{sellPrice:s,discountPrice:n}))}))})):t}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new E(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:e,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===Y.SUCCESS?m.POST_CHECKOUT:m.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(se,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return i.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,j.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===Y.SUCCESS?Y.PAYMENT:this.step,null===(s=e.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=e.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:t.sent(),this.isCampaignOfferLoaded=!0,t.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(i){return e(se,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(t){switch(t.label){case 0:return this.checkout.customer?(e=this.checkout.customer,s=e.firstName,n=e.lastName,r=e.email,s&&n&&r?[4,O.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==f.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,N.listProductFile({id:{in:e}})]:[3,2];case 1:(i=t.sent()).isSuccess&&(this.productFiles=i.data||[]),t.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(i){return e(se,void 0,void 0,(function(){var e,s,n,r,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),(e=this.checkout.orderLineItems.find((function(e){return e.variant.id===i.variantId})))?[4,N.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})]:[3,2];case 1:s=t.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(i.name),r.click(),r.remove()),t.label=2;case 2:return[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=o,this.checkoutSettings=b,this.router=P,this.returnPolicy=q,this.privacyPolicy=Q,this.termsOfService=$,this.imprint=J,this.shippingPolicy=ee,this.t=te,this.customizationProps=ie,this.mpVM=new D,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new w({currentLocale:V.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(q.prototype,"merchantSettings",{get:function(){return new P(V.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=U.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"finalPrice",{get:function(){return this.step===Y.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===H.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==H.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"store",{get:function(){return U.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===c.CREDIT_CARD&&i.type===d.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===u.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddresses",{get:function(){var e,t,s,n=this,r=null===(e=V.getCurrentRouting())||void 0===e?void 0:e.countryCodes;return null===(s=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(e){var t=new b(i({countrySettings:n.countrySettings},e));return t.checkoutSettings=n.checkoutSettings,t.shippingZones=n.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===o.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===o.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isEPayKolayEnabled",{get:function(){var e=V.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPoweredByHidden",{get:function(){var e=V.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),q.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},q}();function z(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function X(e){return e&&q.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(Y||(Y={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR"}(H||(H={}));export{Y as CheckoutStep,H as ErrorType,Q as default};
@@ -1 +1 @@
1
- import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import i from"next/head.js";import{useRouter as a}from"next/router";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as 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/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductList as s}from"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as c}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var l=o((function(o){var s,l,g,v=o.pageType,f=o.pageTitle,h=o.pageDescription,j=o.canonicals,x=o.disableIndex,y=o.pageSpecificData,b=o.merchantSettings,C=o.addOgpMetas,k=o.productReviewSummary,D=o.pageComponentPropValues,T=a(),w="undefined"!=typeof window,L="local"===process.env.NEXT_PUBLIC_ENV,P=T.asPath.split("?")[0].replace("/",""),E=(P="/"===P.charAt(P.length-1)?P.slice(0,-1):P).startsWith("pages/"),R=d.getCurrentRouting(),O=(null==R?void 0:R.path)?"/"+R.path:"",_=L?"http://localhost:3333":"https://"+d.getDomain(),I=null===(s=d.getIndexPageSeoSettings())||void 0===s?void 0:s.find((function(e){return e.locale===d.getCurrentLocale()})),S=I?new n(I):null;t.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[v,y]);var V=t.useMemo((function(){if(y&&y.href)return"".concat(_).concat(y.href)}),[y]),A=t.useMemo((function(){var e,t,o=[];if(C){if(o.push({property:"og:type",content:"website"}),o.push({property:"og:site_name",content:"https://"+d.getDomain()}),f&&o.push({property:"og:title",content:f}),h&&o.push({property:"og:description",content:h}),v===r.INDEX){var i=null,a=null;!f&&(null==S?void 0:S.pageTitle)&&(i=S.pageTitle),!h&&(null==S?void 0:S.description)&&(a=S.description);var n=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));n&&(i=u(y,v,n.titleTemplate||""),a=u(y,v,n.descriptionTemplate||"")),i&&o.push({property:"og:title",content:i}),a&&o.push({property:"og:description",content:a})}if(o.push({property:"og:url",content:V||(w?window.location.href:"")||"https://".concat(d.getDomain())}),y&&v===r.PRODUCT){var s=y.selectedVariant.mainImage;(null==s?void 0:s.image)&&o.push({property:"og:image",content:s.image.src.replace(".webp",".jpg")})}else(null==S?void 0:S.icon)?o.push({property:"og:image",content:null===(t=null==S?void 0:S.icon)||void 0===t?void 0:t.src.replace(".webp",".jpg")}):(null==b?void 0:b.logo)&&o.push({property:"og:image",content:b.logo.src.replace(".webp",".jpg")});if(y&&v===r.CATEGORY){var c=y;c.image&&o.push({property:"og:image",content:c.image.src.replace(".webp",".jpg")})}if(y&&v===r.BRAND){var l=y;l.image&&o.push({property:"og:image",content:l.image.src.replace(".webp",".jpg")})}}return o}),[f,y,V,h,b,C,b]),N=t.useMemo((function(){var t=[];if(b){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},i=function(t){var o,i,a,r,n,s,c=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:c,image:c,url:"https://"+d.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=t.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(s=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===s?void 0:s.code})}}(b);t.push(o),t.push(i)}if(y&&v===r.PRODUCT){var a=y,n=function(t,o){var i,a,r,n,s;try{var c=d.getCurrentRouting(),l=null==c?void 0:c.path,m=function(e){return l?"https://".concat(d.getDomain(),"/").concat(l).concat(e):"https://".concat(d.getDomain()).concat(e)},p=t.selectedVariant;return e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:null===(i=t.metaData)||void 0===i?void 0:i.description,image:null===(a=p.images)||void 0===a?void 0:a.map((function(e){return e.image?e.image.src:""})),productId:p.id,sku:p.sku,mpn:(null===(r=p.barcodeList)||void 0===r?void 0:r.length)?p.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(n=t.brand)||void 0===n?void 0:n.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:m(t.href),priceCurrency:p.price.currency||"TRY",price:(null!==(s=p.campaignPrice)&&void 0!==s?s:p.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:p.stock>0||p.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(e){}}(a,k||null);if(n&&t.push(n),a.categories.length)(c=m(a.categories[0],a))&&t.push(c)}if(y&&v===r.CATEGORY){var s=function(e){var t,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,r=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)};return{"@context":"http://schema.org","@type":"CollectionPage",url:r(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(y),c=m(y),l=p(D);s&&t.push(s),c&&t.push(c),l&&t.push(l)}y&&v===r.BRAND&&((l=p(D))&&t.push(l));if(y&&v===r.BLOG){var u=function(t){var o;try{var i="https://".concat(d.getDomain()).concat(t.href),a=function(e){var t=new Date(e),o=t.getFullYear(),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(i,"-").concat(a)},r="".concat(t.writer.firstName," ").concat(t.writer.lastName),n=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:i,datePublished:a(t.createdAt),dateCreated:a(t.createdAt),dateModified:a(t.updatedAt),description:t.shortDescription,articleBody:n,author:{"@type":"Person",name:r}})}catch(e){}}(y);u&&t.push(u)}return t}),[y,b]),M=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.titleTemplate||""):null}),[v,y]),B=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.descriptionTemplate||""):null}),[v,y]),U=t.useMemo((function(){var e,t=null===(e=d.getFavicon())||void 0===e?void 0:e.id;return(null==S?void 0:S.favIcon)&&(t=S.favIcon),t||null}),[]),F=t.useCallback((function(){var e=d.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),G=[];d.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){G.push({routing:e,hrefLang:e.locale+"-"+t})})):G.push({routing:e,hrefLang:e.locale})}));var Y=function(e){var t,o,i,a,r,n=y,s=null===(o=null===(t=null==n?void 0:n.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));if(s&&(null==s?void 0:s.slug))return s.slug;var d=G.find((function(e){return!e.routing.path}));return d&&(null===(r=null===(a=null===(i=null==n?void 0:n.metaData)||void 0===i?void 0:i.translations)||void 0===a?void 0:a.find((function(e){return e.locale===d.routing.locale})))||void 0===r?void 0:r.slug)||""},H=c.getInstance();return t.createElement(i,null,t.createElement("title",null,f||M||(null==S?void 0:S.pageTitle)||""),t.createElement("meta",{name:"description",content:h||B||(null==S?void 0:S.description)||""}),v===r.CHECKOUT&&F()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(l=d.getApiUrl())||void 0===l?void 0:l.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(g=d.getApiUrl())||void 0===g?void 0:g.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),G.length>1&&G.filter((function(e){return!E||e.routing.id===(null==R?void 0:R.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(_+(e.routing.path?"/"+e.routing.path:""),"/").concat(Y(e.routing))})})),!!x&&t.createElement("meta",{name:"robots",content:"noindex"}),!!C&&A.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!j&&j.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(_).concat(O).concat(e)})})),U&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(U,"/image_180.webp"),type:"image/webp"}),!j&&H.currentPageType!==r.NOT_FOUND&&t.createElement("link",{rel:"canonical",href:"".concat(_).concat(O,"/").concat(P)}),!!N.length&&N.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function m(e,t){try{var o=c.getInstance(),i=d.getCurrentRouting(),a=null==i?void 0:i.path,n=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)},s=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:n(e.href)}}));return s.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:n(e.href)}),o.currentPageType===r.PRODUCT&&t&&s.push({"@type":"ListItem",position:s.length+1,name:t.name,item:n(t.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:s}}catch(e){}}function p(e){try{var t=d.getCurrentRouting(),o=null==t?void 0:t.path;if(e){var i=(e.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[]).find((function(e){return Object.values(e.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(e,t){var i,a,r,n;return{"@type":"ListItem",position:t+1,item:{"@type":"Product",name:e.name,image:(null===(a=null===(i=e.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(n=e.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(n):"https://".concat(d.getDomain()).concat(n)),priceCurrency:e.selectedVariant.price.currency||"TRY",price:(null!==(r=e.selectedVariant.campaignPrice)&&void 0!==r?r:e.selectedVariant.finalPrice).toFixed(2)}}}}))}}}}catch(e){}}function u(e,t,o){var i,a,n=o;try{switch(t){case r.PRODUCT:var s=e,d=s.name,c=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",l=s.selectedVariant.sku||"",m=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",p=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;n.includes("{{name}}")&&(n=g(n,"{{name}}",d)),n.includes("{{brand}}")&&(n=g(n,"{{brand}}",c)),n.includes("{{sku}}")&&(n=g(n,"{{sku}}",l)),n.includes("{{barcode}}")&&(n=g(n,"{{barcode}}",m)),n.includes("{{price}}")&&(n=g(n,"{{price}}",p.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var u=e.name||"";n.includes("{{name}}")&&(n=g(n,"{{name}}",u));break;case r.BLOG:var v=e.title;n.includes("{{name}}")&&(n=g(n,"{{name}}",v))}}catch(e){}return n.trimEnd()}function g(e,t,o){var i=new RegExp(t,"g");return e.replace(i,o)}export{l as IkasPageHead};
1
+ import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import i from"next/head.js";import{useRouter as a}from"next/router";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as 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/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductList as s}from"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as c}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var l=o((function(o){var s,l,g,v=o.pageType,f=o.pageTitle,h=o.pageDescription,j=o.canonicals,x=o.disableIndex,y=o.pageSpecificData,b=o.merchantSettings,C=o.addOgpMetas,k=o.productReviewSummary,D=o.pageComponentPropValues,T=a(),w="undefined"!=typeof window,L="local"===process.env.NEXT_PUBLIC_ENV,P=T.asPath.split("?")[0].replace("/",""),E=(P="/"===P.charAt(P.length-1)?P.slice(0,-1):P).startsWith("pages/"),R=d.getCurrentRouting(),O=(null==R?void 0:R.path)?"/"+R.path:"",_=L?"http://localhost:3333":"https://"+d.getDomain(),I=null===(s=d.getIndexPageSeoSettings())||void 0===s?void 0:s.find((function(e){return e.locale===d.getCurrentLocale()})),S=I?new n(I):null;t.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[v,y]);var V=t.useMemo((function(){if(y&&y.href)return"".concat(_).concat(y.href)}),[y]),A=t.useMemo((function(){var e,t,o=[];if(C){if(o.push({property:"og:type",content:"website"}),o.push({property:"og:site_name",content:"https://"+d.getDomain()}),f&&o.push({property:"og:title",content:f}),h&&o.push({property:"og:description",content:h}),v===r.INDEX){var i=null,a=null;!f&&(null==S?void 0:S.pageTitle)&&(i=S.pageTitle),!h&&(null==S?void 0:S.description)&&(a=S.description);var n=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));n&&(i=u(y,v,n.titleTemplate||""),a=u(y,v,n.descriptionTemplate||"")),i&&o.push({property:"og:title",content:i}),a&&o.push({property:"og:description",content:a})}if(o.push({property:"og:url",content:V||(w?window.location.href:"")||"https://".concat(d.getDomain())}),y&&v===r.PRODUCT){var s=y.selectedVariant.mainImage;(null==s?void 0:s.image)&&o.push({property:"og:image",content:s.image.src.replace(".webp",".jpg")})}else(null==S?void 0:S.icon)?o.push({property:"og:image",content:null===(t=null==S?void 0:S.icon)||void 0===t?void 0:t.src.replace(".webp",".jpg")}):(null==b?void 0:b.logo)&&o.push({property:"og:image",content:b.logo.src.replace(".webp",".jpg")});if(y&&v===r.CATEGORY){var c=y;c.image&&o.push({property:"og:image",content:c.image.src.replace(".webp",".jpg")})}if(y&&v===r.BRAND){var l=y;l.image&&o.push({property:"og:image",content:l.image.src.replace(".webp",".jpg")})}}return o}),[f,y,V,h,b,C,b]),N=t.useMemo((function(){var t=[];if(b){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},i=function(t){var o,i,a,r,n,s,c=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:c,image:c,url:"https://"+d.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=t.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(s=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===s?void 0:s.code})}}(b);t.push(o),t.push(i)}if(y&&v===r.PRODUCT){var a=y,n=function(t,o){var i,a,r,n,s;try{var c=d.getCurrentRouting(),l=null==c?void 0:c.path,m=function(e){return l?"https://".concat(d.getDomain(),"/").concat(l).concat(e):"https://".concat(d.getDomain()).concat(e)},p=t.selectedVariant;return e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:null===(i=t.metaData)||void 0===i?void 0:i.description,image:null===(a=p.images)||void 0===a?void 0:a.map((function(e){return e.image?e.image.src:""})),productId:p.id,sku:p.sku,mpn:(null===(r=p.barcodeList)||void 0===r?void 0:r.length)?p.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(n=t.brand)||void 0===n?void 0:n.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:m(t.href),priceCurrency:p.price.currency||"TRY",price:(null!==(s=p.campaignPrice)&&void 0!==s?s:p.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:p.stock>0||p.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(e){}}(a,k||null);if(n&&t.push(n),a.categories.length)(c=m(a.categories[0],a))&&t.push(c)}if(y&&v===r.CATEGORY){var s=function(e){var t,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,r=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)};return{"@context":"http://schema.org","@type":"CollectionPage",url:r(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(y),c=m(y),l=p(D);s&&t.push(s),c&&t.push(c),l&&t.push(l)}y&&v===r.BRAND&&((l=p(D))&&t.push(l));if(y&&v===r.BLOG){var u=function(t){var o;try{var i="https://".concat(d.getDomain()).concat(t.href),a=function(e){var t=new Date(e),o=t.getFullYear(),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(i,"-").concat(a)},r="".concat(t.writer.firstName," ").concat(t.writer.lastName),n=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:i,datePublished:a(t.createdAt),dateCreated:a(t.createdAt),dateModified:a(t.updatedAt),description:t.shortDescription,articleBody:n,author:{"@type":"Person",name:r}})}catch(e){}}(y);u&&t.push(u)}return t}),[y,b]),M=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.titleTemplate||""):null}),[v,y]),B=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.descriptionTemplate||""):null}),[v,y]),U=t.useMemo((function(){return!d.getFavicon()&&(null==S?void 0:S.favIcon)?S.favIcon:null}),[]),F=t.useCallback((function(){var e=d.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),G=[];d.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){G.push({routing:e,hrefLang:e.locale+"-"+t})})):G.push({routing:e,hrefLang:e.locale})}));var Y=function(e){var t,o,i,a,r,n=y,s=null===(o=null===(t=null==n?void 0:n.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));if(s&&(null==s?void 0:s.slug))return s.slug;var d=G.find((function(e){return!e.routing.path}));return d&&(null===(r=null===(a=null===(i=null==n?void 0:n.metaData)||void 0===i?void 0:i.translations)||void 0===a?void 0:a.find((function(e){return e.locale===d.routing.locale})))||void 0===r?void 0:r.slug)||""},H=c.getInstance();return t.createElement(i,null,t.createElement("title",null,f||M||(null==S?void 0:S.pageTitle)||""),t.createElement("meta",{name:"description",content:h||B||(null==S?void 0:S.description)||""}),v===r.CHECKOUT&&F()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(l=d.getApiUrl())||void 0===l?void 0:l.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(g=d.getApiUrl())||void 0===g?void 0:g.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),G.length>1&&G.filter((function(e){return!E||e.routing.id===(null==R?void 0:R.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(_+(e.routing.path?"/"+e.routing.path:""),"/").concat(Y(e.routing))})})),!!x&&t.createElement("meta",{name:"robots",content:"noindex"}),!!C&&A.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!j&&j.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(_).concat(O).concat(e)})})),U&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(U,"/image_180.webp"),type:"image/webp"}),!j&&H.currentPageType!==r.NOT_FOUND&&t.createElement("link",{rel:"canonical",href:"".concat(_).concat(O,"/").concat(P)}),!!N.length&&N.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function m(e,t){try{var o=c.getInstance(),i=d.getCurrentRouting(),a=null==i?void 0:i.path,n=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)},s=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:n(e.href)}}));return s.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:n(e.href)}),o.currentPageType===r.PRODUCT&&t&&s.push({"@type":"ListItem",position:s.length+1,name:t.name,item:n(t.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:s}}catch(e){}}function p(e){try{var t=d.getCurrentRouting(),o=null==t?void 0:t.path;if(e){var i=(e.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[]).find((function(e){return Object.values(e.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(e,t){var i,a,r,n;return{"@type":"ListItem",position:t+1,item:{"@type":"Product",name:e.name,image:(null===(a=null===(i=e.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(n=e.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(n):"https://".concat(d.getDomain()).concat(n)),priceCurrency:e.selectedVariant.price.currency||"TRY",price:(null!==(r=e.selectedVariant.campaignPrice)&&void 0!==r?r:e.selectedVariant.finalPrice).toFixed(2)}}}}))}}}}catch(e){}}function u(e,t,o){var i,a,n=o;try{switch(t){case r.PRODUCT:var s=e,d=s.name,c=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",l=s.selectedVariant.sku||"",m=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",p=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;n.includes("{{name}}")&&(n=g(n,"{{name}}",d)),n.includes("{{brand}}")&&(n=g(n,"{{brand}}",c)),n.includes("{{sku}}")&&(n=g(n,"{{sku}}",l)),n.includes("{{barcode}}")&&(n=g(n,"{{barcode}}",m)),n.includes("{{price}}")&&(n=g(n,"{{price}}",p.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var u=e.name||"";n.includes("{{name}}")&&(n=g(n,"{{name}}",u));break;case r.BLOG:var v=e.title;n.includes("{{name}}")&&(n=g(n,"{{name}}",v))}}catch(e){}return n.trimEnd()}function g(e,t,o){var i=new RegExp(t,"g");return e.replace(i,o)}export{l as IkasPageHead};
@@ -1,10 +1,12 @@
1
1
  import { IkasProductGroup as IProductGroup } from "@ikas/storefront-models";
2
+ import { IkasProductGroupOrder } from "./order";
2
3
  import { IkasProductGroupTranslation } from "./translation";
3
4
  import { IkasProductGroupValue } from "./value";
4
5
  export declare class IkasProductGroup implements IProductGroup {
5
6
  groupKey: string;
6
7
  id: string;
7
8
  name: string;
9
+ order?: IkasProductGroupOrder | null;
8
10
  translations?: IkasProductGroupTranslation[] | null;
9
11
  values: IkasProductGroupValue[];
10
12
  constructor(data: IProductGroup);
@@ -1 +1 @@
1
- import{IkasProductGroupTranslation as n}from"./translation/index.js";import{IkasProductGroupValue as i}from"./value/index.js";var t=function(t){var r;this.groupKey=t.groupKey,this.id=t.id,this.name=t.name,this.translations=(null===(r=t.translations)||void 0===r?void 0:r.map((function(i){return new n(i)})))||null,this.values=t.values.map((function(n){return new i(n)}))};export{t as IkasProductGroup};
1
+ import{IkasProductGroupOrder as r}from"./order/index.js";import{IkasProductGroupTranslation as n}from"./translation/index.js";import{IkasProductGroupValue as i}from"./value/index.js";var o=function(o){var t;this.groupKey=o.groupKey,this.id=o.id,this.name=o.name,this.order=o.order?new r(o.order):null,this.translations=(null===(t=o.translations)||void 0===t?void 0:t.map((function(r){return new n(r)})))||null,this.values=o.values.map((function(r){return new i(r)}))};export{o as IkasProductGroup};
@@ -0,0 +1,6 @@
1
+ import { IkasProductGroupOrder as IProductGroupOrder } from "@ikas/storefront-models";
2
+ export declare class IkasProductGroupOrder implements IProductGroupOrder {
3
+ orderAttributeId: string;
4
+ value: string;
5
+ constructor(data: IProductGroupOrder);
6
+ }
@@ -0,0 +1 @@
1
+ var t=function(t){this.orderAttributeId=t.orderAttributeId,this.value=t.value};export{t as IkasProductGroupOrder};
@@ -18,6 +18,7 @@ import { IkasProductCampaignOffer } from "./campaign-offer";
18
18
  import { IkasProductOffer } from "./campaign-offer";
19
19
  import { IkasProductGroup } from "./group";
20
20
  import { IkasProductGroupValue } from "./group/value";
21
+ import { IkasProductGroupOrder } from "./group/order";
21
22
  import { IkasImage } from "../image";
22
23
  import { IkasProductSalesChannel } from "./sales-channel";
23
24
  export declare class IkasProduct implements IProduct {
@@ -100,6 +101,7 @@ export declare type IkasProductGroupItem = {
100
101
  image: IkasImage | null;
101
102
  href: string;
102
103
  groupValues: IkasProductGroupValue[];
104
+ order: IkasProductGroupOrder;
103
105
  };
104
106
  export declare type IkasDisplayedProductGroup = {
105
107
  name: string;
@@ -1 +1 @@
1
- import{__spreadArray as t,__assign as e,__awaiter as n,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as u}from"./variant/index.js";import{IkasProductAttributeValue as s}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductType as f}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as h}from"./option-set/index.js";import{makeObservable as v,observable as m,computed as g}from"mobx";import{IkasProductFunctions as b}from"@ikas/storefront-model-functions";import{IkasProductCampaign as V}from"./campaign/index.js";import{IkasStorefrontConfig as y}from"@ikas/storefront-config";import{IkasBaseStore as P}from"../../../store/base.js";import I from"lodash/groupBy";import{IkasProductBaseUnit as O}from"./base-unit/index.js";import{formatCurrency as w}from"../../../utils/currency.js";import"lodash/get";import S from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as T}from"./star/index.js";import{IkasProductCampaignOffer as C,IkasProductOffer as x}from"./campaign-offer/index.js";import{IkasProductGroup as k}from"./group/index.js";import{IkasImage as E}from"../image/index.js";import{IkasProductSalesChannel as A}from"./sales-channel/index.js";var G=function(){function G(b){void 0===b&&(b={});var I,E,L,R=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.selectVariantValue=function(n,i){var r,a=R.metaData,o=R.selectedVariantValues.map((function(t){return t.variantTypeId===n.variantTypeId?n:t})),u=R.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(u)R.selectedVariantValues=o;else{var s=R.variantTypes.findIndex((function(t){return t.variantType.id===n.variantTypeId}));if(s>0){var c=R.variantTypes.slice(0,s),d=R.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[n],!1);u=R.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(u=R.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(u=R.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===n.id}))})))}if(!u)return;R.selectedVariantValues=u.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,n){var i;"vid"!==n&&(f=e(e({},f),((i={})[n]=t,i)))})),R.variantTypes.map((function(t){delete f[t.variantType.slug]}));var h=t(t([],R.variantTypes.map((function(t){var e=t.variantType,n=e.values.find((function(t){return R.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(n)return"".concat(e.slug,"=").concat(n.slug)})),!0),Object.entries(f).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})),!0).filter((function(t){return!!t})).join("&");if(!i){var v="/".concat(a.slug);if(h&&(v="/".concat(a.slug,"?").concat(h)),v===window.location.pathname)return;null===(r=P.getInstance().router)||void 0===r||r.replace(v,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,n,i=t.price;if(i.unitPrice&&R.baseUnit){var r=R.baseUnit.baseAmount,a=(null===(n=null===(e=R.baseUnit)||void 0===e?void 0:e.unit)||void 0===n?void 0:n.name)||"";return"".concat(w(i.unitPrice,i.currency||"",i.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return n(R,void 0,void 0,(function(){var t,e,n,r,a,o=this;return i(this,(function(i){switch(i.label){case 0:return t=P.getInstance(),e=t.customerStore.customer,n=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,S.getProductCampaigns({input:{customerGroupIds:n,salesChannelId:y.getSalesChannelId()||"",variantIds:r}})];case 1:return a=i.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var n;t.variantIds.some((function(t){return t===e.id}))&&(null===(n=e.campaigns)||void 0===n||n.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return n(R,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return t=this.variants.map((function(t){return t.id})),e=y.getPickupStockLocationIds(),[4,S.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,n.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return n(R,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,(e=new j({productId:this.id,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage})).getInitial()];case 1:return n.sent(),[2,e]}}))}))},this.getProductOptionSet=function(){return n(R,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,S.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=n.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return n(R,void 0,void 0,(function(){var t,e,n,r,a,o;return i(this,(function(i){switch(i.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(n=null===(a=P.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===n.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:i.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,i,r;try{var a=null===(e=n.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(i=n.variant.bundleProducts)||void 0===i?void 0:i.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),i.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:i.sent(),i.label=5;case 5:return[2]}}))}))},this.getBundleProductsOfVariant=function(t){return n(R,void 0,void 0,(function(){var e,n,r,o,u,s,c=this;return i(this,(function(i){switch(i.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,S.searchProducts({input:{productIdList:e,perPage:200}})]:[3,2];case 1:(n=i.sent()).isSuccess&&(null===(u=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===u||u.forEach((function(t){c.bundleProductCache[t.id]=t}))),i.label=2;case 2:return null===(s=t.bundleSettings)||void 0===s||s.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new G(a(e)))})),[2]}}))}))},this.setOptionPrices=function(){var t,e=R.variants[0];if(e){var n=e.price.currency;null===(t=R.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;t.selectSettings&&t.selectSettings.values.forEach((function(t){var e;t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===n})))||void 0===e?void 0:e.price)||t.price)})),t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===n})))||void 0===e?void 0:e.price)||t.price)}))}},this.id=b.id||Date.now()+"",this.name=b.name||"",this.type=b.type||f.PHYSICAL,this.description=b.description||"",this.shortDescription=b.shortDescription||"",this.metaData=b.metaData?new l(b.metaData):null,this.brand=b.brand?new d(b.brand):null,this.categories=b.categories?b.categories.map((function(t){return new o(t)})):[],this.deleted=b.deleted||null,this.tags=b.tags?b.tags.map((function(t){return new p(t)})):[],this.variants=b.variants?b.variants.map((function(t){return new u(t)})):[],this.attributes=b.attributes?b.attributes.map((function(t){return new s(t)})):[],this.variantTypes=b.variantTypes?b.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=b.productOptionSetId||null,this.averageRating=null!==(I=b.averageRating)&&void 0!==I?I:null,this.reviewCount=null!==(E=b.reviewCount)&&void 0!==E?E:null,this.stars=b.stars?b.stars.map((function(t){return new T(t)})):null,this.baseUnit=b.baseUnit?new O(b.baseUnit):null,this.productOptionSet=b.productOptionSet?new h(b.productOptionSet):null,this.campaigns=(null===(L=b.campaigns)||void 0===L?void 0:L.map((function(t){return new V(t)})))||null,this.selectedVariantValues=b.selectedVariantValues||[],this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=b.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=b.dynamicPriceListIds||null,this.productVolumeDiscountId=b.productVolumeDiscountId||null,this.campaignOffers=b.campaignOffers?b.campaignOffers.map((function(t){return new C(t)})):null,this.appliedCampaignOffer=b.appliedCampaignOffer,this.offers=b.offers?b.offers.map((function(t){return new x(t)})):void 0,this.productGroup=b.productGroup?new k(b.productGroup):null,this.salesChannels=b.salesChannels?b.salesChannels.map((function(t){return new A(t)})):null,this.productGroupItems=b.productGroupItems,this.setOptionPrices(),this.variants.forEach((function(t){return t.product=R})),v(this,{selectedVariantValues:m,isFiltered:m,isStatic:m,hasVariant:g,hasStock:g,hasValidProductOptionValues:g,href:g,productHref:g,mainVariantType:g,mainVariantValue:g,selectedVariant:g,displayedVariantTypes:g,isCustomerReviewEnabled:g,isCustomerReviewLoginRequired:g,isAddToCartEnabled:g,groupedAttributeValues:g,selectedVariantUnitPriceText:g,displayedProductGroups:g})}return Object.defineProperty(G.prototype,"hasVariant",{get:function(){return b.hasVariant(this)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:b.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"href",{get:function(){return b.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:b.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"mainVariantType",{get:function(){return b.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"mainVariantValue",{get:function(){return b.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?b.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isCustomerReviewEnabled",{get:function(){return y.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isCustomerReviewLoginRequired",{get:function(){return y.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"groupedAttributeValues",{get:function(){var t,e=I(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var n=t.productAttributeId;if(n){var i=e[n];return(null==i?void 0:i.length)&&i[0].productAttribute?{attribute:i[0].productAttribute,values:i}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"displayedProductGroups",{get:function(){var e,n=this,i=[],r=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){i.includes(t.name)||i.push(t.name)}))})),i.forEach((function(e){var i,a={name:e,items:[]};null===(i=n.productGroupItems)||void 0===i||i.forEach((function(i){var r,o,u,s=i.groupValues.find((function(t){return t.name===e}));if(s&&!a.items.some((function(t){return t.value===s.value}))){var c="";if(i.productId===n.id)c=n.href;else{var d=(null===(r=n.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[s],!1),p=null===(o=n.productGroupItems)||void 0===o?void 0:o.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:i.href}a.items.push({image:i.image?new E(i.image):null,href:c,value:s.value,isSelected:(null===(u=n.productGroupItems)||void 0===u?void 0:u.some((function(t){return t.groupValues.some((function(t){return t.value===s.value}))&&t.productId===n.id})))||!1})}})),r.push(a)})),r},enumerable:!1,configurable:!0}),G}();export{G as IkasProduct};
1
+ import{__spreadArray as t,__assign as e,__awaiter as n,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as u}from"./variant/index.js";import{IkasProductAttributeValue as s}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductType as f}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as v}from"./option-set/index.js";import{makeObservable as h,observable as m,computed as g}from"mobx";import{IkasProductFunctions as b}from"@ikas/storefront-model-functions";import{IkasProductCampaign as V}from"./campaign/index.js";import{IkasStorefrontConfig as y}from"@ikas/storefront-config";import{IkasBaseStore as P}from"../../../store/base.js";import I from"lodash/groupBy";import{IkasProductBaseUnit as O}from"./base-unit/index.js";import{formatCurrency as w}from"../../../utils/currency.js";import"lodash/get";import S from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as T}from"./star/index.js";import{IkasProductCampaignOffer as C,IkasProductOffer as x}from"./campaign-offer/index.js";import{IkasProductGroup as k}from"./group/index.js";import{IkasImage as E}from"../image/index.js";import{IkasProductSalesChannel as G}from"./sales-channel/index.js";var A=function(){function A(b){void 0===b&&(b={});var I,E,L,R=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.selectVariantValue=function(n,i){var r,a=R.metaData,o=R.selectedVariantValues.map((function(t){return t.variantTypeId===n.variantTypeId?n:t})),u=R.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(u)R.selectedVariantValues=o;else{var s=R.variantTypes.findIndex((function(t){return t.variantType.id===n.variantTypeId}));if(s>0){var c=R.variantTypes.slice(0,s),d=R.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[n],!1);u=R.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(u=R.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(u=R.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===n.id}))})))}if(!u)return;R.selectedVariantValues=u.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,n){var i;"vid"!==n&&(f=e(e({},f),((i={})[n]=t,i)))})),R.variantTypes.map((function(t){delete f[t.variantType.slug]}));var v=t(t([],R.variantTypes.map((function(t){var e=t.variantType,n=e.values.find((function(t){return R.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(n)return"".concat(e.slug,"=").concat(n.slug)})),!0),Object.entries(f).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})),!0).filter((function(t){return!!t})).join("&");if(!i){var h="/".concat(a.slug);if(v&&(h="/".concat(a.slug,"?").concat(v)),h===window.location.pathname)return;null===(r=P.getInstance().router)||void 0===r||r.replace(h,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,n,i=t.price;if(i.unitPrice&&R.baseUnit){var r=R.baseUnit.baseAmount,a=(null===(n=null===(e=R.baseUnit)||void 0===e?void 0:e.unit)||void 0===n?void 0:n.name)||"";return"".concat(w(i.unitPrice,i.currency||"",i.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return n(R,void 0,void 0,(function(){var t,e,n,r,a,o=this;return i(this,(function(i){switch(i.label){case 0:return t=P.getInstance(),e=t.customerStore.customer,n=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,S.getProductCampaigns({input:{customerGroupIds:n,salesChannelId:y.getSalesChannelId()||"",variantIds:r}})];case 1:return a=i.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var n;t.variantIds.some((function(t){return t===e.id}))&&(null===(n=e.campaigns)||void 0===n||n.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return n(R,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return t=this.variants.map((function(t){return t.id})),e=y.getPickupStockLocationIds(),[4,S.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,n.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return n(R,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,(e=new j({productId:this.id,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage})).getInitial()];case 1:return n.sent(),[2,e]}}))}))},this.getProductOptionSet=function(){return n(R,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,S.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=n.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return n(R,void 0,void 0,(function(){var t,e,n,r,a,o;return i(this,(function(i){switch(i.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(n=null===(a=P.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===n.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:i.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,i,r;try{var a=null===(e=n.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(i=n.variant.bundleProducts)||void 0===i?void 0:i.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),i.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:i.sent(),i.label=5;case 5:return[2]}}))}))},this.getBundleProductsOfVariant=function(t){return n(R,void 0,void 0,(function(){var e,n,r,o,u,s,c=this;return i(this,(function(i){switch(i.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,S.searchProducts({input:{productIdList:e,perPage:200}})]:[3,2];case 1:(n=i.sent()).isSuccess&&(null===(u=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===u||u.forEach((function(t){c.bundleProductCache[t.id]=t}))),i.label=2;case 2:return null===(s=t.bundleSettings)||void 0===s||s.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new A(a(e)))})),[2]}}))}))},this.setOptionPrices=function(){var t,e=R.variants[0];if(e){var n=e.price.currency;null===(t=R.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;t.selectSettings&&t.selectSettings.values.forEach((function(t){var e;t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===n})))||void 0===e?void 0:e.price)||t.price)})),t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===n})))||void 0===e?void 0:e.price)||t.price)}))}},this.id=b.id||Date.now()+"",this.name=b.name||"",this.type=b.type||f.PHYSICAL,this.description=b.description||"",this.shortDescription=b.shortDescription||"",this.metaData=b.metaData?new l(b.metaData):null,this.brand=b.brand?new d(b.brand):null,this.categories=b.categories?b.categories.map((function(t){return new o(t)})):[],this.deleted=b.deleted||null,this.tags=b.tags?b.tags.map((function(t){return new p(t)})):[],this.variants=b.variants?b.variants.map((function(t){return new u(t)})):[],this.attributes=b.attributes?b.attributes.map((function(t){return new s(t)})):[],this.variantTypes=b.variantTypes?b.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=b.productOptionSetId||null,this.averageRating=null!==(I=b.averageRating)&&void 0!==I?I:null,this.reviewCount=null!==(E=b.reviewCount)&&void 0!==E?E:null,this.stars=b.stars?b.stars.map((function(t){return new T(t)})):null,this.baseUnit=b.baseUnit?new O(b.baseUnit):null,this.productOptionSet=b.productOptionSet?new v(b.productOptionSet):null,this.campaigns=(null===(L=b.campaigns)||void 0===L?void 0:L.map((function(t){return new V(t)})))||null,this.selectedVariantValues=b.selectedVariantValues||[],this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=b.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=b.dynamicPriceListIds||null,this.productVolumeDiscountId=b.productVolumeDiscountId||null,this.campaignOffers=b.campaignOffers?b.campaignOffers.map((function(t){return new C(t)})):null,this.appliedCampaignOffer=b.appliedCampaignOffer,this.offers=b.offers?b.offers.map((function(t){return new x(t)})):void 0,this.productGroup=b.productGroup?new k(b.productGroup):null,this.salesChannels=b.salesChannels?b.salesChannels.map((function(t){return new G(t)})):null,this.productGroupItems=b.productGroupItems,this.setOptionPrices(),this.variants.forEach((function(t){return t.product=R})),h(this,{selectedVariantValues:m,isFiltered:m,isStatic:m,hasVariant:g,hasStock:g,hasValidProductOptionValues:g,href:g,productHref:g,mainVariantType:g,mainVariantValue:g,selectedVariant:g,displayedVariantTypes:g,isCustomerReviewEnabled:g,isCustomerReviewLoginRequired:g,isAddToCartEnabled:g,groupedAttributeValues:g,selectedVariantUnitPriceText:g,displayedProductGroups:g})}return Object.defineProperty(A.prototype,"hasVariant",{get:function(){return b.hasVariant(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:b.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"href",{get:function(){return b.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:b.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantType",{get:function(){return b.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantValue",{get:function(){return b.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?b.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewEnabled",{get:function(){return y.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewLoginRequired",{get:function(){return y.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"groupedAttributeValues",{get:function(){var t,e=I(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var n=t.productAttributeId;if(n){var i=e[n];return(null==i?void 0:i.length)&&i[0].productAttribute?{attribute:i[0].productAttribute,values:i}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedProductGroups",{get:function(){var e,n=this,i=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){i.includes(t.name)||i.push(t.name)}))})),i.forEach((function(e){var i,o={name:e,items:[]};n.productGroupItems=r(n.productGroupItems,"order.value"),null===(i=n.productGroupItems)||void 0===i||i.forEach((function(i){var r,a,u,s=i.groupValues.find((function(t){return t.name===e}));if(s&&!o.items.some((function(t){return t.value===s.value}))){var c="";if(i.productId===n.id)c=n.href;else{var d=(null===(r=n.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[s],!1),p=null===(a=n.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:i.href}o.items.push({image:i.image?new E(i.image):null,href:c,value:s.value,isSelected:(null===(u=n.productGroupItems)||void 0===u?void 0:u.some((function(t){return t.groupValues.some((function(t){return t.value===s.value}))&&t.productId===n.id})))||!1})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),A}();export{A as IkasProduct};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
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": "^5.0.5",
21
- "@ikas/storefront-config": "^5.0.5",
22
- "@ikas/storefront-model-functions": "^5.0.5",
23
- "@ikas/storefront-models": "^5.0.5",
24
- "@ikas/storefront-providers": "^5.0.5",
20
+ "@ikas/storefront-api": "^5.0.6",
21
+ "@ikas/storefront-config": "^5.0.6",
22
+ "@ikas/storefront-model-functions": "^5.0.6",
23
+ "@ikas/storefront-models": "^5.0.6",
24
+ "@ikas/storefront-providers": "^5.0.6",
25
25
  "@ikas/localized-address": "1.0.0-beta.3",
26
26
  "@adyen/adyen-web": "^5.28.2",
27
27
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -55,11 +55,11 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@ikas/localized-address": "1.0.0-beta.3",
58
- "@ikas/storefront-api": "^5.0.5",
59
- "@ikas/storefront-config": "^5.0.5",
60
- "@ikas/storefront-model-functions": "^5.0.5",
61
- "@ikas/storefront-models": "^5.0.5",
62
- "@ikas/storefront-providers": "^5.0.5",
58
+ "@ikas/storefront-api": "^5.0.6",
59
+ "@ikas/storefront-config": "^5.0.6",
60
+ "@ikas/storefront-model-functions": "^5.0.6",
61
+ "@ikas/storefront-models": "^5.0.6",
62
+ "@ikas/storefront-providers": "^5.0.6",
63
63
  "mobx": "^6.1.3",
64
64
  "mobx-react-lite": "^3.1.5",
65
65
  "next": "12.2.0",