@restaround/react 1.0.44 → 1.0.46
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/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles/ui.css +1 -1
- package/dist/styles/ui.css.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{createContext as a,useContext as i,useState as n,useRef as o,useEffect as l,useMemo as d,memo as c}from"react";import{isEmpty as s,priceFormatter as u,classNames as m}from"@sorocraft/js-utils";import{Row as _,classNames as h,IconLink as g,Tooltip as p,SVGIcon as v,Flex as f,Column as y,Carousel as b,CarouselItem as C,Chip as P,UIElementType as I,IconButton as A,Modal as w,Button as O,Drawer as N,Text as k,Description as L,Container as S,Card as D}from"@sorocraft/ui";import{Phone as T,Whatsapp as z,Instagram as j,Telegram as x,Tiktok as R,Facebook as Q,Wifi as W,MarkerPin as H,Plus as B,Minus as E,Close as q}from"@sorocraft/ui/icons";function Y(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(r[a[i]]=e[a[i]])}return r}function M(e,t,r,a){return new(r||(r=Promise))((function(i,n){function o(e){try{d(a.next(e))}catch(e){n(e)}}function l(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,l)}d((a=a.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var F="PublicMenu-module_container__QLN6U",U="PublicMenu-module_categories__Iy6NC",V="PublicMenu-module_footer__6G3DQ";const $="https://images.restaround.co",G=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"",Z=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"https://images.restaround.co/no-photo-128.webp",K=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"https://images.restaround.co/restaround-doodle.webp",X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",J=(e,t,r)=>X.charAt(e>>2)+X.charAt((3&e)<<4|t>>4)+X.charAt((15&t)<<2|r>>6)+X.charAt(63&r),ee="restaround.co",te=[ee,"restaround.az","restaround.ee","restaround.nl"],re=a({}),ae=({children:t,value:r})=>{const a=s(r)?{}:r;return a.currency||a.currency,a.language||a.language,e(re.Provider,{value:s(r)?{}:r,children:t})},ie=()=>i(re);var ne="Header-module_container__tenlF",oe="Header-module_cover__BAWZK",le="Header-module_content__Gx4Al",de="Header-module_logo__4MTCm",ce="Header-module_info__IchYA",se="Header-module_name__30wyw",ue="Header-module_address__WOxXc",me="Header-module_addressText__lUszI",_e="Header-module_social__AoP0z",he="Header-module_links__EeQxg",ge="Header-module_wifiPassword__VWBTa",pe="Header-module_wifiPasswordIcon__Ukn3D";const ve=t=>{const r=Y(t,["priority","blurDataURL","quality","placeholder","fetchPriority"]),{imageTag:a}=ie()||{};if(a){return e(a,Object.assign({},t,{quality:t.quality||100,placeholder:"blur",blurDataURL:(i=235,n=59,o=90,`data:image/gif;base64,R0lGODlhAQABAPAA${J(0,i,n)+J(o,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`)}))}var i,n,o;return e("img",Object.assign({},r))};var fe={container:"Languages-module_container__nJeK1",currentLanguage:"Languages-module_currentLanguage__EFw6Q",options:"Languages-module_options__6jLRm",option:"Languages-module_option__QkVQd",isOpen:"Languages-module_isOpen__eUGbg",flexWide:"Languages-module_flexWide__zQ9jN",slidein:"Languages-module_slidein__C4UHU",fadeInOut:"Languages-module_fadeInOut__U-vhH",heightAnimation:"Languages-module_heightAnimation__gIQkF",fadein:"Languages-module_fadein__vPmsX",floatAnimation:"Languages-module_floatAnimation__L-kPH",bottomSheet:"Languages-module_bottomSheet__-t-q8",slideRightToLeft:"Languages-module_slideRightToLeft__y0l-f"};const ye=()=>{var r;const{language:a,languages:i,onLanguageSelect:o}=ie(),[l,d]=n(!1),c=(null==i?void 0:i.length)>1,s=(null===(r=null==i?void 0:i.filter)||void 0===r?void 0:r.call(i,(({code:e})=>e!==a)))||[],u=e=>`https://images.restaround.co/languages/${e}.svg`;return c?e("div",{className:fe.container,onClick:()=>d(!l),children:t(_,{alignItems:"center",gap:0,children:[e(_,{alignItems:"center",className:h(fe,{options:!0,isOpen:l}),children:s.map((({code:t})=>e("img",{src:u(t),className:fe.option,onClick:()=>(e=>{o&&o(e)})(t),alt:t},t)))}),e("img",{src:u(a),alt:a||"",className:fe.currentLanguage})]})}):null},be=({branch:r,coverImage:a,logoImage:i,name:n,instagram:o,facebook:l,whatsapp:d,telegram:c,tiktok:u})=>{const{address:m,latitude:h,longitude:b,phone:C,wifiPassword:P}=r||{},I=s(r),A=`https://www.google.com/maps/place/${h},${b}`;return t("div",{className:ne,children:[e(ve,{src:a,alt:n,className:oe,width:1024,height:400,priority:!0,sizes:"100vw",fetchPriority:"high",loading:"eager"}),e("div",{className:le,children:e(I?()=>t(y,{fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",children:[e(ve,{src:i,alt:n,className:de,width:96,height:96}),e("div",{className:ce,children:e("h1",{className:se,children:n})})]}):()=>t(f,{direction:"row",gap:1,alignItems:"center",children:[e(f.Item,{children:e(ve,{src:i,alt:n,className:de,width:96,height:96})}),e(f.Item,{shrink:!0,children:e("div",{className:ce,children:t(y,{gap:.25,children:[e("h1",{className:se,children:n}),e("a",{className:ue,href:A,target:"_blank",rel:"noopener noreferrer",children:t(_,{alignItems:"center",gap:.5,children:[e(v,{icon:H,theme:"dark"}),e("span",{className:me,children:m})]})})]})})})]}),{})}),e(ye,{}),!I&&e("div",{className:_e,children:e("div",{className:he,children:e(_,{gap:2,alignItems:"center",children:t(_,{alignItems:"center",justifyContent:"center",gap:.5,children:[!!C&&e(g,{icon:T,href:`tel:+${C}`,size:"sm",shape:"circle",theme:"light"}),!!d&&e(g,{icon:z,href:`https://wa.me/${d}`,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!o&&e(g,{icon:j,href:o,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!c&&e(g,{icon:x,href:c,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!u&&e(g,{icon:R,href:u,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!l&&e(g,{icon:Q,href:l,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!P&&e(p,{hint:P,children:e("div",{className:ge,children:e(v,{icon:W,size:"sm",className:pe})})})]})})})})]})},Ce=({categoryProductMap:t=[],language:r,selectedCategoryId:a,onSelectCategory:i})=>{const n=o({}),d=o(null);return l((()=>{a&&(()=>{var e;const t=null===(e=null==n?void 0:n.current)||void 0===e?void 0:e[a];if(!t||!d.current)return;const r=d.current.clientWidth,i=t.offsetLeft-r/2+t.offsetWidth/2;d.current.scrollTo({left:i,behavior:"smooth"})})()}),[a]),e("div",{className:U,children:e(b,{gap:1,onGetRef:e=>{(null==e?void 0:e.current)&&(d.current=e.current)},children:(t||[]).map((({id:t,translations:o})=>{const{name:l}=o.find((e=>e.language===r))||{};return e(C,{children:e(P,{onClick:()=>(e=>{e!==a&&i(e)})(t),type:I.BORDERED_PRIMARY,active:t===a,children:e("div",{ref:e=>n.current[t]=e,children:l})})},t)}))})})};var Pe="Products-module_container__bF2LF",Ie="Products-module_products__AoDrY",Ae="Products-module_category__Sp7dE",we="Products-module_list__LH4v5";const Oe=a({cart:{},isCartOpen:!1,addProduct:()=>{},updateProduct:()=>{},setIsCartOpen:()=>{}}),Ne=({children:t})=>{const[r,a]=n({}),[i,o]=n(!1),l=(e,t,r)=>{if(s(e)||t<0)return;const{id:i,price:n,vat:o=0}=e;a((e=>{const a=e[i],l=r?((null==a?void 0:a.quantity)||0)+t:t;if(l<=0){const t=e,r=i;t[r];return Y(t,["symbol"==typeof r?r:r+""])}return Object.assign(Object.assign({},e),{[i]:{productId:i,price:n,quantity:l,vat:o}})}))},c=(e,t=1)=>l(e,t,!0),u=(e,t=1)=>l(e,t,!1),m=d((()=>({cart:r,isCartOpen:i,addProduct:c,updateProduct:u,setIsCartOpen:o})),[r,i]);return e(Oe.Provider,{value:m,children:t})},ke=()=>i(Oe);var Le={container:"ProductsListItem-module_container__i9tFs",isClickable:"ProductsListItem-module_isClickable__iHHdI",data:"ProductsListItem-module_data__Mb3SF",name:"ProductsListItem-module_name__T1gyJ",description:"ProductsListItem-module_description__oL4CH",price:"ProductsListItem-module_price__V1GRM",image:"ProductsListItem-module_image__h6Wbi",addToCart:"ProductsListItem-module_addToCart__WXrQZ",flexWide:"ProductsListItem-module_flexWide__Ds6LE",slidein:"ProductsListItem-module_slidein__rEzMI",fadeInOut:"ProductsListItem-module_fadeInOut__i1FNq",heightAnimation:"ProductsListItem-module_heightAnimation__2fk7l",fadein:"ProductsListItem-module_fadein__tPTJ6",floatAnimation:"ProductsListItem-module_floatAnimation__vugAV",bottomSheet:"ProductsListItem-module_bottomSheet__-YAdd",slideRightToLeft:"ProductsListItem-module_slideRightToLeft__oXk26"};const Se=(e,t)=>{var r,a;return(null===(a=null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.find)||void 0===a?void 0:a.call(r,(e=>e.language===t)))||{}},De=(e,t,r=0)=>e*t*(1+r/100),Te=(e,t,r,a=1)=>{const{price:i,vat:n}=e||{},o=De(i,a,n);return{totalPrice:o,formattedTotalPrice:u(o,t,r)}},ze=({product:r,currency:a,language:i,onClick:n})=>{const{addProduct:o}=ke(),{image160:l}=r||{},{name:c,description:s}=d((()=>Se(r,i)),[r,i]),{formattedTotalPrice:u}=d((()=>Te(r,a,i)),[r,a,i]);return t("div",{className:m(Le,{container:!0,isClickable:!!n}),onClick:n,children:[t(_,{justifyContent:"space-between",gap:0,children:[e("div",{className:Le.data,children:t(y,{gap:.25,children:[e("h3",{className:Le.name,children:c}),e("div",{className:Le.description,children:s}),e("div",{className:Le.price,children:u})]})}),l&&e(ve,{src:G(l),alt:c||"menu",className:Le.image,loading:"lazy",width:160,height:90})]}),e("div",{className:Le.addToCart,children:e(A,{onClick:e=>{e.preventDefault(),e.stopPropagation(),o(r)},icon:B,type:I.DEFAULT})})]})};var je={container:"ProductDetails-module_container__oa07j",content:"ProductDetails-module_content__Db3NC",image:"ProductDetails-module_image__BlMfl",details:"ProductDetails-module_details__zfnlt",name:"ProductDetails-module_name__ganLM",price:"ProductDetails-module_price__W34k9",volume:"ProductDetails-module_volume__RWG5s",description:"ProductDetails-module_description__HBufi",close:"ProductDetails-module_close__4cHZ3",flexWide:"ProductDetails-module_flexWide__w06FX",slidein:"ProductDetails-module_slidein__N8f4g",fadeInOut:"ProductDetails-module_fadeInOut__hYRtK",heightAnimation:"ProductDetails-module_heightAnimation__hLQyz",fadein:"ProductDetails-module_fadein__QN4mI",floatAnimation:"ProductDetails-module_floatAnimation__dTQbc",bottomSheet:"ProductDetails-module_bottomSheet__HO2S-",slideRightToLeft:"ProductDetails-module_slideRightToLeft__hbtJg"};const xe={en:{viewOrder:"View order",removeFromOrder:"Remove from order",updateOrder:"Update order",addToOrder:"Add to order"},az:{viewOrder:"Şifarişi göstər",removeFromOrder:"Sifarişdən sil",updateOrder:"Sifarişi yenilə",addToOrder:"Sifarişə əlavə et","Your order":"Sifarişiniz",Subtotal:"Ümumi","Empty order":"Boş sifariş","You don't have any items in your order":"Sifarişinizdə heç bir məhsul yoxdur","Add items":"Məhsul əlavə et"},tr:{viewOrder:"Siparişi Görüntüle",removeFromOrder:"Siparişten Kaldır",updateOrder:"Siparişi Güncelle",addToOrder:"Siparişe Ekle","Your order":"Siparişiniz","Empty order":"Boş sipariş","You don't have any items in your order":"Siparişinizde hiç bir ürün yok","Add items":"Ürün ekle",Subtotal:"Toplam"},nl:{viewOrder:"Bestelling bekijken",removeFromOrder:"Uit bestelling verwijderen",updateOrder:"Bestelling bijwerken",addToOrder:"Aan bestelling toevoegen","Your order":"Uw bestelling","Empty order":"Lege bestelling","You don't have any items in your order":"U heeft geen items in uw bestelling","Add items":"Items toevoegen",Subtotal:"Totaal"},et:{viewOrder:"Vaata tellimust",removeFromOrder:"Eemalda tellimusest",updateOrder:"Uuenda tellimust",addToOrder:"Lisa tellimusele","Your order":"Teie tellimus","Empty order":"Tühi tellimus","You don't have any items in your order":"Teie tellimuses pole ühtegi eset","Add items":"Lisa esemeid",Subtotal:"Kokku"},pl:{viewOrder:"Zobacz zamówienie",removeFromOrder:"Usuń z zamówienia",updateOrder:"Zaktualizuj zamówienie",addToOrder:"Dodaj do zamówienia","Your order":"Twoje zamówienie","Empty order":"Puste zamówienie","You don't have any items in your order":"Nie masz żadnych pozycji w zamówieniu","Add items":"Dodaj przedmioty",Subtotal:"Suma"},ru:{viewOrder:"Посмотреть заказ",removeFromOrder:"Удалить из заказа",updateOrder:"Обновить заказ",addToOrder:"Добавить в заказ","Your order":"Ваш заказ","Empty order":"Пустой заказ","You don't have any items in your order":"В вашем заказе нет товаров","Add items":"Добавить товары",Subtotal:"Итого"}},Re=()=>{const{language:e}=ie();return{t:t=>{var r;return(null===(r=xe[e])||void 0===r?void 0:r[t])||t}}},Qe=()=>{const{cart:e}=ke();return Object.values(e||{}).reduce(((e,t)=>e+t.quantity),0)};var We={container:"Quantity-module_container__01ySb",quantityAction:"Quantity-module_quantityAction__wRV2F",quantityValue:"Quantity-module_quantityValue__BBpyw",isDisabled:"Quantity-module_isDisabled__crQCf",sm:"Quantity-module_sm__0Hgp2",md:"Quantity-module_md__hu7a8",lg:"Quantity-module_lg__GA4jn",flexWide:"Quantity-module_flexWide__R95Jw",slidein:"Quantity-module_slidein__5yeWf",fadeInOut:"Quantity-module_fadeInOut__cllco",heightAnimation:"Quantity-module_heightAnimation__dhOgA",fadein:"Quantity-module_fadein__Cof2o",floatAnimation:"Quantity-module_floatAnimation__DSqQr",bottomSheet:"Quantity-module_bottomSheet__5-5iY",slideRightToLeft:"Quantity-module_slideRightToLeft__cjDHk"};const He=({isDecreaseDisabled:r=!1,quantity:a=1,size:i="md",onIncrease:n,onDecrease:o})=>t(_,{className:m(We,{container:!0},[We[i]]),justifyContent:"space-between",gap:0,children:[e("div",{className:m(We,{quantityAction:!0,isDisabled:r}),onClick:o,children:e(v,{icon:E})}),e("div",{className:We.quantityValue,children:a}),e("div",{className:We.quantityAction,onClick:n,children:e(v,{icon:B})})]}),Be=({product:r,onClose:a})=>{const{language:i,currency:c}=ie(),{addProduct:m,updateProduct:h}=ke(),[g,p]=n(1),[v,f]=n(!1),b=o(),{t:C}=Re(),P=(e=>{var t;const{cart:r}=ke();return s(r)||!e?0:(null===(t=r[e])||void 0===t?void 0:t.quantity)||0})(null==r?void 0:r.id),{name:I,description:N}=d((()=>Se(r,i)),[r,i]),{totalPrice:k,formattedTotalPrice:L}=d((()=>Te(r,c,i)),[r,c,i]),S=d((()=>g*k),[g,k]),D=d((()=>u(S,c,i)),[S,c,i]),T=v?0===g:1===g,z=d((()=>C(v?0===g?"removeFromOrder":"updateOrder":"addToOrder")),[v,g]);l((()=>{p(P>0?P:1),f(P>0)}),[P]);const j=e=>{-1===e&&T||p((t=>Math.max(0,t+e)))};if(s(r))return null;const{image1024:x,volume:R}=r;return e("div",{className:je.container,onClick:e=>{var t,r;(null===(r=null===(t=null==b?void 0:b.current)||void 0===t?void 0:t.contains)||void 0===r?void 0:r.call(t,null==e?void 0:e.target))||a&&a()},children:e(w,{onClose:a,ref:b,noBodyPadding:!0,size:"small",content:t("div",{className:je.content,children:[t(y,{gap:0,children:[x&&e(ve,{src:G(x),width:1024,height:400,alt:I||"product",className:je.image}),t(y,{className:je.details,gap:1,children:[e("h2",{className:je.name,children:I}),t(_,{justifyContent:"space-between",children:[e("div",{className:je.price,children:L}),e("div",{className:je.volume,children:R})]}),e("div",{className:je.description,children:N})]})]}),e("div",{className:je.close,children:e(A,{onClick:a,icon:q})})]}),footer:t(_,{className:je.addToCart,gap:.5,children:[e(He,{isDecreaseDisabled:T,onDecrease:()=>j(-1),onIncrease:()=>j(1),quantity:g}),e(O,{className:je.addAction,label:t(_,{fullWidth:!0,justifyContent:"space-between",children:[e("span",{children:z}),e("span",{children:D})]}),onClick:()=>{v?h(r,g):m(r,g),a&&a()},size:"xl",fullWidth:!0})]})})})};var Ee="Cart-module_container__3KQtx",qe="Cart-module_content__rkiZa",Ye={container:"CartStepper-module_container__4CF1L",count:"CartStepper-module_count__E-RBg",actionText:"CartStepper-module_actionText__-rVKA",totalPrice:"CartStepper-module_totalPrice__QboRN",isClickable:"CartStepper-module_isClickable__mDptU",flexWide:"CartStepper-module_flexWide__eXxCr",slidein:"CartStepper-module_slidein__d5JQ-",fadeInOut:"CartStepper-module_fadeInOut__pS8nn",heightAnimation:"CartStepper-module_heightAnimation__7-e5Z",fadein:"CartStepper-module_fadein__-Ba0-",floatAnimation:"CartStepper-module_floatAnimation__rq6zX",bottomSheet:"CartStepper-module_bottomSheet__1wHHD",slideRightToLeft:"CartStepper-module_slideRightToLeft__0KLAo"};const Me=({actionText:r,onClick:a})=>{const i=Qe(),{formattedTotalPrice:n}=(()=>{const{cart:e}=ke(),{currency:t,language:r}=ie(),a=Object.values(e||{}).reduce(((e,{price:t,quantity:r,vat:a})=>e+De(t,r,a)),0);return{totalPrice:a,formattedTotalPrice:u(a,t,r)}})();return t(f,{className:m(Ye,{container:!0,isClickable:!!a}),justifyContent:"space-between",alignItems:"center",onClick:a,children:[e(f.Item,{flex:1,children:t(_,{alignItems:"center",children:[e("div",{className:Ye.count,children:i}),e("div",{className:Ye.actionText,children:r})]})}),e(f.Item,{className:Ye.totalPrice,flex:1,children:n})]})},Fe=()=>{const{setIsCartOpen:t}=ke(),{t:r}=Re();return Qe()<=0?null:e("div",{className:Ee,children:e("div",{className:qe,children:e(Me,{onClick:()=>t(!0),actionText:r("viewOrder")})})})};var Ue={container:"CartDrawer-module_container__zvapw",content:"CartDrawer-module_content__ELSiG",flexWide:"CartDrawer-module_flexWide__ySgY-",slidein:"CartDrawer-module_slidein__XC9AW",fadeInOut:"CartDrawer-module_fadeInOut__w9h6X",heightAnimation:"CartDrawer-module_heightAnimation__tBgkj",fadein:"CartDrawer-module_fadein__QNPoQ",floatAnimation:"CartDrawer-module_floatAnimation__nZWoY",bottomSheet:"CartDrawer-module_bottomSheet__m0wy7",slideRightToLeft:"CartDrawer-module_slideRightToLeft__gpixh"},Ve="CartItem-module_container__At7lj",$e="CartItem-module_image__D-zzG",Ge="CartItem-module_data__Lo3Fb",Ze="CartItem-module_name__EksZu",Ke="CartItem-module_price__yJxl6";const Xe=e=>{var t;const{products:r}=ie();return(null===(t=null==r?void 0:r.find)||void 0===t?void 0:t.call(r,(({id:t})=>t===e)))||{}},Je=({productId:t,min:r=1,size:a="md"})=>{const i=(e=>{const{cart:t}=ke(),r=t[e];return(null==r?void 0:r.quantity)||1})(t),n=Xe(t),{updateProduct:o}=ke();return e(He,{isDecreaseDisabled:i===r,onDecrease:()=>o(n,i-1),onIncrease:()=>o(n,i+1),quantity:i,size:a})},et=({item:r})=>{const{productId:a,quantity:i}=r||{},n=Xe(a),{language:o,currency:l}=ie(),{image160:c}=n,{name:s}=d((()=>Se(n,o)),[n,o]),{formattedTotalPrice:u}=d((()=>Te(n,l,o,i)),[n,l,o,i]);return t(_,{className:Ve,gap:1,alignItems:"center",children:[c&&e(ve,{src:G(c),alt:s||"menu",className:$e,loading:"lazy",width:80,height:45}),t("div",{className:Ge,children:[e("div",{className:Ze,children:s}),e("div",{className:Ke,children:u})]}),e(Je,{productId:a,size:"sm",min:0})]})},tt=()=>{const{isCartOpen:r,cart:a,setIsCartOpen:i}=ke(),n=o(),{t:l}=Re(),d=s(a),c=()=>i(!1);return r?e("div",{className:Ue.container,onClick:e=>{var t,r;(null===(r=null===(t=null==n?void 0:n.current)||void 0===t?void 0:t.contains)||void 0===r?void 0:r.call(t,null==e?void 0:e.target))||c()},children:e(N,{ref:n,onClose:c,isOpen:r,title:l("Your order"),content:e("div",{className:Ue.content,children:d?e((()=>t(y,{className:Ue.noItems,fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",gap:0,children:[e(k,{variant:"h2",children:l("Empty order")}),e(L,{text:l("You don't have any items in your order")})]})),{}):e("div",{className:Ue.items,children:Object.keys(a||{}).map((t=>e(et,{item:a[t]},t)))})}),footer:d?e(O,{label:l("Add items"),onClick:c,type:I.PRIMARY,size:"xl",fullWidth:!0}):e(Me,{actionText:l("Subtotal")})})}):null},rt=c((({categoryProductMap:r=[],currency:a,language:i,productBlocksRef:o,containerRef:d,onCategoryInView:c})=>{const[s,u]=n(null);return l((()=>{const e=new IntersectionObserver((e=>{var t;const r=((null===(t=null==d?void 0:d.current)||void 0===t?void 0:t.clientHeight)||1e3)/2;let a=null,i=1/0;e.forEach((e=>{if(e.isIntersecting){const t=e.boundingClientRect,n=t.top+t.height/2,o=Math.abs(n-r);o<i&&(i=o,a=e.target.getAttribute("data-category-id"))}})),a&&c(Number(a))}),{threshold:.5});return Object.entries(o.current||{}).forEach((([t,r])=>{r&&(r.setAttribute("data-category-id",t),e.observe(r))})),()=>{e.disconnect()}}),[o,d]),e(Ne,{children:t("div",{className:Pe,children:[e(y,{children:(r||[]).map((r=>{const{name:n}=((e,t)=>{var r,a;return(null===(a=null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.find)||void 0===a?void 0:a.call(r,(e=>e.language===t)))||{}})(r,i),{id:l,products:d}=r;return t("div",{className:Ie,ref:e=>o.current[l]=e,"data-category-id":l,children:[e("h2",{className:Ae,children:n}),e("div",{className:we,children:e(y,{gap:0,children:(d||[]).map((t=>e(ze,{product:t,currency:a,language:i,onClick:()=>u(t)},t.id)))})})]},l)}))}),e(Be,{product:s,onClose:()=>u(null)}),e(Fe,{}),e(tt,{})]})})}),((e,t)=>e.categoryProductMap===t.categoryProductMap&&e.currency===t.currency&&e.language===t.language));var at="Branches-module_branches__sOuoV",it="Branches-module_list__vYoT2",nt="Branches-module_name__K0Z-4";const ot=({branches:t=[],rootPath:r="",onBranchSelect:a})=>{const i=({children:t,id:i})=>a?e("div",{onClick:()=>a(i),children:t}):e("a",{href:`${r}/${i}`,children:t});return e("div",{className:at,children:e(S,{className:it,children:t.map((({id:t,name:r})=>e(i,{id:t,children:e(D,{noBottomMargin:!0,children:e(f,{justifyContent:"center",alignItems:"center",fullHeight:!0,children:e("h2",{className:nt,children:r})})})},t)))})})},lt=({data:a})=>{var i;const{name:l,coverImage:d,logoImage:c,branches:s=[],branchId:u,language:m,categories:_,products:h,currency:g,instagram:p,facebook:v,whatsapp:f,telegram:y,tiktok:b,rootPath:C,hostname:P,onBranchSelect:I}=a||{},A=s.length<=1,w=((e,t)=>{const r=t.reduce(((e,t)=>{const r=Number(t.categoryId);return e[r]||(e[r]=[]),e[r].push(t),e}),{});return e.map((e=>Object.assign(Object.assign({},e),{products:r[Number(e.id)]||[]}))).filter((e=>{var t;return(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t.length)>0}))})(_,h),O=(()=>{var e;return A?(null===(e=null==s?void 0:s[0])||void 0===e?void 0:e.id)?s[0]:{}:s.find((e=>e.id===Number(u)))})(),N=A||!(null==O?void 0:O.name)?l:(null==O?void 0:O.name)||"",[k,L]=n(null===(i=null==_?void 0:_[0])||void 0===i?void 0:i.id),S=o({}),D=o(null),T=o(!0),{url:z,domain:j}=((e,t)=>{const r=te.includes(e)?e:ee;return{url:`https://${r}/${t||"en"}`,domain:r}})(P,m);return t("div",{className:F,ref:D,children:[e(be,{branch:O,name:N,coverImage:K(d),logoImage:Z(c),instagram:p,facebook:v,whatsapp:f,telegram:y,tiktok:b}),A||u?t(r,{children:[e(Ce,{categoryProductMap:w,language:m,selectedCategoryId:k,onSelectCategory:e=>M(void 0,void 0,void 0,(function*(){T.current=!1,L(e),(e=>{var t;const r=null===(t=null==S?void 0:S.current)||void 0===t?void 0:t[e];r&&(setTimeout((()=>{r.scrollIntoView({behavior:"smooth",block:"start"})}),100),setTimeout((()=>{T.current=!0}),1e3))})(e)}))}),e(rt,{currency:g,language:m,productBlocksRef:S,containerRef:D,categoryProductMap:w,onCategoryInView:e=>{(null==T?void 0:T.current)&&L(e)}})]}):e(ot,{branches:s,onBranchSelect:I,rootPath:C}),!!P&&e("a",{rel:"noopener",target:"_blank",href:z,className:V,children:j})]})},dt=({data:t})=>e(ae,{value:t,children:e(lt,{data:t})});export{dt as PublicMenu};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{createContext as a,useContext as i,useState as n,useRef as o,useEffect as l,useMemo as d,memo as c}from"react";import{isEmpty as s,priceFormatter as u,classNames as m}from"@sorocraft/js-utils";import{Row as _,classNames as h,IconLink as g,Tooltip as p,SVGIcon as v,Flex as f,Column as y,Carousel as b,CarouselItem as C,Chip as P,UIElementType as I,IconButton as A,Modal as N,Button as w,Drawer as O,Text as k,Description as L,Container as S,Card as D}from"@sorocraft/ui";import{Phone as T,Whatsapp as z,Instagram as j,Telegram as x,Tiktok as R,Facebook as Q,Wifi as W,MarkerPin as H,Plus as B,Minus as E,Close as q}from"@sorocraft/ui/icons";function Y(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(r[a[i]]=e[a[i]])}return r}function M(e,t,r,a){return new(r||(r=Promise))((function(i,n){function o(e){try{d(a.next(e))}catch(e){n(e)}}function l(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,l)}d((a=a.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var F="PublicMenu-module_container__QLN6U",U="PublicMenu-module_categories__Iy6NC",V="PublicMenu-module_footer__6G3DQ";const $="https://images.restaround.co",G=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"",Z=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"https://images.restaround.co/no-photo-128.webp",K=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"https://images.restaround.co/restaround-doodle.webp",X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",J=(e,t,r)=>X.charAt(e>>2)+X.charAt((3&e)<<4|t>>4)+X.charAt((15&t)<<2|r>>6)+X.charAt(63&r),ee="restaround.co",te=[ee,"restaround.az","restaround.ee","restaround.nl"],re=a({}),ae=({children:t,value:r})=>{const a=s(r)?{}:r;return a.currency||a.currency,a.language||a.language,e(re.Provider,{value:s(r)?{}:r,children:t})},ie=()=>i(re);var ne="Header-module_container__tenlF",oe="Header-module_cover__BAWZK",le="Header-module_content__Gx4Al",de="Header-module_logo__4MTCm",ce="Header-module_info__IchYA",se="Header-module_name__30wyw",ue="Header-module_address__WOxXc",me="Header-module_addressText__lUszI",_e="Header-module_social__AoP0z",he="Header-module_links__EeQxg",ge="Header-module_wifiPassword__VWBTa",pe="Header-module_wifiPasswordIcon__Ukn3D";const ve=t=>{const r=Y(t,["priority","blurDataURL","quality","placeholder","fetchPriority"]),{imageTag:a}=ie()||{};if(a){return e(a,Object.assign({},t,{quality:t.quality||100,placeholder:"blur",blurDataURL:(i=235,n=59,o=90,`data:image/gif;base64,R0lGODlhAQABAPAA${J(0,i,n)+J(o,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`)}))}var i,n,o;return e("img",Object.assign({},r))};var fe={container:"Languages-module_container__nJeK1",currentLanguage:"Languages-module_currentLanguage__EFw6Q",options:"Languages-module_options__6jLRm",option:"Languages-module_option__QkVQd",isOpen:"Languages-module_isOpen__eUGbg",flexWide:"Languages-module_flexWide__zQ9jN",slidein:"Languages-module_slidein__C4UHU",fadeInOut:"Languages-module_fadeInOut__U-vhH",heightAnimation:"Languages-module_heightAnimation__gIQkF",fadein:"Languages-module_fadein__vPmsX",floatAnimation:"Languages-module_floatAnimation__L-kPH",bottomSheet:"Languages-module_bottomSheet__-t-q8",slideRightToLeft:"Languages-module_slideRightToLeft__y0l-f"};const ye=()=>{var r;const{language:a,languages:i,onLanguageSelect:o}=ie(),[l,d]=n(!1),c=(null==i?void 0:i.length)>1,s=(null===(r=null==i?void 0:i.filter)||void 0===r?void 0:r.call(i,(({code:e})=>e!==a)))||[],u=e=>`https://images.restaround.co/languages/${e}.svg`;return c?e("div",{className:fe.container,onClick:()=>d(!l),children:t(_,{alignItems:"center",gap:0,children:[e(_,{alignItems:"center",className:h(fe,{options:!0,isOpen:l}),children:s.map((({code:t})=>e("img",{src:u(t),className:fe.option,onClick:()=>(e=>{o&&o(e)})(t),alt:t},t)))}),e("img",{src:u(a),alt:a||"",className:fe.currentLanguage})]})}):null},be=({branch:r,coverImage:a,logoImage:i,name:n,instagram:o,facebook:l,whatsapp:d,telegram:c,tiktok:u})=>{const{address:m,latitude:h,longitude:b,phone:C,wifiPassword:P}=r||{},I=s(r),A=`https://www.google.com/maps/place/${h},${b}`;return t("div",{className:ne,children:[e(ve,{src:a,alt:n,className:oe,width:1024,height:400,priority:!0,sizes:"100vw",fetchPriority:"high",loading:"eager"}),e("div",{className:le,children:e(I?()=>t(y,{fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",children:[e(ve,{src:i,alt:n,className:de,width:96,height:96}),e("div",{className:ce,children:e("h1",{className:se,children:n})})]}):()=>t(f,{direction:"row",gap:1,alignItems:"center",children:[e(f.Item,{children:e(ve,{src:i,alt:n,className:de,width:96,height:96})}),e(f.Item,{shrink:!0,children:e("div",{className:ce,children:t(y,{gap:.25,children:[e("h1",{className:se,children:n}),e("a",{className:ue,href:A,target:"_blank",rel:"noopener noreferrer",children:t(_,{alignItems:"center",gap:.5,children:[e(v,{icon:H,theme:"dark"}),e("span",{className:me,children:m})]})})]})})})]}),{})}),e(ye,{}),!I&&e("div",{className:_e,children:e("div",{className:he,children:e(_,{gap:2,alignItems:"center",children:t(_,{alignItems:"center",justifyContent:"center",gap:.5,children:[!!C&&e(g,{icon:T,href:`tel:+${C}`,size:"sm",shape:"circle",theme:"light"}),!!d&&e(g,{icon:z,href:`https://wa.me/${d}`,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!o&&e(g,{icon:j,href:o,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!c&&e(g,{icon:x,href:c,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!u&&e(g,{icon:R,href:u,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!l&&e(g,{icon:Q,href:l,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!P&&e(p,{hint:P,children:e("div",{className:ge,children:e(v,{icon:W,size:"sm",className:pe})})})]})})})})]})},Ce=({categoryProductMap:t=[],language:r,selectedCategoryId:a,onSelectCategory:i})=>{const n=o({}),d=o(null);return l((()=>{a&&(()=>{var e;const t=null===(e=null==n?void 0:n.current)||void 0===e?void 0:e[a];if(!t||!d.current)return;const r=d.current.clientWidth,i=t.offsetLeft-r/2+t.offsetWidth/2;d.current.scrollTo({left:i,behavior:"smooth"})})()}),[a]),e("div",{className:U,children:e(b,{gap:1,onGetRef:e=>{(null==e?void 0:e.current)&&(d.current=e.current)},children:(t||[]).map((({id:t,translations:o})=>{const{name:l}=o.find((e=>e.language===r))||{};return e(C,{children:e(P,{onClick:()=>(e=>{e!==a&&i(e)})(t),type:I.BORDERED_PRIMARY,active:t===a,children:e("div",{ref:e=>n.current[t]=e,children:l})})},t)}))})})};var Pe="Products-module_container__bF2LF",Ie="Products-module_products__AoDrY",Ae="Products-module_category__Sp7dE",Ne="Products-module_list__LH4v5";const we=a({cart:{},isCartOpen:!1,addProduct:()=>{},updateProduct:()=>{},setIsCartOpen:()=>{}}),Oe=({children:t})=>{const[r,a]=n({}),[i,o]=n(!1),l=(e,t,r)=>{if(s(e)||t<0)return;const{id:i,price:n,vat:o=0}=e;a((e=>{const a=e[i],l=r?((null==a?void 0:a.quantity)||0)+t:t;if(l<=0){const t=e,r=i;t[r];return Y(t,["symbol"==typeof r?r:r+""])}return Object.assign(Object.assign({},e),{[i]:{productId:i,price:n,quantity:l,vat:o}})}))},c=(e,t=1)=>l(e,t,!0),u=(e,t=1)=>l(e,t,!1),m=d((()=>({cart:r,isCartOpen:i,addProduct:c,updateProduct:u,setIsCartOpen:o})),[r,i]);return e(we.Provider,{value:m,children:t})},ke=()=>i(we);var Le={container:"ProductsListItem-module_container__i9tFs",isClickable:"ProductsListItem-module_isClickable__iHHdI",data:"ProductsListItem-module_data__Mb3SF",name:"ProductsListItem-module_name__T1gyJ",description:"ProductsListItem-module_description__oL4CH",price:"ProductsListItem-module_price__V1GRM",image:"ProductsListItem-module_image__h6Wbi",addToCart:"ProductsListItem-module_addToCart__WXrQZ",flexWide:"ProductsListItem-module_flexWide__Ds6LE",slidein:"ProductsListItem-module_slidein__rEzMI",fadeInOut:"ProductsListItem-module_fadeInOut__i1FNq",heightAnimation:"ProductsListItem-module_heightAnimation__2fk7l",fadein:"ProductsListItem-module_fadein__tPTJ6",floatAnimation:"ProductsListItem-module_floatAnimation__vugAV",bottomSheet:"ProductsListItem-module_bottomSheet__-YAdd",slideRightToLeft:"ProductsListItem-module_slideRightToLeft__oXk26"};const Se=(e,t)=>{var r,a;return(null===(a=null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.find)||void 0===a?void 0:a.call(r,(e=>e.language===t)))||{}},De=(e,t,r=0)=>e*t*(1+r/100),Te=(e,t,r,a=1)=>{const{price:i,vat:n}=e||{},o=De(i,a,n);return{totalPrice:o,formattedTotalPrice:u(o,t,r)}},ze=({product:r,currency:a,language:i,onClick:n})=>{const{addProduct:o}=ke(),{image160:l,volume:c}=r||{},{name:s,description:u}=d((()=>Se(r,i)),[r,i]),{formattedTotalPrice:h}=d((()=>Te(r,a,i)),[r,a,i]);return t("div",{className:m(Le,{container:!0,isClickable:!!n}),onClick:n,children:[t(_,{justifyContent:"space-between",gap:0,children:[e("div",{className:Le.data,children:t(y,{gap:.25,children:[e("h3",{className:Le.name,children:t(_,{gap:.5,fullWidth:!0,children:[e("span",{children:s}),!!c&&t("span",{children:["(",c,")"]})]})}),e("div",{className:Le.description,children:u}),e("div",{className:Le.price,children:h})]})}),l&&e(ve,{src:G(l),alt:s||"menu",className:Le.image,loading:"lazy",width:160,height:90})]}),e("div",{className:Le.addToCart,children:e(A,{onClick:e=>{e.preventDefault(),e.stopPropagation(),o(r)},icon:B,type:I.DEFAULT})})]})};var je={container:"ProductDetails-module_container__oa07j",content:"ProductDetails-module_content__Db3NC",image:"ProductDetails-module_image__BlMfl",details:"ProductDetails-module_details__zfnlt",name:"ProductDetails-module_name__ganLM",price:"ProductDetails-module_price__W34k9",volume:"ProductDetails-module_volume__RWG5s",description:"ProductDetails-module_description__HBufi",close:"ProductDetails-module_close__4cHZ3",addAction:"ProductDetails-module_addAction__o4T5R",actionTitle:"ProductDetails-module_actionTitle__NIJGW",flexWide:"ProductDetails-module_flexWide__w06FX",slidein:"ProductDetails-module_slidein__N8f4g",fadeInOut:"ProductDetails-module_fadeInOut__hYRtK",heightAnimation:"ProductDetails-module_heightAnimation__hLQyz",fadein:"ProductDetails-module_fadein__QN4mI",floatAnimation:"ProductDetails-module_floatAnimation__dTQbc",bottomSheet:"ProductDetails-module_bottomSheet__HO2S-",slideRightToLeft:"ProductDetails-module_slideRightToLeft__hbtJg"};const xe={en:{viewOrder:"View order",removeFromOrder:"Remove from order",updateOrder:"Update order",addToOrder:"Add to order"},az:{viewOrder:"Şifarişi göstər",removeFromOrder:"Sifarişdən sil",updateOrder:"Sifarişi yenilə",addToOrder:"Sifarişə əlavə et","Your order":"Sifarişiniz",Subtotal:"Ümumi","Empty order":"Boş sifariş","You don't have any items in your order":"Sifarişinizdə heç bir məhsul yoxdur","Add items":"Məhsul əlavə et"},tr:{viewOrder:"Siparişi Görüntüle",removeFromOrder:"Siparişten Kaldır",updateOrder:"Siparişi Güncelle",addToOrder:"Siparişe Ekle","Your order":"Siparişiniz","Empty order":"Boş sipariş","You don't have any items in your order":"Siparişinizde hiç bir ürün yok","Add items":"Ürün ekle",Subtotal:"Toplam"},nl:{viewOrder:"Bestelling bekijken",removeFromOrder:"Uit bestelling verwijderen",updateOrder:"Bestelling bijwerken",addToOrder:"Aan bestelling toevoegen","Your order":"Uw bestelling","Empty order":"Lege bestelling","You don't have any items in your order":"U heeft geen items in uw bestelling","Add items":"Items toevoegen",Subtotal:"Totaal"},et:{viewOrder:"Vaata tellimust",removeFromOrder:"Eemalda tellimusest",updateOrder:"Uuenda tellimust",addToOrder:"Lisa tellimusele","Your order":"Teie tellimus","Empty order":"Tühi tellimus","You don't have any items in your order":"Teie tellimuses pole ühtegi eset","Add items":"Lisa esemeid",Subtotal:"Kokku"},pl:{viewOrder:"Zobacz zamówienie",removeFromOrder:"Usuń z zamówienia",updateOrder:"Zaktualizuj zamówienie",addToOrder:"Dodaj do zamówienia","Your order":"Twoje zamówienie","Empty order":"Puste zamówienie","You don't have any items in your order":"Nie masz żadnych pozycji w zamówieniu","Add items":"Dodaj przedmioty",Subtotal:"Suma"},ru:{viewOrder:"Посмотреть заказ",removeFromOrder:"Удалить из заказа",updateOrder:"Обновить заказ",addToOrder:"Добавить в заказ","Your order":"Ваш заказ","Empty order":"Пустой заказ","You don't have any items in your order":"В вашем заказе нет товаров","Add items":"Добавить товары",Subtotal:"Итого"}},Re=()=>{const{language:e}=ie();return{t:t=>{var r;return(null===(r=xe[e])||void 0===r?void 0:r[t])||t}}},Qe=()=>{const{cart:e}=ke();return Object.values(e||{}).reduce(((e,t)=>e+t.quantity),0)};var We={container:"Quantity-module_container__01ySb",quantityAction:"Quantity-module_quantityAction__wRV2F",quantityValue:"Quantity-module_quantityValue__BBpyw",isDisabled:"Quantity-module_isDisabled__crQCf",sm:"Quantity-module_sm__0Hgp2",md:"Quantity-module_md__hu7a8",lg:"Quantity-module_lg__GA4jn",flexWide:"Quantity-module_flexWide__R95Jw",slidein:"Quantity-module_slidein__5yeWf",fadeInOut:"Quantity-module_fadeInOut__cllco",heightAnimation:"Quantity-module_heightAnimation__dhOgA",fadein:"Quantity-module_fadein__Cof2o",floatAnimation:"Quantity-module_floatAnimation__DSqQr",bottomSheet:"Quantity-module_bottomSheet__5-5iY",slideRightToLeft:"Quantity-module_slideRightToLeft__cjDHk"};const He=({isDecreaseDisabled:r=!1,quantity:a=1,size:i="md",onIncrease:n,onDecrease:o})=>t(_,{className:m(We,{container:!0},[We[i]]),justifyContent:"space-between",gap:0,children:[e("div",{className:m(We,{quantityAction:!0,isDisabled:r}),onClick:o,children:e(v,{icon:E})}),e("div",{className:We.quantityValue,children:a}),e("div",{className:We.quantityAction,onClick:n,children:e(v,{icon:B})})]}),Be=({product:r,onClose:a})=>{const{language:i,currency:c}=ie(),{addProduct:m,updateProduct:h}=ke(),[g,p]=n(1),[v,f]=n(!1),b=o(),{t:C}=Re(),P=(e=>{var t;const{cart:r}=ke();return s(r)||!e?0:(null===(t=r[e])||void 0===t?void 0:t.quantity)||0})(null==r?void 0:r.id),{name:I,description:O}=d((()=>Se(r,i)),[r,i]),{totalPrice:k,formattedTotalPrice:L}=d((()=>Te(r,c,i)),[r,c,i]),S=d((()=>g*k),[g,k]),D=d((()=>u(S,c,i)),[S,c,i]),T=v?0===g:1===g,z=d((()=>C(v?0===g?"removeFromOrder":"updateOrder":"addToOrder")),[v,g]);l((()=>{p(P>0?P:1),f(P>0)}),[P,r]);const j=e=>{-1===e&&T||p((t=>Math.max(0,t+e)))};if(s(r))return null;const{image1024:x,volume:R}=r;return e("div",{className:je.container,onClick:e=>{var t,r;(null===(r=null===(t=null==b?void 0:b.current)||void 0===t?void 0:t.contains)||void 0===r?void 0:r.call(t,null==e?void 0:e.target))||a&&a()},children:e(N,{onClose:a,ref:b,noBodyPadding:!0,size:"small",content:t("div",{className:je.content,children:[t(y,{gap:0,children:[x&&e(ve,{src:G(x),width:1024,height:400,alt:I||"product",className:je.image}),t(y,{className:je.details,gap:1,children:[e("h2",{className:je.name,children:I}),t(_,{justifyContent:"space-between",children:[e("div",{className:je.price,children:L}),e("div",{className:je.volume,children:R})]}),e("div",{className:je.description,children:O})]})]}),e("div",{className:je.close,children:e(A,{onClick:a,icon:q})})]}),footer:t(_,{className:je.addToCart,gap:.5,children:[e(He,{isDecreaseDisabled:T,onDecrease:()=>j(-1),onIncrease:()=>j(1),quantity:g}),e(w,{className:je.addAction,label:t(_,{fullWidth:!0,justifyContent:"space-between",children:[e("span",{className:je.actionTitle,children:z}),e("span",{children:D})]}),onClick:()=>{v?h(r,g):m(r,g),a&&a()},size:"xl",fullWidth:!0})]})})})};var Ee="Cart-module_container__3KQtx",qe="Cart-module_content__rkiZa",Ye={container:"CartStepper-module_container__4CF1L",count:"CartStepper-module_count__E-RBg",actionText:"CartStepper-module_actionText__-rVKA",totalPrice:"CartStepper-module_totalPrice__QboRN",isClickable:"CartStepper-module_isClickable__mDptU",flexWide:"CartStepper-module_flexWide__eXxCr",slidein:"CartStepper-module_slidein__d5JQ-",fadeInOut:"CartStepper-module_fadeInOut__pS8nn",heightAnimation:"CartStepper-module_heightAnimation__7-e5Z",fadein:"CartStepper-module_fadein__-Ba0-",floatAnimation:"CartStepper-module_floatAnimation__rq6zX",bottomSheet:"CartStepper-module_bottomSheet__1wHHD",slideRightToLeft:"CartStepper-module_slideRightToLeft__0KLAo"};const Me=({actionText:r,onClick:a})=>{const i=Qe(),{formattedTotalPrice:n}=(()=>{const{cart:e}=ke(),{currency:t,language:r}=ie(),a=Object.values(e||{}).reduce(((e,{price:t,quantity:r,vat:a})=>e+De(t,r,a)),0);return{totalPrice:a,formattedTotalPrice:u(a,t,r)}})();return t(f,{className:m(Ye,{container:!0,isClickable:!!a}),justifyContent:"space-between",alignItems:"center",onClick:a,children:[e(f.Item,{flex:1,children:t(_,{alignItems:"center",children:[e("div",{className:Ye.count,children:i}),e("div",{className:Ye.actionText,children:r})]})}),e(f.Item,{className:Ye.totalPrice,flex:1,children:n})]})},Fe=()=>{const{setIsCartOpen:t}=ke(),{t:r}=Re();return Qe()<=0?null:e("div",{className:Ee,children:e("div",{className:qe,children:e(Me,{onClick:()=>t(!0),actionText:r("viewOrder")})})})};var Ue={container:"CartDrawer-module_container__zvapw",content:"CartDrawer-module_content__ELSiG",flexWide:"CartDrawer-module_flexWide__ySgY-",slidein:"CartDrawer-module_slidein__XC9AW",fadeInOut:"CartDrawer-module_fadeInOut__w9h6X",heightAnimation:"CartDrawer-module_heightAnimation__tBgkj",fadein:"CartDrawer-module_fadein__QNPoQ",floatAnimation:"CartDrawer-module_floatAnimation__nZWoY",bottomSheet:"CartDrawer-module_bottomSheet__m0wy7",slideRightToLeft:"CartDrawer-module_slideRightToLeft__gpixh"},Ve="CartItem-module_container__At7lj",$e="CartItem-module_image__D-zzG",Ge="CartItem-module_data__Lo3Fb",Ze="CartItem-module_name__EksZu",Ke="CartItem-module_price__yJxl6";const Xe=e=>{var t;const{products:r}=ie();return(null===(t=null==r?void 0:r.find)||void 0===t?void 0:t.call(r,(({id:t})=>t===e)))||{}},Je=({productId:t,min:r=1,size:a="md"})=>{const i=(e=>{const{cart:t}=ke(),r=t[e];return(null==r?void 0:r.quantity)||1})(t),n=Xe(t),{updateProduct:o}=ke();return e(He,{isDecreaseDisabled:i===r,onDecrease:()=>o(n,i-1),onIncrease:()=>o(n,i+1),quantity:i,size:a})},et=({item:r})=>{const{productId:a,quantity:i}=r||{},n=Xe(a),{language:o,currency:l}=ie(),{image160:c}=n,{name:s}=d((()=>Se(n,o)),[n,o]),{formattedTotalPrice:u}=d((()=>Te(n,l,o,i)),[n,l,o,i]);return t(_,{className:Ve,gap:1,alignItems:"center",children:[c&&e(ve,{src:G(c),alt:s||"menu",className:$e,loading:"lazy",width:80,height:45}),t("div",{className:Ge,children:[e("div",{className:Ze,children:s}),e("div",{className:Ke,children:u})]}),e(Je,{productId:a,size:"sm",min:0})]})},tt=()=>{const{isCartOpen:r,cart:a,setIsCartOpen:i}=ke(),n=o(),{t:l}=Re(),d=s(a),c=()=>i(!1);return r?e("div",{className:Ue.container,onClick:e=>{var t,r;(null===(r=null===(t=null==n?void 0:n.current)||void 0===t?void 0:t.contains)||void 0===r?void 0:r.call(t,null==e?void 0:e.target))||c()},children:e(O,{ref:n,onClose:c,isOpen:r,title:l("Your order"),content:e("div",{className:Ue.content,children:d?e((()=>t(y,{className:Ue.noItems,fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",gap:0,children:[e(k,{variant:"h2",children:l("Empty order")}),e(L,{text:l("You don't have any items in your order")})]})),{}):e("div",{className:Ue.items,children:Object.keys(a||{}).map((t=>e(et,{item:a[t]},t)))})}),footer:d?e(w,{label:l("Add items"),onClick:c,type:I.PRIMARY,size:"xl",fullWidth:!0}):e(Me,{actionText:l("Subtotal")})})}):null},rt=c((({categoryProductMap:r=[],currency:a,language:i,productBlocksRef:o,containerRef:d,onCategoryInView:c})=>{const[s,u]=n(null);return l((()=>{const e=new IntersectionObserver((e=>{var t;const r=((null===(t=null==d?void 0:d.current)||void 0===t?void 0:t.clientHeight)||1e3)/2;let a=null,i=1/0;e.forEach((e=>{if(e.isIntersecting){const t=e.boundingClientRect,n=t.top+t.height/2,o=Math.abs(n-r);o<i&&(i=o,a=e.target.getAttribute("data-category-id"))}})),a&&c(Number(a))}),{threshold:.5});return Object.entries(o.current||{}).forEach((([t,r])=>{r&&(r.setAttribute("data-category-id",t),e.observe(r))})),()=>{e.disconnect()}}),[o,d]),e(Oe,{children:t("div",{className:Pe,children:[e(y,{children:(r||[]).map((r=>{const{name:n}=((e,t)=>{var r,a;return(null===(a=null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.find)||void 0===a?void 0:a.call(r,(e=>e.language===t)))||{}})(r,i),{id:l,products:d}=r;return t("div",{className:Ie,ref:e=>o.current[l]=e,"data-category-id":l,children:[e("h2",{className:Ae,children:n}),e("div",{className:Ne,children:e(y,{gap:0,children:(d||[]).map((t=>e(ze,{product:t,currency:a,language:i,onClick:()=>u(t)},t.id)))})})]},l)}))}),e(Be,{product:s,onClose:()=>u(null)}),e(Fe,{}),e(tt,{})]})})}),((e,t)=>e.categoryProductMap===t.categoryProductMap&&e.currency===t.currency&&e.language===t.language));var at="Branches-module_branches__sOuoV",it="Branches-module_list__vYoT2",nt="Branches-module_name__K0Z-4";const ot=({branches:t=[],rootPath:r="",onBranchSelect:a})=>{const i=({children:t,id:i})=>a?e("div",{onClick:()=>a(i),children:t}):e("a",{href:`${r}/${i}`,children:t});return e("div",{className:at,children:e(S,{className:it,children:t.map((({id:t,name:r})=>e(i,{id:t,children:e(D,{noBottomMargin:!0,children:e(f,{justifyContent:"center",alignItems:"center",fullHeight:!0,children:e("h2",{className:nt,children:r})})})},t)))})})},lt=({data:a})=>{var i;const{name:l,coverImage:d,logoImage:c,branches:s=[],branchId:u,language:m,categories:_,products:h,currency:g,instagram:p,facebook:v,whatsapp:f,telegram:y,tiktok:b,rootPath:C,hostname:P,onBranchSelect:I}=a||{},A=s.length<=1,N=((e,t)=>{const r=t.reduce(((e,t)=>{const r=Number(t.categoryId);return e[r]||(e[r]=[]),e[r].push(t),e}),{});return e.map((e=>Object.assign(Object.assign({},e),{products:r[Number(e.id)]||[]}))).filter((e=>{var t;return(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t.length)>0}))})(_,h),w=(()=>{var e;return A?(null===(e=null==s?void 0:s[0])||void 0===e?void 0:e.id)?s[0]:{}:s.find((e=>e.id===Number(u)))})(),O=A||!(null==w?void 0:w.name)?l:(null==w?void 0:w.name)||"",[k,L]=n(null===(i=null==_?void 0:_[0])||void 0===i?void 0:i.id),S=o({}),D=o(null),T=o(!0),{url:z,domain:j}=((e,t)=>{const r=te.includes(e)?e:ee;return{url:`https://${r}/${t||"en"}`,domain:r}})(P,m);return t("div",{className:F,ref:D,children:[e(be,{branch:w,name:O,coverImage:K(d),logoImage:Z(c),instagram:p,facebook:v,whatsapp:f,telegram:y,tiktok:b}),A||u?t(r,{children:[e(Ce,{categoryProductMap:N,language:m,selectedCategoryId:k,onSelectCategory:e=>M(void 0,void 0,void 0,(function*(){T.current=!1,L(e),(e=>{var t;const r=null===(t=null==S?void 0:S.current)||void 0===t?void 0:t[e];r&&(setTimeout((()=>{r.scrollIntoView({behavior:"smooth",block:"start"})}),100),setTimeout((()=>{T.current=!0}),1e3))})(e)}))}),e(rt,{currency:g,language:m,productBlocksRef:S,containerRef:D,categoryProductMap:N,onCategoryInView:e=>{(null==T?void 0:T.current)&&L(e)}})]}):e(ot,{branches:s,onBranchSelect:I,rootPath:C}),!!P&&e("a",{rel:"noopener",target:"_blank",href:z,className:V,children:j})]})},dt=({data:t})=>e(ae,{value:t,children:e(lt,{data:t})});export{dt as PublicMenu};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|