mealz-components 2.0.0-beta.3 → 2.0.0-beta.5
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.
- package/dist/add-to-cart-cta/add-to-cart-cta.min.js +1 -1
- package/dist/assets/{OperatorSubscriber-C_ZC-4p2.js → OperatorSubscriber-EGuECN6g.js} +1 -1
- package/dist/assets/{async-Cf5pIG6K.js → async-D3oCs_PQ.js} +1 -1
- package/dist/assets/{combineLatest-ZcJd71-W.js → combineLatest-P4GAEtOW.js} +1 -1
- package/dist/assets/{debounceTime-Dqha8z_N.js → debounceTime-Bo5F3ux-.js} +1 -1
- package/dist/assets/delay-ILvLVH1b.js +1 -0
- package/dist/assets/{distinctUntilChanged-C5xhZT8-.js → distinctUntilChanged-BkBiB4M3.js} +1 -1
- package/dist/assets/empty-Cv-4tfKR.js +1 -0
- package/dist/assets/{executeSchedule-BoZ8McHf.js → executeSchedule-DfyZaGAH.js} +1 -1
- package/dist/assets/{filter-CCrCJ0Ez.js → filter-CEeE8t7I.js} +1 -1
- package/dist/assets/{from-BJlgdPzK.js → from-jBe2xW5a.js} +1 -1
- package/dist/assets/{http-_HLok9_q.js → http-aOzufNsj.js} +1 -1
- package/dist/assets/{innerFrom-cJ8wLVnp.js → innerFrom-CfKCbnvr.js} +1 -1
- package/dist/assets/{map-CtoF0MFx.js → map-C4rf5Jbc.js} +1 -1
- package/dist/assets/mapOneOrManyArgs-DNd_tswl.js +1 -0
- package/dist/assets/merge-C-u9uFzU.js +1 -0
- package/dist/assets/{mergeMap-DkeMJrVP.js → mergeMap-buGewtOo.js} +1 -1
- package/dist/assets/{no-shadow-element-Dckeu5Ol.js → no-shadow-element-l9trQfcI.js} +1 -1
- package/dist/assets/{of-CGDeMeoh.js → of-BTA69Qgj.js} +1 -1
- package/dist/assets/{price-3QEU2vDV.js → price-BoM226Kw.js} +1 -1
- package/dist/assets/{product-card-l5_dRD-J.js → product-card-DqcKyf1c.js} +5 -5
- package/dist/assets/promotion-badge-BwN2GpDz.js +12 -0
- package/dist/assets/{property-B_Up5EGr.js → property-leIVgCvV.js} +1 -1
- package/dist/assets/session-handler-BnuvphmJ.js +1 -0
- package/dist/assets/{skipWhile-BpCW6MT3.js → skipWhile-DuMEda_n.js} +1 -1
- package/dist/assets/{state-Dg5rn9XH.js → state-CccUMzBZ.js} +1 -1
- package/dist/assets/{store-locator-DdG34z7_.js → store-locator-m8sx3XDc.js} +1 -1
- package/dist/assets/{switchMap-_eqjHrlq.js → switchMap-D8q0hRYH.js} +1 -1
- package/dist/assets/{take-C-_8_Rq7.js → take-DO4w5a1Y.js} +1 -1
- package/dist/assets/{tap-C7Bbgrv8.js → tap-BCGrRktL.js} +1 -1
- package/dist/assets/{timer-FQ7WMtFD.js → timer-BOl4bYNY.js} +1 -1
- package/dist/assets/{unsafe-html-ZfqpUwaC.js → unsafe-html-CmALAWuN.js} +1 -1
- package/dist/assets/{viewport-listener-VXtYxJHH.js → viewport-listener-RTCBatPv.js} +1 -1
- package/dist/basket-transfer-modal/basket-transfer-modal.min.js +1 -1
- package/dist/catalog/basket-preview/basket-preview.min.js +9 -9
- package/dist/catalog/catalog-category/catalog-category.min.js +1 -1
- package/dist/catalog/catalog-favorites/catalog-favorites.min.js +1 -1
- package/dist/catalog/catalog-history/catalog-history.min.js +1 -1
- package/dist/catalog/catalog-home/catalog-home.min.js +1 -1
- package/dist/catalog/catalog-list/catalog-list.min.js +1 -1
- package/dist/catalog/catalog-load-more.min.js +1 -1
- package/dist/catalog/catalog-tabs/catalog-tabs.min.js +1 -1
- package/dist/catalog/catalog-toolbar/catalog-toolbar.min.js +1 -1
- package/dist/catalog/my-meals-button/my-meals-button.min.js +1 -1
- package/dist/counter/counter.min.js +2 -2
- package/dist/drawer/drawer.min.js +1 -1
- package/dist/drawer-view-swapper/drawer-view-swapper.min.js +4 -4
- package/dist/history-drawer/history-drawer.min.js +1 -1
- package/dist/history-order/history-order.min.js +1 -1
- package/dist/history-order-expanded/history-order-expanded.min.js +1 -1
- package/dist/last-order-badge/last-order-badge.min.js +2 -2
- package/dist/last-order-modal/last-order-modal.min.js +1 -1
- package/dist/like-button/like-button.min.js +1 -1
- package/dist/modal/modal.min.js +1 -1
- package/dist/order-again/order-again.min.js +1 -1
- package/dist/planner/planner-abandon-modal/planner-abandon-modal.min.js +2 -2
- package/dist/planner/planner-budget-gauge/planner-budget-gauge.min.js +1 -1
- package/dist/planner/planner-catalog/planner-catalog.min.js +1 -1
- package/dist/planner/planner-current-menu/planner-current-menu.min.js +1 -1
- package/dist/planner/planner-current-menu-modal/planner-current-menu-modal.min.js +1 -1
- package/dist/planner/planner-dashboard/planner-dashboard.min.js +1 -1
- package/dist/planner/planner-form/planner-form.min.js +1 -1
- package/dist/planner/planner-menu-option/planner-menu-option.min.js +1 -1
- package/dist/planner/planner-open-catalog-modal/planner-open-catalog-modal.min.js +1 -1
- package/dist/planner/planner-recipe-card/planner-recipe-card.min.js +1 -1
- package/dist/planner/planner-recipe-list/planner-recipe-list.css +1 -1
- package/dist/planner/planner-recipe-list/planner-recipe-list.min.js +1 -1
- package/dist/planner/planner-recipe-suggestion/planner-recipe-suggestion.css +1 -1
- package/dist/planner/planner-recipe-suggestion/planner-recipe-suggestion.min.js +1 -1
- package/dist/planner/to-basket-loader/to-basket-loader.min.js +5 -5
- package/dist/preferences/preferences.min.js +4 -4
- package/dist/price/price.min.js +3 -3
- package/dist/recipe-card/recipe-card.min.js +1 -1
- package/dist/recipe-card-cta/recipe-card-cta.min.js +1 -1
- package/dist/recipe-details/recipe-details.min.js +11 -11
- package/dist/recipe-pricing/recipe-pricing.min.js +1 -1
- package/dist/replace-item/replace-item-card/replace-item-card.min.js +1 -1
- package/dist/replace-item/replace-item.min.js +1 -1
- package/dist/replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js +1 -1
- package/dist/replace-item-planner/replace-item-planner.min.js +2 -2
- package/dist/slider-tabs/slider-tabs.min.js +1 -1
- package/dist/store-indicator/store-indicator.min.js +2 -2
- package/dist/store-locator-drawer/store-locator-drawer.min.js +4 -4
- package/package.json +1 -1
- package/dist/assets/delay-DY9ohHpd.js +0 -1
- package/dist/assets/empty-DzB-G1O3.js +0 -1
- package/dist/assets/mapOneOrManyArgs-BgYvpJCA.js +0 -1
- package/dist/assets/merge-CfUUBPqp.js +0 -1
- package/dist/assets/promotion-badge-CErkYPs5.js +0 -12
- package/dist/assets/session-handler-BjExGUaE.js +0 -1
- package/dist/product-card-skeleton.css +0 -44
- package/dist/product-card.css +0 -208
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as h,v as m,S as f,m as p}from"../../assets/no-shadow-element-Dckeu5Ol.js";import{R as S}from"../../assets/recipe-BwGs-blm.js";import{t as R}from"../../assets/custom-element-BhZVzxrc.js";import{d as v}from"../../assets/debounceTime-Dqha8z_N.js";import{o as L}from"../../assets/of-CGDeMeoh.js";import{t as d}from"../../assets/take-C-_8_Rq7.js";import{t as C}from"../../assets/tap-C7Bbgrv8.js";import"../../assets/async-Cf5pIG6K.js";import"../../assets/OperatorSubscriber-C_ZC-4p2.js";import"../../assets/from-BJlgdPzK.js";import"../../assets/executeSchedule-BoZ8McHf.js";import"../../assets/innerFrom-cJ8wLVnp.js";import"../../assets/empty-DzB-G1O3.js";var B=Object.getOwnPropertyDescriptor,b=(e,t,s,i)=>{for(var n=i>1?void 0:i?B(t,s):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(n=r(n)||n);return n};let g=class extends h{constructor(){super(...arguments),this.recipeId="",this.isDragging=!1,this.dragStartX=0,this.initialScrollLeft=0,this.layoutObserver=null,this.menuRecipes=[],this.suggestedRecipes=[],this.buttonClickHandlers=new Map,this.swapRecipeCount=0,this.swapRecipeClick$=new m,this.analyticsPath="/meals-planner/current",this.preferencesSubscription=new f}get selectors(){return{buttonsContainer:".mealz-planner-recipe-suggestion__meals-count",title:".mealz-planner-current-menu__recipe-title",removeButtons:".mealz-planner-recipe-suggestion__actions-remove",removeButton:".mealz-planner-recipe-suggestion__actions-remove-button",swapButton:".mealz-planner-recipe-suggestion__actions-swap-button",addButton:".mealz-planner-recipe-suggestion__actions-add-button",seeRecipe:".mealz-planner-recipe-suggestion__see-recipe",promotion:".mealz-planner-recipe-suggestion__recipe-badges-promotion",sponsor:".mealz-planner-recipe-suggestion__recipe-sponsor",addAndSwapButtons:".mealz-planner-recipe-suggestion__actions-add-and-swap",buttons:[".mealz-planner-recipe-suggestion__meals-count-button"],activeButton:".mealz-planner-recipe-suggestion__meals-count-button.primary",pictureContainer:".mealz-planner-recipe-suggestion__picture",picture:".mealz-planner-recipe-suggestion__picture img",sponsorImg:".mealz-planner-recipe-suggestion__recipe-sponsor img"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.addEventListeners(),this.swapRecipeClick$.pipe(v(300)).subscribe(()=>this.swapRecipe()),this.subscribeToPreferencesChanges()}disconnectedCallback(){super.disconnectedCallback(),this.layoutObserver&&this.layoutObserver.disconnect(),this.swapRecipeClick$.complete(),this.preferencesSubscription.unsubscribe()}render(){const{buttonsContainer:e,buttons:t}=this.elements;!e||!t.length||this.mealsCountButtonsListener(t)}firstUpdated(){var i,n;const{buttonsContainer:e,buttons:t}=this.elements;if(!e||!t.length)return;this.initScrolling(e,t),this.initDragScrolling(e);const s=(i=this.attributes["starting-data"])==null?void 0:i.value;s&&(Object.assign(this,JSON.parse(s)),this.recipeId=(n=this.recipeDisplayed)==null?void 0:n.id,t.length===1&&this.recipeId&&this.suggestionShownEvent(),this.removeAttribute("starting-data"))}addEventListeners(){this.addClickListener("removeButton",()=>this.removeRecipe().subscribe()),this.addClickListener("swapButton",()=>this.swapRecipeClick$.next()),this.addClickListener("addButton",()=>this.addRecipe()),this.addClickListener("title",()=>this.openRecipeDetails()),this.addClickListener("seeRecipe",()=>this.openRecipeDetails()),this.addClickListener("pictureContainer",()=>this.openRecipeDetails())}mealsCountButtonsListener(e){e.forEach((t,s)=>{const i=this.buttonClickHandlers.get(t);i&&t.removeEventListener("click",i);const n=()=>this.handleRecipeSelect(e,t,s);this.buttonClickHandlers.set(t,n),t.addEventListener("click",n)})}handleRecipeSelect(e,t,s){e.forEach(i=>i.classList.remove("primary")),t.classList.add("primary"),this.updateDisplayedRecipe(!1,s),s+1===e.length&&this.suggestionShownEvent(),this.scrollToButton(t)}updateDisplayedRecipe(e=!1,t){const{title:s,promotion:i,sponsor:n,addAndSwapButtons:o,removeButtons:r,picture:c,sponsorImg:l}=this.elements;if(!c||!s||!i||!n||!l||!o||!r)return;const a=this.getRecipeToDisplay(e,t);if(!a)return;const u=new S;Object.assign(u,a),this.recipeId=a.id,this.initializeUIState(c,i,n),this.setupImageHandlers(c,l,n,u,s,i,o,r,t)}getRecipeToDisplay(e,t){return e?this.suggestedRecipes[0]:this.menuRecipes[t]||this.suggestedRecipes[0]}initializeUIState(e,t,s){e.classList.add("loading"),t.classList.add("hidden"),s.classList.add("hidden")}setupImageHandlers(e,t,s,i,n,o,r,c,l){let a=null;const u=()=>{a&&(clearTimeout(a),a=null),this.updateRecipeUI(e,s,n,o,r,c,i,l)};if(e.onload=u,e.onerror=u,i.attributes["media-url"])e.src=i.attributes["media-url"];else{u();return}i.sponsorLogoUrl&&(t.src=i.sponsorLogoUrl),a=window.setTimeout(u,1e3)}updateRecipeUI(e,t,s,i,n,o,r,c){e.classList.remove("loading"),r.sponsorLogoUrl&&t.classList.remove("hidden"),s.textContent=r.attributes.title||"",i.classList.toggle("hidden",!r.discounted);const l=!!this.menuRecipes[c];n.classList.toggle("hidden",l),o.classList.toggle("hidden",!l)}addRecipe(){this.toggleLoadingButton(!0);const e=document.querySelector("mealz-planner-current-menu");if(!e){this.toggleLoadingButton(!1);return}e.addRecipe(this.recipeId,this.guests).subscribe({next:()=>{this.addAndSelectNewSuggestion(),this.toggleLoadingButton(!1)},error:()=>{this.toggleLoadingButton(!1)}})}toggleLoadingButton(e){const t=this.selectors.addButton,s=this.querySelector(t);s&&s.classList.toggle("loading",e)}addAndSelectNewSuggestion(e){!e||this.suggestedRecipes[0].id===e.id?(this.menuRecipes.push(this.suggestedRecipes[0]),this.removeSuggestedRecipe()):this.menuRecipes.push(e),this.addNewMealCountButton(),this.selectNewSuggestion(),this.addCheckIconToButton(),this.requestUpdate()}addNewMealCountButton(){var n;const{buttons:e}=this.elements;if(!e.length)return;const t=e[e.length-1],s=t.cloneNode(!0);s.classList.remove("primary");const i=s.querySelector("span");if(i){const o=(n=i.textContent)==null?void 0:n.match(/\d+/);if(o){const r=parseInt(o[0],10)+1;i.textContent=i.textContent.replace(/\d+/,r.toString())}}t.after(s)}selectNewSuggestion(){this.initSelectors("buttons");const{buttons:e}=this.elements;if(!e.length)return;const t=e[e.length-1];this.handleRecipeSelect(e,t,e.length-1)}addCheckIconToButton(){this.initSelectors("buttons");const{buttons:e}=this.elements;if(!e.length)return;const t=e[e.length-2],s=document.createElement("img");s.src="https://storage.googleapis.com/assets.miam.tech/generic/icons/Check.svg",s.alt="check icon",t.appendChild(s)}removeRecipe(e){const t=e||this.recipeId,s=document.querySelector("mealz-planner-current-menu");return!s||!t?L():s.removeRecipe(t).pipe(d(1),C(()=>{const i=this.menuRecipes.findIndex(n=>n.id===t);i!==-1&&(this.removeRecipeFromMenu(i),this.removeButtonFromContainer(i),this.updateButtonsCount())}))}removeButtonFromContainer(e){const{buttonsContainer:t,buttons:s}=this.elements;if(!t||!s.length)return;const i=s[e];if(i.classList.contains("primary")){const n=+e+1,o=s[n];this.handleRecipeSelect(s,o,e)}i.remove()}removeRecipeFromMenu(e){this.menuRecipes.splice(e,1)}updateButtonsCount(){this.initSelectors("buttons");const{buttons:e}=this.elements;e.forEach((t,s)=>{var n;const i=t.querySelector("span");if(i&&((n=i.textContent)==null?void 0:n.match(/\d+/))){const r=s+1;i.textContent=i.textContent.replace(/\d+/,r.toString())}}),this.requestUpdate()}swapRecipe(){p.planner.rejectRecipe(this.recipeId).pipe(d(1)).subscribe(),this.recipeSwappedEvent(),this.swapRecipeCount++,!sessionStorage.getItem("_miam/selectFromCatalogSuggestion")&&this.swapRecipeCount>3&&(sessionStorage.setItem("_miam/selectFromCatalogSuggestion","true"),this.openCatalogModal()),this.removeSuggestedRecipe(),this.updateDisplayedRecipe(!0)}removeSuggestedRecipe(){this.suggestedRecipes.shift(),this.suggestedRecipes.length<3&&p.planner.getSuggestedRecipes().pipe(d(1)).subscribe(e=>{this.suggestedRecipes=[...this.suggestedRecipes,...e]})}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)}initScrolling(e,t){t.length>0&&t[0].offsetWidth>0?this.centerActiveButton(e,t):this.waitForButtonLayout(e,t)}centerActiveButton(e,t){this.initSelectors("activeButton");const{activeButton:s}=this.elements;this.setPadding(e,t),s&&this.scrollToButton(s,"instant")}waitForButtonLayout(e,t){const s=new ResizeObserver(()=>{t.length>0&&t[0].offsetWidth>0&&(this.centerActiveButton(e,t),s.disconnect())});t.forEach(i=>s.observe(i))}initDragScrolling(e){e.addEventListener("mousedown",t=>this.startDrag(t,e)),e.addEventListener("mouseleave",()=>this.stopDrag()),e.addEventListener("mouseup",()=>this.stopDrag()),e.addEventListener("mousemove",t=>this.onDrag(t,e))}refreshSuggestions(){p.planner.getSuggestedRecipes().pipe(d(1)).subscribe(e=>{var n;this.suggestedRecipes=e,this.initSelectors("buttons","activeButton");const{buttons:t,activeButton:s}=this.elements;if(!!(t!=null&&t.length)&&s===t[t.length-1]&&this.suggestedRecipes.length>0){const o=this.suggestedRecipes[0];((n=this.recipeDisplayed)==null?void 0:n.id)!==o.id&&(this.recipeDisplayed=o,this.updateDisplayedRecipe(!0),this.requestUpdate())}})}subscribeToPreferencesChanges(){this.preferencesSubscription.add(p.preferences.preferencesChanged$().subscribe(()=>this.refreshSuggestions()))}setPadding(e,t){const s=t[0].offsetWidth,i=t[t.length-1].offsetWidth;e.style.paddingLeft=`calc(50% - ${s/2}px)`,e.style.paddingRight=`calc(50% - ${i/2}px)`}scrollToButton(e,t="smooth"){if(!e||!e.parentElement)return;const s=e.parentElement,n=Array.from(this.elements.buttons).indexOf(e);if(n===-1)return;const o=window.getComputedStyle(s),r=parseFloat(o.paddingLeft||"0"),c=window.getComputedStyle(e),l=parseFloat(c.marginRight||"0");let a=e.offsetLeft-r;a+=l*n,s.scrollTo({left:a,behavior:t})}startDrag(e,t){this.isDragging=!0,this.dragStartX=e.pageX-t.offsetLeft,this.initialScrollLeft=t.scrollLeft}stopDrag(){this.isDragging=!1}onDrag(e,t){if(!this.isDragging)return;e.preventDefault();const s=e.pageX-t.offsetLeft;t.scrollLeft=this.initialScrollLeft-(s-this.dragStartX)}recipeSwappedEvent(){p.analytics.sendEvent("planner.recipe.swap",this.analyticsPath,{recipe_id:this.recipeId})}promptCatalogEvent(){p.analytics.sendEvent("planner.recipe.catalog-prompt",this.analyticsPath,{})}suggestionShownEvent(){p.analytics.sendEvent("planner.suggestion.show",this.analyticsPath,{recipe_id:this.recipeId})}};g=b([R("mealz-planner-recipe-suggestion")],g);
|
|
1
|
+
import{N as h,v as m,S as f,m as p}from"../../assets/no-shadow-element-l9trQfcI.js";import{R as S}from"../../assets/recipe-BwGs-blm.js";import{t as R}from"../../assets/custom-element-BhZVzxrc.js";import{d as v}from"../../assets/debounceTime-Bo5F3ux-.js";import{o as L}from"../../assets/of-BTA69Qgj.js";import{t as d}from"../../assets/take-DO4w5a1Y.js";import{t as C}from"../../assets/tap-BCGrRktL.js";import"../../assets/async-D3oCs_PQ.js";import"../../assets/OperatorSubscriber-EGuECN6g.js";import"../../assets/from-jBe2xW5a.js";import"../../assets/executeSchedule-DfyZaGAH.js";import"../../assets/innerFrom-CfKCbnvr.js";import"../../assets/empty-Cv-4tfKR.js";var B=Object.getOwnPropertyDescriptor,b=(e,t,s,i)=>{for(var n=i>1?void 0:i?B(t,s):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(n=r(n)||n);return n};let g=class extends h{constructor(){super(...arguments),this.recipeId="",this.isDragging=!1,this.dragStartX=0,this.initialScrollLeft=0,this.layoutObserver=null,this.menuRecipes=[],this.suggestedRecipes=[],this.buttonClickHandlers=new Map,this.swapRecipeCount=0,this.swapRecipeClick$=new m,this.analyticsPath="/meals-planner/current",this.preferencesSubscription=new f}get selectors(){return{buttonsContainer:".mealz-planner-recipe-suggestion__meals-count",title:".mealz-planner-current-menu__recipe-title",removeButtons:".mealz-planner-recipe-suggestion__actions-remove",removeButton:".mealz-planner-recipe-suggestion__actions-remove-button",swapButton:".mealz-planner-recipe-suggestion__actions-swap-button",addButton:".mealz-planner-recipe-suggestion__actions-add-button",seeRecipe:".mealz-planner-recipe-suggestion__see-recipe",promotion:".mealz-planner-recipe-suggestion__recipe-badges-promotion",sponsor:".mealz-planner-recipe-suggestion__recipe-sponsor",addAndSwapButtons:".mealz-planner-recipe-suggestion__actions-add-and-swap",buttons:[".mealz-planner-recipe-suggestion__meals-count-button"],activeButton:".mealz-planner-recipe-suggestion__meals-count-button.primary",pictureContainer:".mealz-planner-recipe-suggestion__picture",picture:".mealz-planner-recipe-suggestion__picture img",sponsorImg:".mealz-planner-recipe-suggestion__recipe-sponsor img"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.addEventListeners(),this.swapRecipeClick$.pipe(v(300)).subscribe(()=>this.swapRecipe()),this.subscribeToPreferencesChanges()}disconnectedCallback(){super.disconnectedCallback(),this.layoutObserver&&this.layoutObserver.disconnect(),this.swapRecipeClick$.complete(),this.preferencesSubscription.unsubscribe()}render(){const{buttonsContainer:e,buttons:t}=this.elements;!e||!t.length||this.mealsCountButtonsListener(t)}firstUpdated(){var i,n;const{buttonsContainer:e,buttons:t}=this.elements;if(!e||!t.length)return;this.initScrolling(e,t),this.initDragScrolling(e);const s=(i=this.attributes["starting-data"])==null?void 0:i.value;s&&(Object.assign(this,JSON.parse(s)),this.recipeId=(n=this.recipeDisplayed)==null?void 0:n.id,t.length===1&&this.recipeId&&this.suggestionShownEvent(),this.removeAttribute("starting-data"))}addEventListeners(){this.addClickListener("removeButton",()=>this.removeRecipe().subscribe()),this.addClickListener("swapButton",()=>this.swapRecipeClick$.next()),this.addClickListener("addButton",()=>this.addRecipe()),this.addClickListener("title",()=>this.openRecipeDetails()),this.addClickListener("seeRecipe",()=>this.openRecipeDetails()),this.addClickListener("pictureContainer",()=>this.openRecipeDetails())}mealsCountButtonsListener(e){e.forEach((t,s)=>{const i=this.buttonClickHandlers.get(t);i&&t.removeEventListener("click",i);const n=()=>this.handleRecipeSelect(e,t,s);this.buttonClickHandlers.set(t,n),t.addEventListener("click",n)})}handleRecipeSelect(e,t,s){e.forEach(i=>i.classList.remove("primary")),t.classList.add("primary"),this.updateDisplayedRecipe(!1,s),s+1===e.length&&this.suggestionShownEvent(),this.scrollToButton(t)}updateDisplayedRecipe(e=!1,t){const{title:s,promotion:i,sponsor:n,addAndSwapButtons:o,removeButtons:r,picture:c,sponsorImg:l}=this.elements;if(!c||!s||!i||!n||!l||!o||!r)return;const a=this.getRecipeToDisplay(e,t);if(!a)return;const u=new S;Object.assign(u,a),this.recipeId=a.id,this.initializeUIState(c,i,n),this.setupImageHandlers(c,l,n,u,s,i,o,r,t)}getRecipeToDisplay(e,t){return e?this.suggestedRecipes[0]:this.menuRecipes[t]||this.suggestedRecipes[0]}initializeUIState(e,t,s){e.classList.add("loading"),t.classList.add("hidden"),s.classList.add("hidden")}setupImageHandlers(e,t,s,i,n,o,r,c,l){let a=null;const u=()=>{a&&(clearTimeout(a),a=null),this.updateRecipeUI(e,s,n,o,r,c,i,l)};if(e.onload=u,e.onerror=u,i.attributes["media-url"])e.src=i.attributes["media-url"];else{u();return}i.sponsorLogoUrl&&(t.src=i.sponsorLogoUrl),a=window.setTimeout(u,1e3)}updateRecipeUI(e,t,s,i,n,o,r,c){e.classList.remove("loading"),r.sponsorLogoUrl&&t.classList.remove("hidden"),s.textContent=r.attributes.title||"",i.classList.toggle("hidden",!r.discounted);const l=!!this.menuRecipes[c];n.classList.toggle("hidden",l),o.classList.toggle("hidden",!l)}addRecipe(){this.toggleLoadingButton(!0);const e=document.querySelector("mealz-planner-current-menu");if(!e){this.toggleLoadingButton(!1);return}e.addRecipe(this.recipeId,this.guests).subscribe({next:()=>{this.addAndSelectNewSuggestion(),this.toggleLoadingButton(!1)},error:()=>{this.toggleLoadingButton(!1)}})}toggleLoadingButton(e){const t=this.selectors.addButton,s=this.querySelector(t);s&&s.classList.toggle("loading",e)}addAndSelectNewSuggestion(e){!e||this.suggestedRecipes[0].id===e.id?(this.menuRecipes.push(this.suggestedRecipes[0]),this.removeSuggestedRecipe()):this.menuRecipes.push(e),this.addNewMealCountButton(),this.selectNewSuggestion(),this.addCheckIconToButton(),this.requestUpdate()}addNewMealCountButton(){var n;const{buttons:e}=this.elements;if(!e.length)return;const t=e[e.length-1],s=t.cloneNode(!0);s.classList.remove("primary");const i=s.querySelector("span");if(i){const o=(n=i.textContent)==null?void 0:n.match(/\d+/);if(o){const r=parseInt(o[0],10)+1;i.textContent=i.textContent.replace(/\d+/,r.toString())}}t.after(s)}selectNewSuggestion(){this.initSelectors("buttons");const{buttons:e}=this.elements;if(!e.length)return;const t=e[e.length-1];this.handleRecipeSelect(e,t,e.length-1)}addCheckIconToButton(){this.initSelectors("buttons");const{buttons:e}=this.elements;if(!e.length)return;const t=e[e.length-2],s=document.createElement("img");s.src="https://storage.googleapis.com/assets.miam.tech/generic/icons/Check.svg",s.alt="check icon",t.appendChild(s)}removeRecipe(e){const t=e||this.recipeId,s=document.querySelector("mealz-planner-current-menu");return!s||!t?L():s.removeRecipe(t).pipe(d(1),C(()=>{const i=this.menuRecipes.findIndex(n=>n.id===t);i!==-1&&(this.removeRecipeFromMenu(i),this.removeButtonFromContainer(i),this.updateButtonsCount())}))}removeButtonFromContainer(e){const{buttonsContainer:t,buttons:s}=this.elements;if(!t||!s.length)return;const i=s[e];if(i.classList.contains("primary")){const n=+e+1,o=s[n];this.handleRecipeSelect(s,o,e)}i.remove()}removeRecipeFromMenu(e){this.menuRecipes.splice(e,1)}updateButtonsCount(){this.initSelectors("buttons");const{buttons:e}=this.elements;e.forEach((t,s)=>{var n;const i=t.querySelector("span");if(i&&((n=i.textContent)==null?void 0:n.match(/\d+/))){const r=s+1;i.textContent=i.textContent.replace(/\d+/,r.toString())}}),this.requestUpdate()}swapRecipe(){p.planner.rejectRecipe(this.recipeId).pipe(d(1)).subscribe(),this.recipeSwappedEvent(),this.swapRecipeCount++,!sessionStorage.getItem("_miam/selectFromCatalogSuggestion")&&this.swapRecipeCount>3&&(sessionStorage.setItem("_miam/selectFromCatalogSuggestion","true"),this.openCatalogModal()),this.removeSuggestedRecipe(),this.updateDisplayedRecipe(!0)}removeSuggestedRecipe(){this.suggestedRecipes.shift(),this.suggestedRecipes.length<3&&p.planner.getSuggestedRecipes().pipe(d(1)).subscribe(e=>{this.suggestedRecipes=[...this.suggestedRecipes,...e]})}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)}initScrolling(e,t){t.length>0&&t[0].offsetWidth>0?this.centerActiveButton(e,t):this.waitForButtonLayout(e,t)}centerActiveButton(e,t){this.initSelectors("activeButton");const{activeButton:s}=this.elements;this.setPadding(e,t),s&&this.scrollToButton(s,"instant")}waitForButtonLayout(e,t){const s=new ResizeObserver(()=>{t.length>0&&t[0].offsetWidth>0&&(this.centerActiveButton(e,t),s.disconnect())});t.forEach(i=>s.observe(i))}initDragScrolling(e){e.addEventListener("mousedown",t=>this.startDrag(t,e)),e.addEventListener("mouseleave",()=>this.stopDrag()),e.addEventListener("mouseup",()=>this.stopDrag()),e.addEventListener("mousemove",t=>this.onDrag(t,e))}refreshSuggestions(){p.planner.getSuggestedRecipes().pipe(d(1)).subscribe(e=>{var n;this.suggestedRecipes=e,this.initSelectors("buttons","activeButton");const{buttons:t,activeButton:s}=this.elements;if(!!(t!=null&&t.length)&&s===t[t.length-1]&&this.suggestedRecipes.length>0){const o=this.suggestedRecipes[0];((n=this.recipeDisplayed)==null?void 0:n.id)!==o.id&&(this.recipeDisplayed=o,this.updateDisplayedRecipe(!0),this.requestUpdate())}})}subscribeToPreferencesChanges(){this.preferencesSubscription.add(p.preferences.preferencesChanged$().subscribe(()=>this.refreshSuggestions()))}setPadding(e,t){const s=t[0].offsetWidth,i=t[t.length-1].offsetWidth;e.style.paddingLeft=`calc(50% - ${s/2}px)`,e.style.paddingRight=`calc(50% - ${i/2}px)`}scrollToButton(e,t="smooth"){if(!e||!e.parentElement)return;const s=e.parentElement,n=Array.from(this.elements.buttons).indexOf(e);if(n===-1)return;const o=window.getComputedStyle(s),r=parseFloat(o.paddingLeft||"0"),c=window.getComputedStyle(e),l=parseFloat(c.marginRight||"0");let a=e.offsetLeft-r;a+=l*n,s.scrollTo({left:a,behavior:t})}startDrag(e,t){this.isDragging=!0,this.dragStartX=e.pageX-t.offsetLeft,this.initialScrollLeft=t.scrollLeft}stopDrag(){this.isDragging=!1}onDrag(e,t){if(!this.isDragging)return;e.preventDefault();const s=e.pageX-t.offsetLeft;t.scrollLeft=this.initialScrollLeft-(s-this.dragStartX)}recipeSwappedEvent(){p.analytics.sendEvent("planner.recipe.swap",this.analyticsPath,{recipe_id:this.recipeId})}promptCatalogEvent(){p.analytics.sendEvent("planner.recipe.catalog-prompt",this.analyticsPath,{})}suggestionShownEvent(){p.analytics.sendEvent("planner.suggestion.show",this.analyticsPath,{recipe_id:this.recipeId})}};g=b([R("mealz-planner-recipe-suggestion")],g);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{N as n,k as
|
|
1
|
+
import{N as n,k as c}from"../../assets/no-shadow-element-l9trQfcI.js";import{t as m}from"../../assets/custom-element-BhZVzxrc.js";import{n as h}from"../../assets/property-leIVgCvV.js";import{r as d}from"../../assets/state-CccUMzBZ.js";var u=Object.defineProperty,g=Object.getOwnPropertyDescriptor,i=(e,t,o,a)=>{for(var r=a>1?void 0:a?g(t,o):t,l=e.length-1,p;l>=0;l--)(p=e[l])&&(r=(a?p(t,o,r):p(r))||r);return a&&r&&u(t,o,r),r};let s=class extends n{constructor(){super(),this.recipeImgs=[],this.currentStep=0,this.displayedRecipes=[],this.isComplete=!1,this.backgroundImages=[],this.activeBackgroundIndex=0,this.preloadedImages=new Map,this.styleURL=new URL("./planner/to-basket-loader/to-basket-loader.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.scrollIntoView({behavior:"smooth",block:"center"}),this.preloadImages().then(()=>{this.startAnimation()})}async preloadImages(){if(!this.recipeImgs||this.recipeImgs.length===0)return Promise.resolve();const e=this.recipeImgs.map(t=>new Promise(o=>{const a=new Image;a.onload=()=>{this.preloadedImages.set(t,a),o()},a.onerror=()=>{o()},a.src=t}));return Promise.all(e).then(()=>{this.backgroundImages=[null,null]})}startAnimation(){this.displayedRecipes=[],this.recipeImgs.length>0&&(this.backgroundImages[0]=this.recipeImgs[0],this.activeBackgroundIndex=0);const e=()=>{if(this.currentStep<this.recipeImgs.length){const t=this.recipeImgs[this.currentStep];this.displayedRecipes=[...this.displayedRecipes,t],this.updateBackgroundImage(t),this.currentStep++,setTimeout(()=>{e()},1200)}else this.isComplete=!0,setTimeout(()=>{this.emitLoaderComplete()},1500)};setTimeout(()=>{e()},500)}updateBackgroundImage(e){const t=(this.activeBackgroundIndex+1)%2;this.backgroundImages[t]=e,this.activeBackgroundIndex=t,this.requestUpdate()}emitLoaderComplete(){this.dispatchEvent(new CustomEvent("basketComplete",{bubbles:!0,composed:!0}))}render(){return c`
|
|
2
2
|
<div class="mealz-to-basket-loader ${this.isComplete?"complete":""}">
|
|
3
|
-
${this.backgroundImages.map((e,t)=>e?
|
|
3
|
+
${this.backgroundImages.map((e,t)=>e?c`
|
|
4
4
|
<div class="mealz-to-basket-loader__background ${t===this.activeBackgroundIndex?"active":""}"
|
|
5
5
|
style="background-image: url('${e}')"></div>
|
|
6
6
|
`:"")}
|
|
7
7
|
<div class="mealz-to-basket-loader__container">
|
|
8
8
|
<div class="mealz-to-basket-loader__recipes">
|
|
9
|
-
${this.displayedRecipes.map(e=>
|
|
9
|
+
${this.displayedRecipes.map(e=>c`
|
|
10
10
|
<div class="mealz-to-basket-loader__recipe-item">
|
|
11
11
|
<div class="mealz-to-basket-loader__recipe-image">
|
|
12
|
-
${e?
|
|
12
|
+
${e?c`<img src="${e}" alt="Recipe">`:c`
|
|
13
13
|
<div class="mealz-to-basket-loader__recipe-placeholder"></div>`}
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
@@ -17,4 +17,4 @@ import{N as n,k as d}from"../../assets/no-shadow-element-Dckeu5Ol.js";import{t a
|
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
|
-
`}};i([h({type:Array})],s.prototype,"recipeImgs",2);i([
|
|
20
|
+
`}};i([h({type:Array})],s.prototype,"recipeImgs",2);i([d()],s.prototype,"currentStep",2);i([d()],s.prototype,"displayedRecipes",2);i([d()],s.prototype,"isComplete",2);i([d()],s.prototype,"backgroundImages",2);i([d()],s.prototype,"activeBackgroundIndex",2);i([d()],s.prototype,"preloadedImages",2);s=i([m("mealz-to-basket-loader")],s);customElements.get("mealz-to-basket-loader")||customElements.define("mealz-to-basket-loader",s);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{N as _,k as c,B as $,S,m as i}from"../assets/no-shadow-element-
|
|
1
|
+
import{N as _,k as c,B as $,S,m as i}from"../assets/no-shadow-element-l9trQfcI.js";import{t as b}from"../assets/custom-element-BhZVzxrc.js";import{n as p}from"../assets/property-leIVgCvV.js";import{a as z}from"../assets/unsafe-html-CmALAWuN.js";import{r as u}from"../assets/state-CccUMzBZ.js";import{d as C}from"../assets/debounceTime-Bo5F3ux-.js";import{d as T}from"../assets/distinctUntilChanged-BkBiB4M3.js";import{s as k}from"../assets/switchMap-D8q0hRYH.js";import{f as x}from"../assets/filter-CEeE8t7I.js";import"../assets/async-D3oCs_PQ.js";import"../assets/OperatorSubscriber-EGuECN6g.js";import"../assets/innerFrom-CfKCbnvr.js";var I=Object.defineProperty,q=Object.getOwnPropertyDescriptor,g=(e,s,r,a)=>{for(var t=a>1?void 0:a?q(s,r):s,n=e.length-1,l;n>=0;n--)(l=e[n])&&(t=(a?l(s,r,t):l(t))||t);return a&&t&&I(s,r,t),t};let h=class extends _{constructor(){super(),this.isCollapsed=!0,this.isCollapsedChangeEvent=new CustomEvent("isCollapsedChange",{detail:{isCollapsed:this.isCollapsed},bubbles:!0,composed:!0}),this.styleURL=new URL("./accordion/accordion.css",this.getBaseURL())}connectedCallback(){super.connectedCallback();const e=this.querySelector('[slot="title"]');e&&(this.titleSlot=e.innerHTML,e.remove());const s=this.querySelector('[slot="content"]');s&&(this.contentSlot=s.innerHTML,s.remove()),this.innerHTML=""}disconnectedCallback(){super.disconnectedCallback()}toggleAccordion(){this.isCollapsed=!this.isCollapsed,this.dispatchEvent(this.isCollapsedChangeEvent),this.requestUpdate()}updated(){this.classList.toggle("opened",!this.isCollapsed)}render(){return c`
|
|
2
2
|
<button
|
|
3
3
|
class="mealz-accordion__header"
|
|
4
4
|
@click=${()=>this.toggleAccordion()}
|
|
@@ -16,7 +16,7 @@ import{N as _,k as c,B as $,S,m as i}from"../assets/no-shadow-element-Dckeu5Ol.j
|
|
|
16
16
|
${typeof this.contentSlot=="string"?z(this.contentSlot):this.contentSlot}
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
|
-
`}};g([p({type:String})],
|
|
19
|
+
`}};g([p({type:String})],h.prototype,"titleSlot",2);g([p({type:String})],h.prototype,"contentSlot",2);g([p({type:String})],h.prototype,"iconUrl",2);g([p({type:Boolean})],h.prototype,"isCollapsed",2);h=g([b("mealz-accordion")],h);var P=Object.defineProperty,E=Object.getOwnPropertyDescriptor,v=(e,s,r,a)=>{for(var t=a>1?void 0:a?E(s,r):s,n=e.length-1,l;n>=0;n--)(l=e[n])&&(t=(a?l(s,r,t):l(t))||t);return a&&t&&P(s,r,t),t};let m=class extends _{constructor(){super(),this.suggestedTags=[],this.notFound=!1,this.searchQuery=new $(""),this.subscription=new S,this.styleURL=new URL("./preferences/preferences-search/preferences-search.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenOnSearchChange()}disconnectedCallback(){super.disconnectedCallback(),this.subscription.unsubscribe()}searchInputUpdate(e){this.searchQuery.next(e.target.value)}listenOnSearchChange(){this.subscription.add(this.searchQuery.pipe(C(250),T(),k(e=>e.length>0?i.tags.autocomplete(e):[])).subscribe(e=>{var s,r;this.suggestedTags=(s=e==null?void 0:e.data)==null?void 0:s.filter(a=>a.attributes["tag-type-id"]==="ingredient_category"||a.attributes["tag-type-id"]==="ingredientsdefinition"),this.notFound=((r=this.suggestedTags)==null?void 0:r.length)===0,this.requestUpdate()}))}addTag(e){i.preferences.newTagFromSearch(e),this.dispatchEvent(new CustomEvent("backAndReload"))}render(){return c`
|
|
20
20
|
<div class="mealz-preferences-search">
|
|
21
21
|
<div class="mealz-preferences-search__searchbar-container">
|
|
22
22
|
<div class="mealz-preferences-search__searchbar mealz-ds-searchbar">
|
|
@@ -51,7 +51,7 @@ import{N as _,k as c,B as $,S,m as i}from"../assets/no-shadow-element-Dckeu5Ol.j
|
|
|
51
51
|
`)}
|
|
52
52
|
`}
|
|
53
53
|
</div>
|
|
54
|
-
`}};v([
|
|
54
|
+
`}};v([u()],m.prototype,"suggestedTags",2);v([u()],m.prototype,"notFound",2);m=v([b("mealz-preferences-search")],m);class y{constructor(){this.attributes={"tag-type-id":"",name:"","icon-url":"","picture-url":""}}get tagType(){return this.attributes["tag-type-id"]}get name(){return this.attributes.name}}var O=Object.defineProperty,U=Object.getOwnPropertyDescriptor,d=(e,s,r,a)=>{for(var t=a>1?void 0:a?U(s,r):s,n=e.length-1,l;n>=0;n--)(l=e[n])&&(t=(a?l(s,r,t):l(t))||t);return a&&t&&O(s,r,t),t};let o=class extends _{constructor(){super(),this.isOpen=!1,this.diets=[],this.ingredients=[],this.equipments=[],this.displayType="defaultView",this.analyticsPath="/preferences",this.openedModalSubscriptions=[],this.subscriptions=[],this.forcedIngredients=[{id:"ingredient_category_lgumes",name:"Légume"},{id:"ingredient_category_viandes-blanches",name:"Viande blanche"},{id:"ingredient_category_fromage",name:"Fromage"},{id:"ingredient_category_poissons",name:"Poisson"},{id:"ingredient_category_fruits",name:"Fruit"},{id:"ingredientsdefinition_coriandre",name:"Coriandre"},{id:"ingredientsdefinition_brocoli",name:"Brocoli"},{id:"ingredientsdefinition_oeuf",name:"Oeuf"},{id:"ingredient_category_alcool",name:"Alcool"}],this.drawerViewSwapper=document.querySelector("mealz-drawer-view-swapper")}connectedCallback(){super.connectedCallback(),this.initSubscriptions(),window.scrollTo(0,0)}disconnectedCallback(){super.disconnectedCallback(),this.openedModalSubscriptions.forEach(e=>e.unsubscribe()),this.subscriptions.forEach(e=>e.unsubscribe())}initSubscriptions(){this.subscriptions.push(this.drawerViewSwapper.displayPreferences$.subscribe(e=>{this.isOpen=e,e?(this.fetchTags(),this.pageview()):this.openedModalSubscriptions.forEach(s=>s.unsubscribe()),this.requestUpdate()}),i.supplier.currentSupplier().pipe(x(e=>!!e)).subscribe(e=>{this.supplierId=e.id,this.fetchTags(),this.requestUpdate()}))}defaultViewHeader(){return c`
|
|
55
55
|
<button class="mealz-ds-button ghost square mealz-preferences__back-button" @click=${this.close}>
|
|
56
56
|
<img class="mealz-preferences__back-image" alt="go back"
|
|
57
57
|
src="https://storage.googleapis.com/assets.miam.tech/generic/icons/arrow-right.svg">
|
|
@@ -174,4 +174,4 @@ import{N as _,k as c,B as $,S,m as i}from"../assets/no-shadow-element-Dckeu5Ol.j
|
|
|
174
174
|
></mealz-preferences-search>
|
|
175
175
|
`}
|
|
176
176
|
</div>
|
|
177
|
-
`:c``}close(){this.sendCloseEvent(),this.drawerViewSwapper.displayPreferences$.next(!1),i.preferences.resetTagsActions()}pageview(){i.analytics.sendEvent("pageview",this.analyticsPath,{})}sendCloseEvent(){i.analytics.sendEvent("preferences.close",this.analyticsPath,{})}createTagSubscription(e,s){this.openedModalSubscriptions.push(i.tags.all({remotefilter:{tag_type:e,for_supplier:this.supplierId}}).subscribe(r=>{this[`${e}s`]=r.data.map(a=>({tag:a,checked:i.preferences.tagShouldBeChecked(a,s),without:e!=="diet"})),this.requestUpdate()}))}fetchTags(){this.supplierId&&(this.createTagSubscription("diet",!1),this.createTagSubscription("equipment",!0),this.initIngredientTags())}reset(){i.preferences.resetPreferences(),i.preferences.sendCacheRequest("remove","preferences").subscribe(),this.fetchTags()}initIngredientTags(){this.ingredients=[],this.forcedIngredients.forEach(e=>{const s=new y;s.id=e.id,s.attributes.name=e.name,this.ingredients.push({tag:s,checked:i.preferences.tagShouldBeChecked(s,!0),without:!0})}),this.getAdditionalIngredients()}getAdditionalIngredients(){(i.preferences.preferencesInStorage()||{without:[]}).without.filter(t=>t.id.includes("ingredient_category_")||t.id.includes("ingredientsdefinition_")||t.id.includes("meal_type_")).forEach(t=>{if(this.forcedIngredients.findIndex(n=>n.id===t.id)===-1){const n=new y;n.id=t.id,n.attributes={"tag-type-id":"",name:t.name,"icon-url":"","picture-url":""},i.preferences.tagShouldBeChecked(n,!0)&&this.ingredients.push({tag:n,checked:!0,without:!0})}});const r=["ingredient_category_","ingredientsdefinition_","meal_type_"],a=i.preferences.tagsToAdd.filter(t=>{const n=t.tag.id,l=r.some(f=>n.includes(f)),w=!this.ingredients.some(f=>f.tag.id===n);return l&&w});this.ingredients.push(...a),this.updateFiltersInCache()}toggleTag(e){e.checked=!e.checked,e.tag.attributes["tag-type-id"]==="equipment"!==e.checked?i.preferences.addTag(e):(i.preferences.removeTag(e),this.isAdditionalIngredient(e)&&this.ingredients.splice(this.ingredients.findIndex(s=>s.tag.id===e.tag.id),1)),this.requestUpdate()}isAdditionalIngredient(e){return this.forcedIngredients.findIndex(s=>s.id===e.tag.id)===-1&&(e.tag.id.includes("ingredient_category_")||e.tag.id.includes("ingredientsdefinition_"))}updateAndBack(){i.preferences.updatePreferences(),i.preferences.preferencesChanged(),this.updateFiltersInCache(!0)}goToDefaultView(){this.displayType="defaultView",this.requestUpdate()}goToSearchView(){this.displayType="searchView",this.requestUpdate()}updateFiltersInCache(e=!1){const s=i.preferences.addPreferencesToRemoteFilters(this.filters,!0),r={exclude_tags:s.exclude_tags,include_tags:s.include_tags,...i.preferences.guests$.value!==4&&{guests:i.preferences.guests$.value}};(Object.keys(r).length>0?i.preferences.sendCacheRequest("set","preferences",r):i.preferences.sendCacheRequest("remove","preferences")).subscribe(()=>{e&&(i.preferences.preferencesChanged(),this.close())})}updateGuests(e){i.preferences.guests$.next(e.detail.value),this.requestUpdate()}};d([p({type:Object})],o.prototype,"filters",2);d([p({type:Boolean})],o.prototype,"isOpen",2);d([
|
|
177
|
+
`:c``}close(){this.sendCloseEvent(),this.drawerViewSwapper.displayPreferences$.next(!1),i.preferences.resetTagsActions()}pageview(){i.analytics.sendEvent("pageview",this.analyticsPath,{})}sendCloseEvent(){i.analytics.sendEvent("preferences.close",this.analyticsPath,{})}createTagSubscription(e,s){this.openedModalSubscriptions.push(i.tags.all({remotefilter:{tag_type:e,for_supplier:this.supplierId}}).subscribe(r=>{this[`${e}s`]=r.data.map(a=>({tag:a,checked:i.preferences.tagShouldBeChecked(a,s),without:e!=="diet"})),this.requestUpdate()}))}fetchTags(){this.supplierId&&(this.createTagSubscription("diet",!1),this.createTagSubscription("equipment",!0),this.initIngredientTags())}reset(){i.preferences.resetPreferences(),i.preferences.sendCacheRequest("remove","preferences").subscribe(),this.fetchTags()}initIngredientTags(){this.ingredients=[],this.forcedIngredients.forEach(e=>{const s=new y;s.id=e.id,s.attributes.name=e.name,this.ingredients.push({tag:s,checked:i.preferences.tagShouldBeChecked(s,!0),without:!0})}),this.getAdditionalIngredients()}getAdditionalIngredients(){(i.preferences.preferencesInStorage()||{without:[]}).without.filter(t=>t.id.includes("ingredient_category_")||t.id.includes("ingredientsdefinition_")||t.id.includes("meal_type_")).forEach(t=>{if(this.forcedIngredients.findIndex(n=>n.id===t.id)===-1){const n=new y;n.id=t.id,n.attributes={"tag-type-id":"",name:t.name,"icon-url":"","picture-url":""},i.preferences.tagShouldBeChecked(n,!0)&&this.ingredients.push({tag:n,checked:!0,without:!0})}});const r=["ingredient_category_","ingredientsdefinition_","meal_type_"],a=i.preferences.tagsToAdd.filter(t=>{const n=t.tag.id,l=r.some(f=>n.includes(f)),w=!this.ingredients.some(f=>f.tag.id===n);return l&&w});this.ingredients.push(...a),this.updateFiltersInCache()}toggleTag(e){e.checked=!e.checked,e.tag.attributes["tag-type-id"]==="equipment"!==e.checked?i.preferences.addTag(e):(i.preferences.removeTag(e),this.isAdditionalIngredient(e)&&this.ingredients.splice(this.ingredients.findIndex(s=>s.tag.id===e.tag.id),1)),this.requestUpdate()}isAdditionalIngredient(e){return this.forcedIngredients.findIndex(s=>s.id===e.tag.id)===-1&&(e.tag.id.includes("ingredient_category_")||e.tag.id.includes("ingredientsdefinition_"))}updateAndBack(){i.preferences.updatePreferences(),i.preferences.preferencesChanged(),this.updateFiltersInCache(!0)}goToDefaultView(){this.displayType="defaultView",this.requestUpdate()}goToSearchView(){this.displayType="searchView",this.requestUpdate()}updateFiltersInCache(e=!1){const s=i.preferences.addPreferencesToRemoteFilters(this.filters,!0),r={exclude_tags:s.exclude_tags,include_tags:s.include_tags,...i.preferences.guests$.value!==4&&{guests:i.preferences.guests$.value}};(Object.keys(r).length>0?i.preferences.sendCacheRequest("set","preferences",r):i.preferences.sendCacheRequest("remove","preferences")).subscribe(()=>{e&&(i.preferences.preferencesChanged(),this.close())})}updateGuests(e){i.preferences.guests$.next(e.detail.value),this.requestUpdate()}};d([p({type:Object})],o.prototype,"filters",2);d([p({type:Boolean})],o.prototype,"isOpen",2);d([u()],o.prototype,"diets",2);d([u()],o.prototype,"ingredients",2);d([u()],o.prototype,"equipments",2);d([u()],o.prototype,"displayType",2);d([p({type:String})],o.prototype,"analyticsPath",2);o=d([b("mealz-preferences")],o);
|
package/dist/price/price.min.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{N as n,k as
|
|
1
|
+
import{N as n,k as a,D as d}from"../assets/no-shadow-element-l9trQfcI.js";import{t as v}from"../assets/custom-element-BhZVzxrc.js";import{n as m}from"../assets/property-leIVgCvV.js";import{P as h}from"../assets/price-BoM226Kw.js";var u=Object.defineProperty,P=Object.getOwnPropertyDescriptor,l=(o,i,c,t)=>{for(var e=t>1?void 0:t?P(i,c):i,s=o.length-1,p;s>=0;s--)(p=o[s])&&(e=(t?p(i,c,e):p(e))||e);return t&&e&&u(i,c,e),e};let r=class extends n{constructor(){super(),this.priceService=h.getInstance(),this.styleURL=new URL("./price/price.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.priceService.initFormatter()}renderOldPrice(){return a`
|
|
2
2
|
<div class="mealz-price__previous mealz-ds-text weight-l size-xs">
|
|
3
3
|
${this.priceService.priceTemplate(this.oldPrice)}
|
|
4
4
|
</div>
|
|
5
|
-
`}render(){return
|
|
5
|
+
`}render(){return a`
|
|
6
6
|
<div class="mealz-price">
|
|
7
7
|
${this.oldPrice?this.renderOldPrice():d}
|
|
8
8
|
<div class="mealz-price__current">
|
|
9
9
|
${this.priceService.priceTemplate(this.price)}
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
|
-
`}};l([
|
|
12
|
+
`}};l([m({type:Number})],r.prototype,"price",2);l([m({type:Number})],r.prototype,"oldPrice",2);r=l([v("mealz-price")],r);customElements.get("mealz-price")||customElements.define("mealz-price",r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as f,m as n}from"../assets/no-shadow-element-
|
|
1
|
+
import{N as f,m as n}from"../assets/no-shadow-element-l9trQfcI.js";import{V as u}from"../assets/viewport-listener-RTCBatPv.js";import{t as w}from"../assets/custom-element-BhZVzxrc.js";import{h as v}from"../assets/session-handler-BnuvphmJ.js";import{f as m}from"../assets/filter-CEeE8t7I.js";import{s as y}from"../assets/switchMap-D8q0hRYH.js";import{c as L}from"../assets/combineLatest-P4GAEtOW.js";import{t as d}from"../assets/take-DO4w5a1Y.js";import"../assets/debounceTime-Bo5F3ux-.js";import"../assets/async-D3oCs_PQ.js";import"../assets/OperatorSubscriber-EGuECN6g.js";import"../assets/innerFrom-CfKCbnvr.js";import"../assets/from-jBe2xW5a.js";import"../assets/executeSchedule-DfyZaGAH.js";import"../assets/mapOneOrManyArgs-DNd_tswl.js";import"../assets/map-C4rf5Jbc.js";import"../assets/empty-Cv-4tfKR.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,i,s){const r=Date.now(),a=!this.trackedRecipes.get(e),l=this.hasScrolled;!a&&!l||(this.trackedRecipes.size>=this.MAX_RECIPES&&this.cleanOldRecipes(),this.trackedRecipes.set(e,r),window.mealzInternal.analytics.sendEvent("recipe.show",i,{recipe_id:e,category_id:s}))}cleanOldRecipes(){const i=Date.now()-3600*1e3;for(const[s,r]of this.trackedRecipes.entries())r<i&&this.trackedRecipes.delete(s)}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 b=Object.getOwnPropertyDescriptor,C=(t,e,i,s)=>{for(var r=s>1?void 0:s?b(e,i):e,c=t.length-1,a;c>=0;c--)(a=t[c])&&(r=a(r)||r);return r};let g=class extends f{constructor(){super(...arguments),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),this.listenInView(),this.setupSubscriptions()}setupSubscriptions(){this.subscriptions.push(n.basket.recipePricesInBasket$().subscribe(t=>{const e=t.find(i=>i.id===this.recipeId);e&&(this.updatedRecipeId=e.id,this.updateDOM())}),this.setupPlannerMenuSubscription())}setupPlannerMenuSubscription(){return n.planner.menuPrice$.pipe(m(()=>this.planner&&!!this.recipeId),y(()=>L([n.planner.isRecipeInMenu$(this.recipeId).pipe(d(1)),n.planner.getGuestsForRecipe(this.recipeId).pipe(d(1))])),m(([t,e])=>t&&typeof e=="number"&&e>0)).subscribe(([t,e])=>{this.guests=e,this.updateGuestDisplay()})}disconnectedCallback(){var e,i;super.disconnectedCallback(),this.subscriptions.forEach(s=>s.unsubscribe()),(e=this.priceViewportObserver)==null||e.disconnect(),(i=this.analyticsViewportObserver)==null||i.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.priceViewportObserver=new u(this,()=>{this.handleIntersection()}),this.analyticsViewportObserver=new u(this,()=>{this.sendAnalyticsShow()},{threshold:.8,debounce:1e3})}handleIntersection(){this.recipePricing=this.querySelector("mealz-recipe-pricing"),this.recipePricing&&(this.recipePricing.fetchPrice(this.posId,this.guests,this.recipeId),this.priceViewportObserver.disconnect())}getInitialStatus(){var p;const t=(p=this.attributes["starting-data"])==null?void 0:p.value;if(!t)return;const{id:e,guests:i,posId:s,path:r,categoryId:c,initialTabIndex:a,planner:l,sessionId:S,recipe:I}=JSON.parse(t);if(this.posId=s,this.recipeId=e,this.analyticsPath=r,this.categoryId=c,this.guests=i,this.initialTabIndex=a,this.planner=l,this.recipe=I,v(S),!i){this.guests=this.getGuests();const h=this.querySelector(".mealz-recipe-card__counter p");h&&(h.innerHTML=this.guests.toString())}this.removeAttribute("starting-data")}openDetails(){n.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(){const t=this.querySelector("mealz-recipe-card-cta");if(!t)return;const e=t.getStatus();e==="add"?(this.showAddingToMenuState(t),this.addRecipeToMenu()):e==="in-menu"&&(this.showRemovingFromMenuState(t),this.removeRecipeFromMenu())}addRecipeToMenu(){var s,r;const t=document.querySelector("mealz-planner-recipe-suggestion"),e=(t==null?void 0:t.guests)||this.guests;t.recipeId=this.recipeId;const i=document.querySelector("mealz-planner-current-menu");if(!i){const c=(r=(s=n.recipes)==null?void 0:s.productsPlannerByCategory$)==null?void 0:r.value,a=(c==null?void 0:c.toPickProducts)||[];n.planner.addRecipeToMenu(this.recipeId,e,!!n.pos.currentPos().value,a).pipe(d(1)).subscribe(()=>{this.removeRecipeCardLoader("add");const l=document.querySelector("mealz-planner-recipe-list");l==null||l.addRecipeCardToList(this.recipeId)});return}i.addRecipe(this.recipeId,e).subscribe(()=>{this.removeRecipeCardLoader("add"),t.addAndSelectNewSuggestion(this.recipe)})}removeRecipeFromMenu(){const t=document.querySelector("mealz-planner-recipe-suggestion");if(!t){n.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"),i=t.querySelector("img.in-menu");e==null||e.classList.remove("hidden"),i==null||i.classList.add("hidden")}removeRecipeCardLoader(t){const e=this.querySelector("mealz-recipe-card-cta");if(!e)return;const i=this.querySelector(".mealz-recipe-card-cta"),s=this.querySelector(".mealz-recipe-card-cta__loader"),r=e.querySelector("img.add"),c=e.querySelector("img.in-menu");t==="add"?(s==null||s.classList.add("hidden"),i==null||i.classList.replace("primary","secondary"),c==null||c.classList.remove("hidden"),e.updateStatus("in-menu")):(s==null||s.classList.add("hidden"),i==null||i.classList.replace("secondary","primary"),r==null||r.classList.remove("hidden"),e.updateStatus("add"))}showAddingToMenuState(t){const e=this.querySelector(".mealz-recipe-card-cta__loader"),i=t.querySelector("img.add"),s=t.querySelector("img.in-menu");e==null||e.classList.remove("hidden"),i==null||i.classList.add("hidden"),s==null||s.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(),this.updatedRecipeId&&this.guests&&this.recipePricing&&this.recipePricing.fetchPrice(this.posId,this.guests,this.recipeId))}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)}};g=C([w("mealz-recipe-card")],g);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as l,m as p}from"../assets/no-shadow-element-
|
|
1
|
+
import{N as l,m as p}from"../assets/no-shadow-element-l9trQfcI.js";import{t as h}from"../assets/custom-element-BhZVzxrc.js";import{m as u}from"../assets/map-C4rf5Jbc.js";import{d}from"../assets/distinctUntilChanged-BkBiB4M3.js";import{s as o}from"../assets/switchMap-D8q0hRYH.js";import"../assets/OperatorSubscriber-EGuECN6g.js";import"../assets/innerFrom-CfKCbnvr.js";var m=Object.getOwnPropertyDescriptor,b=(e,t,s,i)=>{for(var a=i>1?void 0:i?m(t,s):t,r=e.length-1,c;r>=0;r--)(c=e[r])&&(a=c(a)||a);return a};let n=class extends l{constructor(){super(...arguments),this.subscriptions=[],this.recipeId="",this.status="add",this.planner=!1}connectedCallback(){super.connectedCallback(),this.getInitialStatus();const e=p.basket.recipePricesInBasket$().pipe(u(t=>t.some(s=>s.id===this.recipeId)),d());this.subscriptions.push(p.planner.isRecipeInMenu$(this.recipeId).pipe(o(t=>e.pipe(u(s=>{let i;return this.planner?i=s?"in-basket":t?"in-menu":"add":i=s?"in-basket":"add",i}))),d()).subscribe(t=>this.updateStatus(t)))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){this.recipeCta=this.querySelector(".mealz-recipe-card-cta"),this.recipeCta}getInitialStatus(){var t;const e=(t=this.attributes["starting-data"])==null?void 0:t.value;if(e)try{if(Object.assign(this,JSON.parse(e)),this.removeAttribute("starting-data"),this.planner)this.updateStatus(this.status);else{const s=this.classList.contains("in-basket");this.updateStatus(s?"in-basket":"add")}}catch(s){console.error("Error parsing starting-data attribute:",s)}}updateStatus(e){this.status!==e&&(this.status=e,this.recipeCta&&(this.recipeCta.classList.remove("in-basket","in-menu","add"),this.recipeCta.classList.add(this.status),this.recipeCta.classList.toggle("primary",this.status==="add"),this.recipeCta.classList.toggle("secondary",this.status!=="add"),this.updateButtonState(),this.updateImages()))}updateButtonState(){this.recipeCta&&(this.planner&&this.status==="in-basket"?this.recipeCta.setAttribute("disabled","true"):this.recipeCta.removeAttribute("disabled"))}updateImages(){if(!this.recipeCta)return;this.recipeCta.querySelectorAll("img").forEach(t=>{t.classList.contains(this.status)?t.classList.remove("hidden"):t.classList.add("hidden")})}getStatus(){return this.status}};n=b([h("mealz-recipe-card-cta")],n);customElements.get("mealz-recipe-card-cta")||customElements.define("mealz-recipe-card-cta",n);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{N as u,m as a,D as o,k as s}from"../assets/no-shadow-element-
|
|
1
|
+
import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{N as u,m as a,D as o,k as s}from"../assets/no-shadow-element-l9trQfcI.js";import{t as h}from"../assets/custom-element-BhZVzxrc.js";import{n as p}from"../assets/property-leIVgCvV.js";import{P as B}from"../assets/price-BoM226Kw.js";import{R as A}from"../assets/recipe-BwGs-blm.js";import{m as w}from"../assets/merge-C-u9uFzU.js";import{m as d}from"../assets/map-C4rf5Jbc.js";import{t as P}from"../assets/take-DO4w5a1Y.js";import{c as D}from"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import{G as L}from"../assets/product-card-DqcKyf1c.js";import"../price/price.min.js";import"../assets/promotion-badge-BwN2GpDz.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 M}from"../last-order-modal/last-order-modal.min.js";import{a as N}from"../assets/unsafe-html-CmALAWuN.js";import{f as I}from"../assets/filter-CEeE8t7I.js";import{t as G}from"../assets/tap-BCGrRktL.js";import{s as T}from"../assets/switchMap-D8q0hRYH.js";import{c as E}from"../assets/combineLatest-P4GAEtOW.js";import"../assets/skipWhile-DuMEda_n.js";import"../assets/OperatorSubscriber-EGuECN6g.js";import"../assets/innerFrom-CfKCbnvr.js";import"../assets/from-jBe2xW5a.js";import"../assets/executeSchedule-DfyZaGAH.js";import"../assets/mapOneOrManyArgs-DNd_tswl.js";import"../assets/of-BTA69Qgj.js";import"../assets/mergeMap-buGewtOo.js";import"../assets/empty-Cv-4tfKR.js";import"../assets/debounceTime-Bo5F3ux-.js";import"../assets/async-D3oCs_PQ.js";import"../assets/delay-ILvLVH1b.js";import"../assets/timer-BOl4bYNY.js";import"../assets/store-locator-m8sx3XDc.js";import"../assets/state-CccUMzBZ.js";var q=Object.defineProperty,F=Object.getOwnPropertyDescriptor,v=(e,t,r,l)=>{for(var i=l>1?void 0:l?F(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=(l?c(t,r,i):c(i))||i);return l&&i&&q(t,r,i),i};let m=class extends u{constructor(){super(),this.noPosDisplay=!1,this.noSupplier=!1,this.recipeId="",this.plannerMode=!1,this.subscriptions=[],this.remainingBasketEntries=[],this.recipePrice={remaining:0,inBasket:0,total:0,totalPerGuest:0},this.priceService=B.getInstance(),this.allIngredientsToBasketLoading=!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(w(a.recipes.remainingBasketEntries$.pipe(d(e=>{this.remainingBasketEntries=e})),a.recipes.recipePrice$.pipe(d(e=>{const t=e.remaining+e.inBasket;this.recipePrice={...e,total:t,totalPerGuest:0}})),a.recipes.allIngredientsToBasketLoading$.pipe(d(e=>{this.allIngredientsToBasketLoading=e})),a.recipes.ingredientToBasketLoading$.pipe(d(e=>{this.ingredientToBasketLoading=e})),a.recipes.updateIngredientFromBasketLoading$.pipe(d(e=>{this.updateIngredientFromBasketLoading=e})),a.recipes.productsLoading$.pipe(d(e=>{this.productsLoading=e})),a.planner.isRecipeInMenu$(this.recipeId).pipe(d(e=>this.inMenu=e)),a.planner.plannerRecipePrice$.pipe(d(e=>{this.recipePrice.totalPerGuest=this.guests>0?e/this.guests:e}))).subscribe(()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}closeRecipeDetails(e=!1){a.recipes.displayedRecipe$.next(null),e&&a.basket.basketPreviewState$.next({isOpen:!0,activeTabIndex:a.basket.basketPreviewState$.getValue().activeTabIndex})}continueShopping(){this.closeRecipeDetails(),this.sendContinueEvent()}addToMenu(){var r,l;this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion");e.recipeId=this.recipeId;const t=document.querySelector("mealz-planner-current-menu");if(!t){const i=(l=(r=a.recipes)==null?void 0:r.productsPlannerByCategory$)==null?void 0:l.value,n=(i==null?void 0:i.toPickProducts)||[];a.planner.addRecipeToMenu(this.recipeId,this.guests,!!a.pos.currentPos().value,n).pipe(P(1)).subscribe(()=>{this.inMenu=!0;const c=document.querySelector("mealz-planner-recipe-list");c==null||c.addRecipeCardToList(this.recipeId),this.menuUpdateLoading=!1,this.requestUpdate()});return}t.addRecipe(this.recipeId,this.guests).subscribe(()=>{this.inMenu=!0,e.addAndSelectNewSuggestion(this.recipe),this.menuUpdateLoading=!1,this.requestUpdate()})}removeFromMenu(){this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){a.planner.removeRecipeFromMenu(this.recipeId).pipe(P(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(){a.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),this.sendAddAllEvent(),this.recipePrice.inBasket===0&&this.sendAddRecipeEvent()}render(){if(this.noPosDisplay&&!this.plannerMode)return o;const e=this.remainingBasketEntries.length>0&&!this.plannerMode,t=this.plannerMode&&this.noPosDisplay,r=this.plannerMode&&!this.inMenu;return s`
|
|
2
2
|
<div class="mealz-recipe-details__footer">
|
|
3
3
|
${this.productsLoading&&!this.plannerMode?o:s`
|
|
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(){a.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){a.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){a.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};v([p({type:Boolean})],m.prototype,"noPosDisplay",2);v([p({type:Boolean})],m.prototype,"noSupplier",2);v([p({type:String})],m.prototype,"recipeId",2);v([p({type:Boolean})],m.prototype,"plannerMode",2);v([p({type:Number})],m.prototype,"guests",2);v([p({type:
|
|
94
|
+
`}sendAddAllEvent(){a.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){a.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){a.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};v([p({type:Boolean})],m.prototype,"noPosDisplay",2);v([p({type:Boolean})],m.prototype,"noSupplier",2);v([p({type:String})],m.prototype,"recipeId",2);v([p({type:Boolean})],m.prototype,"plannerMode",2);v([p({type:Number})],m.prototype,"guests",2);v([p({type:A})],m.prototype,"recipe",2);m=v([h("mealz-details-footer")],m);customElements.get("mealz-details-footer")||customElements.define("mealz-details-footer",m);var V=Object.getOwnPropertyDescriptor,H=(e,t,r,l)=>{for(var i=l>1?void 0:l?V(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let x=class extends u{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(a.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 s`<span class="mealz-recipe-details-infos__no-time-placeholder">0 min</span>`}noDataPlaceholder(){return s`<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 s`<span class="mealz-ds-text">Facile</span>`;case 2:return s`<span class="mealz-ds-text">Moyen</span>`;case 3:return s`<span class="mealz-ds-text">Difficile</span>`;default:return o}}renderPreparationTime(){return s`
|
|
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
|
-
`}};x=H([h("mealz-details-infos")],x);var j=Object.getOwnPropertyDescriptor,K=(e,t,r,l)=>{for(var i=l>1?void 0:l?j(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let C=class extends u{constructor(){super(),this.steps=[],this.subscriptions=[],this.styleURL=new URL("./details-steps.css",
|
|
160
|
+
`}};x=H([h("mealz-details-infos")],x);var j=Object.getOwnPropertyDescriptor,K=(e,t,r,l)=>{for(var i=l>1?void 0:l?j(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let C=class extends u{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(a.recipes.displayedRecipe$.subscribe(e=>{e&&(this.steps=e.recipe.relationships["recipe-steps"].data.sort((t,r)=>t.attributes["step-number"]-r.attributes["step-number"]).map(t=>t.attributes.description),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){return s`
|
|
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
|
-
`}};C=K([h("mealz-details-steps")],C);var Q=Object.getOwnPropertyDescriptor,Y=(e,t,r,l)=>{for(var i=l>1?void 0:l?Q(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let S=class extends u{constructor(){super(),this.ingredients=[],this.subscriptions=[],this.styleURL=new URL("./details-ingredients.css",
|
|
183
|
+
`}};C=K([h("mealz-details-steps")],C);var Q=Object.getOwnPropertyDescriptor,Y=(e,t,r,l)=>{for(var i=l>1?void 0:l?Q(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let S=class extends u{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(a.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 s`
|
|
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"}};S=Y([h("mealz-details-ingredients")],S);var W=Object.defineProperty,X=Object.getOwnPropertyDescriptor,b=(e,t,r,l)=>{for(var i=l>1?void 0:l?X(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=(l?c(t,r,i):c(i))||i);return l&&i&&W(t,r,i),i};const f=["unavailable"],J=["ticked","unselected"];let g=class extends u{constructor(){super(),this.isSponsored=!1,this.subscriptions=[],this.guestObserverService=L.getInstance(),this.modifiedIngQty=0,this.analyticsPath="/meals-planner/current",this.styleURL=new URL("./product-card-planner.css",
|
|
212
|
+
`}ingredientPicture(e){return e.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}};S=Y([h("mealz-details-ingredients")],S);var W=Object.defineProperty,X=Object.getOwnPropertyDescriptor,b=(e,t,r,l)=>{for(var i=l>1?void 0:l?X(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=(l?c(t,r,i):c(i))||i);return l&&i&&W(t,r,i),i};const f=["unavailable"],J=["ticked","unselected"];let g=class extends u{constructor(){super(),this.isSponsored=!1,this.subscriptions=[],this.guestObserverService=L.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"}updated(){var e,t;this.product&&(this.isSponsored=((t=(e=this.product.item)==null?void 0:e.attributes)==null?void 0:t.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(){a.planner.openReplaceItemView(this.product),this.replaceItemViewEvent()}onCheckboxChange(e){e.target.checked?(this.status="ticked",a.planner.selectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.addItemEvent()):(this.status="unselected",a.planner.unselectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.deleteItemEvent()),this.requestUpdate()}render(){return s`
|
|
213
213
|
<div class="mealz-product-card-planner
|
|
214
214
|
${this.status==="ticked"?"added":""}
|
|
215
215
|
${f.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(){a.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){a.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){a.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};b([p({type:Object})],g.prototype,"product",2);b([p({type:String})],g.prototype,"recipeId",2);b([p({type:Number})],g.prototype,"initialGuests",2);b([p({type:Number})],g.prototype,"currentGuests",2);b([p({type:Boolean})],g.prototype,"oftenIgnored",2);g=b([h("mealz-product-card-planner")],g);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",g);var Z=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,
|
|
321
|
+
`}addItemEvent(){a.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){a.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){a.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};b([p({type:Object})],g.prototype,"product",2);b([p({type:String})],g.prototype,"recipeId",2);b([p({type:Number})],g.prototype,"initialGuests",2);b([p({type:Number})],g.prototype,"currentGuests",2);b([p({type:Boolean})],g.prototype,"oftenIgnored",2);g=b([h("mealz-product-card-planner")],g);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",g);var Z=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,U=(e,t,r,l)=>{for(var i=l>1?void 0:l?ee(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=(l?c(t,r,i):c(i))||i);return l&&i&&Z(t,r,i),i};let y=class extends u{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(r=>r.id==="ingredient_category_alcool")}render(){return this.containsAlcohol?s`
|
|
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
|
-
`:o}};
|
|
333
|
+
`:o}};U([p()],y.prototype,"tags",2);y=U([h("mealz-legal-notice")],y);var te=Object.getOwnPropertyDescriptor,se=(e,t,r,l)=>{for(var i=l>1?void 0:l?te(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let O=class extends u{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 s`
|
|
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
|
-
`}};O=se([h("mealz-products-card-skeleton")],O);var ie=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,k=(e,t,r,l)=>{for(var i=l>1?void 0:l?ae(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=(l?c(t,r,i):c(i))||i);return l&&i&&ie(t,r,i),i};let z=class extends u{constructor(){super(),this.inBasket=!1,this.plannerMode=!1,this.numberUnavailableProducts=0,this.subscriptions=[],this.noSupplier=a.supplier.isNoSupplier(),this.styleURL=new URL("./products-picker.css",
|
|
376
|
+
`}};O=se([h("mealz-products-card-skeleton")],O);var ie=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,k=(e,t,r,l)=>{for(var i=l>1?void 0:l?ae(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=(l?c(t,r,i):c(i))||i);return l&&i&&ie(t,r,i),i};let z=class extends u{constructor(){super(),this.inBasket=!1,this.plannerMode=!1,this.numberUnavailableProducts=0,this.subscriptions=[],this.noSupplier=a.supplier.isNoSupplier(),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(a.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?a.recipes.productsPlannerByCategory$:a.recipes.productsByCategory$;this.subscriptions.push(e.subscribe(t=>{this.productsByCategory=t,this.plannerMode?this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(r=>r.status==="unavailable").length:this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(r=>r.basketEntry.status==="out_of_stock").length,this.requestUpdate()}))}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(a.router.getCatalogUrl())}closeRecipeModal(){}currentPath(){return""}guestsChange(){const e=new CustomEvent("guestChange",{bubbles:!0,composed:!0});this.dispatchEvent(e)}render(){var e,t,r;return s`
|
|
377
377
|
<div class="mealz-products-picker">
|
|
378
378
|
${this.inBasket&&this.plannerMode?s`
|
|
379
379
|
<div class="mealz-products-picker__overlay">
|
|
@@ -488,7 +488,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
488
488
|
`}
|
|
489
489
|
</div>
|
|
490
490
|
<mealz-legal-notice .tags="${this.recipe.relationships.tags}"></mealz-legal-notice>
|
|
491
|
-
`}sendHomeDisplayEvent(){a.analytics.sendEvent("home.display",this.analyticsPath,{})}};k([p({type:Boolean})],z.prototype,"inBasket",2);k([p({type:Boolean})],z.prototype,"plannerMode",2);z=k([h("mealz-products-picker")],z);customElements.get("mealz-products-picker")||customElements.define("mealz-products-picker",z);var re=Object.getOwnPropertyDescriptor,ne=(e,t,r,l)=>{for(var i=l>1?void 0:l?re(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let $=class extends u{constructor(){super(),this.invalidPos=!1,this.subscriptions=[],this.styleURL=new URL("./no-pos-selected.css",
|
|
491
|
+
`}sendHomeDisplayEvent(){a.analytics.sendEvent("home.display",this.analyticsPath,{})}};k([p({type:Boolean})],z.prototype,"inBasket",2);k([p({type:Boolean})],z.prototype,"plannerMode",2);z=k([h("mealz-products-picker")],z);customElements.get("mealz-products-picker")||customElements.define("mealz-products-picker",z);var re=Object.getOwnPropertyDescriptor,ne=(e,t,r,l)=>{for(var i=l>1?void 0:l?re(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let $=class extends u{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(a.recipes.invalidPosDisplay$.subscribe(e=>{this.invalidPos=e,this.requestUpdate()}))}callPosSelector(){const e=new CustomEvent("posSelected",{bubbles:!0,composed:!0});this.dispatchEvent(e)}openStoreLocator(){const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayStoreLocator$.next(!0)}render(){return s`
|
|
492
492
|
<div class="mealz-no-pos-selected">
|
|
493
493
|
${this.invalidPos?s`
|
|
494
494
|
<!-- INVALID POS -->
|
|
@@ -528,7 +528,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
528
528
|
Sélectionner un magasin
|
|
529
529
|
</button>
|
|
530
530
|
</div>
|
|
531
|
-
`}};$=ne([h("mealz-no-pos-selected")],$);customElements.get("mealz-no-pos-selected")||customElements.define("mealz-no-pos-selected",$);var le=Object.getOwnPropertyDescriptor,ce=(e,t,r,l)=>{for(var i=l>1?void 0:l?le(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let
|
|
531
|
+
`}};$=ne([h("mealz-no-pos-selected")],$);customElements.get("mealz-no-pos-selected")||customElements.define("mealz-no-pos-selected",$);var le=Object.getOwnPropertyDescriptor,ce=(e,t,r,l)=>{for(var i=l>1?void 0:l?le(t,r):t,n=e.length-1,c;n>=0;n--)(c=e[n])&&(i=c(i)||i);return i};let R=class extends u{constructor(){super(),this.activeTabIndex=0,this.subscriptions=[],this.remainingBasketEntries=[],this.guestObserverService=L.getInstance(),this.isSticky=!1,this.styleURL=new URL("./recipe-details/recipe-details.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.handleNoSupplierMode(),this.subscriptions.push(w(a.recipes.displayedRecipe$.pipe(I(e=>!!e),G(e=>{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()}),T(()=>this.listenToRecipeInBasket())),this.listenPosStatus(),this.listenRemainingBasketEntries(),this.listenLastOrderDate(),this.listenToLoadingStates(),this.listenToAddAllToBasket()).subscribe(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.topObserver&&this.topObserver.disconnect(),this.stickyTimeout&&clearTimeout(this.stickyTimeout)}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 r=!t.isIntersecting;this.isSticky!==r&&(this.isSticky=r,this.requestUpdate())},150)},{threshold:0}),this.topObserver.observe(e))})}handleNoSupplierMode(){this.noSupplier=a.supplier.isNoSupplier(),this.requestUpdate()}close(){this.sendCloseEvent(),a.recipes.displayedRecipe$.next(null)}listenToCloseEvent(){document.querySelector("mealz-drawer").addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}selectTab(e){this.activeTabIndex=e,this.activeTabIndex===1&&this.sendCookingDisplayEvent(),this.requestUpdate()}getLikeButton(){this.noSupplier||this.subscriptions.push(a.user.isAuthenticated().pipe(I(e=>e),T(()=>a.html.like(this.recipe.id))).subscribe(e=>{this.likeButtonHTML=e,this.requestUpdate()}))}checkSponsorStorytelling(){this.sponsor&&this.subscriptions.push(a.sponsor.hasStorytelling(this.sponsor.id).subscribe(e=>{this.hasSponsorStorytelling=e,this.requestUpdate()}))}listenPosStatus(){return E({noPosDisplay:a.recipes.noPosDisplay$,invalidPosDisplay:a.recipes.invalidPosDisplay$}).pipe(d(({noPosDisplay:e,invalidPosDisplay:t})=>{this.noPosDisplay=e,this.invalidPosDisplay=t,this.activeTabIndex=e?1:0}))}listenLastOrderDate(){return a.recipes.orderHistoryDate$.pipe(d(e=>{this.orderHistoryDate=e}))}listenToLoadingStates(){return E([a.recipes.ingredientToBasketLoading$,a.recipes.updateIngredientFromBasketLoading$]).pipe(d(([e,t])=>{this.basketIsUpdating=e||t}))}listenRemainingBasketEntries(){return a.recipes.remainingBasketEntries$.pipe(d(e=>{this.remainingBasketEntries=e}))}listenToAddAllToBasket(){return a.recipes.allIngredientsToBasketLoading$.pipe(d(e=>{e&&(this.selectTab(0),setTimeout(()=>{this.scrollToPicker()},50))}))}listenToRecipeInBasket(){return a.recipes.isRecipeInBasket(this.recipe.id).pipe(d(e=>{this.inBasket=e}))}scrollToPicker(){const e=this.querySelector(".mealz-products-picker");if(e){const t=this.querySelector(".mealz-recipe-details__title-container"),r=(t==null?void 0:t.offsetHeight)||0;e.style.scrollMarginTop=`${r}px`,e.scrollIntoView({behavior:"instant",block:"start"})}}scrollToReplacedItem(e){var r,l;const t=this.querySelectorAll("mealz-product-card-planner");for(const i of Array.from(t)){const n=i;if(((l=(r=n.product)==null?void 0:r.item)==null?void 0:l.id)===e){n.scrollIntoView({behavior:"instant",block:"center"});break}}}openLastOrderModal(){this.sendOrderedDisplayEvent();const e=new M;e.recipeId=this.recipe.id,e.addEventListener("orderAgain",()=>this.orderAgain()),e.displayLastOrderModal(this.orderHistoryDate)}orderAgain(){a.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?a.planner.updateGuests(this.recipe.modifiedGuests,t):a.recipes.updateGuests(t),this.requestUpdate()}render(){return s`
|
|
532
532
|
<div class="mealz-recipe-details">
|
|
533
533
|
<!-- IF IS LOADING -->
|
|
534
534
|
${this.recipe?o:s`
|
|
@@ -695,4 +695,4 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
695
695
|
</div>
|
|
696
696
|
`:o}
|
|
697
697
|
</div>
|
|
698
|
-
`}showRecipeAddon(){this.sendSponsorDisplayEvent(),document.querySelector("mealz-drawer-view-swapper").displayRecipeAddon$.next(!0)}pageview(){a.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){a.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){a.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){a.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){a.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};
|
|
698
|
+
`}showRecipeAddon(){this.sendSponsorDisplayEvent(),document.querySelector("mealz-drawer-view-swapper").displayRecipeAddon$.next(!0)}pageview(){a.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){a.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){a.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){a.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){a.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};R=ce([h("mealz-recipe-details")],R);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as z,N as A,B as C,m as c}from"../assets/no-shadow-element-
|
|
1
|
+
import{O as z,N as A,B as C,m as c}from"../assets/no-shadow-element-l9trQfcI.js";import{P as _}from"../assets/price-BoM226Kw.js";import{t as D}from"../assets/custom-element-BhZVzxrc.js";import{f as P}from"../assets/filter-CEeE8t7I.js";import{a as k,b as w,c as L}from"../assets/combineLatest-P4GAEtOW.js";import{s as O}from"../assets/skipWhile-DuMEda_n.js";import{s as g}from"../assets/switchMap-D8q0hRYH.js";import{i as F}from"../assets/innerFrom-CfKCbnvr.js";import{b as E}from"../assets/from-jBe2xW5a.js";import{c as R}from"../assets/OperatorSubscriber-EGuECN6g.js";import{m as U}from"../assets/mapOneOrManyArgs-DNd_tswl.js";import{o as f}from"../assets/of-BTA69Qgj.js";import{t as y}from"../assets/take-DO4w5a1Y.js";import{t as $}from"../assets/tap-BCGrRktL.js";import"../assets/executeSchedule-DfyZaGAH.js";import"../assets/map-C4rf5Jbc.js";import"../assets/empty-Cv-4tfKR.js";function B(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var r=E(e),t=k(e),s=t.args,a=t.keys,l=new z(function(h){var o=s.length;if(!o){h.complete();return}for(var n=new Array(o),u=o,v=o,I=function(b){var m=!1;F(s[b]).subscribe(R(h,function(M){m||(m=!0,v--),n[b]=M},function(){return u--},void 0,function(){(!u||!m)&&(v||h.next(a?w(a,n):n),h.complete())}))},d=0;d<o;d++)I(d)});return r?l.pipe(U(r)):l}class p{constructor(){this.priceMemorized=new Map,this.displayedPrices=new Set,this.cleanupInterval=null,this.MAX_MEMO_SIZE=500,this.CLEANUP_INTERVAL=600*1e3,this.handlePageUnload=()=>{this.destroy()},this.startAutoCleanup(),this.setupPageUnloadListener()}static getInstance(){return p.instance||(p.instance=new p),p.instance}getMemorizedPrice(i,r){const t=`${i}-${r}`;return this.priceMemorized.get(t)}memorizedPrice(i,r,t){const s=`${i}-${r}`;this.priceMemorized.size>=this.MAX_MEMO_SIZE&&this.cleanOldPrices(),this.priceMemorized.set(s,{price:t,guests:r})}isPriceDisplayed(i,r){const t=`${i}-${r}`;return this.displayedPrices.has(t)}markPriceAsDisplayed(i,r){const t=`${i}-${r}`;this.displayedPrices.add(t)}cleanOldPrices(){this.priceMemorized.size>this.MAX_MEMO_SIZE*.8&&Array.from(this.priceMemorized.entries()).slice(0,Math.floor(this.priceMemorized.size*.3)).forEach(([t])=>{this.priceMemorized.delete(t),this.displayedPrices.delete(t)})}clearAllPrices(){this.priceMemorized.clear(),this.displayedPrices.clear()}destroy(){window.removeEventListener("beforeunload",this.handlePageUnload),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.priceMemorized.clear(),this.displayedPrices.clear(),p.instance=null}startAutoCleanup(){this.cleanupInterval=window.setInterval(()=>{this.cleanOldPrices()},this.CLEANUP_INTERVAL)}setupPageUnloadListener(){window.addEventListener("beforeunload",this.handlePageUnload)}}var V=Object.getOwnPropertyDescriptor,N=(e,i,r,t)=>{for(var s=t>1?void 0:t?V(i,r):i,a=e.length-1,l;a>=0;a--)(l=e[a])&&(s=l(s)||s);return s};let S=class extends A{constructor(){super(...arguments),this.formattedPrice="",this.rendered=new C(!1),this.inBasket=!1,this.planner=!1,this.lastPlannerPrice=0,this.plannerPriceSubscription=null,this.subscriptions=[],this.priceService=_.getInstance()}connectedCallback(){super.connectedCallback(),this.classList.add("re-rendering"),this.getInitialStatus(),this.setupSubscriptions(),requestAnimationFrame(()=>{this.classList.remove("re-rendering")})}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null)}setupSubscriptions(){this.subscriptions.push(c.recipes.guestsUpdated().subscribe(e=>{e.recipeId===this.recipeId&&(this.serves=e.guests,this.recalculatePrice())}),this.listenToBasket(),this.setupDisplayedRecipeSubscription(),this.setupGuestUpdatesSubscription(),this.setupMenuPriceSubscription())}setupDisplayedRecipeSubscription(){return c.recipes.displayedRecipe$.pipe(P(()=>this.planner&&!!this.recipeId)).subscribe(e=>{var i;((i=e==null?void 0:e.recipe)==null?void 0:i.id)===this.recipeId?(this.lastDisplayedRecipeId=this.recipeId,this.trackPlannerRecipePrice(),this.updateGuestCountFromMenu()):!(e!=null&&e.recipe)&&this.lastDisplayedRecipeId===this.recipeId&&(this.updatePriceFromCapturedPlannerPrice(),this.lastDisplayedRecipeId=null,this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null))})}setupGuestUpdatesSubscription(){return c.recipes.guestsUpdated().pipe(P(()=>this.planner&&!!this.recipeId)).subscribe(({guests:e,recipeId:i})=>{i===this.recipeId&&!this.planner&&(this.serves=e)})}setupMenuPriceSubscription(){return c.planner.menuPrice$.pipe(P(()=>this.planner&&!!this.recipeId)).subscribe(e=>{if(this.updateGuestCountFromMenu(),this.lastPlannerPrice>0&&this.serves>0){const i=this.lastPlannerPrice/this.serves;this.applyCurrencyDisplay(i.toFixed(2))}})}fetchPrice(e,i,r){var h,o;const t=(h=this.recipePricing)==null?void 0:h.querySelector(".mealz-recipe-pricing__wrapper"),s=(o=this.attributes["starting-data"])==null?void 0:o.value;if(!s){t==null||t.classList.replace("active","hidden");return}if(s){const n=JSON.parse(s);if(this.removeAttribute("starting-data"),n.pricePerServe!==null||n.inBasket){t==null||t.classList.replace("hidden","active"),this.applyCurrencyDisplay(n.pricePerServe),this.inBasket=n.inBasket;return}}const a=p.getInstance(),l=a.getMemorizedPrice(r,i);if(l){requestAnimationFrame(()=>{this.applyCurrencyDisplay(l.price),a.markPriceAsDisplayed(r,i)});return}t==null||t.classList.replace("active","hidden"),this.subscriptions.push(c.recipes.fetchPricing(r,e,"DEFAULT",i).subscribe(n=>{if(n!=null&&n.price_per_serve){const u=p.getInstance();u.memorizedPrice(r,i,n.price_per_serve),requestAnimationFrame(()=>{t==null||t.classList.replace("hidden","active"),this.applyCurrencyDisplay(n.price_per_serve),u.markPriceAsDisplayed(r,i)})}}))}render(){this.recipePricing=this.querySelector(".mealz-recipe-pricing"),this.recipePricing&&(this.recipeId&&this.pricePerServe&&p.getInstance().isPriceDisplayed(this.recipeId,this.serves)&&requestAnimationFrame(()=>{this.applyCurrencyDisplay(this.pricePerServe)}),this.rendered.next(!0),this.getInitialStatus())}getInitialStatus(){var a;const e=(a=this.attributes["starting-data"])==null?void 0:a.value;if(!e)return;const{recipeId:i,pricePerServe:r,serves:t,planner:s}=JSON.parse(e);this.recipeId=i,this.pricePerServe=(r==null?void 0:r.toString())??null,this.serves=t,this.planner=s||!1,this.applyCurrencyDisplay(this.pricePerServe),this.updateDOM()}applyCurrencyDisplay(e){const i=parseFloat(e);isNaN(i)||(this.formattedPrice=i.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),this.updateDOM())}showPrice(){var r,t;const e=(r=this.recipePricing)==null?void 0:r.querySelector(".mealz-recipe-pricing__loading"),i=(t=this.recipePricing)==null?void 0:t.querySelector(".mealz-recipe-pricing__wrapper");e==null||e.classList.replace("active","hidden"),i==null||i.classList.replace("hidden","active")}updateDOM(){var i;const e=(i=this.recipePricing)==null?void 0:i.querySelector(".mealz-recipe-pricing__wrapper__price");e&&(e.innerHTML=this.formattedPrice+" €",this.showPrice())}listenToBasket(){return L([this.rendered,c.basket.recipePricesInBasket$()]).pipe(O(([e,i])=>!e||!i),g(([,e])=>B([f(e),c.pos.currentPos().pipe(y(1))])),g(([e,i])=>(this.recipePricingValue=e.find(r=>r.id===this.recipeId),this.recipePricingValue?(this.inBasket=!0,this.applyCurrencyDisplay((+this.recipePricingValue.price/this.serves).toString()),f(null)):i&&this.inBasket?c.recipes.fetchPricing(this.recipeId,i.id,"DEFAULT",this.serves).pipe($(r=>{r!=null&&r.price_per_serve&&(this.applyCurrencyDisplay(r.price_per_serve),this.inBasket=!1)})):(this.formattedPrice=this.pricePerServe,f(null))))).subscribe(()=>{this.showPrice()})}recalculatePrice(){if(this.recipePricingValue){const e=(parseFloat(this.recipePricingValue.price)/this.recipePricingValue.guests).toString();requestAnimationFrame(()=>{this.applyCurrencyDisplay(e);const i=p.getInstance();i.memorizedPrice(this.recipeId,this.recipePricingValue.guests,e),i.markPriceAsDisplayed(this.recipeId,this.recipePricingValue.guests)})}}trackPlannerRecipePrice(){this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null),this.plannerPriceSubscription=c.planner.plannerRecipePrice$.subscribe(e=>{e>0&&(this.lastPlannerPrice=e)})}updateGuestCountFromMenu(){!this.planner||!this.recipeId||c.planner.getGuestsForRecipe(this.recipeId).pipe(y(1)).subscribe(e=>{e&&e>0&&(this.serves=e)})}updatePriceFromCapturedPlannerPrice(){!this.planner||!this.recipeId||c.planner.isRecipeInMenu$(this.recipeId).pipe(y(1)).subscribe(e=>{if(e&&this.lastPlannerPrice>0){if(this.serves>0){const i=this.lastPlannerPrice/this.serves;this.applyCurrencyDisplay(i.toFixed(2))}}else this.pricePerServe&&this.applyCurrencyDisplay(this.pricePerServe)})}};S=N([D("mealz-recipe-pricing")],S);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../../assets/promotion-badge-
|
|
1
|
+
import"../../assets/promotion-badge-BwN2GpDz.js";import{N as o,m as n,k as s}from"../../assets/no-shadow-element-l9trQfcI.js";import{t as h}from"../../assets/custom-element-BhZVzxrc.js";import{n as p}from"../../assets/property-leIVgCvV.js";import{g as u,a as b}from"../../assets/price-utils-BRFZa-3D.js";import"../../assets/price-BoM226Kw.js";var z=Object.defineProperty,_=Object.getOwnPropertyDescriptor,l=(e,i,r,a)=>{for(var t=a>1?void 0:a?_(i,r):i,c=e.length-1,d;c>=0;c--)(d=e[c])&&(t=(a?d(i,r,t):d(t))||t);return a&&t&&z(i,r,t),t};let m=class extends o{constructor(){super(),this.noSupplier=n.supplier.isNoSupplier(),this.subscriptions=[],this.styleURL=new URL("./replace-item/replace-item-card/replace-item-card.css",this.getBaseURL()),this.subscriptions.push(n.replaceItem.replaceItemLoading$.subscribe(e=>{this.replaceItemLoading=e,this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}onSelectItem(e){const i={detail:{item:e},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("selectItem",i))}render(){var e,i,r,a,t,c;return s`
|
|
2
2
|
<div
|
|
3
3
|
class="
|
|
4
4
|
mealz-replace-item-card
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./replace-item-card/replace-item-card.min.js";import{N as h,v as u,m as s,D as o,k as i}from"../assets/no-shadow-element-
|
|
1
|
+
import"./replace-item-card/replace-item-card.min.js";import{N as h,v as u,m as s,D as o,k as i}from"../assets/no-shadow-element-l9trQfcI.js";import{t as g}from"../assets/custom-element-BhZVzxrc.js";import{c as _}from"../assets/capitalize-DUAqYmp4.js";import{m as b}from"../assets/merge-C-u9uFzU.js";import{m as n}from"../assets/map-C4rf5Jbc.js";import{d as v}from"../assets/debounceTime-Bo5F3ux-.js";import{f as z}from"../assets/filter-CEeE8t7I.js";import{d as S}from"../assets/distinctUntilChanged-BkBiB4M3.js";import{s as $}from"../assets/switchMap-D8q0hRYH.js";import"../assets/promotion-badge-BwN2GpDz.js";import"../assets/property-leIVgCvV.js";import"../assets/price-BoM226Kw.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/mergeMap-buGewtOo.js";import"../assets/innerFrom-CfKCbnvr.js";import"../assets/OperatorSubscriber-EGuECN6g.js";import"../assets/executeSchedule-DfyZaGAH.js";import"../assets/empty-Cv-4tfKR.js";import"../assets/from-jBe2xW5a.js";import"../assets/async-D3oCs_PQ.js";var I=Object.getOwnPropertyDescriptor,f=(e,t,c,a)=>{for(var r=a>1?void 0:a?I(t,c):t,l=e.length-1,m;l>=0;l--)(m=e[l])&&(r=m(r)||r);return r};let p=class extends h{constructor(){super(),this.addProductMode=!1,this.fromRecipeDetails=!1,this.isLoading=!1,this.subscriptions=[],this.searchString="",this.itemsWithPricesList=[],this.searchSubject=new u,this.styleURL=new URL("./replace-item/replace-item.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(this.setupSearchObservable(),s.replaceItem.basketEntryToReplace$.subscribe(e=>{this.handleToReplace(e)}),b(s.recipes.displayedRecipe$.pipe(n(e=>{var t;this.currentRecipeId=(t=e==null?void 0:e.recipe)==null?void 0:t.id,this.fromRecipeDetails=!!this.currentRecipeId})),s.replaceItem.replaceProductFromPreviewOpen$.pipe(n(e=>{this.basketEntry=e})),s.replaceItem.additionModalOpen$.pipe(n(e=>{this.addProductMode=e})),s.replaceItem.itemsWithPricesList$.pipe(n(e=>{this.itemsWithPricesList=e})),s.replaceItem.fetchingItemLoading$.pipe(n(e=>{this.isLoading=e}))).subscribe(()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}handleToReplace(e){if(this.searchString="",!e){this.basketEntry=void 0,this.ingredient=void 0,this.ignoreSelected=!1;return}this.basketEntry=e.basketEntry,this.ingredient=e.ingredient,this.ignoreSelected=e.ignoreSelected||!1,this.requestUpdate()}onClose(){s.replaceItem.replaceItemLoading$.next(void 0),s.replaceItem.basketEntryToReplace$.next(void 0)}onSearchInputChange(e){this.searchString=e.target.value,this.searchSubject.next(this.searchString)}setupSearchObservable(){return this.searchSubject.pipe(v(200),z(e=>e.length>=3),S(),$(e=>s.replaceItem.searchItem(e))).subscribe()}onSelectItem(e){var a;const t=(a=this.basketEntry)==null?void 0:a.id,c=this.fromRecipeDetails?`/recipes/${this.currentRecipeId}/shopping`:"/basket/products";s.replaceItem.onSelectItem(e.detail.item,this.searchString,()=>{this.onClose(),s.productAddition.productAdded$.next(t)},{originPath:`${c}/item-selector`,props:{}})}renderIssues(){var e,t;return i`
|
|
2
2
|
<!-- NO SUBSTITUTION PRODUCT -->
|
|
3
3
|
${!this.isLoading&&this.itemsWithPricesList.length===1&&!this.searchString?i`
|
|
4
4
|
<div class="mealz-replace-item__error">
|
package/dist/replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../../assets/promotion-badge-
|
|
1
|
+
import"../../assets/promotion-badge-BwN2GpDz.js";import{N as d,m as o,k as t}from"../../assets/no-shadow-element-l9trQfcI.js";import{t as h}from"../../assets/custom-element-BhZVzxrc.js";import{n}from"../../assets/property-leIVgCvV.js";import{g as u,a as z}from"../../assets/price-utils-BRFZa-3D.js";import"../../assets/price-BoM226Kw.js";var P=Object.defineProperty,_=Object.getOwnPropertyDescriptor,p=(a,r,l,s)=>{for(var e=s>1?void 0:s?_(r,l):r,c=a.length-1,m;c>=0;c--)(m=a[c])&&(e=(s?m(r,l,e):m(e))||e);return s&&e&&P(r,l,e),e};let i=class extends d{constructor(){super(),this.noSupplier=o.supplier.isNoSupplier(),this.styleURL=new URL("./replace-item-planner/replace-item-card-planner/replace-item-card-planner.css",this.getBaseURL())}onSelectItem(){this.itemWithPrice.status="ticked";const a={detail:{itemWithPrice:this.itemWithPrice},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("selectItem",a)),this.requestUpdate()}render(){return t`
|
|
2
2
|
<div class=" mealz-replace-item-card-planner
|
|
3
3
|
${this.itemWithPrice.status==="ticked"?"selected":""}"
|
|
4
4
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./replace-item-card-planner/replace-item-card-planner.min.js";import{N as h,v as
|
|
1
|
+
import"./replace-item-card-planner/replace-item-card-planner.min.js";import{N as h,v as d,m as i,D as o,k as a}from"../assets/no-shadow-element-l9trQfcI.js";import{c as u}from"../assets/capitalize-DUAqYmp4.js";import{t as g}from"../assets/custom-element-BhZVzxrc.js";import{m as _}from"../assets/merge-C-u9uFzU.js";import{m}from"../assets/map-C4rf5Jbc.js";import{d as b}from"../assets/debounceTime-Bo5F3ux-.js";import{f as z}from"../assets/filter-CEeE8t7I.js";import{d as v}from"../assets/distinctUntilChanged-BkBiB4M3.js";import{s as S}from"../assets/switchMap-D8q0hRYH.js";import"../assets/promotion-badge-BwN2GpDz.js";import"../assets/property-leIVgCvV.js";import"../assets/price-BoM226Kw.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/mergeMap-buGewtOo.js";import"../assets/innerFrom-CfKCbnvr.js";import"../assets/OperatorSubscriber-EGuECN6g.js";import"../assets/executeSchedule-DfyZaGAH.js";import"../assets/empty-Cv-4tfKR.js";import"../assets/from-jBe2xW5a.js";import"../assets/async-D3oCs_PQ.js";var f=Object.getOwnPropertyDescriptor,$=(e,t,s,n)=>{for(var r=n>1?void 0:n?f(t,s):t,l=e.length-1,p;l>=0;l--)(p=e[l])&&(r=p(r)||r);return r};let c=class extends h{constructor(){super(),this.isLoading=!1,this.subscriptions=[],this.searchString="",this.itemsWithPricesList=[],this.analyticsPath="/meals-planner/current",this.searchSubject=new d,this.styleURL=new URL("./replace-item-planner/replace-item-planner.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(this.setupSearchObservable(),i.planner.itemToReplace$.subscribe(e=>{this.handleToReplace(e)}),_(i.recipes.displayedRecipe$.pipe(m(e=>{var t;this.currentRecipeId=(t=e==null?void 0:e.recipe)==null?void 0:t.id})),i.planner.itemsWithPricesList$.pipe(m(e=>{this.itemsWithPricesList=e})),i.planner.fetchingItemLoading$.pipe(m(e=>{this.isLoading=e}))).subscribe(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}handleToReplace(e){if(this.searchString="",!e){this.item=void 0,this.ingredient=void 0;return}this.item=e.item,this.ingredient=e.ingredient,this.requestUpdate()}onClose(){i.planner.itemToReplace$.next(void 0)}onSearchInputChange(e){this.searchString=e.target.value,this.searchSubject.next(this.searchString)}setupSearchObservable(){return this.searchSubject.pipe(b(200),z(e=>e.length>=3),v(),S(e=>i.planner.searchItem(e,this.ingredient,this.item))).subscribe()}onSelectItem(e){this.replacedItemEvent(e.detail.itemWithPrice),i.planner.replaceProduct(e.detail.itemWithPrice),this.item=e.detail.itemWithPrice.item,this.onClose()}formatNumber(e){const t=i.user.getLanguage()||"fr";return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:2}).format(e)}renderIssues(){var e,t;return a`
|
|
2
2
|
<!-- NO SUBSTITUTION PRODUCT -->
|
|
3
3
|
${!this.isLoading&&this.itemsWithPricesList.length===1&&!this.searchString?a`
|
|
4
4
|
<div class="mealz-replace-item-planner__error">
|
|
@@ -62,7 +62,7 @@ import"./replace-item-card-planner/replace-item-card-planner.min.js";import{N as
|
|
|
62
62
|
|
|
63
63
|
<div class="mealz-replace-item-planner__product-banner">
|
|
64
64
|
<span class="mealz-replace-item-planner__banner-product-name mealz-ds-text size-s">
|
|
65
|
-
<span>${
|
|
65
|
+
<span>${u(((t=(e=this.ingredient)==null?void 0:e.attributes)==null?void 0:t.name)||"")} :</span>
|
|
66
66
|
<span class="mealz-replace-item-planner__banner-quantity mealz-ds-text weight-xxl">
|
|
67
67
|
${this.formatNumber(+((s=this.ingredient)==null?void 0:s.attributes.quantity))}
|
|
68
68
|
${(n=this.ingredient)==null?void 0:n.attributes.unit}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../assets/store-locator-
|
|
1
|
+
import"../assets/store-locator-m8sx3XDc.js";import{N as h,k as c}from"../assets/no-shadow-element-l9trQfcI.js";import{t as o}from"../assets/custom-element-BhZVzxrc.js";import{n as b}from"../assets/property-leIVgCvV.js";import"../assets/state-CccUMzBZ.js";var p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,n=(e,t,d,l)=>{for(var s=l>1?void 0:l?m(t,d):t,i=e.length-1,r;i>=0;i--)(r=e[i])&&(s=(l?r(t,d,s):r(s))||s);return l&&s&&p(t,d,s),s};let a=class extends h{constructor(){super(),this._selectedTabIndex=0,this.styleURL=new URL("./slider-tabs/slider-tabs.css",this.getBaseURL())}get selectedTabIndex(){return this._selectedTabIndex}set selectedTabIndex(e){this._selectedTabIndex!==e&&(this._selectedTabIndex=e,this.sliderElement&&this.updateSlider())}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}firstUpdated(){this.sliderElement=this.querySelector(".mealz-slider-tab__background"),this.updateSlider()}render(){return c`
|
|
2
2
|
<div class="mealz-slider-tabs">
|
|
3
3
|
${this.tabs.map((e,t)=>c`
|
|
4
4
|
<button
|