1import{u as y}from"./CYqbzUre.js";function T(e,...n){for(const s of n)for(const a of s||[])for(const t of a.offers||[])if(t.offer.id===e)return{offer:t.offer,offer_type:a.offer_type,customer_group:t.customer_group,display:t.display};return null}function b(e){return e?.group_type==="premium_customers"}function w(e,...n){return e==null?!1:b(T(e,...n)?.customer_group)}const F="WFD Go only";function f(e){return Number.isInteger(e)?String(e):e.toFixed(2)}function U(e){return f(e)}function M(e){return e.discount_type==="percentage"?`${f(e.discount_amount)}%`:`â¬${f(e.discount_amount)}`}function x(e,n){let s=n.discount_type==="percentage"?e*n.discount_amount/100:n.discount_amount;return s>n.discount_limit&&(s=n.discount_limit),s>e&&(s=e),Math.max(0,Math.round((e-s)*100)/100)}function R(e){return e.minimum_spend===0||e.applies_now}function G(e,n,s){const a=(n??[]).find(c=>c.mechanic==="discount"&&c.offer_id===e.offer_id),t=a?a.badge.toLowerCase():s?`${M(s)} off`:null,u=e.remaining_to_unlock??0;return u>0?t?`Spend â¬${u.toFixed(2)} more to get ${t}`:`Spend â¬${u.toFixed(2)} more to save`:`${t??"Save"} over â¬${f(e.minimum_spend)}`}const O={discount:"i-lucide-percent",basket:"i-lucide-shopping-basket",free_delivery:"i-lucide-truck",bogo:"i-lucide-gift",free_item:"i-lucide-package",service_fee:"i-lucide-receipt",offer:"i-lucide-tag"};function B(e){return O[e]??"i-lucide-tag"}function H(e){return O[e]??"i-lucide-tag"}const S=["discount","bogo"];function W(e){const n=(e??[]).filter(s=>s.role==="scope");for(const s of S){const a=n.find(t=>t.mechanic===s);if(a)return a}return n[0]??null}function V(e){return(e??[]).filter(n=>n.role==="trigger")}function I(e){switch(e.mechanic){case"free_delivery":return"free delivery";case"free_item":return"a free item";case"admin_fee":return"no service fee";default:return e.badge.toLowerCase()}}function K(e){const n=e.mechanic==="basket"?"Add to unlock":"Add for",s=I(e),a=R(e)?"":` over â¬${U(e.minimum_spend)}`;return`${n} ${s}${a}`}function E(e){const n=e,s=n?.status??n?.statusCode??n?.data?.status??500,a=n?.message??n?.detail??n?.data?.message??n?.data?.detail??"An unexpected error occurred",t=a.toLowerCase();let u="UNKNOWN_ERROR",c;return t.includes("site")&&t.includes("not found")?(u="SITE_NOT_FOUND",c="site_not_found"):t.includes("no schedules found")?(u="NO_SCHEDULES_FOUND",c="no_schedules"):t.includes("no currently active")||t.includes("no active")&&t.includes("schedule")?(u="NO_ACTIVE_SCHEDULE",c="no_active_schedule"):t.includes("menu is not active")?(u="MENU_NOT_ACTIVE",c="menu_not_active"):t.includes("menu is not published")?(u="MENU_NOT_PUBLISHED",c="menu_not_published"):t.includes("menu")&&t.includes("not found")?(u="MENU_NOT_FOUND",c="menu_not_found"):s===404?(u="MENU_NOT_FOUND",c="unknown"):s===500||t.includes("failed to")||t.includes("internal")||t.includes("unexpected")?u="INTERNAL_ERROR":s===400&&(u="VALIDATION_ERROR"),{code:u,message:a,statusCode:s,unavailableReason:c}}function C(e){switch(e.code){case"SITE_NOT_FOUND":return"The restaurant you're looking for could not be found.";case"NO_SCHEDULES_FOUND":return"This restaurant has not set up their menu schedule yet. Please check back later.";case"NO_ACTIVE_SCHEDULE":return"This restaurant is currently closed. Please check back during opening hours.";case"MENU_NOT_ACTIVE":return"The menu for this restaurant is currently unavailable. Please check back later.";case"MENU_NOT_PUBLISHED":return"This restaurant is still setting up their menu. Please check back later.";case"MENU_NOT_FOUND":return"No menu is currently available for this restaurant.";case"INTERNAL_ERROR":return"An error occurred while loading the menu. Please try again later.";case"VALIDATION_ERROR":return e.message||"Invalid request. Please try again.";default:return e.message||"An unexpected error occurred. Please try again."}}function k(e,n){return e.code===n}function A(e){return e.code!=="SITE_NOT_FOUND"&&e.unavailableReason!==void 0}const J=()=>{const{$api:e}=y(),n=async r=>(await e(`/menu/site/${r}/active`,{method:"GET"})).menu,s=async(r,i)=>{const o=typeof i=="number"&&i>0?`?menu_id=${i}`:"";return(await e(`/menu/site/${r}/listing${o}`,{method:"GET"})).menu},a=async r=>await e(`/products/${r}/detail`,{method:"GET"}),t=async r=>{try{return(await e(`/sites/slug/${r}`,{method:"GET"})).site}catch{return null}},u=async r=>{try{const i=await n(r);return i.unavailable_reason?{success:!1,error:{code:N(i.unavailable_reason),message:h(i.unavailable_reason),statusCode:200,unavailableReason:i.unavailable_reason},site:i.site}:{success:!0,data:i}}catch(i){return{success:!1,error:E(i)}}},c=r=>!r.unavailable_reason&&r.menu!==null&&r.menu!==void 0,h=r=>{switch(r){case"no_schedules":return"This restaurant has not set up their menu schedule yet. Please check back later.";case"no_active_schedule":return"This restaurant is currently closed. Please check back during opening hours.";case"menu_not_active":return"The menu for this restaurant is currently unavailable. Please check back later.";case"menu_not_published":return"This restaurant is still setting up their menu. Please check back later.";case"menu_not_found":return"No menu is currently available for this restaurant.";default:return"The menu is currently unavailable. Please check back later."}},N=r=>{switch(r){case"no_schedules":return"NO_SCHEDULES_FOUND";case"no_active_schedule":return"NO_ACTIVE_SCHEDULE";case"menu_not_active":return"MENU_NOT_ACTIVE";
1case"menu_not_published":return"MENU_NOT_PUBLISHED";case"menu_not_found":return"MENU_NOT_FOUND";default:return"UNKNOWN_ERROR"}};return{getSiteWithMenu:n,getSiteBySlug:t,safeSiteWithMenu:u,getMenuListing:s,getProductDetail:a,hasMenu:c,getMessageForUnavailableReason:h,mapUnavailableReasonToErrorCode:N,menuToJSONLD:(r,i,o)=>{if(!o)return null;const l=o.site,v=(o.product_listing||[]).map(_=>({"@type":"MenuSection",name:_?.name,description:_?.description||void 0,hasMenuItem:(_.products||[]).filter(d=>d.product).map(d=>{const p=d.product;let m;return"product_media"in d&&d.product_media?.length?m=d.product_media.filter(g=>g.content_type==="image").map(g=>g.content_url):"media"in d&&d.media?.content_url&&(m=[d.media.content_url]),{"@type":"MenuItem",name:p?.name,description:p?.description||void 0,offers:{"@type":"Offer",price:p.price,priceCurrency:"EUR"},image:m&&m.length>0?m:void 0}})}));return{"@context":"https://schema.org","@type":"Restaurant","@id":`${r}/sites/${i}`,name:l?.name,description:l?.description||void 0,image:l.logo_url||void 0,address:{"@type":"PostalAddress",streetAddress:l.address},geo:{"@type":"GeoCoordinates",latitude:l.location_latitude,longitude:l.location_longitude},email:l.email||void 0,servesCuisine:l.food_types?.map(_=>_?.name)||void 0,hasMenu:{"@type":"Menu",name:o.menu?.name||"Menu",description:o.menu?.description||void 0,hasMenuSection:v}}},siteToJSONLD:(r,i,o)=>({"@context":"https://schema.org","@type":"Restaurant","@id":`${r}/sites/${i}`,name:o?.name,description:o?.description||void 0,image:o.logo_url||void 0,address:{"@type":"PostalAddress",streetAddress:o.address},geo:{"@type":"GeoCoordinates",latitude:o.location_latitude,longitude:o.location_longitude},email:o.email||void 0,servesCuisine:o.food_types?.map(l=>l?.name)||void 0}),parseMenuError:E,getMenuErrorMessage:C,isMenuError:k,isSiteExistsButMenuUnavailable:A}};export{F as W,b as a,G as b,K as c,R as d,T as e,U as f,x as g,w as i,B as m,H as o,W as p,V as t,J as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.