mealz-components 2.4.2 → 2.5.0

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"../../drawer-view-swapper/drawer-view-swapper.min.js";import"../../slider-tabs/slider-tabs.min.js";import"../planner-onboarding-modal/planner-onboarding-modal.min.js";import"../to-basket-loader/to-basket-loader.min.js";import{o as f}from"../helpers/open-onboarding-modal.min.js";import{M as _}from"../planner-abandon-modal/planner-abandon-modal.min.js";import{M as b}from"../planner-onboarding/planner-onboarding.min.js";import{M as S}from"../planner-open-catalog-modal/planner-open-catalog-modal.min.js";import{M as B}from"../planner-welcome-modal/planner-welcome-modal.min.js";import{N as E,B as z,O as L}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as R}from"../../assets/custom-element-BhZVzxrc.js";import{r as C}from"../../assets/state-W5mtSPAs.js";import{m as o}from"../../assets/mealz-sdk-E_fNZM-c.js";import{i as k,a as P}from"../../assets/responsive-C7Qf71r3.js";import{P as O}from"../../assets/price-DAxY_7sk.js";import{g as I,f as V}from"../helpers/menu-title.min.js";import{t as l}from"../../assets/take-CozE9iSG.js";import{s as h}from"../../assets/switchMap-Dk_0Nhlo.js";import{f as q}from"../../assets/from-CAidt5N1.js";import{m}from"../../assets/map-BVOhpQm0.js";import{f as w}from"../../assets/filter-BZ75lS5D.js";import{c as T}from"../../assets/combineLatest-BmqPE0OB.js";import"../../drawer/drawer.min.js";import"../../assets/property-_7ObQ3dl.js";import"../../assets/unsafe-html-CY0Np4--.js";import"../../store-locator-drawer/store-locator-drawer.min.js";import"../../assets/skipWhile-BZVFq1Cg.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../recipe-details/recipe-details.min.js";import"../../recipe-pricing/recipe-pricing.min.js";import"../../assets/viewport-listener-CDsKFDz1.js";import"../../assets/debounceTime-B4DpnstH.js";import"../../assets/async-CFBGA-Dz.js";import"../../assets/empty-0eVnsLmk.js";import"../../assets/merge-Cm-mm3_Q.js";import"../../assets/mergeAll-BdUAXyrs.js";import"../../assets/mergeMap-Dw_YYHwH.js";import"../../assets/executeSchedule-CEDvgTzM.js";import"../../assets/args-BozZ6oU-.js";import"../../assets/isScheduler-C5PGPVU1.js";import"../../assets/capitalize-DUAqYmp4.js";import"../../counter/counter.min.js";import"../../assets/product-card-HetVhdJ3.js";import"../../price/price.min.js";import"../../assets/promotion-badge-8Arhhb-p.js";import"../../assets/delay-BNnJ-6LE.js";import"../../assets/timer-D82-ik89.js";import"../../assets/accordion-DJLqKUJq.js";import"../../store-indicator/store-indicator.min.js";import"../../store-locator/store-locator.min.js";import"../../assets/query-BApjzB0v.js";import"../../last-order-badge/last-order-badge.min.js";import"../../order-again/order-again.min.js";import"../../like-button/like-button.min.js";import"../../last-order-modal/last-order-modal.min.js";import"../../assets/tap-C8CJ3R2H.js";import"../../onboarding/onboarding.min.js";import"../../onboarding/events.min.js";import"../../onboarding/analytics/onboarding-analytics.min.js";import"../../assets/mapOneOrManyArgs-COA1aRZM.js";import"../planner-catalog/planner-catalog.min.js";import"../../catalog/catalog-load-more.min.js";import"../../assets/http-Bepz6wA4.js";import"../../replace-item/replace-item.min.js";import"../../replace-item/replace-item-card/replace-item-card.min.js";import"../../assets/price-utils-BRFZa-3D.js";import"../../assets/distinctUntilChanged-91AVuO2B.js";import"../../replace-item-planner/replace-item-planner.min.js";import"../../replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js";import"../../history-drawer/history-drawer.min.js";import"../../assets/of-DiALp3BZ.js";import"../../supplier-selector/supplier-selector.min.js";import"../../catalog/basket-preview/basket-preview.min.js";import"../../modal/modal.min.js";import"../../preferences/preferences.min.js";function x({root:e,footer:t,fixedClass:r="is-fixed"}){let n;const i=()=>{n=void 0;const a=e.getBoundingClientRect(),c=t.offsetHeight||0,u=window.innerHeight||document.documentElement.clientHeight,p=a.top<u-c&&a.bottom>u;t.classList.toggle(r,p),p?(t.style.left=`${a.left}px`,t.style.width=`${a.width}px`,e.style.paddingBottom=`${c}px`):(t.style.left="",t.style.width="",e.style.paddingBottom="")},s=()=>{n===void 0&&(n=window.requestAnimationFrame(i))};return window.addEventListener("scroll",s,{passive:!0}),window.addEventListener("resize",s,{passive:!0}),s(),()=>{window.removeEventListener("scroll",s),window.removeEventListener("resize",s),n!==void 0&&(window.cancelAnimationFrame(n),n=void 0),t.classList.remove(r),t.style.left="",t.style.width="",e.style.paddingBottom=""}}var A=Object.defineProperty,F=Object.getOwnPropertyDescriptor,g=(e,t,r,n)=>{for(var i=n>1?void 0:n?F(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&A(t,r,i),i};const y="view",M="menu",v="recipe";let d=class extends E{constructor(){super(...arguments),this.analyticsPath="/meals-planner/current",this.loaderToBasketComplete$=new z(!1),this.subscriptions=[],this.isCustomMenu=!1,this.budget=0,this.recipeSources=new Map,this.priceService=O.getInstance(),this.isMobile=!1,this.mobileView="recipe",this.handleBasketComplete=()=>{this.loaderToBasketComplete$.next(!0)}}get selectors(){return{recipe:".mealz-planner-current-menu__recipe",menu:".mealz-planner-current-menu__menu",displayRecipeButton:".mealz-planner-current-menu__mobile-recipe-button",preferencesButton:".mealz-planner-current-menu__menu-header-preferences",preferencesMobileButton:".mealz-planner-current-menu__mobile-preferences-button",onboardingButton:".mealz-planner-current-menu__onboarding-button",onboardingButtonMobile:".mealz-planner-current-menu__mobile-onboarding-button",cancelMenuButton:".mealz-planner-current-menu__cancel-menu-button",footer:".mealz-planner-current-menu__footer",footerButton:".mealz-planner-current-menu__footer-button",footerIcon:".mealz-planner-current-menu__footer-icon",footerDisabledIcon:".mealz-planner-current-menu__footer-disabled-icon",preferencesCounterBadges:[".mealz-planner-current-menu__preferences-badge"],footerPrimary:".mealz-planner-current-menu__footer-primary",footerQuickMenu:".mealz-planner-current-menu__footer-quick-menu"}}get nbrRecipeInMenu(){return this.querySelectorAll(".mealz-planner-recipe-card").length}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{window.scrollTo(0,0)}),this.pageview(),this.initSelectors(),this.addEventListeners(),this.footerStickyCleanup=this.setupFooterViewportSticky(),this.priceService.initFormatter(),this.addEventListener("budgetUpdated",e=>{const t=e.detail;(t==null?void 0:t.budgetLimit)===void 0||t.budgetLimit===null||this.updateBudget(t.budgetLimit)}),this.isMobile=k(this,"","(max-width: 1023px)"),this.isCustomMenu=localStorage.getItem("_miam/isCustomMenu")==="true",this.mobileView=this.getInitialMobileViewFromUrlOrDefault(),this.handleResize(),this.removeResponsiveListener=P(this,e=>{e!==this.isMobile&&(this.isMobile=e),this.handleResize()},"","(max-width: 1023px)"),o.recipes.setIsRecipeDetailsFromPlanner(!0),this.subscriptions.push(o.preferences.preferencesCount().subscribe(e=>this.updatePreferencesCount(e))),this.showWelcomeModal()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.footerStickyCleanup&&(this.footerStickyCleanup(),this.footerStickyCleanup=void 0),this.removeResponsiveListener&&(this.removeResponsiveListener(),this.removeResponsiveListener=void 0)}setupFooterViewportSticky(){const e=this.querySelector(".mealz-planner-current-menu"),t=this.querySelector(".mealz-planner-current-menu__footer");if(!(!e||!t))return x({root:e,footer:t,fixedClass:"is-fixed"})}render(){const e=this.getAttribute("starting-data");e&&(Object.assign(this,JSON.parse(e)),this.removeAttribute("starting-data"))}showWelcomeModal(){const e=this.isCustomMenu?"_miam/customMenuOnboarding":"_miam/suggestionOnboarding";if(localStorage.getItem(e)==="true")return;const r=new B;r.isCustomMenu=this.isCustomMenu,r.addEventListener("openOnboarding",n=>{const i=n.detail??{};this.startPlannerOnboarding(i.isCustomMenu??this.isCustomMenu,!1)}),r.addEventListener("onboarding-skipped",()=>{localStorage.setItem(e,"true"),this.startPlannerOnboarding(!1,!0)}),r.displayPlannerWelcomeModal(),this.autoCloseWelcomeOnDrawerOpen(r)}autoCloseWelcomeOnDrawerOpen(e){requestAnimationFrame(()=>{const r=document.querySelector("mealz-drawer-view-swapper");if(!r)return;const n=r.currentView$.subscribe(i=>{i!==void 0&&(document.body.contains(e)&&e.remove(),n.unsubscribe())})})}startPlannerOnboarding(e,t){this.scrollIntoView({behavior:"smooth",block:"center"});const r=new b;r.isCustomMenu=e,document.body.appendChild(r),t?(r.type=this.isMobile?"guide-mobile":"guide",r.launchOnboardingTour()):(this.isMobile?r.type=e?"custom-mobile":"suggestion-mobile":r.type=e?"custom":"suggestion",r.startTour())}addEventListeners(){this.addClickListener("displayRecipeButton",()=>{this.setMobileView("recipe")}),this.addClickListener("preferencesButton",()=>{this.openPreferences()}),this.addClickListener("preferencesMobileButton",()=>{this.openPreferences()}),this.addClickListener("cancelMenuButton",()=>{this.cancelMenu()}),this.addClickListener("footerButton",()=>{this.handleMenu()}),this.addClickListener("onboardingButton",()=>f("current")),this.addClickListener("onboardingButtonMobile",()=>f("current"))}showMenu(){this.setMobileView("menu")}setMobileView(e,t){this.mobileView=e,this.isMobile&&this.toggleMobileView(e==="menu"),(t==null?void 0:t.updateUrl)!==!1&&this.updateUrlMobileView(e)}toggleMobileView(e){const{recipe:t,menu:r,displayRecipeButton:n,footerPrimary:i,footerQuickMenu:s}=this.elements;!t||!r||(t.style.display=e?"none":"block",r.style.display=e?"flex":"none",n&&(n.style.display=e?"flex":"none"),i&&(i.style.display=e?"flex":"none"),s&&(s.style.display=e?"none":"block"))}showSuggestions(){this.setMobileView("recipe")}getInitialMobileViewFromUrlOrDefault(){const e=this.getUrlMobileView();return e||(this.isCustomMenu?"recipe":"menu")}getUrlMobileView(){if(typeof window>"u")return null;try{const t=new URLSearchParams(window.location.search).get(y);return t?t===M?"menu":t===v?"recipe":null:null}catch{return null}}updateUrlMobileView(e){var t;if(!(typeof window>"u")&&(t=window.history)!=null&&t.replaceState)try{const r=new URL(window.location.href);r.searchParams.set(y,e==="menu"?M:v),window.history.replaceState(window.history.state,"",r.toString())}catch{console.error("Failed to update URL mobile view")}}handleResize(){const{menu:e,recipe:t,footerPrimary:r,footerQuickMenu:n}=this.elements;!e||!t||(this.isMobile?this.toggleMobileView(this.mobileView==="menu"):(e.style.display="flex",t.style.display="block",r&&(r.style.display="flex"),n&&(n.style.display="none")))}async openPreferences(){const e=document.querySelector("mealz-drawer-view-swapper");e&&(e.displayPreferences$.next(!0),await e.updateComplete)}updatePreferencesCount(e){const{preferencesCounterBadges:t}=this.elements;t&&t.forEach(r=>{const n=r.querySelector("p");n&&(n.textContent=e.toString(),r.classList.toggle("hidden",e===0))})}updateRecipeCounterBadge(e){const{recipeCounterBadge:t}=this.elements;if(!t)return;const r=t.querySelector("p");r.textContent=e.toString(),t.classList.toggle("hidden",e===0)}cancelMenu(){const e=new _;e.addEventListener("resetMenu",()=>this.resetMenu()),e.displayPlannerAbandonModal()}resetMenu(){if(!this.menuId)return;const e=I()??this.guests??4;this.isCustomMenu=!0,localStorage.setItem("_miam/isCustomMenu","true");const t=o.planner.deleteMenu(this.menuId).pipe(l(1),h(()=>o.planner.createMenu()),l(1),h(r=>{const n=r==null?void 0:r.id;return n?q(V(!0)).pipe(h(i=>o.planner.updateMenu(n,{attributes:{guests:e,title:i}}).pipe(l(1),m(()=>{})))):new L(i=>{i.error(new Error("Menu reset: createMenu did not return a menu id"))})}));this.resetMenuEvent(),t.subscribe({next:()=>{this.updateRecipeCounterBadge(0),this.updateFooterButton(!1),window.location.reload()},error:r=>{console.error("Error while resetting menu:",r),window.location.reload()}})}redirectToRetailerCart(){var e,t;if((e=this.plannerRoutes)!=null&&e.retailerCart){window.location.href=this.plannerRoutes.retailerCart;return}(t=this.plannerRoutes)!=null&&t.catalogHome&&(window.location.href=this.plannerRoutes.catalogHome+"?myMeals=products")}handleMenu(){this.storeId?(this.displayAddToBasketLoaderView(),this.finalizeMenuEvent(),this.navigateOnceDone()):console.log("register menu")}navigateOnceDone(){const e=this.loaderToBasketComplete$.pipe(w(r=>r===!0),l(1)),t=o.planner.menuToBasket(this.basket.id).pipe(l(1),m(()=>o.basket.updateRetailerBasketFromPlanner()));this.subscriptions.push(T([t,e]).pipe(l(1)).subscribe(()=>{this.loaderToBasketElement.remove(),this.redirectToRetailerCart()}))}retrieveRecipesImgs(){const e=[];return document.querySelectorAll(".mealz-planner-recipe-card").forEach(r=>{if(r.querySelector(".mealz-planner-recipe-card__in-basket:not(.hidden)"))return;const i=r.querySelector("img");i&&i.src&&e.push(i.src)}),e}displayAddToBasketLoaderView(){const e=document.querySelector(".mealz-planner-current-menu");if(!e)return;this.loaderToBasketComplete$.next(!1),e.style.display="none";const t=this.retrieveRecipesImgs(),r=document.querySelector("mealz-to-basket-loader");r&&r.remove(),this.loaderToBasketElement=document.createElement("mealz-to-basket-loader"),this.loaderToBasketElement.recipeImgs=t,this.loaderToBasketElement.addEventListener("basketComplete",this.handleBasketComplete),e.insertAdjacentElement("afterend",this.loaderToBasketElement)}updateFooterButton(e){const{footerButton:t,footerIcon:r,footerDisabledIcon:n}=this.elements;!t||!r||!n||(t.classList.toggle("disabled",!e),r.classList.toggle("hidden",!e),n.classList.toggle("hidden",e))}openCatalogModal(){const e=new S;e.addEventListener("openCatalog",()=>{this.openCatalogDrawer()}),e.displayMealzPlannerOpenCatalogModal()}async openCatalogDrawer(e=!0){const t=document.querySelector("mealz-drawer-view-swapper");if(!t)return;t.displayPlannerCatalog$.next(!0),await t.updateComplete;const r=document.querySelector("mealz-planner-catalog");r&&(r.setConfig(this.storeId,this.catalogURL,this.sessionId,e),r.getPlannerCatalog(),r.pageview())}getRecipeSource(){const e=document.querySelector("mealz-planner-catalog");if(e){const t=e.getExtraType();if(t)switch(t){case"starter":return"collection_entrees";case"dessert":return"collection_desserts";case"drink":return"collection_boissons"}}return"catalog"}getJourney(){const e=document.querySelector("mealz-planner-catalog");if(e){if(e.getExtraType())return"meals-planner-categories";const r=document.querySelector("mealz-catalog-toolbar");if(r){const n=r.querySelector(".mealz-catalog-toolbar__searchbar-input");if(n&&n.value.trim().length>0)return"meals-space-catalog-search"}return"meals-space-catalog"}return"meals-planner-dashboard"}addRecipe(e,t,r,n){var u,p;const i=(p=(u=o.recipes)==null?void 0:u.productsPlannerByCategory$)==null?void 0:p.value,s=(i==null?void 0:i.toPickProducts)||[],a=r||this.getRecipeSource(),c=n||this.getJourney();return this.recipeSources.set(e,a),o.planner.addRecipeToMenu(e,t,!!o.pos.currentPos().value,s).pipe(l(1),m(async()=>{await this.addRecipeToList(e),this.showResetMenuButton(),this.updateFooterButtonState(),this.recipeAddedEvent(e,a,c),this.shouldShowMenuToBasketOnboarding()}))}removeRecipe(e){return o.planner.removeRecipeFromMenu(e).pipe(l(1),m(()=>{const t=this.findRecipeIndexById(e);t!==-1&&(this.removeRecipeFromList(t),this.recipeSources.delete(e),this.updateFooterButtonState(),this.recipeRemovedEvent(e))}))}async addRecipeToList(e){const t=document.querySelector("mealz-planner-recipe-list");t&&await t.addRecipeCardToList(e)}removeRecipeFromList(e){const t=document.querySelector("mealz-planner-recipe-list");t&&t.removeRecipeCardFromList(e)}showResetMenuButton(){const e=document.querySelector(".mealz-planner-current-menu__cancel-menu");e&&e.classList.remove("hidden")}shouldShowMenuToBasketOnboarding(){var n;if(localStorage.getItem("_miam/menuToBasketOnboarding")==="true")return;this.isMobile&&this.setMobileView("menu");const t=document.querySelector("mealz-drawer-view-swapper");((n=t==null?void 0:t.currentView$)==null?void 0:n.value)!==void 0?this.subscriptions.push(t.currentView$.pipe(w(i=>i===void 0),l(1)).subscribe(()=>{this.showMenuToBasketOnboarding()})):this.showMenuToBasketOnboarding()}showMenuToBasketOnboarding(){this.updateComplete.then(()=>{const e=new b;e.type=this.isMobile?"menu-to-basket-mobile":"menu-to-basket",document.body.appendChild(e),e.launchOnboardingTour()})}updateFooterButtonState(){const e=this.nbrRecipeInMenu>0;this.updateFooterButton(e)}findRecipeIndexById(e){const t=document.querySelectorAll("mealz-planner-recipe-card");for(let r=0;r<t.length;r++)if(t[r].recipeId===e)return r;return-1}getAllRecipeIds(){const e=[];return document.querySelectorAll("mealz-planner-recipe-card").forEach(r=>{const n=r.recipeId;n&&e.push(n)}),e}pageview(){o.analytics.sendEvent("pageview",this.analyticsPath,{})}resetMenuEvent(){o.analytics.sendEvent("planner.reset",this.analyticsPath,{})}finalizeMenuEvent(){o.analytics.sendEvent("planner.finalize",this.analyticsPath,{budget_user:this.budget,recipe_count:this.nbrRecipeInMenu,guests:this.guests,mode:this.isCustomMenu?"custom":"from-featured"},"meals-planner-dashboard"),this.getAllRecipeIds().forEach(t=>{const r=this.recipeSources.get(t)||"";o.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:t,recipe_source:r,mode:this.isCustomMenu?"custom":"from-featured"},"meals-planner-dashboard")})}recipeAddedEvent(e,t,r){o.analytics.sendEvent("planner.recipe.add",this.analyticsPath,{recipe_id:e,recipe_source:t||"",mode:this.isCustomMenu?"custom":"from-featured"},r||"meals-planner-dashboard")}recipeRemovedEvent(e){o.analytics.sendEvent("planner.recipe.delete",this.analyticsPath,{recipe_id:e})}updateBudget(e){if(!this.menuId)return;const r=o.planner.updateMenu(this.menuId,{attributes:{budget:e}}).pipe(l(1)).subscribe({next:()=>{this.budget=e,this.updateBudgetGaugeUI(e)}});this.subscriptions.push(r)}updateBudgetGaugeUI(e){var c;const t=this.querySelector(".mealz-planner-budget-gauge__budget-limit"),r=this.querySelector(".mealz-planner-budget-gauge__budget-define"),n=this.querySelector(".mealz-planner-budget-gauge__budget-edit"),i=this.querySelector(".mealz-planner-budget-gauge__budget"),s=this.querySelector(".mealz-planner-budget-gauge__gauge");t&&(t.textContent=`/ ${this.priceService.formatPrice(e)}`,t.classList.toggle("hidden",e<=0)),r&&r.classList.toggle("hidden",e>0),n&&n.classList.toggle("hidden",e<=0),i&&i.classList.toggle("only-total",e<=0),s&&s.classList.toggle("hidden",e<=0);const a=this.querySelector("mealz-planner-budget-gauge");a&&(a.budgetLimit=e,(c=a.elements)!=null&&c.gaugeBar&&typeof a.updateGaugeBar=="function"&&a.updateGaugeBar())}};g([C()],d.prototype,"isMobile",2);g([C()],d.prototype,"mobileView",2);d=g([R("mealz-planner-current-menu")],d);customElements.get("mealz-planner-current-menu")||customElements.define("mealz-planner-current-menu",d);
1
+ import"../../drawer-view-swapper/drawer-view-swapper.min.js";import"../../slider-tabs/slider-tabs.min.js";import"../planner-onboarding-modal/planner-onboarding-modal.min.js";import"../to-basket-loader/to-basket-loader.min.js";import{o as w}from"../helpers/open-onboarding-modal.min.js";import{M as S}from"../planner-abandon-modal/planner-abandon-modal.min.js";import{M}from"../planner-onboarding/planner-onboarding.min.js";import{M as k}from"../planner-open-catalog-modal/planner-open-catalog-modal.min.js";import{M as _}from"../planner-welcome-modal/planner-welcome-modal.min.js";import{M as I}from"../planner-current-menu-modal/planner-current-menu-modal.min.js";import{v as P,p as L,N as z,B as T,O}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as x}from"../../assets/custom-element-BhZVzxrc.js";import{r as E}from"../../assets/state-W5mtSPAs.js";import{m as s}from"../../assets/mealz-sdk-E_fNZM-c.js";import{i as A,a as q}from"../../assets/responsive-C7Qf71r3.js";import{P as F}from"../../assets/price-DAxY_7sk.js";import{g as v,f as V}from"../helpers/menu-title.min.js";import{t as l}from"../../assets/take-CozE9iSG.js";import{s as h}from"../../assets/switchMap-Dk_0Nhlo.js";import{f as D}from"../../assets/from-CAidt5N1.js";import{m}from"../../assets/map-BVOhpQm0.js";import{f}from"../../assets/filter-BZ75lS5D.js";import{c as $}from"../../assets/combineLatest-BmqPE0OB.js";import"../../drawer/drawer.min.js";import"../../assets/property-_7ObQ3dl.js";import"../../assets/unsafe-html-CY0Np4--.js";import"../../store-locator-drawer/store-locator-drawer.min.js";import"../../assets/skipWhile-BZVFq1Cg.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../recipe-details/recipe-details.min.js";import"../../recipe-pricing/recipe-pricing.min.js";import"../../assets/viewport-listener-CDsKFDz1.js";import"../../assets/debounceTime-B4DpnstH.js";import"../../assets/async-CFBGA-Dz.js";import"../../assets/empty-0eVnsLmk.js";import"../../assets/merge-Cm-mm3_Q.js";import"../../assets/mergeAll-BdUAXyrs.js";import"../../assets/mergeMap-Dw_YYHwH.js";import"../../assets/executeSchedule-CEDvgTzM.js";import"../../assets/args-BozZ6oU-.js";import"../../assets/isScheduler-C5PGPVU1.js";import"../../assets/capitalize-DUAqYmp4.js";import"../../counter/counter.min.js";import"../../assets/product-card-HetVhdJ3.js";import"../../price/price.min.js";import"../../assets/promotion-badge-8Arhhb-p.js";import"../../assets/delay-BNnJ-6LE.js";import"../../assets/timer-D82-ik89.js";import"../../assets/accordion-DJLqKUJq.js";import"../../store-indicator/store-indicator.min.js";import"../../store-locator/store-locator.min.js";import"../../assets/query-BApjzB0v.js";import"../../last-order-badge/last-order-badge.min.js";import"../../order-again/order-again.min.js";import"../../like-button/like-button.min.js";import"../../last-order-modal/last-order-modal.min.js";import"../../assets/tap-C8CJ3R2H.js";import"../../onboarding/onboarding.min.js";import"../../onboarding/events.min.js";import"../../onboarding/analytics/onboarding-analytics.min.js";import"../../assets/mapOneOrManyArgs-COA1aRZM.js";import"../planner-catalog/planner-catalog.min.js";import"../../catalog/catalog-load-more.min.js";import"../../assets/http-Bepz6wA4.js";import"../../replace-item/replace-item.min.js";import"../../replace-item/replace-item-card/replace-item-card.min.js";import"../../assets/price-utils-BRFZa-3D.js";import"../../assets/distinctUntilChanged-91AVuO2B.js";import"../../replace-item-planner/replace-item-planner.min.js";import"../../replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js";import"../../history-drawer/history-drawer.min.js";import"../../assets/of-DiALp3BZ.js";import"../../supplier-selector/supplier-selector.min.js";import"../../catalog/basket-preview/basket-preview.min.js";import"../../modal/modal.min.js";import"../../preferences/preferences.min.js";var U=P(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function g(e,t){return new Promise(function(r,n){var i=new L({next:function(o){r(o),i.unsubscribe()},error:n,complete:function(){n(new U)}});e.subscribe(i)})}function W({root:e,footer:t,fixedClass:r="is-fixed"}){let n;const i=()=>{n=void 0;const a=e.getBoundingClientRect(),c=t.offsetHeight||0,p=window.innerHeight||document.documentElement.clientHeight,u=a.top<p-c&&a.bottom>p;t.classList.toggle(r,u),u?(t.style.left=`${a.left}px`,t.style.width=`${a.width}px`,e.style.paddingBottom=`${c}px`):(t.style.left="",t.style.width="",e.style.paddingBottom="")},o=()=>{n===void 0&&(n=window.requestAnimationFrame(i))};return window.addEventListener("scroll",o,{passive:!0}),window.addEventListener("resize",o,{passive:!0}),o(),()=>{window.removeEventListener("scroll",o),window.removeEventListener("resize",o),n!==void 0&&(window.cancelAnimationFrame(n),n=void 0),t.classList.remove(r),t.style.left="",t.style.width="",e.style.paddingBottom=""}}var N=Object.defineProperty,G=Object.getOwnPropertyDescriptor,b=(e,t,r,n)=>{for(var i=n>1?void 0:n?G(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&N(t,r,i),i};const C="view",R="menu",B="recipe";let d=class extends z{constructor(){super(...arguments),this.analyticsPath="/meals-planner/current",this.loaderToBasketComplete$=new T(!1),this.subscriptions=[],this.isCustomMenu=!1,this.budget=0,this.recipeSources=new Map,this.priceService=F.getInstance(),this.prefilledRecipeIds=[],this.prefilledRecipeImgs=[],this.hasAddedPrefilledRecipes=!1,this.isMobile=!1,this.mobileView="recipe",this.handleBasketComplete=()=>{this.loaderToBasketComplete$.next(!0)}}get selectors(){return{recipe:".mealz-planner-current-menu__recipe",menu:".mealz-planner-current-menu__menu",displayRecipeButton:".mealz-planner-current-menu__mobile-recipe-button",preferencesButton:".mealz-planner-current-menu__menu-header-preferences",preferencesMobileButton:".mealz-planner-current-menu__mobile-preferences-button",onboardingButton:".mealz-planner-current-menu__onboarding-button",onboardingButtonMobile:".mealz-planner-current-menu__mobile-onboarding-button",cancelMenuButton:".mealz-planner-current-menu__cancel-menu-button",footer:".mealz-planner-current-menu__footer",footerButton:".mealz-planner-current-menu__footer-button",footerIcon:".mealz-planner-current-menu__footer-icon",footerDisabledIcon:".mealz-planner-current-menu__footer-disabled-icon",preferencesCounterBadges:[".mealz-planner-current-menu__preferences-badge"],footerPrimary:".mealz-planner-current-menu__footer-primary",footerQuickMenu:".mealz-planner-current-menu__footer-quick-menu"}}get nbrRecipeInMenu(){return this.querySelectorAll(".mealz-planner-recipe-card").length}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{window.scrollTo(0,0)}),this.pageview(),this.initSelectors(),this.addEventListeners(),this.footerStickyCleanup=this.setupFooterViewportSticky(),this.priceService.initFormatter(),this.addEventListener("budgetUpdated",e=>{const t=e.detail;(t==null?void 0:t.budgetLimit)===void 0||t.budgetLimit===null||this.updateBudget(t.budgetLimit)}),this.isMobile=A(this,"","(max-width: 1023px)"),this.isCustomMenu=localStorage.getItem("_miam/isCustomMenu")==="true",this.mobileView=this.getInitialMobileViewFromUrlOrDefault(),this.handleResize(),this.removeResponsiveListener=q(this,e=>{e!==this.isMobile&&(this.isMobile=e),this.handleResize()},"","(max-width: 1023px)"),s.recipes.setIsRecipeDetailsFromPlanner(!0),this.subscriptions.push(s.preferences.preferencesCount().subscribe(e=>this.updatePreferencesCount(e)))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.footerStickyCleanup&&(this.footerStickyCleanup(),this.footerStickyCleanup=void 0),this.removeResponsiveListener&&(this.removeResponsiveListener(),this.removeResponsiveListener=void 0)}setupFooterViewportSticky(){const e=this.querySelector(".mealz-planner-current-menu"),t=this.querySelector(".mealz-planner-current-menu__footer");if(!(!e||!t))return W({root:e,footer:t,fixedClass:"is-fixed"})}render(){const e=this.getAttribute("starting-data");if(!e)return;const t=JSON.parse(e);Object.assign(this,t),t.recipesId&&Array.isArray(t.recipesId)&&t.recipesId.length>0&&(this.prefilledRecipeIds=t.recipesId,this.prefilledRecipeImgs=t.recipeImgs||[]),this.removeAttribute("starting-data"),globalThis.location.search.includes("fromFeatured")?this.handlePrefilledRecipesFromEntry():this.showWelcomeModal()}waitForSSRMenuRender(){return new Promise(e=>{const n=Date.now(),i=()=>{const o=this.nbrRecipeInMenu,a=Date.now()-n;if(o>0||a>=1e3){e();return}globalThis.setTimeout(i,50)};requestAnimationFrame(()=>{i()})})}showWelcomeModal(){const e=this.isCustomMenu?"_miam/customMenuOnboarding":"_miam/suggestionOnboarding";if(localStorage.getItem(e)==="true")return;const r=new _;r.isCustomMenu=this.isCustomMenu,r.addEventListener("openOnboarding",n=>{const i=n.detail??{};this.startPlannerOnboarding(i.isCustomMenu??this.isCustomMenu,!1)}),r.addEventListener("onboarding-skipped",()=>{localStorage.setItem(e,"true"),this.startPlannerOnboarding(!1,!0)}),r.displayPlannerWelcomeModal(),this.autoCloseWelcomeOnDrawerOpen(r)}autoCloseWelcomeOnDrawerOpen(e){requestAnimationFrame(()=>{const r=document.querySelector("mealz-drawer-view-swapper");if(!r)return;const n=r.currentView$.subscribe(i=>{i!==void 0&&(document.body.contains(e)&&e.remove(),n.unsubscribe())})})}startPlannerOnboarding(e,t){this.scrollIntoView({behavior:"smooth",block:"center"});const r=new M;r.isCustomMenu=e,document.body.appendChild(r),t?(r.type=this.isMobile?"guide-mobile":"guide",r.launchOnboardingTour()):(this.isMobile?r.type=e?"custom-mobile":"suggestion-mobile":r.type=e?"custom":"suggestion",r.startTour())}addEventListeners(){this.addClickListener("displayRecipeButton",()=>{this.setMobileView("recipe")}),this.addClickListener("preferencesButton",()=>{this.openPreferences()}),this.addClickListener("preferencesMobileButton",()=>{this.openPreferences()}),this.addClickListener("cancelMenuButton",()=>{this.cancelMenu()}),this.addClickListener("footerButton",()=>{this.handleMenu()}),this.addClickListener("onboardingButton",()=>w("current")),this.addClickListener("onboardingButtonMobile",()=>w("current"))}showMenu(){this.setMobileView("menu")}setMobileView(e,t){this.mobileView=e,this.isMobile&&this.toggleMobileView(e==="menu"),(t==null?void 0:t.updateUrl)!==!1&&this.updateUrlMobileView(e)}toggleMobileView(e){const{recipe:t,menu:r,displayRecipeButton:n,footerPrimary:i,footerQuickMenu:o}=this.elements;!t||!r||(t.style.display=e?"none":"block",r.style.display=e?"flex":"none",n&&(n.style.display=e?"flex":"none"),i&&(i.style.display=e?"flex":"none"),o&&(o.style.display=e?"none":"block"))}showSuggestions(){this.setMobileView("recipe")}getInitialMobileViewFromUrlOrDefault(){const e=this.getUrlMobileView();return e||(this.isCustomMenu?"recipe":"menu")}getUrlMobileView(){if(typeof window>"u")return null;try{const t=new URLSearchParams(window.location.search).get(C);return t?t===R?"menu":t===B?"recipe":null:null}catch{return null}}updateUrlMobileView(e){var t;if(!(typeof window>"u")&&(t=window.history)!=null&&t.replaceState)try{const r=new URL(window.location.href);r.searchParams.set(C,e==="menu"?R:B),window.history.replaceState(window.history.state,"",r.toString())}catch{console.error("Failed to update URL mobile view")}}handleResize(){const{menu:e,recipe:t,footerPrimary:r,footerQuickMenu:n}=this.elements;!e||!t||(this.isMobile?this.toggleMobileView(this.mobileView==="menu"):(e.style.display="flex",t.style.display="block",r&&(r.style.display="flex"),n&&(n.style.display="none")))}async openPreferences(){const e=document.querySelector("mealz-drawer-view-swapper");e&&(e.displayPreferences$.next(!0),await e.updateComplete)}updatePreferencesCount(e){const{preferencesCounterBadges:t}=this.elements;t&&t.forEach(r=>{const n=r.querySelector("p");n&&(n.textContent=e.toString(),r.classList.toggle("hidden",e===0))})}updateRecipeCounterBadge(e){const{recipeCounterBadge:t}=this.elements;if(!t)return;const r=t.querySelector("p");r.textContent=e.toString(),t.classList.toggle("hidden",e===0)}cancelMenu(){const e=new S;e.addEventListener("resetMenu",()=>this.resetMenu()),e.displayPlannerAbandonModal()}resetMenu(){if(!this.menuId)return;const e=v()??this.guests??4;this.isCustomMenu=!0,localStorage.setItem("_miam/isCustomMenu","true");const t=s.planner.deleteMenu(this.menuId).pipe(l(1),h(()=>s.planner.createMenu()),l(1),h(r=>{const n=r==null?void 0:r.id;return n?D(V(!0)).pipe(h(i=>s.planner.updateMenu(n,{attributes:{guests:e,title:i}}).pipe(l(1),m(()=>{})))):new O(i=>{i.error(new Error("Menu reset: createMenu did not return a menu id"))})}));this.resetMenuEvent(),t.subscribe({next:()=>{this.updateRecipeCounterBadge(0),this.updateFooterButton(!1),window.location.reload()},error:r=>{console.error("Error while resetting menu:",r),window.location.reload()}})}redirectToRetailerCart(){var e,t;if((e=this.plannerRoutes)!=null&&e.retailerCart){window.location.href=this.plannerRoutes.retailerCart;return}(t=this.plannerRoutes)!=null&&t.catalogHome&&(window.location.href=this.plannerRoutes.catalogHome+"?myMeals=products")}handleMenu(){s.hook.hookCallback().pipe(l(1)).subscribe(e=>{e&&(this.storeId?(this.displayAddToBasketLoaderView(),this.finalizeMenuEvent(),this.navigateOnceDone()):console.log("register menu"))})}navigateOnceDone(){const e=this.loaderToBasketComplete$.pipe(f(r=>r===!0),l(1)),t=s.planner.menuToBasket(this.basket.id).pipe(l(1),m(()=>s.basket.updateRetailerBasketFromPlanner()));this.subscriptions.push($([t,e]).pipe(l(1)).subscribe(()=>{this.loaderToBasketElement.remove(),this.redirectToRetailerCart()}))}retrieveRecipesImgs(){const e=[];return document.querySelectorAll(".mealz-planner-recipe-card").forEach(r=>{if(r.querySelector(".mealz-planner-recipe-card__in-basket:not(.hidden)"))return;const i=r.querySelector("img");i&&i.src&&e.push(i.src)}),e}displayAddToBasketLoaderView(){const e=document.querySelector(".mealz-planner-current-menu");if(!e)return;this.loaderToBasketComplete$.next(!1),e.style.display="none";const t=this.retrieveRecipesImgs(),r=document.querySelector("mealz-to-basket-loader");r&&r.remove(),this.loaderToBasketElement=document.createElement("mealz-to-basket-loader"),this.loaderToBasketElement.recipeImgs=t,this.loaderToBasketElement.addEventListener("basketComplete",this.handleBasketComplete),e.insertAdjacentElement("afterend",this.loaderToBasketElement)}updateFooterButton(e){const{footerButton:t,footerIcon:r,footerDisabledIcon:n}=this.elements;!t||!r||!n||(t.classList.toggle("disabled",!e),r.classList.toggle("hidden",!e),n.classList.toggle("hidden",e))}openCatalogModal(){const e=new k;e.addEventListener("openCatalog",()=>{this.openCatalogDrawer()}),e.displayMealzPlannerOpenCatalogModal()}async openCatalogDrawer(e=!0){const t=document.querySelector("mealz-drawer-view-swapper");if(!t)return;t.displayPlannerCatalog$.next(!0),await t.updateComplete;const r=document.querySelector("mealz-planner-catalog");r&&(r.setConfig(this.storeId,this.catalogURL,this.sessionId,e),r.getPlannerCatalog(),r.pageview())}getRecipeSource(){const e=document.querySelector("mealz-planner-catalog");if(e){const t=e.getExtraType();if(t)switch(t){case"starter":return"collection_entrees";case"dessert":return"collection_desserts";case"drink":return"collection_boissons"}}return"catalog"}getJourney(){const e=document.querySelector("mealz-planner-catalog");if(e){if(e.getExtraType())return"meals-planner-categories";const r=document.querySelector("mealz-catalog-toolbar");if(r){const n=r.querySelector(".mealz-catalog-toolbar__searchbar-input");if(n&&n.value.trim().length>0)return"meals-space-catalog-search"}return"meals-space-catalog"}return"meals-planner-dashboard"}addRecipe(e,t,r,n){var u,y;const i=(y=(u=s.recipes)==null?void 0:u.productsPlannerByCategory$)==null?void 0:y.value,o=(i==null?void 0:i.toPickProducts)||[],a=r||this.getRecipeSource(),c=n||this.getJourney(),p=!!s.pos.currentPos().value;return this.recipeSources.set(e,a),s.planner.addRecipeToMenu(e,t,p,o).pipe(l(1),m(async()=>{await this.addRecipeToList(e),this.showResetMenuButton(),this.updateFooterButtonState(),this.recipeAddedEvent(e,a,c),this.loaderToBasketComplete$.value&&this.shouldShowMenuToBasketOnboarding()}))}removeRecipe(e){return s.planner.removeRecipeFromMenu(e).pipe(l(1),m(()=>{const t=this.findRecipeIndexById(e);t!==-1&&(this.removeRecipeFromList(t),this.recipeSources.delete(e),this.updateFooterButtonState(),this.recipeRemovedEvent(e))}))}async addRecipeToList(e){const t=document.querySelector("mealz-planner-recipe-list");t&&await t.addRecipeCardToList(e)}removeRecipeFromList(e){const t=document.querySelector("mealz-planner-recipe-list");t&&t.removeRecipeCardFromList(e)}showResetMenuButton(){const e=document.querySelector(".mealz-planner-current-menu__cancel-menu");e&&e.classList.remove("hidden")}shouldShowMenuToBasketOnboarding(){var n;if(localStorage.getItem("_miam/menuToBasketOnboarding")==="true")return;this.isMobile&&this.setMobileView("menu");const t=document.querySelector("mealz-drawer-view-swapper");((n=t==null?void 0:t.currentView$)==null?void 0:n.value)!==void 0?this.subscriptions.push(t.currentView$.pipe(f(i=>i===void 0),l(1)).subscribe(()=>{this.showMenuToBasketOnboarding()})):this.showMenuToBasketOnboarding()}showMenuToBasketOnboarding(){this.updateComplete.then(()=>{const e=new M;e.type=this.isMobile?"menu-to-basket-mobile":"menu-to-basket",document.body.appendChild(e),e.launchOnboardingTour()})}updateFooterButtonState(){const e=this.nbrRecipeInMenu>0;this.updateFooterButton(e)}findRecipeIndexById(e){const t=document.querySelectorAll("mealz-planner-recipe-card");for(let r=0;r<t.length;r++)if(t[r].recipeId===e)return r;return-1}getAllRecipeIds(){const e=[];return document.querySelectorAll("mealz-planner-recipe-card").forEach(r=>{const n=r.recipeId;n&&e.push(n)}),e}pageview(){s.analytics.sendEvent("pageview",this.analyticsPath,{})}resetMenuEvent(){s.analytics.sendEvent("planner.reset",this.analyticsPath,{})}finalizeMenuEvent(){s.analytics.sendEvent("planner.finalize",this.analyticsPath,{budget_user:this.budget,recipe_count:this.nbrRecipeInMenu,guests:this.guests,mode:this.isCustomMenu?"custom":"from-featured"},"meals-planner-dashboard"),this.getAllRecipeIds().forEach(t=>{const r=this.recipeSources.get(t)||"";s.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:t,recipe_source:r,mode:this.isCustomMenu?"custom":"from-featured"},"meals-planner-dashboard")})}recipeAddedEvent(e,t,r){s.analytics.sendEvent("planner.recipe.add",this.analyticsPath,{recipe_id:e,recipe_source:t||"",mode:this.isCustomMenu?"custom":"from-featured"},r||"meals-planner-dashboard")}recipeRemovedEvent(e){s.analytics.sendEvent("planner.recipe.delete",this.analyticsPath,{recipe_id:e})}updateBudget(e){if(!this.menuId)return;const r=s.planner.updateMenu(this.menuId,{attributes:{budget:e}}).pipe(l(1)).subscribe({next:()=>{this.budget=e,this.updateBudgetGaugeUI(e)}});this.subscriptions.push(r)}updateBudgetGaugeUI(e){var c;const t=this.querySelector(".mealz-planner-budget-gauge__budget-limit"),r=this.querySelector(".mealz-planner-budget-gauge__budget-define"),n=this.querySelector(".mealz-planner-budget-gauge__budget-edit"),i=this.querySelector(".mealz-planner-budget-gauge__budget"),o=this.querySelector(".mealz-planner-budget-gauge__gauge");t&&(t.textContent=`/ ${this.priceService.formatPrice(e)}`,t.classList.toggle("hidden",e<=0)),r&&r.classList.toggle("hidden",e>0),n&&n.classList.toggle("hidden",e<=0),i&&i.classList.toggle("only-total",e<=0),o&&o.classList.toggle("hidden",e<=0);const a=this.querySelector("mealz-planner-budget-gauge");a&&(a.budgetLimit=e,(c=a.elements)!=null&&c.gaugeBar&&typeof a.updateGaugeBar=="function"&&a.updateGaugeBar())}handlePrefilledRecipesFromEntry(){if(this.hasAddedPrefilledRecipes||!this.prefilledRecipeIds||this.prefilledRecipeIds.length===0)return!1;const e=new URL(globalThis.location.href);return e.searchParams.delete("fromFeatured"),globalThis.history.replaceState({},"",e.toString()),this.nbrRecipeInMenu>0?this.displayCurrentMenuModal():(this.displayAddToBasketLoaderForPrefilledRecipes(),this.waitForSSRMenuRender().then(()=>{this.addPrefilledRecipesToMenu()})),!0}displayCurrentMenuModal(e,t){const r=new I;r.displayPlannerCurrentMenuModal();const n=e||(()=>this.replaceMenuWithPrefilledRecipes()),i=t||(()=>this.keepCurrentMenu());r.addEventListener("replaceMenu",n),r.addEventListener("keepMenu",i)}replaceMenuWithPrefilledRecipes(){const e=document.querySelectorAll("mealz-planner-recipe-card"),t=[];e.forEach(r=>{const n=r.recipeId;n&&t.push(n)}),this.removeRecipesAndAddPrefilled(t)}async removeRecipesAndAddPrefilled(e){this.displayAddToBasketLoaderForPrefilledRecipes();for(const t of e)try{await g(s.planner.removeRecipeFromMenu(t).pipe(l(1)));const r=this.findRecipeIndexById(t);r!==-1&&this.removeRecipeFromList(r)}catch(r){console.error("Error removing recipe from menu:",r)}this.addPrefilledRecipesToMenu()}keepCurrentMenu(){this.prefilledRecipeIds=[],this.prefilledRecipeImgs=[],this.showWelcomeModal()}displayAddToBasketLoaderForPrefilledRecipes(){const e=document.querySelector(".mealz-planner-current-menu");if(!e)return;this.hasAddedPrefilledRecipes=!0,this.loaderToBasketComplete$.next(!1),e.style.display="none";const t=document.querySelector("mealz-to-basket-loader");t&&t.remove(),this.loaderToBasketElement=document.createElement("mealz-to-basket-loader"),this.loaderToBasketElement.recipeImgs=this.prefilledRecipeImgs,this.loaderToBasketElement.addEventListener("basketComplete",this.handleBasketComplete),e.insertAdjacentElement("afterend",this.loaderToBasketElement)}async addPrefilledRecipesToMenu(){const e=this.guests||v()||4,t=this.loaderToBasketElement?g(this.loaderToBasketComplete$.pipe(f(Boolean),l(1))):Promise.resolve();await Promise.all([(async()=>{for(const n of this.prefilledRecipeIds)try{await g(this.addRecipe(n,e).pipe(l(1)))}catch(i){console.error("Error adding prefilled recipe to menu:",i)}})(),t]);const r=document.querySelector(".mealz-planner-current-menu");r&&(r.style.display=""),this.loaderToBasketElement&&this.loaderToBasketElement.remove(),this.loaderToBasketComplete$.next(!0),this.updateFooterButton(!0),this.showResetMenuButton(),this.showWelcomeModal()}};b([E()],d.prototype,"isMobile",2);b([E()],d.prototype,"mobileView",2);d=b([x("mealz-planner-current-menu")],d);customElements.get("mealz-planner-current-menu")||customElements.define("mealz-planner-current-menu",d);
@@ -1,4 +1,4 @@
1
- import{N as g,D as h,k as r}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as b}from"../../assets/custom-element-BhZVzxrc.js";import{n as o}from"../../assets/property-_7ObQ3dl.js";import{M as f}from"../planner-current-menu-modal/planner-current-menu-modal.min.js";import{m as i}from"../../assets/mealz-sdk-E_fNZM-c.js";import{f as v}from"../helpers/menu-title.min.js";import{t as p}from"../../assets/take-CozE9iSG.js";import{f as M}from"../../assets/from-CAidt5N1.js";import{s as c}from"../../assets/switchMap-Dk_0Nhlo.js";import"../../modal/modal.min.js";import"../../assets/unsafe-html-CY0Np4--.js";import"../../onboarding/events.min.js";import"../../assets/empty-0eVnsLmk.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../assets/executeSchedule-CEDvgTzM.js";var _=Object.defineProperty,z=Object.getOwnPropertyDescriptor,a=(e,t,u,l)=>{for(var n=l>1?void 0:l?z(t,u):t,m=e.length-1,d;m>=0;m--)(d=e[m])&&(n=(l?d(t,u,n):d(n))||n);return l&&n&&_(t,u,n),n};let s=class extends g{constructor(){super(),this.menuId="",this.guests=4,this.hideBudget=!1,this.isCustomMenu=!1,this.currentMenuModal=!1,this.budget=0,this.generatingLoader=!1,this.analyticsPath="/meals-planner/dashboard",this.styleURL=new URL("./planner/planner-form/planner-form.css",this.getBaseURL())}render(){return r`
1
+ import{N as g,D as h,k as r}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as b}from"../../assets/custom-element-BhZVzxrc.js";import{n as o}from"../../assets/property-_7ObQ3dl.js";import{m as i}from"../../assets/mealz-sdk-E_fNZM-c.js";import{f}from"../helpers/menu-title.min.js";import{t as d}from"../../assets/take-CozE9iSG.js";import{f as v}from"../../assets/from-CAidt5N1.js";import{s as c}from"../../assets/switchMap-Dk_0Nhlo.js";import"../../assets/empty-0eVnsLmk.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../assets/executeSchedule-CEDvgTzM.js";var _=Object.defineProperty,M=Object.getOwnPropertyDescriptor,a=(e,t,u,l)=>{for(var n=l>1?void 0:l?M(t,u):t,m=e.length-1,p;m>=0;m--)(p=e[m])&&(n=(l?p(t,u,n):p(n))||n);return l&&n&&_(t,u,n),n};let s=class extends g{constructor(){super(),this.menuId="",this.guests=4,this.hideBudget=!1,this.isCustomMenu=!1,this.currentMenuModal=!1,this.budget=0,this.generatingLoader=!1,this.analyticsPath="/meals-planner/dashboard",this.styleURL=new URL("./planner/planner-form/planner-form.css",this.getBaseURL())}render(){return r`
2
2
  <div class="mealz-planner-form">
3
3
  <img class="mealz-planner-form__logo"
4
4
  src="https://storage.googleapis.com/assets.miam.tech/generic/images/meals-planner_logo.svg" alt="Meals Planner"/>
@@ -59,4 +59,4 @@ import{N as g,D as h,k as r}from"../../assets/no-shadow-element-YPHUv5PR.js";imp
59
59
  </div>
60
60
  </div>
61
61
  </div>
62
- `}updateBudget(e){const t=e.target;this.budget=Number(t.value)||0}updateGuests(e){this.guests=Math.max(1,Math.min(12,this.guests+e))}displayCurrentMenuModal(){this.generatingLoader=!0,this.requestUpdate();const e=new f;e.displayPlannerCurrentMenuModal(),e.addEventListener("replaceMenu",()=>this.replaceMenu()),e.addEventListener("keepMenu",()=>this.keepMenu()),e.addEventListener("modalClosed",()=>{this.generatingLoader=!1,this.requestUpdate()})}generateMenu(){this.generatingLoader=!0,this.requestUpdate(),this.updateMenu().pipe(p(1)).subscribe(()=>{const e={detail:{guests:this.guests,budget:this.budget},bubbles:!0,composed:!0};this.generateMenuEvent();const t=new CustomEvent("generateMenu",e);this.dispatchEvent(t)})}updateMenu(){const e={guests:this.guests,budget:this.budget};return M(v(this.isCustomMenu)).pipe(c(t=>i.planner.updateMenu(this.menuId,{attributes:{...e,title:t}})))}replaceMenu(){this.resetMenuEvent(),i.planner.deleteMenu(this.menuId).pipe(p(1),c(()=>i.planner.createMenu()),p(1)).subscribe(e=>{this.menuId=e.id,this.generateMenu()})}keepMenu(){const e=new CustomEvent("displayDashboard");this.dispatchEvent(e),this.remove()}generateMenuEvent(){i.analytics.sendEvent("planner.started",this.analyticsPath,{guests:this.guests,budget:this.budget,mode:this.isCustomMenu?"custom":"from-featured"})}resetMenuEvent(){i.analytics.sendEvent("planner.reset",this.analyticsPath,{})}};a([o({type:String})],s.prototype,"menuId",2);a([o({type:Number})],s.prototype,"guests",2);a([o({type:Boolean})],s.prototype,"hideBudget",2);a([o({type:Boolean})],s.prototype,"isCustomMenu",2);a([o({type:Boolean})],s.prototype,"currentMenuModal",2);s=a([b("mealz-planner-form")],s);customElements.get("mealz-planner-form")||customElements.define("mealz-planner-form",s);
62
+ `}updateBudget(e){const t=e.target;this.budget=Number(t.value)||0}updateGuests(e){this.guests=Math.max(1,Math.min(12,this.guests+e))}displayCurrentMenuModal(){this.generatingLoader=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-current-menu");e?e.displayCurrentMenuModal(()=>this.replaceMenu(),()=>{this.keepMenu(),this.generatingLoader=!1,this.requestUpdate()}):(console.warn("mealz-planner-current-menu component not found, proceeding without modal"),this.generatingLoader=!1,this.requestUpdate(),this.generateMenu())}generateMenu(){this.generatingLoader=!0,this.requestUpdate(),this.updateMenu().pipe(d(1)).subscribe(()=>{const e={detail:{guests:this.guests,budget:this.budget},bubbles:!0,composed:!0};this.generateMenuEvent();const t=new CustomEvent("generateMenu",e);this.dispatchEvent(t)})}updateMenu(){const e={guests:this.guests,budget:this.budget};return v(f(this.isCustomMenu)).pipe(c(t=>i.planner.updateMenu(this.menuId,{attributes:{...e,title:t}})))}replaceMenu(){this.resetMenuEvent(),i.planner.deleteMenu(this.menuId).pipe(d(1),c(()=>i.planner.createMenu()),d(1)).subscribe(e=>{this.menuId=e.id,this.generateMenu()})}keepMenu(){const e=new CustomEvent("displayDashboard");this.dispatchEvent(e),this.remove()}generateMenuEvent(){i.analytics.sendEvent("planner.started",this.analyticsPath,{guests:this.guests,budget:this.budget,mode:this.isCustomMenu?"custom":"from-featured"})}resetMenuEvent(){i.analytics.sendEvent("planner.reset",this.analyticsPath,{})}};a([o({type:String})],s.prototype,"menuId",2);a([o({type:Number})],s.prototype,"guests",2);a([o({type:Boolean})],s.prototype,"hideBudget",2);a([o({type:Boolean})],s.prototype,"isCustomMenu",2);a([o({type:Boolean})],s.prototype,"currentMenuModal",2);s=a([b("mealz-planner-form")],s);customElements.get("mealz-planner-form")||customElements.define("mealz-planner-form",s);
@@ -1 +1 @@
1
- import"../planner-form/planner-form.min.js";import"../to-basket-loader/to-basket-loader.min.js";import{M as p}from"../planner-abandon-modal/planner-abandon-modal.min.js";import{M}from"../planner-current-menu-modal/planner-current-menu-modal.min.js";import{v as f,p as g,N as y}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as C}from"../../assets/custom-element-BhZVzxrc.js";import{m as i}from"../../assets/mealz-sdk-E_fNZM-c.js";import{g as E,f as b}from"../helpers/menu-title.min.js";import{t as l}from"../../assets/take-CozE9iSG.js";import{o as c}from"../../assets/of-DiALp3BZ.js";import{f as T}from"../../assets/from-CAidt5N1.js";import{s as m}from"../../assets/switchMap-Dk_0Nhlo.js";import"../../assets/property-_7ObQ3dl.js";import"../../modal/modal.min.js";import"../../assets/unsafe-html-CY0Np4--.js";import"../../onboarding/events.min.js";import"../../assets/empty-0eVnsLmk.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../assets/executeSchedule-CEDvgTzM.js";import"../../assets/state-W5mtSPAs.js";import"../../assets/args-BozZ6oU-.js";import"../../assets/isScheduler-C5PGPVU1.js";var v=f(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function P(e,t){return new Promise(function(n,s){var r=new g({next:function(a){n(a),r.unsubscribe()},error:s,complete:function(){s(new v)}});e.subscribe(r)})}var k=Object.getOwnPropertyDescriptor,I=(e,t,n,s)=>{for(var r=s>1?void 0:s?k(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(r=o(r)||r);return r};let d=class extends y{constructor(){super(...arguments),this.menuId="",this.isCustomMenu=!1,this.guests=4,this.storeId="",this.recipeIds=[],this.hasCustomRecipes=!1,this.currentMenuPageUrl="",this.recipeImgs=[],this.analyticsPath="/meals-planner/dashboard",this.isRedirecting=!1,this.menuTitle="",this.shouldUpdateMenuTitleOnRedirect=!1}get selectors(){return{cancelMenuButton:".mealz-planner-menu-option__cancel",menuOption:".mealz-planner-menu-option__container"}}connectedCallback(){super.connectedCallback(),this.initStartingData(),this.initSelectors(),this.addEventListeners(),this.syncGuestsFromStorage(),this.listenToPlannerGuestsChanges()}disconnectedCallback(){this.plannerGuestsChangeHandler&&document.removeEventListener("plannerGuestsChanged",this.plannerGuestsChangeHandler),super.disconnectedCallback()}initStartingData(){const e=this.getAttribute("starting-data");if(e){try{const{isCustomMenu:t,guestsPreference:n,storeId:s,hasCustomRecipes:r,menuId:a,recipesId:o,currentMenuPageUrl:u,recipeImgs:h}=JSON.parse(e);this.isCustomMenu=!!t,this.storeId=s??this.storeId,this.hasCustomRecipes=!!r,this.menuId=a??this.menuId,this.currentMenuPageUrl=u??this.currentMenuPageUrl,this.recipeImgs=h||[],this.recipeIds=Array.isArray(o)?o:[],typeof n=="number"&&(this.guests=n)}catch(t){console.error("Failed to parse starting-data:",t)}this.removeAttribute("starting-data"),this.initMenuTitle(),this.syncGuestsFromStorage()}}initMenuTitle(){i.planner.fetchMenuTitle().pipe(l(1)).subscribe(e=>{this.menuTitle=e||""})}syncGuestsFromStorage(){const e=E();typeof e=="number"&&(this.guests=e)}listenToPlannerGuestsChanges(){this.plannerGuestsChangeHandler=e=>{var n;const t=e;(n=t.detail)!=null&&n.guests&&(this.guests=t.detail.guests)},document.addEventListener("plannerGuestsChanged",this.plannerGuestsChangeHandler)}addEventListeners(){this.addClickListener("cancelMenuButton",()=>this.cancelMenu()),this.addClickListener("menuOption",()=>this.handleMenuOptionClick())}handleMenuOptionClick(){const e=this.isCustomMenu?"custom":"from-featured";this.sendModeSelectEvent(e);const t=this.isFromPlannerEntry();i.hook.hookCallback().pipe(l(1)).subscribe(n=>{if(!n)return;if(localStorage.setItem("_miam/isCustomMenu",this.isCustomMenu.toString()),this.hasCustomRecipes&&!this.isCustomMenu&&t){this.displayCurrentMenuModal();return}this.proceedAfterHookAndOptionalModal()})}sendModeSelectEvent(e){i.analytics.sendEvent("planner.mode.select",this.analyticsPath,{mode:e},"meals-planner-home")}isFromPlannerEntry(){return!!document.querySelector("mealz-planner-entry")}proceedAfterHookAndOptionalModal(){if(this.isFromPlannerEntry()){localStorage.setItem("_mealz/planner/from-entry","true"),!this.isCustomMenu&&this.recipeIds.length>0?(this.hasCustomRecipes||(this.shouldUpdateMenuTitleOnRedirect=!0,this.menuTitle=""),this.startPrefilledRecipesFlow(this.guests)):this.redirectToMenu();return}else localStorage.removeItem("_mealz/planner/from-entry");!this.isCustomMenu||this.recipeIds.length===0?this.displayPlannerForm():this.redirectToMenu()}displayPlannerForm(){const e=document.querySelector(".mealz-planner-dashboard");e&&(e.style.display="none");let t=document.querySelector("mealz-planner-form");t||(t=document.createElement("mealz-planner-form"),t.guests=this.guests,t.isCustomMenu=this.isCustomMenu,t.hideBudget=!this.isCustomMenu||!this.storeId,t.currentMenuModal=!this.isCustomMenu&&this.hasCustomRecipes,t.menuId=this.menuId,t.addEventListener("displayDashboard",()=>this.displayDashboard()),t.addEventListener("generateMenu",n=>this.startPrefilledRecipesFlow(n.detail.guests)),e?e.insertAdjacentElement("afterend",t):document.body.appendChild(t))}startPrefilledRecipesFlow(e){if(this.recipeIds.length===0){this.redirectToMenu();return}this.displayAddToBasketLoaderView(e)}updateMenuTitle(){return this.menuTitle.length>0?c(null):T(b(this.isCustomMenu)).pipe(m(e=>(this.menuTitle=e,i.planner.updateMenu(this.menuId,{attributes:{title:e}}))))}displayAddToBasketLoaderView(e){this.hideUIElements(),this.setupBasketLoader(e)}hideUIElements(){const e=document.querySelector(".mealz-planner-dashboard");e&&(e.style.display="none");const t=document.querySelector("mealz-planner-form");t&&(t.style.display="none")}setupBasketLoader(e){if(this.loaderToBasketElement=document.querySelector("mealz-to-basket-loader")??void 0,!this.loaderToBasketElement){this.loaderToBasketElement=document.createElement("mealz-to-basket-loader"),this.loaderToBasketElement.recipeImgs=this.recipeImgs,this.waitForBasketCompleteAndRecipesAdded(this.loaderToBasketElement,e);const t=document.querySelector("mealz-planner-form"),n=document.querySelector("mealz-planner-entry");t?t.insertAdjacentElement("afterend",this.loaderToBasketElement):n?n.insertAdjacentElement("afterend",this.loaderToBasketElement):document.body.appendChild(this.loaderToBasketElement)}}async waitForBasketCompleteAndRecipesAdded(e,t){await Promise.all([this.waitForBasketComplete(e),this.addPrefilledRecipesToMenu(t)]),this.redirectToMenu()}waitForBasketComplete(e){return new Promise(t=>{e.addEventListener("basketComplete",()=>t(),{once:!0})})}async addPrefilledRecipesToMenu(e){var r,a;const t=(a=(r=i.recipes)==null?void 0:r.productsPlannerByCategory$)==null?void 0:a.value,n=(t==null?void 0:t.toPickProducts)||[],s=!!i.pos.currentPos().value;for(const o of this.recipeIds)try{await P(i.planner.addRecipeToMenu(o,e,s,n).pipe(l(1))),this.recipeAddedEvent(o)}catch(u){console.error("Error adding recipe to menu:",u)}}redirectToMenu(){if(this.isRedirecting)return;this.isRedirecting=!0;const e=this.shouldUpdateMenuTitleOnRedirect&&!this.isCustomMenu;this.shouldUpdateMenuTitleOnRedirect=!1,(e?this.updateMenuTitle():c(null)).pipe(l(1)).subscribe({next:()=>{this.sendRedirectToMenuEvent();const n=this.getCurrentMenuUrlWithInitialView();n&&n!==globalThis.location.href&&(globalThis.location.href=n)},error:n=>{console.error("Error updating menu title:",n),this.sendRedirectToMenuEvent();const s=this.getCurrentMenuUrlWithInitialView();s&&s!==globalThis.location.href&&(globalThis.location.href=s)}})}sendRedirectToMenuEvent(){const e=this.getCurrentMenuUrlWithInitialView(),t=new CustomEvent("redirectToMenu",{bubbles:!0,composed:!0,detail:{url:e}});this.dispatchEvent(t)}getCurrentMenuUrlWithInitialView(){const e=this.currentMenuPageUrl;if(!e)return e;const t=this.isCustomMenu?"recipe":"menu";try{const n=new URL(e,globalThis.location.origin);return n.searchParams.set("view",t),n.toString()}catch{const n=e.includes("?")?"&":"?";return`${e}${n}view=${encodeURIComponent(t)}`}}displayDashboard(){const e=document.querySelector(".mealz-planner-dashboard");e&&(e.style.display="block")}cancelMenu(){const e=new p;e.addEventListener("resetMenu",()=>this.resetMenu()),e.displayPlannerAbandonModal()}resetMenu(){const e=i.planner.deleteMenu(this.menuId);this.resetMenuEvent(),e.pipe(l(1)).subscribe(()=>{globalThis.location.reload()})}displayCurrentMenuModal(){const e=new M;e.displayPlannerCurrentMenuModal(),e.addEventListener("replaceMenu",()=>this.replaceMenu()),e.addEventListener("keepMenu",()=>this.keepMenu())}replaceMenu(){this.resetMenuEvent(),i.planner.deleteMenu(this.menuId).pipe(l(1),m(()=>i.planner.createMenu()),l(1)).subscribe(e=>{this.menuId=e.id,this.shouldUpdateMenuTitleOnRedirect=!0,this.menuTitle="",this.proceedAfterHookAndOptionalModal()})}keepMenu(){this.redirectToMenu()}resetMenuEvent(){i.analytics.sendEvent("planner.reset",this.analyticsPath,{})}recipeAddedEvent(e){i.analytics.sendEvent("planner.recipe.add",this.analyticsPath,{recipe_id:e,recipe_source:"pre_filled",mode:this.isCustomMenu?"custom":"from-featured"},"meals-planner-home")}};d=I([C("mealz-planner-menu-option")],d);customElements.get("mealz-planner-menu-option")||customElements.define("mealz-planner-menu-option",d);
1
+ import"../planner-form/planner-form.min.js";import{M as p}from"../planner-abandon-modal/planner-abandon-modal.min.js";import{N as M}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as g}from"../../assets/custom-element-BhZVzxrc.js";import{m as r}from"../../assets/mealz-sdk-E_fNZM-c.js";import{g as f,f as C}from"../helpers/menu-title.min.js";import{t as l}from"../../assets/take-CozE9iSG.js";import{o as d}from"../../assets/of-DiALp3BZ.js";import{f as b}from"../../assets/from-CAidt5N1.js";import{s as h}from"../../assets/switchMap-Dk_0Nhlo.js";import"../../assets/property-_7ObQ3dl.js";import"../../assets/empty-0eVnsLmk.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../assets/executeSchedule-CEDvgTzM.js";import"../../modal/modal.min.js";import"../../assets/unsafe-html-CY0Np4--.js";import"../../onboarding/events.min.js";import"../../assets/args-BozZ6oU-.js";import"../../assets/isScheduler-C5PGPVU1.js";var y=Object.getOwnPropertyDescriptor,T=(e,t,n,s)=>{for(var i=s>1?void 0:s?y(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i};let u=class extends M{constructor(){super(...arguments),this.menuId="",this.isCustomMenu=!1,this.guests=4,this.storeId="",this.recipeIds=[],this.hasCustomRecipes=!1,this.currentMenuPageUrl="",this.recipeImgs=[],this.analyticsPath="/meals-planner/dashboard",this.isRedirecting=!1,this.menuTitle="",this.shouldUpdateMenuTitleOnRedirect=!1}get selectors(){return{cancelMenuButton:".mealz-planner-menu-option__cancel",menuOption:".mealz-planner-menu-option__container"}}connectedCallback(){super.connectedCallback(),this.initStartingData(),this.initSelectors(),this.addEventListeners(),this.syncGuestsFromStorage(),this.listenToPlannerGuestsChanges()}disconnectedCallback(){this.plannerGuestsChangeHandler&&document.removeEventListener("plannerGuestsChanged",this.plannerGuestsChangeHandler),super.disconnectedCallback()}initStartingData(){const e=this.getAttribute("starting-data");if(e){try{const{isCustomMenu:t,guestsPreference:n,storeId:s,hasCustomRecipes:i,menuId:a,recipesId:o,currentMenuPageUrl:c,recipeImgs:m}=JSON.parse(e);this.isCustomMenu=!!t,this.storeId=s??this.storeId,this.hasCustomRecipes=!!i,this.menuId=a??this.menuId,this.currentMenuPageUrl=c??this.currentMenuPageUrl,this.recipeImgs=m||[],this.recipeIds=Array.isArray(o)?o:[],typeof n=="number"&&(this.guests=n)}catch(t){console.error("Failed to parse starting-data:",t)}this.removeAttribute("starting-data"),this.initMenuTitle(),this.syncGuestsFromStorage()}}initMenuTitle(){r.planner.fetchMenuTitle().pipe(l(1)).subscribe(e=>{this.menuTitle=e||""})}syncGuestsFromStorage(){const e=f();typeof e=="number"&&(this.guests=e)}listenToPlannerGuestsChanges(){this.plannerGuestsChangeHandler=e=>{var n;const t=e;(n=t.detail)!=null&&n.guests&&(this.guests=t.detail.guests)},document.addEventListener("plannerGuestsChanged",this.plannerGuestsChangeHandler)}addEventListeners(){this.addClickListener("cancelMenuButton",()=>this.cancelMenu()),this.addClickListener("menuOption",()=>this.handleMenuOptionClick())}handleMenuOptionClick(){const e=this.isCustomMenu?"custom":"from-featured";this.sendModeSelectEvent(e),this.isFromPlannerEntry(),localStorage.setItem("_miam/isCustomMenu",this.isCustomMenu.toString()),this.proceedAfterHookAndOptionalModal()}sendModeSelectEvent(e){r.analytics.sendEvent("planner.mode.select",this.analyticsPath,{mode:e,guests:this.guests},"meals-planner-home")}isFromPlannerEntry(){return!!document.querySelector("mealz-planner-entry")}proceedAfterHookAndOptionalModal(){if(this.isFromPlannerEntry()){localStorage.setItem("_mealz/planner/from-entry","true"),!this.isCustomMenu&&this.recipeIds.length>0&&(this.hasCustomRecipes||(this.shouldUpdateMenuTitleOnRedirect=!0,this.menuTitle="")),this.redirectToMenu();return}else localStorage.removeItem("_mealz/planner/from-entry");!this.isCustomMenu||this.recipeIds.length===0?this.displayPlannerForm():this.redirectToMenu()}displayPlannerForm(){const e=document.querySelector(".mealz-planner-dashboard");e&&(e.style.display="none");let t=document.querySelector("mealz-planner-form");t||(t=document.createElement("mealz-planner-form"),t.guests=this.guests,t.isCustomMenu=this.isCustomMenu,t.hideBudget=!this.isCustomMenu||!this.storeId,t.currentMenuModal=!this.isCustomMenu&&this.hasCustomRecipes,t.menuId=this.menuId,t.addEventListener("displayDashboard",()=>this.displayDashboard()),t.addEventListener("generateMenu",()=>{this.redirectToMenu()}),e?e.insertAdjacentElement("afterend",t):document.body.appendChild(t))}updateMenuTitle(){return this.menuTitle.length>0?d(null):b(C(this.isCustomMenu)).pipe(h(e=>(this.menuTitle=e,r.planner.updateMenu(this.menuId,{attributes:{title:e}}))))}redirectToMenu(){if(this.isRedirecting)return;this.isRedirecting=!0;const e=this.shouldUpdateMenuTitleOnRedirect&&!this.isCustomMenu;this.shouldUpdateMenuTitleOnRedirect=!1,(e?this.updateMenuTitle():d(null)).pipe(l(1)).subscribe({next:()=>{this.sendRedirectToMenuEvent();const n=this.getCurrentMenuUrlWithInitialView();n&&n!==globalThis.location.href&&(globalThis.location.href=n)},error:n=>{console.error("Error updating menu title:",n),this.sendRedirectToMenuEvent();const s=this.getCurrentMenuUrlWithInitialView();s&&s!==globalThis.location.href&&(globalThis.location.href=s)}})}sendRedirectToMenuEvent(){const e=this.getCurrentMenuUrlWithInitialView(),t=new CustomEvent("redirectToMenu",{bubbles:!0,composed:!0,detail:{url:e}});this.dispatchEvent(t)}getCurrentMenuUrlWithInitialView(){const e=this.currentMenuPageUrl;if(!e)return e;const t=this.isCustomMenu?"recipe":"menu",n=this.isFromPlannerEntry()&&!this.isCustomMenu&&this.recipeIds.length>0;try{const s=new URL(e,globalThis.location.origin);return s.searchParams.set("view",t),n&&s.searchParams.set("fromFeatured","true"),s.toString()}catch{const s=e.includes("?")?"&":"?",i=`view=${encodeURIComponent(t)}`;return`${e}${s}${i}${n?"&fromFeatured=true":""}`}}displayDashboard(){const e=document.querySelector(".mealz-planner-dashboard");e&&(e.style.display="block")}cancelMenu(){const e=new p;e.addEventListener("resetMenu",()=>this.resetMenu()),e.displayPlannerAbandonModal()}resetMenu(){const e=r.planner.deleteMenu(this.menuId);this.resetMenuEvent(),e.pipe(l(1)).subscribe(()=>{globalThis.location.reload()})}replaceMenu(){this.resetMenuEvent(),r.planner.deleteMenu(this.menuId).pipe(l(1),h(()=>r.planner.createMenu()),l(1)).subscribe(e=>{this.menuId=e.id,this.shouldUpdateMenuTitleOnRedirect=!0,this.menuTitle="",this.proceedAfterHookAndOptionalModal()})}keepMenu(){this.redirectToMenu()}resetMenuEvent(){r.analytics.sendEvent("planner.reset",this.analyticsPath,{})}};u=T([g("mealz-planner-menu-option")],u);customElements.get("mealz-planner-menu-option")||customElements.define("mealz-planner-menu-option",u);
@@ -1 +1 @@
1
- import{N as h,n as m,a as f}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as _}from"../../assets/custom-element-BhZVzxrc.js";import{m as p}from"../../assets/mealz-sdk-E_fNZM-c.js";import{d as S}from"../../assets/debounceTime-B4DpnstH.js";import{E as c}from"../../assets/empty-0eVnsLmk.js";import{t as u}from"../../assets/take-CozE9iSG.js";import{t as d}from"../../assets/tap-C8CJ3R2H.js";import{o as x}from"../../assets/of-DiALp3BZ.js";import"../../assets/async-CFBGA-Dz.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/args-BozZ6oU-.js";import"../../assets/isScheduler-C5PGPVU1.js";import"../../assets/from-CAidt5N1.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../assets/executeSchedule-CEDvgTzM.js";class R{constructor(){this.attributes={title:"","ext-id":"","ext-link":"",description:"","number-of-guests":"","preparation-time":"","preheating-time":"","cooking-time":"","resting-time":"","media-url":"",source:"","informational-page-html":"","filigrane-logo-url":"","informational-sentence":"","order-history":"",difficulty:1,cost:1,suggested:!1,popularity:0,"video-id":"",promoted:!1,discounted:!1,editable:!1,position:-1},this.ttl=3600,this.finalTimer=this.attributes["preparation-time"]+this.attributes["preheating-time"]+this.attributes["cooking-time"]+this.attributes["resting-time"]}get title(){return this.attributes.title}get promoted(){return this.attributes.promoted}get discounted(){return this.attributes.discounted}get guests(){return this.attributes["number-of-guests"]}set guests(t){this.attributes["number-of-guests"]=t}get filigraneLogoUrl(){return this.attributes["filigrane-logo-url"]?this.attributes["filigrane-logo-url"]:null}get sponsorName(){return this.relationships.sponsors.length>0?this.relationships.sponsors[0].attributes.name:null}get sponsorLogoUrl(){var t,s;return this.relationships.sponsors.data.length>0?(s=(t=this.relationships.sponsors.data[0])==null?void 0:t.attributes)==null?void 0:s["logo-url"]:null}get informationalSentence(){return this.attributes["informational-sentence"]}get costLabel(){switch(this.attributes.cost){case 1:return"faible";case 2:return"moyen";case 3:return"élevé";default:return"moyen"}}get orderHistory(){return this.attributes["order-history"]}get preparationTime(){}get cookingTime(){}get restingTime(){}get difficulty(){return this.attributes.difficulty}set difficulty(t){this.attributes.difficulty=t}set discounted(t){this.attributes.discounted=t}}var b=Object.getOwnPropertyDescriptor,z=(e,t,s,i)=>{for(var a=i>1?void 0:i?b(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(a=n(a)||a);return a};let l=class extends h{constructor(){super(...arguments),this.recipeId="",this.guests=0,this.menuRecipes=[],this.suggestedRecipes=[],this.nextSuggestion=null,this.swapRecipeCount=0,this.swapRecipeClick$=new m,this.analyticsPath="/meals-planner/current",this.preferencesSubscription=new f,this.lastShownRecipeId=null,this.isAnimating=!1,this.prefersReducedMotion=!1,this.hasUserInteracted=!1,this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh=!1}get selectors(){return{currentCard:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)",title:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-current-menu__recipe-title",swapButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-swap-button",addButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-button",seeRecipe:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__see-recipe",addAndSwapButtons:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-and-swap",pictureContainer:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture",picture:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture img",promotion:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-badges-promotion",sponsor:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor",sponsorImg:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor img",nextSuggestionCard:".mealz-planner-recipe-suggestion__next",nextSuggestionPicture:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__picture img",nextSuggestionTitle:".mealz-planner-recipe-suggestion__next .mealz-planner-current-menu__recipe-title",nextPromotion:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-badges-promotion",nextSponsor:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor",nextSponsorImg:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor img"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.addEventListeners(),this.swapRecipeClick$.pipe(S(300)).subscribe(()=>this.swapRecipe()),this.subscribeToPreferencesChanges(),this.prefersReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches}disconnectedCallback(){super.disconnectedCallback(),this.swapRecipeClick$.complete(),this.preferencesSubscription.unsubscribe()}firstUpdated(){const e=this.getAttribute("starting-data");e&&(Object.assign(this,JSON.parse(e)),this.nextSuggestion=this.suggestedRecipes[1]||null,this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.recipeId&&this.suggestionShownEvent(),this.removeAttribute("starting-data"))}addEventListeners(){this.addEventListener("click",e=>{if(this.isAnimating){e.preventDefault(),e.stopPropagation();return}const t=e.target;if(t.closest(".mealz-planner-recipe-suggestion__actions-swap-button")){this.swapRecipeClick$.next();return}const s=t.closest(".mealz-planner-recipe-suggestion__actions-add-button");if(s&&!s.classList.contains("loading")){this.addRecipe();return}if(t.closest(".mealz-planner-current-menu__recipe-title")||t.closest(".mealz-planner-recipe-suggestion__see-recipe")||t.closest(".mealz-planner-recipe-suggestion__picture")){this.openRecipeDetails();return}})}updateDisplayedRecipe(){const{title:e,addAndSwapButtons:t,picture:s,promotion:i,sponsor:a,sponsorImg:o}=this.elements;if(!s||!e||!i||!a||!o||!t)return;const n=this.suggestedRecipes[0];if(!n)return;const r=new R;Object.assign(r,n),this.recipeId=n.id,this.setupImageHandlers(s,r,e,t,i,a,o)}setupImageHandlers(e,t,s,i,a,o,n){let r=null;const g=()=>{r&&(clearTimeout(r),r=null),this.updateRecipeUI(e,s,i,t,a,o,n)};e.classList.add("loading"),e.onload=g,e.onerror=g,t.attributes["media-url"]?(e.src=t.attributes["media-url"],r=window.setTimeout(g,1e3)):g()}updateRecipeUI(e,t,s,i,a,o,n){e.classList.remove("loading"),o.classList.toggle("hidden",!i.sponsorLogoUrl),n&&(n.src=i.sponsorLogoUrl?i.sponsorLogoUrl:""),a.classList.toggle("hidden",!i.discounted),t.textContent=i.attributes.title||"";const r=this.menuRecipes.some(g=>g.id===i.id);s.classList.toggle("hidden",r)}updateNextSuggestionUI(){return new Promise(e=>{const{nextSuggestionCard:t,nextSuggestionPicture:s,nextSuggestionTitle:i,nextPromotion:a,nextSponsor:o,nextSponsorImg:n}=this.elements;if(!this.nextSuggestion){t&&t.classList.add("hidden"),e();return}if(t&&t.classList.remove("hidden"),!s||!i){e();return}const r=s,g=i;if(g.textContent=this.nextSuggestion.attributes.title||"",o.classList.toggle("hidden",!this.nextSuggestion.sponsorLogoUrl),n&&(n.src=this.nextSuggestion.sponsorLogoUrl?this.nextSuggestion.sponsorLogoUrl:""),a.classList.toggle("hidden",!this.nextSuggestion.discounted),this.nextSuggestion.attributes["media-url"]){if(r.classList.add("loading"),r.complete&&r.src===this.nextSuggestion.attributes["media-url"]){r.classList.remove("loading"),e();return}r.onload=()=>{r.classList.remove("loading"),e()},r.onerror=()=>{r.classList.remove("loading"),e()},r.src=this.nextSuggestion.attributes["media-url"]}else e()})}async waitForNextSuggestionReady(){for(;this.isLoadingNextSuggestion;)await new Promise(e=>setTimeout(e,50));this.nextSuggestion&&await this.updateNextSuggestionUI()}runSuggestionTransition(e,t){if(this.isAnimating)return;const s=this.querySelector(".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)"),i=this.querySelector(".mealz-planner-recipe-suggestion__next");if(!s||!i){t();return}if(this.prefersReducedMotion){t(),this.initSelectors();return}this.isAnimating=!0;const a=e==="add"?"mealz-planner-recipe-suggestion__exit-add":"mealz-planner-recipe-suggestion__exit-pass";s.classList.add(a),i.classList.add("mealz-planner-recipe-suggestion__promote"),setTimeout(()=>{(async()=>{s.style.display="none",s.classList.remove(a),s.classList.add("mealz-planner-recipe-suggestion__next"),i.classList.remove("mealz-planner-recipe-suggestion__promote","mealz-planner-recipe-suggestion__next"),this.initSelectors(),t(),await this.waitForNextSuggestionReady();const n=this.querySelector(".mealz-planner-recipe-suggestion__next");n?(n.classList.add("mealz-planner-recipe-suggestion__reveal"),n.style.display="flex",setTimeout(()=>{n.classList.remove("mealz-planner-recipe-suggestion__reveal"),this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))},200)):(this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0})))})()},300)}addRecipe(){this.addRecipeUsingSuggestionFlow$().subscribe()}addRecipeFromDetails$(e){return typeof e=="number"&&(this.guests=e),this.addRecipeUsingSuggestionFlow$()}addRecipeUsingSuggestionFlow$(){if(this.isAnimating)return c;this.toggleLoadingButton(!0);const e=document.querySelector("mealz-planner-current-menu");return e?(this.rejectCurrentRecipeIfNeeded(),e.addRecipe(this.recipeId,this.guests,"ai_suggestion","meals-planner-dashboard").pipe(u(1),d({next:()=>{this.runSuggestionTransition("add",()=>{this.addAndSelectNewSuggestion(),this.toggleLoadingButton(!1)})},error:()=>{this.toggleLoadingButton(!1)}}))):(this.toggleLoadingButton(!1),c)}toggleLoadingButton(e){this.querySelectorAll(".mealz-planner-recipe-suggestion .mealz-planner-recipe-suggestion__actions-add-button").forEach(s=>{s.classList.toggle("loading",e)})}addAndSelectNewSuggestion(e){if(e){this.menuRecipes.push(e),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.requestUpdate();return}this.suggestedRecipes.length===0||!this.suggestedRecipes[0]||(this.menuRecipes.push(this.suggestedRecipes[0]),this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent(),this.requestUpdate())}removeRecipe(e){const t=e||this.recipeId,s=document.querySelector("mealz-planner-current-menu");return!s||!t?x():s.removeRecipe(t).pipe(u(1),d(()=>{const i=this.menuRecipes.findIndex(a=>a.id===t);i!==-1&&(this.menuRecipes.splice(i,1),this.recipeId===t&&(this.updateDisplayedRecipe(),this.requestUpdate()))}))}swapRecipe(){this.isAnimating||(this.rejectCurrentRecipeIfNeeded(),this.recipeSwappedEvent(),this.swapRecipeCount++,!sessionStorage.getItem("_miam/selectFromCatalogSuggestion")&&this.swapRecipeCount>3&&(sessionStorage.setItem("_miam/selectFromCatalogSuggestion","true"),this.openCatalogModal()),this.runSuggestionTransition("pass",()=>{this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent()}))}rejectCurrentRecipeIfNeeded(){const e=this.suggestedRecipes[0];(!this.hasUserInteracted||this.suggestedRecipes.length===1)&&(e!=null&&e.id)&&p.planner.rejectRecipe(e.id).pipe(u(1)).subscribe(),this.hasUserInteracted||(this.hasUserInteracted=!0)}updateNextSuggestion(e=!1){var t;this.suggestedRecipes.length>1?(this.nextSuggestion=this.suggestedRecipes[1],e&&((t=this.nextSuggestion)!=null&&t.id)&&p.planner.rejectRecipe(this.nextSuggestion.id).pipe(u(1)).subscribe()):(this.nextSuggestion=null,this.getNewSuggestedRecipes())}getNewSuggestedRecipes(e){const t=(e==null?void 0:e.replace)===!0;this.isLoadingNextSuggestion=!0,p.planner.getSuggestedRecipes().pipe(u(1)).subscribe(s=>{t?(this.suggestedRecipes=[...s],this.hasUserInteracted=!1,this.nextSuggestion=this.suggestedRecipes[1]||null):(this.suggestedRecipes=[...this.suggestedRecipes,...s],this.hasUserInteracted=!1,this.updateNextSuggestion()),this.updateDisplayedRecipe(),this.updateNextSuggestionUI().then(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}).catch(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}),this.suggestionShownEvent()})}openCatalogModal(){const e=document.querySelector("mealz-planner-current-menu");this.promptCatalogEvent(),e==null||e.openCatalogModal()}openRecipeDetails(){p.recipes.openDetails(this.recipeId,this.guests,0,"",!0)}subscribeToPreferencesChanges(){this.preferencesSubscription.add(p.preferences.preferencesChanged$().subscribe(()=>{if(this.isAnimating||this.isLoadingNextSuggestion){this.pendingPreferencesRefresh=!0;return}this.getNewSuggestedRecipes({replace:!0})}))}recipeSwappedEvent(){p.analytics.sendEvent("planner.recipe.swap",this.analyticsPath,{recipe_id:this.recipeId})}promptCatalogEvent(){p.analytics.sendEvent("planner.recipe.catalog-prompt",this.analyticsPath,{})}suggestionShownEvent(){this.recipeId&&this.recipeId!==this.lastShownRecipeId&&(p.analytics.sendEvent("planner.suggestion.show",this.analyticsPath,{recipe_id:this.recipeId}),this.lastShownRecipeId=this.recipeId)}};l=z([_("mealz-planner-recipe-suggestion")],l);customElements.get("mealz-planner-recipe-suggestion")||customElements.define("mealz-planner-recipe-suggestion",l);
1
+ import{N as h,n as m,a as f}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as _}from"../../assets/custom-element-BhZVzxrc.js";import{m as g}from"../../assets/mealz-sdk-E_fNZM-c.js";import{d as S}from"../../assets/debounceTime-B4DpnstH.js";import{t as u}from"../../assets/take-CozE9iSG.js";import{E as c}from"../../assets/empty-0eVnsLmk.js";import{t as d}from"../../assets/tap-C8CJ3R2H.js";import{o as x}from"../../assets/of-DiALp3BZ.js";import"../../assets/async-CFBGA-Dz.js";import"../../assets/OperatorSubscriber-BaYaQC1O.js";import"../../assets/args-BozZ6oU-.js";import"../../assets/isScheduler-C5PGPVU1.js";import"../../assets/from-CAidt5N1.js";import"../../assets/innerFrom-BgPDnAsH.js";import"../../assets/executeSchedule-CEDvgTzM.js";class R{constructor(){this.attributes={title:"","ext-id":"","ext-link":"",description:"","number-of-guests":"","preparation-time":"","preheating-time":"","cooking-time":"","resting-time":"","media-url":"",source:"","informational-page-html":"","filigrane-logo-url":"","informational-sentence":"","order-history":"",difficulty:1,cost:1,suggested:!1,popularity:0,"video-id":"",promoted:!1,discounted:!1,editable:!1,position:-1},this.ttl=3600,this.finalTimer=this.attributes["preparation-time"]+this.attributes["preheating-time"]+this.attributes["cooking-time"]+this.attributes["resting-time"]}get title(){return this.attributes.title}get promoted(){return this.attributes.promoted}get discounted(){return this.attributes.discounted}get guests(){return this.attributes["number-of-guests"]}set guests(t){this.attributes["number-of-guests"]=t}get filigraneLogoUrl(){return this.attributes["filigrane-logo-url"]?this.attributes["filigrane-logo-url"]:null}get sponsorName(){return this.relationships.sponsors.length>0?this.relationships.sponsors[0].attributes.name:null}get sponsorLogoUrl(){var t,s;return this.relationships.sponsors.data.length>0?(s=(t=this.relationships.sponsors.data[0])==null?void 0:t.attributes)==null?void 0:s["logo-url"]:null}get informationalSentence(){return this.attributes["informational-sentence"]}get costLabel(){switch(this.attributes.cost){case 1:return"faible";case 2:return"moyen";case 3:return"élevé";default:return"moyen"}}get orderHistory(){return this.attributes["order-history"]}get preparationTime(){}get cookingTime(){}get restingTime(){}get difficulty(){return this.attributes.difficulty}set difficulty(t){this.attributes.difficulty=t}set discounted(t){this.attributes.discounted=t}}var b=Object.getOwnPropertyDescriptor,z=(e,t,s,i)=>{for(var a=i>1?void 0:i?b(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(a=n(a)||a);return a};let l=class extends h{constructor(){super(...arguments),this.recipeId="",this.guests=0,this.menuRecipes=[],this.suggestedRecipes=[],this.nextSuggestion=null,this.swapRecipeCount=0,this.swapRecipeClick$=new m,this.analyticsPath="/meals-planner/current",this.preferencesSubscription=new f,this.lastShownRecipeId=null,this.isAnimating=!1,this.prefersReducedMotion=!1,this.hasUserInteracted=!1,this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh=!1}get selectors(){return{currentCard:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)",title:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-current-menu__recipe-title",swapButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-swap-button",addButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-button",seeRecipe:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__see-recipe",addAndSwapButtons:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-and-swap",pictureContainer:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture",picture:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture img",promotion:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-badges-promotion",sponsor:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor",sponsorImg:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor img",nextSuggestionCard:".mealz-planner-recipe-suggestion__next",nextSuggestionPicture:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__picture img",nextSuggestionTitle:".mealz-planner-recipe-suggestion__next .mealz-planner-current-menu__recipe-title",nextPromotion:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-badges-promotion",nextSponsor:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor",nextSponsorImg:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor img"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.addEventListeners(),this.swapRecipeClick$.pipe(S(300)).subscribe(()=>this.swapRecipe()),this.subscribeToPreferencesChanges(),this.prefersReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches}disconnectedCallback(){super.disconnectedCallback(),this.swapRecipeClick$.complete(),this.preferencesSubscription.unsubscribe()}firstUpdated(){const e=this.getAttribute("starting-data");e&&(Object.assign(this,JSON.parse(e)),this.nextSuggestion=this.suggestedRecipes[1]||null,this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.recipeId&&this.suggestionShownEvent(),this.removeAttribute("starting-data"))}addEventListeners(){this.addEventListener("click",e=>{if(this.isAnimating){e.preventDefault(),e.stopPropagation();return}const t=e.target;if(t.closest(".mealz-planner-recipe-suggestion__actions-swap-button")){this.swapRecipeClick$.next();return}const s=t.closest(".mealz-planner-recipe-suggestion__actions-add-button");if(s&&!s.classList.contains("loading")){this.addRecipe();return}if(t.closest(".mealz-planner-current-menu__recipe-title")||t.closest(".mealz-planner-recipe-suggestion__see-recipe")||t.closest(".mealz-planner-recipe-suggestion__picture")){this.openRecipeDetails();return}})}updateDisplayedRecipe(){const{title:e,addAndSwapButtons:t,picture:s,promotion:i,sponsor:a,sponsorImg:o}=this.elements;if(!s||!e||!i||!a||!o||!t)return;const n=this.suggestedRecipes[0];if(!n)return;const r=new R;Object.assign(r,n),this.recipeId=n.id,this.setupImageHandlers(s,r,e,t,i,a,o)}setupImageHandlers(e,t,s,i,a,o,n){let r=null;const p=()=>{r&&(clearTimeout(r),r=null),this.updateRecipeUI(e,s,i,t,a,o,n)};e.classList.add("loading"),e.onload=p,e.onerror=p,t.attributes["media-url"]?(e.src=t.attributes["media-url"],r=window.setTimeout(p,1e3)):p()}updateRecipeUI(e,t,s,i,a,o,n){e.classList.remove("loading"),o.classList.toggle("hidden",!i.sponsorLogoUrl),n&&(n.src=i.sponsorLogoUrl?i.sponsorLogoUrl:""),a.classList.toggle("hidden",!i.discounted),t.textContent=i.attributes.title||"";const r=this.menuRecipes.some(p=>p.id===i.id);s.classList.toggle("hidden",r)}updateNextSuggestionUI(){return new Promise(e=>{const{nextSuggestionCard:t,nextSuggestionPicture:s,nextSuggestionTitle:i,nextPromotion:a,nextSponsor:o,nextSponsorImg:n}=this.elements;if(!this.nextSuggestion){t&&t.classList.add("hidden"),e();return}if(t&&t.classList.remove("hidden"),!s||!i){e();return}const r=s,p=i;if(p.textContent=this.nextSuggestion.attributes.title||"",o.classList.toggle("hidden",!this.nextSuggestion.sponsorLogoUrl),n&&(n.src=this.nextSuggestion.sponsorLogoUrl?this.nextSuggestion.sponsorLogoUrl:""),a.classList.toggle("hidden",!this.nextSuggestion.discounted),this.nextSuggestion.attributes["media-url"]){if(r.classList.add("loading"),r.complete&&r.src===this.nextSuggestion.attributes["media-url"]){r.classList.remove("loading"),e();return}r.onload=()=>{r.classList.remove("loading"),e()},r.onerror=()=>{r.classList.remove("loading"),e()},r.src=this.nextSuggestion.attributes["media-url"]}else e()})}async waitForNextSuggestionReady(){for(;this.isLoadingNextSuggestion;)await new Promise(e=>setTimeout(e,50));this.nextSuggestion&&await this.updateNextSuggestionUI()}runSuggestionTransition(e,t){if(this.isAnimating)return;const s=this.querySelector(".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)"),i=this.querySelector(".mealz-planner-recipe-suggestion__next");if(!s||!i){t();return}if(this.prefersReducedMotion){t(),this.initSelectors();return}this.isAnimating=!0;const a=e==="add"?"mealz-planner-recipe-suggestion__exit-add":"mealz-planner-recipe-suggestion__exit-pass";s.classList.add(a),i.classList.add("mealz-planner-recipe-suggestion__promote"),setTimeout(()=>{(async()=>{s.style.display="none",s.classList.remove(a),s.classList.add("mealz-planner-recipe-suggestion__next"),i.classList.remove("mealz-planner-recipe-suggestion__promote","mealz-planner-recipe-suggestion__next"),this.initSelectors(),t(),await this.waitForNextSuggestionReady();const n=this.querySelector(".mealz-planner-recipe-suggestion__next");n?(n.classList.add("mealz-planner-recipe-suggestion__reveal"),n.style.display="flex",setTimeout(()=>{n.classList.remove("mealz-planner-recipe-suggestion__reveal"),this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))},200)):(this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0})))})()},300)}addRecipe(){g.hook.hookCallback().pipe(u(1)).subscribe(e=>{e&&this.addRecipeUsingSuggestionFlow$().subscribe()})}addRecipeFromDetails$(e){return typeof e=="number"&&(this.guests=e),this.addRecipeUsingSuggestionFlow$()}addRecipeUsingSuggestionFlow$(){if(this.isAnimating)return c;this.toggleLoadingButton(!0);const e=document.querySelector("mealz-planner-current-menu");return e?(this.rejectCurrentRecipeIfNeeded(),e.addRecipe(this.recipeId,this.guests,"ai_suggestion","meals-planner-dashboard").pipe(u(1),d({next:()=>{this.runSuggestionTransition("add",()=>{this.addAndSelectNewSuggestion(),this.toggleLoadingButton(!1)})},error:()=>{this.toggleLoadingButton(!1)}}))):(this.toggleLoadingButton(!1),c)}toggleLoadingButton(e){this.querySelectorAll(".mealz-planner-recipe-suggestion .mealz-planner-recipe-suggestion__actions-add-button").forEach(s=>{s.classList.toggle("loading",e)})}addAndSelectNewSuggestion(e){if(e){this.menuRecipes.push(e),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.requestUpdate();return}this.suggestedRecipes.length===0||!this.suggestedRecipes[0]||(this.menuRecipes.push(this.suggestedRecipes[0]),this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent(),this.requestUpdate())}removeRecipe(e){const t=e||this.recipeId,s=document.querySelector("mealz-planner-current-menu");return!s||!t?x():s.removeRecipe(t).pipe(u(1),d(()=>{const i=this.menuRecipes.findIndex(a=>a.id===t);i!==-1&&(this.menuRecipes.splice(i,1),this.recipeId===t&&(this.updateDisplayedRecipe(),this.requestUpdate()))}))}swapRecipe(){this.isAnimating||(this.rejectCurrentRecipeIfNeeded(),this.recipeSwappedEvent(),this.swapRecipeCount++,!sessionStorage.getItem("_miam/selectFromCatalogSuggestion")&&this.swapRecipeCount>3&&(sessionStorage.setItem("_miam/selectFromCatalogSuggestion","true"),this.openCatalogModal()),this.runSuggestionTransition("pass",()=>{this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent()}))}rejectCurrentRecipeIfNeeded(){const e=this.suggestedRecipes[0];(!this.hasUserInteracted||this.suggestedRecipes.length===1)&&(e!=null&&e.id)&&g.planner.rejectRecipe(e.id).pipe(u(1)).subscribe(),this.hasUserInteracted||(this.hasUserInteracted=!0)}updateNextSuggestion(e=!1){var t;this.suggestedRecipes.length>1?(this.nextSuggestion=this.suggestedRecipes[1],e&&((t=this.nextSuggestion)!=null&&t.id)&&g.planner.rejectRecipe(this.nextSuggestion.id).pipe(u(1)).subscribe()):(this.nextSuggestion=null,this.getNewSuggestedRecipes())}getNewSuggestedRecipes(e){const t=(e==null?void 0:e.replace)===!0;this.isLoadingNextSuggestion=!0,g.planner.getSuggestedRecipes().pipe(u(1)).subscribe(s=>{t?(this.suggestedRecipes=[...s],this.hasUserInteracted=!1,this.nextSuggestion=this.suggestedRecipes[1]||null):(this.suggestedRecipes=[...this.suggestedRecipes,...s],this.hasUserInteracted=!1,this.updateNextSuggestion()),this.updateDisplayedRecipe(),this.updateNextSuggestionUI().then(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}).catch(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}),this.suggestionShownEvent()})}openCatalogModal(){const e=document.querySelector("mealz-planner-current-menu");this.promptCatalogEvent(),e==null||e.openCatalogModal()}openRecipeDetails(){g.recipes.openDetails(this.recipeId,this.guests,0,"",!0)}subscribeToPreferencesChanges(){this.preferencesSubscription.add(g.preferences.preferencesChanged$().subscribe(()=>{if(this.isAnimating||this.isLoadingNextSuggestion){this.pendingPreferencesRefresh=!0;return}this.getNewSuggestedRecipes({replace:!0})}))}recipeSwappedEvent(){g.analytics.sendEvent("planner.recipe.swap",this.analyticsPath,{recipe_id:this.recipeId})}promptCatalogEvent(){g.analytics.sendEvent("planner.recipe.catalog-prompt",this.analyticsPath,{})}suggestionShownEvent(){this.recipeId&&this.recipeId!==this.lastShownRecipeId&&(g.analytics.sendEvent("planner.suggestion.show",this.analyticsPath,{recipe_id:this.recipeId}),this.lastShownRecipeId=this.recipeId)}};l=z([_("mealz-planner-recipe-suggestion")],l);customElements.get("mealz-planner-recipe-suggestion")||customElements.define("mealz-planner-recipe-suggestion",l);
@@ -1 +1 @@
1
- import{N as S}from"../assets/no-shadow-element-YPHUv5PR.js";import{V as f}from"../assets/viewport-listener-CDsKFDz1.js";import{t as I}from"../assets/custom-element-BhZVzxrc.js";import{h as w}from"../assets/session-handler-BZFnRy_K.js";import{w as y,m as c}from"../assets/mealz-sdk-E_fNZM-c.js";import{f as m}from"../assets/filter-BZ75lS5D.js";import{s as b}from"../assets/switchMap-Dk_0Nhlo.js";import{c as v}from"../assets/combineLatest-BmqPE0OB.js";import{t as d}from"../assets/take-CozE9iSG.js";import"../assets/debounceTime-B4DpnstH.js";import"../assets/async-CFBGA-Dz.js";import"../assets/OperatorSubscriber-BaYaQC1O.js";import"../assets/innerFrom-BgPDnAsH.js";import"../assets/from-CAidt5N1.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/mapOneOrManyArgs-COA1aRZM.js";import"../assets/map-BVOhpQm0.js";import"../assets/args-BozZ6oU-.js";import"../assets/isScheduler-C5PGPVU1.js";import"../assets/empty-0eVnsLmk.js";class o{constructor(){this.trackedRecipes=new Map,this.hasScrolled=!1,this.scrollListener=null,this.cleanupInterval=null,this.MAX_RECIPES=1e3,this.CLEANUP_INTERVAL=300*1e3,this.handlePageUnload=()=>{this.destroy()},this.setupScrollListener(),this.startAutoCleanup(),this.setupPageUnloadListener()}static getInstance(){return o.instance||(o.instance=new o),o.instance}trackRecipeShow(t,s,i){const r=Date.now(),n=!this.trackedRecipes.get(t),l=this.hasScrolled;!n&&!l||(this.trackedRecipes.size>=this.MAX_RECIPES&&this.cleanOldRecipes(),this.trackedRecipes.set(t,r),window.mealzInternal.analytics.sendEvent("recipe.show",s,{recipe_id:t,category_id:i}))}cleanOldRecipes(){const s=Date.now()-3600*1e3;for(const[i,r]of this.trackedRecipes.entries())r<s&&this.trackedRecipes.delete(i)}clearAllRecipes(){this.trackedRecipes.clear()}destroy(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null),window.removeEventListener("beforeunload",this.handlePageUnload),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.trackedRecipes.clear(),this.hasScrolled=!1,o.instance=null}setupScrollListener(){let t;this.scrollListener=()=>{this.hasScrolled=!0,clearTimeout(t),t=window.setTimeout(()=>{this.hasScrolled=!1},2e3)},window.addEventListener("scroll",this.scrollListener)}startAutoCleanup(){this.cleanupInterval=window.setInterval(()=>{this.cleanOldRecipes()},this.CLEANUP_INTERVAL)}setupPageUnloadListener(){window.addEventListener("beforeunload",this.handlePageUnload)}}var L=Object.getOwnPropertyDescriptor,C=(e,t,s,i)=>{for(var r=i>1?void 0:i?L(t,s):t,a=e.length-1,n;a>=0;a--)(n=e[a])&&(r=n(r)||r);return r};let p=class extends S{constructor(){super(...arguments),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),this.listenInView(),y().then(()=>{this.setupSubscriptions()}).catch(e=>{console.warn("Failed to initialize SDK subscriptions:",e)})}setupSubscriptions(){this.subscriptions.push(c.basket.recipePricesInBasket$().subscribe(e=>{if(!e)return;const t=e.find(s=>s.id===this.recipeId);e.length>0&&t&&parseFloat(t.price)>0?(this.guests=c.basket.guestsForRecipe(t.id),this.updatedRecipeId=t.id,this.updateDOM()):this.render()}),this.setupPlannerMenuSubscription(),this.setupGuestUpdatesSubscription())}setupPlannerMenuSubscription(){return c.planner.menuPrice$.pipe(m(()=>this.planner&&!!this.recipeId),b(()=>v([c.planner.isRecipeInMenu$(this.recipeId).pipe(d(1))])),m(([e,t])=>e&&typeof t=="number"&&t>0)).subscribe(([e,t])=>{this.guests=t,this.updateGuestDisplay()})}setupGuestUpdatesSubscription(){return c.recipes.guestsUpdated().subscribe(e=>{e.recipeId===this.recipeId&&(this.guests=e.guests,this.updatedRecipeId=this.recipeId,this.updateDOM())})}disconnectedCallback(){var t;super.disconnectedCallback(),this.subscriptions.forEach(s=>s.unsubscribe()),(t=this.analyticsViewportObserver)==null||t.disconnect(),o.getInstance().cleanOldRecipes()}render(){this.recipeCardTop=this.querySelector(".mealz-recipe-card__top"),this.recipeCardCta=this.querySelector(".mealz-recipe-card__cta"),this.recipeCardTop&&(this.getInitialStatus(),this.recipeCardTop.addEventListener("click",()=>this.openDetails()),this.recipeCardCta&&this.recipeCardCta.addEventListener("click",()=>this.recipeCardCtaClick()))}listenInView(){this.analyticsViewportObserver=new f(this,()=>{this.sendAnalyticsShow()},{threshold:.8,debounce:1e3})}getInitialStatus(){var h;const e=(h=this.attributes["starting-data"])==null?void 0:h.value;if(!e)return;const{id:t,guests:s,path:i,categoryId:r,initialTabIndex:a,planner:n,sessionId:l,recipe:g}=JSON.parse(e);if(this.recipeId=t,this.analyticsPath=i,this.categoryId=r,this.guests=s,this.initialTabIndex=a,this.planner=n,this.recipe=g,w(l),!this.guests){this.guests=this.getGuests();const u=this.querySelector(".mealz-recipe-card__counter p");u&&(u.innerHTML=this.guests.toString())}this.removeAttribute("starting-data"),this.updateDOM()}openDetails(){c.recipes.openDetails(this.recipeId,this.guests,this.initialTabIndex,this.analyticsPath,this.planner,this.categoryId)}recipeCardCtaClick(){this.planner?this.handleCTAClickForPlanner():this.openDetails()}getGuests(){const e=localStorage.getItem("_miam/preferences/guests");if(e){const t=+e;if(!isNaN(t)&&t>0&&t<=30)return t}return 4}handleCTAClickForPlanner(){const e=this.querySelector("mealz-recipe-card-cta");if(!e)return;const t=e.querySelector(".mealz-recipe-card-cta__loader");if(t&&!t.classList.contains("hidden"))return;const s=e.getStatus();s==="add"?(this.showAddingToMenuState(e),this.addRecipeToMenu()):s==="in-menu"&&(this.showRemovingFromMenuState(e),this.removeRecipeFromMenu())}addRecipeToMenu(){var i,r;const e=document.querySelector("mealz-planner-recipe-suggestion"),t=(e==null?void 0:e.guests)||this.guests;this.guests=t,e&&(e.recipeId=this.recipeId);const s=document.querySelector("mealz-planner-current-menu");if(!s){const a=(r=(i=c.recipes)==null?void 0:i.productsPlannerByCategory$)==null?void 0:r.value,n=(a==null?void 0:a.toPickProducts)||[];c.planner.addRecipeToMenu(this.recipeId,t,!!c.pos.currentPos().value,n).pipe(d(1)).subscribe(()=>{this.removeRecipeCardLoader("add");const l=document.querySelector("mealz-planner-recipe-list");l==null||l.addRecipeCardToList(this.recipeId)});return}s.addRecipe(this.recipeId,t).subscribe(()=>{this.removeRecipeCardLoader("add"),e==null||e.addAndSelectNewSuggestion(this.recipe)})}removeRecipeFromMenu(){const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){c.planner.removeRecipeFromMenu(this.recipeId).pipe(d(1)).subscribe(()=>this.removeRecipeCardLoader("remove"));return}e.removeRecipe(this.recipeId).subscribe(()=>this.removeRecipeCardLoader("remove"))}showRemovingFromMenuState(e){const t=this.querySelector(".mealz-recipe-card-cta__loader"),s=e.querySelector("img.in-menu");t==null||t.classList.remove("hidden"),s==null||s.classList.add("hidden")}removeRecipeCardLoader(e){const t=this.querySelector("mealz-recipe-card-cta");if(!t)return;const s=this.querySelector(".mealz-recipe-card-cta"),i=this.querySelector(".mealz-recipe-card-cta__loader"),r=t.querySelector("img.add"),a=t.querySelector("img.in-menu");e==="add"?(i==null||i.classList.add("hidden"),s==null||s.classList.replace("primary","secondary"),a==null||a.classList.remove("hidden"),t.updateStatus("in-menu")):(i==null||i.classList.add("hidden"),s==null||s.classList.replace("secondary","primary"),r==null||r.classList.remove("hidden"),t.updateStatus("add"))}showAddingToMenuState(e){const t=this.querySelector(".mealz-recipe-card-cta__loader"),s=e.querySelector("img.add"),i=e.querySelector("img.in-menu");t==null||t.classList.remove("hidden"),s==null||s.classList.add("hidden"),i==null||i.classList.add("hidden")}updateDOM(){if(this.recipeId!==this.updatedRecipeId)return;const e=this.querySelector(".mealz-recipe-card__counter p");e&&(e.innerHTML=this.guests.toString())}updateGuestDisplay(){const e=this.querySelector(".mealz-recipe-card__counter p");e&&this.guests&&(e.innerHTML=this.guests.toString())}sendAnalyticsShow(){o.getInstance().trackRecipeShow(this.recipeId,this.analyticsPath,this.categoryId)}};p=C([I("mealz-recipe-card")],p);customElements.get("mealz-recipe-card")||customElements.define("mealz-recipe-card",p);
1
+ import{N as S}from"../assets/no-shadow-element-YPHUv5PR.js";import{V as f}from"../assets/viewport-listener-CDsKFDz1.js";import{t as I}from"../assets/custom-element-BhZVzxrc.js";import{h as w}from"../assets/session-handler-BZFnRy_K.js";import{w as b,m as c}from"../assets/mealz-sdk-E_fNZM-c.js";import{f as m}from"../assets/filter-BZ75lS5D.js";import{s as y}from"../assets/switchMap-Dk_0Nhlo.js";import{c as v}from"../assets/combineLatest-BmqPE0OB.js";import{t as d}from"../assets/take-CozE9iSG.js";import"../assets/debounceTime-B4DpnstH.js";import"../assets/async-CFBGA-Dz.js";import"../assets/OperatorSubscriber-BaYaQC1O.js";import"../assets/innerFrom-BgPDnAsH.js";import"../assets/from-CAidt5N1.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/mapOneOrManyArgs-COA1aRZM.js";import"../assets/map-BVOhpQm0.js";import"../assets/args-BozZ6oU-.js";import"../assets/isScheduler-C5PGPVU1.js";import"../assets/empty-0eVnsLmk.js";class o{constructor(){this.trackedRecipes=new Map,this.hasScrolled=!1,this.scrollListener=null,this.cleanupInterval=null,this.MAX_RECIPES=1e3,this.CLEANUP_INTERVAL=300*1e3,this.handlePageUnload=()=>{this.destroy()},this.setupScrollListener(),this.startAutoCleanup(),this.setupPageUnloadListener()}static getInstance(){return o.instance||(o.instance=new o),o.instance}trackRecipeShow(e,s,i){const r=Date.now(),n=!this.trackedRecipes.get(e),l=this.hasScrolled;!n&&!l||(this.trackedRecipes.size>=this.MAX_RECIPES&&this.cleanOldRecipes(),this.trackedRecipes.set(e,r),window.mealzInternal.analytics.sendEvent("recipe.show",s,{recipe_id:e,category_id:i}))}cleanOldRecipes(){const s=Date.now()-3600*1e3;for(const[i,r]of this.trackedRecipes.entries())r<s&&this.trackedRecipes.delete(i)}clearAllRecipes(){this.trackedRecipes.clear()}destroy(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null),window.removeEventListener("beforeunload",this.handlePageUnload),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.trackedRecipes.clear(),this.hasScrolled=!1,o.instance=null}setupScrollListener(){let e;this.scrollListener=()=>{this.hasScrolled=!0,clearTimeout(e),e=window.setTimeout(()=>{this.hasScrolled=!1},2e3)},window.addEventListener("scroll",this.scrollListener)}startAutoCleanup(){this.cleanupInterval=window.setInterval(()=>{this.cleanOldRecipes()},this.CLEANUP_INTERVAL)}setupPageUnloadListener(){window.addEventListener("beforeunload",this.handlePageUnload)}}var L=Object.getOwnPropertyDescriptor,C=(t,e,s,i)=>{for(var r=i>1?void 0:i?L(e,s):e,a=t.length-1,n;a>=0;a--)(n=t[a])&&(r=n(r)||r);return r};let p=class extends S{constructor(){super(...arguments),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),this.listenInView(),b().then(()=>{this.setupSubscriptions()}).catch(t=>{console.warn("Failed to initialize SDK subscriptions:",t)})}setupSubscriptions(){this.subscriptions.push(c.basket.recipePricesInBasket$().subscribe(t=>{if(!t)return;const e=t.find(s=>s.id===this.recipeId);t.length>0&&e&&parseFloat(e.price)>0?(this.guests=c.basket.guestsForRecipe(e.id),this.updatedRecipeId=e.id,this.updateDOM()):this.render()}),this.setupPlannerMenuSubscription(),this.setupGuestUpdatesSubscription())}setupPlannerMenuSubscription(){return c.planner.menuPrice$.pipe(m(()=>this.planner&&!!this.recipeId),y(()=>v([c.planner.isRecipeInMenu$(this.recipeId).pipe(d(1))])),m(([t,e])=>t&&typeof e=="number"&&e>0)).subscribe(([t,e])=>{this.guests=e,this.updateGuestDisplay()})}setupGuestUpdatesSubscription(){return c.recipes.guestsUpdated().subscribe(t=>{t.recipeId===this.recipeId&&(this.guests=t.guests,this.updatedRecipeId=this.recipeId,this.updateDOM())})}disconnectedCallback(){var e;super.disconnectedCallback(),this.subscriptions.forEach(s=>s.unsubscribe()),(e=this.analyticsViewportObserver)==null||e.disconnect(),o.getInstance().cleanOldRecipes()}render(){this.recipeCardTop=this.querySelector(".mealz-recipe-card__top"),this.recipeCardCta=this.querySelector(".mealz-recipe-card__cta"),this.recipeCardTop&&(this.getInitialStatus(),this.recipeCardTop.addEventListener("click",()=>this.openDetails()),this.recipeCardCta&&this.recipeCardCta.addEventListener("click",()=>this.recipeCardCtaClick()))}listenInView(){this.analyticsViewportObserver=new f(this,()=>{this.sendAnalyticsShow()},{threshold:.8,debounce:1e3})}getInitialStatus(){var h;const t=(h=this.attributes["starting-data"])==null?void 0:h.value;if(!t)return;const{id:e,guests:s,path:i,categoryId:r,initialTabIndex:a,planner:n,sessionId:l,recipe:g}=JSON.parse(t);if(this.recipeId=e,this.analyticsPath=i,this.categoryId=r,this.guests=s,this.initialTabIndex=a,this.planner=n,this.recipe=g,w(l),!this.guests){this.guests=this.getGuests();const u=this.querySelector(".mealz-recipe-card__counter p");u&&(u.innerHTML=this.guests.toString())}this.removeAttribute("starting-data"),this.updateDOM()}openDetails(){c.recipes.openDetails(this.recipeId,this.guests,this.initialTabIndex,this.analyticsPath,this.planner,this.categoryId)}recipeCardCtaClick(){this.planner?this.handleCTAClickForPlanner():this.openDetails()}getGuests(){const t=localStorage.getItem("_miam/preferences/guests");if(t){const e=+t;if(!isNaN(e)&&e>0&&e<=30)return e}return 4}handleCTAClickForPlanner(){c.hook.hookCallback().pipe(d(1)).subscribe(t=>{if(!t)return;const e=this.querySelector("mealz-recipe-card-cta");if(!e)return;const s=e.querySelector(".mealz-recipe-card-cta__loader");if(s&&!s.classList.contains("hidden"))return;const i=e.getStatus();i==="add"?(this.showAddingToMenuState(e),this.addRecipeToMenu()):i==="in-menu"&&(this.showRemovingFromMenuState(e),this.removeRecipeFromMenu())})}addRecipeToMenu(){var i,r;const t=document.querySelector("mealz-planner-recipe-suggestion"),e=(t==null?void 0:t.guests)||this.guests;this.guests=e,t&&(t.recipeId=this.recipeId);const s=document.querySelector("mealz-planner-current-menu");if(!s){const a=(r=(i=c.recipes)==null?void 0:i.productsPlannerByCategory$)==null?void 0:r.value,n=(a==null?void 0:a.toPickProducts)||[];c.planner.addRecipeToMenu(this.recipeId,e,!!c.pos.currentPos().value,n).pipe(d(1)).subscribe(()=>{this.removeRecipeCardLoader("add");const l=document.querySelector("mealz-planner-recipe-list");l==null||l.addRecipeCardToList(this.recipeId)});return}s.addRecipe(this.recipeId,e).subscribe(()=>{this.removeRecipeCardLoader("add"),t==null||t.addAndSelectNewSuggestion(this.recipe)})}removeRecipeFromMenu(){const t=document.querySelector("mealz-planner-recipe-suggestion");if(!t){c.planner.removeRecipeFromMenu(this.recipeId).pipe(d(1)).subscribe(()=>this.removeRecipeCardLoader("remove"));return}t.removeRecipe(this.recipeId).subscribe(()=>this.removeRecipeCardLoader("remove"))}showRemovingFromMenuState(t){const e=this.querySelector(".mealz-recipe-card-cta__loader"),s=t.querySelector("img.in-menu");e==null||e.classList.remove("hidden"),s==null||s.classList.add("hidden")}removeRecipeCardLoader(t){const e=this.querySelector("mealz-recipe-card-cta");if(!e)return;const s=this.querySelector(".mealz-recipe-card-cta"),i=this.querySelector(".mealz-recipe-card-cta__loader"),r=e.querySelector("img.add"),a=e.querySelector("img.in-menu");t==="add"?(i==null||i.classList.add("hidden"),s==null||s.classList.replace("primary","secondary"),a==null||a.classList.remove("hidden"),e.updateStatus("in-menu")):(i==null||i.classList.add("hidden"),s==null||s.classList.replace("secondary","primary"),r==null||r.classList.remove("hidden"),e.updateStatus("add"))}showAddingToMenuState(t){const e=this.querySelector(".mealz-recipe-card-cta__loader"),s=t.querySelector("img.add"),i=t.querySelector("img.in-menu");e==null||e.classList.remove("hidden"),s==null||s.classList.add("hidden"),i==null||i.classList.add("hidden")}updateDOM(){if(this.recipeId!==this.updatedRecipeId)return;const t=this.querySelector(".mealz-recipe-card__counter p");t&&(t.innerHTML=this.guests.toString())}updateGuestDisplay(){const t=this.querySelector(".mealz-recipe-card__counter p");t&&this.guests&&(t.innerHTML=this.guests.toString())}sendAnalyticsShow(){o.getInstance().trackRecipeShow(this.recipeId,this.analyticsPath,this.categoryId)}};p=C([I("mealz-recipe-card")],p);customElements.get("mealz-recipe-card")||customElements.define("mealz-recipe-card",p);
@@ -1,4 +1,4 @@
1
- import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{_ as re,n as D,p as X,b as ne,c as oe,q as le,N as m,D as c,k as r}from"../assets/no-shadow-element-YPHUv5PR.js";import{t as g}from"../assets/custom-element-BhZVzxrc.js";import{n as p}from"../assets/property-_7ObQ3dl.js";import{P as ce}from"../assets/price-DAxY_7sk.js";import{m as o}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as Z}from"../assets/merge-Cm-mm3_Q.js";import{m as h}from"../assets/map-BVOhpQm0.js";import{t as U}from"../assets/take-CozE9iSG.js";import{c as ee}from"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import{G as te}from"../assets/product-card-HetVhdJ3.js";import"../price/price.min.js";import"../assets/promotion-badge-8Arhhb-p.js";import"../assets/accordion-DJLqKUJq.js";import"../store-indicator/store-indicator.min.js";import"../last-order-badge/last-order-badge.min.js";import"../order-again/order-again.min.js";import"../like-button/like-button.min.js";import{L as de}from"../last-order-modal/last-order-modal.min.js";import{a as pe}from"../assets/unsafe-html-CY0Np4--.js";import{M as ue}from"../planner/planner-onboarding/planner-onboarding.min.js";import{o as se,c as he}from"../assets/OperatorSubscriber-BaYaQC1O.js";import{i as H}from"../assets/innerFrom-BgPDnAsH.js";import{f as Q}from"../assets/filter-BZ75lS5D.js";import{t as z}from"../assets/tap-C8CJ3R2H.js";import{s as Y}from"../assets/switchMap-Dk_0Nhlo.js";import{c as J}from"../assets/combineLatest-BmqPE0OB.js";import{d as me}from"../assets/async-CFBGA-Dz.js";import"../assets/viewport-listener-CDsKFDz1.js";import"../assets/debounceTime-B4DpnstH.js";import"../assets/skipWhile-BZVFq1Cg.js";import"../assets/mergeAll-BdUAXyrs.js";import"../assets/mergeMap-Dw_YYHwH.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-0eVnsLmk.js";import"../assets/args-BozZ6oU-.js";import"../assets/isScheduler-C5PGPVU1.js";import"../assets/from-CAidt5N1.js";import"../assets/delay-BNnJ-6LE.js";import"../assets/timer-D82-ik89.js";import"../store-locator/store-locator.min.js";import"../assets/state-W5mtSPAs.js";import"../assets/query-BApjzB0v.js";import"../onboarding/onboarding.min.js";import"../onboarding/events.min.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../assets/responsive-C7Qf71r3.js";import"../assets/mapOneOrManyArgs-COA1aRZM.js";var ge=function(e){re(t,e);function t(s,a,i){s===void 0&&(s=1/0),a===void 0&&(a=1/0),i===void 0&&(i=me);var n=e.call(this)||this;return n._bufferSize=s,n._windowTime=a,n._timestampProvider=i,n._buffer=[],n._infiniteTimeWindow=!0,n._infiniteTimeWindow=a===1/0,n._bufferSize=Math.max(1,s),n._windowTime=Math.max(1,a),n}return t.prototype.next=function(s){var a=this,i=a.isStopped,n=a._buffer,l=a._infiniteTimeWindow,d=a._timestampProvider,v=a._windowTime;i||(n.push(s),!l&&n.push(d.now()+v)),this._trimBuffer(),e.prototype.next.call(this,s)},t.prototype._subscribe=function(s){this._throwIfClosed(),this._trimBuffer();for(var a=this._innerSubscribe(s),i=this,n=i._infiniteTimeWindow,l=i._buffer,d=l.slice(),v=0;v<d.length&&!s.closed;v+=n?1:2)s.next(d[v]);return this._checkFinalizedStatuses(s),a},t.prototype._trimBuffer=function(){var s=this,a=s._bufferSize,i=s._timestampProvider,n=s._buffer,l=s._infiniteTimeWindow,d=(l?1:2)*a;if(a<1/0&&d<n.length&&n.splice(0,n.length-d),!l){for(var v=i.now(),k=0,u=1;u<n.length&&n[u]<=v;u+=2)k=u;k&&n.splice(0,k+1)}},t}(D);function ve(e){e===void 0&&(e={});var t=e.connector,s=t===void 0?function(){return new D}:t,a=e.resetOnError,i=a===void 0?!0:a,n=e.resetOnComplete,l=n===void 0?!0:n,d=e.resetOnRefCountZero,v=d===void 0?!0:d;return function(k){var u,f,I,T=0,w=!1,S=!1,C=function(){f==null||f.unsubscribe(),f=void 0},L=function(){C(),u=I=void 0,w=S=!1},ae=function(){var P=u;L(),P==null||P.unsubscribe()};return se(function(P,K){T++,!S&&!w&&C();var x=I=I??s();K.add(function(){T--,T===0&&!S&&!w&&(f=A(ae,v))}),x.subscribe(K),!u&&T>0&&(u=new X({next:function(R){return x.next(R)},error:function(R){S=!0,C(),f=A(L,i,R),x.error(R)},complete:function(){w=!0,C(),f=A(L,l),x.complete()}}),H(P).subscribe(u))})(k)}}function A(e,t){for(var s=[],a=2;a<arguments.length;a++)s[a-2]=arguments[a];if(t===!0){e();return}if(t!==!1){var i=new X({next:function(){i.unsubscribe(),e()}});return H(t.apply(void 0,ne([],oe(s)))).subscribe(i)}}function be(e,t,s){var a,i=!1;return a=e,ve({connector:function(){return new ge(a,t,s)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}function O(e){return se(function(t,s){H(e).subscribe(he(s,function(){return s.complete()},le)),!s.closed&&t.subscribe(s)})}var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,y=(e,t,s,a)=>{for(var i=a>1?void 0:a?fe(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&_e(t,s,i),i};let b=class extends m{constructor(){super(),this.noPosDisplay=!1,this.noSupplier=!1,this.recipeId="",this.plannerMode=!1,this.guests=0,this.recipe=null,this.analyticsPath="",this.subscriptions=[],this.remainingBasketEntries=[],this.recipePrice={remaining:0,inBasket:0,total:0,totalPerGuest:0},this.priceService=ce.getInstance(),this.allIngredientsToBasketLoading=!1,this.ingredientToBasketLoading=!1,this.updateIngredientFromBasketLoading=!1,this.productsLoading=!1,this.inMenu=!1,this.menuUpdateLoading=!1,this.styleURL=new URL("./recipe-details/details-footer/details-footer.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.priceService.initFormatter(),this.analyticsPath=`/recipes/${this.recipeId}/shopping`,this.subscriptions.push(Z(o.recipes.remainingBasketEntries$.pipe(h(e=>{this.remainingBasketEntries=e})),o.recipes.recipePrice$.pipe(h(e=>{const t=e.remaining+e.inBasket;this.recipePrice={...e,total:t,totalPerGuest:0}})),o.recipes.allIngredientsToBasketLoading$.pipe(h(e=>{this.allIngredientsToBasketLoading=e})),o.recipes.ingredientToBasketLoading$.pipe(h(e=>{this.ingredientToBasketLoading=e})),o.recipes.updateIngredientFromBasketLoading$.pipe(h(e=>{this.updateIngredientFromBasketLoading=e})),o.recipes.productsLoading$.pipe(h(e=>{this.productsLoading=e})),o.planner.plannerRecipePrice$.pipe(h(e=>{this.recipePrice.totalPerGuest=this.guests>0?e/this.guests:e}))).subscribe(()=>this.requestUpdate())),this.subscribeIsRecipeInMenu()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.isRecipeInMenuSub&&(this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=void 0)}updated(e){super.updated(e),e.has("recipeId")&&this.subscribeIsRecipeInMenu()}subscribeIsRecipeInMenu(){this.recipeId&&(this.isRecipeInMenuSub&&this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=o.planner.isRecipeInMenu$(this.recipeId).pipe(h(e=>{this.inMenu=e})).subscribe(()=>this.requestUpdate()))}closeRecipeDetails(e=!1){o.recipes.displayedRecipe$.next(null),e&&o.basket.basketPreviewState$.next({isOpen:!0,activeTabIndex:o.basket.basketPreviewState$.getValue().activeTabIndex})}continueShopping(){this.closeRecipeDetails(),this.sendContinueEvent()}addToMenu(){var a,i;this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion"),t=!!e&&!!e.recipeId&&e.recipeId===this.recipeId,s=document.querySelector("mealz-planner-current-menu");if(!s){const n=(i=(a=o.recipes)==null?void 0:a.productsPlannerByCategory$)==null?void 0:i.value,l=(n==null?void 0:n.toPickProducts)||[];o.planner.addRecipeToMenu(this.recipeId,this.guests,!!o.pos.currentPos().value,l).pipe(U(1)).subscribe(()=>{this.inMenu=!0;const d=document.querySelector("mealz-planner-recipe-list");d==null||d.addRecipeCardToList(this.recipeId),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()});return}if(t){e.addRecipeFromDetails$(this.guests).subscribe({next:()=>{this.inMenu=!0,this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}});return}s.addRecipe(this.recipeId,this.guests).pipe(U(1)).subscribe({next:()=>{this.inMenu=!0,e==null||e.addAndSelectNewSuggestion(this.recipe||void 0),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}})}removeFromMenu(){this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){o.planner.removeRecipeFromMenu(this.recipeId).pipe(U(1)).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()});return}e.removeRecipe(this.recipeId).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()})}addAllIngredients(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),this.sendAddAllEvent(),this.recipePrice.inBasket===0&&this.sendAddRecipeEvent()}render(){if(this.noPosDisplay&&!this.plannerMode)return c;const e=this.remainingBasketEntries.length>0&&!this.plannerMode,t=this.plannerMode&&this.noPosDisplay,s=this.plannerMode&&!this.inMenu;return r`
1
+ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{_ as re,n as B,p as X,b as ne,c as oe,q as le,N as g,D as c,k as r}from"../assets/no-shadow-element-YPHUv5PR.js";import{t as v}from"../assets/custom-element-BhZVzxrc.js";import{n as p}from"../assets/property-_7ObQ3dl.js";import{P as ce}from"../assets/price-DAxY_7sk.js";import{m as o}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as Z}from"../assets/merge-Cm-mm3_Q.js";import{m}from"../assets/map-BVOhpQm0.js";import{t as O}from"../assets/take-CozE9iSG.js";import{c as ee}from"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import{G as te}from"../assets/product-card-HetVhdJ3.js";import"../price/price.min.js";import"../assets/promotion-badge-8Arhhb-p.js";import"../assets/accordion-DJLqKUJq.js";import"../store-indicator/store-indicator.min.js";import"../last-order-badge/last-order-badge.min.js";import"../order-again/order-again.min.js";import"../like-button/like-button.min.js";import{L as de}from"../last-order-modal/last-order-modal.min.js";import{a as pe}from"../assets/unsafe-html-CY0Np4--.js";import{M as ue}from"../planner/planner-onboarding/planner-onboarding.min.js";import{o as se,c as he}from"../assets/OperatorSubscriber-BaYaQC1O.js";import{i as H}from"../assets/innerFrom-BgPDnAsH.js";import{f as Q}from"../assets/filter-BZ75lS5D.js";import{t as z}from"../assets/tap-C8CJ3R2H.js";import{s as Y}from"../assets/switchMap-Dk_0Nhlo.js";import{c as J}from"../assets/combineLatest-BmqPE0OB.js";import{d as me}from"../assets/async-CFBGA-Dz.js";import"../assets/viewport-listener-CDsKFDz1.js";import"../assets/debounceTime-B4DpnstH.js";import"../assets/skipWhile-BZVFq1Cg.js";import"../assets/mergeAll-BdUAXyrs.js";import"../assets/mergeMap-Dw_YYHwH.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-0eVnsLmk.js";import"../assets/args-BozZ6oU-.js";import"../assets/isScheduler-C5PGPVU1.js";import"../assets/from-CAidt5N1.js";import"../assets/delay-BNnJ-6LE.js";import"../assets/timer-D82-ik89.js";import"../store-locator/store-locator.min.js";import"../assets/state-W5mtSPAs.js";import"../assets/query-BApjzB0v.js";import"../onboarding/onboarding.min.js";import"../onboarding/events.min.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../assets/responsive-C7Qf71r3.js";import"../assets/mapOneOrManyArgs-COA1aRZM.js";var ge=function(e){re(t,e);function t(s,a,i){s===void 0&&(s=1/0),a===void 0&&(a=1/0),i===void 0&&(i=me);var n=e.call(this)||this;return n._bufferSize=s,n._windowTime=a,n._timestampProvider=i,n._buffer=[],n._infiniteTimeWindow=!0,n._infiniteTimeWindow=a===1/0,n._bufferSize=Math.max(1,s),n._windowTime=Math.max(1,a),n}return t.prototype.next=function(s){var a=this,i=a.isStopped,n=a._buffer,l=a._infiniteTimeWindow,d=a._timestampProvider,u=a._windowTime;i||(n.push(s),!l&&n.push(d.now()+u)),this._trimBuffer(),e.prototype.next.call(this,s)},t.prototype._subscribe=function(s){this._throwIfClosed(),this._trimBuffer();for(var a=this._innerSubscribe(s),i=this,n=i._infiniteTimeWindow,l=i._buffer,d=l.slice(),u=0;u<d.length&&!s.closed;u+=n?1:2)s.next(d[u]);return this._checkFinalizedStatuses(s),a},t.prototype._trimBuffer=function(){var s=this,a=s._bufferSize,i=s._timestampProvider,n=s._buffer,l=s._infiniteTimeWindow,d=(l?1:2)*a;if(a<1/0&&d<n.length&&n.splice(0,n.length-d),!l){for(var u=i.now(),k=0,h=1;h<n.length&&n[h]<=u;h+=2)k=h;k&&n.splice(0,k+1)}},t}(B);function ve(e){e===void 0&&(e={});var t=e.connector,s=t===void 0?function(){return new B}:t,a=e.resetOnError,i=a===void 0?!0:a,n=e.resetOnComplete,l=n===void 0?!0:n,d=e.resetOnRefCountZero,u=d===void 0?!0:d;return function(k){var h,f,I,T=0,w=!1,S=!1,C=function(){f==null||f.unsubscribe(),f=void 0},U=function(){C(),h=I=void 0,w=S=!1},ae=function(){var P=h;U(),P==null||P.unsubscribe()};return se(function(P,K){T++,!S&&!w&&C();var x=I=I??s();K.add(function(){T--,T===0&&!S&&!w&&(f=A(ae,u))}),x.subscribe(K),!h&&T>0&&(h=new X({next:function(R){return x.next(R)},error:function(R){S=!0,C(),f=A(U,i,R),x.error(R)},complete:function(){w=!0,C(),f=A(U,l),x.complete()}}),H(P).subscribe(h))})(k)}}function A(e,t){for(var s=[],a=2;a<arguments.length;a++)s[a-2]=arguments[a];if(t===!0){e();return}if(t!==!1){var i=new X({next:function(){i.unsubscribe(),e()}});return H(t.apply(void 0,ne([],oe(s)))).subscribe(i)}}function be(e,t,s){var a,i=!1;return a=e,ve({connector:function(){return new ge(a,t,s)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}function D(e){return se(function(t,s){H(e).subscribe(he(s,function(){return s.complete()},le)),!s.closed&&t.subscribe(s)})}var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,y=(e,t,s,a)=>{for(var i=a>1?void 0:a?fe(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&_e(t,s,i),i};let b=class extends g{constructor(){super(),this.noPosDisplay=!1,this.noSupplier=!1,this.recipeId="",this.plannerMode=!1,this.guests=0,this.recipe=null,this.analyticsPath="",this.subscriptions=[],this.remainingBasketEntries=[],this.recipePrice={remaining:0,inBasket:0,total:0,totalPerGuest:0},this.priceService=ce.getInstance(),this.allIngredientsToBasketLoading=!1,this.ingredientToBasketLoading=!1,this.updateIngredientFromBasketLoading=!1,this.productsLoading=!1,this.inMenu=!1,this.menuUpdateLoading=!1,this.styleURL=new URL("./recipe-details/details-footer/details-footer.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.priceService.initFormatter(),this.analyticsPath=`/recipes/${this.recipeId}/shopping`,this.subscriptions.push(Z(o.recipes.remainingBasketEntries$.pipe(m(e=>{this.remainingBasketEntries=e})),o.recipes.recipePrice$.pipe(m(e=>{const t=e.remaining+e.inBasket;this.recipePrice={...e,total:t,totalPerGuest:0}})),o.recipes.allIngredientsToBasketLoading$.pipe(m(e=>{this.allIngredientsToBasketLoading=e})),o.recipes.ingredientToBasketLoading$.pipe(m(e=>{this.ingredientToBasketLoading=e})),o.recipes.updateIngredientFromBasketLoading$.pipe(m(e=>{this.updateIngredientFromBasketLoading=e})),o.recipes.productsLoading$.pipe(m(e=>{this.productsLoading=e})),o.planner.plannerRecipePrice$.pipe(m(e=>{this.recipePrice.totalPerGuest=this.guests>0?e/this.guests:e}))).subscribe(()=>this.requestUpdate())),this.subscribeIsRecipeInMenu()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.isRecipeInMenuSub&&(this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=void 0)}updated(e){super.updated(e),e.has("recipeId")&&this.subscribeIsRecipeInMenu()}subscribeIsRecipeInMenu(){this.recipeId&&(this.isRecipeInMenuSub&&this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=o.planner.isRecipeInMenu$(this.recipeId).pipe(m(e=>{this.inMenu=e})).subscribe(()=>this.requestUpdate()))}closeRecipeDetails(e=!1){o.recipes.displayedRecipe$.next(null),e&&o.basket.basketPreviewState$.next({isOpen:!0,activeTabIndex:o.basket.basketPreviewState$.getValue().activeTabIndex})}continueShopping(){this.closeRecipeDetails(),this.sendContinueEvent()}addToMenu(){o.hook.hookCallback().pipe(O(1)).subscribe(e=>{var i,n;if(!e)return;this.menuUpdateLoading=!0,this.requestUpdate();const t=document.querySelector("mealz-planner-recipe-suggestion"),s=!!t&&!!t.recipeId&&t.recipeId===this.recipeId,a=document.querySelector("mealz-planner-current-menu");if(!a){const l=(n=(i=o.recipes)==null?void 0:i.productsPlannerByCategory$)==null?void 0:n.value,d=(l==null?void 0:l.toPickProducts)||[];o.planner.addRecipeToMenu(this.recipeId,this.guests,!!o.pos.currentPos().value,d).pipe(O(1)).subscribe(()=>{this.inMenu=!0;const u=document.querySelector("mealz-planner-recipe-list");u==null||u.addRecipeCardToList(this.recipeId),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()});return}if(s){t.addRecipeFromDetails$(this.guests).subscribe({next:()=>{this.inMenu=!0,this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}});return}a.addRecipe(this.recipeId,this.guests).pipe(O(1)).subscribe({next:()=>{this.inMenu=!0,t==null||t.addAndSelectNewSuggestion(this.recipe||void 0),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}})})}removeFromMenu(){this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){o.planner.removeRecipeFromMenu(this.recipeId).pipe(O(1)).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()});return}e.removeRecipe(this.recipeId).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()})}addAllIngredients(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),this.sendAddAllEvent(),this.recipePrice.inBasket===0&&this.sendAddRecipeEvent()}render(){if(this.noPosDisplay&&!this.plannerMode)return c;const e=this.remainingBasketEntries.length>0&&!this.plannerMode,t=this.plannerMode&&this.noPosDisplay,s=this.plannerMode&&!this.inMenu;return r`
2
2
  <div class="mealz-recipe-details__footer">
3
3
  ${this.productsLoading&&!this.plannerMode?c:r`
4
4
  <!-- ADD TO BASKET CTA -->
@@ -91,7 +91,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
91
91
  ${this.plannerMode?"par personne":"dans votre panier"}
92
92
  </span>
93
93
  </div>
94
- `}sendAddAllEvent(){o.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){o.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){o.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};y([p({type:Boolean})],b.prototype,"noPosDisplay",2);y([p({type:Boolean})],b.prototype,"noSupplier",2);y([p({type:String})],b.prototype,"recipeId",2);y([p({type:Boolean})],b.prototype,"plannerMode",2);y([p({type:Number})],b.prototype,"guests",2);y([p({attribute:!1})],b.prototype,"recipe",2);b=y([g("mealz-details-footer")],b);customElements.get("mealz-details-footer")||customElements.define("mealz-details-footer",b);var ze=Object.getOwnPropertyDescriptor,ye=(e,t,s,a)=>{for(var i=a>1?void 0:a?ze(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let N=class extends m{constructor(){super(),this.tags=[],this.displayTags=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-infos/details-infos.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.tags=e.recipe.relationships.tags.data.map(t=>t.attributes.name),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}toggleTags(){this.displayTags=!this.displayTags,this.requestUpdate()}noTimePlaceholder(){return r`<span class="mealz-recipe-details-infos__no-time-placeholder">0 min</span>`}noDataPlaceholder(){return r`<span class="mealz-recipe-details-infos__no-data-placeholder">-</span>`}getRecipeDifficultyIntoClassName(){switch(this.recipe.attributes.difficulty){case 1:return"easy";case 2:return"medium";case 3:return"hard";default:return"no-difficulty-defined"}}getRecipeDifficultyIntoText(){switch(this.recipe.attributes.difficulty){case 1:return r`<span class="mealz-ds-text">Facile</span>`;case 2:return r`<span class="mealz-ds-text">Moyen</span>`;case 3:return r`<span class="mealz-ds-text">Difficile</span>`;default:return c}}renderPreparationTime(){return r`
94
+ `}sendAddAllEvent(){o.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){o.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){o.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};y([p({type:Boolean})],b.prototype,"noPosDisplay",2);y([p({type:Boolean})],b.prototype,"noSupplier",2);y([p({type:String})],b.prototype,"recipeId",2);y([p({type:Boolean})],b.prototype,"plannerMode",2);y([p({type:Number})],b.prototype,"guests",2);y([p({attribute:!1})],b.prototype,"recipe",2);b=y([v("mealz-details-footer")],b);customElements.get("mealz-details-footer")||customElements.define("mealz-details-footer",b);var ze=Object.getOwnPropertyDescriptor,ye=(e,t,s,a)=>{for(var i=a>1?void 0:a?ze(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let N=class extends g{constructor(){super(),this.tags=[],this.displayTags=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-infos/details-infos.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.tags=e.recipe.relationships.tags.data.map(t=>t.attributes.name),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}toggleTags(){this.displayTags=!this.displayTags,this.requestUpdate()}noTimePlaceholder(){return r`<span class="mealz-recipe-details-infos__no-time-placeholder">0 min</span>`}noDataPlaceholder(){return r`<span class="mealz-recipe-details-infos__no-data-placeholder">-</span>`}getRecipeDifficultyIntoClassName(){switch(this.recipe.attributes.difficulty){case 1:return"easy";case 2:return"medium";case 3:return"hard";default:return"no-difficulty-defined"}}getRecipeDifficultyIntoText(){switch(this.recipe.attributes.difficulty){case 1:return r`<span class="mealz-ds-text">Facile</span>`;case 2:return r`<span class="mealz-ds-text">Moyen</span>`;case 3:return r`<span class="mealz-ds-text">Difficile</span>`;default:return c}}renderPreparationTime(){return r`
95
95
  <!-- PREPARATION TIME -->
96
96
  <div
97
97
  class="
@@ -157,7 +157,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
157
157
  ${this.renderRecipeDifficulty()}
158
158
  ${this.renderMoreTags()}
159
159
  </div>
160
- `}};N=ye([g("mealz-details-infos")],N);customElements.get("mealz-details-infos")||customElements.define("mealz-details-infos",N);var $e=Object.getOwnPropertyDescriptor,ke=(e,t,s,a)=>{for(var i=a>1?void 0:a?$e(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let q=class extends m{constructor(){super(),this.steps=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-steps/details-steps.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.steps=e.recipe.relationships["recipe-steps"].data.sort((t,s)=>t.attributes["step-number"]-s.attributes["step-number"]).map(t=>t.attributes.description),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){return r`
160
+ `}};N=ye([v("mealz-details-infos")],N);customElements.get("mealz-details-infos")||customElements.define("mealz-details-infos",N);var $e=Object.getOwnPropertyDescriptor,ke=(e,t,s,a)=>{for(var i=a>1?void 0:a?$e(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let q=class extends g{constructor(){super(),this.steps=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-steps/details-steps.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.steps=e.recipe.relationships["recipe-steps"].data.sort((t,s)=>t.attributes["step-number"]-s.attributes["step-number"]).map(t=>t.attributes.description),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){return r`
161
161
  <div class="mealz-details-steps">
162
162
  <!-- HEADER -->
163
163
  <div class="mealz-ds-text weight-xxl mealz-details-steps__header">
@@ -180,7 +180,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
180
180
  `)}
181
181
  </div>
182
182
  </div>
183
- `}};q=ke([g("mealz-details-steps")],q);customElements.get("mealz-details-steps")||customElements.define("mealz-details-steps",q);var Ie=Object.getOwnPropertyDescriptor,Pe=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ie(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let G=class extends m{constructor(){super(),this.ingredients=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-ingredients/details-ingredients.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.ingredients=e.recipe.relationships.ingredients.data,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){var e,t;return r`
183
+ `}};q=ke([v("mealz-details-steps")],q);customElements.get("mealz-details-steps")||customElements.define("mealz-details-steps",q);var Ie=Object.getOwnPropertyDescriptor,Pe=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ie(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let G=class extends g{constructor(){super(),this.ingredients=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-ingredients/details-ingredients.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.ingredients=e.recipe.relationships.ingredients.data,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){var e,t;return r`
184
184
  <div class="mealz-details-ingredients">
185
185
  <!-- HEADER -->
186
186
  <div class="mealz-ds-text weight-xxl mealz-details-ingredients__header">
@@ -209,7 +209,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
209
209
  `)}
210
210
  </div>
211
211
  </div>
212
- `}ingredientPicture(e){return e.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}};G=Pe([g("mealz-details-ingredients")],G);customElements.get("mealz-details-ingredients")||customElements.define("mealz-details-ingredients",G);var Ee=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,$=(e,t,s,a)=>{for(var i=a>1?void 0:a?Te(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Ee(t,s,i),i};const M=["unavailable"],we=["ticked","unselected"];let _=class extends m{constructor(){super(),this.subscriptions=[],this.guestObserverService=te.getInstance(),this.modifiedIngQty=0,this.analyticsPath="/meals-planner/current",this.styleURL=new URL("./product-card/product-card-planner.css",this.getBaseURL())}get status(){var e;return(e=this.product)==null?void 0:e.status}set status(e){this.product.status=e,this.requestUpdate()}get productImage(){var e;return((e=this.product.item)==null?void 0:e.attributes.image)||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get ingredientPicture(){return this.product.ingredient.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get isSponsored(){var e,t,s;return((s=(t=(e=this.product)==null?void 0:e.item)==null?void 0:t.attributes)==null?void 0:s.sponsored)===!0}connectedCallback(){super.connectedCallback(),this.listenGuestsChange(),this.calculateQty()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenGuestsChange(){this.subscriptions.push(this.guestObserverService.guests$.subscribe(e=>{this.currentGuests=e,this.calculateQty()}))}calculateQty(){const e=this.product.ingredient.attributes.quantity/this.initialGuests;this.modifiedIngQty=Number((e*this.currentGuests).toFixed(2)),this.requestUpdate()}openReplaceItemView(){o.planner.openReplaceItemView(this.product),this.replaceItemViewEvent()}onCheckboxChange(e){e.target.checked?(this.status="ticked",o.planner.selectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.addItemEvent()):(this.status="unselected",o.planner.unselectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.deleteItemEvent()),this.requestUpdate()}render(){return r`
212
+ `}ingredientPicture(e){return e.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}};G=Pe([v("mealz-details-ingredients")],G);customElements.get("mealz-details-ingredients")||customElements.define("mealz-details-ingredients",G);var Ee=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,$=(e,t,s,a)=>{for(var i=a>1?void 0:a?Te(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Ee(t,s,i),i};const M=["unavailable"],we=["ticked","unselected"];let _=class extends g{constructor(){super(),this.subscriptions=[],this.guestObserverService=te.getInstance(),this.modifiedIngQty=0,this.analyticsPath="/meals-planner/current",this.styleURL=new URL("./product-card/product-card-planner.css",this.getBaseURL())}get status(){var e;return(e=this.product)==null?void 0:e.status}set status(e){this.product.status=e,this.requestUpdate()}get productImage(){var e;return((e=this.product.item)==null?void 0:e.attributes.image)||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get ingredientPicture(){return this.product.ingredient.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get isSponsored(){var e,t,s;return((s=(t=(e=this.product)==null?void 0:e.item)==null?void 0:t.attributes)==null?void 0:s.sponsored)===!0}connectedCallback(){super.connectedCallback(),this.listenGuestsChange(),this.calculateQty()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenGuestsChange(){this.subscriptions.push(this.guestObserverService.guests$.subscribe(e=>{this.currentGuests=e,this.calculateQty()}))}calculateQty(){const e=this.product.ingredient.attributes.quantity/this.initialGuests;this.modifiedIngQty=Number((e*this.currentGuests).toFixed(2)),this.requestUpdate()}openReplaceItemView(){o.planner.openReplaceItemView(this.product),this.replaceItemViewEvent()}onCheckboxChange(e){e.target.checked?(this.status="ticked",o.planner.selectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.addItemEvent()):(this.status="unselected",o.planner.unselectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.deleteItemEvent()),this.requestUpdate()}render(){return r`
213
213
  <div class="mealz-product-card-planner
214
214
  ${this.status==="ticked"?"added":""}
215
215
  ${M.includes(this.status)||this.oftenIgnored?"disabled":""}
@@ -318,7 +318,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
318
318
  <span>Remplacer</span>
319
319
  </button>
320
320
  `:""}
321
- `}addItemEvent(){o.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){o.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){o.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};$([p({type:Object})],_.prototype,"product",2);$([p({type:String})],_.prototype,"recipeId",2);$([p({type:Number})],_.prototype,"initialGuests",2);$([p({type:Number})],_.prototype,"currentGuests",2);$([p({type:Boolean})],_.prototype,"oftenIgnored",2);_=$([g("mealz-product-card-planner")],_);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",_);var Se=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ie=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ce(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Se(t,s,i),i};let B=class extends m{constructor(){super(),this.styleURL=new URL("./legal-notice/legal-notice.css",this.getBaseURL())}get containsAlcohol(){var t;return(((t=this.tags)==null?void 0:t.data)||[]).some(s=>s.id==="ingredient_category_alcool")}render(){return this.containsAlcohol?r`
321
+ `}addItemEvent(){o.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){o.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){o.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};$([p({type:Object})],_.prototype,"product",2);$([p({type:String})],_.prototype,"recipeId",2);$([p({type:Number})],_.prototype,"initialGuests",2);$([p({type:Number})],_.prototype,"currentGuests",2);$([p({type:Boolean})],_.prototype,"oftenIgnored",2);_=$([v("mealz-product-card-planner")],_);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",_);var Se=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ie=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ce(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Se(t,s,i),i};let L=class extends g{constructor(){super(),this.styleURL=new URL("./legal-notice/legal-notice.css",this.getBaseURL())}get containsAlcohol(){var t;return(((t=this.tags)==null?void 0:t.data)||[]).some(s=>s.id==="ingredient_category_alcool")}render(){return this.containsAlcohol?r`
322
322
  <div class="mealz-products-picker__legal-notices">
323
323
  <span class="mealz-ds-text weight-xxl mealz-products-picker__legal-notices-header">Mentions légales</span>
324
324
  <div class="mealz-products-picker__legal-notices-content">
@@ -330,7 +330,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
330
330
  </span>
331
331
  </div>
332
332
  </div>
333
- `:c}};ie([p()],B.prototype,"tags",2);B=ie([g("mealz-legal-notice")],B);customElements.get("mealz-legal-notice")||customElements.define("mealz-legal-notice",B);var xe=Object.getOwnPropertyDescriptor,Re=(e,t,s,a)=>{for(var i=a>1?void 0:a?xe(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let F=class extends m{constructor(){super(),this.styleURL=[new URL("./product-card/product-card-skeleton/product-card-skeleton.css",this.getBaseURL()),new URL("./product-card/product-card.css",this.getBaseURL())]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}render(){return r`
333
+ `:c}};ie([p()],L.prototype,"tags",2);L=ie([v("mealz-legal-notice")],L);customElements.get("mealz-legal-notice")||customElements.define("mealz-legal-notice",L);var xe=Object.getOwnPropertyDescriptor,Re=(e,t,s,a)=>{for(var i=a>1?void 0:a?xe(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let F=class extends g{constructor(){super(),this.styleURL=[new URL("./product-card/product-card-skeleton/product-card-skeleton.css",this.getBaseURL()),new URL("./product-card/product-card.css",this.getBaseURL())]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}render(){return r`
334
334
  <!-- PRODUCT CARD -->
335
335
  <div class="mealz-product-card skeleton">
336
336
  <!-- HEADER -->
@@ -373,7 +373,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
373
373
  </div>
374
374
  </div>
375
375
  </div>
376
- `}};F=Re([g("mealz-products-card-skeleton")],F);customElements.get("mealz-products-card-skeleton")||customElements.define("mealz-products-card-skeleton",F);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,W=(e,t,s,a)=>{for(var i=a>1?void 0:a?De(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Oe(t,s,i),i};let E=class extends m{constructor(){super(),this.inBasket=!1,this.plannerMode=!1,this.numberUnavailableProducts=0,this.subscriptions=[],this.noSupplier=o.supplier.isNoSupplier(),this.hasEmittedReady=!1,this.styleURL=new URL("./products-picker/products-picker.css",this.getBaseURL())}get totalProducts(){return this.recipe.relationships.ingredients.data.length}connectedCallback(){super.connectedCallback(),this.resetProducts(),this.listenToProducts(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.resetProducts(),this.subscriptions.forEach(e=>e.unsubscribe())}resetProducts(){this.productsByCategory={toPickProducts:[],oftenIgnoredProducts:[]},this.numberUnavailableProducts=0,this.requestUpdate()}listenToProducts(){const e=this.plannerMode?o.recipes.productsPlannerByCategory$:o.recipes.productsByCategory$;this.subscriptions.push(e.subscribe(t=>{this.productsByCategory=t,this.plannerMode?this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.status==="unavailable").length:this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.basketEntry.status==="out_of_stock").length,this.requestUpdate(),this.notifyReadyIfRendered()}))}async notifyReadyIfRendered(){if(this.hasEmittedReady)return;if(await this.updateComplete,this.querySelector(".mealz-product-card-planner__checkbox")||this.querySelector(".mealz-product-card__checkbox")){this.hasEmittedReady=!0;const t=new CustomEvent("products-picker-ready",{bubbles:!0,composed:!0});this.dispatchEvent(t)}}scrollToFirstUnavailable(){const e=document.querySelector(this.plannerMode?".mealz-products-picker":".mealz-products-picker__container");if(e){const t=e.querySelector(this.plannerMode?".mealz-product-card-planner.unavailable":".mealz-product-card__container.out_of_stock");t&&t.scrollIntoView({behavior:"smooth",block:"center"})}}isAlreadyOnCatalogPage(){return window.location.href.includes(o.router.getCatalogUrl())}closeRecipeModal(){}currentPath(){return""}guestsChange(e){const t=new CustomEvent("guestChange",{bubbles:!0,composed:!0,detail:{value:e.detail.value}});this.dispatchEvent(t)}render(){var e,t,s;return r`
376
+ `}};F=Re([v("mealz-products-card-skeleton")],F);customElements.get("mealz-products-card-skeleton")||customElements.define("mealz-products-card-skeleton",F);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,W=(e,t,s,a)=>{for(var i=a>1?void 0:a?De(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Oe(t,s,i),i};let E=class extends g{constructor(){super(),this.inBasket=!1,this.plannerMode=!1,this.numberUnavailableProducts=0,this.subscriptions=[],this.noSupplier=o.supplier.isNoSupplier(),this.hasEmittedReady=!1,this.styleURL=new URL("./products-picker/products-picker.css",this.getBaseURL())}get totalProducts(){return this.recipe.relationships.ingredients.data.length}connectedCallback(){super.connectedCallback(),this.resetProducts(),this.listenToProducts(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.resetProducts(),this.subscriptions.forEach(e=>e.unsubscribe())}resetProducts(){this.productsByCategory={toPickProducts:[],oftenIgnoredProducts:[]},this.numberUnavailableProducts=0,this.requestUpdate()}listenToProducts(){const e=this.plannerMode?o.recipes.productsPlannerByCategory$:o.recipes.productsByCategory$;this.subscriptions.push(e.subscribe(t=>{this.productsByCategory=t,this.plannerMode?this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.status==="unavailable").length:this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.basketEntry.status==="out_of_stock").length,this.requestUpdate(),this.notifyReadyIfRendered()}))}async notifyReadyIfRendered(){if(this.hasEmittedReady)return;if(await this.updateComplete,this.querySelector(".mealz-product-card-planner__checkbox")||this.querySelector(".mealz-product-card__checkbox")){this.hasEmittedReady=!0;const t=new CustomEvent("products-picker-ready",{bubbles:!0,composed:!0});this.dispatchEvent(t)}}scrollToFirstUnavailable(){const e=document.querySelector(this.plannerMode?".mealz-products-picker":".mealz-products-picker__container");if(e){const t=e.querySelector(this.plannerMode?".mealz-product-card-planner.unavailable":".mealz-product-card__container.out_of_stock");t&&t.scrollIntoView({behavior:"smooth",block:"center"})}}isAlreadyOnCatalogPage(){return window.location.href.includes(o.router.getCatalogUrl())}closeRecipeModal(){}currentPath(){return""}guestsChange(e){const t=new CustomEvent("guestChange",{bubbles:!0,composed:!0,detail:{value:e.detail.value}});this.dispatchEvent(t)}render(){var e,t,s;return r`
377
377
  <div class="mealz-products-picker">
378
378
  ${this.inBasket&&this.plannerMode?r`
379
379
  <div class="mealz-products-picker__overlay">
@@ -496,7 +496,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
496
496
  `}
497
497
  </div>
498
498
  <mealz-legal-notice .tags="${this.recipe.relationships.tags}"></mealz-legal-notice>
499
- `}sendHomeDisplayEvent(){o.analytics.sendEvent("home.display",this.analyticsPath,{})}};W([p({type:Boolean})],E.prototype,"inBasket",2);W([p({type:Boolean})],E.prototype,"plannerMode",2);E=W([g("mealz-products-picker")],E);customElements.get("mealz-products-picker")||customElements.define("mealz-products-picker",E);var Be=Object.getOwnPropertyDescriptor,Le=(e,t,s,a)=>{for(var i=a>1?void 0:a?Be(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let V=class extends m{constructor(){super(),this.invalidPos=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/no-pos-selected/no-pos-selected.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenIfPosInvalid()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenIfPosInvalid(){this.subscriptions.push(o.recipes.invalidPosDisplay$.subscribe(e=>{this.invalidPos=e,this.requestUpdate()}))}callPosSelector(){const e=new CustomEvent("posSelected",{bubbles:!0,composed:!0});this.dispatchEvent(e)}openStoreLocator(){window.mealzInternal.noSupplier.displaySupplierSelector$.next(!0)}render(){return r`
499
+ `}sendHomeDisplayEvent(){o.analytics.sendEvent("home.display",this.analyticsPath,{})}};W([p({type:Boolean})],E.prototype,"inBasket",2);W([p({type:Boolean})],E.prototype,"plannerMode",2);E=W([v("mealz-products-picker")],E);customElements.get("mealz-products-picker")||customElements.define("mealz-products-picker",E);var Be=Object.getOwnPropertyDescriptor,Le=(e,t,s,a)=>{for(var i=a>1?void 0:a?Be(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let V=class extends g{constructor(){super(),this.invalidPos=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/no-pos-selected/no-pos-selected.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenIfPosInvalid()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenIfPosInvalid(){this.subscriptions.push(o.recipes.invalidPosDisplay$.subscribe(e=>{this.invalidPos=e,this.requestUpdate()}))}callPosSelector(){const e=new CustomEvent("posSelected",{bubbles:!0,composed:!0});this.dispatchEvent(e)}openStoreLocator(){window.mealzInternal.noSupplier.displaySupplierSelector$.next(!0)}render(){return r`
500
500
  <div class="mealz-no-pos-selected">
501
501
  ${this.invalidPos?r`
502
502
  <!-- INVALID POS -->
@@ -536,7 +536,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
536
536
  Sélectionner un magasin
537
537
  </button>
538
538
  </div>
539
- `}};V=Le([g("mealz-no-pos-selected")],V);customElements.get("mealz-no-pos-selected")||customElements.define("mealz-no-pos-selected",V);var Ue=Object.getOwnPropertyDescriptor,Ae=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ue(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let j=class extends m{constructor(){super(),this.activeTabIndex=0,this.destroy$=new D,this.remainingBasketEntries=[],this.guestObserverService=te.getInstance(),this.isSticky=!1,this.hasBackNavigation=!1,this.drawerViewSwapper=null,this.styleURL=new URL("./recipe-details/recipe-details.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.destroy$=new D,this.handleNoSupplierMode(),Z(o.recipes.displayedRecipe$.pipe(O(this.destroy$),Q(e=>!!e),z(e=>{e.recipe!==null&&(this.recipe=e.recipe,this.sponsor=e.recipe.relationships.sponsors.data[0],this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.plannerMode=!!e.planner,this.getLikeButton(),this.checkSponsorStorytelling(),this.pageview(),this.listenToCloseEvent(),this.setStickyObserver())}),Y(e=>e.recipe===null?[]:this.listenToRecipeInBasket())),this.listenPosStatus(),this.listenRemainingBasketEntries(),this.listenLastOrderDate(),this.listenToLoadingStates(),this.listenToAddAllToBasket()).pipe(O(this.destroy$)).subscribe({next:()=>this.requestUpdate(),error:e=>console.error("Recipe details error:",e)}),this.addEventListener("products-picker-ready",()=>this.startRecipeDetailsOnboardingIfNeeded()),this.setupDrawerBackNavigationIndicator()}disconnectedCallback(){super.disconnectedCallback(),this.destroy$.next(),this.destroy$.complete(),this.topObserver&&this.topObserver.disconnect(),this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.drawerViewSwapper&&this.onActiveViewsChanged&&this.drawerViewSwapper.removeEventListener("mealz-active-views-changed",this.onActiveViewsChanged)}setupDrawerBackNavigationIndicator(){const e=this.closest("mealz-drawer-view-swapper");this.drawerViewSwapper=e??document.querySelector("mealz-drawer-view-swapper"),this.drawerViewSwapper&&(this.updateBackNavigationFromActiveViews(this.drawerViewSwapper.getActiveViewNames()),this.onActiveViewsChanged=t=>{const s=t==null?void 0:t.detail;s!=null&&s.activeViews&&this.updateBackNavigationFromActiveViews(s.activeViews)},this.drawerViewSwapper.addEventListener("mealz-active-views-changed",this.onActiveViewsChanged))}updateBackNavigationFromActiveViews(e){const t=Array.isArray(e)&&e.length>1;this.hasBackNavigation!==t&&(this.hasBackNavigation=t,this.requestUpdate())}getRecipeDetailsCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/arrow-right.svg",alt:"back button",className:"mealz-recipe-details__close-icon is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_primary.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}getRecipeDetailsStickyCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/ArrowLeft_dark.svg",alt:"back button",className:"mealz-recipe-details__close-icon before-title is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_Black.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}setStickyObserver(){this.topObserver||this.updateComplete.then(()=>{const e=this.querySelector(".mealz-recipe-details__sticky-anchor");e&&(this.topObserver=new IntersectionObserver(([t])=>{this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.stickyTimeout=window.setTimeout(()=>{const s=!t.isIntersecting;this.isSticky!==s&&(this.isSticky=s,this.requestUpdate())},150)},{threshold:0}),this.topObserver.observe(e))})}startRecipeDetailsOnboardingIfNeeded(){localStorage.getItem("_miam/recipeDetailsOnboarding")==="true"||!this.plannerMode||this.updateComplete.then(()=>{this.scrollJustAfterImage();let t=document.querySelector("mealz-planner-onboarding");t?t.type="recipe-details":(t=new ue,t.type="recipe-details",document.body.appendChild(t)),t.launchOnboardingTour()})}scrollJustAfterImage(){const e=this.querySelector(".mealz-recipe-details__tabs");if(!e)return;const t=document.querySelector(".mealz-drawer__content-container");if(t){const s=e.getBoundingClientRect(),a=t.getBoundingClientRect();t.scrollTop+=s.top-a.top;return}e.scrollIntoView({behavior:"smooth",block:"start"})}handleNoSupplierMode(){this.noSupplier=!!o.supplier.isNoSupplier(),this.requestUpdate()}close(){this.sendCloseEvent(),o.recipes.displayedRecipe$.next(null)}listenToCloseEvent(){const e=document.querySelector("mealz-drawer");e&&e.addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}selectTab(e){this.activeTabIndex=e,this.activeTabIndex===1&&this.sendCookingDisplayEvent(),this.requestUpdate()}getLikeButton(){this.noSupplier||o.user.isAuthenticated().pipe(O(this.destroy$),Q(e=>e),Y(()=>o.html.like(this.recipe.id))).subscribe({next:e=>{this.likeButtonHTML=e,this.requestUpdate()},error:e=>console.error("Like button error:",e)})}checkSponsorStorytelling(){this.sponsor&&o.sponsor.hasStorytelling(this.sponsor.id).pipe(O(this.destroy$)).subscribe({next:e=>{this.hasSponsorStorytelling=e,this.requestUpdate()},error:e=>console.error("Sponsor storytelling error:",e)})}listenPosStatus(){return J({noPosDisplay:o.recipes.noPosDisplay$,invalidPosDisplay:o.recipes.invalidPosDisplay$}).pipe(z(({noPosDisplay:e,invalidPosDisplay:t})=>{this.noPosDisplay=e,this.invalidPosDisplay=t,this.activeTabIndex=e?1:0}),h(()=>{}))}listenLastOrderDate(){return o.recipes.orderHistoryDate$.pipe(z(e=>{this.orderHistoryDate=e}))}listenToLoadingStates(){return J([o.recipes.ingredientToBasketLoading$,o.recipes.updateIngredientFromBasketLoading$]).pipe(h(([e,t])=>e||t),z(e=>{this.basketIsUpdating=e}),be(1))}listenRemainingBasketEntries(){return o.recipes.remainingBasketEntries$.pipe(z(e=>{this.remainingBasketEntries=e}))}listenToAddAllToBasket(){return o.recipes.allIngredientsToBasketLoading$.pipe(z(e=>{e&&(this.selectTab(0),setTimeout(()=>{this.scrollToPicker()},50))}))}listenToRecipeInBasket(){return o.recipes.isRecipeInBasket(this.recipe.id).pipe(z(e=>{this.inBasket=e}))}scrollToPicker(){const e=this.querySelector(".mealz-products-picker");if(e){const t=this.querySelector(".mealz-recipe-details__title-container"),s=(t==null?void 0:t.offsetHeight)||0;e.style.scrollMarginTop=`${s}px`,e.scrollIntoView({behavior:"instant",block:"start"})}}scrollToReplacedItem(e){var s,a;const t=this.querySelectorAll("mealz-product-card-planner");for(const i of Array.from(t)){const n=i;if(((a=(s=n.product)==null?void 0:s.item)==null?void 0:a.id)===e){n.scrollIntoView({behavior:"instant",block:"center"});break}}}openLastOrderModal(){this.sendOrderedDisplayEvent();const e=new de;e.recipeId=this.recipe.id,e.addEventListener("orderAgain",()=>this.orderAgain()),e.displayLastOrderModal(this.orderHistoryDate)}orderAgain(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}})}updateGuests(e){if(this.recipe.modifiedGuests===e.detail.value)return;this.recipe.modifiedGuests=e.detail.value,this.guestObserverService.updateGuests(this.recipe.modifiedGuests);const t={originPath:this.analyticsPath,props:{}};this.plannerMode?o.planner.updateGuests(this.recipe.modifiedGuests,t):o.recipes.updateGuests(t),this.requestUpdate()}render(){const e=this.getRecipeDetailsCloseIcon(),t=this.getRecipeDetailsStickyCloseIcon();return r`
539
+ `}};V=Le([v("mealz-no-pos-selected")],V);customElements.get("mealz-no-pos-selected")||customElements.define("mealz-no-pos-selected",V);var Ue=Object.getOwnPropertyDescriptor,Ae=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ue(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let j=class extends g{constructor(){super(),this.activeTabIndex=0,this.destroy$=new B,this.remainingBasketEntries=[],this.guestObserverService=te.getInstance(),this.isSticky=!1,this.hasBackNavigation=!1,this.drawerViewSwapper=null,this.styleURL=new URL("./recipe-details/recipe-details.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.destroy$=new B,this.handleNoSupplierMode(),Z(o.recipes.displayedRecipe$.pipe(D(this.destroy$),Q(e=>!!e),z(e=>{e.recipe!==null&&(this.recipe=e.recipe,this.sponsor=e.recipe.relationships.sponsors.data[0],this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.plannerMode=!!e.planner,this.getLikeButton(),this.checkSponsorStorytelling(),this.pageview(),this.listenToCloseEvent(),this.setStickyObserver())}),Y(e=>e.recipe===null?[]:this.listenToRecipeInBasket())),this.listenPosStatus(),this.listenRemainingBasketEntries(),this.listenLastOrderDate(),this.listenToLoadingStates(),this.listenToAddAllToBasket()).pipe(D(this.destroy$)).subscribe({next:()=>this.requestUpdate(),error:e=>console.error("Recipe details error:",e)}),this.addEventListener("products-picker-ready",()=>this.startRecipeDetailsOnboardingIfNeeded()),this.setupDrawerBackNavigationIndicator()}disconnectedCallback(){super.disconnectedCallback(),this.destroy$.next(),this.destroy$.complete(),this.topObserver&&this.topObserver.disconnect(),this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.drawerViewSwapper&&this.onActiveViewsChanged&&this.drawerViewSwapper.removeEventListener("mealz-active-views-changed",this.onActiveViewsChanged)}setupDrawerBackNavigationIndicator(){const e=this.closest("mealz-drawer-view-swapper");this.drawerViewSwapper=e??document.querySelector("mealz-drawer-view-swapper"),this.drawerViewSwapper&&(this.updateBackNavigationFromActiveViews(this.drawerViewSwapper.getActiveViewNames()),this.onActiveViewsChanged=t=>{const s=t==null?void 0:t.detail;s!=null&&s.activeViews&&this.updateBackNavigationFromActiveViews(s.activeViews)},this.drawerViewSwapper.addEventListener("mealz-active-views-changed",this.onActiveViewsChanged))}updateBackNavigationFromActiveViews(e){const t=Array.isArray(e)&&e.length>1;this.hasBackNavigation!==t&&(this.hasBackNavigation=t,this.requestUpdate())}getRecipeDetailsCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/arrow-right.svg",alt:"back button",className:"mealz-recipe-details__close-icon is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_primary.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}getRecipeDetailsStickyCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/ArrowLeft_dark.svg",alt:"back button",className:"mealz-recipe-details__close-icon before-title is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_Black.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}setStickyObserver(){this.topObserver||this.updateComplete.then(()=>{const e=this.querySelector(".mealz-recipe-details__sticky-anchor");e&&(this.topObserver=new IntersectionObserver(([t])=>{this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.stickyTimeout=window.setTimeout(()=>{const s=!t.isIntersecting;this.isSticky!==s&&(this.isSticky=s,this.requestUpdate())},150)},{threshold:0}),this.topObserver.observe(e))})}startRecipeDetailsOnboardingIfNeeded(){localStorage.getItem("_miam/recipeDetailsOnboarding")==="true"||!this.plannerMode||this.updateComplete.then(()=>{this.scrollJustAfterImage();let t=document.querySelector("mealz-planner-onboarding");t?t.type="recipe-details":(t=new ue,t.type="recipe-details",document.body.appendChild(t)),t.launchOnboardingTour()})}scrollJustAfterImage(){const e=this.querySelector(".mealz-recipe-details__tabs");if(!e)return;const t=document.querySelector(".mealz-drawer__content-container");if(t){const s=e.getBoundingClientRect(),a=t.getBoundingClientRect();t.scrollTop+=s.top-a.top;return}e.scrollIntoView({behavior:"smooth",block:"start"})}handleNoSupplierMode(){this.noSupplier=!!o.supplier.isNoSupplier(),this.requestUpdate()}close(){this.sendCloseEvent(),o.recipes.displayedRecipe$.next(null)}listenToCloseEvent(){const e=document.querySelector("mealz-drawer");e&&e.addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}selectTab(e){this.activeTabIndex=e,this.activeTabIndex===1&&this.sendCookingDisplayEvent(),this.requestUpdate()}getLikeButton(){this.noSupplier||o.user.isAuthenticated().pipe(D(this.destroy$),Q(e=>e),Y(()=>o.html.like(this.recipe.id))).subscribe({next:e=>{this.likeButtonHTML=e,this.requestUpdate()},error:e=>console.error("Like button error:",e)})}checkSponsorStorytelling(){this.sponsor&&o.sponsor.hasStorytelling(this.sponsor.id).pipe(D(this.destroy$)).subscribe({next:e=>{this.hasSponsorStorytelling=e,this.requestUpdate()},error:e=>console.error("Sponsor storytelling error:",e)})}listenPosStatus(){return J({noPosDisplay:o.recipes.noPosDisplay$,invalidPosDisplay:o.recipes.invalidPosDisplay$}).pipe(z(({noPosDisplay:e,invalidPosDisplay:t})=>{this.noPosDisplay=e,this.invalidPosDisplay=t,this.activeTabIndex=e?1:0}),m(()=>{}))}listenLastOrderDate(){return o.recipes.orderHistoryDate$.pipe(z(e=>{this.orderHistoryDate=e}))}listenToLoadingStates(){return J([o.recipes.ingredientToBasketLoading$,o.recipes.updateIngredientFromBasketLoading$]).pipe(m(([e,t])=>e||t),z(e=>{this.basketIsUpdating=e}),be(1))}listenRemainingBasketEntries(){return o.recipes.remainingBasketEntries$.pipe(z(e=>{this.remainingBasketEntries=e}))}listenToAddAllToBasket(){return o.recipes.allIngredientsToBasketLoading$.pipe(z(e=>{e&&(this.selectTab(0),setTimeout(()=>{this.scrollToPicker()},50))}))}listenToRecipeInBasket(){return o.recipes.isRecipeInBasket(this.recipe.id).pipe(z(e=>{this.inBasket=e}))}scrollToPicker(){const e=this.querySelector(".mealz-products-picker");if(e){const t=this.querySelector(".mealz-recipe-details__title-container"),s=(t==null?void 0:t.offsetHeight)||0;e.style.scrollMarginTop=`${s}px`,e.scrollIntoView({behavior:"instant",block:"start"})}}scrollToReplacedItem(e){var s,a;const t=this.querySelectorAll("mealz-product-card-planner");for(const i of Array.from(t)){const n=i;if(((a=(s=n.product)==null?void 0:s.item)==null?void 0:a.id)===e){n.scrollIntoView({behavior:"instant",block:"center"});break}}}openLastOrderModal(){this.sendOrderedDisplayEvent();const e=new de;e.recipeId=this.recipe.id,e.addEventListener("orderAgain",()=>this.orderAgain()),e.displayLastOrderModal(this.orderHistoryDate)}orderAgain(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}})}updateGuests(e){if(this.recipe.modifiedGuests===e.detail.value)return;this.recipe.modifiedGuests=e.detail.value,this.guestObserverService.updateGuests(this.recipe.modifiedGuests);const t={originPath:this.analyticsPath,props:{}};this.plannerMode?o.planner.updateGuests(this.recipe.modifiedGuests,t):o.recipes.updateGuests(t),this.requestUpdate()}render(){const e=this.getRecipeDetailsCloseIcon(),t=this.getRecipeDetailsStickyCloseIcon();return r`
540
540
  <div class="mealz-recipe-details">
541
541
  <!-- IF IS LOADING -->
542
542
  ${this.recipe?c:r`
@@ -704,4 +704,4 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
704
704
  </div>
705
705
  `:c}
706
706
  </div>
707
- `}showRecipeAddon(){this.sendSponsorDisplayEvent();const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!0)}pageview(){o.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){o.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){o.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){o.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){o.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};j=Ae([g("mealz-recipe-details")],j);customElements.get("mealz-recipe-details")||customElements.define("mealz-recipe-details",j);
707
+ `}showRecipeAddon(){this.sendSponsorDisplayEvent();const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!0)}pageview(){o.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){o.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){o.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){o.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){o.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};j=Ae([v("mealz-recipe-details")],j);customElements.get("mealz-recipe-details")||customElements.define("mealz-recipe-details",j);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mealz-components",
3
3
  "type": "module",
4
- "version": "2.4.2",
4
+ "version": "2.5.0",
5
5
  "main": "./dist/mealz-components.js",
6
6
  "module": "./dist/mealz-components.js",
7
7
  "scripts": {