mealz-components 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{accordion-la5mVBfL.js → accordion-Ba11uzYA.js} +1 -1
- package/dist/assets/responsive-C7Qf71r3.js +1 -0
- package/dist/assets/{unsafe-html-Bv_ydUHb.js → unsafe-html-uboinnys.js} +1 -1
- package/dist/catalog/basket-preview/basket-preview.min.js +1 -1
- package/dist/catalog/catalog-list/catalog-list.css +1 -0
- package/dist/catalog/catalog-list/catalog-list.min.js +1 -1
- package/dist/catalog/catalog-load-more.min.js +1 -1
- package/dist/catalog/my-meals-button/my-meals-button.min.js +1 -1
- package/dist/drawer/drawer.css +1 -1
- package/dist/drawer/drawer.min.js +1 -1
- package/dist/drawer-view-swapper/drawer-view-swapper.min.js +1 -1
- package/dist/history-drawer/history-drawer.min.js +1 -1
- package/dist/modal/modal.css +1 -1
- package/dist/modal/modal.min.js +7 -3
- package/dist/onboarding/onboarding.css +1 -1
- package/dist/onboarding/onboarding.min.js +5 -5
- package/dist/planner/helpers/open-onboarding-modal.min.js +1 -1
- package/dist/planner/planner-abandon-modal/planner-abandon-modal.min.js +1 -1
- package/dist/planner/planner-budget-edit-modal/planner-budget-edit-modal.css +1 -1
- package/dist/planner/planner-budget-edit-modal/planner-budget-edit-modal.min.js +1 -1
- package/dist/planner/planner-budget-gauge/planner-budget-gauge.css +1 -1
- package/dist/planner/planner-budget-gauge/planner-budget-gauge.min.js +1 -1
- package/dist/planner/planner-catalog/planner-catalog.css +1 -1
- package/dist/planner/planner-catalog/planner-catalog.min.js +2 -2
- package/dist/planner/planner-current-menu/planner-current-menu.css +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-onboarding/planner-onboarding.min.js +1 -1
- package/dist/planner/planner-onboarding-modal/planner-onboarding-modal.min.js +12 -15
- package/dist/planner/planner-open-catalog-modal/planner-open-catalog-modal.min.js +1 -1
- package/dist/planner/planner-quick-menu/planner-quick-menu.css +1 -0
- package/dist/planner/planner-quick-menu/planner-quick-menu.min.js +1 -0
- package/dist/planner/planner-recipe-card/planner-recipe-card.css +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/planner-welcome-modal/planner-welcome-modal.css +1 -1
- package/dist/planner/planner-welcome-modal/planner-welcome-modal.min.js +1 -1
- package/dist/planner/to-basket-loader/to-basket-loader.min.js +2 -2
- package/dist/planner-entry/planner-entry.min.js +1 -1
- package/dist/preferences/preferences.min.js +1 -1
- package/dist/recipe-card-cta/recipe-card-cta.min.js +1 -1
- package/dist/recipe-details/recipe-details.min.js +25 -25
- package/dist/store-locator/store-locator.min.js +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{N as n,k as c}from"../../assets/no-shadow-element-Dz9jgDtr.js";import{t as m}from"../../assets/custom-element-BhZVzxrc.js";import{n as h}from"../../assets/property-Bx8Yvr4_.js";import{r as
|
|
1
|
+
import{N as n,k as c}from"../../assets/no-shadow-element-Dz9jgDtr.js";import{t as m}from"../../assets/custom-element-BhZVzxrc.js";import{n as h}from"../../assets/property-Bx8Yvr4_.js";import{r as d}from"../../assets/state-C5zM4-Pq.js";import"../../assets/mealz-sdk-E_fNZM-c.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
3
|
${this.backgroundImages.map((e,t)=>e?c`
|
|
4
4
|
<div class="mealz-to-basket-loader__background ${t===this.activeBackgroundIndex?"active":""}"
|
|
@@ -17,4 +17,4 @@ import{N as n,k as c}from"../../assets/no-shadow-element-Dz9jgDtr.js";import{t a
|
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
|
-
`}};
|
|
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 +1 @@
|
|
|
1
|
-
import{N as p}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as o}from"../assets/custom-element-BhZVzxrc.js";import{o as l}from"../planner/helpers/open-onboarding-modal.min.js";import{m as c}from"../assets/mealz-sdk-E_fNZM-c.js";import"../modal/modal.min.js";import"../assets/property-Bx8Yvr4_.js";import"../assets/unsafe-html-
|
|
1
|
+
import{N as p}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as o}from"../assets/custom-element-BhZVzxrc.js";import{o as l}from"../planner/helpers/open-onboarding-modal.min.js";import{m as c}from"../assets/mealz-sdk-E_fNZM-c.js";import"../modal/modal.min.js";import"../assets/property-Bx8Yvr4_.js";import"../assets/unsafe-html-uboinnys.js";import"../onboarding/events.min.js";import"../planner/planner-onboarding-modal/planner-onboarding-modal.min.js";import"../assets/state-C5zM4-Pq.js";import"../onboarding/analytics/onboarding-analytics.min.js";var h=Object.getOwnPropertyDescriptor,m=(t,e,r,s)=>{for(var n=s>1?void 0:s?h(e,r):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(n=a(n)||n);return n};let u=class extends p{constructor(){super(...arguments),this.minGuests=1,this.maxGuests=12,this.currentGuests=4,this.menuId=null,this.subscriptions=[]}get selectors(){return{stepperMinus:".mealz-planner-entry__stepper-button--minus",stepperPlus:".mealz-planner-entry__stepper-button--plus",stepperNumber:".mealz-planner-entry__stepper-number",helpLink:".mealz-planner-entry__help-link"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.initStartingData(),this.initGuests(),this.addEventListeners(),this.updateStepperButtons()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(t=>t.unsubscribe()),this.subscriptions=[]}initStartingData(){const t=this.getAttribute("starting-data");if(t){try{const{menuId:e}=JSON.parse(t);e&&(this.menuId=e)}catch(e){console.error("Failed to parse starting-data:",e);return}this.removeAttribute("starting-data")}}initGuests(){const t=localStorage.getItem("_mealz/planner/guests");if(t){const e=parseInt(t,10);!isNaN(e)&&e>=this.minGuests&&e<=this.maxGuests&&(this.currentGuests=e)}else{const e=this.querySelector(this.selectors.stepperNumber);if(e){const r=e.getAttribute("data-guests");if(r){const s=parseInt(r,10);!isNaN(s)&&s>=this.minGuests&&s<=this.maxGuests&&(this.currentGuests=s)}}if(this.currentGuests===4){const r=localStorage.getItem("_miam/preferences/guests");if(r){const s=parseInt(r,10);!isNaN(s)&&s>=this.minGuests&&s<=this.maxGuests&&(this.currentGuests=s)}}}this.updateGuestsDisplay()}addEventListeners(){this.addClickListener("stepperMinus",()=>this.decrementGuests()),this.addClickListener("stepperPlus",()=>this.incrementGuests()),this.querySelectorAll(this.selectors.helpLink).forEach(e=>{e.addEventListener("click",r=>{r.preventDefault(),this.openOnboarding()})})}decrementGuests(){this.currentGuests>this.minGuests&&(this.currentGuests--,this.updateGuests())}incrementGuests(){this.currentGuests<this.maxGuests&&(this.currentGuests++,this.updateGuests())}updateGuests(){if(localStorage.setItem("_mealz/planner/guests",this.currentGuests.toString()),this.updateGuestsDisplay(),this.updateStepperButtons(),this.menuId){const t={guests:this.currentGuests};this.subscriptions.push(c.planner.updateMenu(this.menuId,{attributes:{...t}}).subscribe())}this.dispatchEvent(new CustomEvent("plannerGuestsChanged",{detail:{guests:this.currentGuests},bubbles:!0,composed:!0}))}updateGuestsDisplay(){const t=this.querySelector(this.selectors.stepperNumber);t&&(t.textContent=this.currentGuests.toString(),t.setAttribute("data-guests",this.currentGuests.toString()))}updateStepperButtons(){const t=this.querySelector(this.selectors.stepperMinus),e=this.querySelector(this.selectors.stepperPlus);t&&(t.disabled=this.currentGuests<=this.minGuests),e&&(e.disabled=this.currentGuests>=this.maxGuests)}openOnboarding(){l("dashboard")}};u=m([o("mealz-planner-entry")],u);customElements.get("mealz-planner-entry")||customElements.define("mealz-planner-entry",u);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../assets/accordion-
|
|
1
|
+
import"../assets/accordion-Ba11uzYA.js";import{N as _,B as z,a as y,k as r}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as b}from"../assets/custom-element-BhZVzxrc.js";import{r as p}from"../assets/state-C5zM4-Pq.js";import{m as t}from"../assets/mealz-sdk-E_fNZM-c.js";import{d as w}from"../assets/debounceTime-D7R6Z3Am.js";import{d as T}from"../assets/distinctUntilChanged-VvZTmHoN.js";import{s as $}from"../assets/switchMap-6Z80ObHE.js";import{n as g}from"../assets/property-Bx8Yvr4_.js";import{f as k}from"../assets/filter-DQ4vwAGj.js";import"../assets/unsafe-html-uboinnys.js";import"../assets/async-D5WN8Wfc.js";import"../assets/OperatorSubscriber-DF1TYu__.js";import"../assets/innerFrom-FMZwm2mb.js";var S=Object.defineProperty,x=Object.getOwnPropertyDescriptor,m=(e,s,n,a)=>{for(var i=a>1?void 0:a?x(s,n):s,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=(a?d(s,n,i):d(i))||i);return a&&i&&S(s,n,i),i};let u=class extends _{constructor(){super(),this.suggestedTags=[],this.notFound=!1,this.searchQuery=new z(""),this.subscription=new y,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(w(250),T(),$(e=>e.length>0?t.tags.autocomplete(e):[])).subscribe(e=>{var s,n;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=((n=this.suggestedTags)==null?void 0:n.length)===0,this.requestUpdate()}))}addTag(e){t.preferences.newTagFromSearch(e),this.dispatchEvent(new CustomEvent("backAndReload"))}render(){return r`
|
|
2
2
|
<div class="mealz-preferences-search">
|
|
3
3
|
<div class="mealz-preferences-search__searchbar-container">
|
|
4
4
|
<div class="mealz-preferences-search__searchbar mealz-ds-searchbar">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as m}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as f}from"../assets/custom-element-BhZVzxrc.js";import{w as b,m as n}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as u}from"../assets/map-DHslluWD.js";import{d as c}from"../assets/distinctUntilChanged-VvZTmHoN.js";import{m as C}from"../assets/mergeAll-DTkL1sF8.js";import{f as k,p as h}from"../assets/from-BTlWkhKh.js";import{o as g}from"../assets/OperatorSubscriber-DF1TYu__.js";import{c as v}from"../assets/combineLatest-BN0_WcEG.js";import"../assets/mergeMap-g-JGW99j.js";import"../assets/innerFrom-FMZwm2mb.js";import"../assets/executeSchedule-C0acKsif.js";import"../assets/mapOneOrManyArgs-Bdu6mo6S.js";function
|
|
1
|
+
import{N as m}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as f}from"../assets/custom-element-BhZVzxrc.js";import{w as b,m as n}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as u}from"../assets/map-DHslluWD.js";import{d as c}from"../assets/distinctUntilChanged-VvZTmHoN.js";import{m as C}from"../assets/mergeAll-DTkL1sF8.js";import{f as k,p as h}from"../assets/from-BTlWkhKh.js";import{o as g}from"../assets/OperatorSubscriber-DF1TYu__.js";import{c as v}from"../assets/combineLatest-BN0_WcEG.js";import"../assets/mergeMap-g-JGW99j.js";import"../assets/innerFrom-FMZwm2mb.js";import"../assets/executeSchedule-C0acKsif.js";import"../assets/mapOneOrManyArgs-Bdu6mo6S.js";function S(){return C(1)}function d(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return S()(k(e,h(e)))}function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var s=h(e);return g(function(i,a){(s?d(e,i,s):d(e,i)).subscribe(a)})}var I=Object.getOwnPropertyDescriptor,L=(e,t,s,i)=>{for(var a=i>1?void 0:i?I(t,s):t,r=e.length-1,p;r>=0;r--)(p=e[r])&&(a=p(a)||a);return a};let l=class extends m{constructor(){super(...arguments),this.subscriptions=[],this.clickHandler=()=>{},this.recipeId="",this.status="add",this.planner=!1,this.recipeCta=null,this.guests=4,this.standalone=!1,this.inBasket=!1}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),b().then(()=>{this.setupClickHandler(),this.setupSubscriptions()}).catch(e=>{console.warn("Failed to initialize SDK subscriptions:",e)})}setupSubscriptions(){const e=n.basket.recipePricesInBasket$().pipe(u(t=>t.some(s=>s.id===this.recipeId)),c(),o(!1));this.subscriptions.push(v([n.planner.isRecipeInMenu$(this.recipeId).pipe(o(!1),c()),e]).pipe(u(([t,s])=>this.planner?s?"in-basket":t?"in-menu":"add":s?"in-basket":"add"),c()).subscribe(t=>this.updateStatus(t)))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.removeClickHandler()}render(){this.recipeCta=this.querySelector(".mealz-recipe-card-cta"),this.recipeCta&&this.updateStatus(this.status)}getInitialStatus(){const e=this.attributes.getNamedItem("starting-data"),t=(e==null?void 0:e.value)||"{}",s=JSON.parse(t);if(s){if(s.recipeId)this.recipeId=s.recipeId,this.guests=s.guests||4,this.standalone=!0,this.inBasket=s.inBasket||!1,this.planner=s.planner||!1,this.status=s.status||"add",this.updateDOM(this.inBasket);else{const i=e==null?void 0:e.value;this.recipeId=i||"",this.standalone=!1;const a=this.classList.contains("in-basket");this.updateDOM(a)}if(this.removeAttribute("starting-data"),this.planner)this.updateStatus(this.status);else{const i=this.classList.contains("in-basket");this.updateStatus(i?"in-basket":"add")}}}setupClickHandler(){this.standalone&&(this.recipeCta=this.querySelector(".mealz-recipe-card-cta"),this.recipeCta&&(this.clickHandler=()=>{n.recipes.openDetails(this.recipeId,this.guests,0,"/recipes")},this.recipeCta.addEventListener("click",this.clickHandler)))}removeClickHandler(){this.recipeCta&&this.clickHandler&&this.recipeCta.removeEventListener("click",this.clickHandler)}updateStatus(e){this.recipeCta&&(this.recipeCta.classList.remove("hidden"),this.status=e,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}updateDOM(e){const t=this.querySelector(".mealz-recipe-card-cta");t&&(t.classList.remove("hidden"),e?(t.classList.replace("primary","secondary"),t.classList.add("in-basket")):(t.classList.replace("secondary","primary"),t.classList.remove("in-basket")))}};l=L([f("mealz-recipe-card-cta")],l);customElements.get("mealz-recipe-card-cta")||customElements.define("mealz-recipe-card-cta",l);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{_ as re,n as
|
|
1
|
+
import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{_ as re,n as L,p as X,b as ne,c as le,q as oe,N as m,D as c,k as a}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as g}from"../assets/custom-element-BhZVzxrc.js";import{n as p}from"../assets/property-Bx8Yvr4_.js";import{P as ce}from"../assets/price-CHipCs2z.js";import{m as l}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as Z}from"../assets/merge-tdU3EgEI.js";import{m as h}from"../assets/map-DHslluWD.js";import{t as B}from"../assets/take-ByPtGQky.js";import{c as ee}from"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import{G as te}from"../assets/product-card-c_0I2Lp_.js";import"../price/price.min.js";import"../assets/promotion-badge-CzwsPJJq.js";import"../assets/accordion-Ba11uzYA.js";import"../store-indicator/store-indicator.min.js";import"../last-order-badge/last-order-badge.min.js";import"../order-again/order-again.min.js";import"../like-button/like-button.min.js";import{L as de}from"../last-order-modal/last-order-modal.min.js";import{a as pe}from"../assets/unsafe-html-uboinnys.js";import{M as ue}from"../planner/planner-onboarding/planner-onboarding.min.js";import{o as se,c as he}from"../assets/OperatorSubscriber-DF1TYu__.js";import{i as H}from"../assets/innerFrom-FMZwm2mb.js";import{f as Q}from"../assets/filter-DQ4vwAGj.js";import{t as z}from"../assets/tap-K_D6lo97.js";import{s as Y}from"../assets/switchMap-6Z80ObHE.js";import{c as J}from"../assets/combineLatest-BN0_WcEG.js";import{d as me}from"../assets/async-D5WN8Wfc.js";import"../assets/viewport-listener-DrFhSZNW.js";import"../assets/debounceTime-D7R6Z3Am.js";import"../assets/skipWhile-BzDgmir5.js";import"../assets/mergeAll-DTkL1sF8.js";import"../assets/mergeMap-g-JGW99j.js";import"../assets/executeSchedule-C0acKsif.js";import"../assets/empty-Bs9kqCuA.js";import"../assets/from-BTlWkhKh.js";import"../assets/delay-wUm-cx7a.js";import"../assets/timer-C3uKg-qK.js";import"../store-locator/store-locator.min.js";import"../assets/state-C5zM4-Pq.js";import"../assets/query-BApjzB0v.js";import"../onboarding/onboarding.min.js";import"../onboarding/events.min.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../assets/responsive-C7Qf71r3.js";import"../assets/mapOneOrManyArgs-Bdu6mo6S.js";var ge=function(e){re(t,e);function t(s,r,i){s===void 0&&(s=1/0),r===void 0&&(r=1/0),i===void 0&&(i=me);var n=e.call(this)||this;return n._bufferSize=s,n._windowTime=r,n._timestampProvider=i,n._buffer=[],n._infiniteTimeWindow=!0,n._infiniteTimeWindow=r===1/0,n._bufferSize=Math.max(1,s),n._windowTime=Math.max(1,r),n}return t.prototype.next=function(s){var r=this,i=r.isStopped,n=r._buffer,o=r._infiniteTimeWindow,d=r._timestampProvider,v=r._windowTime;i||(n.push(s),!o&&n.push(d.now()+v)),this._trimBuffer(),e.prototype.next.call(this,s)},t.prototype._subscribe=function(s){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(s),i=this,n=i._infiniteTimeWindow,o=i._buffer,d=o.slice(),v=0;v<d.length&&!s.closed;v+=n?1:2)s.next(d[v]);return this._checkFinalizedStatuses(s),r},t.prototype._trimBuffer=function(){var s=this,r=s._bufferSize,i=s._timestampProvider,n=s._buffer,o=s._infiniteTimeWindow,d=(o?1:2)*r;if(r<1/0&&d<n.length&&n.splice(0,n.length-d),!o){for(var v=i.now(),k=0,u=1;u<n.length&&n[u]<=v;u+=2)k=u;k&&n.splice(0,k+1)}},t}(L);function ve(e){e===void 0&&(e={});var t=e.connector,s=t===void 0?function(){return new L}:t,r=e.resetOnError,i=r===void 0?!0:r,n=e.resetOnComplete,o=n===void 0?!0:n,d=e.resetOnRefCountZero,v=d===void 0?!0:d;return function(k){var u,f,I,T=0,S=!1,x=!1,C=function(){f==null||f.unsubscribe(),f=void 0},D=function(){C(),u=I=void 0,S=x=!1},ae=function(){var P=u;D(),P==null||P.unsubscribe()};return se(function(P,K){T++,!x&&!S&&C();var R=I=I??s();K.add(function(){T--,T===0&&!x&&!S&&(f=A(ae,v))}),R.subscribe(K),!u&&T>0&&(u=new X({next:function(O){return R.next(O)},error:function(O){x=!0,C(),f=A(D,i,O),R.error(O)},complete:function(){S=!0,C(),f=A(D,o),R.complete()}}),H(P).subscribe(u))})(k)}}function A(e,t){for(var s=[],r=2;r<arguments.length;r++)s[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var i=new X({next:function(){i.unsubscribe(),e()}});return H(t.apply(void 0,ne([],le(s)))).subscribe(i)}}function be(e,t,s){var r,i=!1;return r=e,ve({connector:function(){return new ge(r,t,s)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}function w(e){return se(function(t,s){H(e).subscribe(he(s,function(){return s.complete()},oe)),!s.closed&&t.subscribe(s)})}var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,y=(e,t,s,r)=>{for(var i=r>1?void 0:r?fe(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=(r?o(t,s,i):o(i))||i);return r&&i&&_e(t,s,i),i};let b=class extends m{constructor(){super(),this.noPosDisplay=!1,this.noSupplier=!1,this.recipeId="",this.plannerMode=!1,this.guests=0,this.recipe=null,this.analyticsPath="",this.subscriptions=[],this.remainingBasketEntries=[],this.recipePrice={remaining:0,inBasket:0,total:0,totalPerGuest:0},this.priceService=ce.getInstance(),this.allIngredientsToBasketLoading=!1,this.ingredientToBasketLoading=!1,this.updateIngredientFromBasketLoading=!1,this.productsLoading=!1,this.inMenu=!1,this.menuUpdateLoading=!1,this.styleURL=new URL("./recipe-details/details-footer/details-footer.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.priceService.initFormatter(),this.analyticsPath=`/recipes/${this.recipeId}/shopping`,this.subscriptions.push(Z(l.recipes.remainingBasketEntries$.pipe(h(e=>{this.remainingBasketEntries=e})),l.recipes.recipePrice$.pipe(h(e=>{const t=e.remaining+e.inBasket;this.recipePrice={...e,total:t,totalPerGuest:0}})),l.recipes.allIngredientsToBasketLoading$.pipe(h(e=>{this.allIngredientsToBasketLoading=e})),l.recipes.ingredientToBasketLoading$.pipe(h(e=>{this.ingredientToBasketLoading=e})),l.recipes.updateIngredientFromBasketLoading$.pipe(h(e=>{this.updateIngredientFromBasketLoading=e})),l.recipes.productsLoading$.pipe(h(e=>{this.productsLoading=e})),l.planner.plannerRecipePrice$.pipe(h(e=>{this.recipePrice.totalPerGuest=this.guests>0?e/this.guests:e}))).subscribe(()=>this.requestUpdate())),this.subscribeIsRecipeInMenu()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.isRecipeInMenuSub&&(this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=void 0)}updated(e){super.updated(e),e.has("recipeId")&&this.subscribeIsRecipeInMenu()}subscribeIsRecipeInMenu(){this.recipeId&&(this.isRecipeInMenuSub&&this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=l.planner.isRecipeInMenu$(this.recipeId).pipe(h(e=>{this.inMenu=e})).subscribe(()=>this.requestUpdate()))}closeRecipeDetails(e=!1){l.recipes.displayedRecipe$.next(null),e&&l.basket.basketPreviewState$.next({isOpen:!0,activeTabIndex:l.basket.basketPreviewState$.getValue().activeTabIndex})}continueShopping(){this.closeRecipeDetails(),this.sendContinueEvent()}addToMenu(){var r,i;this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion"),t=!!e&&!!e.recipeId&&e.recipeId===this.recipeId,s=document.querySelector("mealz-planner-current-menu");if(!s){const n=(i=(r=l.recipes)==null?void 0:r.productsPlannerByCategory$)==null?void 0:i.value,o=(n==null?void 0:n.toPickProducts)||[];l.planner.addRecipeToMenu(this.recipeId,this.guests,!!l.pos.currentPos().value,o).pipe(B(1)).subscribe(()=>{this.inMenu=!0;const d=document.querySelector("mealz-planner-recipe-list");d==null||d.addRecipeCardToList(this.recipeId),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()});return}if(t){e.addRecipeFromDetails$(this.guests).subscribe({next:()=>{this.inMenu=!0,this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}});return}s.addRecipe(this.recipeId,this.guests).pipe(B(1)).subscribe({next:()=>{this.inMenu=!0,e==null||e.addAndSelectNewSuggestion(this.recipe||void 0),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}})}removeFromMenu(){this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){l.planner.removeRecipeFromMenu(this.recipeId).pipe(B(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(){l.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),this.sendAddAllEvent(),this.recipePrice.inBasket===0&&this.sendAddRecipeEvent()}render(){if(this.noPosDisplay&&!this.plannerMode)return c;const e=this.remainingBasketEntries.length>0&&!this.plannerMode,t=this.plannerMode&&this.noPosDisplay,s=this.plannerMode&&!this.inMenu;return a`
|
|
2
2
|
<div class="mealz-recipe-details__footer">
|
|
3
3
|
${this.productsLoading&&!this.plannerMode?c:a`
|
|
4
4
|
<!-- ADD TO BASKET CTA -->
|
|
5
|
-
${e||t||
|
|
5
|
+
${e||t||s?this.renderAddToBasketButton():a`
|
|
6
6
|
<div class="mealz-recipe-details__recipe-is-in-basket-cta-container">
|
|
7
7
|
${this.renderBasketActions()}
|
|
8
8
|
</div>
|
|
@@ -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(){l.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){l.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){l.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};y([p({type:Boolean})],b.prototype,"noPosDisplay",2);y([p({type:Boolean})],b.prototype,"noSupplier",2);y([p({type:String})],b.prototype,"recipeId",2);y([p({type:Boolean})],b.prototype,"plannerMode",2);y([p({type:Number})],b.prototype,"guests",2);y([p({attribute:!1})],b.prototype,"recipe",2);b=y([g("mealz-details-footer")],b);customElements.get("mealz-details-footer")||customElements.define("mealz-details-footer",b);var ze=Object.getOwnPropertyDescriptor,ye=(e,t,
|
|
94
|
+
`}sendAddAllEvent(){l.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){l.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){l.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};y([p({type:Boolean})],b.prototype,"noPosDisplay",2);y([p({type:Boolean})],b.prototype,"noSupplier",2);y([p({type:String})],b.prototype,"recipeId",2);y([p({type:Boolean})],b.prototype,"plannerMode",2);y([p({type:Number})],b.prototype,"guests",2);y([p({attribute:!1})],b.prototype,"recipe",2);b=y([g("mealz-details-footer")],b);customElements.get("mealz-details-footer")||customElements.define("mealz-details-footer",b);var ze=Object.getOwnPropertyDescriptor,ye=(e,t,s,r)=>{for(var i=r>1?void 0:r?ze(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=o(i)||i);return i};let N=class extends m{constructor(){super(),this.tags=[],this.displayTags=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-infos/details-infos.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(l.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 a`<span class="mealz-recipe-details-infos__no-time-placeholder">0 min</span>`}noDataPlaceholder(){return a`<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 a`<span class="mealz-ds-text">Facile</span>`;case 2:return a`<span class="mealz-ds-text">Moyen</span>`;case 3:return a`<span class="mealz-ds-text">Difficile</span>`;default:return c}}renderPreparationTime(){return a`
|
|
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
|
-
`}};
|
|
160
|
+
`}};N=ye([g("mealz-details-infos")],N);customElements.get("mealz-details-infos")||customElements.define("mealz-details-infos",N);var $e=Object.getOwnPropertyDescriptor,ke=(e,t,s,r)=>{for(var i=r>1?void 0:r?$e(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=o(i)||i);return i};let q=class extends m{constructor(){super(),this.steps=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-steps/details-steps.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(l.recipes.displayedRecipe$.subscribe(e=>{e&&(this.steps=e.recipe.relationships["recipe-steps"].data.sort((t,s)=>t.attributes["step-number"]-s.attributes["step-number"]).map(t=>t.attributes.description),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){return a`
|
|
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
|
-
`}};
|
|
183
|
+
`}};q=ke([g("mealz-details-steps")],q);customElements.get("mealz-details-steps")||customElements.define("mealz-details-steps",q);var Ie=Object.getOwnPropertyDescriptor,Pe=(e,t,s,r)=>{for(var i=r>1?void 0:r?Ie(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=o(i)||i);return i};let G=class extends m{constructor(){super(),this.ingredients=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-ingredients/details-ingredients.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(l.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 a`
|
|
184
184
|
<div class="mealz-details-ingredients">
|
|
185
185
|
<!-- HEADER -->
|
|
186
186
|
<div class="mealz-ds-text weight-xxl mealz-details-ingredients__header">
|
|
@@ -189,30 +189,30 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
189
189
|
</div>
|
|
190
190
|
<!-- LIST -->
|
|
191
191
|
<div class="mealz-details-ingredients__list">
|
|
192
|
-
${this.ingredients.map(
|
|
192
|
+
${this.ingredients.map(s=>a`
|
|
193
193
|
<div class="mealz-details-ingredients__item">
|
|
194
194
|
<!-- PICTURE -->
|
|
195
195
|
<div class="mealz-ds-avatar mealz-details-ingredients__picture_container">
|
|
196
196
|
<img class="mealz-details-ingredients__picture"
|
|
197
|
-
src="${this.ingredientPicture(
|
|
198
|
-
alt="${
|
|
197
|
+
src="${this.ingredientPicture(s)}"
|
|
198
|
+
alt="${s.attributes.name} picture">
|
|
199
199
|
</div>
|
|
200
200
|
<!-- NAME -->
|
|
201
201
|
<span class="mealz-ds-text size-s weight-xxl mealz-details-ingredients__name">
|
|
202
|
-
${ee(
|
|
202
|
+
${ee(s.attributes.name)}
|
|
203
203
|
</span>
|
|
204
204
|
<!-- QUANTITY -->
|
|
205
205
|
<div class="mealz-ds-text size-s weight-l mealz-details-ingredients__row__qty">
|
|
206
|
-
${
|
|
206
|
+
${s.attributes.quantity} ${s.attributes.unit}
|
|
207
207
|
</div>
|
|
208
208
|
</div>
|
|
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"}};
|
|
212
|
+
`}ingredientPicture(e){return e.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}};G=Pe([g("mealz-details-ingredients")],G);customElements.get("mealz-details-ingredients")||customElements.define("mealz-details-ingredients",G);var Ee=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,$=(e,t,s,r)=>{for(var i=r>1?void 0:r?Te(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=(r?o(t,s,i):o(i))||i);return r&&i&&Ee(t,s,i),i};const M=["unavailable"],Se=["ticked","unselected"];let _=class extends m{constructor(){super(),this.subscriptions=[],this.guestObserverService=te.getInstance(),this.modifiedIngQty=0,this.analyticsPath="/meals-planner/current",this.styleURL=new URL("./product-card/product-card-planner.css",this.getBaseURL())}get status(){var e;return(e=this.product)==null?void 0:e.status}set status(e){this.product.status=e,this.requestUpdate()}get productImage(){var e;return((e=this.product.item)==null?void 0:e.attributes.image)||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get ingredientPicture(){return this.product.ingredient.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get isSponsored(){var e,t,s;return((s=(t=(e=this.product)==null?void 0:e.item)==null?void 0:t.attributes)==null?void 0:s.sponsored)===!0}connectedCallback(){super.connectedCallback(),this.listenGuestsChange(),this.calculateQty()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenGuestsChange(){this.subscriptions.push(this.guestObserverService.guests$.subscribe(e=>{this.currentGuests=e,this.calculateQty()}))}calculateQty(){const e=this.product.ingredient.attributes.quantity/this.initialGuests;this.modifiedIngQty=Number((e*this.currentGuests).toFixed(2)),this.requestUpdate()}openReplaceItemView(){l.planner.openReplaceItemView(this.product),this.replaceItemViewEvent()}onCheckboxChange(e){e.target.checked?(this.status="ticked",l.planner.selectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.addItemEvent()):(this.status="unselected",l.planner.unselectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.deleteItemEvent()),this.requestUpdate()}render(){return a`
|
|
213
213
|
<div class="mealz-product-card-planner
|
|
214
214
|
${this.status==="ticked"?"added":""}
|
|
215
|
-
${
|
|
215
|
+
${M.includes(this.status)||this.oftenIgnored?"disabled":""}
|
|
216
216
|
${this.status==="unavailable"?"unavailable":""}"
|
|
217
217
|
>
|
|
218
218
|
${this.renderHeader()}
|
|
@@ -267,7 +267,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
267
267
|
class="
|
|
268
268
|
mealz-product-card-planner__header-name
|
|
269
269
|
mealz-ds-text weight-xl
|
|
270
|
-
${
|
|
270
|
+
${M.includes(this.status)||this.oftenIgnored?"mealz-product-card-planner__disabled-text":""}"
|
|
271
271
|
>
|
|
272
272
|
${ee(this.product.ingredient.attributes.name)}
|
|
273
273
|
</span>
|
|
@@ -275,7 +275,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
275
275
|
class="
|
|
276
276
|
mealz-product-card-planner__header-quantity
|
|
277
277
|
mealz-ds-text size-s weight-l
|
|
278
|
-
${
|
|
278
|
+
${M.includes(this.status)||this.oftenIgnored?"mealz-product-card-planner__disabled-text":""}"
|
|
279
279
|
>
|
|
280
280
|
<span>${this.modifiedIngQty?this.modifiedIngQty:this.product.ingredient.attributes.quantity}</span>
|
|
281
281
|
<span>${this.product.ingredient.attributes.unit}</span>
|
|
@@ -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(){l.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){l.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){l.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};$([p({type:Object})],_.prototype,"product",2);$([p({type:String})],_.prototype,"recipeId",2);$([p({type:Number})],_.prototype,"initialGuests",2);$([p({type:Number})],_.prototype,"currentGuests",2);$([p({type:Boolean})],_.prototype,"oftenIgnored",2);_=$([g("mealz-product-card-planner")],_);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",_);var
|
|
321
|
+
`}addItemEvent(){l.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){l.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){l.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};$([p({type:Object})],_.prototype,"product",2);$([p({type:String})],_.prototype,"recipeId",2);$([p({type:Number})],_.prototype,"initialGuests",2);$([p({type:Number})],_.prototype,"currentGuests",2);$([p({type:Boolean})],_.prototype,"oftenIgnored",2);_=$([g("mealz-product-card-planner")],_);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",_);var xe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ie=(e,t,s,r)=>{for(var i=r>1?void 0:r?Ce(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=(r?o(t,s,i):o(i))||i);return r&&i&&xe(t,s,i),i};let U=class extends m{constructor(){super(),this.styleURL=new URL("./legal-notice/legal-notice.css",this.getBaseURL())}get containsAlcohol(){var t;return(((t=this.tags)==null?void 0:t.data)||[]).some(s=>s.id==="ingredient_category_alcool")}render(){return this.containsAlcohol?a`
|
|
322
322
|
<div class="mealz-products-picker__legal-notices">
|
|
323
323
|
<span class="mealz-ds-text weight-xxl mealz-products-picker__legal-notices-header">Mentions légales</span>
|
|
324
324
|
<div class="mealz-products-picker__legal-notices-content">
|
|
@@ -330,7 +330,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
330
330
|
</span>
|
|
331
331
|
</div>
|
|
332
332
|
</div>
|
|
333
|
-
`:c}};ie([p()],
|
|
333
|
+
`:c}};ie([p()],U.prototype,"tags",2);U=ie([g("mealz-legal-notice")],U);customElements.get("mealz-legal-notice")||customElements.define("mealz-legal-notice",U);var Re=Object.getOwnPropertyDescriptor,Oe=(e,t,s,r)=>{for(var i=r>1?void 0:r?Re(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=o(i)||i);return i};let F=class extends m{constructor(){super(),this.styleURL=[new URL("./product-card/product-card-skeleton/product-card-skeleton.css",this.getBaseURL()),new URL("./product-card/product-card.css",this.getBaseURL())]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}render(){return a`
|
|
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
|
-
`}};
|
|
376
|
+
`}};F=Oe([g("mealz-products-card-skeleton")],F);customElements.get("mealz-products-card-skeleton")||customElements.define("mealz-products-card-skeleton",F);var we=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,W=(e,t,s,r)=>{for(var i=r>1?void 0:r?Le(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=(r?o(t,s,i):o(i))||i);return r&&i&&we(t,s,i),i};let E=class extends m{constructor(){super(),this.inBasket=!1,this.plannerMode=!1,this.numberUnavailableProducts=0,this.subscriptions=[],this.noSupplier=l.supplier.isNoSupplier(),this.hasEmittedReady=!1,this.styleURL=new URL("./products-picker/products-picker.css",this.getBaseURL())}get totalProducts(){return this.recipe.relationships.ingredients.data.length}connectedCallback(){super.connectedCallback(),this.resetProducts(),this.listenToProducts(),this.subscriptions.push(l.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?l.recipes.productsPlannerByCategory$:l.recipes.productsByCategory$;this.subscriptions.push(e.subscribe(t=>{this.productsByCategory=t,this.plannerMode?this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.status==="unavailable").length:this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.basketEntry.status==="out_of_stock").length,this.requestUpdate(),this.notifyReadyIfRendered()}))}async notifyReadyIfRendered(){if(this.hasEmittedReady)return;if(await this.updateComplete,this.querySelector(".mealz-product-card-planner__checkbox")||this.querySelector(".mealz-product-card__checkbox")){this.hasEmittedReady=!0;const t=new CustomEvent("products-picker-ready",{bubbles:!0,composed:!0});this.dispatchEvent(t)}}scrollToFirstUnavailable(){const e=document.querySelector(this.plannerMode?".mealz-products-picker":".mealz-products-picker__container");if(e){const t=e.querySelector(this.plannerMode?".mealz-product-card-planner.unavailable":".mealz-product-card__container.out_of_stock");t&&t.scrollIntoView({behavior:"smooth",block:"center"})}}isAlreadyOnCatalogPage(){return window.location.href.includes(l.router.getCatalogUrl())}closeRecipeModal(){}currentPath(){return""}guestsChange(e){const t=new CustomEvent("guestChange",{bubbles:!0,composed:!0,detail:{value:e.detail.value}});this.dispatchEvent(t)}render(){var e,t,s;return a`
|
|
377
377
|
<div class="mealz-products-picker">
|
|
378
378
|
${this.inBasket&&this.plannerMode?a`
|
|
379
379
|
<div class="mealz-products-picker__overlay">
|
|
@@ -388,12 +388,12 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
388
388
|
${this.renderHeader()}
|
|
389
389
|
<div class="mealz-products-picker__list">
|
|
390
390
|
<!-- TO PICK PRODUCTS -->
|
|
391
|
-
${((e=this.productsByCategory)==null?void 0:e.toPickProducts.length)>0?this.productsByCategory.toPickProducts.map(r=>{var
|
|
391
|
+
${((e=this.productsByCategory)==null?void 0:e.toPickProducts.length)>0?this.productsByCategory.toPickProducts.map(r=>{var i,n,o,d;return this.plannerMode?a`
|
|
392
392
|
<mealz-product-card-planner
|
|
393
393
|
.product="${r}"
|
|
394
394
|
.recipeId="${this.recipe.id}"
|
|
395
395
|
.oftenIgnored="${!1}"
|
|
396
|
-
.initialGuests="${((
|
|
396
|
+
.initialGuests="${((i=this.recipe)==null?void 0:i.attributes["number-of-guests"])||4}"
|
|
397
397
|
.currentGuests="${this.recipe.modifiedGuests||((n=this.recipe)==null?void 0:n.attributes["number-of-guests"])||4}"
|
|
398
398
|
></mealz-product-card-planner>
|
|
399
399
|
`:a`
|
|
@@ -409,7 +409,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
409
409
|
</div>
|
|
410
410
|
<!-- OFTEN IGNORED PRODUCTS -->
|
|
411
411
|
<div class="mealz-products-picker__secondary-list">
|
|
412
|
-
${((
|
|
412
|
+
${((s=(t=this.productsByCategory)==null?void 0:t.oftenIgnoredProducts)==null?void 0:s.length)>0?a`
|
|
413
413
|
<mealz-accordion
|
|
414
414
|
.noStyling=${!0}
|
|
415
415
|
.titleSlot=${a`
|
|
@@ -419,12 +419,12 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
419
419
|
`}
|
|
420
420
|
.contentSlot=${a`
|
|
421
421
|
<div class="mealz-products-picker__list">
|
|
422
|
-
${this.productsByCategory.oftenIgnoredProducts.map(r=>{var
|
|
422
|
+
${this.productsByCategory.oftenIgnoredProducts.map(r=>{var i,n,o,d;return this.plannerMode?a`
|
|
423
423
|
<mealz-product-card-planner
|
|
424
424
|
.product=${r}
|
|
425
425
|
.recipeId=${this.recipe.id}
|
|
426
426
|
.oftenIgnored=${!0}
|
|
427
|
-
.initialGuests=${((
|
|
427
|
+
.initialGuests=${((i=this.recipe)==null?void 0:i.attributes["number-of-guests"])||4}
|
|
428
428
|
.currentGuests=${this.recipe.modifiedGuests||((n=this.recipe)==null?void 0:n.attributes["number-of-guests"])||4}
|
|
429
429
|
></mealz-product-card-planner>
|
|
430
430
|
`:a`
|
|
@@ -496,7 +496,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
496
496
|
`}
|
|
497
497
|
</div>
|
|
498
498
|
<mealz-legal-notice .tags="${this.recipe.relationships.tags}"></mealz-legal-notice>
|
|
499
|
-
`}sendHomeDisplayEvent(){l.analytics.sendEvent("home.display",this.analyticsPath,{})}};
|
|
499
|
+
`}sendHomeDisplayEvent(){l.analytics.sendEvent("home.display",this.analyticsPath,{})}};W([p({type:Boolean})],E.prototype,"inBasket",2);W([p({type:Boolean})],E.prototype,"plannerMode",2);E=W([g("mealz-products-picker")],E);customElements.get("mealz-products-picker")||customElements.define("mealz-products-picker",E);var Ue=Object.getOwnPropertyDescriptor,De=(e,t,s,r)=>{for(var i=r>1?void 0:r?Ue(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=o(i)||i);return i};let j=class extends m{constructor(){super(),this.invalidPos=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/no-pos-selected/no-pos-selected.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenIfPosInvalid()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenIfPosInvalid(){this.subscriptions.push(l.recipes.invalidPosDisplay$.subscribe(e=>{this.invalidPos=e,this.requestUpdate()}))}callPosSelector(){const e=new CustomEvent("posSelected",{bubbles:!0,composed:!0});this.dispatchEvent(e)}openStoreLocator(){window.mealzInternal.noSupplier.displaySupplierSelector$.next(!0)}render(){return a`
|
|
500
500
|
<div class="mealz-no-pos-selected">
|
|
501
501
|
${this.invalidPos?a`
|
|
502
502
|
<!-- INVALID POS -->
|
|
@@ -536,7 +536,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
536
536
|
Sélectionner un magasin
|
|
537
537
|
</button>
|
|
538
538
|
</div>
|
|
539
|
-
`}};
|
|
539
|
+
`}};j=De([g("mealz-no-pos-selected")],j);customElements.get("mealz-no-pos-selected")||customElements.define("mealz-no-pos-selected",j);var Be=Object.getOwnPropertyDescriptor,Ae=(e,t,s,r)=>{for(var i=r>1?void 0:r?Be(t,s):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(i=o(i)||i);return i};let V=class extends m{constructor(){super(),this.activeTabIndex=0,this.destroy$=new L,this.remainingBasketEntries=[],this.guestObserverService=te.getInstance(),this.isSticky=!1,this.styleURL=new URL("./recipe-details/recipe-details.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.destroy$=new L,this.handleNoSupplierMode(),Z(l.recipes.displayedRecipe$.pipe(w(this.destroy$),Q(e=>!!e),z(e=>{e.recipe!==null&&(this.recipe=e.recipe,this.sponsor=e.recipe.relationships.sponsors.data[0],this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.plannerMode=!!e.planner,this.getLikeButton(),this.checkSponsorStorytelling(),this.pageview(),this.listenToCloseEvent(),this.setStickyObserver())}),Y(e=>e.recipe===null?[]:this.listenToRecipeInBasket())),this.listenPosStatus(),this.listenRemainingBasketEntries(),this.listenLastOrderDate(),this.listenToLoadingStates(),this.listenToAddAllToBasket()).pipe(w(this.destroy$)).subscribe({next:()=>this.requestUpdate(),error:e=>console.error("Recipe details error:",e)}),this.addEventListener("products-picker-ready",()=>this.startRecipeDetailsOnboardingIfNeeded())}disconnectedCallback(){super.disconnectedCallback(),this.destroy$.next(),this.destroy$.complete(),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 s=!t.isIntersecting;this.isSticky!==s&&(this.isSticky=s,this.requestUpdate())},150)},{threshold:0}),this.topObserver.observe(e))})}startRecipeDetailsOnboardingIfNeeded(){localStorage.getItem("_miam/recipeDetailsOnboarding")==="true"||!this.plannerMode||this.updateComplete.then(()=>{this.scrollJustAfterImage();let t=document.querySelector("mealz-planner-onboarding");t?t.type="recipe-details":(t=new ue,t.type="recipe-details",document.body.appendChild(t)),t.launchOnboardingTour()})}scrollJustAfterImage(){const e=this.querySelector(".mealz-recipe-details__tabs");if(!e)return;const t=document.querySelector(".mealz-drawer__content-container");if(t){const s=e.getBoundingClientRect(),r=t.getBoundingClientRect();t.scrollTop+=s.top-r.top;return}e.scrollIntoView({behavior:"smooth",block:"start"})}handleNoSupplierMode(){this.noSupplier=!!l.supplier.isNoSupplier(),this.requestUpdate()}close(){this.sendCloseEvent(),l.recipes.displayedRecipe$.next(null)}listenToCloseEvent(){const e=document.querySelector("mealz-drawer");e&&e.addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}selectTab(e){this.activeTabIndex=e,this.activeTabIndex===1&&this.sendCookingDisplayEvent(),this.requestUpdate()}getLikeButton(){this.noSupplier||l.user.isAuthenticated().pipe(w(this.destroy$),Q(e=>e),Y(()=>l.html.like(this.recipe.id))).subscribe({next:e=>{this.likeButtonHTML=e,this.requestUpdate()},error:e=>console.error("Like button error:",e)})}checkSponsorStorytelling(){this.sponsor&&l.sponsor.hasStorytelling(this.sponsor.id).pipe(w(this.destroy$)).subscribe({next:e=>{this.hasSponsorStorytelling=e,this.requestUpdate()},error:e=>console.error("Sponsor storytelling error:",e)})}listenPosStatus(){return J({noPosDisplay:l.recipes.noPosDisplay$,invalidPosDisplay:l.recipes.invalidPosDisplay$}).pipe(z(({noPosDisplay:e,invalidPosDisplay:t})=>{this.noPosDisplay=e,this.invalidPosDisplay=t,this.activeTabIndex=e?1:0}),h(()=>{}))}listenLastOrderDate(){return l.recipes.orderHistoryDate$.pipe(z(e=>{this.orderHistoryDate=e}))}listenToLoadingStates(){return J([l.recipes.ingredientToBasketLoading$,l.recipes.updateIngredientFromBasketLoading$]).pipe(h(([e,t])=>e||t),z(e=>{this.basketIsUpdating=e}),be(1))}listenRemainingBasketEntries(){return l.recipes.remainingBasketEntries$.pipe(z(e=>{this.remainingBasketEntries=e}))}listenToAddAllToBasket(){return l.recipes.allIngredientsToBasketLoading$.pipe(z(e=>{e&&(this.selectTab(0),setTimeout(()=>{this.scrollToPicker()},50))}))}listenToRecipeInBasket(){return l.recipes.isRecipeInBasket(this.recipe.id).pipe(z(e=>{this.inBasket=e}))}scrollToPicker(){const e=this.querySelector(".mealz-products-picker");if(e){const t=this.querySelector(".mealz-recipe-details__title-container"),s=(t==null?void 0:t.offsetHeight)||0;e.style.scrollMarginTop=`${s}px`,e.scrollIntoView({behavior:"instant",block:"start"})}}scrollToReplacedItem(e){var s,r;const t=this.querySelectorAll("mealz-product-card-planner");for(const i of Array.from(t)){const n=i;if(((r=(s=n.product)==null?void 0:s.item)==null?void 0:r.id)===e){n.scrollIntoView({behavior:"instant",block:"center"});break}}}openLastOrderModal(){this.sendOrderedDisplayEvent();const e=new de;e.recipeId=this.recipe.id,e.addEventListener("orderAgain",()=>this.orderAgain()),e.displayLastOrderModal(this.orderHistoryDate)}orderAgain(){l.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?l.planner.updateGuests(this.recipe.modifiedGuests,t):l.recipes.updateGuests(t),this.requestUpdate()}render(){return a`
|
|
540
540
|
<div class="mealz-recipe-details">
|
|
541
541
|
<!-- IF IS LOADING -->
|
|
542
542
|
${this.recipe?c:a`
|
|
@@ -704,4 +704,4 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
|
|
|
704
704
|
</div>
|
|
705
705
|
`:c}
|
|
706
706
|
</div>
|
|
707
|
-
`}showRecipeAddon(){this.sendSponsorDisplayEvent();const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!0)}pageview(){l.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){l.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){l.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){l.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){l.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};
|
|
707
|
+
`}showRecipeAddon(){this.sendSponsorDisplayEvent();const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!0)}pageview(){l.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){l.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){l.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){l.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){l.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};V=Ae([g("mealz-recipe-details")],V);customElements.get("mealz-recipe-details")||customElements.define("mealz-recipe-details",V);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{N as u,k as a}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as m}from"../assets/custom-element-BhZVzxrc.js";import{n as c}from"../assets/property-Bx8Yvr4_.js";import{r as _}from"../assets/state-C5zM4-Pq.js";import{e as p}from"../assets/query-BApjzB0v.js";import{a as h}from"../assets/mealz-sdk-E_fNZM-c.js";class
|
|
1
|
+
import{N as u,k as a}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as m}from"../assets/custom-element-BhZVzxrc.js";import{n as c}from"../assets/property-Bx8Yvr4_.js";import{r as _}from"../assets/state-C5zM4-Pq.js";import{e as p}from"../assets/query-BApjzB0v.js";import{a as h}from"../assets/mealz-sdk-E_fNZM-c.js";class f{get extId(){return this.attributes["ext-id"]}}var g=Object.defineProperty,b=Object.getOwnPropertyDescriptor,l=(t,e,s,i)=>{for(var o=i>1?void 0:i?b(e,s):e,n=t.length-1,d;n>=0;n--)(d=t[n])&&(o=(i?d(e,s,o):d(o))||o);return i&&o&&g(e,s,o),o};let r=class extends u{constructor(){var t,e,s,i,o,n;super(),this.selectedRadius=50,this.getByAddress=(e=(t=h)==null?void 0:t.pos)==null?void 0:e.getByAddress,this.getByCoordinates=(i=(s=h)==null?void 0:s.pos)==null?void 0:i.getByCoordinates,this.getAffiliateSuppliers=(n=(o=h)==null?void 0:o.supplier)==null?void 0:n.getAffiliateSuppliers,this._show=!1,this._posList=[],this._suppliers=[],this._markers=[],this._searchingPos=!1,this._searchSubmitted=!1,this._prevAddress="",this._selectedSuppliers=[],this._showPosList=!1,this._posSelected=!1,this.subscriptions=[],this.styleURL=new URL("/store-locator.css",import.meta.url)}get show(){return this._show}set show(t){this._show=t,this._show&&(this._posSelected=!1,this.initialSearch(),this._map&&this.ensureMapSize())}set geolocationCoordinates(t){var e,s;this._geolocationCoordinates=t,typeof((e=t==null?void 0:t.coords)==null?void 0:e.latitude)=="number"&&typeof((s=t==null?void 0:t.coords)==null?void 0:s.longitude)=="number"&&this.setGeolocation()}get geolocationCoordinates(){return this._geolocationCoordinates}getMapContainer(){var e;const t=this._mapElement??((e=this.querySelector)==null?void 0:e.call(this,"#mealz-store-locator__map"));return t instanceof HTMLElement?t:null}_nameOfStore(t){return`${t.supplier.attributes.name} - ${t.attributes.name}`}connectedCallback(){super.connectedCallback(),this.initLeaflet(),this.initEvents(),this.initResizeObserver()}disconnectedCallback(){var t,e,s;this.subscriptions.forEach(i=>i.unsubscribe()),this._resizeObserver&&this._resizeObserver.disconnect(),super.disconnectedCallback(),this._map&&(this._map.off(),this._map.remove(),this._map=void 0),(t=this._leafletCss)==null||t.remove(),(e=this._miamDs)==null||e.remove(),(s=this._leafletJs)==null||s.remove()}firstUpdated(){this._posSelected=!1,this.loadMap(),this.geolocationTimeout(),this.listenFormSubmit(),this._map&&this.ensureMapSize()}render(){return this.show?this.posSelectionTemplate():a``}posSelectionTemplate(){return a`
|
|
2
2
|
<div class="mealz-store-locator mealz-ds-body">
|
|
3
3
|
<div class="mealz-store-locator__pos-selection">
|
|
4
4
|
<button
|
|
@@ -53,7 +53,7 @@ import{N as u,k as a}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as m
|
|
|
53
53
|
<b>Aucun magasin trouvé à proximité.</b>
|
|
54
54
|
<span>Essayez une autre adresse.</span>
|
|
55
55
|
</div>
|
|
56
|
-
`;if(this._posList.length<1)return
|
|
56
|
+
`;if(this._posList.length<1)return a``;const t=document.querySelector(".mealz-store-locator__pos-selection");return t&&t.classList.toggle("mealz-store-locator__pos-selection__height",this._showPosList),a`
|
|
57
57
|
<div id="mealz-store-locator__pos-list"
|
|
58
58
|
class="${this._showPosList?"mealz-store-locator__pos-list__visible":"mealz-store-locator__pos-list__hidden"}">
|
|
59
59
|
${this._posList.map(e=>a`
|
|
@@ -77,7 +77,7 @@ import{N as u,k as a}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as m
|
|
|
77
77
|
</div>
|
|
78
78
|
`)}
|
|
79
79
|
</div>
|
|
80
|
-
`}addAddressMarker(){if(!this._map||!this._userLocation)return;this._userLocationMarker&&(this._map.removeLayer(this._userLocationMarker),this._userLocationMarker=void 0);const
|
|
80
|
+
`}addAddressMarker(){var s,i;if(!this._map||!this._userLocation)return;const t=(i=(s=this._map).getSize)==null?void 0:i.call(s);if(!t||t.x===0||t.y===0){this.ensureMapSize(),requestAnimationFrame(()=>this.addAddressMarker());return}this._userLocationMarker&&(this._map.removeLayer(this._userLocationMarker),this._userLocationMarker=void 0);const e=getComputedStyle(document.documentElement).getPropertyValue("--mealz-ds-color-primary").trim()||"#24748F";this._userLocationMarker=window.L.circleMarker([this._userLocation.latitude,this._userLocation.longitude],{stroke:!1,fillOpacity:1,fill:!0,color:e,className:"mealz-store-locator__address-marker"}).addTo(this._map)}getButtonLabel(){if(this._showPosList)return"Voir la carte";const t=this._posList.length;return t===1?"Voir le magasin":`Voir les ${t} magasins`}dispatchShow(t){const e={detail:{show:t},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("showChange",e))}initLeaflet(){this._leafletCss=document.createElement("link"),this._leafletCss.setAttribute("rel","stylesheet"),this._leafletCss.setAttribute("href","https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"),this._leafletCss.setAttribute("integrity","sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="),this._leafletCss.setAttribute("crossorigin",""),this._leafletJs=document.createElement("script"),this._leafletJs.setAttribute("src","https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"),this._leafletJs.setAttribute("integrity","sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="),this._leafletJs.setAttribute("crossorigin",""),this._miamDs=document.createElement("link"),this._miamDs.setAttribute("rel","stylesheet"),this._miamDs.setAttribute("href","https://unpkg.com/mealz-ds@2.0.0/mealz-ds.min.css"),document.head.appendChild(this._miamDs),document.head.appendChild(this._leafletCss),document.head.appendChild(this._leafletJs)}waitForLeaflet(t){let i=50;console.debug("[Map] Checking for window.L");const o=setInterval(()=>{window.L!==void 0||i===0?(clearInterval(o),window.L!==void 0?(console.debug("[Map] window.L is defined"),t(!0)):(console.error("[Map] Failed to load Leaflet after",5e3,"ms"),t(!1))):i--},100)}loadMap(){this.waitForLeaflet(t=>{t&&(this._map&&(this._map.off(),this._map.remove()),this.setNewLocation(),window.L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png",{maxZoom:19,attribution:"Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL."}).addTo(this._map))})}initEvents(){this._filterEvent=new CustomEvent("filterChange",{detail:{supplierName:""},bubbles:!0,composed:!0})}initResizeObserver(){this._resizeObserver=new ResizeObserver(()=>{this._map&&this._map.invalidateSize()})}ensureMapSize(){!this._map||!this._mapElement||requestAnimationFrame(()=>{this._map&&this._mapElement.offsetWidth>0&&this._mapElement.offsetHeight>0?this._map.invalidateSize():requestAnimationFrame(()=>{this._map&&this._map.invalidateSize()})})}initialSearch(){var t,e,s,i;this.setSupplier(),!this._prevAddress&&((e=(t=this.geolocationCoordinates)==null?void 0:t.coords)!=null&&e.latitude)&&((i=(s=this.geolocationCoordinates)==null?void 0:s.coords)!=null&&i.longitude)?this.getPosByCoordinates():this.setAddress(!0)}setAddress(t=!1){var e;!t&&(!this._addressInput.value||this._addressInput.value.length<3||this._searchingPos)||!t&&this._prevAddress===this._addressInput.value+", France"||(this._prevAddress=(e=this._addressInput)!=null&&e.value?this._addressInput.value+", France":"Paris, France",this._searchingPos=!0,this.requestUpdate(),this.subscriptions.push(this.getByAddress(this._prevAddress,this.selectedRadius,this._selectedSuppliers).subscribe(s=>{this._userLocation=s["current-coordinates"],this.setPosList(s),this.setNewLocation(),this.addAddressMarker(),this.dispatchSearch(this._prevAddress,s.data.length),this._searchingPos=!1,this._searchSubmitted=!0,this.togglePosList(!1),this.requestUpdate()})))}setGeolocation(){this._prevAddress="",this.getPosByCoordinates()}getPosByCoordinates(){var e;const t=(e=this.geolocationCoordinates)==null?void 0:e.coords;if(!t){this._searchingPos=!1;return}this._searchingPos=!0,this.requestUpdate(),this.subscriptions.push(this.getByCoordinates(t.latitude,t.longitude,this.selectedRadius,this._selectedSuppliers).subscribe(s=>{this._addressInput.value="",this._userLocation=s["current-coordinates"],this.setPosList(s),this._searchingPos=!1,this.setNewLocation(),this.addAddressMarker(),this._searchSubmitted=!0,this.togglePosList(!1),this.requestUpdate()}))}setPosList(t){this._posList=t.data.map(e=>{const s=Object.assign(new f,e);return s.supplier=t.included.find(i=>i.id===s.relationships.supplier.data.id),s}).sort((e,s)=>e.attributes.name.includes("onoprix")?-1:s.attributes.name.includes("onoprix")?1:0)}setNewLocation(){var e;const t=this.getMapContainer();if(t){if(this._map&&this._map.getContainer&&this._map.getContainer()!==t&&(this._map.off(),this._map.remove(),this._map=void 0),this._map){const s=this._map;this._markers.forEach(i=>{s.removeLayer(i)}),this._markers=[],s.panTo(this.getCoordinates())}else this._map=(e=window.L)==null?void 0:e.map(t).setView(this.getCoordinates(),13),this._resizeObserver&&this._resizeObserver.observe(t),this.ensureMapSize();this.addMarkers()}}getCoordinates(){var t,e;return(t=this._userLocation)!=null&&t.latitude&&((e=this._userLocation)!=null&&e.longitude)?[Number(this._userLocation.latitude),Number(this._userLocation.longitude)]:this._posList.length>0?[Number(this._posList[0].attributes.latitude),Number(this._posList[0].attributes.longitude)]:[48.866667,2.333333]}addMarkers(){this._posList.length>0&&this._posList.forEach((t,e)=>{this._markers.push(window.L.marker([t.attributes.latitude,t.attributes.longitude],{icon:this.buildIcon(t.supplier)}).addTo(this._map));const s=window.L.popup({content:`
|
|
81
81
|
<div class="mealz-store-locator__pos-item">
|
|
82
82
|
<div class="mealz-store-locator__pos-data">
|
|
83
83
|
<img class="mealz-store-locator__pos-picture" src="${t.supplier.attributes.logo}"
|
|
@@ -94,4 +94,4 @@ import{N as u,k as a}from"../assets/no-shadow-element-Dz9jgDtr.js";import{t as m
|
|
|
94
94
|
</button>
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
97
|
-
`});this._markers[e].bindPopup(s).on("popupopen",i=>{var n,d;const o=(n=i.target.getPopup())==null?void 0:n.getElement();(d=o==null?void 0:o.querySelector("#mealz-select"))==null||d.addEventListener("click",()=>{this.dispatchPos(t)})})})}buildIcon(t){return window.L.icon({iconUrl:t.attributes.logo||"https://cdn-icons-png.flaticon.com/512/3515/3515146.png",shadowUrl:"https://storage.googleapis.com/assets.miam.tech/mealz-components/store-locator/marker.svg",iconSize:[24,24],shadowSize:[44,53],iconAnchor:[16,43],shadowAnchor:[22,45],popupAnchor:[0,-55],className:"mealz-marker-icon"})}togglePosList(t){this._showPosList=!t;const e=document.getElementById("mealz-store-locator__pos-list"),s={bubbles:!0,composed:!0};e&&(t?(e.style.display="none",this.dispatchEvent(new CustomEvent("mapSelected",s))):(e.style.display="flex",this.dispatchEvent(new CustomEvent("listSelected",s))),this.requestUpdate())}geolocationTimeout(){setTimeout(()=>{this.geolocationCoordinates===void 0&&(this.geolocationCoordinates={})},2e4)}listenFormSubmit(){document.getElementById("mealz-store-locator__store-locator-form").addEventListener("submit",e=>{e.preventDefault(),this.setAddress()})}setSupplier(){const t=localStorage.getItem("_miam/selectedSupplierId");t&&(this._selectedSuppliers=[t])}dispatchPos(t){this._posSelected=!0,this.requestUpdate();const e={detail:{posId:t.id,posExtId:t.extId,supplierId:t.supplier.id,supplierName:t.supplier.attributes.name,posName:this._nameOfStore(t)},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("posIdChange",e))}resetPosSelection(){this._posSelected&&(this._posSelected=!1,this.requestUpdate())}dispatchSearch(t,e){const s={detail:{searchTerm:t,storesFoundCount:e},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("searchChange",s))}};l([c({type:Number})],r.prototype,"selectedRadius",2);l([c()],r.prototype,"getByAddress",2);l([c()],r.prototype,"getByCoordinates",2);l([c()],r.prototype,"getAffiliateSuppliers",2);l([c({type:Boolean})],r.prototype,"show",1);l([c({attribute:!1})],r.prototype,"geolocationCoordinates",1);l([_()],r.prototype,"_geolocationCoordinates",2);l([p("input")],r.prototype,"_addressInput",2);l([p("#mealz-store-locator__map")],r.prototype,"_mapElement",2);r=l([m("mealz-store-locator")],r);customElements.get("mealz-store-locator")||customElements.define("mealz-store-locator",r);
|
|
97
|
+
`});this._markers[e].bindPopup(s).on("popupopen",i=>{var n,d;const o=(n=i.target.getPopup())==null?void 0:n.getElement();(d=o==null?void 0:o.querySelector("#mealz-select"))==null||d.addEventListener("click",()=>{this.dispatchPos(t)})})})}buildIcon(t){return window.L.icon({iconUrl:t.attributes.logo||"https://cdn-icons-png.flaticon.com/512/3515/3515146.png",shadowUrl:"https://storage.googleapis.com/assets.miam.tech/mealz-components/store-locator/marker.svg",iconSize:[24,24],shadowSize:[44,53],iconAnchor:[16,43],shadowAnchor:[22,45],popupAnchor:[0,-55],className:"mealz-marker-icon"})}togglePosList(t){this._showPosList=!t;const e=document.getElementById("mealz-store-locator__pos-list"),s={bubbles:!0,composed:!0};e&&(t?(e.style.display="none",this.dispatchEvent(new CustomEvent("mapSelected",s))):(e.style.display="flex",this.dispatchEvent(new CustomEvent("listSelected",s))),this.requestUpdate())}geolocationTimeout(){setTimeout(()=>{this.geolocationCoordinates===void 0&&(this.geolocationCoordinates={})},2e4)}listenFormSubmit(){const t=document.getElementById("mealz-store-locator__store-locator-form");t&&t.addEventListener("submit",e=>{e.preventDefault(),this.setAddress()})}setSupplier(){const t=localStorage.getItem("_miam/selectedSupplierId");t&&(this._selectedSuppliers=[t])}dispatchPos(t){this._posSelected=!0,this.requestUpdate();const e={detail:{posId:t.id,posExtId:t.extId,supplierId:t.supplier.id,supplierName:t.supplier.attributes.name,posName:this._nameOfStore(t)},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("posIdChange",e))}resetPosSelection(){this._posSelected&&(this._posSelected=!1,this.requestUpdate())}dispatchSearch(t,e){const s={detail:{searchTerm:t,storesFoundCount:e},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("searchChange",s))}};l([c({type:Number})],r.prototype,"selectedRadius",2);l([c()],r.prototype,"getByAddress",2);l([c()],r.prototype,"getByCoordinates",2);l([c()],r.prototype,"getAffiliateSuppliers",2);l([c({type:Boolean})],r.prototype,"show",1);l([c({attribute:!1})],r.prototype,"geolocationCoordinates",1);l([_()],r.prototype,"_geolocationCoordinates",2);l([p("input")],r.prototype,"_addressInput",2);l([p("#mealz-store-locator__map")],r.prototype,"_mapElement",2);r=l([m("mealz-store-locator")],r);customElements.get("mealz-store-locator")||customElements.define("mealz-store-locator",r);
|