PageSourceSearch

https://petwantsatlnorth.com/_next/static/chunks/a2e360a551974854.js

js petwantsatlnorth.com collected 2026-09-28 09:39:57 UTC 52,797 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,726784,511555,866830,e=>{"use strict";class i{children;menuModel;isSelected;isAllItemsLoaded;constructor(e){this.menuModel=e,this.isSelected=!1,this.isAllItemsLoaded=!1,this.children=[],e.subMenus&&this.menuModel.subMenus.forEach(e=>{this.children.push(new i(e))})}getBranchMenuItem(){return this.menuModel}setSelected(e){this.isSelected=e}isBranchSelected(){return this.isSelected}hasChildren(){return this.children.length>0}getChildren(){return this.children}setChildren(e){let i=[];e.forEach(e=>{i.push(e.getBranchMenuItem())}),this.menuModel.subMenus=i}getBranchProducts(){return this.getBranchProductsRecursionly(this)}setAllItemsLoaded(e){this.isAllItemsLoaded=e}getIfAllItemsLoaded(){return this.isAllItemsLoaded}addNewItems(e){let i=this.getBranchProducts().map(e=>e.id),t=[],r=e.filter(e=>!i.includes(e.id)).filter(e=>!t.includes(e.id)&&(t.push(e.id),!0));return this.menuModel.items=[...this.menuModel.items,...r],e}clearProducts(){this.menuModel.items=[],this.children.forEach(e=>e.clearProducts())}getBranchProductsRecursionly(e){let i=[];return e.getBranchMenuItem().items.forEach(e=>{i.push(e)}
1),e.hasChildren()&&e.getChildren().forEach(e=>{let t=this.getBranchProductsRecursionly(e);i=[...i,...t]}),i}}e.s(["default",()=>i],726784);var t,r,s=((t={})[t.LEFT=3]="LEFT",t[t.FULL=15]="FULL",t[t.RIGHT=12]="RIGHT",t);e.s(["PizzaSide",()=>s],511555);var o=((r={})[r.REGISTER=0]="REGISTER",r[r.IMPULS_BUY=1]="IMPULS_BUY",r[r.PRODUCT_VARIANT=4]="PRODUCT_VARIANT",r);e.s(["ItemSource",()=>o],866830)},418697,e=>{"use strict";var i=e.i(635136);class t{static SHIPPING_METHOD_NAMES={[i.ShippingOption.STORE_PICKUP]:"Store Pick-up",[i.ShippingOption.IN_STORE]:"In-Store",[i.ShippingOption.DELIVER]:"Delivery",[i.ShippingOption.SHIP]:"Ship"};static PICKUP_METHODS=new Set([i.ShippingOption.STORE_PICKUP]);static DELIVERY_METHODS=new Set([i.ShippingOption.DELIVER,i.ShippingOption.SHIP]);static hasPickup(e){return this.filterSupportedMethods(e).some(e=>this.PICKUP_METHODS.has(e))}static hasDelivery(e){return this.filterSupportedMethods(e).some(e=>this.DELIVERY_METHODS.has(e))}static hasAllShippingMethods(e=[]){return new Set(this.filterSupportedMethods(e)).size===Object.keys(i.ShippingOption).length-1}static isStorePickupOnly(e){return this.hasPickup(e)&&!this.hasDelivery(e)}static isDeliveryOnly(e){return!this.hasPickup(e)&&this.hasDelivery(e)}static hasMethod(e,t){return!!e?.length&&t!==i.ShippingOption.IN_STORE&&e.includes(t)}static getShippingInfoMessage=e=>{if(0===e.length||this.hasAllShippingMethods(e))return null;let i=Array.from(new Set(e.map(e=>this.SHIPPING_METHOD_NAMES[e]).filter(Boolean)));if(1===i.length)return`This product is ${i[0]} only`;let t=i.join(" / ");return`This product is ${t} only`};static filterSupportedMethods(e=[]){return e.filter(e=>e!==i.ShippingOption.IN_STORE)}}e.s(["ProductShippingHelper",()=>t])},788563,e=>{"use strict";var i=e.i(356756),t=e.i(726784),r=e.i(496424),s=e.i(571152),o=e.i(999595),d=e.i(917295),n=e.i(511555),a=e.i(833212),h=e.i(783771),l=e.i(866830),c=e.i(91986),u=e.i(820204),p=e.i(418697);class m extends i.default{isRetailProduct;productItem;modifiersSetsState;predifinedModifiersState;selectedMatrixSet;isAnyPredefinedSetIsAvailableOnStock;quantity;price;qtyOnStock;isSimpleProduct;isCloseOrderDialog;isDialog;isLoading;isWishlistLoading;isAuthorized;isSignInShown;store;isAddToWishlistButtonEnabled;isAddCartButtonEnabled;isNoItemsOnStockError;modifierSetsErrors;isShowDeliveryOnly;isShowStorePickupOnly;isShowConfirmationDialog;confirmationMessage;isShowErrorDialog;errorDialogMessage;stockUnit;priceUnit;allowDecimalCount;allowOrderOutOfStockItems;isQtyOnStockIsZero;isShowStockAmount;quickSelectionNumbers;possibleSubscriptions;isSubscriptionChecked;checkedSubscriptionId;relatedProducts;isShowRelatedProducts;productNotes;isLoadingItems;isMealMode;openedMenuId;isShowProductsList;mealsMenus;mealsMenuBranches;isMealProductLoading;openedMealProduct;openedMealProductModifiersSetsState;openedMealProductPredifinedModifiersState;openedMealProductMenuId;addedMealProducts;isMenuItemsLoading;isDisplayMealProduct;isMealProductAdded;freeMealItemsCount;rootMealId;mealMenuWithError;isShowMealMenusErrors;rootMeal;rootMealMenuId;rootMealModifiersSetsState;isMealsProductsRequesting;isProductPreview;isBundleProduct;bundleProducts;recipientEmail;isRecipientEmailError;recipientName;isRecipientNameError;selectedProductVariant;openedVendorProduct;selectedVendor;storeRepository;authRepository;cart;wishlist;browserHistoryHelper;analyticsHelper;errorLogger;storeId;menuId;categoryName;vendorName;onProductAdded;isUsePredefinedModifiersStockAndPrice;productQtyOnStock;editingOrder;itemSource;settings;productViewModel;dependencyInjector;authListener;constructor(e,i,t,r,s,o,d,n,a,h,c,u){super(),this.store=n,this.settings=a,this.productViewModel=c,this.dependencyInjector=h,this.cart=e,this.wishlist=void 0,this.storeRepository=i,this.authRepository=t,this.browserHistoryHelper=s,this.analyticsHelper=o,this.errorLogger=d,this.isCloseOrderDialog=!1,this.isLoading=!1,this.isWishlistLoading=!0,this.isAuthorized=!1,this.isSignInShown=!1,this.isAddToWishlistButtonEnabled=!0,this.isAddCartButtonEnabled=!1,this.isNoItemsOnStockError=!1,this.productItem=void 0,this.isRetailProduct=!1,this.modifiersSetsState={},this.predifinedModifiersState={},this.selectedMatrixSet=void 0,this.modifierSetsErrors={},this.quantity=1,this.price=0,this.qtyOnStock=0,this.productQtyOnStock=0,this.isSimpleProduct=!1,this.isAnyPredefinedSetIsAvailableOnStock=!1,this.isUsePredefinedModifiersStockAndPrice=!1,this.isShowStockAmount=!1,this.isShowDeliveryOnly=!1,this.isShowStorePickupOnly=!1,this.isShowConfirmationDialog=!1,this.confirmationMessage="",this.isShowErrorDialog=!1,this.errorDialogMessage="",this.allowDecimalCount=!1,this.allowOrderOutOfStockItems=!1,this.isQtyOnStockIsZero=!1,this.quickSelectionNumbers=[],this.possibleSubscriptions=[],this.isSubscriptionChecked=!0,this.relatedProducts=[],this.isShowRelatedProducts=!1,this.itemSource=l.ItemSource.REGISTER,this.isMealMode=!1,this.openedMenuId=void 0,this.isShowProductsList=!1,this.mealsMenus=[],this.mealsMenuBranches=[],this.addedMealProducts=[],this.isMealProductLoading=!1,this.openedMealProduct=void 0,this.openedMealProductModifiersSetsState={},this.openedMealProductPredifinedModifiersState={},this.openedMealProductMenuId=void 0,this.isMenuItemsLoading=!1,this.isDisplayMealProduct=!1,this.isMealProductAdded=!1,this.freeMealItemsCount=0,this.mealMenuWithError=void 0,this.isShowMealMenusErrors=!1,this.rootMealModifiersSetsState={},this.isLoadingItems=!1,this.isMealsProductsRequesting=!1,this.isProductPreview=u,this.isBundleProduct=!1,this.bundleProducts=[],this.recipientEmail=void 0,this.isRecipientEmailError=!1,this.recipientName=void 0,this.isRecipientNameError=!1,this.productNotes="",this.authListener={onSignedIn:async()=>{await this.initWishlist(),this.closeSignIn(),await this.onAddToWishlistButton()},onSignedOut:()=>{this.isAuthorized=!1}}}attachView=e=>{this.errorLogger.log("ProductOrderViewModelImpl.attachView"),super.attachView(e),this.isLoading=!1,this.isDialog=!1,this.productItem=void 0,this.isAddToWishlistButtonEnabled=!0,this.isAddCartButtonEnabled=!1,this.isNoItemsOnStockError=!1,this.isRetailProduct=!0,this.modifiersSetsState={},this.predifinedModifiersState={},this.selectedMatrixSet=void 0,this.modifierSetsErrors={},this.quantity=1,this.price=0,this.qtyOnStock=0,this.isSimpleProduct=!1,this.isUsePredefinedModifiersStockAndPrice=!1,this.authRepository.addAuthListener(this.authListener),super.notifyViewAboutChanges()};onBindProduct=async(e,i,r,o,d=!1,n=!1,h,p,m,f,S,g)=>{this.errorLogger.log("ProductOrderViewModelImpl.onBindProduct",`storeId=${e}, menuId=${i}, productId=${o}, isRetailProduct=${d}, isDialog=${n}, isNextMealProduct=${p}, editingOrder=${JSON.stringify(m)}`),this.isMealMode&&(this.isDisplayMealProduct=!0),this.isRetailProduct=d,this.isDialog=n,this.onProductAdded=h,this.storeId=e,this.menuId=i,this.categoryName=r,this.isLoading=!0,this.selectedProductVariant=S,this.itemSource=g||l.ItemSource.REGISTER,this.notifyViewAboutChanges();let M=await this.storeRepository.getMenuItem(this.store.id||e,i,o,void 0,this.store.isRestaurant);M.data.modifierSets||(M.data.modifierSets=[]),this.store||(this.store=(await this.storeRepository.getStore(e)).data);let I=new s.CaseInsensitiveUrlParams(new URLSearchParams(window.location.search)),P=Number(I.get("vendorId")||"")||M.data.vendorId;if(this.settings.siteType!==a.SiteType.CONSUMER&&P&&this.store.vendors){let e=this.store.vendors.find(e=>e.id===P);this.vendorName=e?.name,this.settings.siteType===a.SiteType.GLOBAL_MARKETPLACE&&M.data.vendors&&(this.openedVendorProduct=M.data.vendors.find(e=>e.id===P))}
1this.stockUnit=M.data.stockUnit||"",this.priceUnit=M.data.priceUnit||"$",this.allowOrderOutOfStockItems=this.store.allowOrderOutOfStockItems,M.data.id=o,this.isAnyPredefinedSetIsAvailableOnStock=!M.data.trackInventory;let[y,O]=this.createModifiersInitStates(M.data);this.isShowStockAmount=!!M.data.trackInventory,this.modifiersSetsState=y,this.predifinedModifiersState=O,m&&(this.modifiersSetsState=m.modifierSets,this.editingOrder=m,m.mealGroupId&&(this.addedMealProducts=this.cart.getOrders().filter(e=>e.mealGroupId===m.mealGroupId).filter(e=>e.isMealChild))),this.productItem=M.data,this.price=this.getTotalPrice(),this.updatePickupAndDeliveryMessages(this.productItem),this.productItem.subscriptions&&this.productItem.subscriptions.length>0&&(this.possibleSubscriptions=this.productItem.subscriptions),this.isSubscriptionChecked=!1,this.checkedSubscriptionId=void 0,this.relatedProducts=this.productItem.relatedProducts||[];try{this.quickSelectionNumbers=this.productItem.quickQuantities?this.productItem.quickQuantities.split(",").map(e=>Number(e)):[]}catch(e){this.quickSelectionNumbers=[]}if(this.isShowProductsList=!0,this.mealMenuWithError=void 0,this.isShowMealMenusErrors=!1,this.productItem.isMeal&&!p)for(let e of(this.isDisplayMealProduct=!0,this.isMealMode=!0,this.rootMealId=this.productItem.id,this.rootMealMenuId=i,this.rootMeal=this.productItem,this.productItem.mealMenu?.items&&(this.mealsMenus=this.productItem.mealMenu.items),this.productItem.mealMenu?.itemsInPrice&&(this.freeMealItemsCount=this.productItem.mealMenu.itemsInPrice),this.mealsMenus)){let{data:i}=await this.storeRepository.getCategoriesProducts_v2_4(this.store.id,e.menuId,void 0,void 0,!0),r=i.filter(i=>i.id===e.menuId)[0],s=new t.default(r);this.mealsMenuBranches.push(s)}if(this.productItem.bundleItems.length>0){this.isBundleProduct=!0;let i=[];if(this.bundleProducts=await Promise.all(this.productItem.bundleItems.map(t=>this.storeRepository.getMenuItem(e,t.menuId,t.id).then(e=>{let r=e?.data;return r||i.push({name:t.name,errorCode:e.error?.code}),{...t,availableShippingMethods:r?.availableShippingMethods,isPickupAllowed:r?.isPickupAllowed,isDeliverAllowed:r?.isDeliverAllowed}}))),i.length>0){let e=i.map(({name:e})=>e).join(", ");u.toast.danger(`Could not load full details for ${e}. You can still add this product to your cart.`,5e3)}}let b=M.data.stock-this.getSameProductInTheCartQty();this.allowOrderOutOfStockItems?(this.quantity=1,this.qtyOnStock=this.settings.siteType!==a.SiteType.CONSUMER?0x3b9ac9ff:999):b<=0?(this.quantity=1,this.isQtyOnStockIsZero=!0,this.qtyOnStock=this.settings.siteType!==a.SiteType.CONSUMER?0x3b9ac9ff:999):(this.isQtyOnStockIsZero=!1,this.qtyOnStock=b<=0?0:b),this.productQtyOnStock=b,this.isAddToWishlistButtonEnabled=!this.productItem?.trackInventory||this.isQtyOnStockIsZero||this.qtyOnStock>=this.quantity,this.isAddCartButtonEnabled=!this.productItem?.trackInventory||this.qtyOnStock>=this.quantity,this.isNoItemsOnStockError=!!this.productItem?.trackInventory&&this.qtyOnStock<this.quantity,this.productItem.isGiftCard&&(this.productItem.trackInventory=!1,this.quantity=0,this.price=this.getTotalPrice(),this.isAddToWishlistButtonEnabled=!1),S&&this.setProductOrderDetails(S),this.setMatrixCombinationFromUrl(),(0,c.decode)(I.get("autoAddToCart")||"")&&this.onClickOrderProductItem(),f&&await this.initWishlist(),this.isLoading=!1,this.notifyViewAboutChanges(),n&&this.analyticsHelper.trackViewItem(M.data)};detachView=e=>{this.errorLogger.log("ProductOrderViewModelImpl.detachView"),super.detachView(e),this.isDialog=void 0,this.quickSelectionNumbers=[],this.possibleSubscriptions=[],this.isSubscriptionChecked=!1,this.checkedSubscriptionId=void 0,this.selectedProductVariant=void 0,this.relatedProducts=[],this.isShowRelatedProducts=!1,this.price=0,this.isAnyPredefinedSetIsAvailableOnStock=!1,this.isMealMode=!1,this.openedMenuId=void 0,this.isShowProductsList=!1,this.mealsMenus=[],this.mealsMenuBranches=[],this.addedMealProducts=[],this.isMealProductLoading=!1,this.openedMealProduct=void 0,this.openedMealProductModifiersSetsState={},this.openedMealProductPredifinedModifiersState={},this.openedMealProductMenuId=void 0,this.isMenuItemsLoading=!1,this.isDisplayMealProduct=!1,this.isMealProductAdded=!1,this.isBundleProduct=!1,this.bundleProducts=[],this.recipientEmail=void 0,this.isRecipientEmailError=!1,this.recipientName=void 0,this.isRecipientNameError=!1,this.editingOrder=void 0,super.notifyViewAboutChanges()};initWishlist=async()=>
1{if(!this.store)return;this.isWishlistLoading=!0,super.notifyViewAboutChanges();let e=this.dependencyInjector.data.getProfileRepository(),i=this.authRepository.isAuthorized();if(this.isAuthorized=i,!i){this.isWishlistLoading=!1,super.notifyViewAboutChanges();return}let{data:t}=await e.getProfile(this.store.id);this.wishlist=this.dependencyInjector.domain.getWishlist(this.store,t.user.customerId),this.isWishlistLoading=!1,super.notifyViewAboutChanges()};onModifierChecked=async(e,i,t)=>{this.errorLogger.log("ProductOrderViewModelImpl.onModifierChecked",`modifierSet=${JSON.stringify(e)}, modifier=${JSON.stringify(i)}`);let r=this.getModifiersSetsState(),s=!!r[e.modifierSetId].modifiers[i.modifierId];if(r[e.modifierSetId].modifiers[i.modifierId]=s?void 0:{},s)r[e.modifierSetId].modifiers[i.modifierId]=void 0;else{let t=r[e.modifierSetId].modifiers[i.modifierId];if(!t)throw Error("Modifier is undefined");t.price=i.price,t.priceType=i.priceType,t.name=i.modifierName,t.modifierSetName=e.modifierSetName,t.count=Number(i.qty),t.isEnableQuantitySelection=i.enableQuantitySelection,t.requireModifierOption=i.requireModifierOption,i.modifierOption?.name&&(t.selectedModifierOptionId=i.modifierOption.modifierOptionId,t.selectedModifierOptionName=i.modifierOption.name,t.selectedModifierOption=i.modifierOption.options[0]),0===t.count&&(t.count=1),3===e.modifierSetType&&(t.pizzaSide=n.PizzaSide.FULL),this.isRetailProduct&&(r[e.modifierSetId].modifiers={}),r[e.modifierSetId].modifiers[i.modifierId]=t}this.openedMealProduct?this.openedMealProductModifiersSetsState=r:this.modifiersSetsState=r,t&&(this.quantity=1),this.price=this.getTotalPrice(),this.updateProductInfoWithMatrixSet(),this.updateUrlWithMatrixCombination(),super.notifyViewAboutChanges()};onModifierSelected=async(e,i)=>{this.errorLogger.log("ProductOrderViewModelImpl.onModifierSelected",`modifierSet=${JSON.stringify(e)}, modifier=${JSON.stringify(i)}`);let t=JSON.parse(JSON.stringify(this.getModifiersSetsState()));t[e.modifierSetId].modifiers={};let r={};r.price=i.price,r.priceType=i.priceType,r.name=i.modifierName,r.modifierSetName=e.modifierSetName,r.count=Number(i.qty),r.isEnableQuantitySelection=i.enableQuantitySelection,r.requireModifierOption=i.requireModifierOption,i.modifierOption?.name&&(r.selectedModifierOptionId=i.modifierOption.modifierOptionId,r.selectedModifierOptionName=i.modifierOption.name,r.selectedModifierOption=i.modifierOption.options[0]),3===e.modifierSetType&&(r.pizzaSide=15),0===r.count&&(r.count=1),this.getModifiersSetsState()[e.modifierSetId].modifiers[i.modifierId]&&!t[e.modifierSetId].isRequired?t[e.modifierSetId].modifiers[i.modifierId]=void 0:t[e.modifierSetId].modifiers[i.modifierId]=r,this.openedMealProduct?this.openedMealProductModifiersSetsState=t:this.modifiersSetsState=t,this.price=this.getTotalPrice(),super.notifyViewAboutChanges()};onSubscriptionChecked=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onSubscriptionChecked"),this.isSubscriptionChecked=!this.isSubscriptionChecked,super.notifyViewAboutChanges()};onSubscriptionSelected=e=>{this.errorLogger.log("ProductOrderViewModelImpl.onSubscriptionSelected",`id=${e}`),this.checkedSubscriptionId=e,void 0===e?this.isSubscriptionChecked=!1:this.isSubscriptionChecked=!0,super.notifyViewAboutChanges()};setQuantity=e=>{this.errorLogger.log("ProductOrderViewModelImpl.setQuantity",`quantity=${e}`),this.quantity=e,this.price=this.getTotalPrice(),this.notifyViewAboutChanges()};setProductNotes(e){this.productNotes=e,super.notifyViewAboutChanges()}onProductVariantSelected=async e=>{if(this.errorLogger.log("ProductOrderViewModelImpl.onProductVariantSelected",`productVariant=${JSON.stringify(e)}`),void 0===e){this.selectedProductVariant=void 0,this.itemSource=l.ItemSource.REGISTER,this.productViewModel?.setProductImages(void 0),this.setProductOrderDetails(void 0),super.notifyViewAboutChanges();return}if(this.store&&this.menuId)try{this.isLoading=!0,super.notifyViewAboutChanges();let{data:i}=await this.storeRepository.getMenuItem(this.store?.id,this.menuId,e.id,e?.productVariantId);this.selectedProductVariant=i,this.itemSource=l.ItemSource.PRODUCT_VARIANT,this.productViewModel?.setProductImages(i),this.setProductOrderDetails(i),this.isLoading=!1,super.notifyViewAboutChanges(),this.analyticsHelper.trackViewItem(this.selectedProductVariant)}catch(e){console.error(e.message),this.isLoading=!1,super.notifyViewAboutChanges()}};onRelatedProductClicked=e=>{this.errorLogger.log("ProductOrderViewModelImpl.onRelatedProductClicked",`relatedProduct=${JSON.stringify(e)}`),this.browserHistoryHelper.moveTo(d.UrlUtils.getLink(this.store,this.settings,`shop?productC
1ode=${e.code}`)),window.location.reload()};onAddRelatedProduct=async e=>{if(this.errorLogger.log("ProductOrderViewModelImpl.onAddRelatedProduct",`relatedProduct=${JSON.stringify(e)}`),!e.isAdding){this.relatedProducts.forEach(i=>{i.id===e.id&&(i.isAdding=!0)}),super.notifyViewAboutChanges();let i=this.store;if(i){let t=e.menuId,r=e.id,s=(await this.storeRepository.getMenuItem(i.id,t,r)).data;if(s.stock<=0&&s.trackInventory&&!this.store?.allowOrderOutOfStockItems){this.relatedProducts.forEach(i=>{i.id===e.id&&(i.isAdded=!1,i.outOfStock=!0,i.isAdding=!1)}),super.notifyViewAboutChanges();return}let o={orderId:crypto.randomUUID(),stockCount:this.store?.allowOrderOutOfStockItems?9999:s.stock,isTrackInventary:!this.selectedProductVariant&&!!s.trackInventory,companyId:i.id,menuId:t,matrixProductTotalPrice:s.predefinedModifierSets&&s.predefinedModifierSets.length>0?s.price:void 0,isRetailProduct:!e.isMatrix,categoryName:this.categoryName,vendorName:this.vendorName,itemId:s.id,code:s.code,itemPrice:s.price,itemName:s.name,count:1,allowDecimalCount:!1,isService:!!s?.isService,modifierSets:{},largeImageUrl:s.imageUrl,availableShippingMethods:s.availableShippingMethods,isPickupAllowed:s.isPickupAllowed,isDeliverAllowed:s.isDeliverAllowed,purchasingUnitQuantity:s.purchasingUnitQuantity,purchasingUnitName:s.purchasingUnitName,isUncheckedManuallyInCart:!1,isVendorError:!1,itemSource:l.ItemSource.IMPULS_BUY};this.cart.addOrder(o),this.onProductAdded&&this.onProductAdded(),this.relatedProducts.forEach(i=>{i.id===e.id&&(i.isAdded=!0,i.isAdding=!1)}),super.notifyViewAboutChanges(),this.analyticsHelper.trackAddToCart(s)}}};onQuantityOfModifierChanged=async(e,i,t)=>{this.errorLogger.log("ProductOrderViewModelImpl.onQuantityOfModifierChanged",`modifierSetId=${e}, modifierId=${i}, quantity=${t}`);let r=JSON.parse(JSON.stringify(this.getModifiersSetsState())),s=r[e].modifiers[i];if(!s)throw Error("Modifier is undefined");s.count=t,r[e].modifiers[i]=s,this.openedMealProduct?this.openedMealProductModifiersSetsState=r:this.modifiersSetsState=r,this.price=this.getTotalPrice(),super.notifyViewAboutChanges()};onPizzaPartOfModifierChanged=(e,i,t)=>{this.errorLogger.log("ProductOrderViewModelImpl.onPizzaPartOfModifierChanged",`modifierSetId=${e}, modifierId=${i}, pizzaSide=${t}`);let r=JSON.parse(JSON.stringify(this.modifiersSetsState)),s=r[e].modifiers[i];if(!s)throw Error("Modifier is undefined");s.pizzaSide!==t&&((s.pizzaSide===n.PizzaSide.LEFT||s.pizzaSide===n.PizzaSide.RIGHT)&&(t===n.PizzaSide.LEFT||t===n.PizzaSide.RIGHT)||((s.pizzaSide===n.PizzaSide.LEFT||s.pizzaSide===n.PizzaSide.RIGHT)&&t===n.PizzaSide.FULL?s.price=Number(Number(2*s.price).toFixed(2)):s.price=Number(Number(s.price/2).toFixed(2))),s.pizzaSide=t,r[e].modifiers[i]=s,this.modifiersSetsState=r,this.price=this.getTotalPrice(),super.notifyViewAboutChanges())};onModifierOptionClicked=(e,i,t)=>{this.errorLogger.log("ProductOrderViewModelImpl.onPizzaPartOfModifierChanged",`modifierSetId=${e}, modifierId=${i}, modifier=${JSON.stringify(t)}`);let r=JSON.parse(JSON.stringify(this.modifiersSetsState)),s=r[e].modifiers[i];if(!s)throw Error("Modifier is undefined");s.isModifierOptionSelected=!s.isModifierOptionSelected,s.isModifierOptionSelected&&(s.selectedModifierOptionName=t.modifierOption?.name,s.selectedModifierOptionId=t.modifierOption?.modifierOptionId),r[e].modifiers[i]=s,this.modifiersSetsState=r,super.notifyViewAboutChanges(),s.isModifierOptionSelected&&this.onModifierOptionSelected(e,i,t,void 0)};onModifierOptionSelected=(e,i,t,r)=>{this.errorLogger.log("ProductOrderViewModelImpl.onModifierOptionSelected",`modifierSetId=${e}, modifierId=${i}, modifier=${JSON.stringify(t)}, option=${r}`);let s=JSON.parse(JSON.stringify(this.getModifiersSetsState())),o=s[e].modifiers[i];if(!o)throw Error("Modifier is undefined");r&&(o.selectedModifierOptionName=t.modifierOption?.name,o.selectedModifierOptionId=t.modifierOption?.modifierOptionId),o.selectedModifierOption=r,s[e].modifiers[i]=o,this.openedMealProduct?this.openedMealProductModifiersSetsState=s:this.modifiersSetsState=s,super.notifyViewAboutChanges()};onVendorAddToCartClicked=e=>{this.errorLogger.log("ProductOrderViewModelImpl.onVendorItemSelected"),this.selectedVendor=e,this.onClickOrderProductItem()};onClickOrderProductItem=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onClickOrderProductItem");let e=this.cart.getOrders();if(this.isShowStorePickupOnly){let i=e.find(e=>p.ProductShippingHelper.isDeliveryOnly(e.availableShippingMethods));
1if(i){this.errorDialogMessage=`The order contains the product (${i.itemName}) for which delivery shipping method only is available.`,this.isShowErrorDialog=!0,super.notifyViewAboutChanges();return}if(!e.some(e=>p.ProductShippingHelper.isStorePickupOnly(e.availableShippingMethods))){this.confirmationMessage="This item is a <span>store pickup only</span> item. All items on this order will have to be <span>picked up at the store</span>.",this.isShowConfirmationDialog=!0,super.notifyViewAboutChanges();return}}if(this.isShowDeliveryOnly){let i=e.find(e=>p.ProductShippingHelper.isStorePickupOnly(e.availableShippingMethods));if(i){this.errorDialogMessage=`The order contains the product (${i.itemName}) for which store pickup shipping method only is available.`,this.isShowErrorDialog=!0,super.notifyViewAboutChanges();return}if(!e.some(e=>p.ProductShippingHelper.isDeliveryOnly(e.availableShippingMethods))){this.confirmationMessage="This item is a <span>delivery only</span> item. All items on this order will have to be <span>delivered</span>.",this.isShowConfirmationDialog=!0,super.notifyViewAboutChanges();return}}this.onOrderConfirmed()};onOrderConfirmed=async()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.onOrderConfirmed"),this.isShowConfirmationDialog=!1,this.isShowErrorDialog=!1,super.notifyViewAboutChanges(),!(this.quantity<=0)){if(this.validateModifiers()&&this.validateGiftCard()){let e;if(!this.productItem)throw Error("Product item is undefined");if(!this.store?.id)throw Error("Company id is undefined");if(!this.menuId)throw Error("Menu id is undefined");if(!this.store)throw Error("Store information id is undefined");let i=this.selectedProductVariant||this.productItem,t=this.getSelectedMatrix(),s=this.selectedVendor||this.openedVendorProduct;this.selectedProductVariant&&(e=this.productItem.productVariants.find(e=>e.id===this.selectedProductVariant?.id)?.productVariantId);let o={orderId:crypto.randomUUID(),stockCount:i.stock||this.qtyOnStock,isTrackInventary:!!this.productItem.trackInventory,companyId:this.store.id,menuId:i.menuId||this.menuId,matrixProductTotalPrice:i.predefinedModifierSets&&i.predefinedModifierSets.length>0?this.getTotalPrice()/this.quantity:void 0,isRetailProduct:!!this.isRetailProduct,categoryName:this.categoryName,vendorName:s?.name||this.vendorName,vendorId:s?.id||i.vendorId,itemId:i.id,code:t?.sku||i.code,itemPrice:s?.price||t?.price||i.price,originalPrice:t?.originalPrice||i.originalPrice,itemName:t?.name||i.name,isOnSale:t?t.isOnSale:i.isOnSale,isService:!!i?.isService,count:this.productItem.isGiftCard?1:this.productItem.isMembership?this.productItem.membership.chargeInFull?this.productItem.membership.term:1:this.settings.siteType!==a.SiteType.CONSUMER&&this.productItem.purchasingUnitQuantity?this.productItem.purchasingUnitQuantity*Number(this.quantity):Number(this.quantity),allowDecimalCount:!1,modifierSets:this.modifiersSetsState,subscriptionId:this.isSubscriptionChecked?this.checkedSubscriptionId:void 0,subscriptionPeriod:this.checkedSubscriptionId?this.possibleSubscriptions.filter(e=>e.id===this.checkedSubscriptionId)[0]?.name:void 0,largeImageUrl:t?.imageUrl||i.largeImageUrl,availableShippingMethods:i.availableShippingMethods,isPickupAllowed:i.isPickupAllowed,isDeliverAllowed:i.isDeliverAllowed,isGiftCard:i.isGiftCard,giftCardPrice:i.isGiftCard?this.price:void 0,recipientName:this.recipientName,recipientEmail:this.recipientEmail,isMembership:i.isMembership,membership:i.membership,isAstroProduct:i.isAstroProduct,notes:i?.enableNotes?this.productNotes:void 0,purchasingUnitQuantity:i?.purchasingUnitQuantity,purchasingUnitName:i?.purchasingUnitName,isUncheckedManuallyInCart:!1,isVendorError:!1,itemSource:this.itemSource,relatedProductId:e,potentialDiscounts:i.potentialDiscounts};if(this.isMealMode){if(this.productItem.id===this.rootMealId&&!this.isAllMealMenusCompleted())return;let e=JSON.parse(JSON.stringify(o));if(this.rootMeal){let i=(this.rootMeal.mealMenu?.items||[]).filter(e=>e.menuId===o.menuId)[0];i&&(e.mealMenuDisplayOrder=i.displayOrder)}this.addedMealProducts.push(new r.default(e)),this.qtyOnStock=this.qtyOnStock-o.count,this.productItem.id===this.rootMealId&&this.onCompleteMealsOrder(),this.isDisplayMealProduct=!0,this.productItem=this.rootMeal,this.modifiersSetsState=this.rootMealModifiersSetsState}else{if(this.isBundleProduct){let e=o.count;this.removeEditinOrderFromTheCart();for(let i=0;i<e;i+=1){let e=crypto.randomUUID();o.bundleGroupId=e,o.bundleId=o.itemId,o.isBundleRoot=!0,o.count=1,o.orderId=o.orderId+i,this.cart.addOrder(o),this.bundleProducts.forEac
1h((i,t)=>{let r={orderId:crypto.randomUUID(),stockCount:i.stock||1,isTrackInventary:!this.selectedProductVariant&&!!i.trackInventory,companyId:this.store.id,menuId:this.selectedProductVariant?this.selectedProductVariant.menuId:this.menuId,isRetailProduct:!!this.isRetailProduct,categoryName:this.categoryName,vendorName:this.vendorName,code:this.selectedProductVariant?this.selectedProductVariant.code:this.productItem?.code,itemId:this.selectedProductVariant?this.selectedProductVariant.id:i.id,itemPrice:this.selectedProductVariant?this.selectedProductVariant.price:i.price,itemName:this.selectedProductVariant?this.selectedProductVariant.name:i.name,count:Number(i.quantity||1),allowDecimalCount:!1,isService:!!i.isService,modifierSets:this.modifiersSetsState,subscriptionId:this.isSubscriptionChecked?this.checkedSubscriptionId:void 0,subscriptionPeriod:this.checkedSubscriptionId?this.possibleSubscriptions.filter(e=>e.id===this.checkedSubscriptionId)[0]?.name:void 0,largeImageUrl:i.imageUrl||h.IMAGE_NOT_FOUND_URL,availableShippingMethods:i.availableShippingMethods??[],isPickupAllowed:i.isPickupAllowed??!1,isDeliverAllowed:i.isDeliverAllowed??!1,bundleId:o.bundleId,bundleGroupId:e,isBundleRoot:!1,isBundleChild:!0,isLastBundleChild:this.bundleProducts.length-1===t,notes:this.productItem?.enableNotes?this.productNotes:void 0,purchasingUnitQuantity:i?.purchasingUnitQuantity,purchasingUnitName:i?.purchasingUnitName,isUncheckedManuallyInCart:!1,isVendorError:!1};this.cart.addOrder(r),this.qtyOnStock=this.qtyOnStock-o.count,this.recipientName="",this.recipientEmail=""})}this.onProductAdded&&this.onProductAdded()}else{let e;this.removeEditinOrderFromTheCart(),this.store.groupOrderItemsByProduct&&(e=this.cart.getOrderForGroupingByProduct(o)),e?(e.count+=o.count,this.cart.updateOrder(new r.default(e))):this.cart.addOrder(o),this.qtyOnStock=this.qtyOnStock-o.count,super.notifyViewAboutChanges(),this.onProductAdded&&this.onProductAdded()}this.onClose()}this.setQuantity(this.qtyOnStock<=0?0:1),super.notifyViewAboutChanges(),this.analyticsHelper.trackAddToCart(i,o.count)}this.selectedVendor=void 0,this.isAddCartButtonEnabled=!this.productItem?.trackInventory||this.qtyOnStock>=this.quantity,this.isNoItemsOnStockError=!!this.productItem?.trackInventory&&this.qtyOnStock<this.quantity,super.notifyViewAboutChanges()}};onMealOrderConfirmed=()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.onMealOrderConfirmed"),!this.openedMealProduct)return void u.toast.danger("Meal product cannot be added. Please try again");if(!this.validateModifiers())return void u.toast.danger("Please complete all required modifiers");let e={orderId:crypto.randomUUID(),stockCount:this.openedMealProduct.stock||this.qtyOnStock,isTrackInventary:!!this.openedMealProduct.trackInventory,companyId:this.store.id,menuId:this.openedMealProductMenuId||this.openedMealProduct.menuId,matrixProductTotalPrice:this.openedMealProduct.predefinedModifierSets&&this.openedMealProduct.predefinedModifierSets.length>0?this.getTotalPrice()/this.quantity:void 0,isRetailProduct:!!this.isRetailProduct,categoryName:this.categoryName,vendorName:this.vendorName,itemId:this.openedMealProduct.id,code:this.openedMealProduct.code,itemPrice:this.openedMealProduct.price,originalPrice:this.openedMealProduct.originalPrice,itemName:this.openedMealProduct.name,isOnSale:this.openedMealProduct.isOnSale,count:this.settings.siteType!==a.SiteType.CONSUMER&&this.openedMealProduct.purchasingUnitQuantity?this.openedMealProduct.purchasingUnitQuantity*Number(this.quantity):Number(this.quantity),allowDecimalCount:!1,modifierSets:this.openedMealProductModifiersSetsState,isService:!1,subscriptionId:this.isSubscriptionChecked?this.checkedSubscriptionId:void 0,subscriptionPeriod:this.checkedSubscriptionId?this.possibleSubscriptions.filter(e=>e.id===this.checkedSubscriptionId)[0]?.name:void 0,largeImageUrl:this.openedMealProduct.largeImageUrl,availableShippingMethods:this.openedMealProduct.availableShippingMethods,isPickupAllowed:this.openedMealProduct.isPickupAllowed,isDeliverAllowed:this.openedMealProduct.isDeliverAllowed,isGiftCard:this.openedMealProduct.isGiftCard,giftCardPrice:this.openedMealProduct.isGiftCard?this.price:void 0,recipientName:this.recipientName,recipientEmail:this.recipientEmail,isMembership:this.openedMealProduct.isMembership,membership:this.openedMealProduct.membership,isAstroProduct:this.openedMealProduct.isAstroProduct,notes:this.openedMealProduct?.enableNotes?this.productNotes:void 0,purchasingUnitQuantity:this.openedMealProduct?.purchasingUnitQuantity,purchasingUnitName:this.openedMealProduct?.purchasingUnitName,isUncheckedManuallyInCart:!1,isVendorError:!1,itemSource:this.itemSource,potentialDiscounts:this.openedMealProduct.potentialDiscounts},i=JSON.parse(JSON.stringify(e));if(this.productItem){let t=(this.productItem.mealMenu?.items||[]).filter(i=>i.menuId===e.menuId)[0];t&&(i.mealMenuDisplayOrder=t.displayOrder)}this.addedMealProducts.push(new r.default(i)),this.onCloseMealProduct()};isProductInCart=e=>!!e&&this.cart.getOrders().filter(e=>!e.isBundleChild&&!e.isMealChild).some(i=>i.itemId===e.id);onCloseConfirmationOrErrorDialog=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onCloseConfirmationOrErrorDialog"),this.isShowConfirmationDialog=!1,this.isShowErrorDialog=!1,super.notifyViewAboutChanges()};isModifierQtyOnStockZero=(e,i)=>{let t=!1,r=!0,s=(e=>{let i=new Set,t=this.openedMealProduct?this.openedMealProductModifiersSetsState:this.modifiersSetsState;if(!t)return i;for(let[r,s]of Object.entries(t))if(null==e||Number(r)!==e)for(let[e,t]of Object.entries(s?.modifiers||{}))t&&i.add(String(e));return i})(i),o=String(e),d=(e,i=new Set)=>{if(r&&e&&"object"==typeof e)for(let[n,a]of Object.entries(e)){if(!a||"object"!=typeof a)continue;let e=new Set(i);if(e.add(String(n)),"stockQty"in a){let i=e.has(o),d=[...s].every(i=>e.has(i));if(i&&d&&(t=!0,(Number(a.stockQty)||0)>0)){r=!1;return}continue}if(d(a,e),!r)return}},n=this.openedMealProduct?this.openedMealProductPredifinedModifiersState:this.predifinedModifiersState;return n&&d(n),t&&r};isModifierEnabled=e=>(this.errorLogger.log("ProductOrderViewModelImpl.isModifierEnabled",`checkingModifierId=${e}`),this.isModifierEnableWithoutReplacemement(e));onClose=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onClose"),this.isCloseOrderDialog=!0,super.notifyViewAboutChanges()};onDialogClosed=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onDialogClosed"),this.isCloseOrderDialog=!1,super.notifyViewAboutChanges()};onMenuTabChoosed=async e=>{this.errorLogger.log("ProductOrderViewModelImpl.onMenuTabChoosed",`menuId=${e}`),this.mealMenuWithError=void 0,this.isShowMealMenusErrors=!1,this.isDisplayMealProduct=!1,this.openedMenuId=e,super.notifyViewAboutChanges(),setTimeout(()=>{this.onLoadingDetectorReached()},250)};onChooseMoreProductsClicked=async()=>{this.errorLogger.log("ProductOrderViewModelImpl.onChooseMoreProductsClicked"),this.isShowProductsList=!0,this.isDisplayMealProduct=!1,super.notifyViewAboutChanges()};onOpenMealProduct=async(e,i)=>{this.errorLogger.log("ProductOrderViewModelImpl.onOpenMealProduct",`menuId=${e}, productId=${i}`);try{this.isMealProductLoading=!0,super.notifyViewAboutChanges();let{data:t,error:r}=await this.storeRepository.getMenuItem(this.store.id,e,i,void 0,this.store.isRestaurant);if(r?.message)throw Error(r.message);t.modifierSets||(t.modifierSets=[]);let[s,o]=this.createModifiersInitStates(t);this.openedMealProductPredifinedModifiersState=o||{},this.openedMealProductMenuId=e,this.openedMealProduct=t;let d=this.addedMealProducts.find(e=>e.itemId===t.id);d?this.openedMealProductModifiersSetsState=d.modifierSets:this.openedMealProductModifiersSetsState=s,0===Object.keys(s).length&&this.onMealOrderConfirmed()}catch(e){u.toast.danger(e.message),console.error(e)}finally{this.isMealProductLoading=!1,super.notifyViewAboutChanges()}};onCloseMealProduct=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onCloseMealProduct"),this.openedMealProduct=void 0,this.openedMealProductModifiersSetsState={},this.openedMealProductPredifinedModifiersState={},this.openedMealProductMenuId=void 0,super.notifyViewAboutChanges()};onRemoveMealProduct=e=>{this.errorLogger.log("ProductOrderViewModelImpl.onRemoveMealProduct",`orderId=${e}`),this.addedMealProducts.splice(this.addedMealProducts.indexOf(this.addedMealProducts.filter(i=>i.orderId===e)[0]),1),super.notifyViewAboutChanges(),u.toast.success("Product have been removed")};onClickNext=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onClickNext"),this.isDisplayMealProduct||!this.isMealMode?this.onOrderConfirmed():(this.isDisplayMealProduct=!0,super.notifyViewAboutChanges())};onCompleteMealsOrder=()=>{this.errorLogger.log("ProductOrderViewModelImpl.onCompleteMealsOrder");let e=this.addedMealProducts[this.addedMealProducts.length-1].itemId,i=crypto.randomUUID();this.addedMealProducts.unshift(this.addedMealProducts.pop()),this.recalculateMealPrices(),this.removeEditinOrderFromTheCart();for(let t=0;t<this.addedMealProducts.length;t+=1){let r=this.addedMealProducts[t];r.mealId=e,r.mealGroupId=i,r.isLastMealChild=!1,0===t&&(r.isMealRoot=!0,r.menuId=this.rootMealMenuId,r.itemPrice=this.addedMealProducts.slice(1).reduce((e,i)=>e+(i.isFreeMealItem?0:i.getItemCost()),this.addedMealProducts[0].itemPrice)),0!==t&&(r.isMealChild=!0),t===this.addedMealProducts.length-1&&(r.isLastMealChild=!0),this.cart.addOrder(r)}this.onProductAdded&&this.onProductAdded(),this.onClose()};onRecipientEmailChanged=e=>{this.errorLogger.log("ProductOrderViewModelImpl.onRecipientEmailChanged",`query=${e}`),this.recipientEmail=e,this.isRecipientEmailError=!1,super.notifyViewAboutChanges()};onRecipientNameChanged=e=>{this.errorLogger.log("ProductOrderViewModelImpl.onRecipientNameChanged",`query=${e}`),this.recipientName=e,this.isRecipientNameError=!1,super.notifyViewAboutChanges()};onLoadingDetectorReached=async()=>
1{if(this.errorLogger.log("ProductOrderViewModelImpl.onLoadingDetectorReached"),!this.openedMenuId)return;let e=this.mealsMenuBranches.filter(e=>e.getBranchMenuItem().id===this.openedMenuId)[0];if(!(!e||e?.getIfAllItemsLoaded())&&!this.isMealsProductsRequesting){this.isMealsProductsRequesting=!0,this.isLoadingItems=!0,super.notifyViewAboutChanges();let{data:i}=await this.storeRepository.getCategoriesProducts(this.store.id,this.openedMenuId,e.getBranchProducts().length,void 0,!0),t=i.data||[];e.addNewItems(t),t.length<0&&e.setAllItemsLoaded(!0),this.isMealsProductsRequesting=!1,this.isLoadingItems=!1,super.notifyViewAboutChanges()}};isAllMealMenusCompleted=()=>{for(let e of(this.errorLogger.log("ProductOrderViewModelImpl.isAllMealMenusCompleted"),this.mealMenuWithError=void 0,super.notifyViewAboutChanges(),this.mealsMenus)){let i=this.addedMealProducts.filter(i=>i.menuId===e.menuId).length;if(void 0!==e.minItems&&null!==e.minItems&&i<e.minItems)return this.mealMenuWithError=e,super.notifyViewAboutChanges(),u.toast.danger(`Please choose more required products: ${e.menuName}`),!1}return!0};recalculateMealPrices=()=>{this.errorLogger.log("ProductOrderViewModelImpl.recalculateMealPrices");let e=this.addedMealProducts.splice(0,1)[0];this.addedMealProducts.sort((e,i)=>void 0===e.mealMenuDisplayOrder||void 0===i.mealMenuDisplayOrder?0:e.mealMenuDisplayOrder>i.mealMenuDisplayOrder?1:e.mealMenuDisplayOrder<i.mealMenuDisplayOrder?-1:0),this.addedMealProducts.unshift(e);for(let e=0;e<this.addedMealProducts.length;e+=1){let i=this.addedMealProducts[e];i&&(i.isFreeMealItem=0!==e&&e<=this.freeMealItemsCount)}};validateModifiers=()=>{this.errorLogger.log("ProductOrderViewModelImpl.validateModifiers");let e={},i=0,t=this.getModifiersSetsState();return Object.keys(t).forEach(r=>{if(t[r].isRequired){let s=!1;Object.values(t[r].modifiers).forEach(e=>{e&&(s=!0)}),s?(e[r]||(e[r]={}),e[r].error=void 0):(e[r]||(e[r]={}),e[r].error="This field is required",i+=1)}let s=0,o=!1;if(Object.values(t[r].modifiers).forEach(i=>{i&&(i.count&&(s+=i.count),i.requireModifierOption&&!i.selectedModifierOption&&(o=!0,e[r]||(e[r]={}),e[r].error=`Please choose an option for ${i.name}`))}),o){i+=1;return}if(0===s&&!t[r].isRequired){e[r]||(e[r]={}),e[r].error=void 0;return}(!e[r]||"This field is required"!==e[r].error)&&(e[r]||(e[r]={}),e[r].error=void 0,s<t[r].minNumberOfModifiersRequired&&(e[r]||(e[r]={}),e[r].error=`Should be more than ${t[r].minNumberOfModifiersRequired-1}`,i+=1),s>t[r].maxNumberOfModifiersRequired&&0!==t[r].maxNumberOfModifiersRequired&&(e[r]||(e[r]={}),e[r].error=`Should be less than ${t[r].maxNumberOfModifiersRequired+1}`,i+=1))}),this.setModifiersSetsState(t),this.modifierSetsErrors=e,super.notifyViewAboutChanges(),0===i};validateGiftCard=()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.validateGiftCard"),this.productItem?.isGiftCard){if(!this.recipientName)return this.isRecipientNameError=!0,super.notifyViewAboutChanges(),!1;if(!this.recipientEmail||!o.FormValidator.isValidEmail(this.recipientEmail))return this.isRecipientEmailError=!0,super.notifyViewAboutChanges(),!1}return!0};setModifiersSetsState=e=>{this.openedMealProduct?this.openedMealProductModifiersSetsState=e:this.modifiersSetsState=e,super.notifyViewAboutChanges()};getModifiersSetsState=()=>this.openedMealProduct?this.openedMealProductModifiersSetsState:this.modifiersSetsState;getPredifinedModifiersState=()=>this.openedMealProduct?this.openedMealProductPredifinedModifiersState:this.predifinedModifiersState;isModifierEnableWithoutReplacemement=e=>{let i;this.errorLogger.log("ProductOrderViewModelImpl.isModifierEnableWithoutReplacemement",`checkingModifierId=${e}`);let t=this.getPredifinedModifiersState();if(!t)return!0;let r=this.getModifiersSetsState(),s=[];Object.keys(r).forEach(e=>{r[e].isRequired&&Object.keys(r[e].modifiers).forEach(i=>{r[e].modifiers[i]&&s.push(i)})});let o=this.openedMealProduct?this.openedMealProduct:this.productItem;if(!o)throw Error("Product item is undefined");let d=this.getParentSetIdOfModifier(e,o),n=!1;s.forEach(e=>{this.getParentSetIdOfModifier(Number(e),o)===d&&(n=!0,i=e)}),n&&i&&s.splice(s.indexOf(i),1);let a=!0,h=t;if(s.reduce((e,i)=>
1((!e[i]).isPossible&&(a=!1),h=e[i],e[i]),t),!a)return!1;let l=`${e}`;return!!(h[l]&&h[l].isPossible)};createModifiersInitStates=e=>{let i;this.errorLogger.log("ProductOrderViewModelImpl.createModifiersInitStates",`productItem=${JSON.stringify(e)}`);let t={};e.modifierSets.forEach(e=>{t[e.modifierSetId]={isRequired:!!e.isRequired,minNumberOfModifiersRequired:e.minNumberOfModifiersRequired,maxNumberOfModifiersRequired:e.maxNumberOfModifiersRequired,error:!1,modifiers:{}},e.items.forEach(i=>{i.isSelected&&(t[e.modifierSetId].modifiers[i.modifierId]={modifierSetName:e.modifierSetName,name:i.modifierName,price:Number(i.price),priceType:Number(i.priceType),count:Number(i.qty),isEnableQuantitySelection:i.enableQuantitySelection,requireModifierOption:i.requireModifierOption,selectedModifierOptionId:i.modifierOption?.modifierOptionId,selectedModifierOptionName:i.modifierOption?.name,selectedModifierOption:i.modifierOption&&i.modifierOption.options?i.modifierOption.options[0]:void 0,pizzaSide:3===e.modifierSetType?15:void 0},t[e.modifierSetId].modifiers[i.modifierId]?.count===0&&(t[e.modifierSetId].modifiers[i.modifierId].count=1))})});let{predefinedModifierSets:r}=e;return r&&r.length>0?(this.isUsePredefinedModifiersStockAndPrice=!0,super.notifyViewAboutChanges(),i={},r.forEach(t=>{t.stock>0&&!this.isAnyPredefinedSetIsAvailableOnStock&&(this.isAnyPredefinedSetIsAvailableOnStock=!0);let{modifiers:r}=t,s=[];r.forEach(e=>{s.push(e.value)}
1),this.getAllArrayPermutations(s).forEach(r=>{if(!i)throw Error("PredefinedModifiersState is undefined");let s={};r.reduce((i,t)=>{if(void 0===i)throw Error("Accumulator is undefined");if(i[t]){let r=this.getParentSetIdOfModifier(t,e);i[t]={...i[t],parentSetId:r}}else{let r=this.getParentSetIdOfModifier(t,e);i[t]={isPossible:!0,parentSetId:r}}return s=i[t],i[t]},i),s.price=t.price;let o=t.stock;s.stockQty=o<=0?0:o})})):this.isSimpleProduct=!0,[t,i]};getParentSetIdOfModifier=(e,i)=>{let t;return this.errorLogger.log("ProductOrderViewModelImpl.getParentSetIdOfModifier",`modifierId=${e}, productItem=${JSON.stringify(i)}`),i.modifierSets.forEach(i=>{i.items.forEach(r=>{e===r.modifierId&&(t=i.modifierSetId)})}),t};getAllArrayPermutations=e=>{this.errorLogger.log("ProductOrderViewModelImpl.getAllArrayPermutations",`array=${JSON.stringify(e)}`);let i=[];for(let t=0;t<e.length;t+=1){let r=this.getAllArrayPermutations(e.slice(0,t).concat(e.slice(t+1)));if(r.length)for(let s=0;s<r.length;s+=1)i.push([e[t]].concat(r[s]));else i.push([e[t]])}return i};getTotalPrice=()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.getTotalPrice"),this.productItem?.isGiftCard)return this.isAddToWishlistButtonEnabled=!!this.quantity,this.quantity;if(this.productItem&&this.productItem.isMembership)if(this.productItem.membership.chargeInFull)return this.productItem.price*this.productItem.membership.term;else return this.productItem.price;if(this.predifinedModifiersState){let e=[];Object.keys(this.modifiersSetsState).forEach(i=>{this.modifiersSetsState[i].isRequired&&Object.keys(this.modifiersSetsState[i].modifiers).forEach(t=>{this.modifiersSetsState[i].modifiers[t]&&e.push(t)})});let i=this.predifinedModifiersState;return e.reduce((e,t)=>(i=e[t],e[t]),this.predifinedModifiersState),this.isUsePredefinedModifiersStockAndPrice&&(this.qtyOnStock=i.stockQty-this.getSameProductInTheCartQty(),this.qtyOnStock<=0?(this.isQtyOnStockIsZero=!0,this.qtyOnStock=999):this.isQtyOnStockIsZero=!1,this.isAddCartButtonEnabled=!this.productItem?.trackInventory||this.qtyOnStock>=this.quantity,this.isNoItemsOnStockError=!!this.productItem?.trackInventory&&this.qtyOnStock<this.quantity,super.notifyViewAboutChanges()),i.price?Number(Number(i.price*this.quantity).toFixed(2)):0}if(this.isAddCartButtonEnabled=!this.productItem?.trackInventory||this.qtyOnStock>=this.quantity,this.isNoItemsOnStockError=!!this.productItem?.trackInventory&&this.qtyOnStock<this.quantity,super.notifyViewAboutChanges(),!this.productItem)throw Error("Product item is undefined");let e=this.selectedProductVariant?this.selectedProductVariant.price:this.productItem.price;return Object.keys(this.modifiersSetsState).forEach(i=>{Object.values(this.modifiersSetsState[i].modifiers).forEach(i=>{this.productItem&&(e+=r.default.getModifierPrice(i,this.productItem.price))})}),Number((e*=this.quantity).toFixed(2))};getSameProductInTheCartQty=()=>{this.errorLogger.log("ProductOrderViewModelImpl.getSameProductInTheCartQty");let e=this.selectedProductVariant||this.productItem;return e?this.cart.getSameProductCount(e.id,!!this.isRetailProduct,this.modifiersSetsState):0};removeEditinOrderFromTheCart=()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.removeEditinOrderFromTheCart"),this.editingOrder)if(this.editingOrder.mealGroupId)for(let e of this.cart.getOrders().filter(e=>e.mealGroupId===this.editingOrder?.mealGroupId))this.cart.removeOrder(e);else this.cart.removeOrder(this.editingOrder)};isProductInWishlist=async()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.isProductInWishlist"),!this.wishlist||!this.productItem)return!1;let e=[];return this.modifiersSetsState&&Object.keys(this.modifiersSetsState).forEach(i=>{Object.values(this.modifiersSetsState[i].modifiers).forEach(i=>{e.push(i?.name)})}),this.wishlist.isProductInWishlist(this.productItem.id,void 0,e)};onAddToWishlistButton=async()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.onAddToWishlistButton"),!this.isAuthorized)return void this.openSignIn();if(!this.wishlist)return;let e=this.createItemForStoredWishlist();if(e){if(this.isWishlistLoading=!0,super.notifyViewAboutChanges(),await this.wishlist.isProductInWishlist(e.id,this.modifiersSetsState)){await this.wishlist.removeItemFromWishlist(e),this.isWishlistLoading=!1,super.notifyViewAboutChanges(),u.toast.success(`Product has been removed from the ${this.store.wishlistName||"wishlist"}`);return}return this.validateModifiers()?(this.validateModifiers()&&(await this.wishlist.addItemToWishlist(e),this.analyticsHelper.trackAddToWishlist(this.selectedProductVariant||this.productItem)),this.isWishlistLoading=!1,super.notifyViewAboutChanges(),u.toast.success(`Product has been added to the ${this.store.wishlistName||"wishlist"}`),!0):(this.isWishlistLoading=!1,super.notifyViewAboutChanges(),!1)}};openSignIn=()=>{this.errorLogger.log("ProductOrderViewModelImpl.openSignIn"),this.isSignInShown=!0,super.notifyViewAboutChanges()};closeSignIn=()=>{this.errorLogger.log("ProductOrderViewModelImpl.closeSignIn"),this.isSignInShown=!1,super.notifyViewAboutChanges()};updateProductInfoWithMatrixSet=()=>{let e=this.getSelectedMatrix();e||(this.selectedMatrixSet=void 0,this.productViewModel?.setMatr
1ix(void 0)),this.selectedMatrixSet=e,this.productViewModel?.setMatrix(e),super.notifyViewAboutChanges()};getSelectedMatrix=()=>{let e=Object.keys(this.modifiersSetsState).map(e=>{let i=Object.keys(this.modifiersSetsState[e].modifiers)[0];return{key:Number(e),value:Number(i)}}),i=!0;for(let t of e)if(!t.value){i=!1;break}if(i&&this.productItem?.predefinedModifierSets){for(let i of this.productItem.predefinedModifierSets)if(JSON.stringify(i.modifiers)===JSON.stringify(e)){let e=i.imageUrl||this.productItem?.images&&this.productItem.images[0]||h.IMAGE_NOT_FOUND_URL;return{name:i.name,sku:i.sku,originalPrice:i.originalPrice,price:this.getTotalPrice(),isOnSale:i.isOnSale,imageUrl:e}}}};setProductOrderDetails=e=>{this.errorLogger.log("ProductOrderViewModelImpl.onProductVariantSelected",`productVariant=${JSON.stringify(e)}`);let i=e||this.productItem;if(!i)return;if(this.settings.siteType!==a.SiteType.CONSUMER&&i?.vendorId&&this.store?.vendors){let e=this.store.vendors.find(e=>e.id===i.vendorId);this.vendorName=e?.name}this.allowDecimalCount=!1,this.stockUnit=i?.stockUnit||"",this.priceUnit=i?.priceUnit||"$",this.isAnyPredefinedSetIsAvailableOnStock=!i?.trackInventory;let[t,r]=this.createModifiersInitStates(i);this.isShowStockAmount=!!i?.trackInventory,this.modifiersSetsState=t,this.predifinedModifiersState=r,this.price=this.getTotalPrice(),this.updatePickupAndDeliveryMessages(i),i?.subscriptions&&i?.subscriptions.length>0?this.possibleSubscriptions=i?.subscriptions:this.possibleSubscriptions=[],this.isSubscriptionChecked=!1,this.checkedSubscriptionId=void 0,this.relatedProducts=i?.relatedProducts||[];try{this.quickSelectionNumbers=i?.quickQuantities?i.quickQuantities.split(",").map(e=>Number(e)):[]}catch(e){this.quickSelectionNumbers=[]}this.isShowProductsList=!0,this.mealMenuWithError=void 0,this.isShowMealMenusErrors=!1;let s=i?.stock?i?.stock-this.getSameProductInTheCartQty():0;this.allowOrderOutOfStockItems?(this.quantity=1,this.qtyOnStock=this.settings.siteType!==a.SiteType.CONSUMER?0x3b9ac9ff:999):s<=0?(this.quantity=1,this.isQtyOnStockIsZero=!0,this.qtyOnStock=this.settings.siteType!==a.SiteType.CONSUMER?0x3b9ac9ff:999):(this.isQtyOnStockIsZero=!1,this.qtyOnStock=s<=0?0:s),this.productQtyOnStock=s,this.isAddToWishlistButtonEnabled=!i?.trackInventory||this.isQtyOnStockIsZero||this.qtyOnStock>=this.quantity,this.isAddCartButtonEnabled=!i?.trackInventory||this.qtyOnStock>=this.quantity,this.isNoItemsOnStockError=!!i?.trackInventory&&this.qtyOnStock<this.quantity,i?.isGiftCard&&(i.trackInventory=!1,this.quantity=0,this.price=this.getTotalPrice(),this.isAddToWishlistButtonEnabled=!1)};updateUrlWithMatrixCombination=()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.updateUrlWithMatrixCombination"),this.isProductPreview||this.store?.isRestaurant)return;let{categoryId:e,productIdentifier:i,matrix:t}=this.browserHistoryHelper.getRoutes(),r=t&&t[0]||"",s=new Map;r&&r.split(";").forEach(e=>{let[i,t]=e.split("=");i&&t&&s.set(i,t)});let o=new Map;for(let e in this.modifiersSetsState){let i=this.modifiersSetsState[e];if(i&&!i.error)for(let e in i.modifiers){let t=i.modifiers[e];if(t){let e=t.modifierSetName,i=t.name;o.set(e||"",i||"")}}}for(let e of s.keys())o.has(e)||s.delete(e);for(let[e,i]of o)s.set(e,i);let n=Array.from(s.entries()).map(([e,i])=>`${e}=${i}`).join(";"),a=d.UrlUtils.getLink(this.store,this.settings,"product",`${e}/${i}`);n&&(a+=`/${n}`),this.browserHistoryHelper.replaceCurrectUrlInHistory(a,!0)};setMatrixCombinationFromUrl=()=>{if(this.errorLogger.log("ProductOrderViewModelImpl.setMatrixCombinationFromUrl"),this.isProductPreview||!this.isRetailProduct||this.selectedProductVariant)return;let{matrix:e}=this.browserHistoryHelper.getRoutes();if(!e||!e[0])return;let i=e[0]||"",t={};for(let[e,r]of(i.split(";").forEach(e=>{let[i,r]=e.split("=");i&&r&&(t[i]=r)}),Object.entries(t))){let i=this.productItem?.modifierSets.find(i=>i.modifierSetName===e);if(i){let e=i?.items.find(e=>e.modifierName===r);e&&this.onModifierChecked(i,e)}}super.notifyViewAboutChanges()};createItemForStoredWishlist=()=>{let e=this.selectedProductVariant||this.productItem;
1if(!e?.id)return;let i={...this.isSubscriptionChecked&&{checkedSubscriptionId:this.checkedSubscriptionId,subscriptionPeriod:this.possibleSubscriptions.filter(e=>e.id===this.checkedSubscriptionId)[0]?.name}},t={...Object.keys(this.modifiersSetsState).length>0&&{modifierSets:this.modifiersSetsState}};return{additionalData:Object.keys(i).length>0?JSON.stringify(i):"",categoryId:e?.menuId||this.menuId||0,createdDt:new Date().toISOString(),id:e.id,modifiers:Object.keys(t).length>0?JSON.stringify(t):""}};updatePickupAndDeliveryMessages=e=>{this.isShowStorePickupOnly=p.ProductShippingHelper.isStorePickupOnly(e.availableShippingMethods),this.isShowDeliveryOnly=p.ProductShippingHelper.isDeliveryOnly(e.availableShippingMethods),super.notifyViewAboutChanges()}}e.s(["MAX_MARKETPLACE_QUANTITY",0,0x3b9ac9ff,"MAX_RETAIL_QUANTITY",0,999,"default",()=>m])}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.