PageSourceSearch

https://pide.comecamila.com/_next/static/chunks/pages/[resturant]/cart.js

js comecamila.com collected 2026-10-04 10:53:28 UTC 355,632 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7061868e-ed88-4509-af82-a0a99e5671b2",e._sentryDebugIdIdentifier="sentry-dbid-7061868e-ed88-4509-af82-a0a99e5671b2")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[463,3259,6305,6635,8442,8753,8975,9231],{65498:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/[resturant]/cart",function(){return r(59284)}])},66635:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>l});var o=r(74848),a=r(96540);let i=e=>{var t;let{type:r,onClick:i,children:l,disabled:n=!1}=e,[s,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(!0);if((0,a.useEffect)(()=>{let e=localStorage.getItem("resturantserversideTheme");e&&d(JSON.parse(e)),u(!1)},[]),c)return null;null==s||s.primary_text_color;let m=(null==s?void 0:s.primary_button_color)||"#000000",_=(null==s?void 0:s.primary_button_text_color)||"#FFCD00",p=(null==s?void 0:s.secondary_button_color)||"#FFCD00",v=(null==s?void 0:s.secondary_button_text_color)||"#000000",g=(null==s?void 0:null===(t=s.fonts)||void 0===t?void 0:t.name)||"sans-serif",f="",y={};switch(r){case"primary":f="font-bold py-2 px-4 text-sm rounded-3xl",y={backgroundColor:m,color:_,fontFamily:"".concat(g,", sans-serif")};break;case"secondary":f="text-xs font-black lg:py-3 lg:px-5 py-2 px-4 rounded-lg",y={backgroundColor:p,color:v,fontFamily:"".concat(g,", sans-serif")};break;case"yellowRounded":f="text-sm font-black py-2.5 px-5 rounded-3xl",y={backgroundColor:p,color:v,fontFamily:"".concat(g,", sans-serif")};break;case"danger":f="bg-red-500 hover:bg-red-700 text-white font-bold py-1.5 px-4 rounded";break;case"success":f="bg-green-500 hover:bg-green-700 text-white font-bold py-1.5 px-4 rounded";break;case"yellowRoundedItemDetail":f="text-[11px] font-black py-3 px-4 rounded-3xl w-full  ",y={backgroundColor:p,color:v,fontFamily:"".concat(g,", sans-serif"),fontWeight:900};break;default:f="bg-gray-500 hover:bg-gray-700 text-white font-bold py-1.5 px-4 rounded"}return(0,o.jsx)("button",{className:f,style:{...y,opacity:n?.6:1,cursor:n?"not-allowed":"pointer"},onClick:n?void 0:i,disabled:n,children:l})},l=e=>{let{type:t,text:r,onClick:a,disabled:l}=e;return(0,o.jsx)(i,{type:t,onClick:a,disabled:l,children:r})}},86305:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i});var o=r(74848);r(96540);var a=r(77255);let i=e=>{let{message:t,onClose:r}=e,{t:i}=(0,a.Bd)();return(0,o.jsx)("div",{className:" h-[100px] fixed top-3 right-1 z-80 animate-slide-in",children:(0,o.jsxs)("div",{role:"alert",className:"rounded border-s-4 w-[350px] shadow-md border-red-500 bg-red-50 p-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 text-red-800",children:[(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"h-5 w-5",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})}),(0,o.jsxs)("strong",{className:"block font-medium",children:[" ",i("Something went wrong")," "]})]}),(0,o.jsx)("p",{className:"mt-2 text-sm text-red-700",children:t})]})})}},39231:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});
1var o=r(74848),a=r(29861),i=r(77255),l=r(78885);let n=e=>{let{open:t,setOpen:r,modalMessage:n,modalDetail:s,closeModal:d,redcolor:c,fontFamily:u}=e,{t:m}=(0,i.Bd)();return(0,o.jsx)(a.lG,{open:t,onClose:r,children:(0,o.jsx)("div",{className:"fixed top-3 right-1 z-[100000] animate-slide-in",children:(0,o.jsxs)("div",{className:"alert-box   border  rounded-lg flex-col w-[300px]  transform items-start   gap-4  bg-white transition delay-200 duration-500 ease-in-out",style:{zIndex:"100"},children:[(0,o.jsxs)("div",{className:"flex w-full items-start justify-between p-3",children:[(0,o.jsxs)("div",{className:" ",children:[(0,o.jsx)("span",{style:{fontFamily:"".concat(u,", sans-serif")},className:" text-[13px] font-medium leading-tight text-black",children:n}),s?(0,o.jsxs)("span",{style:{fontFamily:"".concat(u,", sans-serif")},className:"mt-1 block text-[11px] leading-tight text-gray-500",children:["(",s,")"]}):null]}),(0,o.jsx)("div",{className:"cursor-pointer duration-300 hover:opacity-70",onClick:d,children:(0,o.jsx)(l.LyW,{className:"h-5 w-5 text-black"})})]}),(0,o.jsx)("div",{style:{backgroundColor:c,fontFamily:"".concat(u,", sans-serif")},className:"flex h-4 w-full items-center justify-center rounded-b-lg"})]})})})}},18975:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i});var o=r(74848),a=r(29861);let i=e=>{let{open:t,setOpen:r,setAddress:i,children:l,setCheckItemurl:n}=e;return(0,o.jsxs)(a.lG,{className:"relative z-30",open:t,onClose:()=>{r(!1),i(""),n(!1)},children:[(0,o.jsx)(a.Xi,{transition:!0,className:"fixed inset-0 bg-gray-800 bg-opacity-60 transition-opacity data-[closed]:opacity-0 data-[enter]:duration-300 data-[leave]:duration-200 data-[enter]:ease-out data-[leave]:ease-in"}),(0,o.jsx)("div",{className:"fixed inset-0 z-20 w-screen overflow-y-auto",children:(0,o.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center sm:items-center sm:p-0",children:(0,o.jsx)(a.Lj,{transition:!0,className:"relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all data-[closed]:translate-y-4 data-[closed]:opacity-0 data-[enter]:duration-300 data-[leave]:duration-200 data-[enter]:ease-out data-[leave]:ease-in sm:my-8 sm:w-max mx-6 data-[closed]:sm:translate-y-0 data-[closed]:sm:scale-95",children:(0,o.jsx)("div",{className:"",children:l})})})})]})}},43259:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i});var o=r(74848),a=r(96540);let i=e=>{let{isOpen:t,setIsOpen:r,children:i,primarycolor:l,secondaycolor:n,setAddress:s}=e,d=(0,a.useRef)(null),c=(0,a.useCallback)(e=>{d.current&&!d.current.contains(e.target)&&e.preventDefault()},[]);return((0,a.useEffect)(()=>(t&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%",document.addEventListener("touchmove",c,{passive:!1}),document.addEventListener("wheel",c,{passive:!1})),()=>{document.body.style.overflow="",document.body.style.position="",document.body.style.width="",document.body.style.height="",document.removeEventListener("touchmove",c),document.removeEventListener("wheel",c)}),[t,c]),t)?(0,o.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-30 overflow-hidden",onClick:e=>{d.current&&!d.current.contains(e.target)&&(r(!1),s(""))},children:(0,o.jsxs)("div",{ref:d,className:"absolute bottom-0 left-0 right-0 z-30 bg-white rounded-t-[25px] transform transition-transform duration-300 ease-out",style:{maxHeight:"80vh",minHeight:"60vh",transform:t?"translateY(0)":"translateY(100%)"},children:[(0,o.jsx)("div",{className:"absolute",style:{top:"calc(-50px + env(safe-area-inset-top))",right:"1px"},children:(0,o.jsx)("div",{style:{backgroundColor:n},className:"w-[56px] h-[70px] ring-1 ring-white rounded-t-[70px] flex justify-center items-center cursor-pointer",onClick:()=>r(!t),children:(0,o.jsxs)("svg",{width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("rect",{width:"15.1632",height:"3.03264",transform:"matrix(0.707107 -0.707106 0.707107 0.707106 4.28906 15.0107)",fill:l}),(0,o.jsx)("rect",{width:"15.1632",height:"3.03264",transform:"matrix(-0.707107 -0.707106 0.707107 -0.707106 15.0107 17.155)",fill:l})]})})}),(0,o.jsx)("div",{className:"  overflow-hidden rounded-t-[25px]",style:{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain"},children:(0,o.jsx)("div",{className:"relative h-full",children:i})})]})}):null}},98442:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});
1var o=r(74848),a=r(29861),i=r(77255),l=r(78885);let n=e=>{let{open:t,setOpen:r,modalMessage:n,closeModal:s}=e,{t:d}=(0,i.Bd)();return(0,o.jsx)(a.lG,{open:t,onClose:r,children:(0,o.jsx)("div",{className:"fixed top-3 right-1 z-80 animate-slide-in",children:(0,o.jsxs)("div",{className:"alert-box   border  rounded-lg flex-col w-[300px]  transform items-start   gap-4  bg-white transition delay-200 duration-500 ease-in-out",style:{zIndex:"100"},children:[(0,o.jsxs)("div",{className:"flex w-full items-start justify-between p-3",children:[(0,o.jsxs)("div",{className:" ",children:[(0,o.jsxs)("div",{className:"text-green-500 text-lg font-medium leading-tig",children:[" ",d("success")]}),(0,o.jsx)("span",{className:"  text-[13px] font-medium leading-tight text-black",children:n})]}),(0,o.jsx)("div",{className:"cursor-pointer duration-300 hover:opacity-70",onClick:s,children:(0,o.jsx)(l.LyW,{className:"h-5 w-5 text-black"})})]}),(0,o.jsx)("div",{className:"flex h-4 w-full items-center bg-green-500 justify-center rounded-b-lg"})]})})})}},59284:(e,t,r)=>{"use strict";r.r(t),r.d(t,{__N_SSP:()=>t3,default:()=>t7});var o=r(74848),a=r(64251),i=r(95891),l=r(57968),n=r(43270);let s=!1,d=()=>{let e="https://[email protected]/4507985046339584";return!!e&&(l.KU()||s||(s=!0,n.Ts({dsn:e,tracesSampleRate:0,beforeSend:e=>{var t;return(null===(t=e.tags)||void 0===t?void 0:t.deliberate)==="true"?e:null}})),!!l.KU())},c=(e,t)=>{try{if(!d())return;a.wd("fallback"===e?"delivery_address_fell_back_to_selecteduseraddress":"delivery_address_missing_at_checkout",{level:"fallback"===e?"warning":"error",tags:{deliberate:"true",area:"delivery-address",alias:t.alias,resolved_from:t.resolved_from,is_callin:t.is_callin?"true":"false"},extra:{...t,url:window.location.href}})}catch(e){}};var u=r(96540),m=r(52698),_=r(76897),p=r(77255);let v=e=>{let{isOpen:t,onClose:r,type:a,onAction:i,primaryBtnColor:l="#FFCD00",primaryBtnTxtColor:n="#000000",secondaryBtnColor:s="#000000",secondaryBtnTxtColor:d="#FFFFFF"}=e,{t:c}=(0,p.Bd)();return t?(0,o.jsx)("div",{onClick:r,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 px-4 backdrop-blur-sm",children:(0,o.jsxs)("div",{onClick:e=>
1e.stopPropagation(),className:"relative w-full max-w-md scale-100 rounded-xl bg-white p-6 shadow-xl transition-all",children:[(0,o.jsx)("button",{onClick:r,className:"absolute right-3 top-3 rounded-full p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:(0,o.jsx)(_.A,{size:18})}),"SCHEDULE_EXPIRED"===a?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full",style:{backgroundColor:"".concat(l,"20")},children:(0,o.jsx)(m.A,{className:"h-6 w-6",style:{color:l}})}),(0,o.jsx)("h3",{className:"text-center text-lg font-semibold text-gray-900",children:c("schedule_expired_title")}),(0,o.jsx)("p",{className:"mt-2 text-center text-sm text-gray-600",children:c("schedule_expired_message")}),(0,o.jsxs)("div",{className:"mt-6 flex flex-col gap-2",children:[(0,o.jsx)("button",{onClick:()=>{i&&i()},className:"w-full rounded-lg px-4 py-2 text-sm font-semibold transition hover:opacity-90 focus:outline-none focus:ring-2",style:{backgroundColor:l,color:n},children:c("update_schedule_btn")}),(0,o.jsx)("button",{onClick:r,style:{backgroundColor:s,color:d},className:"w-full rounded-lg px-4 py-2 text-sm font-semibold transition hover:opacity-90 focus:outline-none focus:ring-2",children:c("close_btn")})]})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:c("notice_title")}),(0,o.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:c("generic_error_message")}),(0,o.jsx)("button",{onClick:r,className:"mt-6 w-full rounded-lg bg-gray-900 px-4 py-2 text-sm font-semibold text-white hover:bg-gray-800",children:c("close_btn")})]})]})}):null},g=e=>{let{onClick:t,text:r,secondaryBtnTxtColor:a,secondaryBtnColor:i,fontFamily:l,taxDetails:n,loader:s,cartItemDetails:d,currency:c}=e,{t:u}=(0,p.Bd)();return(0,o.jsx)("div",{children:(0,o.jsxs)("div",{style:{backgroundColor:i,
1color:a,fontFamily:"".concat(l," , sans-serif")},onClick:t,className:"cursor-pointer flex justify-center items-center text-[17px] leading-4 font-black  py-5  rounded-full ",children:[s?"Cargando...":r," -"," ",n&&d.length>0?"".concat(c).concat(n):c+0]})})};var f=r(29965),y=r.n(f),h=r(86715),x=r(20181),b=r.n(x),w=r(18491),N=r(18030),j=r(24112),k=r(53336),S=r(84345),C=r(29861),I=r(27930),F=r(36802),E=r(89268),A=r(16810);let D=async(e,t)=>{let{City:o}=await Promise.all([r.e(7831),r.e(6543)]).then(r.bind(r,46543));return o.getCitiesOfState(e,t)},O=e=>{let{onClose:t,formData:r,setPaymentCardModal:a,open:i,setOpen:l,secondaryBtnColor:n,primarybtn:s,primarybtntxt:d,secondaryBtnTxtColor:c,fontFamily:u,primaryColor:m,setIsOpen:_,cardLimitReached:v}=e,g=e=>{if(e&&v)return;let t={...r,saveCard:e};sessionStorage.setItem("cardForm",JSON.stringify(t)),sessionStorage.setItem("cardFormBoolean","true"),a(!1),l(!1),_(!0)},{t:f}=(0,p.Bd)();return(0,o.jsxs)(C.lG,{open:i,onClose:l,className:"relative z-50",children:[(0,o.jsx)(C.Xi,{transition:!0,className:"fixed inset-0 bg-gray-500/75 transition-opacity duration-500 ease-in-out data-[closed]:opacity-0"}),(0,o.jsx)("div",{className:"fixed inset-0 overflow-hidden",children:(0,o.jsx)("div",{className:"absolute inset-0 overflow-hidden",children:(0,o.jsx)("div",{className:"pointer-events-none fixed inset-y-0 right-0 flex   pl-10",children:(0,o.jsxs)(C.Lj,{transition:!0,className:"pointer-events-auto relative w-screen max-w-lg transform transition duration-500 ease-in-out data-[closed]:translate-x-full sm:duration-700",children:[(0,o.jsx)(I._,{children:(0,o.jsx)("div",{className:"absolute lg:right-4   outline-none right-0 top-0 rounded-full m-2 z-50 flex p-2 duration-800 ease-in-out data-[closed]:opacity-0",children:(0,o.jsxs)("div",{onClick:()=>l(!1),className:"flex my-auto ",children:[(0,o.jsx)("svg",{width:"8",height:"10",className:"my-auto mr-2",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{d:"M6.52548 1.47452L2 6L6.52548 10.5255",stroke:"black",strokeWidth:"2.5","stroke-linejoin":"round"})}),(0,o.jsx)("div",{style:{color:m,fontFamily:"".concat(u,", sans-serif")},className:"my-auto text-[12px] font-bold",children:f("go_back")})]})})}),(0,o.jsx)("div",{className:"flex h-full min-h-screen flex-col overflow-y-scroll bg-white py-6 shadow-xl",children:(0,o.jsx)("div",{className:"relative flex  mt-16 items-center justify-center px-4 sm:px-6",children:(0,o.jsxs)("div",{className:"flex flex-col items-center justify-center px-6",children:[(0,o.jsx)("h1",{style:{color:m,fontFamily:"".concat(u,", sans-serif")},className:"text-2xl font-bold leading-6 text-center mb-8",children:"\xbfQuieres guardar esta tarjeta para futuras transacciones?"}),v&&(0,o.jsx)("p",{className:"text-xs text-center mb-4 max-w-xs",style:{color:"#b91c1c"},children:f("card_save_limit_reached","You already have 3 saved cards, which is the maximum allowed, so this one can't be saved. Please choose 'No'.")}),(0,o.jsxs)("div",{className:"w-full space-y-4 max-w-xs contents",children:[(0,o.jsx)("button",{onClick:()=>g(!0),disabled:v,style:{backgroundColor:n,color:c,fontFamily:"".concat(u,", sans-serif"),opacity:v?.5:1,cursor:v?"not-allowed":"pointer"},className:"w-fit  font-semibold py-3 px-8  rounded-full",children:"SI, GUARDAR TARJETA"}),(0,o.jsx)("button",{style:{backgroundColor:s,color:d,fontFamily:"".concat(u,", sans-serif")},onClick:()=>g(!1),className:"w-fit   font-semibold py-3 px-8  rounded-full",children:"NO"})]})]})})})]})})})})]})},M=e=>{let{fontFamily:t,primaryColor:r,secondaryBtnColor:a,secondaryBtnTxtColor:i,setOpen:l,open:n,setPaymentCardModal:s,bgColor:d,setLoa
1der:c,primarybtn:m,primarybtntxt:_,secondaryColor:v,setIsOpen:g,ErrorPrimaryColor:f,cardLimitReached:h}=e,{t:x}=(0,p.Bd)(),[b,w]=(0,u.useState)({cardNumber:"",firstName:"",lastName:"",dueDay:"",dueYear:"",cvv:"",country:"",state:"",city:"",postalCode:"",street:"",telephone:"",email:""}),[N,j]=(0,u.useState)({}),[k,M]=(0,u.useState)(!1),[P,T]=(0,u.useState)(!1),[L,q]=(0,u.useState)(!1),[R,B]=(0,u.useState)([]),[z,J]=(0,u.useState)([]),[V,U]=(0,u.useState)(!1),[W,H]=(0,u.useState)([]),[G,Y]=(0,u.useState)(!1),K=(0,u.useRef)(null),X=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),Z=e=>{let t=E.A.getAllCountries().find(t=>X(t.name)===X(e));return t?t.isoCode:null};(0,u.useEffect)(()=>{let e=e=>{K.current&&!K.current.contains(e.target)&&U(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,u.useEffect)(()=>{let e="".concat((0,S.o)());if(e){let t=localStorage.getItem("profile_check_".concat(e));if(t)try{let e=JSON.parse(t);w(t=>({...t,telephone:e.phone_number||"",email:e.email||""}))}catch(e){console.error("Failed to parse profile data:",e)}}},[]),(0,u.useEffect)(()=>{b.country&&b.state&&D(b.country,b.state).then(e=>{J(e),H(e)})},[b.country,b.state]),(0,u.useEffect)(()=>{g(!1);let e=setTimeout(()=>{T(n)},750);return()=>clearTimeout(e)},[n]);let $=e=>{let{name:t,value:r}=e.target,o="email"===t||"telephone"===t?r.trim():r,a="telephone"===t?o.replace(/\D/g,"").slice(0,15):o;"country"===t?(w(e=>({...e,[t]:o,state:"",city:""})),B(A.Ay.getStatesOfCountry(o)),J([]),H([])):"state"===t?(w(e=>({...e,[t]:o,city:""})),b.country&&o&&D(b.country,o).then(e=>{J(e),H(e)})):"city"===t?(H(z.filter(e=>e.name.toLowerCase().includes(o.toLowerCase()))),U(!0),w(e=>({...e,[t]:o}))):w(e=>({...e,[t]:a})),j(e=>({...e,[t]:""}))};(0,u.useEffect)(()=>{let e=localStorage.getItem("selected_branchmode_".concat((0,S.o)()));if(e)try{var t,r;let o=JSON.parse(e),a=null==o?void 0:null===(t=o.branch)||void 0===t?void 0:t.state,i=null==o?void 0:null===(r=o.branch)||void 0===r?void 0:r.country,l=Z(i);if(l){let e=A.Ay.getStatesOfCountry(l);B(e);let t=e.find(e=>e.name.toLowerCase()===(null==a?void 0:a.toLowerCase()));w(e=>({...e,country:l,state:(null==t?void 0:t.isoCode)||""})),t&&D(l,t.isoCode).then(e=>{J(e),H(e)})}}catch(e){console.error("Error parsing stored mode:",e)}},[]);let Q=e=>{w(t=>({...t,city:e})),U(!1)},ee=()=>{let e={};b.cardNumber||(e.cardNumber=x("Card_number_is_required")),b.firstName||(e.firstName=x("First_name_is_required")),b.lastName||(e.lastName=x("Last_name_is_required")),b.dueDay&&b.dueYear||(e.dueDate=x("Due_date_is_required")),b.cvv?isNaN(Number(b.cvv))&&(e.cvv=x("CVV_must_be_a_number")):e.cvv=x("CVV_is_required"),b.country||(e.country=x("Country_is_required")),b.state||(e.state=x("State_is_required")),b.city||(e.city=x("City_is_required")),b.postalCode||(e.postalCode=x("Postal_code_is_required")),b.street||(e.street=x("Street_is_required"));let t=b.telephone.replace(/\D/g,"");return b.telephone?(t.length<7||t.length>15)&&(e.telephone=x("Telephone_must_be_between_7_and_15_digits")):e.telephone=x("Telephone_is_required"),b.email?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b.email)||(e.email=x("Please_enter_a_valid_email")):e.email=x("Email_is_required"),j(e),0===Object.keys(e).length},et=async()=>{ee()&&Y(!0)};return(0,o.jsxs)(C.lG,{open:P,onClose:()=>{sessionStorage.setItem("netpayCardFormCancelled","true"),l(!1),c(!1),g(!0)},className:"relative z-50",children:[(0,o.jsx)("div",{children:G&&(0,o.jsx)(O,{onClose:()=>Y(!1),open:G,setOpen:Y,formData:b,setPaymentCardModal:s,secondaryBtnTxtColor:i,secondaryBtnColor:a,primarybtn:m,primarybtntxt:_,fontFamily:t,primaryColor:r,setIsOpen:g,cardLimitReached:h})}),(0,o.jsx)(C.Xi,{transition:!0,className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity duration-500 ease-in-out data-[closed]:opacity-0"}),(0,o.jsxs)("div",{className:"absolute  inset-0 overflow-y-auto",children:[" ",(0,o.jsxs)("div",{className:"flex h-screen items-center justify-center",children:[" ",(0,o.jsx)("div",{className:"pointer-events-auto fixed inset-y-0 right-0 flex max-w-full",children:(0,o.jsxs)(C.Lj,{transition:!0,style:{zIndex:1e3,overflowY:"auto",scrollBehavior:"smooth",WebkitOverflowScrolling:"touch"},className:"pointer-events-auto relative h-full w-screen max-w-lg transform transition duration-500 ease-in-out data-[closed]:translate-x-full sm:duration-700",children:[(0,o.jsx)(I._,{children:(0,o.jsx)("div",{style:{backgroundColor:a,color:i,fontFamily:"".concat(t,", sans-serif")},className:"absolute lg:right-4 shadow-lg outline-none right-0 top-0 rounded-full m-2 z-50 flex p-2 duration-800 ease-in-out data-[closed]:opacity-0",children:(0,o.jsxs)("button",{type:"button",onClick:()=>{sessionStorage.setItem("netpayCardFormCancelled","true"),l(!1),c(!1),g(!0)},className:"relative rounded-md focus:outline-none",children:[(0,o.jsx)("span",{className:"absolute -inset-2.5"}),(0,o.jsx)("span",{className:"sr-only",children:"Close panel"}),(0,o.jsx)(F.A,{className:"h-4 w-4 outline-none","aria-hidden":"true"})]})})}),(0,o.jsx)("div",{style:{backgroundColor:d,fontFamily:"".concat(t,", sans-serif"),"--scrollbar-thumb-color":v},className:"flex-1 h-[900px] overflow-y-auto p-6 shadow-xl  ",children:(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"flex ",children:[(0,o.jsxs)("svg",{width:"26",height:"33",viewBox:"0 0 26 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{d:"M19.8456 3.3616C18.4056 3.3616 16.9656 3.016 15.6984 2.3824L12.9912 1L10.284 2.3248C9.01676 2.9584 7.57676 3.304 6.13676 3.304H1.35596V19.0288C1.35596 22.312 3.08396 25.3648 5.90636 27.0352L12.9912 31.2976L20.1336 27.0352C22.956 25.3648 24.684 22.312 24.684 19.0288V3.3616H19.8456Z",fill:a,stroke:"black",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M9.3623 10.6191V7.39347C9.3623 6.81747 9.8231 6.29907 10.4567 6.29907H14.7191C15.2951 6.29907 15.8135 6.75987 15.8135 7.39347V10.6191",stroke:"black",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M17.5415 22.7149H7.57665C6.65505 22.7149 5.90625 21.9661 5.90625 21.0445V12.4621C5.90625 11.5405 6.65505 10.7917 7.57665 10.7917H17.4838C18.4054 10.7917 19.1543 11.5405 19.1543 12.4621V21.0445C19.1543 21.9
1661 18.4631 22.7149 17.5415 22.7149Z",fill:"white",stroke:"black",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M13.9127 15.8607C13.9127 15.0543 13.1639 14.3631 12.2999 14.5935C11.7815 14.7087 11.3783 15.1119 11.2631 15.6303C11.1479 16.3215 11.5511 16.9551 12.1271 17.1279V18.5103C12.1271 18.7407 12.2999 18.9711 12.5879 18.9711C12.8183 18.9711 13.0487 18.7983 13.0487 18.5103V17.1279C13.5095 16.9551 13.9127 16.4367 13.9127 15.8607Z",fill:"black"}),(0,o.jsx)("path",{d:"M19.0391 21.6782C17.1246 21.6782 15.5255 20.0792 15.5255 18.1646C15.5255 16.2501 17.1246 14.651 19.0391 14.651C20.9537 14.651 22.5527 16.2501 22.5527 18.1646C22.5527 20.082 21.0085 21.6782 19.0391 21.6782Z",fill:"white",stroke:"black",strokeWidth:"0.576"}),(0,o.jsx)("path",{d:"M22.5528 18.1647C22.5528 16.2201 20.9839 14.6511 19.0392 14.6511C17.0946 14.6511 15.5256 16.2201 15.5256 18.1647C15.5256 20.1094 17.0946 21.6783 19.0392 21.6783C20.9839 21.6783 22.5528 20.1094 22.5528 18.1647ZM14.9496 18.1647C14.9496 15.9046 16.7791 14.0751 19.0392 14.0751C21.2994 14.0751 23.1288 15.9046 23.1288 18.1647C23.1288 20.4249 21.2994 22.2543 19.0392 22.2543C16.7791 22.2543 14.9496 20.4249 14.9496 18.1647Z",fill:"black",stroke:"black",strokeWidth:"0.576"}),(0,o.jsx)("path",{d:"M18.8397 18.3682L20.1986 17.0093L20.5826 17.3659L18.636 19.3125L17.4881 18.1646L17.8795 17.7732L18.425 18.3605L18.6283 18.5796L18.8397 18.3682Z",fill:"black",stroke:"black",strokeWidth:"0.576"})]}),(0,o.jsx)("div",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-lg pl-4",children:x("pay_online")})]}),(0,o.jsxs)("div",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"my-auto flex py-3 ",children:[x("this_payment_is_done_by_netpay"),(0,o.jsx)(y(),{height:5,alt:"netpay",loading:"lazy",className:"object-fit w-[100px] ml-2 rounded-sm",width:60,src:"/ecomv2/Netpayy.png"})]}),(0,o.jsxs)("div",{className:"mt-2",children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("card_number")}),(0,o.jsx)("input",{type:"text",name:"cardNumber",value:b.cardNumber,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("card_number")}),N.cardNumber&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},className:"  text-sm",children:N.cardNumber})]}),(0,o.jsxs)("div",{className:"mt-4",children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("name_on_card")}),(0,o.jsxs)("div",{className:"grid grid-cols-2 gap-x-3",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("input",{type:"text",name:"firstName",value:b.firstName,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("name")}),N.firstName&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.firstName})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("input",{type:"text",name:"lastName",value:b.lastName,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("last_name")}),N.lastName&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.lastName})]})]})]}),(0,o.jsxs)("div",{className:"mt-4 flex gap-x-3",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("due_date")}),(0,o.jsxs)("div",{className:"grid grid-cols-2 w-[200px] gap-x-3",children:[(0,o.jsxs)("div",{className:"relative text-sm w-full",children:[(0,o.jsxs)("select",{name:"dueDay",value:b.dueDay,onChange:$,className:"w-full p-3 mt-0.5 rounded-lg bg-lightGray appearance-none",children:[(0,o.jsx)("option",{value:"",disabled:!0,children:x("month")}),Array.from({length:12},(e,t)=>t+1).map(e=>(0,o.jsx)("option",{value:e.toString().padStart(2,"0"),children:e},e))]}),(0,o.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none",children:(0,o.jsx)("svg",{width:"11",height:"7",viewBox:"0 0 11 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{d:"M5.5 7L10.2631 0.25H0.73686L5.5 7Z",fill:"black"})})})]}),(0,o.jsxs)("div",{className:"relative text-sm w-full",children:[(0,o.jsxs)("select",{name:"dueYear",value:b.dueYear,onChange:$,className:"w-full p-3 mt-0.5 rounded-lg bg-lightGray appearance-none",children:[(0,o.jsx)("option",{value:"",disabled:!0,children:x("year")}),Array.from({length:10},(e,t)=>new Date().getFullYear()+t).map(e=>(0,o.jsx)("option",{value:String(e).slice(2),children:e},e))]}),(0,o.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none",children:(0,o.jsx)("svg",{width:"11",height:"7",viewBox:"0 0 11 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{d:"M5.5 7L10.2631 0.25H0.73686L5.5 7Z",fill:"black"})})})]})]}),N.dueDate&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.dueDate})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:"CVV"}),(0,o.jsx)("input",{type:"password",name:"cvv",value:b.cvv,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray border-b-2 border-transparent focus:outline-none focus:border-2 focus:border-blue-500",placeholder:"CVV",maxLength:4,style:{WebkitAppearance:"none",MozAp
1pearance:"none",appearance:"none",borderRadius:"8px "}}),N.cvv&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.cvv})]})]}),(0,o.jsxs)("div",{className:"mt-4 grid grid-cols-3 gap-x-3",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("country")}),(0,o.jsxs)("div",{className:"relative text-sm w-full",children:[(0,o.jsxs)("select",{name:"country",value:b.country,onChange:$,className:"w-full p-3 mt-0.5 rounded-lg bg-lightGray appearance-none",children:[(0,o.jsx)("option",{value:"",children:x("Select_country")}),E.A.getAllCountries().map(e=>(0,o.jsx)("option",{value:e.isoCode,children:e.name},e.isoCode))]}),(0,o.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none",children:(0,o.jsx)("svg",{width:"11",height:"7",viewBox:"0 0 11 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{d:"M5.5 7L10.2631 0.25H0.73686L5.5 7Z",fill:"black"})})})]}),N.country&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.country})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("state")}),(0,o.jsxs)("div",{className:"relative text-sm w-full",children:[(0,o.jsxs)("select",{name:"state",value:b.state,onChange:$,className:"w-full p-3 mt-0.5 rounded-lg bg-lightGray appearance-none",disabled:!b.country,children:[(0,o.jsx)("option",{value:"",children:x("select_state")}),R.map(e=>(0,o.jsx)("option",{value:e.isoCode,children:e.name},e.isoCode))]}),(0,o.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none",children:(0,o.jsx)("svg",{width:"11",height:"7",viewBox:"0 0 11 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{d:"M5.5 7L10.2631 0.25H0.73686L5.5 7Z",fill:"black"})})})]}),N.state&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.state})]}),(0,o.jsxs)("div",{ref:K,className:"relative",children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("city")}),(0,o.jsx)("input",{type:"text",name:"city",value:b.city,onChange:$,onFocus:()=>U(!0),className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("city"),disabled:!b.state}),V&&W.length>0&&(0,o.jsx)("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg max-h-48 overflow-y-auto",children:W.map(e=>(0,o.jsx)("div",{className:"px-4 py-2 cursor-pointer hover:bg-gray-100",onClick:()=>Q(e.name),children:e.name},e.name))}),N.city&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.city})]})]}),(0,o.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-x-3",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("postal_code")}),(0,o.jsx)("input",{type:"text",name:"postalCode",value:b.postalCode,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("postal_code")}),N.postalCode&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.postalCode})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("street")}),(0,o.jsx)("input",{type:"text",name:"street",value:b.street,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("street")}),N.street&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.street})]})]}),(0,o.jsxs)("div",{className:"mt-4",children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("telephone")}),(0,o.jsx)("input",{type:"tel",name:"telephone",inputMode:"numeric",minLength:7,maxLength:15,value:b.telephone,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("telephone")}),N.telephone&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.telephone})]}),(0,o.jsxs)("div",{className:"mt-4",children:[(0,o.jsx)("label",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"font-black text-sm",children:x("email")}),(0,o.jsx)("input",{type:"email",name:"email",value:b.email,onChange:$,className:"w-full p-3 mt-0.5 text-sm rounded-lg bg-lightGray",placeholder:x("email")}),N.email&&(0,o.jsx)("div",{style:{color:f,fontSize:"10px"},children:N.email})]}),(0,o.jsx)("div",{children:(0,o.jsx)("div",{onClick:et,style:{color:i,backgroundColor:a,fontFamily:"".concat(t,", sans-serif")},className:"mt-8 cursor-pointer flex justify-center items-center font-black py-3  roun
1ded-full px-4 m-1",children:k?"".concat(x("processing"),"..."):x("use_this_card")})})]})})]})})]})]})]})};var P=r(77037),T=r(66635),L=r(26474),q=r(11804),R=r(37644),B=r(82042);let z=e=>{var t,r;let{open:a,setOpen:i,bgColor:l,fontFamily:n,secondaryColor:s,primaryColor:d,thankyouJson:c,ratings:m,comment:_,setRatings:v,setComment:g,orderexp:f,secondaryBtnColor:x,secondaryBtnTxtColor:b,saveDeliveryMode:w,handleClick:N,localalias:j,ErrorPrimaryColor:k,pixelId:S,gMeasurementId:E,userCartData:A,page_location:D,shippingCost:O}=e,[M,z]=(0,u.useState)(0),[J,V]=(0,u.useState)(""),[U,W]=(0,u.useState)(null),{t:H}=(0,p.Bd)(),G=(0,h.useRouter)(),[Y,K]=(0,u.useState)([]),[X,Z]=(0,u.useState)({}),[$,Q]=(0,u.useState)(0),ee=(0,u.useMemo)(()=>{let e=localStorage.getItem("branch_delivery_".concat(G.query.resturant));if(!e)return null;try{return JSON.parse(e)}catch(e){return console.error("Error parsing stored branch delivery data:",e),null}},[G.query.resturant]),et=(0,u.useMemo)(()=>null!=ee&&!!ee.branch_id&&(0,R.ZT)(j,ee.branch_id),[null==ee?void 0:ee.branch_id,j]),er=(0,u.useRef)([]),eo=(0,u.useRef)([]),ea=(0,u.useRef)(""),[ei,el]=(0,u.useState)(null),en="cart";(0,u.useEffect)(()=>{let e=localStorage.getItem("analytics_settings_".concat(j));if(e)try{let t=JSON.parse(e),r=Array.isArray(t)?t:[];er.current=r.filter(e=>"7ef38a2c-42dc-11ed-b878-0242ac120002"==e.platform&&"1"==e.status),eo.current=r.filter(e=>"db0098c8-42dc-11ed-b878-0242ac120002"==e.platform&&"1"==e.status),K(eo.current)}catch(e){console.error("Failed to parse analytics settings:",e)}},[]);let[es,ed]=(0,u.useState)(null),[ec,eu]=(0,u.useState)(null);return(0,u.useEffect)(()=>{if(!G.isReady)return;let e="scheduleOrderResponse_".concat(G.query.resturant),t=localStorage.getItem(e);if(t)try{let e=JSON.parse(t);ed((null==e?void 0:e.time)||null),eu((null==e?void 0:e.date)||null)}catch(e){console.error("Failed to parse scheduled order",e)}},[G.isReady]),Array.isArray(null==A?void 0:null===(t=A.order_items)||void 0===t?void 0:t.item_details)&&A.order_items.item_details.map(e=>{var t,r;return{item_id:e.item_id,item_name:e.item_name,quantity:e.quantity,price:null!==(r=null!==(t=e.total_item_price)&&void 0!==t?t:e.item_price_with_modifier)&&void 0!==r?r:e.item_price}}),A&&(null==A||null===(r=A.promotion_applied)||void 0===r||r.title),(0,u.useEffect)(()=>{var e,t,r,o,a,i,l,n;let s,d;let u=localStorage.getItem("cartData_".concat(j)),m=localStorage.getItem("resturantserversidesettings");if(u)try{s=JSON.parse(u)}catch(e){console.error("Failed to parse cartData:",e)}if(m)try{d=JSON.parse(m).currency}catch(e){console.error("Failed to parse cartData:",e)}if((null==s?void 0:s.final_amount)!==void 0&&d){let r=Array.isArray(null==er?void 0:er.current)&&er.current.length>0?er.current[0].id:"";ea.current=r;let o=null!==(t=null==s?void 0:null===(e=s.order_items)||void 0===e?void 0:e.item_details)&&void 0!==t?t:[],a=o.map(e=>String(e.item_id)),i=o.reduce((e,t)=>{var r;return e+(null!==(r=t.quantity)&&void 0!==r?r:1)},0);el({id:r,currency:d,value:s.final_amount,content_ids:a,content_type:"product",num_items:i})}let _=Array.isArray(null==eo?void 0:eo.current)&&eo.current.length>0,p=!!E;if(console.log("[GA Purchase] Gate check:",{hasGaDashboard:_,hasGaEnvId:p,hasFinalAmount:(null==s?void 0:s.final_amount)!==void 0,finalAmount:null==s?void 0:s.final_amount,currency:d,transaction_id:null==c?void 0:c.orderID,gtm_idData:null==eo?void 0:eo.current,gMeasurementIds:E}),(_||p)&&(null==s?void 0:s.final_amount)!==void 0&&d){let e=(null!==(i=null==s?void 0:null===(r=s.order_items)||void 0===r?void 0:r.item_details)&&void 0!==i?i:[]).map(e=>{var t,r;return{item_id:e.item_id,item_name:e.item_name,quantity:e.quantity,price:null!==(r=null!==(t=e.total_item_price)&&void 0!==t?t:e.item_price_with_modifier)&&void 0!==r?r:e.item_price}}),t={currency:d,value:s.final_amount,transaction_id:null!==(l=null==c?void 0:c.orderID)&&void 0!==l?l:"",items:e,offer:(null==A?void 0:null===(o=A.promotion_applied)||void 0===o?void 0:o.title)||null,shipping:O,points_redeemed:null!==(n=null==A?void 0:null===(a=A.loyalty_points_details)||void 0===a?void 0:a.points_redeemed)&&void 0!==n?n:0};console.log("[GA Purchase] Setting googleAnalyticsData:",t),Z(t)}else console.warn("[GA Purchase] Skipped — condition not met:",{hasGaDashboard:_,hasGaEnvId:p,finalAmount:null==s?void 0:s.final_amount,currency:d})},[]),(0,u.useEffect)(()=>{Array.isArray(null==er?void 0:er.current)&&(null==er?void 0:er.current.length)>0&&(ea.current=null==er?void 0:er.current[0].id)}),console.log(ei,"vvv"),(0,u.useEffect)(()=>{0===m?V(H("write_here")):m>=1&&m<=4?V(H("how_can_we_improve")):5===m&&V(H("thank_you_very_much"))},[m,H]),(0,u.useEffect)(()=>{let e=localStorage.getItem("offers_".concat(j)),t=localStorage.getItem("offer_details_".concat(j));if(e&&t){let r=JSON.parse(e),o=JSON.parse(t);r=r.filter(e=>e.offer_id!==o.offer_id||"user_specific"!==e.offer_type||(console.log("Removing offer with offer_id: ".concat(e.offer_id)),!1)),localStorage.setItem("offers_".concat(j),JSON.stringify(r)),localStorage.removeItem("offer_details_".concat(j)),window.dispatchEvent(new Event("promotionCleared")),console.log("Updated offers:",r)}else console.log("Offers or offer details not found in localStorage")}),(0,o.jsxs)(o.Fragment,{children:[ei&&(0,o.jsx)(L.default,{id:S,resId:ea.current,page:en,data:{currency:ei.currency,value:ei.value,content_ids:ei.content_ids,content_type:ei.content_type,num_items:ei.num_items}}),Object.keys(X).length>0&&(0,o.jsx)(q.default,{id:E,settings:Y,page:en,data:X,page_location:D}),(0,o.jsxs)(C.lG,{open:a,onClose:()=>{i(!1),setTimeout(()=>{G.back(),localStorage.removeItem("scheduleOrderResponse_".concat(G.query.resturant)),localStorage.removeItem("hasShownUpsellingPopup_".concat(G.query.resturant)),localStorage.removeItem("branch_delivery_".concat(G.query.resturant))},200)},className:"relative z-20",style:{fontFamily:"".concat(n,", sans-serif"),position:"relative",zIndex:1500},children:[(0,o.jsx)(C.Xi,{transition:!0,className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity duration-500 ease-in-out data-[closed]:opacity-0"}),(0,o.jsx)("div",{className:"fixed inset-0 overflow-hidden ",children:(0,o.jsx)("div",{className:"absolute inset-0  overflow-hidden",children:(0,o.jsx)("div",{style:{backgroundColor:l,fontFamily:"".concat(n,", sans-serif")},className:"pointer-events-none   fixed inset-y-0 right-0 flex  ",children:(0,o.jsxs)(C.Lj,{transition:!0,className:"pointer-events-auto  relative w-screen max-w-xl transform transition duration-500 ease-in-out data-[closed]:translate-x-full sm:duration-700",children:[(0,o.jsx)(I._,{children:(0,o.jsx)("div",{style:{backgroundColor:x,color:b,fontFamily:"".concat(n,", sans-serif")},className:"absolute lg:right-4 shadow-lg outline-none right-0 top-0 rounded-full mt-4 mx-2  z-10   flex p-2  duration-800 ease-in-out data-[closed]:opacity-0  ",children:(0,o.jsxs)("button",{type:"button",onClick:()=>{N(),setTimeout(()=>{localStorage.removeItem("scheduleOrderResponse_".concat(G.query.resturant)),localStorage.removeItem("hasShownUpsellingPopup_".concat(G.query.resturant)),localStorage.removeItem("branch_delivery_".concat(G.query.resturant)),console.log("Item removed from localStorage")},3e3)},className:"relative rounded-md  focus:outline-none ",children:[(0,o.jsx)("span",{className:"absolute -inset-2.5"}),(0,o.jsx)("span",{className:"sr-only",children:"Close panel"}),(0,o.jsx)(F.A,{"aria-hidden":"true",className:"h-4 w-4 outline-none"})]})})}),(0,o.jsx)("div",{className:"flex h-full flex-col overflow-y-scroll py-6 shadow-xl",children:(0,o.jsxs)("div",{className:" mt-[80px]  items-center justify-center min-h-screen px-6 pb-6 text-center",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"leading-5 text-2xl font-black",children:H("thank_you_so_much")}),(0,o.jsx)("div",{style:{color:s,fontFamily:"".concat(n,", sans-serif")},className:"leading-5 text-2xl font-black",children:H("for_your_order")}),(0,o.jsx)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"text-sm leading-4 mt-4 font-black",children:es&&ec&&"ASAP"!==es?(0,o.jsxs)(o.Fragment,{children:[H("your order has been scheduled for")," ",(0,o.jsx)("span",{style:{color:s},children:es})," ",H("and for")," ",(0,o.jsx)("span",{style:{color:s},children:ec})]}):H("Your order has been placed Successfully")}),(0,o.jsxs)("div",{className:"flex py-8 justify-between",children:[(0,o.jsxs)("div",{className:"w-1/2 flex flex-col items-center",children:[(0,o.jsxs)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"text-sm leading-4 font-black",children:[H("order_no"),":"]}),(0,o.jsxs)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"leading-4 text-sm",children:[null==c?void 0:c.orderID,(null==c?void 0:c.ec
1om_order_id)&&(0,o.jsxs)("span",{className:"ml-1",children:["(#",c.ecom_order_id,")"]})]}),(0,o.jsxs)("div",{className:"leading-4 text-sm text-center mt-2",children:[(0,o.jsxs)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"text-sm leading-4 font-black",children:["delivery"===w?H("delivery"):"dinein"===w?H("dine_in"):H("pick_up_at"),":"]}),(0,o.jsxs)("div",{className:"max-w-[230px] mx-auto text-center break-words leading-4",children:["delivery"===w?"a":"dinein"===w?"en":"V\xeda"," ",c.branch]})]})]}),(0,o.jsx)("div",{style:{backgroundColor:d,fontFamily:"".concat(n,", sans-serif")},className:"w-[1.5px] h-[85px]"}),(0,o.jsxs)("div",{className:"w-1/2 flex flex-col items-center",children:[(0,o.jsxs)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"text-sm font-black leading-4",children:[H("date"),":"]}),(0,o.jsx)("div",{className:"leading-4 text-sm",children:c.date}),(0,o.jsxs)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"text-sm font-black leading-4 pt-4",children:[H("hour"),":"]}),(0,o.jsx)("div",{className:"leading-4 text-sm",children:c.hour})]})]}),(0,o.jsx)("div",{className:"flex justify-center",children:(0,o.jsxs)("div",{className:"flex items-center gap-3",children:[(0,o.jsx)("div",{style:{color:s,fontFamily:"".concat(n,", sans-serif")},className:"text-sm underline underline-offset-1 font-black leading-4",children:(0,o.jsxs)("a",{href:c&&c.mobile?"tel:".concat(c.mobile):"",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2",children:[(0,o.jsx)(P.dRU,{className:"text-sm"}),(0,o.jsx)("span",{children:H("call_the_restaurant")})]})}),et&&(null==ee?void 0:ee.restaurant_phone)&&(null==ee?void 0:ee.restaurant_phone)!==""&&(0,o.jsx)("span",{className:"mx-1 sm:mx-0 text-gray-800  text-xl sm:text-base",children:"|"}),et&&(null==ee?void 0:ee.restaurant_phone)&&(null==ee?void 0:ee.restaurant_phone)!==""&&(0,o.jsx)("div",{style:{color:"#075E54",fontFamily:"".concat(n,", sans-serif")},className:"text-sm underline underline-offset-1 font-black leading-4",children:(0,o.jsxs)("a",{href:"https://wa.me/".concat(null==ee?void 0:ee.restaurant_phone),rel:"noopener noreferrer",target:"_blank",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2",children:[(0,o.jsx)(P.EcP,{className:"text-lg sm:text-base"}),(0,o.jsx)("span",{children:H("Chat_with_restaurant")})]})})]})}),(0,o.jsx)("div",{className:"flex justify-center",children:(0,o.jsxs)("div",{onClick:()=>{localStorage.setItem("status_id",c.orderID),localStorage.removeItem("scheduleOrderResponse_".concat(G.query.resturant)),localStorage.removeItem("branch_delivery_".concat(G.query.resturant)),setTimeout(()=>{G.push("/".concat(j,"/myorders"))},50)},style:{color:s,borderRadius:"24px",paddingInline:"16px",boxShadow:"0 0 4px ".concat(s)},className:"py-2 my-3 text-sm underline underline-offset-1 font-bold cursor-pointer flex items-center justify-center gap-2 text-center hover:shadow-md transition-all duration-200",children:[(0,o.jsx)(B.Cc4,{className:"text-xl",style:{color:s}}),H("Track_your_Order")]})}),(0,o.jsxs)("div",{className:"pb-6",children:[(0,o.jsx)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"text-sm font-black w-[50%] md:w-full mx-auto leading-5",children:H("tell_us_about_your_shopping_experience")}),(0,o.jsx)("div",{className:"flex space-x-1 justify-center py-4",children:[void 0,void 0,void 0,void 0,void 0].map((e,t)=>{let r=t+1;return(0,o.jsx)(P.gt3,{className:"cursor-pointer h-8 w-8",style:{color:r<=(M||m)?s:"#E6E6E6"},onClick:()=>v(r),onMouseEnter:()=>z(r),onMouseLeave:()=>z(0)},t)})}),U&&(0,o.jsx)("div",{style:{color:k},className:"  text-sm text-center pb-2",children:U}),(0,o.jsx)("textarea",{placeholder:J,value:_,onChange:e=>{let t=e.target.value;t.length<=700&&(g(t),Q(t.length))},className:"w-full bg-zincLight outline-none p-4 rounded-2xl border border-[#E6E6E6]",rows:3}),(0,o.jsxs)("div",{className:" grid grid-cols-3 items-center justify-between pt-3",children:[(0,o.jsx)("div",{}),(0,o.jsx)("div",{children:(0,o.jsx)(T.default,{type:"yellowRounded",text:H("send"),onClick:()=>
1{if(localStorage.setItem("OpenSuccessModal","true"),0===m){W(H("please_select_a_rating"));return}W(null),f()}})}),(0,o.jsxs)("div",{style:{color:d,fontFamily:"".concat(n,", sans-serif")},className:"text-sm text-right",children:[$," / 700"]})]})]})]}),(0,o.jsxs)("div",{className:"    w-full justify-center   pb-6 flex lg:px-12  ",children:[(0,o.jsx)("div",{style:{fontFamily:"".concat(n,", sans-serif"),color:d},className:"font-bold   items-end ",children:H("Powered_by")}),(0,o.jsx)("div",{className:"pl-3  items-end",children:(0,o.jsx)(y(),{height:21,width:120,alt:"foodbotlogo",src:"/ecomv2/FoodBot - Logo.png"})})]})]})})]})})})})]})]})};var J=r(21396),V=r.n(J);class U{static Encrypt(e,t){e=btoa(e);let r=V().PBKDF2(t,this.KEY_COMPLEMENTARY,{keySize:12,iterations:1e3}),o=V().lib.WordArray.create(r.words,32),a=V().lib.WordArray.create(r.words.splice(8),16),i=V().enc.Utf16LE.parse(e);return V().AES.encrypt(i,o,{iv:a}).toString()}static Decrypt(e,t){let r=V().PBKDF2(t,this.KEY_COMPLEMENTARY,{keySize:12,iterations:1e3}),o=V().lib.WordArray.create(r.words),a=V().lib.WordArray.create(r.words.splice(8),16),i=V().AES.decrypt(e,o,{iv:a});return V().enc.Utf16LE.stringify(i)}static nodeRsaEncryption(e){let t=V().AES.encrypt(e,"B&E)H@McQfTjWnZr4u7x!A%C*F-JaNdR").toString();return console.log("B&E)H@McQfTjWnZr4u7x!A%C*F-JaNdR","encryptkey"),t}static nodeRsaDecryption(e){let t=V().AES.decrypt(e,"B&E)H@McQfTjWnZr4u7x!A%C*F-JaNdR"),r=V().enc.Utf8.stringify(t);return console.log("B&E)H@McQfTjWnZr4u7x!A%C*F-JaNdR","encryptkey2"),r}static createSignature(e){let t=V().HmacSHA256(e,"Xn2r5u8x!A%D*G-KaPdSgVkYp3s6v9y$"),r=V().enc.Base64.stringify(t);return console.log("Xn2r5u8x!A%D*G-KaPdSgVkYp3s6v9y$","encryptkey3"),r}}U.KEY_COMPLEMENTARY="Ivan Medvedev";var W=r(56981);let H=(e,t)=>{var r,o,a;let i=null!==(a=null==t?void 0:t.error)&&void 0!==a?a:null==t?void 0:null===(o=t.response)||void 0===o?void 0:null===(r=o.body)||void 0===r?void 0:r.error;return"string"==typeof i&&i.trim()&&("string"!=typeof e||i.trim().toLowerCase()!==e.trim().toLowerCase())?i:""};var G=r(89928),Y=r(18975),K=r(63118),X=r(75538),Z=r(86305),$=r(64201);let Q={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11,Ene:0,Abr:3,Ago:7,Dic:11};function ee(e){try{if(!e||"string"!=typeof e)return null;let t=e.split("-");if(3!==t.length)return null;let r=parseInt(t[0],10),o=Q[t[1]],a=parseInt(t[2],10);if(isNaN(r)||void 0===o||isNaN(a))return null;let i=new Date(a,o,r);if(isNaN(i.getTime()))return null;return i}catch(e){return null}}var et=r(32862),er=r(96438),eo=r(98442),ea=r(39231),ei=r(43259),el=r(5595),en=r(11962),es=r(27528);let ed=()=>{let[e,t]=(0,u.useState)(!1),[r,o]=(0,u.useState)(null),[a,i]=(0,u.useState)(null);return(0,u.useEffect)(()=>{(async()=>{try{await new Promise((e,t)=>{let r=document.getElementById("netpay3ds-dev-script"),a=document.getElementById("netpay3ds-latest-script");
1if(r&&a){e();return}let i=document.createElement("script");i.src="https://cdn.netpay.mx/js/dev/netpay3ds.js",i.id="netpay3ds-dev-script",i.async=!0,i.defer=!0;let l=document.createElement("script");l.src="https://cdn.netpay.mx/js/latest/netpay3ds.js",l.id="netpay3ds-latest-script",l.async=!0,l.defer=!0,l.onload=()=>{window.netpay3ds&&(console.log("Netpay 3DS scripts loaded successfully",window.netpay3ds),o(window.netpay3ds)),e()},l.onerror=e=>{console.error("Error loading Netpay 3DS scripts:",e),t()},document.body.appendChild(l)}),t(!0)}catch(e){console.error("Error loading Netpay 3DS scripts:",e),i(e)}})()},[]),{loaded:e,netpay3ds:r,error:a}};var ec=r(49505);let eu=async e=>{console.log(e,"payloadnetpay");let t=U.createSignature(JSON.stringify(e)),r=U.nodeRsaEncryption(JSON.stringify(e)),o=(0,ec.z)();o.append("x-foodbot-signature",t);try{let e="".concat(window.location.origin,"/"),t="https://order.foodbot.ai/apiv2";e&&(t=e+"apiv2");let a=await fetch("".concat(t,"/ecom/v1/pg/netpay/v1/confirm-transaction"),{method:"POST",headers:o,body:JSON.stringify({payload:r})}),i=await a.json();return console.log(i),i}catch(e){return console.error("Error in netPayConfirmTransaction:",e),{status_code:500,message:"Network error"}}},em=async e=>{let t=sessionStorage.getItem("session_id"),r=sessionStorage.getItem("version");e.session_id=t,e.version=r,e.source="ecom";let o=U.createSignature(JSON.stringify(e)),a=U.nodeRsaEncryption(JSON.stringify(e)),i=(0,ec.z)();i.append("x-foodbot-signature",o);try{let e="".concat(window.location.origin,"/"),t="https://order.foodbot.ai/apiv2";e&&(t=e+"apiv2");let r=await fetch("".concat(t,"/ecom/v1/pg/netpay/v1/get-transaction-details"),{method:"POST",headers:i,body:JSON.stringify({payload:a})}),o=await r.json();return console.log(o),o}catch(e){return console.error("Error in netpayTransactiondetail:",e),{status_code:500,message:"Network error"}}},e_=e=>{let{fontFamily:t,primaryColor:r,saveDeliveryMode:a,saveModedetails:i,deliveryTime:l,setOpenMode:n,handlePaymentMethod:s,loader:d,setChangeModeModal:c}=e,{t:u}=(0,p.Bd)();return(0,o.jsx)("div",{className:"px-4 py-2 border border-gray-300",children:(0,o.jsxs)("div",{className:"flex  justify-between",children:[(0,o.jsxs)("div",{className:"flex ",children:[(0,o.jsx)("div",{className:"  p-2 my-auto",children:(0,o.jsxs)("svg",{width:"24",height:"27",viewBox:"0 0 26 30",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{d:"M3.58078 4.67407L1.00067 13.9515V28.8832H19.5555V13.9515L22.2084 4.68841",stroke:r,strokeWidth:"1.584","stroke-miterlimit":"10",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M19.5549 28.8834H25.0994V13.9517L22.684 5.38794",stroke:r,strokeWidth:"1.584","stroke-miterlimit":"10",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M19.5549 28.9931L22.3546 26.2483L25.0994 28.9931",stroke:r,strokeWidth:"1.584","stroke-miterlimit":"10",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M22.3553 26.2482V14.8848",stroke:r,strokeWidth:"1.584","stroke-miterlimit":"10",strokeLinecap:"round",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M22.2085 4.67427H2.53839C2.09922 4.29 1.87964 3.74104 1.87964 3.13718C1.87964 2.53333 2.15412 1.98437 2.53839 1.6001H22.6695",stroke:r,strokeWidth:"1.584","stroke-miterlimit":"10",strokeLinecap:"round",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M23.5906 3.30544C23.5906 3.87281 23.4517 4.36414 23.2512 4.69826C23.0453 5.04155 22.8249 5.1496 22.6686 5.1496C22.5122 5.1496 22.2919 5.04155 22.0859 4.69826C21.8854 4.36414 21.7465 3.87281 21.7465 3.30544C21.7465 2.73807 21.8854 2.24674 22.0859 1.91262C22.2919 1.56933 22.5122 1.46128 22.6686 1.46128C22.8249 1.46128 23.0453 1.56933 23.2512 1.91262C23.4517 2.24674 23.5906 2.73807 23.5906 3.30544Z",fill:r,stroke:r,strokeWidth:"0.922076"})]})}),(0,o.jsxs)("div",{className:"ml-1 mt-1.5 ",children:[(0,o.jsx)("div",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"text-[14px] font-medium leading-4",children:"delivery"===a?(0,o.jsx)("div",{className:"",children:(0,o.jsxs)("div",{className:"font-normal",children:[(0,o.jsxs)("div",{className:"",children:[u("delivery"),":"]}),(0,o.jsx)("div",{className:"font-normal text-sm  py-1 leading-4",children:i&&(null==i?void 0:i.formatted_address)})]})}):(0,o.jsxs)("div",{className:"",children:[u("pick_up"),":",(0,o.jsx)("span",{className:"  pl-1",children:i&&i.branch_name})]})}),(0,o.jsx)("div",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"text-[14px] font-medium leading-4",children:"delivery"===a?(null==l?void 0:l.delivery_time_estimate)?"".concat(l.delivery_time_estimate," - ").concat(Number(l.delivery_time_estimate)+10," ").concat(u("time_unit_min")):"":(null==i?void 0:i.pickup_time_estimate)?"".concat(i.pickup_time_estimate," - ").concat(Number(i.pickup_time_estimate)+10," ").concat(u("time_unit_min")):""})]})]}),(0,o.jsx)("div",{style:{color:r,fontFamily:"".concat(t,", sans-serif")},className:"mt-1.5  text-[14px] font-medium leading-4 underline underline-offset-2 cursor-pointer pr-3",onClick:c,children:u("changes")}
1)]})})};function ep(e){let{t}=(0,p.Bd)();return(0,o.jsxs)(C.lG,{open:e.isOpen,onClose:e.setIsOpen,className:"relative z-10",children:[(0,o.jsx)(C.Xi,{transition:!0,className:"fixed inset-0 bg-gray-500/75 transition-opacity duration-500 ease-in-out data-[closed]:opacity-0"}),(0,o.jsx)("div",{className:"fixed inset-0 overflow-hidden",children:(0,o.jsx)("div",{className:"absolute inset-0 overflow-hidden",children:(0,o.jsx)("div",{className:"pointer-events-none fixed inset-y-0 right-0 flex max-w-full",children:(0,o.jsx)(C.Lj,{transition:!0,className:"pointer-events-auto relative w-screen max-w-xl transform transition duration-500 ease-in-out data-[closed]:translate-x-full sm:duration-700",children:(0,o.jsxs)("div",{style:{backgroundColor:e.bgColor},className:"flex h-full flex-col overflow-y-scroll  py-4 shadow-xl",children:[(0,o.jsx)("div",{className:"flex justify-end pb-4",children:(0,o.jsxs)("div",{onClick:()=>{e.setIsOpen(!1),e.resetData()},className:"flex my-auto px-6 ",children:[(0,o.jsx)("svg",{width:"8",height:"10",className:"my-auto mr-2",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,o.jsx)("path",{d:"M6.52548 1.47452L2 6L6.52548 10.5255",stroke:e.primaryColor,strokeWidth:"2.5","stroke-linejoin":"round"})}),(0,o.jsx)("div",{style:{color:e.primaryColor,fontFamily:"".concat(e.fontFamily,", sans-serif")},className:"my-auto text-[12px] font-bold",children:t("go_back")})]})}),(0,o.jsx)("div",{className:"relative flex-1",children:e.children})]})})})})})]})}var ev=r(86297),eg=r(56486);function ef(e){let{message:t,onClose:r,primaryColor:a,fontFamily:i,bgColor:l,secondaryColor:n,paymentModal:s}=e,[d,c]=(0,u.useState)(!0),m=()=>{c(!1),s(!0),r()};return(0,u.useEffect)(()=>{let e=e=>{"Escape"===e.key&&m()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m]),(0,o.jsx)(ev.N,{children:d&&(0,o.jsx)(eg.P.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0  z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:(0,o.jsxs)(eg.P.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",damping:20,stiffness:300},style:{backgroundColor:l},className:"relative   dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-md w-full mx-4",children:[(0,o.jsx)("button",{onClick:m,className:"absolute top-4 right-4   text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",style:{color:a},children:(0,o.jsx)(_.A,{size:18})}),(0,o.jsxs)("div",{className:"mt-8",children:[(0,o.jsx)("div",{className:"text-center text-md  mb-6",style:{color:a,fontFamily:"".concat(i,", sans-serif")},children:t}),(0,o.jsx)("button",{onClick:m,className:"w-full py-2 px-4 rounded transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2",style:{backgroundColor:a,color:n,fontFamily:"".concat(i,", sans-serif")},children:"OK"})]})]})})})}var ey=r(72124);let eh=async(e,t,r,o,a,i,l,n,s,d,c)=>{let u={restaurant_id:e,order_id:t,branch_id:r,phone_number:o,request_timestamp:a,payment_gateway_id:i,pg_response:l,isSchedule:n,session_id:s,version:d,source:c};console.log(" ORDER-ID::",t);let m=U.createSignature(JSON.stringify(u)),_=U.nodeRsaEncryption(JSON.stringify(u));try{let e="".concat(window.location.origin,"/"),t="https://order.foodbot.ai/apiv2";e&&(t="".concat(e,"apiv2"));let r=await fetch("".concat(t,"/ecom/v1/pg/moneris_make_payment"),{method:"POST",headers:{"Content-Type":"application/json","x-foodbot-signature":m},body:JSON.stringify({payload:_})});return await r.json()}catch(e){throw console.error("Failed to make Moneris payment",e),e}},ex=e=>{let{ticket:t,mode:r,scriptUrl:a,onSuccess:i,onError:l,onCancel:n,restaurantId:s,orderId:d,branchId:c,phoneNumber:m,paymentGatewayId:_,scheduledOrder:p,sessionId:v,version:g}=e,f=(0,u.useRef)(null),y=(0,u.useRef)(null),h=(0,u.useRef)(!1),x=(0,u.useRef)(!1),b=function(e){let[t,r]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(!e)return;if(document.querySelector('script[src="'.concat(e,'"]'))){r(!0);return}let t=document.createElement("script");return t.src=e,t.async=!0,t.type="text/javascript",t.onload=()=>{window.monerisCheckout?r(!0):(console.error("Moneris script loaded but monerisCheckout not found"),r(!1))},t.onerror=()=>{console.error("Failed to load Moneris script"),r(!1)},document.body.appendChild(t),()=>{document.body.contains(t)&&document.body.removeChild(t)}},[e]),t}(a);return((0,u.useEffect)(()=>{if(b&&!h.current&&f.current){h.current=!0;try{for(;f.current.firstChild;)f.current.removeChild(f.current.firstChild);let e=new window.monerisCheckout;y.current=e,e.setMode(r),e.setCheckoutDiv("monerisCheckout"),e.setCallback("page_loaded",e=>{console.log("Moneris checkout page loaded:",e)}),e.setCallback("cancel_transaction",()=>{console.log("Transaction cancelled by user"),x.current||(x.current=!0,n())}),e.setCallback("error_event",e=>{console.error("Moneris payment error:",e),x.current||(x.current=!0,l(e.message||"Payment processing failed"))}),e.setCallback("payment_receipt",async e=>{if(!x.current){x.current=!0;try{let t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch(e){console.error("Failed to parse response:",e),l("Invalid payment response format");return}let r=await eh(s,d,c,m,new Date().toISOString(),_,t,p,v,g,"EcomV2");200==r.status_code?i():l(r.message||"Payment failed")}catch(e){console.error("Payment API error:",e),l("Failed to process payment")}}}),e.startCheckout(t)}catch(e){console.error("Error initializing Moneris checkout:",e),x.current||(x.current=!0,l("Failed to initialize payment system"))}return()=>{y.current&&(y.current=null,h.current=!1,x.current=!1)}}},[b,t,r,i,l,n,s,d,c,m,_,v,g]),b)?(0,o.jsx)("div",{id:"monerisCheckout",ref:f,className:"w-full h-screen z-80 bg-white",style:{minWidth:"100%",minHeight:"600px",border:"none",overflow:"hidden",position:"relative",zIndex:1e3}}):(0,o.jsx)("div",{className:"flex items-center justify-center h-[600px]",children:(0,o.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"})})};var eb=r(52790),ew=r(31962),eN=r(24663),ej=r(4029),ek=r(76459);let eS=e=>{let{secondaryBtnColor:t,secondaryBtnTxtColor:r,primaryColor:a,primaryBtnColor:i,primaryBtnTxtColor:l,fontFamily:n,saveModedetails:s,setShowBranchConfirmModal:d,setChangeModeModal:c,setOpenMode:m,handleConfirmBranch:v,saveDeliveryMode:g,bgColor:f,pickupScheduleData:y,localalias:h,currentBranch:x,dineintable:b}=e,{t:w}=(0,p.Bd)(),[N,j]=u.useState(!1);return u.useEffect(()=>{j("true"===localStorage.getItem("is_dinein_tab_".concat(h)))},[h]),(0,u.useEffect)(()=>{let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[]),(0,o.jsx)("div",{className:"fixed inset-0 flex items-center justify-center bg-black/70 z-50 p-4",onClick:e=>{e.target===e.currentTarget&&d(!1)},children:(0,o.jsxs)("div",{className:"bg-card rounded-3xl shadow-xl w-full max-w-md overflow-hidden animate-in fade-in-50 zoom-in-95",style:{backgroundColor:f,border:"1px solid"+a,borderColor:a,fontFamily:"".concat(n,", system-ui, sans-serif"),boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)"},onClick:e=>e.stopPropagation(),children:[(0,o.jsxs)("div",{className:"flex justify-between items-start p-6 pb-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-3",children:[(0,o.jsx)("div",{className:"w-10 h-10 bg-orange-100 rounded-full flex items-center justify-center",children:(0,o.jsx)("div",{className:"w-6 h-6 bg-orange-500 rounded-full flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-white text-xs font-bold",children:"!"})})}),(0,o.jsx)("h2",{style:{color:a},className:"text-xl font-semibold text-foreground",children:w("Confirm_Information")})]}),(0,o.jsx)("button",{className:"w-10 h-10 bg-accent hover:bg-accent/80 rounded-full flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>d(!1),"aria-label":"Close",children:(0,o.jsx)(_.A,{size:20,className:"text-accent-foreground"})})]}),(0,o.jsx)("div",{className:"px-6 pb-6",children:(0,o.jsx)("p",{style:{color:a},className:"text-muted-foreground text-base",children:w("delivery"===g?"Your delivery address is":"dinein"===g?"ordering_from_branch_dine_in":"ordering_from_branch")})}),(0,o.jsxs)("div",{className:"px-6 space-y-4",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between py-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-4",children:[(0,o.jsx)("div",{className:"w-10 h-10  rounded-lg flex items-center justify-center",children:(0,o.jsx)(ej.A,{size:20,style:{color:a}})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{color:a},className:"text-sm text-muted-foreground mb-1",children:w("delivery"===g?"addresss":"branch")}),(0,o.jsxs)("p",{style:{color:a},className:"text-lg font-semibold text-foreground",children:[s||"----","dinein"===g&&(0,o.jsxs)(o.Fragment,{children:[" - ",N?"QSR":b||w("no_table")]})]})]})]}),(0,o.jsxs)("button",{style:{color:a,borderColor:a},className:"px-4 py-2 border-2 border-primary text-primary rounded-lg font-medium hover:bg-primary/10 transition-colors flex items-center gap-2",onClick:()=>{d(!1),setTimeout(()=>{window.innerWidth<1024?c(!0):m(!0)},300)},children:[(0,o.jsx)(ej.A,{size:20,style:{color:a}}),w("change").toLocaleLowerCase()]})]}),y&&"ASAP"!==y.time&&(0,o.jsx)("div",{className:"flex items-center justify-between py-4",children:(0,o.jsxs)("div",{className:"flex items-center gap-4",children:[(0,o.jsx)("div",{className:"w-10 h-10 flex items-center justify-center",children:(0,o.jsx)(ek.A,{size:20,style:{color:a}})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{color:a},className:"text-sm text-muted-foreground mb-1",children:w("scheduled time")}),(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("p",{style:{color:a},className:"text-lg font-semibold text-foreground",children:y.date||"Hoy"}),(0,o.jsx)("span",{className:"w-px h-5  "}),(0,o.jsx)("p",{style:{color:a},className:"text-lg font-semibold text-foreground",children:y.time})]})]})]})})]}),(0,o.jsx)("div",{className:"p-6 pt-8",children:(0,o.jsx)("button",{style:{backgroundColor:i,
1color:l},className:"w-full bg-primary text-primary-foreground py-4 rounded-xl font-semibold text-lg hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-ring",onClick:v,children:w("all_good")})})]})})};var eC=r(71536);let eI=e=>{let t=e.query.resturant||localStorage.getItem("alias");if(!t){console.warn("[restrictDirectAccess] no alias found — router.query:",e.query),e.push("/".concat(e.query.resturant||""));return}let r=localStorage.getItem("loggedin_".concat(t)),o=localStorage.getItem("selected_branchmode_".concat(t)),a=localStorage.getItem("profile_check_".concat(t)),i=(0,eC.parseCookies)(),l=i["payload_".concat(t)];i["loggedin_".concat(t)];let n=i["selected_branchmode_".concat(t)],s=localStorage.getItem("callin_order_".concat(t));if(s)try{let e=JSON.parse(s);if(!(e.expires_at&&Date.now()>e.expires_at)){console.log("Callin session active — skipping restrictDirectAccess redirect");return}}catch(e){}r&&o&&a&&l&&n||(console.log("Redirecting: Missing required keys or cookies"),e.push("/".concat(t)))};var eF=r(76424),eE=r(48049),eA=r(72793);let eD=e=>{let{open:t,setOpen:r,bgColor:a,fontFamily:i,secondaryColor:l,primaryColor:n,secondaryBtnColor:s,secondaryBtnTxtColor:d,localalias:c,setBtnLoading:u,primaryBtnColor:m,primaryBtnTxtColor:v,orderId:g}=e,{t:f}=(0,p.Bd)(),y=(0,eF.useRouter)(),h=()=>{u(!0),r(!1),setTimeout(()=>{y.push("/".concat(c))},100)};return(0,o.jsx)(eA.lG,{open:t,onOpenChange:r,children:(0,o.jsxs)(eA.Cf,{style:{backgroundColor:a,fontFamily:i,padding:"24px"},children:[(0,o.jsx)("div",{className:"absolute right-4 top-2 z-50",children:(0,o.jsxs)(eE.$,{variant:"ghost",className:"h-8 w-8 rounded-full font-black p-0 flex items-center justify-center  ",onClick:h,style:{color:n},children:[(0,o.jsx)(_.A,{className:"h-4 w-4 "}),(0,o.jsx)("span",{className:"sr-only",children:"Close"})]})}),(0,o.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,o.jsx)("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-3",children:(0,o.jsx)(P.CMH,{className:"h-10 w-10",style:{color:n}})}),(0,o.jsx)("div",{className:"text-center mb-1",children:(0,o.jsx)("h2",{className:"text-xl font-semibold",style:{color:l},children:f("Thank You")})}),(0,o.jsx)("p",{className:"text-center mb-4",style:{color:l},children:f("Thank you for your feedback!")}),(0,o.jsxs)("div",{className:"grid w-full gap-2",children:[(0,o.jsx)(eE.$,{className:"w-full rounded-md py-2.5 font-medium transition-colors",style:{backgroundColor:m,color:v,borderColor:n,fontFamily:i},onClick:()=>{u(!0),localStorage.setItem("status_id",g),setTimeout(()=>{y.push("/".concat(c,"/myorders"))},50)},children:f("Track_your_Order")}),(0,o.jsx)(eE.$,{variant:"outline",className:"w-full rounded-md py-2 font-medium transition-colors",style:{color:n,borderColor:s,fontFamily:i},onClick:()=>{u(!0),r(!1),setTimeout(()=>{y.push("/".concat(c,"/myorders"))},100)},children:f("See My Order")}),(0,o.jsx)(eE.$,{variant:"outline",className:"w-full rounded-md py-2 font-medium transition-colors",style:{backgroundColor:s,color:d,borderColor:s,fontFamily:i},onClick:h,children:f("Back to Menu")})]})]})]})})};var eO=r(82699),eM=r(80518);let eP=e=>{let{heading:t,text:r,children:a,texttwo:i,primaryColor:l}=e,[n,s]=(0,u.useState)(!1);return(0,o.jsxs)("div",{className:"relative inline-block",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,o.jsx)("div",{className:"cursor-pointer",children:a}),n&&(0,o.jsxs)("div",{className:"absolute bottom-full mb-4 left-[-240%] transform -translate-x-1/2 w-56 bg-white   rounded-lg shadow-lg p-4 z-10",children:[(0,o.jsx)("div",{className:"flex justify-end items-end ",children:(0,o.jsxs)("svg",{onClick:()=>s(!1),width:"18",height:"18",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("rect",{width:"15.1632",height:"3.03264",transform:"matrix(0.707107 -0.707106 0.707107 0.707106 4.28906 15.0109)",fill:"black"}),(0,o.jsx)("rect",{width:"15.1632",height:"3.03264",transform:"matrix(-0.707107 -0.707106 0.707107 -0.707106 15.0107 17.155)",fill:"black"})]})}),(0,o.jsx)("div",{style:{color:l},className:" font-black underline underline-offset-8 decoration-2",children:t}),(0,o.jsx)("div",{className:"text-gray-700 text-sm mt-4",children:r},""),(0,o.jsx)("div",{className:"text-gray-700 text-sm mt-4",children:i}),(0,o.jsx)("div",{className:"absolute top-full left-[85%] transform -translate-x-1/2 w-0 h-0 border-l-8 border-r-8 border-t-8 border-transparent border-t-white"})]})]})};var eT=r(90363),eL=r(73807),eq=r(83004),eR=r(20424);let eB=e=>{let{primaryColor:t,secondaryColor:r,fontFamily:a,billpocketCardsList:i,selectedBillpocketCard:l,onBillpocketCardSelect:n,onDeleteCard:s}=e,{t:d}=(0,p.Bd)();return(0,o.jsxs)("div",{className:"mt-6 ml-0 md:ml-8 animate-in fade-in slide-in-from-top-4 duration-500",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,o.jsx)(eR.A,{size:20,style:{color:t}}),(0,o.jsx)("h3",{style:{color:t,fontFamily:"".concat(a,", sans-serif")},className:"font-bold text-lg",children:d("select a card")})]}),(0,o.jsx)("div",{className:"grid gap-3",children:i.map(e=>{var i,c;let u=(null==l?void 0:l.card_id)===e.card_id;return(0,o.jsxs)("div",{className:"group relative overflow-hidden p-4 rounded-xl cursor-pointer transition-all duration-300 border-2 ".concat(u?"shadow-md scale-[1.02]":"border-gray-300 hover:border-gray-500 hover:bg-gray-50/50"),style:{borderColor:u?t:"#c0c6d4ff"},onClick:()=>n(e),children:[u&&(0,o.jsx)("div",{className:"absolute inset-0 opacity-10 pointer-events-none",style:{backgroundColor:t}}),(0,o.jsxs)("div",{className:"flex items-center justify-between relative z-10 pl-2",children:[(0,o.jsxs)("div",{className:"flex items-center gap-4",children:[(0,o.jsx)("div",{className:"p-3 rounded-full transition-colors ".concat(u?"bg-white":"bg-gray-50"),children:(0,o.jsx)(eT.A,{size:24,style:{color:r}})}),(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{style:{color:t,fontFamily:"".concat(a,", sans-serif")},className:"font-bold text-base tracking-wider",children:["•••• •••• •••• ",e.card_number]}),(0,o.jsxs)("div",{style:{color:t,fontFamily:"".concat(a,", sans-serif")},className:"text-xs uppercase tracking-tight opacity-60 font-medium mt
1-0.5",children:[null===(i=e.user_details)||void 0===i?void 0:i.first_name," ",null===(c=e.user_details)||void 0===c?void 0:c.last_name]})]})]}),(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[u?(0,o.jsx)(eL.A,{size:24,fill:r,className:"text-white"}):(0,o.jsx)("div",{className:"w-6 h-6 rounded-full border-2 border-gray-200"}),(0,o.jsx)("div",{className:"p-1.5 rounded-full hover:bg-red-50 text-gray-400 hover:text-red-500 transition-colors duration-200",onClick:t=>{t.stopPropagation(),s(e)},title:d("Delete Card"),children:(0,o.jsx)(eq.A,{size:20})})]})]})]},e.card_id)})})]})};var ez=r(29691),eJ=r(32147),eV=r(28363),eU=r(67497),eW=r(26923);let eH=e=>{var t,r,a,i,l;let{paymentMethods:n,primaryColor:s,fontFamily:d,secondaryColor:c}=e,{t:m}=(0,p.Bd)(),[_,v]=(0,u.useState)(!1),g=null==n?void 0:null===(a=n.Payment_settings)||void 0===a?void 0:null===(r=a.find(e=>{var t;return(null==e?void 0:null===(t=e.payment_method)||void 0===t?void 0:t.toLowerCase())==="transferencia"}))||void 0===r?void 0:null===(t=r.settings)||void 0===t?void 0:t.bank_details,f=async e=>{try{await navigator.clipboard.writeText(e),v(!0),setTimeout(()=>v(!1),2e3)}catch(e){}};return g?(0,o.jsxs)("div",{className:"mt-4 sm:mt-6 bg-gradient-to-br from-white to-gray-50 shadow-lg rounded-2xl p-4 sm:p-6 border border-gray-100 transition-all duration-300 hover:shadow-xl",children:[(0,o.jsxs)("div",{className:"flex items-center pb-2",children:[(0,o.jsx)(eW.Ioy,{className:"mr-2",style:{color:c}}),(0,o.jsx)("h3",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-[16px]  font-semibold    tracking-tight",children:m("bank_details")})]}),(0,o.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:gap-4",children:[(null==g?void 0:g.clabe)&&(0,o.jsxs)("div",{style:{border:"1px solid #e5e7eb"},className:"flex items-center justify-between p-2 sm:p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors",children:[(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm font-medium",children:m("clabe")}),(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm font-mono",children:g.clabe})]}),(0,o.jsxs)("button",{onClick:()=>f(g.clabe),className:"p-1 sm:p-2 rounded-full hover:bg-gray-200 transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[${primaryColor}]",title:m("copy_clabe"),children:[_?(0,o.jsx)(eV.A,{className:"h-4 sm:h-5 w-4 sm:w-5 text-green-600"}):(0,o.jsx)(eU.A,{className:"h-4 sm:h-5 w-4 sm:w-5 text-gray-600"}),_&&(0,o.jsx)("span",{className:"absolute ml-2 text-xs text-green-600 bg-gray-100 p-1 rounded",children:"Copied"})]})]}),(null==g?void 0:null===(i=g.concept)||void 0===i?void 0:i.trim())&&(0,o.jsxs)("div",{style:{border:"1px solid #e5e7eb"},className:"flex justify-between p-2 sm:p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors",children:[(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm font-medium",children:m("concept")}),(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm",children:g.concept})]}),(null==g?void 0:g.bank_name)&&(0,o.jsxs)("div",{style:{border:"1px solid #e5e7eb"},className:"flex justify-between p-2 sm:p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors",children:[(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm font-medium",children:m("bank_name")}),(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm",children:g.bank_name})]}),(null==g?void 0:null===(l=g.account_number)||void 0===l?void 0:l.trim())&&(0,o.jsxs)("div",{style:{border:"1px solid #e5e7eb"},className:"flex justify-between p-2 sm:p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors",children:[(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm font-medium",children:m("account_number")}),(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm",children:g.account_number})]}),(null==g?void 0:g.beneficiary_name)&&(0,o.jsxs)("div",{style:{border:"1px solid #e5e7eb"},className:"grid grid-cols-2   p-2 sm:p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors",children:[(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm font-medium",children:m("beneficiary_name")}),(0,o.jsx)("span",{style:{color:s,fontFamily:"".concat(d,", sans-serif")},className:"text-sm text-right",children:g.beneficiary_name})]})]})]}):null};var eG=r(6210),eY=r(66895);let eK=e=>{let{isOpen:t,onClose:r,buyProductIds:a,getProductIds:i=[],packageItems:l=[],alias:n,primaryColor:s,bgColor:d,secondaryColor:c,fontFamily:m}=e,{currentLang:_,botLanguage:v}=(0,eG.ok)(),{t:g}=(0,p.Bd)(),[f,y]=(0,u.useState)([]),[h,x]=(0,u.useState)([]),[b,w]=(0,u.useState)([]),[N,j]=(0,u.useState)(!1);(0,u.useEffect)(()=>{(async()=>
1{if(t&&(a.length>0||i.length>0||l.length>0)){j(!0);try{let e=await (0,eN.KR)("branchMenuDetail_".concat(n));if(e){let t=[],r=[],o=[],n=e=>{e.forEach(e=>{let s=(0,eY.M1)(e,_,v);e.cat_items&&e.cat_items.forEach(e=>{a.some(t=>String(t)===String(e.item_id))&&t.push({name:(0,eY.X5)(e,_,v),category:s}),i.some(t=>String(t)===String(e.item_id))&&r.push({name:(0,eY.X5)(e,_,v),category:s}),l.some(t=>String(t)===String(e.item_id))&&o.push({name:(0,eY.X5)(e,_,v),category:s})}),e.menu_category&&n(e.menu_category)})};if(Array.isArray(e)){let t=e.filter(e=>Array.isArray(e)?!e.some(e=>(null==e?void 0:e.type)==="top_picks"):(null==e?void 0:e.type)!=="top_picks");n(t)}y(t),x(r),w(o)}}catch(e){console.error("Error fetching menu from DB:",e)}finally{j(!1)}}})()},[t,a,i,l,n,_,v,g]),(0,u.useEffect)(()=>{if(t){let e=window.scrollY;return document.body.style.position="fixed",document.body.style.top="-".concat(e,"px"),document.body.style.width="100%",document.body.style.overflow="hidden",()=>{let e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}}{let e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}},[t]),(0,u.useEffect)(()=>{t||(y([]),x([]),w([]),S(""))},[t]);let[k,S]=(0,u.useState)(""),C=e=>e.filter(e=>e.name.toLowerCase().includes(k.toLowerCase())||e.category.toLowerCase().includes(k.toLowerCase())),I=C(f),F=C(h),E=C(b);return t?(0,o.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm p-4",children:(0,o.jsxs)("div",{className:"rounded-2xl shadow-2xl relative w-full max-w-md flex flex-col max-h-[85vh]",style:{backgroundColor:d},children:[(0,o.jsxs)("div",{className:"p-5 border-b flex justify-between items-center shrink-0",children:[(0,o.jsx)("h2",{className:"text-xl font-bold leading-tight",style:{color:s,fontFamily:m},children:g("eligible_products_promo")}),(0,o.jsx)("button",{onClick:r,className:"p-1 rounded-full hover:bg-gray-100 transition-colors",style:{color:s},children:(0,o.jsx)(P.QCr,{size:20})})]}),(0,o.jsx)("div",{className:"p-4 shrink-0",children:(0,o.jsx)("input",{type:"text",placeholder:g("search_products")||"Search products...",value:k,onChange:e=>S(e.target.value),className:"w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-opacity-50",style:{fontFamily:m,borderColor:c,outline:"none"}})}),(0,o.jsx)("div",{className:"overflow-y-auto px-4 pb-6 flex-grow custom-scrollbar",style:{"--scrollbar-thumb-color":c,"--scrollbar-track-color":"".concat(c,"20")},children:N?(0,o.jsx)("div",{className:"flex justify-center py-8",children:(0,o.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2",style:{borderColor:s}})}):(0,o.jsx)(o.Fragment,{children:0===I.length&&0===F.length&&0===E.length?(0,o.jsx)("div",{className:"text-center py-8 text-gray-500 flex flex-col items-center",children:(0,o.jsx)("p",{style:{fontFamily:m},children:g(k?"no_results_found":"no_products_found")})}):(0,o.jsxs)("div",{className:"space-y-6",children:[I.length>0&&(0,o.jsxs)("div",{children:[F.length>0&&(0,o.jsx)("h3",{className:"text-lg font-bold mb-3",style:{color:s,fontFamily:m},children:g("buy_products")||"Buy Products"}),(0,o.jsx)("div",{className:"grid grid-cols-1 gap-2",children:I.map((e,t)=>(0,o.jsxs)("div",{className:"p-3 rounded-lg border flex items-center bg-white/50 hover:bg-white/80 transition-all",style:{borderColor:"".concat(s,"20")},children:[(0,o.jsx)("div",{className:"w-2 h-2 rounded-full mr-3 shrink-0",style:{backgroundColor:s}}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"text-gray-800 font-medium",style:{fontFamily:m},children:e.name}),e.category&&(0,o.jsx)("span",{className:"text-xs text-gray-500",style:{fontFamily:m},children:e.category})]})]},"buy-".concat(t)))})]}),F.length>0&&(0,o.jsxs)("div",{children:[I.length>0&&(0,o.jsx)("div",{className:"my-4 border-t",style:{borderColor:"".concat(s,"20")}}),(0,o.jsx)("h3",{className:"text-lg font-bold mb-3",style:{color:s,fontFamily:m},children:g("get_products")||"Get Products"}),(0,o.jsx)("div",{className:"grid grid-cols-1 gap-2",children:F.map((e,t)=>(0,o.jsxs)("div",{className:"p-3 rounded-lg border flex items-center bg-white/50 hover:bg-white/80 transition-all",style:{borderColor:"".concat(s,"20")},children:[(0,o.jsx)("div",{className:"w-2 h-2 rounded-full mr-3 shrink-0",style:{backgroundColor:s}}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"text-gray-800 font-medium",style:{fontFamily:m},children:e.name}),e.category&&(0,o.jsx)("span",{className:"text-xs text-gray-500",style:{fontFamily:m},children:e.category})]})]},"get-".concat(t)))})]}),E.length>0&&(0,o.jsxs)("div",{children:[(I.length>0||F.length>0)&&(0,o.jsx)("div",{className:"my-4 border-t",style:{borderColor:"".concat(s,"20")}}),(0,o.jsx)("h3",{className:"text-lg font-bold mb-3",style:{color:s,fontFamily:m},children:g("package_products")||"Package Products"}),(0,o.jsx)("div",{className:"grid grid-cols-1 gap-2",children:E.map((e,t)=>(0,o.jsxs)("div",{className:"p-3 rounded-lg border flex items-center bg-white/50 hover:bg-white/80 transition-all",style:{borderColor:"".concat(s,"20")},children:[(0,o.jsx)("div",{className:"w-2 h-2 rounded-full mr-3 shrink-0",style:{backgroundColor:s}}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"text-gray-800 font-medium",style:{fontFamily:m},children:e.name}),e.category&&(0,o.jsx)("span",{className:"text-xs text-gray-500",style:{fontFamily:m},children:e.category})]})]},"package-".concat(t)))})]})]})})}),(0,o.jsxs)("div",{className:"p-4 border-t shrink-0 text-center text-xs text-gray-400",children:[I.length+F.length+E.length," ",g("products_available")]})]})}):null},eX=(e,t,r)=>{if(3!==r||!e)return{isValid:!0};let o=e.cash_orders_amount_capping;if(!o||1!==o.status)return{isValid:!0};let a=parseFloat(String(o.amount));return t>a?{isValid:!1,errorMessage:"Cash orders cannot exceed ".concat(a,". Please choose a different payment method or reduce your order total."),cappingAmount:a}:{isValid:!0,cappingAmount:a}},eZ=(e,t,r)=>{if(3!==r)return{shouldReset:!1};let o=eX(e,t,r);return o.isValid?{shouldReset:!1}:{shouldReset:!0,reason:o.errorMessage,cappingAmount:o.cappingAmount}},e$=(e,t,r)=>{if(3!==r||!e||!e.settings)return{isValid:!0};let o=Number(e.settings.pickup_cash_capping_amount);return!o||isNaN(o)?{isValid:!0}:t>o?{isValid:!1,errorMessage:"Cash orders cannot exceed ".concat(o,". Please choose a different payment method or reduce your order total."),cappingAmount:o}:{isValid:!0,cappingAmount:o}},eQ=e=>{let{subtotal:t,tax:r,charges:a,currencySymbol:i="$",secondaryBtnColor:l="",secondaryBtnTxtColor:n="",secondaryColor:s="",fontFamily:d="",currentcharge:c}=e,{t:m}=(0,p.Bd)(),[_,v]=u.useState(null);return(u.useEffect(()=>{var e;
1if(!a||1!==a.cartvalue_based_pricing||!(null===(e=a.cartvalue_pricing_details)||void 0===e?void 0:e.length)){v(null);return}let o=a.cartvalue_pricing_details,l=a.delivery_charges||0,n=(parseFloat(t)||0)+(parseFloat(r)||0),s=e=>{var t,r,o,a,i,l;return"absolute"===(null===(r=e.settings)||void 0===r?void 0:null===(t=r.cost_share_setting)||void 0===t?void 0:t.type)?parseFloat((null===(a=e.settings)||void 0===a?void 0:null===(o=a.cost_share_setting)||void 0===o?void 0:o.cost_share)||"0"):parseFloat((null===(l=e.delivery_partners)||void 0===l?void 0:null===(i=l[0])||void 0===i?void 0:i.delivery_cost)||e.delivery_cost||"0")},d=l,c=null;for(let e of o){let t=e.cart_minvalue||0,r=e.cart_maxvalue||1/0;if(n>=t&&(0===r||n<=r)){c=e,d=s(e);break}}c||(d=l);let u=null,m=0,_=d;for(let e of o){let t=e.cart_minvalue||0,r=s(e);n<t&&r<d&&r<_&&(u=e,_=r,m=t-n)}u&&m>0?(v({show:!0,amountToAdd:m,currentCharge:d,reducedCharge:_}),console.log("Delivery Banner: Add ".concat(i).concat(m.toFixed(2)," to reduce delivery from ").concat(i).concat(d.toFixed(2)," to ").concat(i).concat(_.toFixed(2)))):v(null)},[t,r,a,i]),null==_?void 0:_.show)?(_.currentCharge,_.reducedCharge,(0,o.jsxs)("div",{style:{fontFamily:d,backgroundColor:"".concat(s,"20"),borderColor:l,color:n},className:"  p-4 rounded-lg mb-4 border  ",children:[(0,o.jsxs)("p",{className:"text-sm  ",children:[m("Add products worth")," ",i,_.amountToAdd.toFixed(2)," ",m("to reduce delivery charges by")," ",i,_.reducedCharge.toFixed(2)]}),(0,o.jsxs)("p",{className:"text-xs mt-1",style:{color:n},children:[m("Current delivery charges will be")," ",c]})]})):null};function e0(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1280,[t,r]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{let t=()=>r(window.innerWidth<e);return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),t}let e1=e=>{var t,r,a,i,l,n,s,d,c,m,_,v,g,f,h,x,b,w,N,j,k,C,I,F,E,A,D,O,M,T,R,B,z,J,V,U,W,H,G,Y,K,X,Z,$,Q,ee,er,eo;let{bgColor:ea,primaryColor:ei,fontFamily:el,secondaryColor:es,sessionID:ed,cartItemDetails:eu,taxDetails:em,paymentMethods:e_,secondaryBtnTxtColor:ep,secondaryBtnColor:ev,setPaymentCardModal:eg,onPaymentMethodChange:ef,errorMessage:ey,openPay:eh,seterror:ex,cardListapi:eb,onDeleteCard:ew,currency:eN,cardList:ej,handlePaymentMethod:ek,handleCardCheckboxChange:eS,setCvv:eC,cvv:eI,total:eF,handleCustomTip:eE,handleTipClick:eA,handleOpenCustomTip:eD,openCustomTip:eO,setOpenCustomTip:eR,tipValue:eV,tipType:eU,setCardRouter:eW,addeditem:eG,pointsdata:eY,deftax:e1,inputRef:e2,currencySymbol:e5,cvvError:e4,setCvvError:e3,setusePoints:e7,setPointData:e6,usePoints:e8,setTipValue:e9,onPromotionChange:te,selectedCard:tt,setSelectedCard:tr,setpromotion:to,reedemable:ta,promotion:ti,isInitializedForOneScreen:tl,checkedPaymentMethod:tn,setIsCartUpdated:ts,setCheckedPaymentMethod:td,openBtn:tc,setOpenBtn:tu,setIsOpen:tm,initialCardListApiError:t_,initialCardListApiCalled:tp,localalias:tv,ErrorPrimaryColor:tg,isPointsDataLoaded:tf,changeAmount:ty,setChangeAmount:th,showChangeInput:tx,setShowChangeInput:tb,showTipSection:tw,setShowTipSection:tN,changeError:tj,showChangePrompt:tk,setShowChangePrompt:tS,selectedButton:tC,setSelectedButton:tI,minimumOrderAmount:tF,isBelowMinimum:tE,selectDeliveryPartner:tA,paymentGateway:tD,setPaymentGateway:tO,setMercadoModal:tM,MercadoList:tP,page_location:tT,setBillpocketModal:tL,billpocketCardsList:tq=[],selectedBillpocketCard:tR,onBillpocketCardSelect:tB,onDeleteBillpocketCard:tz}=e,{t:tJ}=(0,p.Bd)(),tV=e0(769),tU=(0,u.useContext)(et.ib);if(!tU)throw Error("IndexPage must be used within a MyProvider");let{openSuccessModalFunc:tW,openFailureModalFunc:tH,openAlertModalFunc:tG,restaurantData:tY}=tU,tK=(null===(t=(Array.isArray(null==tY?void 0:null===(r=tY.ecom_settings)||void 0===r?void 0:r.analytics_settings)?tY.ecom_settings.analytics_settings:(null==tY?void 0:null===(a=tY.ecom_settings)||void 0===a?void 0:a.analytics_settings)?[tY.ecom_settings.analytics_settings]:[]).find(e=>"7ef38a2c-42dc-11ed-b878-0242ac120002"===e.platform&&"1"===e.status))||void 0===t?void 0:t.id)||"848451747356230",tX="checkout",tZ=(null===(i=(Array.isArray(null==tY?void 0:null===(l=tY.ecom_settings)||void 0===l?void 0:l.analytics_settings)?tY.ecom_settings.analytics_settings:(null==tY?void 0:null===(n=tY.ecom_settings)||void 0===n?void 0:n.analytics_settings)?[tY.ecom_settings.analytics_settings]:[]).find(e=>"db0098c8-42dc-11ed-b878-0242ac120002"===e.platform))||void 0===i?void 0:i.id)||"G-V55PFGDBF9",t$=[],tQ=(0,u.useRef)([]),t0=(0,u.useRef)([]),t1=(0,u.useRef)(""),[t2,t5]=(0,u.useState)([]),[t4,t3]=(0,u.useState)({}),[t7,t6]=(0,u.useState)(null),[t8,t9]=(0,u.useState)(!1),[re,rt]=(0,u.useState)(null),[rr,ro]=(0,u.useState)(""),[ra,r
1i]=(0,u.useState)(!1),[rl,rn]=(0,u.useState)(null),[rs,rd]=(0,u.useState)(null),[rc,ru]=(0,u.useState)(!1),[rm,r_]=(0,u.useState)(!1),[rp,rv]=(0,u.useState)(!1),rg=null==re?void 0:null===(d=re.ecom_settings)||void 0===d?void 0:null===(s=d.tip_config)||void 0===s?void 0:s.tip_status,rf=(0,u.useRef)(0);(0,u.useEffect)(()=>{e8||(rf.current=Number(em.service)||0)},[e8,em.service]),rf.current;let ry=Math.min(Number(null==eG?void 0:null===(c=eG.order_items)||void 0===c?void 0:c.point_discount_amount)||0,Number((null==eY?void 0:eY.points)||0)),rh=Math.min(Number(null==eG?void 0:null===(m=eG.order_items)||void 0===m?void 0:m.total)||0,Number((null==eY?void 0:eY.points)||0));(0,u.useEffect)(()=>{var e,t;if(ts(!0),(null==eG?void 0:eG.order_type)==="delivery"&&tn){let t=null==e_?void 0:null===(e=e_.Payment_settings)||void 0===e?void 0:e.find(e=>e.payment_method===tn);if((null==t?void 0:t.payment_method_id)===3){let e=(0,S.o)(),t=localStorage.getItem("selected_delivery_partner_".concat(e));if(t)try{let e=JSON.parse(t),r=em.total||0,o=eZ(e,r,3);o.shouldReset&&(td(null),ef("",{},null),tu(!1),tN(!1),e9(0),tb(!1),tS(!1),th(0),tI(""),tH(tJ("cash_order_amount_exceeds_limit",{amount:o.cappingAmount})),console.log("Cash payment method reset due to amount exceeding limit:",o.cappingAmount))}catch(e){console.error("Error validating cash order amount on total change:",e)}}}if((null==eG?void 0:eG.order_type)!=="delivery"&&tn){let e=null==e_?void 0:null===(t=e_.Payment_settings)||void 0===t?void 0:t.find(e=>e.payment_method===tn);(null==e?void 0:e.payment_method_id)===3&&rw(3)}},[em,tn,null==eG?void 0:eG.order_type,e_,td,tu,tN,e9,tb,tS,th,tI,tH,tJ]);let rx=(0,u.useRef)(!0);(0,u.useEffect)(()=>()=>{rx.current=!1},[]),(0,u.useEffect)(()=>{var e,t;let r=((null==re?void 0:null===(t=re.ecom_settings)||void 0===t?void 0:null===(e=t.tip_config)||void 0===e?void 0:e.options)||[]).find(e=>e.is_default);tw&&"1"==rg&&(r?eA(r.is_custom&&null===r.value?0:r.value):eA(null))},[re,tw]),(0,u.useEffect)(()=>{let e=localStorage.getItem("analytics_settings_".concat(tv)),t=localStorage.getItem("resturantserversidesettings");if(t&&rt(JSON.parse(t)),e){console.log("analyticsSettings",e);try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&"object"==typeof t?[t]:[];tQ.current=r.filter(e=>"7ef38a2c-42dc-11ed-b878-0242ac120002"==e.platform&&"1"==e.status),t0.current=r.filter(e=>"db0098c8-42dc-11ed-b878-0242ac120002"==e.platform&&"1"==e.status),t5(t0.current)}catch(e){console.error("Failed to parse analytics settings:",e)}}},[]);let rb=e=>"string"==typeof e?parseFloat(e.replace(/[^0-9.]/g,""))||0:"number"==typeof e?e:0;(0,u.useEffect)(()=>{var e,t,r;let o;let a=localStorage.getItem("cartData_".concat(tv));if(a)try{o=JSON.parse(a)}catch(e){console.error("Failed to parse cartData:",e)}let i=rb(null==o?void 0:o.final_amount),l=null!==(r=null==o?void 0:null===(t=o.order_items)||void 0===t?void 0:null===(e=t.item_details)||void 0===e?void 0:e.length)&&void 0!==r?r:0,n=e5||eN||"MXN";if(console.log("[Checkout Pixel] finalAmount:",i,"itemCount:",l,"currency:",n),void 0!==i&&n){let e=Array.isArray(null==tQ?void 0:tQ.current)&&tQ.current.length>0?tQ.current[0].id:"";t1.current=e,console.log("[Checkout Pixel] Setting fbData — pixelId:",tK,"resId:",e,"value:",i,"currency:",n),t6({id:e,value:i,num_items:l,currency:n})}else console.warn("[Checkout Pixel] fbData NOT set — finalAmount:",i,"currency:",n);Array.isArray(null==t0?void 0:t0.current)&&(null==t0?void 0:t0.current.length)>0&&(console.log("[Checkout GA] Setting googleAnalyticsData — value:",i,"currency:",n),t3({value:i,num_items:l,currency:n}))},[]),(0,u.useEffect)(()=>{Array.isArray(tQ.current)&&tQ.current.length>0&&(t1.current=tQ.current[0].id)}),(0,u.useEffect)(()=>{},[t8,em]),(0,u.useEffect)(()=>{ti&&"object"==typeof ti&&Object.keys(ti).length>0||(t9(!1),rd(null))},[ti]),(0,u.useEffect)(()=>{tn||(tu(!1),tN(!1),e9(0),tb(!1),tS(!1),th(0),tI(""),console.log("Resetting openBtn and related sections via useEffect"))},[tn,tu,tN,e9,tb,tS,th,tI]),(0,u.useEffect)(()=>{console.log("showChangeInput changed:",tx)},[tx]);let rw=e=>{if((null==eG?void 0:eG.order_type)!=="delivery"&&3===e){var t;let e=e$(null==e_?void 0:null===(t=e_.Payment_settings)||void 0===t?void 0:t.find(e=>3===e.payment_method_id),em.total||0,3);if(!e.isValid)return td(null),ef("",{},null),tu(!1),tN(!1),e9(0),tb(!1),tS(!1),th(0),tI(""),tH(tJ("cash_order_amount_exceeds_limit",{amount:e.cappingAmount})),console.log("Cash payment method reset due to amount exceeding limit (Pickup):",e.cappingAmount),{isValid:!1,cappingAmount:e.cappingAmount}}return{isValid:!0}},rN=(e,t)=>{var r,o,a,i;
1if(eu.some(e=>e.needsUpdate)){tH(tJ("Some of your added items need an update"));return}let{deliveryPartnerAssigned:l,errorMessage:n}=tA(t.payment_method_id,eG,e_);if(n)return tH(n),{deliveryPartnerAssigned:l,errorMessage:n};if((null==eG?void 0:eG.order_type)==="delivery"&&3===t.payment_method_id){let e=(0,S.o)(),r=localStorage.getItem("selected_delivery_partner_".concat(e));if(r)try{let e=JSON.parse(r),o=em.total||0,a=eX(e,o,t.payment_method_id);if(!a.isValid)return tN(!1),e9(0),tb(!1),tS(!1),th(0),tI(""),tH(tJ("cash_order_amount_exceeds_limit",{amount:a.cappingAmount})),{deliveryPartnerAssigned:l,errorMessage:tJ("cash_order_amount_exceeds_limit",{amount:a.cappingAmount})}}catch(e){console.error("Error parsing selected delivery partner:",e)}}if((null==eG?void 0:eG.order_type)!=="delivery"&&3===t.payment_method_id){let e=rw(t.payment_method_id);if(!e.isValid)return{deliveryPartnerAssigned:l,errorMessage:tJ("cash_order_amount_exceeds_limit",{amount:e.cappingAmount})}}tO(t),tu(!1),tr(null);let s=(null==re?void 0:null===(o=re.ecom_settings)||void 0===o?void 0:null===(r=o.tip_config)||void 0===r?void 0:r.payment_methods)||[];if(t.gateway_id&&7==t.gateway_id?((t_||!tp)&&eb(t),tu(!0),tN(!0)):t.gateway_id&&1==t.gateway_id?((null==tP?void 0:tP.length)!=0&&tP||(tm(!1),setTimeout(()=>{tM(!0)},300)),tu(!0),tN(!0)):t.gateway_id&&3==t.gateway_id||(!s||s.includes(t.payment_method_id)||t$.includes(t.payment_method_id)?tN(!0):(e9(0),tN(!1))),"1"==rg&&(!s||s.includes(t.payment_method_id)||t$.includes(t.payment_method_id))){let e=((null==re?void 0:null===(i=re.ecom_settings)||void 0===i?void 0:null===(a=i.tip_config)||void 0===a?void 0:a.options)||[]).find(e=>e.is_default);e?eA(e.is_custom&&null===e.value?0:e.value):eA(null)}else eA(0);let d=s.includes(t.payment_method_id);tN("1"==rg&&d),td(e);let c={...em,service:0,tip:0};return c.total=c.subtotal+c.tax+((null==eG?void 0:eG.delivery_cost)||0)-(c.discount||0),ef(e,t,tt),(null==eG?void 0:eG.order_type)=="delivery"&&3==t.payment_method_id?tS(!0):(tS(!1),tb(!1),th(0)),console.log("Final openBtn state:",tc),{deliveryPartnerAssigned:l,error:n}},rj=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(!((null==tD?void 0:tD.gateway_id)===7&&tn===(null==tD?void 0:tD.payment_method))){rj.current=!1,sessionStorage.removeItem("netpayCardFormCancelled");return}if(!tp){rj.current=!1;return}let e="true"===sessionStorage.getItem("cardFormBoolean")&&!!sessionStorage.getItem("cardForm"),t="true"===sessionStorage.getItem("netpayCardFormCancelled");0!==ej.length||rj.current||e||t?ej.length>0&&(rj.current=!1,sessionStorage.removeItem("netpayCardFormCancelled")):(rj.current=!0,tr(null),eC({}),e3(null),eg(!0),localStorage.setItem("tempPaymentGateway",JSON.stringify(tD)))},[tD,tn,tp,ej,eg,tr,eC,e3]),(0,u.useEffect)(()=>{let e=localStorage.getItem("tempPaymentGateway");e&&(console.log("oooo"),tO(JSON.parse(e)),localStorage.removeItem("tempPaymentGateway"))},[tO]);let rk=(e,t)=>{eC(r=>({...r,[e]:t.target.value})),e4===e&&e3(null)},rS=e=>{var t,r,a,i;let l="•••• ".concat(e.card_number.slice(-4)),n=((null==tt?void 0:tt.token)||(null==tt?void 0:tt.id))===e.token;return(0,o.jsxs)("div",{className:"bg-white shadow-md  rounded-xl p-4 mb-4 border-2 transition-all duration-300 ".concat(n?"border-primary":"border-transparent"," hover:border-primary cursor-pointer"),style:{fontFamily:"".concat(el,", sans-serif")},onClick:()=>eS(e,eI[e.token]||""),children:[(0,o.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("input",{type:"radio",id:"card-".concat(e.token),name:"selectedCard",className:"sr-only",checked:n,readOnly:!0}),(0,o.jsxs)("label",{htmlFor:"card-".concat(e.token),className:"flex items-center",children:[(0,o.jsx)(eT.A,{className:"w-8 h-8 mr-3",style:{color:es}}),(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"text-base font-semibold text-gray-600",children:l}),(0,o.jsx)("p",{className:"text-sm text-gray-600",children:"".concat(null!==(a=null===(t=e.user_details)||void 0===t?void 0:t.first_name)&&void 0!==a?a:""," ").concat(null!==(i=null===(r=e.user_details)||void 0===r?void 0:r.last_name)&&void 0!==i?i:"")})]})]})]}),(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,o.jsx)(eL.A,{className:"w-6 h-6 text-green-500"}),(0,o.jsx)("div",{className:"p-1.5 rounded-full hover:bg-red-50 text-gray-400 hover:text-red-500 transition-colors duration-200 cursor-pointer",onClick:t=>{t.stopPropagation(),null==ew||ew(e)},title:tJ("Delete Card"),children:(0,o.jsx)(eq.A,{className:"w-5 h-5"})})]})]}),(0,o.jsxs)("div",{className:"flex justify-between items-center",children:[(0,o.jsxs)("span",{className:"text-sm text-gray-600",children:["Expires: ",e.expMonth,"/",e.expYear]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("label",{htmlFor:"cvv-".concat(e.token),className:"mr-2 text-sm font-medium",children:"CVV:"}),(0,o.jsx)("input",{type:"password",id:"cvv-".concat(e.token),value:eI[e.token]||"",onChange:t=>rk(e.token,t),onClick:t=>{t.stopPropagation(),n||eS(e,eI[e.token]||"")},placeholder:"•••",className:"w-16 p-2 text-center border rounded-md ".concat(e4===e.token?"border-".concat(tg):"border-gray-300"," focus:outline-none focus:ring-2 focus:ring-primary"),maxLength:4,disabled:!1})]})]})]},e.token)},rC=e=>{let t="•••• ".concat(e.last4),r=((null==tt?void 0:tt.token)||(null==tt?void 0:tt.id))===e.id;return eW(!0),(0,o.jsxs)("div",{className:"bg-white shadow-md rounded-xl p-4 mb-4 border-2 transition-all duration-300 ".concat(r?"border-primary":"border-transparent"," hover:border-primary curs
1or-pointer"),style:{fontFamily:"".concat(el,", sans-serif")},onClick:()=>eS(e,eI[e.id]||""),children:[(0,o.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("input",{type:"radio",id:"card-".concat(e.id),name:"selectedCard",className:"sr-only",checked:r,readOnly:!0}),(0,o.jsxs)("label",{htmlFor:"card-".concat(e.id),className:"flex items-center",children:[(0,o.jsx)(y(),{src:e.secure_thumbnail||e.thumbnail,alt:e.brand,width:24,height:24,className:"w-auto mr-3"}),(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"text-base font-semibold text-gray-600",children:t}),(0,o.jsx)("p",{className:"text-sm text-gray-600",children:e.cardholder_name}),(0,o.jsxs)("p",{className:"text-xs text-gray-500",children:[e.brand," \xb7 ",e.issuer]})]})]})]}),r&&(0,o.jsx)(eL.A,{className:"w-6 h-6 text-green-500"})]}),(0,o.jsxs)("div",{className:"flex justify-between items-center",children:[(0,o.jsxs)("span",{className:"text-sm text-gray-600",children:["Expires: ",e.exp_month,"/",e.exp_year]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("label",{htmlFor:"cvv-".concat(e.id),className:"mr-2 text-sm font-medium",children:"CVV:"}),(0,o.jsx)("input",{type:"password",id:"cvv-".concat(e.id),value:eI[e.id]||"",onChange:t=>rk(e.id,t),onClick:t=>{t.stopPropagation(),r||eS(e,eI[e.id]||"")},placeholder:"•••",className:"w-16 p-2 text-center border rounded-md ".concat(e4===e.id?"border-".concat(tg):"border-gray-300"," focus:outline-none focus:ring-2 focus:ring-primary"),maxLength:e.security_code_length||4,disabled:!1})]})]})]},e.id)},rI=Math.round(100*Number(em.tax))/100;console.log(typeof(null==eY?void 0:eY.redeem_categories),"pointsdata");let rF=(0,u.useMemo)(()=>{var e,t,r;if(!tf||!eY||!Array.isArray(eY.redeem_categories)||!(null==eG?void 0:null===(e=eG.order_items)||void 0===e?void 0:e.item_details)||!Array.isArray(eG.order_items.item_details))return console.warn("Invalid data for validation:",{isPointsDataLoaded:tf,pointsdataExists:!!eY,redeemCategoriesIsArray:Array.isArray(null==eY?void 0:eY.redeem_categories),itemDetailsExists:!!(null==eG?void 0:null===(t=eG.order_items)||void 0===t?void 0:t.item_details),itemDetailsIsArray:Array.isArray(null==eG?void 0:null===(r=eG.order_items)||void 0===r?void 0:r.item_details)}),!1;let o=isNaN(Number(eY.points))?0:Number(eY.points);if(o<=0)return console.warn("No valid points available:",o),!1;try{return eY.redeem_categories.some(e=>eG.order_items.item_details.some(t=>{let r=isNaN(Number(e.product_id))?0:Number(e.product_id),o=isNaN(Number(t.item_id))?0:Number(t.item_id),a=isNaN(Number(e.category_id))?0:Number(e.category_id),i=isNaN(Number(t.category_id))?0:Number(t.category_id),l="All"==e.product_id||r==o,n="All"==e.category_id||a==i;return l&&r!=o&&console.log("Loose equality matched product IDs:",{categoryProductId:r,itemProductId:o}),n&&a!=i&&console.log("Loose equality matched category IDs:",{categoryCategoryId:a,itemCategoryId:i}),l&&n}))}catch(e){return console.error("Error in validCategoriesAndProductsInCart:",(null==e?void 0:e.stack)||e),!1}},[tf,eY,eG]),rE=()=>{let e=sessionStorage.getItem("cardForm"),t=sessionStorage.getItem("cardFormBoolean"),r=localStorage.getItem("mercadoPagoPaymentInfo_".concat(tv));if("true"===t&&e)try{let t=JSON.parse(e).cardNumber;return"".concat(t.slice(0,6),"******").concat(t.slice(-4))}catch(e){console.error("Error parsing card form data:",e)}else if((null==tD?void 0:tD.gateway_id)==1&&r)try{let e=JSON.parse(r).cardNumber;return"".concat(e.slice(0,6),"******").concat(e.slice(-4))}catch(e){console.error("Error parsing card form data:",e)}return null},rA=()=>{eR(!1),eA(0),e9("")},rD=async()=>{if(!rr.trim()){rx.current&&rn(tJ("Please_enter_a_coupon_code"));return}if(rx.current){ri(!0),rn(null);try{var e,t,r,o,a,i,l,n,s;let d=localStorage.getItem("version"),c="profile_check_".concat(tv),u=localStorage.getItem(c),m=u?JSON.parse(u):{},_=localStorage.getItem("selected_branchmode_".concat(tv)),p=(0,ec.z)(),v=null==eG?void 0:eG.order_type,g=_?(null===(e=JSON.parse(_))||void 0===e?void 0:e.mode)==="pickup"?"takeout":null===(t=JSON.parse(_))||void 0===t?void 0:t.mode:"pickup"===v?"takeout":v,f=JSON.stringify({restaurant_id:null==re?void 0:re.restaurant_id,branch_id:_?null===(r=JSON.parse(_))||void 0===r?void 0:r.branch.branch_id:"",order_type:g,phone_number:(null==m?void 0:m.ph
1one_number)||"",member_id:(null==m?void 0:m.member_id)||"",sender_id:null,coupon_code:rr.toLocaleUpperCase(),utm_campaign:rr.toLocaleLowerCase(),utm_source:"promo",is_loyality_show:0,session_id:ed,version:d,source:"ecom",request_timestamp:new Date}),y="".concat(window.location.origin,"/"),h="https://order.foodbot.ai/apiv2";y&&(h=y+"apiv2");let x=await fetch("".concat(h,"/ecom/v1/offers"),{method:"POST",headers:p,body:f,redirect:"follow"}),b=await x.json();if(!rx.current)return;if("success"===b.status&&("200"==b.status_code||"204"==b.status_code)){let e=b.data.offer_details,t=(null===(o=b.data)||void 0===o?void 0:o.new_message)||"",r={promo_link_invalid:tJ("promo_link_invalid"),promo_found_not_redeemed:tJ("promo_found_not_reddemed"),offer_invalid:tJ("offer_invalid"),coupon_redeem_successful:tJ("coupon_redeem_successfull"),promo_first_time_use_only:tJ("promo_first_time_use_only"),claim_limit_reached:tJ("claim_limit_reached"),promo_already_used:tJ("promo_found_not_reddemed"),coupon_already_used:tJ("coupon_already_use"),promo_deleted:tJ("claim_limit_reached"),promo_not_valid_today:tJ("promo_not_valid_today")},c=e.find(e=>e.coupon_code===rr.toLocaleUpperCase());if(c){let e=c.message_key||c.refined_message||c.message;if("coupon_redeem_successful"===e){let e=_?null===(l=JSON.parse(_))||void 0===l?void 0:l.branch.branch_id:"",r=String(c.branch_id).split(",").map(e=>e.trim());if(c.branch_id&&"All"!==String(c.branch_id)&&!r.includes(String(e))){rn(tJ("this_offer_is_not_applicable_for_this_branch")),tH(tJ("this_offer_is_not_applicable_for_this_branch"));return}let o={...c,offer_discount_type:"Discount"===c.offer_discount_type?"discount":c.offer_discount_type};localStorage.setItem("offers_".concat(tv),JSON.stringify(o)),localStorage.setItem("offer_details_".concat(tv),JSON.stringify(o)),window.dispatchEvent(new Event("promotionUpdated"));let a=localStorage.getItem("cartData_".concat(tv));if(a)try{let e=JSON.parse(a);e.promotion_applied=o,localStorage.setItem("cartData_".concat(tv),JSON.stringify(e))}catch(e){console.error("Failed to parse cart data:",e)}te(o),ts(!1),setTimeout(()=>ts(!0),100),ro(""),tW(t||tJ("coupon_redeem_successfull"));return}if("already_claimed_not_used"==c.refined_message){tW(tJ("already_claimed_coupon"));return}if(r[e]&&"promo_found_not_redeemed"!==e){tG(t||r[e]),tm(!1);return}}if(t&&c&&["not_found","already_used","already_redeemed","expired","no_promo_linked","offer_unavailable"].includes(c.refined_message)){tH(t),tm(!1);return}let u=JSON.stringify({restaurant_id:null==re?void 0:re.restaurant_id,branch_id:_?null===(a=JSON.parse(_))||void 0===a?void 0:a.branch.branch_id:"",order_type:g,phone_number:(null==m?void 0:m.ph
1one_number)||"",member_id:(null==m?void 0:m.member_id)||"",sender_id:null,utm_source:"promo",is_loyality_show:0,session_id:ed,version:d,source:"ecom",request_timestamp:new Date}),v=await fetch("".concat(h,"/ecom/v1/offers"),{method:"POST",headers:p,body:u,redirect:"follow"}),f=await v.json();if(!rx.current)return;(null==f?void 0:null===(i=f.data)||void 0===i?void 0:i.loyalty_points_details)&&(localStorage.setItem("loyalty_points_details_".concat(tv),JSON.stringify(f.data.loyalty_points_details)),eY&&e6(f.data.loyalty_points_details),ts(!1),setTimeout(()=>{rx.current&&(ts(!0),window.dispatchEvent(new Event("pointsUpdated")))},100));let y=f.data.offer_details.find(e=>e.promotion_code===rr.toLocaleUpperCase()&&!e.message&&!e.refined_message);if(y){let e=_?null===(n=JSON.parse(_))||void 0===n?void 0:n.branch.branch_id:"",r=String(y.branch_id).split(",").map(e=>e.trim());if(y.branch_id&&"All"!==String(y.branch_id)&&!r.includes(String(e))){rn(tJ("this_offer_is_not_applicable_for_this_branch")),tH(tJ("this_offer_is_not_applicable_for_this_branch"));return}let o={...y,offer_discount_type:"Discount"===y.offer_discount_type?"discount":y.offer_discount_type};localStorage.setItem("offers_".concat(tv),JSON.stringify(o)),localStorage.setItem("offer_details_".concat(tv),JSON.stringify(o)),window.dispatchEvent(new Event("promotionUpdated"));let a=localStorage.getItem("cartData_".concat(tv));if(a)try{let e=JSON.parse(a);e.promotion_applied=o,(null==f?void 0:null===(s=f.data)||void 0===s?void 0:s.loyalty_points_details)&&(e.loyalty_points_details=f.data.loyalty_points_details),localStorage.setItem("cartData_".concat(tv),JSON.stringify(e))}catch(e){console.error("Failed to parse cart data:",e)}te(o),ts(!1),setTimeout(()=>ts(!0),100),ro(""),tW(t||tJ("coupon_redeem_successfull"))}}else rn(b.message),tH(b.message)}catch(e){console.error("Coupon application error:",e),rn(tJ("Error applying coupon")),tH(tJ("Error applying coupon"))}finally{ri(!1)}}},rO=e=>{let t=parseFloat(e);return!isNaN(t)&&0!==t},rM=()=>{(null==ta?void 0:ta.multipleoffer_redeem)==="no"&&ti&&"object"==typeof ti&&Object.keys(ti).length>0?ru(!0):setTimeout(()=>{rx.current&&(e7(!0),e6(eY),to(null),localStorage.removeItem("offer_details_".concat(tv)),window.dispatchEvent(new Event("promotionCleared")),t9(!1))},100)};return(0,o.jsxs)(o.Fragment,{children:[t7&&(0,o.jsx)(L.default,{id:tK,resId:t1.current,page:tX,data:{value:t7.value,num_items:t7.num_items,currency:t7.currency}}),Object.keys(t4).length>0&&(0,o.jsx)(q.default,{id:tZ,settings:t2,page:tX,data:t4,page_location:tT}),rc&&(0,o.jsx)(ez.A,{setIsOpen:ru,isOpen:rc,description:tJ("You chose to redeem points, any other applied offer will be removed, would you like to redeem?"),onConfirm:()=>{e7(!0),e6(eY),to(null),localStorage.removeItem("offer_details_".concat(tv)),t9(!1)},primaryColor:ei,bgColor:ea}),(0,o.jsx)(eK,{isOpen:rp,onClose:()=>rv(!1),buyProductIds:(null==rs?void 0:null===(_=rs.offer_products)||void 0===_?void 0:_.offer_buy_products)||(null==rs?void 0:null===(v=rs.offer_products)||void 0===v?void 0:v.offer_discount_products)||[],getProductIds:(null==rs?void 0:null===(g=rs.offer_products)||void 0===g?void 0:g.offer_get_products)||[],packageItems:(null==rs?void 0:null===(f=rs.offer_products)||void 0===f?void 0:f.package_items)||[],alias:tv,primaryColor:ei,bgColor:ea,secondaryColor:es,fontFamily:el}),(0,o.jsxs)("div",{className:"xl:max-h-[100vh] max-h-[80vh] pt-6 xl:pt-3 z-[50]",children:[(0,o.jsxs)("div",{className:" px-6 xl:px-0",children:[(0,o.jsx)("div",{className:"flex justify-between",children:(0,o.jsx)("div",{style:{color:ep,backgroundColor:ev,fontFamily:"".concat(el,", sans-serif")},className:"mb-4 px-4 py-1  rounded-full  font-bold ",children:tJ("choose_payment_method")})}),(0,o.jsxs)("div",{style:{borderColor:ei},className:"border-b pb-6",children:[(!(null==e_?void 0:e_.Payment_settings)||0===e_.Payment_settings.length)&&(0,o.jsx)("p",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"text-sm py-2",children:tJ("no_payment_methods_available")}),null==e_?void 0:null===(h=e_.Payment_settings)||void 0===h?void 0:h.map(e=>{let t=1===e.payment_method_id?rE():null;return(0,o.jsxs)("div",{className:"mb-2 leading-5 font-bold",children:[(0,o.jsxs)("label",{className:"flex items-center cursor-pointer text-[18px]",children:[(0,o.jsx)("input",{type:"radio",id:"payment-".concat(e.id),name:"paymentType",style:{borderColor:tn===e.payment_method?ei:"#d1d5db",backgroundColor:tn===e.payment_method?es:"transparent",opacity:0===em.total?.5:1,cursor:0===em.total?"not-allowed":"pointer"},className:"h-5 w-5 mr-3 cursor-pointer appearance-none border-2 border-gray-400 rounded-full checked:border-2 checked:border-black",value:e.payment_method,checked:tn===e.payment_method,disabled:0===em.total,onChange:()=>rN(e.payment_method,e)}),(0,o.jsx)("span",{style:{color:ei,fontFamily:"".concat(el,", sans-serif"),opacity:0===em.total?.5:1},children:e.payment_method})]}),(0,o.jsx)("div",{className:"my-2 ml-8",children:t&&tn===e.payment_method&&(0,o.jsx)("span",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"text-sm mt-1",children:t})}),(null==e?void 0:e.payment_method_id)==1?(0,o.jsxs)(o.Fragment,{children:[tc&&(ej.length>0||tP&&(null==tP?void 0:tP.length)>0)&&(0,o.jsx)("div",{id:"netpay-card-list",style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"font-black underline underline-offset-1 cursor-pointer my-4 text-lg",children:tJ("select a card")}),ej.length>0&&tc&&(null==tD?void 0:tD.gateway_id)==7&&ej.map(e=>rS(e)),tP&&(null==tP?void 0:tP.length)>0&&tc&&(null==tD?void 0:tD.gateway_id)==1&&tP.map(e=>rC(e)),tc&&(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"font-black underline underline-offset-1 cursor-pointer mt-4 text-lg",onClick:()=>{(null==tD?void 0:tD.gateway_id)===7?(sessionStorage.removeItem("netpayCardFormCancelled"),tr(null),eC({}),e3(null),eg(!0),localStorage.setItem("tempPaymentGateway",JSON.stringify(e))):(null==tD?void 0:tD.gateway_id)===1?(tm(!1),eC({}),tr(null),setTimeout(()=>{tM(!0)},300)):null==tD||tD.gateway_id},children:tJ("addcard")})]}):null,(null==e?void 0:e.gateway_id)===3&&tn===e.payment_method&&tq&&tq.length>0&&(0,o.jsx)(eB,{primaryColor:ei,secondaryColor:es,fontFamily:el,billpocketCardsList:tq,selectedBillpocketCard:tR,onBillpocketCardSelect:e=>tB&&tB(e),onDeleteCard:e=>tz&&tz(e)})]},e.id)})]}),tn&&"transferencia"===tn.toLowerCase()&&(null==e_?void 0:null===(x=e_.Payment_settings)||void 0===x?void 0:x.some(e=>{var t;return("transferencia"===e.payment_method.toLowerCase()||"转移"===e.payment_method.toLowerCase())&&(null===(t=e.settings)||void 0===t?void 0:t.ask_bank_details)===1}))&&(0,o.jsx)(eH,{paymentMethods:e_,primaryColor:ei,fontFamily:el,secondaryColor:es}),ey&&(0,o.jsx)("div",{style:{color:tg},className:"pt-2   font-medium",children:ey}),(0,o.jsx)(eJ.A,{showChangePrompt:tk,setShowChangePrompt:tS,showChangeInput:tx,setShowChangeInput:tb,changeAmount:ty,setChangeAmount:th,changeError:tj,primaryColor:ei,secondaryBtnColor:ev,secondaryBtnTxtColor:ep,fontFamily:el,ErrorPrimaryColor:tg,currency:eN,taxDetails:em,selectedButton:tC,setSelectedButton:tI,curveorder:!1}),(0,o.jsx)("div",{style:{borderColor:ei},className:"my-auto pb-6 border-b",children:(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"lg:pt-8 pt-6 font-bold text-[12px] lg:text-[15px]",children:tf?(null==eY?void 0:eY.points)>0&&rF&&"yes"===eY.redeemable?(0,o.jsxs)("div",{className:"text-start",children:[parseFloat(eY.store_value||0)>((null==eG?void 0:null===(b=eG.order_items)||void 0===b?void 0:b.total)||0)?(0,o.jsx)("div",{className:"",children:e8?(0,o.jsxs)("div",{className:"font-bold text-[12px] lg:text-[15px]",children:[tJ("You have utilized")," ",Math.round(ry)," ",tJ("points")]}):(0,o.jsxs)("div",{children:[(0,o.jsxs)("p",{className:"text-gray-400 opacity-75",children:[tJ("total_points"),":"," ",isNaN(Number(eY.points))?0:eY.points," ",tJ("points")]}),(0,o.jsxs)("div",{className:"flex justify-between pt-3",children:[(0,o.jsxs)("div",{className:"",children:[tJ("applicable_points"),":"," ",Math.round((null==re?void 0:null===(N=re.ecom_settings)||void 0===N?void 0:null===(w=N.general_settings)||void 0===w?void 0:w.enable_delivery_points_usage)==1&&(null==eG?void 0:eG.order_type)==="delivery"?Math.min(Number((null==eY?void 0:eY.points)||0),rh+Number((null==eG?void 0:eG.delivery_cost)||0)):Math.min(Number((null==eY?void 0:eY.points)||0),rh))," ",tJ("points")]}),(0,o.jsx)("div",{className:"flex items-end",children:(0,o.jsx)(eP,{heading:"".concat((null==eY?void 0:eY.minimum_point_redeem)||0," ").concat(tJ(null==e1?void 0:null===(j=e1.loyalty_currency)||void 0===j?void 0:j.value)||tJ("points")," = ").concat((null==eY?void 0:eY.actual_store_value)||0," ").concat(null==e1?void 0:e1.currency),primaryColor:ei,text:(null==eY?void 0:null===(k=eY.redeem_categories)||void 0===k?void 0:k.length)>0&&(null==eY?void 0:null===(C=eY.redeem_categories[0])||void 0===C?void 0:C.product_id)==="All"&&(null==eY?void 0:null===(I=eY.redeem_categories[0])||void 0===I?void 0:I.category_id)==="All"?"":null==eY?void 0:null===(F=eY.redeem_categories)||void 0===F?void 0:F.map(e=>e.category_name||("All"===e.product_id&&"All"!==e.category_id?"All products in ".concat(e.category_name):"All categories and products")).join(", "),texttwo:"no"===eY.redeemable?"".concat(tJ("Minimum points required for redemption")," ").concat((null==eY?void 0:eY.minimum_point_redeem)||0," ").concat(tJ("points")):"",children:(0,o.jsxs)("svg",{width:"23",height:"23",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{d:"M13.6001 27.46C6.27952 27.46 0.370117 21.5506 0.370117 14.23C0.370117 6.9094 6.27952 1 13.6001 1C20.9207 1 26.8301 6.9094 26.8301 14.23C26.8301 21.5506 20.9207 27.46 13.6001 27.46ZM13.6001 2.9404C7.42612 2.9404 2.3
11052 8.056 2.31052 14.23C2.31052 20.404 7.42612 25.5196 13.6001 25.5196C19.7741 25.5196 24.8897 20.404 24.8897 14.23C24.8897 8.056 19.7741 2.9404 13.6001 2.9404Z",fill:"black",stroke:"black",strokeWidth:"0.525"}),(0,o.jsx)("path",{d:"M13.6001 10.1874C14.412 10.1874 15.0701 9.5293 15.0701 8.71744C15.0701 7.90558 14.412 7.24744 13.6001 7.24744C12.7883 7.24744 12.1301 7.90558 12.1301 8.71744C12.1301 9.5293 12.7883 10.1874 13.6001 10.1874Z",fill:"black"}),(0,o.jsx)("path",{d:"M13.6004 11.5105C12.7919 11.5105 12.1304 12.172 12.1304 12.9805V19.7425C12.1304 20.551 12.7919 21.2125 13.6004 21.2125C14.4089 21.2125 15.0704 20.551 15.0704 19.7425V12.9805C15.0704 12.172 14.4089 11.5105 13.6004 11.5105Z",fill:"black"})]})})})]})]})}):(0,o.jsx)("div",{children:e8?(0,o.jsxs)("div",{className:"font-bold text-[12px] lg:text-[15px]",children:[tJ("You have utilized"),(0,o.jsxs)("span",{className:"mx-2",children:[Math.round(ry)," ",tJ("points")]})]}):(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsxs)("div",{className:"",children:[tJ("applicable_points"),":"," ",Math.min(Math.round(eY.store_value||0),Number(eY.points||0))," ",tJ("points")]}),(0,o.jsx)("div",{className:"flex items-end",children:(0,o.jsx)(eP,{heading:"".concat((null==eY?void 0:eY.minimum_point_redeem)||0," ").concat((null==e1?void 0:null===(E=e1.loyalty_currency)||void 0===E?void 0:E.value)||tJ("points")," = ").concat((null==eY?void 0:eY.actual_store_value)||0," ").concat(null==e1?void 0:e1.currency),primaryColor:ei,text:(null==eY?void 0:null===(A=eY.redeem_categories)||void 0===A?void 0:A.length)>0&&(null==eY?void 0:null===(D=eY.redeem_categories[0])||void 0===D?void 0:D.product_id)==="All"&&(null==eY?void 0:null===(O=eY.redeem_categories[0])||void 0===O?void 0:O.category_id)==="All"?"":null==eY?void 0:null===(M=eY.redeem_categories)||void 0===M?void 0:M.map(e=>e.category_name||("All"===e.product_id&&"All"!==e.category_id?"All products in ".concat(e.category_name):"All categories and products")).join(", "),texttwo:"no"===eY.redeemable?"".concat(tJ("Minimum points required for redemption")," ").concat((null==eY?void 0:eY.minimum_point_redeem)||0," ").concat(tJ("points")):"",children:(0,o.jsxs)("svg",{width:"23",height:"23",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{d:"M13.6001 27.46C6.27952 27.46 0.370117 21.5506 0.370117 14.23C0.370117 6.9094 6.27952 1 13.6001 1C20.9207 1 26.8301 6.9094 26.8301 14.23C26.8301 21.5506 20.9207 27.46 13.6001 27.46ZM13.6001 2.9404C7.42612 2.9404 2.31052 8.056 2.31052 14.23C2.31052 20.404 7.42612 25.5196 13.6001 25.5196C19.7741 25.5196 24.8897 20.404 24.8897 14.23C24.8897 8.056 19.7741 2.9404 13.6001 2.9404Z",fill:"black",stroke:"black",strokeWidth:"0.525"}),(0,o.jsx)("path",{d:"M13.6001 10.1874C14.412 10.1874 15.0701 9.5293 15.0701 8.71744C15.0701 7.90558 14.412 7.24744 13.6001 7.24744C12.7883 7.24744 12.1301 7.90558 12.1301 8.71744C12.1301 9.5293 12.7883 10.1874 13.6001 10.1874Z",fill:"black"}),(0,o.jsx)("path",{d:"M13.6004 11.5105C12.7919 11.5105 12.1304 12.172 12.1304 12.9805V19.7425C12.1304 20.551 12.7919 21.2125 13.6004 21.2125C14.4089 21.2125 15.0704 20.551 15.0704 19.7425V12.9805C15.0704 12.172 14.4089 11.5105 13.6004 11.5105Z",fill:"black"})]})})})]})}),(0,o.jsx)("div",{className:"flex justify-start",children:e8?(0,o.jsx)("div",{className:"flex items-center pt-3 cursor-pointer",children:(0,o.jsx)("div",{className:"text-sm font-bold py-2.5 px-4 rounded-3xl",style:{backgroundColor:ev,color:ep,fontFamily:"".concat(el,", sans-serif")},onClick:()=>{e7(!1),e6(null)},children:(0,o.jsx)("span",{className:"mr-2",children:tJ("cancel")})})}):(0,o.jsx)("div",{onClick:()=>rM(),className:"flex pt-3",children:(0,o.jsx)("button",{onClick:()=>rM(),className:"text-[11px] font-black py-3 px-4 rounded-3xl w-full",style:{backgroundColor:ev,color:ep,fontFamily:"".concat(el,", sans-serif"),fontWeight:900},disabled:!tf||(null==eY?void 0:eY.points)<=0||"yes"!==eY.redeemable||!rF,children:tJ("use_points")})})})]}):(null==eY?void 0:eY.points)>0&&rF&&"no"===eY.redeemable?(0,o.jsx)("div",{children:(0,o.jsxs)("div",{className:"flex justify-start",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"text-[12px] lg:text-[15px] font-bold",children:(0,o.jsxs)("div",{className:"",children:[(0,o.jsxs)("p",{className:"text-gray-400 opacity-75",children:[tJ("total_points"),":"," ",isNaN(Number(eY.points))?0:eY.points," ",tJ("points")]}),(0,o.jsxs)("div",{children:[tJ("applicable_points"),":"," ",Math.round(eY.store_value||0)," ",tJ("points")]})]})}),(0,o.jsx)("div",{className:"flex justify-start items-end pb-2",children:(0,o.jsx)(eP,{heading:"".concat((null==eY?void 0:eY.minimum_point_redeem)||0," ").concat((null==e1?void 0:null===(T=e1.loyalty_currency)||void 0===T?void 0:T.value)||tJ("points")," = ").concat((null==eY?void 0:eY.actual_store_value)||0," ").concat(null==e1?void 0:e1.currency),primaryColor:ei,text:(null==eY?void 0:null===(R=eY.redeem_categories)||void 0===R?void 0:R.length)>0&&(null==eY?void 0:null===(B=eY.redeem_categories[0])||void 0===B?void 0:B.product_id)==="All"&&(null==eY?void 0:null===(z=eY.redeem_categories[0])||void 0===z?void 0:z.category_id)==="All"?"":null==eY?void 0:null===(J=eY.redeem_categories)||void 0===J?void 0:J.map(e=>e.category_name||("All"===e.product_id&&"All"!==e.category_id?"All products in ".concat(e.category_name):"All categories and products")).join(", "),texttwo:"no"===eY.redeemable?"".concat(tJ("Minimum points required for redemption")," ").concat((null==eY?void 0:eY.minimum_point_redeem)||0," ").concat(tJ("points")):"",children:(0,o.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{d:"M13.6001 27.46C6.27952 27.46 0.370117 21.5506 0.370117 14.23C0.370117 6.9094 6.27952 1 13.6001 1C20.9207 1 26.8301 6.9094 26.8301 14.23C26.8301 21.5506 20.9207 27.46 13.6001 27.46ZM13.6001 2.9404C7.42612 2.9404 2.3
11052 8.056 2.31052 14.23C2.31052 20.404 7.42612 25.5196 13.6001 25.5196C19.7741 25.5196 24.8897 20.404 24.8897 14.23C24.8897 8.056 19.7741 2.9404 13.6001 2.9404Z",fill:"black",stroke:"black",strokeWidth:"0.525"}),(0,o.jsx)("path",{d:"M13.6001 10.1874C14.412 10.1874 15.0701 9.5293 15.0701 8.71744C15.0701 7.90558 14.412 7.24744 13.6001 7.24744C12.7883 7.24744 12.1301 7.90558 12.1301 8.71744C12.1301 9.5293 12.7883 10.1874 13.6001 10.1874Z",fill:"black"}),(0,o.jsx)("path",{d:"M13.6004 11.5105C12.7919 11.5105 12.1304 12.172 12.1304 12.9805V19.7425C12.1304 20.551 12.7919 21.2125 13.6004 21.2125C14.4089 21.2125 15.0704 20.551 15.0704 19.7425V12.9805C15.0704 12.172 14.4089 11.5105 13.6004 11.5105Z",fill:"black"})]})})})]})}):(0,o.jsxs)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"text-start font-bold text-[12px] lg:text-[15px]",children:[tJ("total_points"),": ",(null==eY?void 0:eY.points)||0," ",tJ("points")]}):(0,o.jsx)("div",{className:"text-start",children:tJ("Loading points...")})})}),(0,o.jsx)("div",{style:{borderColor:ei},className:"py-6 border-b",children:(0,o.jsxs)("div",{className:" grid grid-cols-1 gap-x-6",children:[(0,o.jsx)(eM.default,{onClose:()=>{},isNavbar:!0,isArrow:!0,isCart:!0,onPromoApplied:e=>{rx.current&&(r_(!0),t9(null!==e),ts(!0),te(e),rd(e),setTimeout(()=>{rx.current&&r_(!1)},1e3))},discountapply:rO(em.discount),reedemableConditon:(null==ta?void 0:ta.multipleoffer_redeem)=="no",usePoints:e8,sessionId:ed},"promo-slider-".concat((null==eG?void 0:eG.branch_id)||"default","-").concat((null==eG?void 0:eG.order_type)||"pickup")),!t8||rm||rO(em.discount)||null!==(eo=null==eG?void 0:null===(V=eG.order_items)||void 0===V?void 0:V.is_delivery_discount)&&void 0!==eo&&eo?null:(0,o.jsxs)("div",{style:{color:tg},children:[" ",tJ("promo_error_message",{currency:eN,amount:null==rs?void 0:rs.oo_min_amount})," ",(null==rs?void 0:rs.offer_products)?(0,o.jsx)("span",{style:{cursor:"pointer",textDecoration:"underline",color:ei},onClick:()=>rv(!0),children:tJ("review_eligible_items")}):(0,o.jsx)("span",{children:tJ("review_eligible_items")})]})]})}),(0,o.jsxs)("div",{className:"mt-6 pb-6 border-b  \n             ",style:{borderColor:ei},children:[(0,o.jsx)("div",{className:"flex justify-between items-center cursor-pointer   py-3",onClick:()=>{rn(null)},children:(0,o.jsx)("span",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"text-[17px] leading-5 font-bold",children:tJ("i_have_coupon")})}),(0,o.jsxs)("div",{className:"  pb-3",children:[(0,o.jsxs)("div",{className:"flex flex-row gap-3 w-full",children:[" ",(0,o.jsx)("input",{type:"text",value:rr,onChange:e=>{ro(e.target.value.trim().toUpperCase()),rn(null)},placeholder:tJ("enter_coupon_code"),className:"w-full sm:flex-1 px-2 py-2.5 bg-[#F3F3F3]  rounded-md text-sm focus:outline-none ".concat(rl?"border border-".concat(tg):""),style:{fontFamily:"".concat(el,", sans-serif"),borderColor:rl?"#ef4444":"rgb(209 213 219)",textTransform:"uppercase"}}),(0,o.jsx)("button",{onClick:rD,disabled:ra,className:"px-6 py-1 rounded-full text-white font-medium whitespace-nowrap flex items-center justify-center min-w-[100px]",style:{color:ep,backgroundColor:ev,fontFamily:"".concat(el,", sans-serif"),opacity:ra?.7:1,height:tV?"36px":"40px",padding:tV?"0 12px":"0 16px",minWidth:tV?"80px":"
1100px"},children:ra?(0,o.jsx)(en.A,{text:tJ("processing")}):tJ("apply")})]}),rl&&(0,o.jsx)("div",{className:"mt-2 text-sm  ",style:{fontFamily:"".concat(el,", sans-serif"),fontSize:"clamp(12px,1.5vw,14px)",color:tg},children:rl})]})]}),tw&&"1"==rg&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},className:"font-black text-lg py-6",children:tJ("tip")}),(0,o.jsx)("div",{style:{borderColor:ei},className:"grid grid-cols-4 gap-x-3 border-b pb-8",children:null==re?void 0:null===(W=re.ecom_settings)||void 0===W?void 0:null===(U=W.tip_config)||void 0===U?void 0:U.options.map((e,t)=>{if(e.is_custom){let r=0==eV&&e.is_default;return eO?(0,o.jsxs)("div",{style:{fontFamily:"".concat(el,", sans-serif"),color:ei,border:"1px solid ".concat(ei),backgroundColor:es},className:"font-bold text-sm rounded-full p-2 my-auto text-center relative",children:[(0,o.jsx)(P.QCr,{onClick:rA,style:{color:tg},className:" absolute top-1 right-2 cursor-pointer"}),(0,o.jsx)("input",{ref:e2,type:"text",maxLength:3,autoFocus:!0,className:"w-full h-full border-none text-gray-400 opacity-75 outline-none bg-transparent text-center",onChange:eE,placeholder:tJ("other"),inputMode:"numeric"})]},"tip-".concat(t)):(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif"),border:r?ei:"1px solid #d3d3d3",backgroundColor:r?es:""},onClick:eD,className:"font-bold text-sm my-auto rounded-full p-2 text-center",children:tJ("other")},"tip-".concat(t))}return(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif"),border:eO||eV!=(null==e?void 0:e.value)?"1px solid #d3d3d3":"1px solid ".concat(ei),backgroundColor:eO||eV!=(null==e?void 0:e.value)?"":es},className:"font-bold text-sm rounded-full p-2 my-auto text-center",onClick:()=>{eA(e.value),eR(!1)},children:e.label},"tip-".concat(t))})})]}),(0,o.jsxs)("div",{className:"my-6 lg:pb-40",children:[0==em.total||0==Number(null==eG?void 0:eG.delivery_cost)?"":(0,o.jsx)(eQ,{subtotal:em.subtotal||0,charges:null==e_?void 0:e_.Charges_details,currencySymbol:eN,fontFamily:el,secondaryBtnColor:ev,secondaryBtnTxtColor:ei,secondaryColor:es,tax:em.tax||0,currentcharge:(null==eG?void 0:null===(H=eG.order_items)||void 0===H?void 0:H.is_delivery_discount)&&eu.length>0?e8&&0===Number(null==eG?void 0:eG.delivery_cost)?"".concat(eN,"0.00"):"".concat(eN).concat(Number(eG.actual_delivery_cost)-Number(null==eG?void 0:null===(G=eG.order_items)||void 0===G?void 0:G.delivery_discount)):(null==eG?void 0:eG.delivery_cost)&&eu.length>0?"".concat(eN).concat(eG.delivery_cost):"".concat(eN,"0.00")}),rO(em.discount)&&(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:tJ("discount")}),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:em.discount&&eu.length>0?"- ".concat(eN+(isNaN(em.discount)?0:em.discount)):eN+0})]}),e8?(0,o.jsxs)("div",{style:{color:ev,fontFamily:"".concat(el,", sans-serif")},className:"flex gap-x-2 justify-between",children:[(0,o.jsx)("div",{children:tJ("points")}),(0,o.jsxs)("div",{style:{fontFamily:"".concat(el,", sans-serif")},children:["- ",Math.round(ry)]})]}):null,(0,o.jsxs)("div",{className:"flex    justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:tJ("subtotal")}),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:em.subtotal&&eu.length>0?em.subtotal==em.total?"".concat(eN).concat((em.subtotal-em.tax).toFixed(2)):"".concat(eN).concat(em.subtotal):"".concat(eN,"0.0")})]}),(()=>{var e;let t=null==eG?void 0:null===(e=eG.order_items)||void 0===e?void 0:e.merged_tax_array,r=Array.isArray(t)?t.filter(e=>{var t;return null==e?void 0:null===(t=e.tax_label)||void 0===t?void 0:t.toLowerCase().includes("ieps")}):[],a=Array.isArray(t)?t.find(e=>{var t;return!(null==e?void 0:null===(t=e.tax_label)||void 0===t?void 0:t.toLowerCase().includes("ieps"))}):null;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:(null==e1?void 0:e1.country_prefix)=="MX"?tJ("vat"):tJ("tax")}),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:a?"".concat(eN).concat(Number(a.tax_amount).toFixed(2)):0!==rI&&rI?"".concat(eN).concat(rI):"".concat(eN,"0")})]}),r.map((e,t)=>(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:1==e.ieps_type?"".concat(e.tax_label," (").concat(e.tax_rate,"%)"):e.tax_label}),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:"".concat(eN).concat(Math.round(100*Number(e.tax_amount))/100)})]},"ieps-".concat(t)))]})})(),(null==eG?void 0:eG.order_type)==="delivery"&&(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:tJ("delivery_charge")}
1),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:(null==eG?void 0:null===(Y=eG.order_items)||void 0===Y?void 0:Y.is_delivery_discount)&&eu.length>0?e8&&0===Number(null==eG?void 0:eG.delivery_cost)?"".concat(eN,"0.00"):"".concat(eN).concat(Number(eG.actual_delivery_cost)-Number(null==eG?void 0:null===(K=eG.order_items)||void 0===K?void 0:K.delivery_discount)):(null==eG?void 0:eG.delivery_cost)&&eu.length>0?"".concat(eN).concat(eG.delivery_cost):"".concat(eN,"0.00")})]}),(null==eG?void 0:eG.order_type)==="delivery"&&(null==eG?void 0:null===(X=eG.order_items)||void 0===X?void 0:X.is_delivery_discount)&&!(e8&&0===Number(null==eG?void 0:eG.delivery_cost))&&(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:tJ("delivery_discount")}),(0,o.jsx)("div",{style:{color:tg,fontFamily:"".concat(el,", sans-serif")},children:(null==eG?void 0:null===(Z=eG.order_items)||void 0===Z?void 0:Z.delivery_discount)&&eu.length>0?"- ".concat(eN).concat(null==eG?void 0:null===($=eG.order_items)||void 0===$?void 0:$.delivery_discount):"".concat(eN,"0.00")})]}),tD&&"1"==rg&&(null==re?void 0:null===(er=re.ecom_settings)||void 0===er?void 0:null===(ee=er.tip_config)||void 0===ee?void 0:null===(Q=ee.payment_methods)||void 0===Q?void 0:Q.includes(tD.payment_method_id))&&(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:tJ("tip")}),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:em.tip&&eu.length>0?"".concat(eN).concat(Number(em.tip).toFixed(2)):"".concat(eN,"0.00")})]}),tD&&1===tD.payment_method_id&&(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:tJ("service_amount")}),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:em.service&&eu.length>0?"".concat(eN).concat(Number(em.service).toFixed(2)):"".concat(eN,"0.00")})]}),(0,o.jsx)("div",{style:{color:tg,fontFamily:"".concat(el,", sans-serif")},className:"text-md",children:tE&&tF?(0,o.jsxs)("p",{children:[tJ("The minimum order amount for delivery is"),": ",eN,tF]}):null}),(0,o.jsxs)("div",{className:"font-black pt-4 flex justify-between",children:[(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:tJ("total")}),(0,o.jsx)("div",{style:{color:ei,fontFamily:"".concat(el,", sans-serif")},children:em.total&&eu.length>0?"".concat(eN).concat(Number(em.total).toFixed(2)):"".concat(eN,"0.00")})]})]})]}),eh&&(0,o.jsx)("div",{className:"pb-6",children:(0,o.jsx)("div",{style:{color:ep,backgroundColor:ev,fontFamily:"".concat(el,", sans-serif")},className:"flex justify-center mx-auto bottom-3 items-center w-[163px] text-[13px] leading-4 font-black py-4 rounded-full ".concat(tE?"o
1pacity-50 cursor-not-allowed":"cursor-pointer"),onClick:()=>{tE||ek()},children:tJ("pay")})})]})]})};var e2=r(18987),e5=r(14953),e4=r.n(e5),e3=r(74353),e7=r.n(e3),e6=r(8906),e8=r.n(e6),e9=r(98867),te=r.n(e9),tt=r(88569),tr=r.n(tt),to=r(83826),ta=r.n(to),ti=r(18256),tl=r(8083);let tn=()=>(0,o.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,o.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),(0,o.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),ts=e=>{let{size:t=18}=e;return(0,o.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("line",{x1:"7",y1:"17",x2:"17",y2:"7"}),(0,o.jsx)("polyline",{points:"9 7 17 7 17 15"})]})},td=e=>{let{size:t=11}=e;return(0,o.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})},tc=e=>{let{size:t=22}=e;return(0,o.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,o.jsx)("circle",{cx:"12",cy:"12",r:"12",fill:"currentColor"}),(0,o.jsx)("polyline",{points:"7 12.5 10.5 16 17 9",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})]})},tu=e=>{let{size:t=16}=e;return(0,o.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("path",{d:"M20.59 13.41 13.42 20.58a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82Z"}),(0,o.jsx)("circle",{cx:"7",cy:"7",r:"1.4",fill:"currentColor",stroke:"none"})]})},tm=e=>{let{size:t=16}=e;return(0,o.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("line",{x1:"4",y1:"12",x2:"19",y2:"12"}),(0,o.jsx)("polyline",{points:"13 6 19 12 13 18"})]})},t_=(e,t)=>/^#[0-9a-fA-F]{6}$/.test(e||"")?"".concat(e).concat(t):e,tp="#16A34A",tv="#F0FDF4",tg="#BBF7D0",tf=e=>{let{show:t,close:r,rules:a,fontFamily:i,primaryColor:l,secondaryBtnColor:n,secondaryBtnTxtColor:s,currency:d="$",onAddItem:c,onUpgrade:m,onAddCombo:_,handlePopupClick:v}=e,{t:g}=(0,p.Bd)(),{currentLang:f,botLanguage:h}=(0,eG.ok)(),[x,b]=u.useState({});if(!t||!Array.isArray(a)||0===a.length)return null;let w="".concat(i,", sans-serif"),N=e=>"".concat(d).concat(Math.abs(Number(e)||0).toFixed(2)),j=a.flatMap(e=>{var t,r,o;let a=null==e?void 0:e.trigger_condition,i="".concat(null!==(t=null==a?void 0:a.type)&&void 0!==t?t:"any",":").concat(null!==(o=null!==(r=null==a?void 0:a.product_id)&&void 0!==r?r:null==a?void 0:a.category_id)&&void 0!==o?o:"all"),l=[];return(e.upgrades&&e.upgrades.length>0?e.upgrades:e.upgrade?[e.upgrade]:[]).forEach((t,r)=>{var o,a,n,s;let d="modifier"===t.type?"".concat(t.product_id,":").concat(t.to_modifier_id):"".concat(null!==(n=null===(o=t.cart_line)||void 0===o?void 0:o.item_id)&&void 0!==n?n:r,":").concat(null!==(s=null===(a=t.to_item)||void 0===a?void 0:a.item_id)&&void 0!==s?s:r);l.push({key:"".concat(i,":upgrade:").concat(d),kind:"upgrade",rule:e,upgrade:t})}),e.combo&&l.push({key:"".concat(i,":combo"),kind:"combo",rule:e}),e.products.length>0&&l.push({key:"".concat(i,":products"),kind:"products",rule:e}),l}).filter(e=>!x[e.key]),k=e=>{if(j.length<=1){r();return}b(t=>({...t,[e]:!0}))},S=e=>(0,eY.HS)(e.item_name,e.item_display_text_v1,f,h),C=e=>(0,eY.HS)(e.item_description,e.item_description_v1,f,h),I=e=>(0,eY.EY)(e,f,h),F=e=>(0,eY.jO)(e,f,h),E=e=>(0,eY.HS)((null==e?void 0:e.item_display_text)||(null==e?void 0:e.item_name),null==e?void 0:e.item_display_text_v1,f,h),A=e=>{let{src:t,alt:r}=e;return(0,o.jsx)("div",{className:"relative w-[52px] h-[52px] shrink-0 rounded-md overflow-hidden bg-gray-100",children:t?(0,o.jsx)(y(),{src:t,alt:r,layout:"fill",objectFit:"cover"}):(0,o.jsx)("div",{className:"h-full w-full flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-gray-400 text-[9px] text-center px-1",children:g("no_image")})})})},D=e=>{let{variant:t}=e;return(0,o.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,o.jsx)("div",{className:"flex items-center justify-center rounded-full shrink-0",style:{backgroundColor:t_(n,"1A"),color:n,width:42,he
1ight:42},children:"upgrade"===t?(0,o.jsx)(ts,{size:20}):(0,o.jsx)(tn,{})}),(0,o.jsxs)("div",{className:"min-w-0 flex-grow",children:[(0,o.jsx)("h3",{className:"font-extrabold leading-tight",style:{fontFamily:w,color:l,fontSize:"17px"},children:g("upsell_".concat(t,"_title"))}),(0,o.jsx)("p",{className:"text-gray-500 leading-snug mt-0.5",style:{fontFamily:w,fontSize:"12px"},children:g("upsell_".concat(t,"_subtitle"))})]}),(0,o.jsxs)("span",{className:"flex items-center gap-1 rounded-full px-2.5 py-1 font-bold shrink-0 border",style:"products"===t?{backgroundColor:t_(n,"14"),borderColor:t_(n,"40"),color:n,fontFamily:w,fontSize:"11px"}:{backgroundColor:"#FFFBEB",borderColor:"#FDE68A",color:"#B45309",fontFamily:w,fontSize:"11px"},children:[(0,o.jsx)(td,{}),"products"===t?g("upsell_recommended_badge"):g("upsell_".concat(t,"_badge"))]})]})},O=e=>{let{icon:t,label:r,onClick:a}=e;return(0,o.jsxs)("button",{type:"button",className:"w-full rounded-xl py-3 mt-3 font-extrabold flex items-center justify-center gap-2.5",style:{backgroundColor:n,color:s,fontFamily:w,fontSize:"15px"},onClick:a,children:[(0,o.jsx)("span",{className:"flex items-center justify-center rounded-lg shrink-0",style:{backgroundColor:"rgba(255,255,255,0.22)",width:30,height:30},"aria-hidden":"true",children:t}),r]})},M=e=>{let{label:t,labelNode:r,image:a,name:i,price:s,originalPrice:d,highlighted:c}=e;return(0,o.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,o.jsx)("div",{className:"mb-1 h-4 flex items-center",children:null!=r?r:(0,o.jsx)("span",{className:"uppercase tracking-wide font-bold text-gray-400 truncate",style:{fontFamily:w,fontSize:"10px"},children:t})}),(0,o.jsxs)("div",{className:"relative rounded-xl border p-2.5 sm:p-3 flex-grow",style:c?{backgroundColor:tv,borderColor:tg}:{backgroundColor:"#F9FAFB",borderColor:"#E5E7EB"},children:[c&&(0,o.jsx)("span",{className:"absolute -top-2 -right-2",style:{color:tp},"aria-hidden":"true",children:(0,o.jsx)(tc,{})}),(0,o.jsx)("div",{className:"relative w-full h-[86px] sm:h-[140px] rounded-lg overflow-hidden bg-white",children:a?(0,o.jsx)(y(),{src:a,alt:i,layout:"fill",objectFit:"cover"}):(0,o.jsx)("div",{className:"h-full w-full flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-gray-400 text-[10px]",children:g("no_image")})})}),(0,o.jsx)("p",{className:"font-bold mt-2 line-clamp-2",style:{fontFamily:w,color:l,fontSize:"14px"},children:i}),(0,o.jsxs)("div",{className:"flex items-baseline gap-1.5 mt-0.5 flex-wrap",children:[void 0!==d&&d>s&&(0,o.jsx)("span",{className:"line-through text-gray-400",style:{fontFamily:w,fontSize:"11px"},children:N(d)}),(0,o.jsx)("span",{className:"font-extrabold",style:{fontFamily:w,color:n,fontSize:"16px"},children:N(s)})]})]})]})},P=e=>{var t,r,a,i,s,d,c,u,_,p,v;let{rule:f,upgrade:y,sectionKey:h}=e,x=y.delta,b=x<0,j="modifier"===y.type,C=j?{image:null===(t=y.product_item)||void 0===t?void 0:t.item_image,name:I(null!==(_=y.current_modifier)&&void 0!==_?_:y.from_modifier),price:Number(null!==(p=null===(r=y.current_modifier)||void 0===r?void 0:r.modifier_item_price)&&void 0!==p?p:null===(a=y.from_modifier)||void 0===a?void 0:a.price)||0}:{image:null===(i=y.cart_line)||void 0===i?void 0:i.item_image,name:E(y.cart_line),price:null!==(v=null===(s=y.cart_line)||void 0===s?void 0:s.price)&&void 0!==v?v:0},A=j?{image:null===(d=y.product_item)||void 0===d?void 0:d.item_image,name:I(y.to_modifier),price:Number(null===(c=y.to_modifier)||void 0===c?void 0:c.price)||0,original:Number(null===(u=y.to_modifier)||void 0===u?void 0:u.original_price)||0}:{image:y.to_item.item_image,name:S(y.to_item),price:(0,tl._X)(y.to_item),original:(0,tl.LO)(y.to_item)},P=j?[S(y.product_item),F(y.modifier_category)].filter(Boolean).join(" \xb7 "):"";return(0,o.jsxs)("div",{className:"rounded-2xl border border-gray-200 p-4 sm:p-5 mb-3",children:[(0,o.jsx)(D,{variant:"upgrade"}),P&&(0,o.jsx)("p",{className:"pb-2.5 mb-3 border-b border-gray-200 line-clamp-2",style:{fontFamily:w,color:l,fontSize:"15px",fontWeight:800},children:P}),(0,o.jsxs)("div",{className:"flex items-stretch gap-1",children:[(0,o.jsx)(M,{label:g("upsell_upgrade_current"),image:C.image,name:C.name,price:C.price}),(0,o.jsx)("div",{className:"flex items-center shrink-0 pt-4",children:(0,o.jsx)("span",{className:"flex items-center justify-center rounded-full bg-white border border-gray-200",style:{color:n,width:30,height:30},"aria-hidden":"true",children:(0,o.jsx)(tm,{})})}),(0,o.jsx)(M,{labelNode:(0,o.jsxs)("span",{className:"flex items-center gap-1 uppercase tracking-wide font-bold truncate",style:{fontFamily:w,color:tp,fontSize:"10px"},children:[(0,o.jsx)(td,{size:10}),g("upsell_upgrade_recommended")]}
1),image:A.image,name:A.name,price:A.price,originalPrice:A.original,highlighted:!0})]}),0!==x&&(0,o.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl px-3 py-2.5 mt-3",style:b?{backgroundColor:tv,border:"1.5px dashed "+tg}:{backgroundColor:"#FFFBEB",border:"1.5px dashed #FCD34D"},children:[(0,o.jsx)("span",{className:"flex items-center justify-center rounded-full shrink-0",style:{backgroundColor:b?"#D1FAE5":"#FDE68A",color:b?"#047857":"#B45309",width:28,height:28},"aria-hidden":"true",children:(0,o.jsx)(tu,{})}),(0,o.jsx)("span",{style:{fontFamily:w,color:b?"#047857":"#B45309",fontSize:"12px"},children:b?g("upsell_upgrade_you_save"):g("upsell_upgrade_only")}),(0,o.jsx)("span",{className:"font-extrabold leading-none",style:{fontFamily:w,color:b?"#047857":"#B45309",fontSize:"22px"},children:"".concat(b?"−":"+").concat(N(x))}),!b&&(0,o.jsx)("span",{style:{fontFamily:w,color:"#B45309",fontSize:"12px"},children:g("upsell_upgrade_extra")})]}),(0,o.jsx)(O,{icon:(0,o.jsx)(ts,{size:16}),label:x>0?g("upsell_upgrade_cta",{amount:N(x)}):x<0?g("upsell_upgrade_cta_save",{amount:N(x)}):g("upsell_upgrade_cta_plain"),onClick:()=>m(y,f)}),(0,o.jsx)("div",{className:"text-center mt-2.5",children:(0,o.jsx)("button",{type:"button",className:"underline",style:{fontFamily:w,color:l,fontSize:"13px"},onClick:()=>k(h),children:g("upsell_no_thanks_cta")})})]})},T=e=>{var t,r;let{rule:a,sectionKey:i}=e,s=a.combo,d=a.trigger_line,c=(null===(t=s.discount)||void 0===t?void 0:t.type)==="percentage"&&(null===(r=s.discount)||void 0===r?void 0:r.value)?Number(s.discount.value):null;return(0,o.jsxs)("div",{className:"rounded-2xl border border-gray-200 p-4 sm:p-5 mb-3",children:[(0,o.jsx)(D,{variant:"combo"}),(0,o.jsxs)("div",{className:"flex items-stretch gap-2",children:[d&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,o.jsx)("p",{className:"mb-1 text-gray-500 truncate",style:{fontFamily:w,fontSize:"10px"},children:g("upsell_combo_current")}),(0,o.jsxs)("div",{className:"rounded-lg border border-gray-200 p-2 flex-grow",children:[(0,o.jsx)(A,{src:d.item_image,alt:d.item_name||""}),(0,o.jsx)("p",{className:"font-bold mt-1.5 line-clamp-2",style:{fontFamily:w,color:l,fontSize:"12px"},children:E(d)}),(0,o.jsx)("p",{className:"font-extrabold mt-0.5",style:{fontFamily:w,color:n,fontSize:"13px"},children:N(d.price)})]})]}),(0,o.jsx)("div",{className:"flex items-center justify-center shrink-0 font-bold",style:{color:n,fontSize:"20px"},"aria-hidden":"true",children:"+"})]}),(0,o.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,o.jsxs)("p",{className:"mb-1 truncate",style:{fontFamily:w,fontSize:"10px"},children:[(0,o.jsx)("span",{className:"text-gray-500",children:g("upsell_combo_add")})," ",(0,o.jsx)("span",{className:"font-bold",style:{color:n},children:g("upsell_upgrade_recommended")})]}),(0,o.jsxs)("div",{className:"rounded-lg border border-gray-200 p-2 flex-grow",children:[s.items.map((e,t)=>(0,o.jsxs)("div",{className:t>0?"mt-2":"",children:[(0,o.jsx)(A,{src:e.item_image,alt:e.item_name}),(0,o.jsx)("p",{className:"font-bold mt-1.5 line-clamp-2",style:{fontFamily:w,color:l,fontSize:"12px"},children:S(e)})]},"".concat(e.item_id,"-").concat(t))),(0,o.jsxs)("div",{className:"flex items-baseline gap-1.5 mt-0.5 flex-wrap",children:[s.saving>0&&(0,o.jsx)("span",{className:"line-through text-gray-400",style:{fontFamily:w,fontSize:"11px"},children:N(s.original_total)}),(0,o.jsx)("span",{className:"font-extrabold",style:{fontFamily:w,color:n,fontSize:"13px"},children:N(s.total)})]})]})]})]}),s.saving>0&&(0,o.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl px-3 py-2.5 mt-3",style:{backgroundColor:tv,border:"1.5px dashed "+tg},children:[(0,o.jsx)("span",{className:"flex items-center justify-center rounded-full shrink-0",style:{backgroundColor:"#D1FAE5",color:"#047857",width:28,height:28},"aria-hidden":"true",children:(0,o.jsx)(tu,{})}),(0,o.jsx)("span",{style:{fontFamily:w,color:"#047857",fontSize:"12px"},children:c?g("upsell_combo_percent_off",{percent:c}
1):g("upsell_upgrade_you_save")}),(0,o.jsx)("span",{className:"font-extrabold leading-none",style:{fontFamily:w,color:"#047857",fontSize:"22px"},children:"−".concat(N(s.saving))})]}),(0,o.jsx)(O,{icon:(0,o.jsx)(tn,{}),label:g("upsell_combo_cta",{amount:N(s.total)}),onClick:()=>_(s,a)}),(0,o.jsx)("div",{className:"text-center mt-2.5",children:(0,o.jsx)("button",{type:"button",className:"underline",style:{fontFamily:w,color:l,fontSize:"13px"},onClick:()=>k(i),children:g("upsell_no_thanks_cta")})})]})},L=e=>{let{rule:t,sectionKey:r}=e,a=t.products.length>1;return(0,o.jsxs)("div",{className:"rounded-2xl border border-gray-200 p-4 sm:p-5 mb-3",children:[(0,o.jsx)(D,{variant:"products"}),(0,o.jsx)("div",{className:"grid gap-2 sm:gap-3 ".concat(a?t.products.length>2?"grid-cols-2 sm:grid-cols-3":"grid-cols-2":"grid-cols-1"),children:t.products.map((e,r)=>(0,o.jsxs)("div",{className:"rounded-xl border border-gray-200 overflow-hidden flex flex-col",children:[(0,o.jsx)("div",{className:"relative w-full bg-gray-100 shrink-0 ".concat(a?"h-[84px] sm:h-[130px]":"h-[110px] sm:h-[190px]"),children:e.item_image?(0,o.jsx)(y(),{src:e.item_image,alt:e.item_name,layout:"fill",objectFit:"cover"}):(0,o.jsx)("div",{className:"h-full w-full flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-gray-500 text-[10px]",children:g("no_image")})})}),(0,o.jsxs)("div",{className:"p-2 sm:p-3 flex flex-col flex-grow",children:[(0,o.jsx)("h4",{className:"font-bold line-clamp-1",style:{fontFamily:w,color:l,fontSize:"12px"},children:S(e)}),C(e)&&(0,o.jsx)("p",{className:a?"text-gray-500 line-clamp-1":"text-gray-500 line-clamp-2",style:{fontFamily:w,fontSize:"10px"},children:C(e)}),(0,o.jsxs)("div",{className:"flex items-baseline gap-1.5 mt-1 flex-wrap",children:[(0,tl.FA)(e)&&(0,o.jsx)("span",{className:"line-through text-gray-400",style:{fontFamily:w,fontSize:"10px"},children:N((0,tl.LO)(e))}),(0,o.jsx)("span",{className:"font-extrabold",style:{fontFamily:w,color:n,fontSize:"14px"},children:N((0,tl._X)(e))})]}),(0,o.jsx)("div",{className:"mt-auto pt-2",children:(0,o.jsx)("button",{type:"button",className:"w-full rounded-lg py-2 text-white font-bold",style:{backgroundColor:n,fontFamily:w,fontSize:"12px"},onClick:()=>c(e,t),children:"+ ".concat(g("upsell_add_cta_short"))})})]})]},"".concat(e.item_id,"-").concat(r)))}),(0,o.jsx)("div",{className:"text-center mt-2.5",children:(0,o.jsx)("button",{type:"button",className:"underline",style:{fontFamily:w,color:l,fontSize:"13px"},onClick:()=>k(r),children:g("upsell_no_thanks_cta")})})]})};return(0,o.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-70 px-4",style:{backgroundColor:"".concat(n,"20")},onClick:r,children:(0,o.jsxs)("div",{className:"bg-white rounded-[20px] shadow-lg w-full max-w-[420px] sm:max-w-[620px] max-h-[85vh] sm:max-h-[88vh] relative overflow-hidden flex flex-col",onClick:v,children:[(0,o.jsx)("button",{className:"absolute top-4 right-4 text-xl font-bold z-10",style:{color:l},onClick:r,"aria-label":g("upsell_dismiss_cta"),children:"\xd7"}),(0,o.jsxs)("div",{className:"p-5 sm:p-6 overflow-y-auto flex-grow",children:[(0,o.jsx)("h2",{className:"mb-1 mt-2 pr-6",style:{fontFamily:w,fontWeight:900,color:l,fontSize:"18px"},children:g("upsell_title")}),(0,o.jsx)("p",{className:"mb-4",style:{fontFamily:w,fontWeight:325,color:"#6B7280",fontSize:"13px"},children:g("upsell_subtitle")}),j.map(e=>{let{key:t,kind:r,rule:a,upgrade:i}=e;return"upgrade"===r?(0,o.jsx)(P,{rule:a,upgrade:i,sectionKey:t},t):"combo"===r?(0,o.jsx)(T,{rule:a,sectionKey:t},t):(0,o.jsx)(L,{rule:a,sectionKey:t},t)})]}),(0,o.jsx)("div",{className:"border-t border-gray-200 py-3 text-center",children:(0,o.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1",style:{fontFamily:w,color:l,fontSize:"13px"},onClick:r,children:[g("upsell_dismiss_cta"),(0,o.jsx)("span",{"aria-hidden":"true",children:"›"})]})})]})})};var ty=r(38567),th=r(40694),tx=r(13765),tb=r(95920),tw=r(76094);function tN(e){let{className:t,...r}=e;return(0,o.jsx)(tb.b,{"data-slot":"label",className:(0,tw.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...r})}var tj=r(92731),tk=r(20005);function tS(e){let{className:t,...r}=e;return(0,o.jsx)(tj.bL,{"data-slot":"checkbox",className:(0,tw.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:(0,o.jsx)(tj.C1,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:(0,o.jsx)(tk.A,{className:"size-3.5"})})})}var tC=r(17169);let tI=e=>new Promise((t,r)=>{if(window.MercadoPago){t();return}(0,tC.Lz)(e);let o=document.createElement("script");o.src="https://sdk.mercadopago.com/js/v2",o.async=!0,o.onload=()=>t(),o.onerror=()=>r(Error("Failed to load MercadoPago SDK")),document.body.appendChild(o)}),tF=async(e,t,r)=>{let o;if(!window.MercadoPago)throw Error("MercadoPago SDK not loaded");let a=new window.MercadoPago(t),i={cardNumber:e.cardNumber.replace(/\s/g,""),cardholderName:e.cardholderName,cardExpirationMonth:e.cardExpirationMonth,cardExpirationYear:e.cardExpirationYear,securityCode:e.securityCode,cardholder:{email:e.email}};try{o=await a.createCardToken(i)}catch(t){throw(0,eb.f)({target_path:"ecom/v1/",file_name:"mercado_error_logs",data:{error_message:(null==t?void 0:t.message)||"createCardToken SDK threw an error",error_source:"createCardToken – SDK exception",error_stack:(null==t?void 0:t.stack)||JSON.stringify(t)||"No stack trace",restaurant_id:(null==r?void 0:r.restaurant_id)||"",phone_number:(null==r?void 0:r.phone_number)||"",request:{cardholderName:i.cardholderName,cardExpirationMonth:i.cardExpirationMonth,cardExpirationYear:i.cardExpirationYear,email:e.email},response:null,url:window.location.href,userAgent:"undefined"!=typeof navigator?navigator.userAgent:"",error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()}),t}if(!o||!o.id)throw(0,eb.f)({target_path:"ecom/v1/",file_name:"mercado_error_logs",data:{error_message:"createCardToken returned no token id",error_source:"createCardToken – empty response",error_stack:"No stack trace",restaurant_id:(null==r?void 0:r.restaurant_id)||"",phone_number:(null==r?void 0:r.phone_number)||"",request:{cardholderName:i.cardholderName,cardExpirationMonth:i.cardExpirationMonth,cardExpirationYear:i.cardExpirationYear,email:e.email},response:o,url:window.location.href,userAgent:"undefined"!=typeof navigator?navigator.userAgent:"",error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()}),Error("MercadoPago createCardToken returned no token");return o.id},tE=async(e,t)=>{var r;if(!window.MercadoPago)throw Error("MercadoPago SDK not loaded");let o=new window.MercadoPago(t),a=e.replace(/\s/g,"").substring(0,6),i=await o.getPaymentMethods({bin:a});if(!(null==i?void 0:null===(r=i.results)||void 0===r?void 0:r.length))throw Error("Unable to detect card brand");return i.results[0]};var tA=r(72635);function tD(e){let{isOpen:t,onClose:r,setIsOpen:a,alias:i,secondaryBtnColor:l,secondaryBtnTxtColor:n,resetdata:s,sdkready:d,publickey:c,email:m,restaurant_id:_,phone_number:p}=e,[v,g]=(0,u.useState)({cardNumber:"",expiration:"",securityCode:"",cardholderName:"",email:m,saveCard:!1}),[f,y]=(0,u.useState)(null),[h,x]=(0,u.useState)(!1);(0,u.useEffect)(()=>{tI(c).catch(e=>y(e.message))},[c]);let b=(e,t)=>{if("expiration"===e&&"string"==typeof t&&(t=t.replace(/\D/g,"")).length>=2&&(t=t.slice(0,2)+"/"+t.slice(2,4)),"cardNumber"===e&&"string"==typeof t){var r;t=(null===(r=(t=t.replace(/\D/g,"")).match(/.{1,4}/g))||void 0===r?void 0:r.join(" "))||""}g(r=>({...r,[e]:t}))},w=async e=>{e.preventDefault(),y(null),x(!0);try{let e=await tF({cardNumber:v.cardNumber,cardholderName:v.cardholderName,cardExpirationMonth:v.expiration.split("/")[0],cardExpirationYear:"20"+v.expiration.split("/")[1],securityCode:v.securityCode,email:v.email}
1,c,{restaurant_id:_,phone_number:p}),t=await tE(v.cardNumber,c);console.log({token:e,cardInfo:t}),localStorage.setItem("mercadoPagoPaymentInfo_".concat(i),JSON.stringify({token:e,brand:t.id,type:t.payment_type_id,cardholderName:v.cardholderName,email:v.email,lastFourDigits:v.cardNumber.slice(-4),saveCard:v.saveCard,timestamp:new Date().toISOString(),cardNumber:v.cardNumber})),r()}catch(e){y(e.message||(0,tA.t)("Failed to process payment"))}finally{x(!1)}};return t?(0,o.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black bg-opacity-50",onClick:e=>{e.target===e.currentTarget&&(r(),s())},children:(0,o.jsxs)("div",{className:"w-full max-w-md bg-white rounded-lg shadow-lg relative",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{r(),s()},className:"absolute top-3 right-3 w-8 h-8 flex items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 text-gray-700",children:(0,o.jsx)("span",{className:"text-lg font-bold",children:"\xd7"})}),(0,o.jsx)("div",{className:"p-6 max-h-[90vh] overflow-y-auto",children:(0,o.jsxs)("form",{onSubmit:w,className:"space-y-6",children:[(0,o.jsx)("div",{className:"text-center",children:(0,o.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Mercado Pago"})}),(0,o.jsxs)("div",{className:"flex gap-2",children:[(0,o.jsx)("div",{className:"w-12 h-8 bg-blue-600 rounded flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-white text-xs font-bold",children:"VISA"})}),(0,o.jsx)("div",{className:"w-12 h-8 bg-gradient-to-r from-red-500 to-orange-400 rounded flex items-center justify-center",children:(0,o.jsxs)("div",{className:"flex",children:[(0,o.jsx)("div",{className:"w-3 h-3 bg-red-500 rounded-full"}),(0,o.jsx)("div",{className:"w-3 h-3 bg-orange-400 rounded-full -ml-1"})]})}),(0,o.jsx)("div",{className:"w-12 h-8 bg-blue-500 rounded flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-white text-xs font-bold",children:"AE"})})]}),(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)(tN,{htmlFor:"cardNumber",className:"text-sm font-medium text-gray-700",children:(0,tA.t)("Card number")}),(0,o.jsx)(tx.p,{id:"cardNumber",type:"text",placeholder:"1234 1234 1234 1234",value:v.cardNumber,onChange:e=>b("cardNumber",e.target.value),className:"h-12",required:!0})]}),(0,o.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)(tN,{htmlFor:"expiration",className:"text-sm font-medium text-gray-700",children:(0,tA.t)("Expiration")}),(0,o.jsx)(tx.p,{id:"expiration",type:"text",placeholder:"MM/YY",value:v.expiration,onChange:e=>b("expiration",e.target.value),className:"h-12",required:!0})]}),(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)(tN,{htmlFor:"securityCode",className:"text-sm font-medium text-gray-700",children:(0,tA.t)("CVV")}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(tx.p,{id:"securityCode",type:"text",placeholder:"123",value:v.securityCode,onChange:e=>b("securityCode",e.target.value),className:"h-12 pr-10",required:!0}),(0,o.jsx)(eT.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]})]}),(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)(tN,{htmlFor:"cardholderName",className:"text-sm font-medium text-gray-700",children:(0,tA.t)("Cardholder name")}),(0,o.jsx)(tx.p,{id:"cardholderName",type:"text",placeholder:"John Doe",value:v.cardholderName,onChange:e=>b("cardholderName",e.target.value),className:"h-12",required:!0})]}),(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)(tN,{htmlFor:"email",className:"text-sm font-medium text-gray-700",children:(0,tA.t)("Email")}),(0,o.jsx)(tx.p,{id:"email",type:"email",placeholder:"[email protected]",value:v.email,onChange:e=>b("email",e.target.value),className:"h-12",required:!0})]}),(0,o.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,o.jsx)(tS,{id:"saveCard",checked:v.saveCard,onCheckedChange:e=>b("saveCard",e)}
1),(0,o.jsx)(tN,{htmlFor:"saveCard",className:"text-sm font-medium text-gray-700",children:(0,tA.t)("Save card for future purchases")})]}),f&&(0,o.jsx)("div",{className:"text-red-600 text-sm",children:f}),(0,o.jsx)(eE.$,{type:"submit",className:"w-full h-12",style:{backgroundColor:l,color:n},disabled:!d,children:h?(0,o.jsxs)("svg",{className:"animate-spin h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,o.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,o.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}):(0,tA.t)("Submit Payment")})]})]})})]})}):null}async function tO(e,t){try{let r=(0,ec.z)(),o="https://order.foodbot.ai/apiv2";t&&(o="".concat(t.replace(/\/$/,""),"/apiv2"));let a=await fetch("".concat(o,"/ecom/v1/pg/mercadopago/v1/make-payment"),{method:"POST",headers:r,body:JSON.stringify(e)});return await a.json()}catch(e){throw console.error("Error in makeMercadoPagoPayment:",e),e}}async function tM(e,t){try{let r=(0,ec.z)(),o="https://order.foodbot.ai/apiv2";t&&(o="".concat(t.replace(/\/$/,""),"/apiv2"));let a=await fetch("".concat(o,"/ecom/v1/pg/mercadopago/v1/get-cards-list"),{method:"POST",headers:r,body:JSON.stringify(e)});return await a.json()}catch(e){throw console.error("Error in getMercadoPagoCardsList:",e),e}}async function tP(e,t){try{let r=(0,ec.z)(),o="https://order.foodbot.ai/apiv2";t&&(o="".concat(t.replace(/\/$/,""),"/apiv2"));let a=await fetch("".concat(o,"/ecom/v1/pg/mercadopago/v1/confirm-transaction"),{method:"POST",headers:r,body:JSON.stringify(e)});return await a.json()}catch(e){throw console.error("Error in confirmMercadoPagoTransaction:",e),e}}async function tT(e,t,r){try{let o=(0,ec.z)(),a="https://order.foodbot.ai/apiv2";t&&(a="".concat(t.replace(/\/$/,""),"/apiv2"));let i=await fetch("".concat(a,"/ecom/v1/pg/mercadopago/v1/create-token"),{method:"POST",headers:o,body:JSON.stringify(e)}),l=await i.json();if(i.ok&&(null==l?void 0:l.status)==="success"&&(null==l?void 0:l.token))return console.log("✅ MercadoPago Token Created:",l.token),l.token;throw console.error("❌ Failed to create token:",l),(0,eb.f)({target_path:"ecom/v1/",file_name:"mercado_error_logs",data:{error_message:(null==l?void 0:l.message)||"Failed to create token from saved card",error_source:"createTokenFromSavedCard – API failure",error_stack:"No stack trace",restaurant_id:(null==e?void 0:e.restaurant_id)||"",phone_number:(null==r?void 0:r.phone_number)||"",request:{card_id:null==e?void 0:e.card_id,payment_gateway_id:null==e?void 0:e.payment_gateway_id,st_id:null==e?void 0:e.st_id},response:l,url:window.location.href,userAgent:"undefined"!=typeof navigator?navigator.userAgent:"",error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()}),Error((null==l?void 0:l.message)||"Failed to create token")}catch(e){throw console.error("Error in createTokenFromSavedCard:",e),e}}let tL=async e=>{let t="https://order.foodbot.ai/apiv2";t="".concat(window.location.origin,"/apiv2");let r={method:"POST",headers:(0,ec.z)(),body:JSON.stringify(e),redirect:"follow"};try{let e=await fetch("".concat(t,"/ecom/v1/pg/billpocket/v1/remove-subscription"),r),o=await e.json();return e.ok||console.error(o.message||"Failed to remove subscription"),o}catch(e){return console.error("Billpocket Remove Subscription Error:",e),{status:"error",status_code:0,message:e instanceof Error?e.message:"Unknown error"}}},tq=async e=>{let t="https://order.foodbot.ai/apiv2";t="".concat(window.location.origin,"/apiv2");let r={method:"POST",headers:(0,ec.z)(),body:JSON.stringify(e),redirect:"follow"};try{let e=await fetch("".concat(t,"/ecom/v1/pg/billpocket/v1/get-cards-list"),r),o=await e.json();return e.ok||console.error(o.message||"Failed to get cards list"),o}catch(e){return console.error("Billpocket Cards List Error:",e),{status:"error",status_code:0,message:e instanceof Error?e.message:"Unknown error",data:[],pg_customer_id:""}}},tR=async e=>{let t="https://order.foodbot.ai/apiv2";t="".concat(window.location.origin,"/apiv2");let r=JSON.stringify(e),o=U.nodeRsaEncryption(r),a=U.createSignature(r),i=(0,ec.z)();i.append("x-foodbot-signature",a);let l={method:"POST",headers:i,body:JSON.stringify({payload:o}),redirect:"follow"};try{let e=await fetch("".concat(t,"/ecom/v1/pg/billpocket/v1/make-payment"),l),r=await e.json();return e.ok||console.error(r.message||"Failed to make payment"),r}catch(e){return console.error("Billpocket Payment Error:",e),{status:"error",status_code:0,message:e instanceof Error?e.message:"Unknown error"}}};var tB=r(9389),tz=r(40961);let tJ=e=>{let t=(0,ec.z)(),{file_name:r,...o}=e,a=JSON.stringify({target_path:"ecom/v1/",file_name:r||"kushki_error_logs",data:{...o,timestamp:new Date().toISOString(),page:window.location.href}}),i="".concat(window.location.origin,"/"),l="https://order.foodbot.ai/apiv2";i&&(l="".concat(i,"apiv2")),fetch("".concat(l,"/write-logs"),{method:"POST",headers:t,body:a,redirect:"follow"}).then(e=>e.json()).then(e=>{"success"===e.status&&200===e.status_code&&console.log("[KushkiLogs] Log sent successfully:",e)}).catch(e=>console.error("[KushkiLogs] Fetch error:",e))},tV=(0,u.createContext)(null),tU=()=>{let e=(0,u.useContext)(tV);if(!e)throw Error("useKushki must be used within KushkiProvider");return e},tW=e=>{let{children:t,publicCredentialId:r,inTest:a=!0}=e,[i,l]=(0,u.useState)(!1),[n,s]=(0,u.useState)(null),[d,c]=(0,u.useState)(null);return(0,u.useEffect)(()=>
1{if(window.Kushki&&d&&"function"==typeof d.requestSubscriptionToken)return;let e="kushki-sdk-script",t=document.getElementById(e),o=()=>{try{if(window.Kushki){let e=new window.Kushki({merchantId:r,inTestEnvironment:a});"function"!=typeof e.requestSubscriptionToken&&console.error("Kushki SDK does not support subscription tokens"),c(e),l(!0),console.log("Kushki SDK initialized with subscription support")}}catch(o){var e;console.error("Failed to initialize Kushki SDK:",o);let t=null!==(e=null==o?void 0:o.message)&&void 0!==e?e:"Failed to initialize payment SDK";s(t),tJ({event:"sdk_init_error",gateway:"kushki",error_message:t,merchant_id:r,is_sandbox:a})}};t?window.Kushki?o():t.onload=o:((t=document.createElement("script")).id=e,t.src="https://cdn.kushkipagos.com/kushki.min.js",t.async=!0,t.onload=o,t.onerror=()=>{let e="Failed to load Kushki SDK script";s(e),tJ({event:"sdk_script_load_error",gateway:"kushki",error_message:e,merchant_id:r,is_sandbox:a})},document.body.appendChild(t))},[r,a]),(0,o.jsx)(tV.Provider,{value:{kushkiInstance:d,isReady:i,error:n},children:t})},tH=(0,u.forwardRef)(function(e,t){let{isOpen:r=!1,onClose:a=()=>{},onPaymentSubmit:i,widthClass:l="max-w-lg",totalAmount:n=0,primaryColor:s="#4f46e5",primaryTextColor:d="#ffffff",secondaryColor:c="#000000",secondaryTextColor:m="#ffffff",restaurantId:_="",prefillName:v="",profilecheckdata:g,saveCardEnabled:f=!1,onRetryLoaderChange:h}=e,[x,b]=(0,u.useState)(!1),[w,N]=(0,u.useState)(null),[j,k]=(0,u.useState)(null),[S,C]=(0,u.useState)(!1),[I,F]=(0,u.useState)(""),[E,A]=(0,u.useState)({cardholderName:"",cardNumber:"",expirationDate:"",securityCode:""}),{kushkiInstance:D,isReady:O,error:M}=tU(),{t:P}=(0,p.Bd)(),T=(0,u.useRef)(null),L=(0,u.useRef)(!1),q=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(r)return k(null),N(null),F(""),C(!1),A({cardholderName:v||"",cardNumber:"",expirationDate:"",securityCode:""}),L.current=!1,q.current=!1,()=>{L.current=!0}},[r]);let R=(e,t)=>new Promise(r=>{if(!D){r({error:P("billpocket_modal.payment_errors.sdk_loading")});return}let[o,a]=e.expirationDate.split("/"),i={card:{name:e.cardholderName,number:e.cardNumber.replace(/\s/g,""),expiryMonth:o,expiryYear:a,cvc:e.securityCode},currency:"MXN",amount:t.toString()};try{D.requestToken(i,e=>{if(!e||e.code){r({error:(null==e?void 0:e.message)||P("billpocket_modal.payment_errors.token_generation_error")});return}if(e.security&&!1!==e.security.authRequired){try{D.requestValidate3DS({secureId:e.secureId,security:{acsURL:e.security.acsURL,authenticationTransactionId:e.security.authenticationTransactionId,paReq:e.security.paReq,specificationVersion:e.security.specificationVersion,authRequired:e.security.authRequired}},t=>{if(!t||t.code){r({error:P("billpocket_modal.payment_errors.three_ds_failed")});return}r({token:e.token,threeDomainSecure:{secureId:e.secureId,authenticationTransactionId:e.security.authenticationTransactionId,eci:"05",specificationVersion:e.security.specificationVersion||"1.0.2"}})})}catch(e){r({error:(null==e?void 0:e.message)||P("billpocket_modal.payment_errors.three_ds_failed")})}return}r({token:e.token})})}catch(e){r({error:(null==e?void 0:e.message)||P("billpocket_modal.payment_errors.unexpected_error")})}});if((0,u.useImperativeHandle)(t,()=>({regenerateOneTimeToken:R})),(0,u.useEffect)(()=>{M&&k(M)},[M]),(0,u.useEffect)(()=>{if(!r)return;let e=e=>{"Escape"===e.key&&a()},t=document.body.style.overflow;return document.body.style.overflow="hidden",document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e),document.body.style.overflow=t}},[r,a]),!r)return null;let B=()=>{let{cardholderName:e,cardNumber:t,expirationDate:r,securityCode:o}=E;if(!e.trim())return k(P("billpocket_modal.validation_errors.cardholder_name_required")),!1;let a=t.replace(/\s/g,"");if(!t.trim()||a.length<15||a.length>16)return k(P("billpocket_modal.validation_errors.card_number_16_digits")),!1;if(!r.trim()||!/^\d{2}\/\d{2}$/.test(r))return k(P("billpocket_modal.validation_errors.expiration_format")),!1;let[i,l]=r.split("/").map(Number),n=new Date().getMonth()+1,s=new Date().getFullYear()%100;if(l<s||l===s&&i<n)return k(P("billpocket_modal.validation_errors.card_expired")),!1;if(!o.trim()||o.length<3||o.length>4)return k(P("billpocket_modal.validation_errors.cvv_3_4_digits")),!1;if(!(null==g?void 0:g.email)||(null==g?void 0:g.email.trim())===""){if(!I.trim())return k(P("billpocket_modal.validation_errors.email_required")),!1;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I.trim()))return k(P("billpocket_modal.validation_errors.email_invalid")),!1}return!0},z=async e=>
1{if(e.preventDefault(),B()){if(!O||!D){k(P("billpocket_modal.payment_errors.sdk_loading"));return}b(!0),k(null),N(null),q.current=!1;try{let e=S,[t,r]=E.expirationDate.split("/"),o={card:{name:E.cardholderName,number:E.cardNumber.replace(/\s/g,""),expiryMonth:t,expiryYear:r,cvc:E.securityCode},currency:"MXN",amount:n.toString()};tJ({event:"payment_attempt",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{saveCard:S,cardDigits:E.cardNumber.replace(/\s/g,"").length}});let l=t=>{if(!e||q.current)return!1;q.current=!0,e=!1,C(!1),tJ({event:"save_card_token_failed_retry_one_time",gateway:"billpocket",error_message:t,amount:n,currency:"MXN",restaurant_id:_}),null==h||h(!0,P("billpocket_modal.retry_one_time_charge"));try{o.amount=n.toString(),D.requestToken(o,c)}catch(e){null==h||h(!1),k((null==e?void 0:e.message)||P("billpocket_modal.payment_errors.unexpected_error")),b(!1)}return!0},s=e=>{q.current&&(null==h||h(!1),tJ({event:"save_card_token_retry_result",gateway:"billpocket",error_message:e,amount:n,currency:"MXN",restaurant_id:_,extra:{outcome:"failed"}})),k(e),b(!1)},d=t=>{if(L.current)return;let r=t.token;N(r);let o={...E,saveCard:e,token:r,totalAmount:n,currency:"MXN",email:(null==g?void 0:g.email)&&(null==g?void 0:g.email.trim())!==""?g.email:I.trim()};t.security&&!1!==t.security.authRequired&&!e&&(o.threeDomainSecure={secureId:t.secureId,authenticationTransactionId:t.security.authenticationTransactionId,eci:"05",specificationVersion:t.security.specificationVersion||"1.0.2"}),console.log("Token generation successful:",o),tJ({event:"payment_success",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{token:r,saveCard:e,has3DS:!!o.threeDomainSecure}}),q.current&&(null==h||h(!1),tJ({event:"save_card_token_retry_result",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{outcome:"success",token:r}})),i?i(o):localStorage.setItem("billpocket_transaction",JSON.stringify(o)),a(),b(!1)},c=t=>{var r,o,a;if(!L.current){if(console.log("Kushki Token Response:",t),tJ({event:"token_callback_received",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{responseIsNull:null===t,responseType:typeof t,hasCode:!!(null==t?void 0:t.code),hasSecurity:!!(null==t?void 0:t.security),authRequired:null==t?void 0:null===(r=t.security)||void 0===r?void 0:r.authRequired}}),!t){if(tJ({event:"token_null_response",gateway:"billpocket",error_message:"tokenResponse was null — SDK fired callback with no data",amount:n,currency:"MXN",restaurant_id:_}),l(P("billpocket_modal.payment_errors.token_generation_error")))return;s(P("billpocket_modal.payment_errors.token_generation_error"));return}if(t.code){let e=t.message||P("billpocket_modal.payment_errors.token_generation_error");if(tJ({event:"token_generation_error",gateway:"billpocket",error_message:t.message,error_code:t.code,amount:n,currency:"MXN",restaurant_id:_}),l(e))return;s(e);return}if(t.security&&!1!==t.security.authRequired){tJ({event:"three_ds_required",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{secureId:t.secureId,specificationVersion:null===(o=t.security)||void 0===o?void 0:o.specificationVersion,authRequired:null===(a=t.security)||void 0===a?void 0:a.authRequired}});try{D.requestValidate3DS({secureId:t.secureId,security:{acsURL:t.security.acsURL,authenticationTransactionId:t.security.authenticationTransactionId,paReq:t.security.paReq,specificationVersion:t.security.specificationVersion,authRequired:t.security.authRequired}},e=>{if(!L.current){if(console.log("3DS Validation Response:",e),tJ({event:"three_ds_callback_received",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{responseIsNull:null===e,responseType:typeof e,hasCode:!!(null==e?void 0:e.code)}}),!e){if(tJ({event:"three_ds_null_response",gateway:"billpocket",error_message:"threeDSResponse was null — 3DS callback fired with no data",amount:n,currency:"MXN",restaurant_id:_,extra:{secureId:t.secureId}}),l(P("billpocket_modal.payment_errors.three_ds_failed")))return;s(P("billpocket_modal.payment_errors.three_ds_failed"));return}if(e.code){if(tJ({event:"three_ds_error",gateway:"billpocket",error_message:e.message,error_code:e.code,amount:n,currency:"MXN",restaurant_id:_,extra:{secureId:t.secureId}}),l(P("billpocket_modal.payment_errors.three_ds_failed")))return;s(P("billpocket_modal.payment_errors.three_ds_failed"))}else tJ({event:"three_ds_success",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{secureId:t.secureId}}),d(t)}})}catch(e){if(console.error("3DS requestValidate3DS threw:",e),tJ({event:"three_ds_sdk_throw",gateway:"billpocket",error_message:(null==e?void 0:e.message)||String(e),amount:n,currency:"MXN",restaurant_id:_,extra:{secureId:t.secureId}}),l(P("billpocket_modal.payment_errors.three_ds_failed")))return;s(P("billpocket_modal.payment_errors.three_ds_failed"))}}else tJ({event:"token_success_no_3ds",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{token:t.token,saveCard:e}}),d(t)}};tJ({event:"sdk_call_initiated",gateway:"billpocket",amount:n,currency:"MXN",restaurant_id:_,extra:{saveCard:S}});try{e?D.requestSubscriptionToken(o,c):(o.amount=n.toString(),D.requestToken(o,c))}catch(r){console.error("Kushki SDK call threw synchronously:",r);let t=(null==r?void 0:r.message)||P("billpocket_modal.payment_errors.unexpected_error");
1if(tJ({event:"sdk_call_sync_throw",gateway:"billpocket",error_message:t,amount:n,currency:"MXN",restaurant_id:_,extra:{saveCard:e}}),l(t))return;s(t)}}catch(e){console.error("Submit error:",e),tJ({event:"unexpected_error",gateway:"billpocket",error_message:(null==e?void 0:e.message)||String(e),amount:n,currency:"MXN",restaurant_id:_}),L.current||k((null==e?void 0:e.message)||P("billpocket_modal.payment_errors.unexpected_error")),b(!1)}}};return(0,tz.createPortal)((0,o.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center p-4 overflow-y-auto","aria-modal":"true",role:"dialog","aria-labelledby":"dummy-modal-title",children:[(0,o.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 backdrop-blur-sm",onClick:a}),(0,o.jsx)("div",{className:"".concat(l," relative z-10 rounded-t-2xl shadow-lg bg-white my-8 max-h-[calc(100vh-4rem)] flex flex-col"),style:{minWidth:320},children:(0,o.jsxs)("div",{className:"w-full bg-white shadow-xl flex flex-col h-full",children:[(0,o.jsxs)("div",{className:"px-4 py-4 sm:px-8 sm:py-6 relative",style:{backgroundColor:s,color:d},children:[(0,o.jsx)("button",{onClick:a,className:"absolute top-4 right-4 text-white hover:text-indigo-100 focus:outline-none","aria-label":P("billpocket_modal.close"),children:(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,o.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,o.jsx)("h1",{className:"text-2xl font-bold text-white",children:P("billpocket_modal.secure_payment")}),(0,o.jsx)("p",{className:"text-indigo-100 mt-2 text-sm",children:P("billpocket_modal.complete_purchase")})]}),(0,o.jsxs)("div",{className:"overflow-y-auto flex-1 p-2",children:[(0,o.jsxs)("div",{className:"mb-6 p-4 bg-gray-50 rounded-xl border border-gray-100 flex justify-between items-center",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"text-sm text-gray-500",children:P("billpocket_modal.total_to_pay")}),(0,o.jsxs)("p",{className:"text-2xl font-bold text-gray-900",children:["$",n.toFixed(2)," MXN"]})]}),(0,o.jsx)("div",{className:"h-10 w-10 rounded-full flex items-center justify-center",style:{backgroundColor:c,color:m},children:(0,o.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,o.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"})})})]}),(0,o.jsxs)("form",{ref:T,onSubmit:z,className:"space-y-6 p-2",children:[(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:P("billpocket_modal.cardholder_name")}),(0,o.jsx)("input",{type:"text",name:"cardholderName",value:E.cardholderName,onChange:e=>{let{name:t,value:r}=e.target;!("cardholderName"===t&&/\d/.test(r))&&(A(e=>({...e,[t]:r})),j&&k(null))},placeholder:P("billpocket_modal.cardholder_name_placeholder"),className:"w-full h-12 px-4 border border-gray-300 rounded-lg focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 outline-none transition-colors disabled:bg-gray-100 disabled:text-gray-400",required:!0,disabled:x})]}),(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:P("billpocket_modal.card_number")}),(0,o.jsx)("input",{type:"text",name:"cardNumber",value:E.cardNumber,onChange:e=>{let t=e.target.value.replace(/\D/g,"").slice(0,16).replace(/(\d{4})(?=\d)/g,"$1 ");A(e=>({...e,cardNumber:t}))},placeholder:"0000 0000 0000 0000",maxLength:19,className:"w-full h-12 px-4 border border-gray-300 rounded-lg focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 outline-none transition-colors disabled:bg-gray-100 disabled:text-gray-400",required:!0,disabled:x})]}),(0,o.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:P("billpocket_modal.expiration")}),(0,o.jsx)("input",{type:"text",name:"expirationDate",value:E.expirationDate,onChange:e=>{let t=e.target.value.replace(/\D/g,"").slice(0,4);if(t.length>=2){let e=parseInt(t.substring(0,2));e>12&&(t="12"+t.substring(2)),0===e&&(t="01"+t.substring(2)),t=t.substring(0,2)+"/"+t.substring(2)}A(e=>({...e,expirationDate:t}))},placeholder:"MM/AA",maxLength:5,className:"w-full h-12 px-4 border border-gray-300 rounded-lg focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 outline-none transition-colors disabled:bg-gray-100 disabled:text-gray-400",required:!0,disabled:x})]}),(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:P("billpocket_modal.cvv_cvc")}),(0,o.jsx)("input",{type:"password",name:"securityCode",value:E.securityCode,onChange:e=>{let t=e.target.value.replace(/\D/g,"").slice(0,4);A(e=>({...e,securityCode:t}))},placeholder:"123",maxLength:4,className:"w-full h-12 px-4 border border-gray-300 rounded-lg focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 outline-none transition-colors disabled:bg-gray-100 disabled:text-gray-400",required:!0,disabled:x})]})]}),(!g||!g.email||""===g.email.trim())&&(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)("label",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:P("billpocket_modal.email")}),(0,o.jsx)("input",{type:"email",name:"email",value:I,onChange:e=>{F(e.target.value),j&&k(null)},placeholder:P("billpocket_modal.email_placeholder"),className:"w-full h-12 px-4 border border-gray-300 rounded-lg focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 outline-none transition-colors disabled:bg-gray-100 disabled:text-gray-400",required:!0,disabled:x})]}),f&&(0,o.jsxs)("label",{className:"flex items-center gap-2",children:[(0,o.jsx)("input",{type:"checkbox",checked:S,onChange:e=>C(e.target.checked),disabled:x}),(0,o.jsx)("span",{className:"text-sm",children:P("billpocket_modal.save_card_for_future_use")})]}),j&&(0,o.jsxs)("div",{className:"p-4 bg-red-50 border-l-4 border-red-500 text-red-700 text-sm rounded-r",children:[(0,o.jsx)("p",{className:"font-bold",children:P("billpocket_modal.error")}),(0,o.jsx)("p",{children:j})]}),w&&(0,o.jsxs)("div",{className:"p-4 bg-green-50 border-l-4 border-green-500 text-green-700 text-sm rounded-r",children:[(0,o.jsx)("p",{className:"font-bold",children:P("billpocket_modal.token_generated")}),(0,o.jsx)("p",{className:"font-mono text-xs mt-1 break-all",children:w})]}),(0,o.jsx)("button",{type:"submit",disabled:x||!O,className:"w-full py-4 rounded-xl font-bold text-lg shadow-lg transition-all transform active:scale-[0.98] mt-4 disabled:cursor-not-allowed flex items-center justify-center gap-2 disabled:bg-gray-300",style:{backgroundColor:x||!O?void 0:c,color:m,boxShadow:"0 4px 6px -1px ".concat(s,"33, 0 2px 4px -1px ").concat(s,"1a")},children:x?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-4 border-white"}),P("billpocket_modal.processing")]}):O?P("billpocket_modal.pay_now"):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-gray-500"}),P("billpocket_modal.payment_errors.sdk_loading")]})}),(0,o.jsx)("div",{className:"flex justify-center",children:(0,o.jsx)(y(),{src:"/ecomv2/Kushkilogo.svg",height:80,width:100,alt:"logo"})})]})]})]})})]}),document.body)});var tG=r(45703),tY=r.n(tG),tK=r(24501);let tX=e=>{let{isOpen:t,primaryColor:r="#6366f1",loadingText:a,subText:i}=e,{t:l}=(0,p.Bd)(),n=a||l("charging"),s=!!i&&""!==i.trim();return t?(0,o.jsxs)("div",{className:"jsx-6180afc0f5d69eb5 fixed inset-0 z-[99999] flex items-center justify-center bg-black/60 backdrop-blur-md transition-all duration-300 px-4",children:[(0,o.jsxs)("div",{className:"jsx-6180afc0f5d69eb5 flex flex-col items-center w-full max-w-[300px] rounded-3xl bg-[#161616] border border-white/10 shadow-2xl px-6 py-8 scale-in-center",children:[(0,o.jsx)("div",{style:{border:"3px solid",borderColor:"".concat(r,"33"),borderTopColor:r}
1,className:"jsx-6180afc0f5d69eb5 w-14 h-14 rounded-full mb-5 animate-spin"}),(0,o.jsx)("p",{className:"jsx-6180afc0f5d69eb5 text-white text-lg font-bold text-center mb-1.5",children:n}),(0,o.jsx)("p",{className:"jsx-6180afc0f5d69eb5 text-white/50 text-sm text-center leading-snug px-1 mb-5",children:l("payment_processing_description")}),s&&(0,o.jsxs)("div",{className:"jsx-6180afc0f5d69eb5 flex items-start gap-2.5 w-full rounded-xl bg-white/[0.07] px-4 py-3.5",children:[(0,o.jsx)(tK.A,{size:18,className:"shrink-0 mt-0.5 text-white/55"}),(0,o.jsx)("p",{className:"jsx-6180afc0f5d69eb5 text-white/75 text-[13px] leading-snug text-left",children:i})]})]}),(0,o.jsx)(tY(),{id:"6180afc0f5d69eb5",children:".scale-in-center.jsx-6180afc0f5d69eb5{-webkit-animation:scale-in-center.3s cubic-bezier(.25,.46,.45,.94)both;-moz-animation:scale-in-center.3s cubic-bezier(.25,.46,.45,.94)both;-o-animation:scale-in-center.3s cubic-bezier(.25,.46,.45,.94)both;animation:scale-in-center.3s cubic-bezier(.25,.46,.45,.94)both}@-webkit-keyframes scale-in-center{0%{-webkit-transform:scale(.92);transform:scale(.92);opacity:0}
1100%{-webkit-transform:scale(1);transform:scale(1);opacity:1}}@-moz-keyframes scale-in-center{0%{-moz-transform:scale(.92);transform:scale(.92);opacity:0}100%{-moz-transform:scale(1);transform:scale(1);opacity:1}}@-o-keyframes scale-in-center{0%{-o-transform:scale(.92);transform:scale(.92);opacity:0}100%{-o-transform:scale(1);transform:scale(1);opacity:1}}@keyframes scale-in-center{0%{-webkit-transform:scale(.92);-moz-transform:scale(.92);-o-transform:scale(.92);transform:scale(.92);opacity:0}100%{-webkit-transform:scale(1);-moz-transform:scale(1);-o-transform:scale(1);transform:scale(1);opacity:1}}"})]}):null},tZ=new Set(["SAVED_CARD_RESULT_DELETED","SAVED_CARD_RESULT_ALREADY_DELETED","SAVED_CARD_RESULT_CARD_NOT_FOUND"]),t$=()=>"https://api-prod.foodbot.ai",tQ=async e=>{let t={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_gateway_id:7,...e}),redirect:"follow"};try{var r,o,a,i;let e=await fetch("".concat(t$(),"/payment/v1/saved-cards/list"),t),l={};try{l=await e.json()}catch(e){l={}}return{statusCode:Number(null!==(o=null!==(r=null==l?void 0:l.status_code)&&void 0!==r?r:null==l?void 0:l.status)&&void 0!==o?o:e.status),code:null!==(a=null==l?void 0:l.code)&&void 0!==a?a:"",message:null!==(i=null==l?void 0:l.message)&&void 0!==i?i:"",cards:Array.isArray(null==l?void 0:l.cards)?l.cards:[]}}catch(e){return console.error("List Saved Cards Error:",e),{statusCode:0,code:"NETWORK_ERROR",message:e instanceof Error?e.message:"Unknown error",cards:[]}}},t0=async e=>{let t={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_gateway_id:7,...e}),redirect:"follow"};try{var r,o,a,i;let e=await fetch("".concat(t$(),"/payment/v1/saved-cards/remove"),t),l={};try{l=await e.json()}catch(e){l={}}let n=Number(null!==(o=null!==(r=null==l?void 0:l.status_code)&&void 0!==r?r:null==l?void 0:l.status)&&void 0!==o?o:e.status),s=null!==(a=null==l?void 0:l.code)&&void 0!==a?a:"";return{statusCode:n,code:s,message:null!==(i=null==l?void 0:l.message)&&void 0!==i?i:"",cardIsGone:200===n||tZ.has(s)}}catch(e){return console.error("Remove Saved Card Error:",e),{statusCode:0,code:"NETWORK_ERROR",message:e instanceof Error?e.message:"Unknown error",cardIsGone:!1}}};var t1=r(69634),t2=r(13400);let t5=e4()(()=>Promise.resolve().then(r.bind(r,67279)).then(e=>e.GoogleMap),{loadableGenerated:{webpack:()=>[67279]},ssr:!1,loading:()=>(0,o.jsx)(eO.A,{})}),t4=e4()(()=>Promise.resolve().then(r.bind(r,67279)).then(e=>e.Marker),{loadableGenerated:{webpack:()=>[67279]},ssr:!1,loading:()=>(0,o.jsx)(eO.A,{})});e7().extend(e8()),e7().extend(te()),e7().extend(ta()),e7().extend(tr());var t3=!0;let t7=e=>{var t,r,l,n,s,d,m,_,f,x,C,I,F,E,A,D,O,P,T,B,J,V,Q,ev,eg,eh,ej,ek,eC,eF,eE,eA,eO;let[eM,eP]=(0,u.useState)(!1),[eT,eL]=(0,u.useState)(!1),[eq,eR]=(0,u.useState)(""),[eB,eJ]=(0,u.useState)(e.paymentMethod&&e.paymentMethod),[eV,eU]=(0,u.useState)([]),[eW,eH]=(0,u.useState)([]),[eK,eZ]=(0,u.useState)({subtotal:0,discount:0,tax:0,tip:0,service:0,total:0}),[e$,eQ]=(0,u.useState)(!1),[e5,e4]=(0,u.useState)(""),[e3,e6]=(0,u.useState)([]),[e8,e9]=(0,u.useState)(!1),[te,tt]=(0,u.useState)(!1),[tr,to]=(0,u.useState)({}),[ta,tn]=(0,u.useState)({}),[ts,td]=(0,u.useState)({date:"",time:""}),[tc,tu]=(0,u.useState)(null),[tm,t_]=(0,u.useState)({}),[tp,tv]=(0,u.useState)(!1),[tg,tx]=(0,u.useState)(),[tb,tw]=(0,u.useState)(null),[tN,tj]=(0,u.useState)(!1),[tk,tS]=(0,u.useState)(!1),[tC,tF]=(0,u.useState)(null),[tE,tA]=(0,u.useState)(!1);(0,u.useEffect)(()=>{let e=localStorage.getItem("resturantserversideTheme");if(e)try{tw(JSON.parse(e))}catch(e){console.error("Failed to parse theme from localStorage:",e)}tj(!0)},[]),(0,u.useEffect)(()=>{let e="kushki-sdk-script";if(document.getElementById(e))return;let t=document.createElement("script");t.id=e,t.src="https://cdn.kushkipagos.com/kushki.min.js",t.async=!0,document.body.appendChild(t)},[]);let[tz,tV]=(0,u.useState)(null!==(eE=null===(t=e.restaurant_settings)||void 0===t?void 0:t.data)&&void 0!==eE?eE:[]),tU=(0,S.o)(null===(r=e.restaurant_settings)||void 0===r?void 0:r.data,e.restaurant_settings),[tG,tY]=(0,u.useState)(!1),[tK,tZ]=(0,u.useState)(""),{t:t$}=(0,p.Bd)(),{currentLang:t3,botLanguage:t7}=(0,eG.ok)(),t6=(0,h.useRouter)(),[t8,t9]=(0,u.useState)({}
1),[re,rt]=(0,u.useState)(0),[rr,ro]=(0,u.useState)(""),[ra,ri]=(0,u.useState)(0),[rl,rn]=(0,u.useState)({}),[rs,rd]=(0,u.useState)(null),[rc,ru]=(0,u.useState)(""),[rm,r_]=(0,u.useState)(""),[rp,rv]=(0,u.useState)({}),[rg,rf]=(0,u.useState)(null),[ry,rh]=(0,u.useState)(0),[rx,rb]=(0,u.useState)(0),[rw,rN]=(0,u.useState)("percentage"),[rj,rk]=(0,u.useState)(""),[rS,rC]=(0,u.useState)(!1),[rI,rF]=(0,u.useState)(!1),[rE,rA]=(0,u.useState)([]),[rD,rO]=(0,u.useState)(),[rM,rP]=(0,u.useState)(""),[rT,rL]=(0,u.useState)(!1),[rq,rR]=(0,u.useState)(),[rB,rz]=(0,u.useState)(""),[rJ,rV]=(0,u.useState)(!1),[rU,rW]=(0,u.useState)(!1),[rH,rG]=(0,u.useState)(!1),[rY,rK]=(0,u.useState)(""),[rX,rZ]=(0,u.useState)(""),[r$,rQ]=(0,u.useState)(""),[r0,r1]=(0,u.useState)([]),r2=(0,u.useRef)([]),[r5,r4]=(0,u.useState)(!1),[r3,r7]=(0,u.useState)(null),[r6,r8]=(0,u.useState)(!1),[r9,oe]=(0,u.useState)(!1),ot=(0,u.useRef)(!1),{handleApiError:or}=(0,er.u)(),oo=(0,u.useContext)(et.ib),[oa,oi]=(0,u.useState)({}),[ol,on]=(0,u.useState)(""),[os,od]=(0,u.useState)(!1),[oc,ou]=(0,u.useState)(0),[om,o_]=(0,u.useState)(""),[op,ov]=(0,u.useState)(""),[og,of]=(0,u.useState)(!1),[oy,oh]=(0,u.useState)(!1),[ox,ob]=(0,u.useState)(""),[ow,oN]=(0,u.useState)(!0),[oj,ok]=(0,u.useState)(null);if(!oo)throw Error("IndexPage must be used within a MyProvider");let[oS,oC]=(0,u.useState)(!1),{openSuccessModalFunc:oI,openFailureModalFunc:oF,setOpenSuccessModal:oE,openSuccessModal:oA,openFailureModal:oD,setOpenFailureModal:oO,modalMessage:oM,modalDetail:oP,resetSessionId:oT,SetNewPromoAlert:oL,newPromoAlert:oq,sessionId:oR,appVersion:oB,curveOrderInstruction:oz,restaurantData:oJ}=oo,[oV,oU]=(0,u.useState)({}),[oW,oH]=(0,u.useState)({}),[oG,oY]=(0,u.useState)(!1),oK=(0,u.useRef)(null),[oX,oZ]=(0,u.useState)(!1),[o$,oQ]=(0,u.useState)({}),[o0,o1]=(0,u.useState)({}),[o2,o5]=(0,u.useState)({}),o4=(0,u.useRef)([]),o3=(0,u.useRef)([]),o7=(0,u.useRef)(""),o6=(0,u.useRef)(!1),o8=(0,u.useRef)(null),o9=(0,u.useRef)(!1),{loaded:ae,netpay3ds:at,error:ar}=ed(),[ao,aa]=(0,u.useState)(null),[ai,al]=(0,u.useState)(!1),[an,as]=(0,u.useState)(""),{containerStyle:ad,center:ac,onLoad:au,onMarkerClick:am,getUserLocation:a_,marker:ap,autocompleteRef:av,handleLocationSelect:ag,map:af,setMarker:ay,address:ah,setAddress:ax,isReadyMap:ab}=(0,X._)(),{isGoogleMapsLoaded:aw,loadError:aN}=(0,ti.B)(),[aj,ak]=(0,u.useState)(""),[aS,aC]=(0,u.useState)(""),[aI,aF]=(0,u.useState)([]),[aE,aA]=(0,u.useState)(null),[aD,aO]=(0,u.useState)([]),[aM,aP]=(0,u.useState)(!1),[aT,aL]=(0,u.useState)(!1),[aq,aR]=(0,u.useState)(!1),aB=localStorage.getItem("request_id_".concat(tU)),az=(null===(l=(Array.isArray(null==oJ?void 0:null===(n=oJ.ecom_settings)||void 0===n?void 0:n.analytics_settings)?null==oJ?void 0:null===(s=oJ.ecom_settings)||void 0===s?void 0:s.analytics_settings:(null==oJ?void 0:null===(d=oJ.ecom_settings)||void 0===d?void 0:d.analytics_settings)?[oJ.ecom_settings.analytics_settings]:[]).find(e=>"7ef38a2c-42dc-11ed-b878-0242ac120002"===e.platform&&"1"===e.status))||void 0===l?void 0:l.id)||"848451747356230",aJ="viewCart",[aV,aU]=(0,u.useState)("");(0,u.useEffect)(()=>{aU(window.location.href)},[]);let aW=(null===(m=(Array.isArray(null==oJ?void 0:null===(_=oJ.ecom_settings)||void 0===_?void 0:_.analytics_settings)?oJ.ecom_settings.analytics_settings:(null==oJ?void 0:null===(f=oJ.ecom_settings)||void 0===f?void 0:f.analytics_settings)?[oJ.ecom_settings.analytics_settings]:[]).find(e=>"db0098c8-42dc-11ed-b878-0242ac120002"===e.platform))||void 0===m?void 0:m.id)||"G-V55PFGDBF9",[aH,aG]=(0,u.useState)(null),[aY,aK]=(0,u.useState)(null),[aX,aZ]=(0,u.useState)(0),[a$,aQ]=(0,u.useState)(!1),[a0,a1]=(0,u.useState)(""),[a2,a5]=(0,u.useState)(""),[a4,a3]=(0,u.useState)(!1),[a7,a6]=(0,u.useState)([]),[a8,a9]=(0,u.useState)(""),[ie,it]=(0,u.useState)(!0),[ir,io]=(0,u.useState)(!1),[ia,ii]=(0,u.useState)(""),[il,is]=(0,u.useState)(!1),[id,ic]=(0,u.useState)(null),[iu,im]=(0,u.useState)(!1),[i_,ip]=(0,u.useState)(null),[iv,ig]=(0,u.useState)(!1),[iy,ih]=(0,u.useState)(!1),[ix,ib]=(0,u.useState)([]),[iw,iN]=(0,u.useState)(null),[ij,ik]=(0,u.useState)(!1),[iS,iC]=(0,u.useState)(!1),[iI,iF]=(0,u.useState)(""),[iE,iA]=(0,u.useState)(!1),[iD,iO]=(0,u.useState)(!1),[iM,iP]=(0,u.useState)(!1),[iT,iL]=(0,u.useState)(null),[iq,iR]=(0,u.useState)(!1),[iB,iz]=(0,u.useState)(null),[iJ,iV]=(0,u.useState)(""),[iU,iW]=(0,u.useState)(""),iH=(0,u.useRef)(null),iG=e=>{aK(e)},iY=(0,u.useCallback)(()=>{iN(null),ik(!1),tU&&(localStorage.removeItem("selected_billpocket_card_".concat(tU)),localStorage.removeItem("is_paying_with_saved_billpocket_card_".concat(tU)))},[rm,t6.query.resturant]),iK=(0,u.useCallback)(e=>{var t,r,o;let a=(null==e?void 0:null===(t=e.kushki_response)||void 0===t?void 0:t.message)||(null==e?void 0:e.message)||"Payment failed";if((null==tz?void 0:tz.bot_language)==="en"&&(null==e?void 0:null===(r=e.kushki_response)||void 0===r?void 0:r.message)){let t=null==e?void 0:null===(o=e.kushki_response)||void 0===o?void 0:o.code;if(t&&t$("kushki_errors.".concat(t)))a=t$("kushki_errors.".concat(t));else{let t=e.kushki_response.message.toLowerCase();t.includes("fondos insuficientes")?a=t$("kushki_errors.insufficient_funds"):t.includes("suscripci\xf3n")&&(a=t$("kushki_errors.subscription_creation_failed"))}}return a},[null==tz?void 0:tz.bot_language,t$]);(0,R.nn)(tU),(0,ey.r)(tU),(0,u.useEffect)(()=>{eI(t6),it(!1)},[t6]),(0,u.useEffect)(()=>{tu(null),tn({}),rQ(""),rn(null),od(!1),tU&&(localStorage.removeItem("paymentMode_".concat(tU)),localStorage.removeItem("selected_payment_method_".concat(tU))),iY()},[null==rX?void 0:rX.branch_id,e5]),(0,u.useEffect)(()=>()=>{tU&&(localStorage.removeItem("paymentMode_".concat(tU)),localStorage.removeItem("orderTotal_".concat(tU)),iY()
1)},[rm,t6.query.resturant,iY]),(0,u.useEffect)(()=>{iY()},[eB,r$,iY]);let iX=e0(1024),[iZ,i$]=(0,u.useState)(iX);(0,u.useEffect)(()=>{i$(iX)},[iX]),(0,u.useEffect)(()=>{if(tU){let e=localStorage.getItem("callin_order_".concat(tU));if(e)try{let t=JSON.parse(e);if(t.expires_at&&Date.now()>t.expires_at){localStorage.removeItem("callin_order_".concat(tU)),localStorage.removeItem("callin_open_payment"),localStorage.removeItem("handleBranchClickCaller_".concat(tU));return}}catch(e){localStorage.removeItem("callin_order_".concat(tU)),localStorage.removeItem("callin_open_payment"),localStorage.removeItem("handleBranchClickCaller_".concat(tU));return}}"true"===localStorage.getItem("callin_open_payment")&&(localStorage.removeItem("callin_open_payment"),oN(!1),ot.current=!0,oe(!1),tU&&"true"===localStorage.getItem("callin_use_points_".concat(tU))&&(localStorage.removeItem("callin_use_points_".concat(tU)),oZ(!0)),iX&&eP(!0))},[iX,rm,t6.query.resturant]),(0,u.useEffect)(()=>{try{let e=localStorage.getItem("alias"),t="payment_method_".concat(tU),r=localStorage.getItem(t);if(r)try{let e=JSON.parse(r);eJ(e)}catch(e){console.warn("Invalid JSON in localStorage:",t),t6.push("/".concat(t6.query.resturant));return}e?a5(e):t6.query.resturant&&a5("".concat(t6.query.resturant))}catch(e){console.error("Error accessing localStorage:",e)}},[t6,t6.query.resturant,e5,null==rX?void 0:rX.branch_id]);let iQ=localStorage.getItem("selected_branchmode_".concat(tU));(0,u.useEffect)(()=>{let e=localStorage.getItem("analytics_settings_".concat(tU));if(e){console.log("analyticsSettings",e);try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&"object"==typeof t?[t]:[];o4.current=r.filter(e=>"7ef38a2c-42dc-11ed-b878-0242ac120002"==e.platform&&"1"==e.status),o3.current=r.filter(e=>"db0098c8-42dc-11ed-b878-0242ac120002"==e.platform&&"1"==e.status),aO(o3.current)}catch(e){console.error("Failed to parse analytics settings:",e)}}},[]),aB||(aB=(0,W.NF)(2),localStorage.setItem("request_id_".concat(tU),aB));let i0=()=>{iC(!0),eQ(!0)},i1=()=>{iC(!1),eQ(!1),iW("")},i2=e=>"string"==typeof e?parseFloat(e.replace(/[^0-9.]/g,""))||0:"number"==typeof e?e:0,i5=Array.isArray(null==aI?void 0:null===(x=aI.order_items)||void 0===x?void 0:x.item_details)?aI.order_items.item_details.map(e=>{var t,r;return{item_id:e.item_id,item_name:e.item_name,quantity:e.quantity,price:null!==(r=null!==(t=e.total_item_price)&&void 0!==t?t:e.item_price_with_modifier)&&void 0!==r?r:e.item_price}}):[];(0,u.useEffect)(()=>{var e,t,r,o;let a;let i=localStorage.getItem("cartData_".concat(tU));if(i)try{a=JSON.parse(i)}catch(e){console.error("Failed to parse cartData:",e)}let l=i2(null==a?void 0:a.final_amount),n=null!==(t=null==a?void 0:null===(e=a.order_items)||void 0===e?void 0:e.item_details.length)&&void 0!==t?t:0,s=(null==tz?void 0:tz.currency)||"MXN";if(Array.isArray(o4.current)&&o4.current.length>0){let e=o4.current[0].id,t=null!==(o=null==a?void 0:null===(r=a.order_items)||void 0===r?void 0:r.item_details)&&void 0!==o?o:[];aa({id:e,content_ids:t.map(e=>String(e.item_id)),content_type:"product",value:l,currency:s,num_items:t.reduce((e,t)=>{var r;return e+(null!==(r=t.quantity)&&void 0!==r?r:1)},0)})}Array.isArray(o3.current)&&o3.current.length>0&&o5({value:l,ItemCount:n,currency:s,items:i5})},[null==tz?void 0:tz.currency]);let[i4,i3]=(0,u.useState)(!1),[i7,i6]=(0,u.useState)(!1),i8=(null==eB?void 0:null===(C=eB.data)||void 0===C?void 0:C.Payment_settings)||[],i9=i8.find(e=>1==e.payment_method_id&&1===e.gateway_id),le=null==i9?void 0:i9.public_key,lt=null==i9?void 0:i9.payment_st_id.toString();console.log("publicKey",le,"st_id",lt);let lr=i8.find(e=>3==e.gateway_id),lo=null==lr?void 0:lr.payment_st_id;(0,u.useEffect)(()=>{le?tI(le).then(()=>i6(!0)).catch(e=>console.error("Failed to load MercadoPago SDK",e)):(console.warn("MercadoPago publicKey not available"),i6(!1))},[le]),(0,u.useEffect)(()=>{if(iQ)try{let e=JSON.parse(iQ);ak(null==e?void 0:e.branch)}catch(e){console.error("Error parsing storedMode:",e)}let e=localStorage.getItem("restaurant_open_".concat(tU))||t6.query.resturant;if(e)try{let t=JSON.parse(e);i3(t)}catch(e){console.error("Error parsing restaurantstatus:",e)}let t=localStorage.getItem("cartData_".concat(tU));if(t)try{let e=JSON.parse(t);aF(e)}catch(e){console.error("Failed to parse cartData:",e)}let r=localStorage.getItem("dine_in_table");if(r)try{let e=JSON.parse(r);a1(e)}catch(e){console.error("Error parsing dine_in_table:",e)}},[localStorage.getItem("cartData_".concat(tU))]),console.log("dineintable",a0),(0,u.useEffect)(()=>{let e=()=>{let e=localStorage.getItem("offer_details_".concat(tU));if(e)try{t9(JSON.parse(e))}catch(e){}};return window.addEventListener("promotionUpdated",e),()=>window.removeEventListener("promotionUpdated",e)},[]),(0,u.useEffect)(()=>{let e=()=>rt(e=>e+1);return window.addEventListener("offersReady",e),()=>window.removeEventListener("offersReady",e)},[]),(0,u.useEffect)(()=>{let e=(e,t)=>
1{let r=localStorage.getItem(e);if(r&&"undefined"!==r)try{t(JSON.parse(r))}catch(t){console.error("Error parsing ".concat(e,":"),t)}else console.log("No ".concat(e," found in localStorage"))};try{tU&&r_(tU);let t=localStorage.getItem("getPickupBranches_".concat(tU)),r=localStorage.getItem("selected_branchmode_".concat(tU)),o=localStorage.getItem("cartItemDetails_".concat(tU)),a=localStorage.getItem("resturantserversideTheme");localStorage.getItem("currentbranch_".concat(tU));let i=localStorage.getItem("resturantserversidesettings");if(e("offer_details_".concat(tU),t9),e("loyalty_plan_details_".concat(tU),o1),e("branch_delivery_".concat(tU),rz),t&&rR(JSON.parse(t)),a&&tw(JSON.parse(a)),r){let e=JSON.parse(r);e4(null==e?void 0:e.mode),rZ(null==e?void 0:e.branch)}o&&e6(JSON.parse(o)),i&&tV(JSON.parse(i))}catch(e){console.error("General error in useEffect:",e)}},[localStorage.getItem("loyalty_points_details_".concat(tU)),localStorage.getItem("cartItemDetails_".concat(rm)),localStorage.getItem("selected_branchmode_".concat(rm)),localStorage.getItem("branch_delivery_".concat(rm)),localStorage.getItem("restaurant_open_".concat(rm)),rE]),(0,u.useEffect)(()=>{let e;if(o6.current||!e5||0===eK.subtotal||!o8.current)return;if(t8&&"object"==typeof t8&&Object.keys(t8).length>0&&t8.offer_id){o6.current=!0;return}if(!tU)return;let t=localStorage.getItem("offers_".concat(tU));if(!t||"undefined"===t||"null"===t)return;try{let r=JSON.parse(t);if(!Array.isArray(r))return;e=r}catch(e){return}let r=function(e,t,r,o,a){try{if(!Array.isArray(e)||0===e.length||!t||"string"!=typeof t)return[];let i=Number(r);if(isNaN(i))return[];let l=Array.isArray(a)?a:[],n=new Date;n.setHours(0,0,0,0);let s="delivery"===t?"delivery":"dinein"===t?"dinein":"takeout",d=e.filter(e=>{try{if(!e||"object"!=typeof e)return!1;let r=e.oo_order_type;if(!r||"object"!=typeof r||"yes"!==r[s])return!1;let a=Number(e.oo_min_amount);if(!isNaN(a)&&i<a)return!1;let d=e.branch_id;if(null!=d&&""!==String(d).trim()&&"All"!==String(d)&&null!=o&&""!==String(o).trim()&&!String(d).split(",").map(e=>e.trim()).filter(Boolean).includes(String(o).trim())||"free_delivery"===e.offer_discount_type&&"delivery"!==t)return!1;let c=ee(e.validity_from),u=ee(e.validity_to);if(c&&n<c||u&&n>u||!function(e,t){try{let r="string"==typeof(null==e?void 0:e.offer_discount_type)?e.offer_discount_type:"";if("free_delivery"===r||"discount_modifier"===r)return!0;let o=null==e?void 0:e.offer_products;if("discount"===r||"free_product"===r){let e=null==o?void 0:o.offer_discount_products;if(!Array.isArray(e)||0===e.length)return!0;return t.some(t=>{let r=null==t?void 0:t.item_id;return null!=r&&e.some(e=>String(e)===String(r))})}if("buy_x_get_y"===r){let e=null==o?void 0:o.offer_buy_products,r=null==o?void 0:o.offer_get_products,a=Array.isArray(e)&&e.length>0,i=Array.isArray(r)&&r.length>0;if(!a&&!i)return!0;let l=Math.max(1,Number(null==o?void 0:o.buy_item_count)||1),n=Math.max(1,Number(null==o?void 0:o.get_item_count)||1),s=a?l:0,d=i?n:0;for(let o of t){let t=null==o?void 0:o.item_id;if(null==t)continue;let l=Math.max(1,Number(null==o?void 0:o.quantity)||1),n=a&&e.some(e=>String(e)===String(t)),c=i&&r.some(e=>String(e)===String(t));if(n&&s>0){let e=Math.min(l,s);s-=e,l-=e}if(c&&d>0){let e=Math.min(l,d);d-=e}if(s<=0&&d<=0)break}if(a&&s>0||i&&d>0)return!1}return!0}catch(e){return!0}}(e,l))return!1;return!0}catch(e){return!1}});return d.sort((e,t)=>{try{let r=ee(null==e?void 0:e.validity_to),o=ee(null==t?void 0:t.validity_to);if(!r&&!o)return 0;if(!r)return 1;if(!o)return -1;return r.getTime()-o.getTime()}catch(e){return 0}}),d}catch(e){return[]}}(e,e5,eK.subtotal,lc,e3);if(0===r.length)return;let o=!1;return(async()=>{for(let a of r){if(o||o6.current)return;try{var e,t;let r={...o8.current,promotion_applied:(0,w.H)(a)},i=await (0,k.calculateTax)(r);if(o||o6.current)return;let l=Number(null==i?void 0:null===(t=i.data)||void 0===t?void 0:null===(e=t.order_items)||void 0===e?void 0:e.discount);if((null==i?void 0:i.status_code)==200&&l>0){o6.current=!0,t9(a);try{localStorage.setItem("offer_details_".concat(tU),JSON.stringify(a))}catch(e){}window.dispatchEvent(new Event("promotionUpdated"));return}}catch(e){}}})(),()=>{o=!0}},[eK.subtotal,e5,rX,t8,e3,re]),(0,u.useEffect)(()=>{let e=()=>{let e=localStorage.getItem("scheduledOrder_".concat(tU));if(e)try{let t=JSON.parse(e);ip(t),localStorage.setItem("current_scheduledOrder__".concat(tU),"true")}catch(e){console.error("Error parsing scheduled order:",e),ip(null)}else ip(null)};return e(),window.addEventListener("storage",e),()=>{window.removeEventListener("storage",e)}},[localStorage.getItem("scheduledOrder_".concat(tU)),localStorage.getItem("selected_branchmode_".concat(tU))]);let la=(0,u.useCallback)(async()=>{console.log("\uD83D\uDD25 Fetching menu with alias:",tU);let e=await (0,eN.KR)("branchMenuDetail_".concat(tU));e?(console.log("✅ Menu fetched from DB:",e),rA(e)):console.warn("❌ No menu found for alias:",tU)},[t6.query.resturant]);(0,u.useEffect)(()=>{(null==rX?void 0:rX.branch_id)&&(async()=>{try{await la()}catch(e){console.error("fetchMenu failed:",e),oF(t$("menu_fetch_error"))}})()},[la,null==rX?void 0:rX.branch_id]);
1let{reorderSourceId:li,pendingReorderRef:ll}=function(e){let{alias:t,resturantsettings:r,session_id:o,version:a,branchMenuDetail:i,setBranchMenuDetail:l,setCartItemDetails:n,setIsCartUpdated:s,openFailureModalFunc:d,t:c}=e,[m,_]=(0,u.useState)(""),p=(0,u.useRef)(null),v=(0,u.useCallback)((e,r)=>{var o,a;let l=null!=r?r:Array.isArray(i)?i:i?[i]:[];console.log("[REORDER] generateReorderCart — start",{source_menus:l.length,order_items:null===(o=e.order_items)||void 0===o?void 0:o.length});let u=[];l.forEach(e=>{(null==e?void 0:e.menu_category)&&e.menu_category.forEach(t=>{(null==t?void 0:t.cat_items)&&t.cat_items.forEach(r=>{var o,a;u.push({...r,menu_id:null!==(o=r.menu_id)&&void 0!==o?o:e.menu_id,category_id:null!==(a=r.category_id)&&void 0!==a?a:t.category_id})})})});let m=!1,p=[];if((e.order_items||[]).forEach(e=>{if(1===e.is_package)return;let t=u.find(t=>String(t.item_id)===String(e.item_id));if(!t){console.warn("[REORDER] item not found in menu",{item_id:e.item_id,item_name:e.item_display_text}),m=!0;return}console.log("[REORDER] item matched",{item_id:e.item_id});let r=[];(t.cat_items_modifiercat||[]).forEach((e,t)=>{(e.cat_items_modifiercat_modifieritems||[]).forEach(o=>{r.push({...o,modifer_cat:e.modifier_category_id||e.modifier_cat_id,_catIdx:t})})});let o=[];(e.modifiers||[]).forEach(t=>{var a,i,l;let n=r.find(e=>String(e.modifier_item_id)===String(t.modifier_item_id));if(!n){m=!0;return}let s="".concat(null!==(i=null!==(a=n.modifer_category_sequence)&&void 0!==a?a:n._catIdx)&&void 0!==i?i:0).concat(null!==(l=n.modifiersequence)&&void 0!==l?l:0);o.push({is_tax_rate_same:n.is_tax_rate_same||1,modifer_cat:n.modifer_cat,modifier_category_id:n.modifer_cat,modifier_sequence:s,item_id:e.item_id,modifier_item_id:n.modifier_item_id,modifier_item_price:parseFloat(n.price)||0,modifier_item_name:n.modifier_item_name||"",modifier_item_name_v1:n.modifier_item_name_v1,quantity:Number(t.quantity)||1,tax_id:n.product_tax_id||n.tax_id||[],tax_rate:n.tax_rate||0,ieps_tax:n.ieps_tax||null,linked_product:n.linked_product||null,price_list_id:n.price_list_id||""})});let a=o.reduce((e,t)=>e+(parseFloat(t.modifier_item_price)||parseFloat(t.price)||0)*(t.quantity||1),0),i=parseFloat(t.price)||0;p.push({...t,item_price:i,item_price_with_modifier:i+a,quantity:parseInt(e.quantity)||1,special_instruction:e.special_instruction||"",item_modifiers:o,promotion_discount:0,promotion_discount_modifier:0,item_trx_id:(0,W.NF)(1)})}),console.log("[REORDER] generateReorderCart — result",{matched:p.length,some_missing:m}),0===p.length){d(c("items_not_prev_cart"));return}m&&d(c("some_items_removed")),_((null===(a=e.order_id)||void 0===a?void 0:a.toString())||""),n(p),localStorage.setItem("cartItemDetails_".concat(t),JSON.stringify(p)),s(!1),console.log("[REORDER] generateReorderCart — cartItemDetails set with",p.length,"items")},[i,t,d,c]);return(0,u.useEffect)(()=>{var e;let i;if(!t||!(null==r?void 0:r.restaurant_id))return;let n=localStorage.getItem("reorder_data_".concat(t));if(!n)return;try{i=JSON.parse(n),localStorage.removeItem("reorder_data_".concat(t))}catch(e){console.error("[REORDER] Failed to parse reorder data:",e),localStorage.removeItem("reorder_data_".concat(t));return}console.log("[REORDER] Step 1 — reorder detected",{order_id:i.order_id,branch_id:i.branch_id,order_type:i.order_type,item_count:null===(e=i.order_items)||void 0===e?void 0:e.length});let s="takeout"===i.order_type?"pickup":"delivery",d="".concat(window.location.origin,"/");(async()=>{try{var e,n;console.log("[REORDER] Step 1 — calling menu API for branch",i.branch_id,"mode",s);let c=await (0,es._)(t,i.branch_id,r.restaurant_id,r.brand_id||"",s,o,a,d),u=null==c?void 0:null===(e=c.data)||void 0===e?void 0:e.menu_type;console.log("[REORDER] Step 1 — menu API response",{status_code:null==c?void 0:c.status_code,menu_length:null!==(n=null==u?void 0:u.length)&&void 0!==n?n:0}),u&&u.length>0?(await (0,eN.tE)("branchMenuDetail_".concat(t),u),console.log("[REORDER] Step 1 — IndexedDB updated, setting pendingReorderRef and branchMenuDetail"),p.current=i,l(u)):(console.warn("[REORDER] Step 1 — no fresh menu from API, falling back to cached menu"),v(i))}catch(e){console.error("[REORDER] Step 1 — menu API failed:",e),v(i)}})()},[t,null==r?void 0:r.restaurant_id]),(0,u.useEffect)(()=>{let e=Array.isArray(i)?i.length>0:!!i;
1if(console.log("[REORDER] Step 2 fired",{menuReady:e,pendingReorder:!!p.current,menuLength:Array.isArray(i)?i.length:"not array"}),!e||!p.current)return;let t=p.current;p.current=null,console.log("[REORDER] Step 2 — calling generateReorderCart with fresh menu"),v(t)},[i,v]),{reorderSourceId:m,pendingReorderRef:p}}({alias:tU,resturantsettings:tz,session_id:oR,version:oB,branchMenuDetail:rE,setBranchMenuDetail:rA,setCartItemDetails:e6,setIsCartUpdated:aL,openFailureModalFunc:oF,t:t$});(0,u.useEffect)(()=>{console.log(rE,(null==e3?void 0:e3.length)>0,rm,typeof rE,"hey",rE.length>0&&(null==e3?void 0:e3.length)>0)},[rE,e3,rm]);let ln=()=>{let e,t;if(rE&&("true"===localStorage.getItem("current_scheduledOrder__".concat(tU))?(e=rE.menu_type||rE,t=!!rE):(e=rE,t=Array.isArray(rE)?rE.length>0:!!rE)),t&&(null==e3?void 0:e3.length)>0&&rm)try{let t=lj(e,e3);console.log("Validated items in handleConfirmBranch:",t.length);let r=e3.filter(e=>!t.some(t=>t.item_id==e.item_id));t.length!==e3.length&&(e6(t),localStorage.setItem("cartItemDetails_".concat(rm),JSON.stringify(t)),aL(!1),r.length>0&&setTimeout(()=>{a6(r),a3(!0)},200)),localStorage.removeItem("handleBranchClickCaller_".concat(rm))}catch(e){console.error("Error validating cart items:",e),oF(t$("error_validating_cart"))}};(0,u.useEffect)(()=>{let e="hasShownUpsellingPopup_".concat(tU),t=localStorage.getItem((0,tl.bI)(tU)),r="true"===localStorage.getItem(e),o="true"===localStorage.getItem("callin_open_payment"),a=e=>console.log("[upsell] not shown: ".concat(e));if(!r9){if(ot.current)return a("callin order (suppressed)");if(!t6.pathname.includes("cart"))return a("not on the cart page");if(o)return a("callin_open_payment is set");if(r)return a('already shown this visit — run localStorage.removeItem("'.concat(e,'") and reload'));if(t&&"[]"!==t)try{let e=Array.isArray(e3)?e3:[];if(0===e.length){let t=localStorage.getItem("cartItemDetails_".concat(tU));if(t){let r=JSON.parse(t);e=Array.isArray(r)?r:[]}}let r=localStorage.getItem("scheduledOrder_".concat(tU)),o=JSON.parse(t),a=(0,tl.Xl)({rules:o,cartItems:e,restaurantSettings:tz,scheduledOrder:r?JSON.parse(r):null});if(ls(o,e,a),a.length>0){r1(a),r2.current=a,oe(!0);return}}catch(e){console.error("[upsell] failed to parse stored rules:",e)}else a("".concat((0,tl.bI)(tU)," is ").concat(t?"an empty list":"missing"," — open the menu page and pick a branch so the rules get stored"))}},[e3]),(0,u.useEffect)(()=>{if(!r9)return;if(ot.current){oe(!1);return}if(ow||rH||rT||a4){console.log("[upsell] queued, waiting for another modal to close:",{showBranchConfirmModal:ow,changeModeModal:rH,openMode:rT,showUnavailableItemsModal:a4});return}let e=setTimeout(()=>{console.log("[upsell] opening the offers popup"),r4(!0),r8(!0),localStorage.setItem("hasShownUpsellingPopup_".concat(tU),"true"),oe(!1)},400);return()=>clearTimeout(e)},[r9,ow,rH,rT,a4,tU]),(0,u.useEffect)(()=>{(null==tz?void 0:tz.restaurant_id)&&(0,t1.r)(tz.restaurant_id)},[null==tz?void 0:tz.restaurant_id]),(0,u.useEffect)(()=>{(null==tz?void 0:tz.restaurant_id)&&(async()=>{try{var e,t,r;let o=localStorage.getItem("selected_branchmode_".concat(tU)),a=localStorage.getItem("scheduledOrder_".concat(rm));if(!o||"true"===a)return;let i=JSON.parse(o);if("delivery"!==i.mode)return;
1let l=(0,ec.z)(),n={restaurant_alias:tz.alias||tU,formatted_address:i.branch.formatted_address,restaurant_id:tz.restaurant_id,lat:i.branch.latitude,long:i.branch.longitude,session_id:oR,version:oB,source:"EcomV2",lang:tz.lang,ui_request_timestamp:new Date().toISOString()},s="".concat(window.location.origin,"/"),d="https://order.foodbot.ai/apiv2";s&&(d=s+"apiv2");let c=await fetch("".concat(d,"/ecom/v1/branches-delivery"),{method:"POST",headers:l,body:JSON.stringify(n)}),u=await c.json(),m=null==u?void 0:null===(e=u.data)||void 0===e?void 0:e[0];if("success"!==u.status||!m)return;let _=null===(r=m.schedule_settingss)||void 0===r?void 0:null===(t=r.delivery)||void 0===t?void 0:t.status;if(![0,1].includes(_))return;let p={restaurant_id:tz.restaurant_id,branch_id:m.branch_id,is_schedule:!1,order_type:"delivery",source:{lat:Number(i.branch.latitude),lng:Number(i.branch.longitude)},destination:{lat:Number(i.branch.latitude),lng:Number(i.branch.longitude)},address:i.branch,is_callin:!1,lang:t3,api_source:"EcomV2",session_id:oR,version:oB,ui_request_timestamp:new Date().toISOString()},v=await fetch("".concat(d,"/ecom/v1/payment-settings"),{method:"POST",headers:l,body:JSON.stringify(p)});await v.json()}catch(e){console.error("handleDeliveryCheck failed:",e),null==oF||oF(t$("Something went wrong"))}})()},[null==tz?void 0:tz.restaurant_id]);let ls=(e,t,r)=>{Array.isArray(e)&&0!==e.length&&(console.groupCollapsed("[upsell] ".concat(r.length,"/").concat(e.length," rule(s) triggered")),console.table(t.map(e=>({in_cart:null==e?void 0:e.item_name,item_id:null==e?void 0:e.item_id,category_id:null==e?void 0:e.category_id}))),console.table(e.map(e=>{let o=null==e?void 0:e.trigger_condition,a=(0,tl.iB)(e,t),i=r.some(e=>e.trigger_condition===o),l=(null==e?void 0:e.products)||[],n=Array.isArray(null==e?void 0:e.upgrade)?e.upgrade:(null==e?void 0:e.upgrade)?[e.upgrade]:[],s="";return i||(s=a?0===l.length&&0===n.length?"rule offers nothing":n.length>0&&!n.some(e=>(null==e?void 0:e.type)==="category"?t.some(t=>(null==t?void 0:t.category_id)==e.from_category_id):null==e||!e.from_product_id||t.some(t=>(null==t?void 0:t.item_id)==e.from_product_id))?"no candidate swap's from-item/category is in the cart (category swaps fall back to the trigger line)":"offered items already in the cart, or outside their menu_timing":"trigger not in cart"),{tab:null==e?void 0:e.tab,needs:null==o?void 0:o.type,needs_id:(null==o?void 0:o.product_id)||(null==o?void 0:o.category_id),triggered:a,products:l.map(e=>e.item_name).join(", "),upgrade:n.map(e=>{var t,r,o,a,i,l,n,s,d,c,u;return"".concat(null!==(d=null!==(s=null!==(n=null!==(l=null!==(i=null===(t=e.from_item)||void 0===t?void 0:t.item_name)&&void 0!==i?i:null===(r=e.from_category)||void 0===r?void 0:r.category_name)&&void 0!==l?l:null===(o=e.product_item)||void 0===o?void 0:o.item_name)&&void 0!==n?n:e.from_product_id)&&void 0!==s?s:e.from_category_id)&&void 0!==d?d:"?"," -> ").concat(null!==(u=null!==(c=null===(a=e.to_item)||void 0===a?void 0:a.item_name)&&void 0!==c?c:e.to_product_id)&&void 0!==u?u:"?")}).join(" | "),shown:i,dropped_because:s}})),console.groupEnd())},ld=()=>{r4(!1),r8(!0),localStorage.setItem("hasShownUpsellingPopup_".concat(tU),"true")},lc=null==rX?void 0:rX.branch_id,lu=(0,u.useCallback)(()=>{localStorage.getItem("loggedin_".concat(tU))&&(aP(!0),e9(!1),setTimeout(()=>{let e="/".concat(t6.query.resturant);t6.push({pathname:e}),localStorage.removeItem("hasShownUpsellingPopup_".concat(tU))},200))},[t6,e9]);(0,u.useEffect)(()=>{ab||console.log("Google Maps is initializing...")},[ab]),(0,u.useEffect)(()=>{if(tU){r_(tU);let e="profile_check_".concat(tU),t=localStorage.getItem(e);if(t)try{let e=JSON.parse(t);t_(e)}catch(e){console.error("Failed to parse user details:",e)}}},[t6.query.resturant]),(0,u.useEffect)(()=>{if(0!==e3.length)return(async()=>{try{await lh()}catch(e){console.error("fetchTaxDetails failed:",e),oF(t$("Cart calculation failed"))}})(),()=>{var e;return null===(e=lh.cancel)||void 0===e?void 0:e.call(lh)}},[e3,rw,rj,oX,aH,t8,null==eB?void 0:null===(I=eB.data)||void 0===I?void 0:I.multipleoffer_redeem,aT,aH,oW,ta,r$,i_]),(0,u.useEffect)(()=>{0===eK.total&&tc&&(console.log("Total is 0, clearing payment method selection"),tu(null),tn({}),rQ(""),rn(null))},[eK.total,tc]);let lm={phone_number:null==tm?void 0:tm.phone_number,restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,payment_gateway_id:1,email:null==tm?void 0:tm.email,st_id:lt,session_id:oR},l_={restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,payment_gateway_id:3,st_id:lo,email:(null==tm?void 0:tm.email)||"",member_id:(null==tm?void 0:tm.member_id)||"",phone_number:(null==tm?void 0:tm.phone_number)||"",session_id:oR,request_timestamp:new Date().toISOString()},lp=async()=>{try{let e=await tq(l_);e&&"success"===e.status&&e.data?(ib(e.data),console.log("Billpocket cards loaded:",e.data)):ib([])}catch(e){console.error("Failed to fetch billpocket cards:",e),ib([])}},lv=async()=>
1{if(iT)try{eQ(!0),iV(t$("removing")),iC(!0);let e={member_id:(null==tm?void 0:tm.member_id)||"",restaurant_id:(null==tz?void 0:tz.restaurant_id)||"",subscription_id:iT.card_id,phone_number:(null==tm?void 0:tm.phone_number)||"",st_id:lo},t=await tL(e);"success"===t.status?(await lp(),iP(!1),iL(null),rQ(""),tu(null),tn({}),iY(),oI(t$("Card deleted successfully"))):oF(t.message||t$("Failed to delete card"))}catch(e){console.error("Error deleting Billpocket card:",e),oF(t$("An error occurred while deleting the card"))}finally{eQ(!1),iC(!1),iV("")}},lg=e=>{iz(e),iX?(eP(!1),setTimeout(()=>iR(!0),520)):iR(!0)},lf=async()=>{if(!(null==iB?void 0:iB.token))return;let e=iB.token;try{eQ(!0),iV(t$("removing")),iC(!0);let t=await t0({restaurant_id:(null==tz?void 0:tz.restaurant_id)||"",branch_id:lc||"",phone_number:(null==tm?void 0:tm.phone_number)||"",card_token:e});if(t.cardIsGone){iR(!1),iz(null),eU(t=>Array.isArray(t)?t.filter(t=>(null==t?void 0:t.token)!==e):t),rn(null),oI(t$("Card deleted successfully"));return}409===t.statusCode?oF(t$("card_delete_not_configured")):502===t.statusCode?oF(t$("card_delete_gateway_error")):oF(t$("Failed to delete card"))}catch(e){console.error("Error deleting NetPay card:",e),oF(t$("An error occurred while deleting the card"))}finally{eQ(!1),iC(!1),iV("")}};(0,u.useEffect)(()=>{let e=localStorage.getItem("selected_billpocket_card_".concat(rm)),t="true"===localStorage.getItem("is_paying_with_saved_billpocket_card_".concat(rm));if(e&&t)try{let t=JSON.parse(e);iN(t),ik(!0)}catch(e){console.error("Error parsing saved billpocket card:",e)}},[rm]),(0,u.useEffect)(()=>{if(e3.length>0&&!os&&!ai){var e,t,r,o,a,i;let l=null==eB?void 0:null===(t=eB.data)||void 0===t?void 0:null===(e=t.Payment_settings)||void 0===e?void 0:e.find(e=>7===e.gateway_id),n=null==eB?void 0:null===(o=eB.data)||void 0===o?void 0:null===(r=o.Payment_settings)||void 0===r?void 0:r.find(e=>1===e.gateway_id),s=null==eB?void 0:null===(i=eB.data)||void 0===i?void 0:null===(a=i.Payment_settings)||void 0===a?void 0:a.find(e=>3===e.gateway_id);l?(od(!0),(async()=>{try{await nd(l)}catch(e){console.error("cardListapi failed:",e)}})()):n&&(od(!0),lm.email?(async()=>{try{let e=await tM(lm);if(e){eH((null==e?void 0:e.cards)||[]);let t=(null==e?void 0:e.pg_customer_id)||"";a9(t)}}catch(e){console.error("getMercadoPagoCardsList failed:",e),eH([]),a9("")}})():(console.warn("Skipping getMercadoPagoCardsList: email is empty"),eH([]),a9(""))),s&&(s.public_key&&iF(s.public_key),iA(s.sandboxMode||!1),iO(s.saveCardEnabled||!1),od(!0),s.saveCardEnabled?(async()=>{try{await lp()}catch(e){console.error("fetchBillpocketCardsList failed:",e)}})():ib([]))}},[e3,eB,ai]);let ly=(e,t,r)=>{let o=null,a=null,i=localStorage.getItem("payment_method_".concat(tU)),l=i?JSON.parse(i):null,n=(null==l?void 0:l.data)||r;if(!n||!n.Charges_details||!n.delivery_partners)return console.error("Invalid paymentMethods data:",n),{deliveryPartnerAssigned:o,errorMessage:a=t$("invalid_payment_methods_data")};if(r=n,!e3||!Array.isArray(e3))return console.error("Invalid cartItemDetails:",e3),{deliveryPartnerAssigned:o,errorMessage:a=t$("invalid_cart_data")};if((null==t?void 0:t.order_type)==="delivery"&&(null==r?void 0:r.Charges_details)){var s,d,c,u;let t;if(!tU)return console.error("Alias is undefined"),{deliveryPartnerAssigned:o,errorMessage:a=t$("invalid_restaurant_al
1ias")};let i=JSON.parse(localStorage.getItem("scheduledOrder_".concat(tU))||"null"),l=(null==rX?void 0:rX.timezone)||"Etc/GMT+6";if(i&&i.date&&i.time){if("ASAP"===i.time)t=e7()().tz(l);else{if(!e7()("".concat(i.date,"T").concat(i.time)).isValid())return console.error("Invalid scheduled order date or time:",i),{deliveryPartnerAssigned:o,errorMessage:a=t$("invalid_scheduled_order_time")};t=e7().tz("".concat(i.date,"T").concat(i.time),(null===(d=i.branch)||void 0===d?void 0:d.timezone)||l),l=(null===(c=i.branch)||void 0===c?void 0:c.timezone)||l}}else t=e7()().tz(l);if(!t.isValid())return console.error("Invalid checkTime:",t),{deliveryPartnerAssigned:o,errorMessage:a=t$("invalid_time_detected")};let n=e7()("1970-01-01T".concat(t.format("HH:mm:ss")));console.log("Alias for localStorage key:",tU),console.log("Current localStorage before update:",localStorage.getItem("selected_delivery_partner_".concat(tU)));let m=e3.reduce((e,t)=>e+t.item_price_with_modifier*t.quantity,0);console.log("Calculated Cart Value:",m);let _=(null==r?void 0:r.delivery_partners)||[],p=null==r?void 0:r.Charges_details;if(1===p.cartvalue_based_pricing&&(null===(s=p.cartvalue_pricing_details)||void 0===s?void 0:s.length)){let t=null===(u=p.cartvalue_pricing_details)||void 0===u?void 0:u.find(e=>m>=parseFloat(e.cart_minvalue)&&(0===parseFloat(e.cart_maxvalue)||m<=parseFloat(e.cart_maxvalue)));if(!t){console.warn("No matching cartvalue_pricing_details found.");let e=p.cartvalue_pricing_details||[];return{deliveryPartnerAssigned:o,errorMessage:a=t$("cart_value_not_in_range",{minAmount:e.length?Math.min(...e.map(e=>parseFloat(e.cart_minvalue||"0"))):0})}}let r=t.delivery_partners.map((e,t)=>{let r=_.find(t=>t.partner_id===e.partner_id);if(!r)return null;let o=parseFloat(e.delivery_cost),{start_time:a,end_time:i}=r.available_timings,l=e7()("1970-01-01T".concat(5===a.length?"".concat(a,":00"):a)),s=e7()("1970-01-01T".concat(5===i.length?"".concat(i,":00"):i));return(s.isAfter(l)&&n.isSameOrAfter(l)&&n.isSameOrBefore(s)||s.isBefore(l)&&(n.isSameOrAfter(l)||n.isSameOrBefore(s)))&&!isNaN(o)?{...e,_cost:o,_originalIndex:t,available_timings:r.available_timings,cost_share:o}:null}).filter(e=>null!==e).sort((e,t)=>10015==e.partner_id?1:10015==t.partner_id?-1:e._cost-t._cost);for(let t of(console.log("Valid Partners (Cart-based):",r),r)){let r=_.find(e=>e.partner_id===t.partner_id),i=Array.isArray(r.available_payment_methods)?r.available_payment_methods.map(String):[],l=i.includes(String(e))||i.includes("All");if(l&&3===e){let t=eX(r,eK.total||0,e);if(!t.isValid)return{deliveryPartnerAssigned:o,errorMessage:a=t$("cash_order_amount_exceeds_limit",{amount:t.cappingAmount})}}if(l){o={...t};break}}if(o){delete o._originalIndex,delete o._cost,console.log("Selected Delivery Partner (Cart-based):",o);try{localStorage.setItem("selected_delivery_partner_".concat(tU),JSON.stringify(o)),console.log("localStorage updated successfully:",localStorage.getItem("selected_delivery_partner_".concat(tU)))}catch(e){console.error("Failed to update localStorage:",e),a=t$("local_storage_update_failed")}aG(o.cost_share)}else console.log("No valid partners found, removing selected_delivery_partner"),localStorage.removeItem("selected_delivery_partner_".concat(tU)),aG(null),a=t$("no_delivery_partners_available")}else{console.log("Processing non-cart-based pricing");let t=_.map((e,t)=>{let r=parseFloat(e.actual_delivery_charges),o=null!=e.cost_share?parseFloat(e.cost_share):r,a=isNaN(o)?r:o,{start_time:i,end_time:l}=e.available_timings,s=e7()("1970-01-01T".concat(5===i.length?"".concat(i,":00"):i)),d=e7()("1970-01-01T".concat(5===l.length?"".concat(l,":00"):l));return(d.isAfter(s)&&n.isSameOrAfter(s)&&n.isSameOrBefore(d)||d.isBefore(s)&&(n.isSameOrAfter(s)||n.isSameOrBefore(d)))&&!isNaN(a)?{...e,_cost:a,_originalIndex:t,cost_share:a}:null}).filter(e=>null!==e).sort((e,t)=>10015==e.partner_id?1:10015==t.partner_id?-1:e._cost-t._cost);for(let r of(console.log("Valid Partners (Non-cart-based):",t),t)){let t=Array.isArray(r.available_payment_methods)?r.available_payment_methods.map(String):[],i=t.includes(String(e))||t.includes("All");if(i&&3===e){let t=eX(r,eK.total||0,e);if(!t.isValid)return{deliveryPartnerAssigned:o,errorMessage:a=t$("cash_order_amount_exceeds_limit",{amount:t.cappingAmount})}}if(i){o={...r};break}}if(o){delete o._originalIndex,delete o._cost,console.log("Selected Delivery Partner (Non-cart-based):",o);try{localStorage.setItem("selected_delivery_partner_".concat(tU),JSON.stringify(o)),console.log("localStorage updated successfully:",localStorage.getItem("selected_delivery_partner_".concat(tU)))}catch(e){console.error("Failed to update localStorage:",e),a=t$("local_storage_update_failed")}aG(o.cost_share)}else console.log("No valid partners found, removing selected_delivery_partner"),localStorage.removeItem("selected_delivery_partner_".concat(tU)),aG(null),a=t$("no_delivery_partners_available")}}else console.log("Not a delivery order or missing Charges_details.");return{deliveryPartnerAssigned:o,errorMessage:a}};console.log("\uD83D\uDE80 useEffect triggered savepayment",eB),(0,u.useEffect)(()=>{var e,t;let r=localStorage.getItem("payment_method_".concat(tU)),o=r?JSON.parse(r):null,a=(null==o?void 0:o.data)||(null==eB?void 0:eB.data),i=null==a?void 0:a.Charges_details,l=(null==a?void 0:a.delivery_partners)||[],n=JSON.parse(localStorage.getItem("scheduledOrder_".concat(tU))||"null");if(!i||!(null==e3?void 0:e3.length)||"delivery"!==e5||!a||!(null==a?void 0:null===(e=a.delivery_partners)||void 0===e?void 0:e.length)||!(null==a?void 0:a.Charges_details)){console.log("\uD83D\uDED1 Guard clause triggered - missing required data:",{hasChargesDetails:!!i,hasCartItems:!!(null==e3?void 0:e3.length),deliveryMode:e5,hasPaymentData:!!a,hasDeliveryPartners:!!(null==a?void 0:null===(t=a.delivery_partners)||void 0===t?void 0:t.length),hasChargesDetailsNested:!!(null==a?void 0:a.Charges_details)});return}let s=e=>{try{var t,r,o;let a;let s=e3.reduce((e,t)=>
1e+t.item_price_with_modifier*t.quantity,0);localStorage.setItem("delivery_partners_".concat(tU),JSON.stringify(l));let d=(null==rX?void 0:rX.timezone)||"Etc/GMT+6";if(n&&n.date&&n.time){if("ASAP"===n.time)a=e7()().tz(d);else if(e7()("".concat(n.date,"T").concat(n.time)).isValid())a=e7().tz("".concat(n.date,"T").concat(n.time),(null===(r=n.branch)||void 0===r?void 0:r.timezone)||d),d=(null===(o=n.branch)||void 0===o?void 0:o.timezone)||d;else{console.error("❌ Invalid scheduled order date or time:",n),oF(t$("invalid_scheduled_order_time"));return}}else a=e7()().tz(d);if(!a.isValid()){console.error("❌ Invalid checkTime:",a),oF(t$("invalid_time_detected"));return}let c=e7()("1970-01-01T".concat(a.format("HH:mm:ss")));if(1===i.cartvalue_based_pricing&&(null===(t=i.cartvalue_pricing_details)||void 0===t?void 0:t.length)>0){let t=i.cartvalue_pricing_details.find(e=>s>=parseFloat(e.cart_minvalue)&&(0===parseFloat(e.cart_maxvalue)||s<=parseFloat(e.cart_maxvalue)));if(!t)return;let r=t.delivery_partners.map((e,t)=>{let r=l.find(t=>t.partner_id===e.partner_id);if(!r)return null;let o=parseFloat(e.delivery_cost),{start_time:a,end_time:i}=r.available_timings;a=a.trim(),i=i.trim(),a="1970-01-01T".concat(5===a.length?"".concat(a,":00"):a),i="1970-01-01T".concat(5===i.length?"".concat(i,":00"):i);let n=e7()(a),s=e7()(i);return n.isValid()&&s.isValid()?(s.isAfter(n)&&c.isSameOrAfter(n)&&c.isSameOrBefore(s)||s.isBefore(n)&&(c.isSameOrAfter(n)||c.isSameOrBefore(s)))&&!isNaN(o)?{...e,_cost:o,_originalIndex:t,available_timings:r.available_timings,cost_share:o}:null:(console.error("Invalid start or end time detected:",{start_time:a,end_time:i}),null)}).filter(e=>null!==e).sort((e,t)=>10015==e.partner_id?1:10015==t.partner_id?-1:e._cost-t._cost),o=null;for(let t of r){let r=l.find(e=>e.partner_id===t.partner_id),a=Array.isArray(r.available_payment_methods)?r.available_payment_methods.map(String):[];if(!e||a.includes(String(e))||a.includes("All")){o={...t};break}}o?(delete o._originalIndex,delete o._cost,o.cost_share!==aH&&aG(o.cost_share),console.log("\uD83D\uDCCC Updating localStorage in useEffect:",o),localStorage.setItem("selected_delivery_partner_".concat(tU),JSON.stringify(o))):(aG(null),localStorage.removeItem("selected_delivery_partner_".concat(tU)),oF(t$("no_delivery_partners_available")))}else{if(0!==i.cartvalue_based_pricing)return;let t=l.map((e,t)=>{let r=parseFloat(e.cost_share),{start_time:o,end_time:a}=e.available_timings;o=o.trim(),a=a.trim(),o="1970-01-01T".concat(5===o.length?"".concat(o,":00"):o),a="1970-01-01T".concat(5===a.length?"".concat(a,":00"):a);let i=e7()(o),l=e7()(a);if(!i.isValid()||!l.isValid())return console.error("Invalid start or end time detected:",{start_time:o,end_time:a}),null;let n=l.isAfter(i)&&c.isSameOrAfter(i)&&c.isSameOrBefore(l)||l.isBefore(i)&&(c.isSameOrAfter(i)||c.isSameOrBefore(l)),s=parseFloat(e.actual_delivery_charges),d=null!=e.cost_share?parseFloat(e.cost_share):s,u=isNaN(d)?s:d;return n&&!isNaN(r)?{...e,_cost:r,_originalIndex:t,cost_share:u}:null}).filter(e=>null!==e).sort((e,t)=>10015==e.partner_id?1:10015==t.partner_id?-1:e._cost-t._cost),r=null;for(let o of t){let t=Array.isArray(o.available_payment_methods)?o.available_payment_methods.map(String):[];if(!e||t.includes(String(e))||t.includes("All")){r={...o};break}}r?(delete r._originalIndex,delete r._cost,r.cost_share!==aH&&aG(r.cost_share),console.log("\uD83D\uDCCC Updating localStorage in useEffect (no cart value):",r),localStorage.setItem("selected_delivery_partner_".concat(tU),JSON.stringify(r))):(aG(null),localStorage.removeItem("selected_delivery_partner_".concat(tU)),console.error("❌ No delivery partner available (no cart value)"),oF(t$("no_delivery_partners_available")))}}catch(e){console.error("\uD83D\uDD25 Error processing delivery partners:",e),oF(t$("error_processing_delivery_partners"))}};(null==ta?void 0:ta.payment_method_id)?(console.log("\uD83D\uDCA1 Payment selected",ta.payment_method_id),s(ta.payment_method_id)):(console.log("\uD83D\uDCA1 No payment selected"),s())},[e3,eB,e5,t6.query.resturant,aH,ta,t$]);let lh=b()(async()=>{var e,t,r,o,a,i,l,n,s,d,c,u,m,_,p,v,g,f,y,h,x,b,N;localStorage.getItem("handleBranchClickCaller_".concat(rm));let j=(null==tz?void 0:null===(e=tz.ecom_settings)||void 0===e?void 0:e.taxes.map(e=>({...e,tax_rate:parseFloat(e.tax_rate)||0})))||[],S=e3.map(e=>{var t,r;let o=0,a={...e,promotion_discount_modifier:0,promotion_discount:0,item_price_with_modifier:parseFloat(e.item_price_with_modifier)||0,quantity:Math.max(parseInt(e.quantity)||1,1)};return 1===e.isPackage&&(null===(t=e.package_items)||void 0===t?void 0:t.length)>0?(a.package_items=e.package_items.map(e=>{var t;let r=0,i={...e,promotion_discount_modifier:0,promotion_discount:0,item_price_with_modifier:parseFloat(e.item_price_with_modifier)||0};if((null===(t=e.modifiers)||void 0===t?void 0:t.length)>0)i.modifiers=e.modifiers.map(e=>(r+=(parseFloat(e.modifier_item_price)||0)*(e.quantity||1),{...e,promotion_discount:0,promotion_discount_modifier:0}));else if("ungrouped"==e.type&&(!e.cat_items_modifiercat||0===e.cat_items_modifiercat.length)){let t=(e.quantity||1)/Math.max(a.quantity||1,1);r+=(parseFloat(e.price)||0)*t}return o+=r,i.item_price_with_modifier=(parseFloat(i.price)||0)+r,i}),a.item_price_with_modifier=(parseFloat(a.item_price)||0)+o):(null===(r=e.item_modifiers)||void 0===r?void 0:r.length)>
10&&(e.item_modifiers.forEach(e=>{let t=parseFloat(e.price)||parseFloat(e.modifier_item_price)||0;o+=t*(e.quantity||1)}),a.item_modifiers=e.item_modifiers.map(e=>({...e,promotion_discount_modifier:0,modifier_item_price:parseFloat(e.price)||parseFloat(e.modifier_item_price)||0,points_discount:0})),a.item_price_with_modifier=parseFloat(e.item_price_with_modifier)||(parseFloat(a.item_price)||0)+o),a.total_item_price=a.item_price_with_modifier*a.quantity,a}),C=S.reduce((e,t)=>e+(t.total_item_price||(parseFloat(t.item_price_with_modifier)||0)*(t.quantity||1)),0);aZ(C);let I=Number(null!==(c=null==tz?void 0:null===(r=tz.ecom_settings)||void 0===r?void 0:null===(t=r.general_settings)||void 0===t?void 0:t.enable_delivery_points_usage)&&void 0!==c?c:0),F=C,E=null!==tC&&C>=tC;E&&1===I&&aH?(F+=Number(aH),console.log("Debug: Added deliveryCharges to totalCoverableAmount:",aH)):console.log("Debug: Skipped adding deliveryCharges. Reasons:",{isMinimumOrderAmountNull:null===tC,isMinimumOrderAmountZeroOrNegative:tC<=0,isTotalBelowMinimum:C<tC,isDeliveryPointsDisabled:1!==I,isDeliveryChargesMissing:!aH}),E&&eK.service?(F+=Number(eK.service),console.log("Debug: Added service charge to totalCoverableAmount:",eK.service)):console.log("Debug: Skipped adding service charge. Reasons:",{isMinimumOrderAmountNull:null===tC,isMinimumOrderAmountZeroOrNegative:tC<=0,isTotalBelowMinimum:C<tC,isServiceChargePointsDisabled:!1,isServiceChargeMissing:!eK.service}),console.log("Debug: Final totalCoverableAmount:",F);let A=0;oX&&oW&&(A=Number(oW.store_value)>=F?F:Number(oW.store_value));let D=oW&&oW.store_value&&oW.points?Number(oW.store_value)/oW.points:1,O=A>0?Math.min(oW.points,Math.ceil(A/D)):0;console.log("Debug: pointsToApply:",A),console.log("Debug: pointsRedeemed:",O);let M={order_type:e5&&e5,request_id:aB||(0,W.NF)(2),restaurant_id:null==tz?void 0:tz.restaurant_id,brand_id:null==tz?void 0:tz.brand_id,branch_id:lc,order_items:{item_details:S.map(e=>{var t,r;let{item_display_text_v1:o,item_description_v1:a,...i}=e;return{...i,item_modifiers:null!==(r=null===(t=i.item_modifiers)||void 0===t?void 0:t.map(e=>{let{modifier_item_name_v1:t,...r}=e;return r}))&&void 0!==r?r:i.item_modifiers,points_discount:i.quantity>1?(parseFloat(i.item_price_with_modifier)||0)*i.quantity:parseFloat(i.item_price_with_modifier)||0}})},tax_settings:j,tip_type:rw,tip_value:rj,tax_type:null==tz?void 0:tz.tax_type,delivery_cost:aH,service_amount:((null==ta?void 0:ta.payment_method_id)===1||"Credit Card"===r$)&&(null==eB?void 0:null===(a=eB.data)||void 0===a?void 0:null===(o=a.Charges_details)||void 0===o?void 0:o.service_charge)||0,...(null==eB?void 0:null===(i=eB.data)||void 0===i?void 0:i.multipleoffer_redeem)=="yes"?{...t8&&Object.keys(t8).length>0&&{promotion_applied:(0,w.H)(t8)},...oX&&oW&&{store_value:A,store_value_without_roundoff:Number(oW.store_value),loyalty_points_details:{points:oW.points,redeemable:oW.redeemable,store_value:A,redeem_categories:oW.redeem_categories,original_store_value:Number(oW.store_value),status:!0,points_redeemed:O,show_purchase:!1,point_amount:A,full_redemption:A>=C,enable_delivery_points_usage:Number(null!==(u=null==tz?void 0:null===(n=tz.ecom_settings)||void 0===n?void 0:null===(l=n.general_settings)||void 0===l?void 0:l.enable_delivery_points_usage)&&void 0!==u?u:0),enable_service_charge_usage:1},user_detais:{member_id:null==tm?void 0:tm.member_id,first_name:null==tm?void 0:tm.first_name,last_name:null==tm?void 0:tm.last_name,phone_number:null==tm?void 0:tm.mobile_number,country_code:null==tm?void 0:tm.country_code,created_on:new Date().toISOString(),reward_plan_name:null==o0?void 0:o0.plan_name,reward_plan_id:null==o0?void 0:o0.plan_id,calling_code:null==tm?void 0:tm.country_code,name:null==tm?void 0:tm.user_name,mobile:null==tm?void 0:tm.mobile_number}}}:{...t8&&Object.keys(t8).length>0&&{promotion_applied:(0,w.H)(t8)},...oX&&oW&&{store_value:A,store_value_without_roundoff:Number(oW.store_value),loyalty_points_details:{points:oW.points,redeemable:oW.redeemable,store_value:A,redeem_categories:oW.redeem_categories,original_store_value:Number(oW.store_value),status:!0,points_redeemed:O,show_purchase:!1,point_amount:A,full_redemption:A>=C,enable_delivery_points_usage:Number(null!==(m=null==tz?void 0:null===(d=tz.ecom_settings)||void 0===d?void 0:null===(s=d.general_settings)||void 0===s?void 0:s.enable_delivery_points_usage)&&void 0!==m?m:0),enable_service_charge_usage:1},user_detais:{member_id:null==tm?void 0:tm.member_id,first_name:null==tm?void 0:tm.first_name,last_name:null==tm?void 0:tm.last_name,phone_number:null==tm?void 0:tm.mobile_number,country_code:null==tm?void 0:tm.country_code,created_on:new Date().toISOString(),reward_plan_name:null==o0?void 0:o0.plan_name,reward_plan_id:null==o0?void 0:o0.plan_id,calling_code:null==tm?void 0:tm.country_code,name:null==tm?void 0:tm.user_name,mobile:null==tm?void 0:tm.mobile_number}}}};o8.current=M,oX&&console.log("Points + Service Charge payload before calculateTax:",JSON.stringify(M,null,2));try{let e=await (0,k.calculateTax)(M);e.status_code&&200==e.status_code?(localStorage.setItem("cartData_".concat(rm),JSON.stringify(e.data)),tx(e),aA(e.data),eZ({subtotal:(null==e?void 0:null===(p=e.data)||void 0===p?void 0:null===(_=p.order_items)||void 0===_?void 0:_.sub_total)||0,discount:(null==e?void 0:null===(g=e.data)||void 0===g?void 0:null===(v=g.order_items)||void 0===v?void 0:v.discount)||0,tax:(null==e?void 0:null===(y=e.data)||void 0===y?void 0:null===(f=y.order_items)||void 0===f?void 0:f.tax_amount)||0,tip:(null==e?void 0:null===(h=e.data)||void 0===h?void 0:h.tip_amount)||0,service:(null==e?void 0:null===(x=e.data)||void 0===x?void 0:x.service_amount)||0,total:(null==e?void 0:null===(b=e.data)||void 0===b?void 0:b.final_amount)||0}),aL(!0),rh((null==e?void 0:null===(N=e.data)||void 0===N?void 0:N.tip_amount)||0)):console.error("Tax calculation failed:",JSON.stringify(e,null,2))}catch(e){console.error("Error calculating tax:",e),aL(!0)}},300),lx=async e=>
1{let t=(0,ec.z)(),r=JSON.stringify({restaurant_id:e.restaurant_id,branch_id:e.branch_id,cart_json:e.cart_json,brand_id:e.brand_id,phone_number:e.phone_number,member_id:e.member_id,lang:e.lang,request_id:e.request_id,session_id:e.session_id,version:e.version,source:"EcomV2"});try{let e="".concat(window.location.origin,"/"),o="https://order.foodbot.ai/apiv2";e&&(o=e+"apiv2");let a=await fetch("".concat(o,"/ecom/v1/order-carts"),{method:"POST",headers:t,body:r,redirect:"follow"}),i=await a.json();switch(a.status){case 200:"success"===i.status&&console.log("Order cart updated successfully.");break;case 400:console.log("Bad Request:",i.message);break;case 401:console.log("Unauthorized:",i.message);break;case 404:console.log("Not Found:",i.message);break;case 500:console.log("Internal Server Error:",i.message);break;default:console.log("Unexpected error:",i.message)}}catch(e){console.error("API error:",e)}finally{}};(0,u.useEffect)(()=>{let e=setInterval(()=>{let t="loyalty_points_details_".concat(tU),r=localStorage.getItem(t);if(r)try{let t=JSON.parse(r),o={...t,points:isNaN(Number(t.points))?0:Number(t.points),store_value:isNaN(Number(t.store_value))?0:Number(t.store_value),redeemable:t.redeemable||"no",redeem_categories:Array.isArray(t.redeem_categories)?t.redeem_categories.map(e=>{var t,r;return{...e,product_id:null!==(t=e.product_id)&&void 0!==t?t:"0",category_id:null!==(r=e.category_id)&&void 0!==r?r:"0"}}):[]};console.log("Validated pointsdata:",o),oH(o),oY(!0),clearInterval(e)}catch(e){console.error("Error parsing pointsdata:",e),oH({points:0,store_value:0,redeemable:"no",redeem_categories:[]}),oY(!0)}},500);return()=>clearInterval(e)},[t6.query.resturant,localStorage.getItem("loyalty_points_details_".concat(tU))]);let lb=async e=>{var t,r,o,a,i,l,n,s,d,c,u,m,_;let p=(null==tz?void 0:null===(t=tz.ecom_settings)||void 0===t?void 0:t.taxes.map(e=>({...e,tax_rate:parseFloat(e.tax_rate)||0})))||[],v={order_type:e5&&e5,request_id:aB,restaurant_id:null==tz?void 0:tz.restaurant_id,brand_id:null==tz?void 0:tz.brand_id,branch_id:null==aj?void 0:aj.branch_id,order_items:{item_details:e},tax_settings:p,tip_type:rw,tip_value:rj,tip_amount:ry||rx,tax_type:null==tz?void 0:tz.tax_type,store_value:0,delivery_cost:null==eB?void 0:null===(o=eB.data)||void 0===o?void 0:null===(r=o.Charges_details)||void 0===r?void 0:r.delivery_charges,service_amount:ta&&(null==ta?void 0:ta.payment_method_id)===1?null==eB?void 0:null===(i=eB.data)||void 0===i?void 0:null===(a=i.Charges_details)||void 0===a?void 0:a.service_charge:0,...t8&&Object.keys(t8).length>0&&{promotion_applied:(0,w.H)(t8)}};try{let e=await (0,k.calculateTax)(v);return aA(e.data),console.log("res.data :: ",e.data),localStorage.setItem("cartData_".concat(rm),JSON.stringify(e.data)),tx(t=>({...t,...e.data})),eZ({subtotal:(null==e?void 0:null===(n=e.data)||void 0===n?void 0:null===(l=n.order_items)||void 0===l?void 0:l.sub_total)||0,discount:(null==e?void 0:null===(d=e.data)||void 0===d?void 0:null===(s=d.order_items)||void 0===s?void 0:s.discount)||0,tax:(null==e?void 0:null===(u=e.data)||void 0===u?void 0:null===(c=u.order_items)||void 0===c?void 0:c.tax_amount)||0,tip:(null===(m=e.data)||void 0===m?void 0:m.tip_amount)||0,service:(null==e?void 0:e.data.service_amount)||0,total:(null==e?void 0:null===(_=e.data)||void 0===_?void 0:_.final_amount)||0}),e.data}catch(e){throw console.error("Error calculating tax:",e),e}},lw=b()(async e=>{let t=e3.map((t,r)=>{if(r===e){let e=t.quantity+1,r=0;1===t.isPackage?t.package_items=t.package_items.map(o=>{let a=0;console.log("packageItem.quantity :: ",o.quantity),console.log("item.quantity :: ",t.quantity),console.log("newQuantity :: ",e);let i={...o,quantity:o.quantity/t.quantity*e};if(i.modifiers.length>0)i.modifiers.forEach(e=>{a+=parseFloat(e.modifier_item_price)*(e.quantity||1)});else if("ungrouped"===i.type&&(!i.cat_items_modifiercat||0===i.cat_items_modifiercat.length)){let e=o.quantity/t.quantity||1;a+=(parseFloat(i.price)||0)*e}return console.log("itemModifierTotal :: ",a),r+=a,i.item_price_with_modifier=(parseFloat(i.price)||0)+a,i}):r=t.item_modifiers.reduce((e,t)=>
1e+parseFloat(t.modifier_item_price)*(t.quantity||1),0);let o=parseFloat(t.item_price)+r;return{...t,quantity:e,item_price_with_modifier:o.toFixed(2)}}return t});aZ(t.reduce((e,t)=>e+parseFloat(t.item_price_with_modifier),0)),e6(t),localStorage.setItem("cartItemDetails_".concat(rm),JSON.stringify(t)),aL(!1)},300),lN=b()(async e=>{let t=e3.map((t,r)=>{if(r===e&&t.quantity>1){let e=t.quantity-1,r=0;1===t.isPackage?t.package_items=t.package_items.map(o=>{let a=o.quantity>1?o.quantity/t.quantity*e:1,i={...o,quantity:a};if(i.modifiers.length>0)i.modifiers.forEach(e=>{r+=parseFloat(e.modifier_item_price)*(e.quantity||1)});else if("ungrouped"==i.type&&(!i.cat_items_modifiercat||0===i.cat_items_modifiercat.length)){let e=o.quantity/t.quantity||1;r+=(parseFloat(i.price)||0)*e}return i}):r=t.item_modifiers.reduce((e,t)=>e+parseFloat(t.modifier_item_price)*(t.quantity||1),0);let o=parseFloat(t.item_price)+r;return{...t,quantity:e,item_price_with_modifier:o.toFixed(2)}}return t});aZ(t.reduce((e,t)=>e+parseFloat(t.item_price_with_modifier),0)),e6(t),localStorage.setItem("cartItemDetails_".concat(rm),JSON.stringify(t)),aL(!1)},300),lj=(e,t)=>{if(!e||!Array.isArray(t))return console.error("Invalid branchMenuDetail or cartItems",{branchMenuDetail:e,cartItems:t}),[];let r=[];return t.forEach(t=>{var o,a,i,l,n,s;let d=!1,c=JSON.parse(JSON.stringify(t));if(1==t.isPackage&&Array.isArray(t.package_items)){console.log("Processing package item: ".concat(t.item_id));let r=localStorage.getItem("cartData_".concat(rm)),n=!1;if(r)try{let e=JSON.parse(r);e&&(null==e?void 0:null===(a=e.order_items)||void 0===a?void 0:a.item_details)&&(null==e?void 0:null===(i=e.order_items)||void 0===i?void 0:i.item_details.length)>0&&(n=(null==e?void 0:null===(l=e.order_items)||void 0===l?void 0:l.item_details[0].disabled_item)===!0,console.log("Found disabled_item in localStorage: ".concat(n," for item ").concat(t.item_id)))}catch(e){console.error("Error parsing cartData from localStorage:",e)}let s=Array.isArray(e)?e.find(e=>e.menu_id==t.menu_id):e;if(!s){console.log("No menu found with menu_id ".concat(t.menu_id," for item ").concat(t.item_id,", removing"));return}let u=null,m=!1;if(s.item_id==t.item_id&&1==s.isPackage&&(u=s,m=!0),!u&&(null==s?void 0:s.menu_category))for(let e of s.menu_category){if(!e.cat_items)continue;let r=e.cat_items.find(e=>e.item_id==t.item_id);if(r&&e.category_id==t.category_id){u=r,m=!0;break}}if(!m){console.log("Item ".concat(t.item_id," not found in menu ").concat(t.menu_id," or category ").concat(t.category_id,", removing"));return}let _=!0===u.disabled_item;if(console.log("Validating disabled_item for package item ".concat(t.item_id,":"),{localStorageDisabledItem:n,menuDisabledItem:_}),n!==_){console.log("Mismatch in disabled_item for package item ".concat(t.item_id,". ")+"LocalStorage: ".concat(n,", Menu: ").concat(_,". Removing item."));return}let p=(c.package_items||[]).reduce((e,t)=>e+(t.modifiers||[]).reduce((e,t)=>e+(parseFloat(t.modifier_item_price)||0)*(t.quantity||1),0),0);if(c.item_price_with_modifier=(parseFloat(c.item_price||0)+p).toFixed(2),c.item_key="".concat(t.item_id,"-"),(null===(o=c.package_items)||void 0===o?void 0:o.length)>0&&u.grouped_items){console.log("Validating package items for item ".concat(t.item_id));let e=0,r=c.package_items.map(t=>{if("ungrouped"===t.type){var r;return console.log("Keeping ungrouped item ".concat(t.item_id," in package")),(null===(r=t.modifiers)||void 0===r?void 0:r.length)>0&&(e+=t.modifiers.reduce((e,t)=>e+(parseFloat(t.modifier_item_price)||0)*(t.quantity||1),0)),t}let o=!1,a=JSON.parse(JSON.stringify(t));for(let r of u.grouped_items){let i=r.items.find(e=>e.item_id==t.item_id);if(i){let l=r.quantity||1;if(t.quantity>l&&(console.log("Adjusting quantity for ".concat(t.item_id," from ").concat(t.quantity," to ").concat(l)),a.quantity=l),o=!0,a.modifiers&&a.modifiers.length>0){let t=a.modifiers.filter(e=>{if(!e.modifier_item_id)return console.log("Package modifier missing modifier_item_id:",e),!1;let t=!1;if(i.cat_items_modifiercat&&Array.isArray(i.cat_items_modifiercat))for(let r of i.cat_items_modifiercat)r.cat_items_modifiercat_modifieritems&&Array.isArray(r.cat_items_modifiercat_modifieritems)&&r.cat_items_modifiercat_modifieritems.find(t=>t.modifier_item_id==e.modifier_item_id)&&(t=!0);return console.log("Package modifier ".concat(e.modifier_item_id," valid: ").concat(t)),t});a.modifiers=t,e+=t.reduce((e,t)=>
1e+parseFloat(t.modifier_item_price||0)*(t.quantity||1),0)}break}}if(!o&&(null==s?void 0:s.menu_category))for(let r of s.menu_category){if(r.cat_items){let i=r.cat_items.find(e=>e.item_id==t.item_id);if(i&&r.category_id==t.category_id){if(o=!0,a.modifiers&&a.modifiers.length>0){let t=a.modifiers.filter(e=>{if(!e.modifier_item_id)return!1;let t=!1;if(i.cat_items_modifiercat&&Array.isArray(i.cat_items_modifiercat))for(let r of i.cat_items_modifiercat)r.cat_items_modifiercat_modifieritems&&Array.isArray(r.cat_items_modifiercat_modifieritems)&&r.cat_items_modifiercat_modifieritems.find(t=>t.modifier_item_id==e.modifier_item_id)&&(t=!0);return t});a.modifiers=t,e+=t.reduce((e,t)=>e+parseFloat(t.modifier_item_price||0)*(t.quantity||1),0)}break}}if(o)break}return o?a:null}).filter(e=>null!==e);if(r.length===c.package_items.length)c.package_items=r,c.item_price_with_modifier=(parseFloat(c.item_price||0)+e).toFixed(2),console.log("Updated package items for ".concat(t.item_id,":"),r),d=!0;else{console.log("One or more sub-items missing in new branch for combo ".concat(t.item_id,", removing entire combo"));return}}else d=!0}else{let r=Array.isArray(e)?e.find(e=>e.menu_id==t.menu_id):e;console.log("Step 1: Initial matchingMenu based on cartItem.menu_id =",t.menu_id,{matchingMenuFound:!!r,matchingMenu:r});let o=t.menu_id,a=!1,i=null;if(r&&r.menu_category)for(let e of(console.log("Searching for item in matchingMenu.menu_category"),r.menu_category)){console.log("Checking category: ".concat(e.category_id));let r=null===(n=e.cat_items)||void 0===n?void 0:n.find(e=>e.item_id==t.item_id);if(r){if(console.log("Item ".concat(t.item_id," found in category ").concat(e.category_id,", checking category match with cartItem.category_id ").concat(t.category_id)),e.category_id==t.category_id){a=!0,i=r,console.log("Item and category matched. Stopping search in matchingMenu.");break}console.warn("Item ".concat(t.item_id," found but category mismatch: found ").concat(e.category_id,", expected ").concat(t.category_id))}}else console.warn("No menu_category found in matchingMenu or matchingMenu is null.");if(!a&&Array.isArray(e))for(let l of(console.log("Item not found in original menu_id. Searching across all menus..."),e))if(console.log("Checking menu_id:",l.menu_id),l.menu_category){for(let e of l.menu_category){console.log("Checking category ".concat(e.category_id," in menu ").concat(l.menu_id));let n=null===(s=e.cat_items)||void 0===s?void 0:s.find(e=>e.item_id==t.item_id);if(n){if(console.log("Item ".concat(t.item_id," found in menu ").concat(l.menu_id,", category ").concat(e.category_id)),e.category_id==t.category_id){a=!0,i=n,o=l.menu_id,r=l,console.log("Item and category matched. Updated foundMenuId to ".concat(o));break}console.warn("Item ".concat(t.item_id," found in menu ").concat(l.menu_id," but category mismatch: found ").concat(e.category_id,", expected ").concat(t.category_id))}}if(a)break}else console.warn("No menu_category found in menu ".concat(l.menu_id));if(!a||!r){console.warn("Cart item ".concat(t.item_id," not found in menu_id ").concat(t.menu_id," or any other menu, or category ").concat(t.category_id," does not match"));return}d=!0;let l=!1,u=[];if(t.item_modifiers&&i.cat_items_modifiercat&&t.item_modifiers.forEach(e=>{let r=null;for(let t of i.cat_items_modifiercat){var o;let a=null===(o=t.cat_items_modifiercat_modifieritems)||void 0===o?void 0:o.find(t=>t.modifier_item_id==e.modifier_item_id);if(a){r=a;break}}r?u.push({...e,price:r.price}):console.warn("Modifier ".concat(e.modifier_item_id," for item ").concat(t.item_id," is invalid and will be removed"))}),i.cat_items_modifiercat)for(let e of i.cat_items_modifiercat)1!=e.is_required||u.some(t=>e.cat_items_modifiercat_modifieritems.some(e=>e.modifier_item_id==t.modifier_item_id))||(console.warn("Required modifier category ".concat(e.modifier_category_id," missing for item ").concat(t.item_id)),l=!0);if(l)c={...t,menu_id:o,item_modifiers:u,needsUpdate:!0};else{let e=u.reduce((e,t)=>e+(Number(t.price)||0)*(t.quantity||1),0),r=Number(i.price)||0;c={...t,menu_id:o,item_price:r,item_modifiers:u,item_price_with_modifier:r+e,needsUpdate:!1}}}d?r.push(c):console.warn("Cart item with ID ".concat(t.item_id," is no longer valid or category ").concat(t.category_id," does not match"))}),r};(0,u.useEffect)(()=>{let e=localStorage.getItem("handleBranchClickCaller_".concat(rm));console.log("[VALIDATION] fired",{callerPage:e,branchMenuDetailExists:!!rE,menuLength:Array.isArray(rE)?rE.length:"not array",cartItems:e3.length,pendingReorder:!!ll.current,cartItemIds:e3.map(e=>e.item_id)});let t=!e&&e3.length>0&&rE;if(!(("cart"===e||t)&&rE&&Array.isArray(rE)&&e3.length>0)){console.log("Skipping validation: not triggered by cart or valid refresh");return}if(0===rE.length){console.log("Empty menu received, skipping validation to prevent item removal");return}let r=lj(rE,e3),o=r.length!==e3.length,a=e=>{var t,r;let o=null===(t=e.item_modifiers)||void 0===t?void 0:t.map(e=>({modifer_cat:e.modifer_cat,modifier_item_id:e.modifier_item_id,modifier_item_name:e.modifier_item_name,modifier_item_price:Number(e.modifier_item_price||e.price||0),quantity:e.quantity}));return{item_id:e.item_id,item_price:Number(e.item_price),item_price_with_modifier:Number(e.item_price_with_modifier),quantity:e.quantity,item_modifiers:o,item_key:e.item_
1key,needsUpdate:null!==(r=e.needsUpdate)&&void 0!==r&&r}},i=e3.map(a),l=r.map(a),n=JSON.stringify(i)!==JSON.stringify(l);console.log("Validated items:-->",JSON.stringify(r),JSON.stringify(e3));let s=!1;if(!o)for(let e=0;e<e3.length;e++){let t=e3[e],o=r.find(e=>e.item_id==t.item_id);if(o&&(Number(t.item_price_with_modifier)!==Number(o.item_price_with_modifier)||Number(t.item_price)!==Number(o.item_price))){s=!0;break}}if(o||n||s){var d,c;console.log("[VALIDATION] ⚠️ MODIFYING CART",{originalCount:e3.length,validatedCount:r.length,itemsChanged:o,modifiersChanged:n,pricesChanged:s,removedItemIds:e3.filter(e=>!r.some(t=>t.item_id==e.item_id)).map(e=>e.item_id),pendingReorder:!!ll.current,stackTrace:null===(d=Error().stack)||void 0===d?void 0:d.split("\n").slice(1,4).join(" | ")}),e6(r),localStorage.setItem("cartItemDetails_".concat(rm),JSON.stringify(r)),0===r.length&&(localStorage.removeItem("order_id_".concat(rm)),eZ({subtotal:0,discount:0,tax:0,tip:0,service:0,total:0}),tx([]));let e="";e="".concat(t$("Based on the new")," ").concat((null==tg?void 0:null===(c=tg.data)||void 0===c?void 0:c.order_type)==="delivery"?t$("delivery"):t$("pickup"),", ").concat(t$("your cart has been updated. Please review it carefully before proceeding.")),oF(o||n||s?e:" "),aL(!1)}else console.log("Validation complete: No changes needed to cart")},[localStorage.getItem("handleBranchClickCaller_".concat(rm)),rE,rm,t$]);let lk=async e=>{let t=new Set(e),r=e3.filter(e=>!t.has(e));e6(r),localStorage.setItem("cartItemDetails_".concat(rm),JSON.stringify(r)),(0,tl.Uy)(rm,e.map(e=>null==e?void 0:e.item_id).filter(Boolean)),0==r.length&&(localStorage.removeItem("order_id_".concat(rm)),eZ({subtotal:0,discount:0,tax:0,tip:0,service:0,total:0}),tx([])),aL(!1)},lS=async e=>{let t=e3[e],r=e3.filter((t,r)=>r!==e),o=(0,tl.RH)(rm,t,r);if(o.length>0){r7({index:e,parent:t,dependents:o});return}await lk([t])},lC=async()=>{if(!r3)return;let{parent:e,dependents:t}=r3;r7(null),await lk([e,...t])},lI=(e,t,r)=>{let o=Number(e.price)||0;return{menu_id:e.menu_id,item_id:e.item_id,item_image:e.item_image,category_id:e.category_id,item_price:o,item_price_with_modifier:Number(o.toFixed(2)),quantity:1,item_modifiers:[],item_display_text:e.item_display_text,item_name:e.item_name,item_display_text_v1:e.item_display_text_v1||[],item_description_v1:e.item_description_v1||[],tax_rate:parseFloat(e.tax_rate)||0,isPackage:e.isPackage,package_items:[],actual_price:o,item_event:"new",tax_id:e.tax_id||[],ieps_tax:e.ieps_tax||{},special_instruction:"",price_list_id:e.price_list_id,isTopPick:2,item_trx_id:t,upsell_meta:null!=r?r:null}},lF=function(e,t,r){var o,a,i,l,n,s;let d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},c=Number(e.price)||0,u=Number(null!==(o=e.original_price)&&void 0!==o?o:e.price)||0,m=null==t?void 0:t.trigger_condition;return{type:r,product_id:e.item_id,trigger:m?{type:null!==(a=m.type)&&void 0!==a?a:null,id:null!==(l=null!==(i=m.product_id)&&void 0!==i?i:m.category_id)&&void 0!==l?l:null}:null,original_price:u,charged_price:c,discount_amount:Number(Math.max(0,u-c).toFixed(2)),discount_type:null!==(n=e.discount_type)&&void 0!==n?n:null,discount_value:null!==(s=e.discount_value)&&void 0!==s?s:null,...d}},lE=()=>{try{let e=JSON.parse(localStorage.getItem("cartItemDetails_".concat(rm))||"[]");return Array.isArray(e)?e:[]}catch(e){return[]}},lA=async e=>{e6(e),localStorage.setItem("cartItemDetails_".concat(rm),JSON.stringify(e));try{var t,r,o;let a;let i=await lb(e),l=localStorage.getItem("profile_check_".concat(tU));if(l)try{let e=JSON.parse(l);a=e.member_id,t_(e)}catch(e){console.error("Failed to parse profile_check:",e)}await lx({restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:null==aj?void 0:aj.branch_id,cart_json:{cart:{total_amount:null==i?void 0:null===(t=i.order_items)||void 0===t?void 0:t.total,total_after_tax:null==i?void 0:null===(r=i.order_items)||void 0===r?void 0:r.total_after_tax,item_details:e,actual_price:null==i?void 0:null===(o=i.order_items)||void 0===o?void 0:o.sub_total,order_type:null==i?void 0:i.order_type,after_discount:null==i?void 0:i.final_amount}},brand_id:null==tz?void 0:tz.brand_id,phone_number:"",member_id:a||"",lang:tz?null==tz?void 0:tz.bot_language:"",request_id:aB,session_id:oR,version:oB,source:"EcomV2"}),oU("")}catch(e){console.error("[upsell] failed to sync cart:",e)}},lD=e=>1==e.isPackage||Array.isArray(e.cat_items_modifiercat)&&e.cat_items_modifiercat.length>0,lO=(e,t,r)=>{ld(),nj(e.item_id,{...e,isTopPick:2,quantity:1,item_modifiers:[],item_price:e.price,item_trx_id:t,upsell_meta:null!=r?r:null,upsell_price:Number(e.price)||0})},lM=e=>{let t=r0.map(e).filter(e=>null!==e);r1(t),r2.current=t,0===t.length&&ld()},lP=async(e,t)=>{var r;if((0,tl.hu)(rm,null==t?void 0:null===(r=t.trigger_line)||void 0===r?void 0:r.item_id,e.item_id),lD(e)&&Array.isArray(rE)&&rE.length>0){lO(e,(0,W.NF)(1),lF(e,t,"products"));return}await lA([...lE(),lI(e,(0,W.NF)(1),lF(e,t,"products"))]),lM(t=>{let r=t.products.filter(t=>t.item_id!==e.item_id);return 0!==r.length||t.upgrade?{...t,products:r}:null})},lT=async(e,t)=>{var r;let o=null==t?void 0:null===(r=t.trigger_line)||void 0===r?void 0:r.item_id,a=(0,W.NF)(1);
1e.items.forEach(e=>(0,tl.hu)(rm,o,e.item_id));let i=e.items.filter(e=>lD(e)&&Array.isArray(rE)&&rE.length>0),l=e.items.filter(e=>!i.includes(e));if(l.length>0&&await lA([...lE(),...l.map(e=>lI(e,(0,W.NF)(1),lF(e,t,"combo",{combo_group_id:a})))]),i.length>0){lO(i[0],(0,W.NF)(1),lF(i[0],t,"combo",{combo_group_id:a}));return}lM(t=>t.combo!==e?t:0!==t.products.length||t.upgrade?{...t,combo:null}:null)},lL=(e,t,r,o,a)=>{var i,l,n;return{type:"upgrade",upgrade_type:"modifier",product_id:null==t?void 0:t.item_id,modifier_category_id:e.modifier_category_id,from_modifier_id:null!==(n=null!==(l=null==r?void 0:r.modifier_item_id)&&void 0!==l?l:e.from_modifier_id)&&void 0!==n?n:null,to_modifier_id:e.to_modifier_id,trigger:(null===(i=e.cart_line)||void 0===i?void 0:i.item_id)?{type:"product",id:e.cart_line.item_id}:null,original_price:o,charged_price:a,discount_amount:Number(Math.max(0,o-a).toFixed(2)),discount_type:null,discount_value:null,extra_price:e.extra_price}},lq=async e=>{var t,r;let o=e.cart_line,a=lE(),i=(null==o?void 0:o.item_trx_id)?a.findIndex(e=>(null==e?void 0:e.item_trx_id)===o.item_trx_id):a.findIndex(t=>(null==t?void 0:t.item_id)==e.product_id);if(-1===i)return;let l=a[i],n=Array.isArray(l.item_modifiers)?l.item_modifiers:[],s=n.findIndex(t=>{var r;return(null!==(r=null==t?void 0:t.modifier_category_id)&&void 0!==r?r:null==t?void 0:t.modifer_cat)==e.modifier_category_id}),d=-1===s?null:n[s],c=Number(null==d?void 0:d.quantity)||1,u=e.to_modifier,m={...d||{},modifer_cat:e.modifier_category_id,modifier_category_id:e.modifier_category_id,modifier_item_id:u.modifier_item_id,modifier_item_name:u.modifier_item_name,modifier_item_name_v1:u.modifier_item_name_v1||[],modifier_sequence:u.modifier_item_sequence,modifier_item_price:Number(u.price)||0,actual_price:Number(u.price)||0,is_tax_rate_same:u.is_tax_rate_same,tax_rate:u.tax_rate,tax_id:u.tax_id||[],quantity:c,item_id:l.item_id},_=-1===s?[...n,m]:n.map((e,t)=>t===s?m:e),p=(0,t1.M)(null==tz?void 0:tz.restaurant_id),{invalidSelectedItemIds:v}=(0,t2.eo)(p,l.item_id,_.map(e=>{var t;return{modifier_item_id:String(null==e?void 0:e.modifier_item_id),modifier_category_id:String(null!==(t=null==e?void 0:e.modifier_category_id)&&void 0!==t?t:null==e?void 0:e.modifer_cat)}})),g=new Set((v||[]).map(String));if(g.delete(String(u.modifier_item_id)),g.size>0){_=_.filter(e=>!g.has(String(null==e?void 0:e.modifier_item_id))),ld();let r=Number(null!==(t=l.item_price_with_modifier)&&void 0!==t?t:l.item_price)||0;nj(l.item_id,{...l,item_modifiers:_,isTopPick:2,item_trx_id:l.item_trx_id,upsell_meta:lL(e,l,d,r,r)});return}let f=Number(null==d?void 0:d.modifier_item_price)||0,y=(Number(u.price)||0)*c-f*c,h=Number(null!==(r=l.item_price_with_modifier)&&void 0!==r?r:l.item_price)||0,x=Number(Math.max(0,h+y).toFixed(2));a[i]={...l,item_modifiers:_,item_price_with_modifier:x,item_event:"update",isTopPick:2,upsell_meta:lL(e,l,d,h,x)},await lA(a),lM(t=>{var r,o;let a=null!==(r=t.upgrades)&&void 0!==r?r:t.upgrade?[t.upgrade]:[];if(!a.includes(e))return t;let i=a.filter(t=>t!==e);return 0!==t.products.length||t.combo||0!==i.length?{...t,upgrades:i,upgrade:null!==(o=i[0])&&void 0!==o?o:null}:null})},lR=async(e,t)=>{var r,o,a;if("modifier"===e.type)return lq(e);let i=e.cart_line,l=e.to_item,n="category"===e.type?"category":"product",s="category"===e.type?e.from_category_id:null;if(lD(l)&&Array.isArray(rE)&&rE.length>0){lO(l,(null==i?void 0:i.item_trx_id)||(0,W.NF)(1),lF(l,t,"upgrade",{upgrade_type:n,replaced_item_id:null!==(r=null==i?void 0:i.item_id)&&void 0!==r?r:null,replaced_category_id:s,extra_price:e.extra_price}));return}let d=lE();if(i){let e=i.item_trx_id?d.findIndex(e=>(null==e?void 0:e.item_trx_id)===i.item_trx_id):d.findIndex(e=>(null==e?void 0:e.item_id)==i.item_id);if(-1!==e){let t=Number(null===(o=d[e])||void 0===o?void 0:o.quantity)||1;d=t>1?d.map((r,o)=>o===e?{...r,quantity:t-1}:r):d.filter((t,r)=>r!==e)}}await lA([...d,lI(l,(0,W.NF)(1),lF(l,t,"upgrade",{upgrade_type:n,replaced_item_id:null!==(a=null==i?void 0:i.item_id)&&void 0!==a?a:null,replaced_category_id:s,extra_price:e.extra_price}))]),lM(t=>{var r,o;let a=null!==(r=t.upgrades)&&void 0!==r?r:t.upgrade?[t.upgrade]:[];if(!a.includes(e))return t;let i=a.filter(t=>t!==e);
1return 0!==t.products.length||t.combo||0!==i.length?{...t,upgrades:i,upgrade:null!==(o=i[0])&&void 0!==o?o:null}:null})};(0,u.useEffect)(()=>{eB&&t6.query.resturant?localStorage.setItem("payment_method_".concat(tU),JSON.stringify(eB)):console.log("No payment method or restaurant found for localStorage update")},[t6.query.resturant,eB]);let lB=(null==tb?void 0:tb.primary_text_color)||"#000000",lz=(null==tb?void 0:tb.secondary_text_color)||"#FFCD00",lJ=(null==tb?void 0:tb.highlight_text_color)||"#FFFFFF",lV=(null==tb?void 0:null===(F=tb.fonts)||void 0===F?void 0:F.name)||"sans-serif",lU=(null==tb?void 0:tb.primary_description_color)||"#FFFFFF",lW=(null==tb?void 0:tb.primary_button_color)||"#000000",lH=(null==tb?void 0:tb.primary_button_text_color)||"#FFCD00",lG=(null==tb?void 0:tb.secondary_button_color)||"#FFCD00",lY=(null==tb?void 0:tb.secondary_button_text_color)||"#000000",lK=(null==tb?void 0:tb.background_color)||"#FFFFFF",lX=(null==tb?void 0:tb.highlight_bg_color)||"#FF0000",lZ=(null==tb?void 0:tb.error_primary_color)||"#FF0000";null==tb||tb.error_secondary_color;let l$=(null==tb?void 0:tb.selectionLimit_text_color)||"#D1D1D1",lQ=(null==tb?void 0:tb.item_goback_button_text_color)||"#FFCD00",l0=(null==tb?void 0:tb.item_goback_button_color)||"#000000";tz&&(null==tz||null===(A=tz.ecom_settings)||void 0===A||null===(E=A.general_settings)||void 0===E||E.loader_image);let l1=async(e,t,r,o,a,i,l,n,s,d)=>{let c={restaurant_id:e,order_id:t,branch_id:r,phone_number:o,request_timestamp:a,payment_gateway_id:i,isSchedule:l,session_id:n,version:s,source:d},u=U.createSignature(JSON.stringify(c)),m=U.nodeRsaEncryption(JSON.stringify(c));try{let e="".concat(window.location.origin,"/"),t="https://order.foodbot.ai/apiv2";e&&(t="".concat(e,"apiv2"));let r=await fetch("".concat(t,"/ecom/v1/pg/moneris_create_token"),{method:"POST",headers:{"Content-Type":"application/json","x-foodbot-signature":u},body:JSON.stringify({payload:m})});return await r.json()}catch(e){throw console.error("Failed to fetch Moneris token",e),e}};(0,u.useEffect)(()=>{var e,t,r,o,a,i,l,n;let s=null==eB?void 0:null===(t=eB.data)||void 0===t?void 0:null===(e=t.Charges_details)||void 0===e?void 0:e.minimum_order_amount,d=oX&&(null==tg?void 0:null===(o=tg.data)||void 0===o?void 0:null===(r=o.order_items)||void 0===r?void 0:r.point_discount_amount)&&!isNaN(parseFloat(null==tg?void 0:null===(i=tg.data)||void 0===i?void 0:null===(a=i.order_items)||void 0===a?void 0:a.point_discount_amount))?parseFloat(null==tg?void 0:null===(n=tg.data)||void 0===n?void 0:null===(l=n.order_items)||void 0===l?void 0:l.point_discount_amount):0,c=t8&&Object.keys(t8).length>0&&(null==eK?void 0:eK.discount)?Number(eK.discount):0,u="delivery"===e5&&s&&(null==eK?void 0:eK.subtotal)!=null&&(null==eK?void 0:eK.tax)!=null&&Number(eK.subtotal)+Number(eK.tax)+Number(d)+c<s;eK.subtotal,console.log(Number(eK.subtotal),Number(eK.tax),Number(d),c,s,"sssssss"),tF(s),tS(u)},[eB,e5,eK,oX,t8,null==tg?void 0:null===(O=tg.data)||void 0===O?void 0:null===(D=O.order_items)||void 0===D?void 0:D.point_discount_amount]);let l2=()=>{document.querySelectorAll("iframe[src*='netpay']").forEach(e=>e.remove())},l5=()=>{let e=localStorage.getItem("scheduledOrder_".concat(rm));if(e)try{let t=JSON.parse(e),r=t.date,o=t.time;if(r&&o){if("ASAP"==o)return!0;let e="".concat(r," ").concat(o),t=new Date(e),a=new Date;if(t<a)return eP(!1),tZ("SCHEDULE_EXPIRED"),setTimeout(()=>{tY(!0)},500),eQ(!1),eU([]),tn({}),rQ(null),tu(null),!1}}catch(e){console.error("Error parsing scheduled order:",e)}return!0},l4=async()=>{var e,t,r;if((null==ta?void 0:ta.payment_method_id)===1&&(null==ta?void 0:ta.gateway_id)===7&&!("true"===sessionStorage.getItem("cardFormBoolean")&&sessionStorage.getItem("cardForm"))&&eV.length>0&&!rl){oF(t$("please_select_card")),null===(e=document.getElementById("netpay-card-list"))||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"});return}if(i0(),!l5())return;if(e3.some(e=>e.needsUpdate)){i1(),oF(t$("Some of your added items need an update"));return}if(!e3||0===e3.length){i1(),oF(t$("cart_empty_message"));return}let o=nl();if(!o.isValid){i1(),oF(o.errorMessage);return}if((null==ta?void 0:ta.payment_method_id)===3&&iu&&!ir&&"no"!==an){i1(),oF(t$("please_select_change_option"));return}if(ir&&(Number(ia)<eK.total||!ia)){ic("".concat(t$("Minimum amount should be")," ").concat(null==tz?void 0:tz.currency_symbol).concat(eK.total.toFixed(2))),i1();return}if(ic(null),1===ta.payment_method_id&&7!==ta.gateway_id&&6!==ta.gateway_id&&1!==ta.gateway_id&&3!==ta.gateway_id){i1(),oF(t$("Please choose another payment method"));return}if(!(null==ta?void 0:ta.payment_method_id)&&0!==eK.total){i1(),oF(t$("payment_method_selection"));return}window.location.origin;let a=(null==ta?void 0:ta.payment_method_id)==1,i=sessionStorage.getItem("cardForm"),l="true"===sessionStorage.getItem("cardFormBoolean")&&i;if(a&&7==ta.gateway_id){if(l){let e="".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8));try{l2();let r=JSON.parse(i);(0,ew.Ws)("checkout_attempt_started",e,{payment_method_id:null==ta?void 0:ta.payment_method_id,gateway_id:null==ta?void 0:ta.gateway_id,save_card:null==r?void 0:r.saveCard,card_last4:null==r?void 0:null===(t=r.cardNumber)||void 0===t?void 0:t.slice(-4),session_id:oR});let o=await nm(r,e);if(!o)return;if(!o.referenceId)throw Error("3DS Reference ID not available");let a=await na(1);(0,ew.Ws)("order_details_saved",e,{status:null==a?void 0:a.status,order_id:null==a?void 0:a.order_id,message:null==a?void 0:a.message,session_id:oR}),a&&"success"===a.status?(await ng("",a.order_id,r,o,r.saveCard,o.referenceId,e),sessionStorage.removeItem("cardForm"),sessionStorage.removeItem("cardFormBoolean"),sessionStorage.removeItem("netpayCardFormCancelled")):(console.error("Failed to save order details:",(null==a?void 0:a.message)||"Unknown error"),oF(t$("Something_went_wrong")))}catch(e){console.error("An error occurred:",e),i1(),oF((null==e?void 0:e.message)||t$("Something_went_wrong"))}}else{let e=await nu();if(e||console.log("Failed to get 3DS reference ID"),!rl){i1(),oF(t$("please_select_card"));return}if(!eV||0===eV.length){i1(),oF(t$("please_add_card"));return}let t=rl?rp[rl.token]:null;if(!t||""===t.trim()){i1(),oF(t$("enter_cvv_message")),rl&&rf(rl.token);return}rf(null);try{let t=await na(1);t&&"success"===t.status?await ng(rl,t.order_id,null,null==rl?void 0:rl.token,!1,e):oF(t$("Something_went_wrong"))}catch(e){console.error("An error occurred:",e),i1(),oF((null==e?void 0:e.message)||t$("Something_went_wrong"))}}}else if((null==ta?void 0:ta.gateway_id)===6)try{let e=await na(2);if(e&&"success"==e.status){let t=e.order_id;to(t);let o=localStorage.getItem("scheduledOrder_".concat(rm)),a=await l1(null==tz?void 0:tz.restaurant_id,t,null==aj?void 0:aj.branch_id,null==tm?void 0:tm.phone_number,new Date().toISOString(),ta.gateway_id,o?1:0,oR,oB,"EcomV2");
1if(200==a.status_code){let e=U.nodeRsaDecryption(a.pg_response.Create_token);if("string"==typeof e&&(e=JSON.parse(e)),e){let t=null==e?void 0:null===(r=e.response)||void 0===r?void 0:r.ticket,o=null==e?void 0:e.mode,a=null==e?void 0:e.script_url;ok({ticket:t,mode:o,script_url:a}),oh(!0),eP(!1)}}else oF(a.message)}}catch(e){console.error("Moneris payment error:",e),oF("An error occurred during payment initialization.")}else if(1===ta.gateway_id)await no();else if(3===ta.gateway_id){if(console.log("billpocket"),ij&&iw)await ne();else{ih(!0),i1();return}}else try{await na()}catch(e){console.error("An error occurred while saving order details:",e),oF(t$("Something_went_wrong"))}finally{i1()}},l3=(e,t)=>{let r=e.token||e.id,o=(null==rl?void 0:rl.token)||(null==rl?void 0:rl.id);rl&&r==o||(rn(e),rv({}))};console.log(rl,"sssss");let[l7,l6]=(0,u.useState)(!1),l8=e=>{iN(e),ik(!0),localStorage.setItem("selected_billpocket_card_".concat(rm),JSON.stringify({card_id:e.card_id,card_number:e.card_number,exp_date:e.exp_date,user_details:e.user_details})),localStorage.setItem("is_paying_with_saved_billpocket_card_".concat(rm),"true"),console.log("Selected billpocket card:",e)},l9=async e=>{i0(),iC(!0),console.log("handleBillpocketPaymentSubmit called with:",e);try{let o=await na(3);if(!o||"success"!==o.status){oF(t$("Something_went_wrong")),i1(),iC(!1);return}let i=o.order_id;to(i);let l=e.cardholderName.trim().split(" "),n=l[0],s=l.length>1?l.slice(1).join(" "):n,d={orderId:i,token:e.token,order_amount:eK.total,restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:(null==aj?void 0:aj.branch_id)||(null==aj?void 0:aj.id),payment_gateway_id:3,st_id:lo,email:e.email||(null==tm?void 0:tm.email)||"",member_id:(null==tm?void 0:tm.member_id)||"",phone_number:(null==tm?void 0:tm.phone_number)||"",card_data:{exp_date:e.expirationDate.replace("/",""),card_number:e.cardNumber.slice(-4),first_name:n,last_name:s},save_card:e.saveCard||!1,pay_with_subscription:!1,session_id:oR,request_timestamp:new Date().toISOString()};e.threeDomainSecure&&(d.threeDomainSecure=e.threeDomainSecure);let c=await tR(d);if(c&&"success"===c.status){e9(!0),nT(rm),oT(),nP(),iC(!1),i1();return}if(d.save_card){var t,r;let o=!!(null==c?void 0:null===(t=c.order)||void 0===t?void 0:t.card_saved),l=o?"billpocket_modal.retry_one_time_charge_generic":"billpocket_modal.retry_one_time_charge";iV(""),iW(t$(l));let n="billpocket_save_card_retry_".concat(i),s=(e,t,r)=>{var o;let a={event:e,gateway:"billpocket",error_message:t,amount:eK.total,currency:"MXN",restaurant_id:null==tz?void 0:null===(o=tz.restaurant_id)||void 0===o?void 0:o.toString(),extra:r};tJ(a),tJ({...a,file_name:n})};s("save_card_makepayment_failed_retry_one_time",null==c?void 0:c.message,{order_id:i,card_saved_before_retry:o,full_response:c}),a.wd("billpocket_save_card_retry_one_time",{level:"warning",tags:{area:"billpocket-save-card-retry",stage:"retry_started",restaurant_id:String((null==tz?void 0:tz.restaurant_id)||"")},extra:{order_id:i,original_failure_message:null==c?void 0:c.message,card_saved_before_retry:o,full_response:c}});let u=await (null===(r=iH.current)||void 0===r?void 0:r.regenerateOneTimeToken({cardholderName:e.cardholderName,cardNumber:e.cardNumber,expirationDate:e.expirationDate,securityCode:e.securityCode},eK.total));if(u&&"token"in u){let e={...d,token:u.token,save_card:!1};u.threeDomainSecure?e.threeDomainSecure=u.threeDomainSecure:delete e.threeDomainSecure;let t=await tR(e),r=t&&"success"===t.status?"success":"failed";if(s("save_card_makepayment_retry_result","failed"===r?null==t?void 0:t.message:void 0,{order_id:i,outcome:r,full_response:t}),a.wd("billpocket_save_card_retry_one_time",{level:"success"===r?"info":"warning",tags:{area:"billpocket-save-card-retry",stage:"retry_result",outcome:r,restaurant_id:String((null==tz?void 0:tz.restaurant_id)||"")},extra:{order_id:i,original_failure_message:null==c?void 0:c.message,retry_failure_message:"failed"===r?null==t?void 0:t.message:void 0,full_response:t}}),"success"===r){e9(!0),nT(rm),oT(),nP(),iC(!1),i1();return}let o=iK(t);oF(o),iC(!1),i1();return}s("save_card_makepayment_retry_result",u&&"error"in u&&u.error||void 0,{order_id:i,outcome:"token_regeneration_failed",full_response:u}),a.wd("billpocket_save_card_retry_one_time",{level:"warning",tags:{area:"billpocket-save-card-retry",stage:"retry_result",outcome:"token_regeneration_failed",restaurant_id:String((null==tz?void 0:tz.restaurant_id)||"")},extra:{order_id:i,full_response:u}});let m=u&&"error"in u&&u.error||t$("billpocket_modal.payment_errors.token_generation_error");oF(m),iC(!1),i1();return}let u=iK(c);oF(u),iC(!1),i1()}catch(e){console.error("Billpocket Payment Error:",e),oF((null==e?void 0:e.message)||"An error occurred during payment.")}finally{i1(),iC(!1)}},ne=async()=>
1{if(iC(!0),!iw){oF("No saved card selected"),iC(!1);return}try{let e=await na(3);if(!e||"success"!==e.status){oF(t$("Something_went_wrong")),iC(!1);return}let t=e.order_id;to(t);let r={orderId:t,subscription_id:iw.card_id,order_amount:eK.total,restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:(null==aj?void 0:aj.branch_id)||(null==aj?void 0:aj.id),payment_gateway_id:3,st_id:lo,email:(null==tm?void 0:tm.email)||"",member_id:(null==tm?void 0:tm.member_id)||"",phone_number:(null==tm?void 0:tm.phone_number)||"",pay_with_subscription:!0,session_id:oR,request_timestamp:new Date().toISOString()},o=await tR(r);if(o&&"success"===o.status)e9(!0),iC(!1),oT(),nT(rm),nP();else{let e=iK(o);oF(e),iC(!1)}}catch(e){console.error("Billpocket Saved Card Payment Error:",e),oF((null==e?void 0:e.message)||"An error occurred during payment."),i1(),iC(!1)}},nt=async(e,t)=>{try{let r="".concat(window.location.origin,"/"),o={restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:null==aj?void 0:aj.branch_id,order_id:e.toString(),payment_gateway_id:ta.gateway_id,source:t,req_timestamp:new Date().toISOString(),session_id:oR,st_id:lt};return await tP(o,r)}catch(e){return console.error("Error confirming payment status:",e),null}},nr=async(e,t,r,o)=>{let{external_resource_url:a,creq:i}=e.three_ds_info,l=document.createElement("div");l.id="three-ds-challenge",l.style.cssText="\n    position: fixed; top: 0; left: 0; width: 100%; height: 100%; \n    background: rgba(0,0,0,0.5); z-index: 9999; display: flex; \n    justify-content: center; align-items: center;\n  ",document.body.appendChild(l);let n=document.createElement("div");n.style.cssText="\n    background: #fff;\n    padding: 20px;\n    border-radius: 8px;\n    box-shadow: 0 4px 12px rgba(0,0,0,0.2);\n    max-width: 420px;\n    width: 100%;\n    display: flex;\n    justify-content: center;
1\n    align-items: center;\n  ",l.appendChild(n);let s=document.createElement("iframe");s.name="threeDsFrame",s.id="threeDsFrame",s.style.cssText="\n    width: 100%; height: 400px; border: none; background: #fff;\n  ",n.appendChild(s);let d=s.contentDocument||(s.contentWindow?s.contentWindow.document:null);if(!d)return console.error("Could not access iframe document"),!1;let c=d.createElement("form");c.method="post",c.action=a,c.target="threeDsFrame";let u=d.createElement("input");u.type="hidden",u.name="creq",u.value=i,c.appendChild(u),d.body.appendChild(c),c.submit();let m=async e=>{if(e.origin===new URL(a).origin&&"COMPLETE"===e.data.status){var i;console.log("3DS Challenge complete, fetching status...");let e=await nt(r,o),a=null==e?void 0:null===(i=e.status)||void 0===i?void 0:i.toLowerCase();return"approved"===a||"authorized"===a?(localStorage.removeItem("mercadoPagoPaymentInfo_".concat(t)),e9(!0),oT(),nT(t),nP(),v(),!0):(["pending","in_process","in_mediation"].includes(a)||(null==e?void 0:e.status_detail)==="pending_challenge"?console.log("Status still pending after challenge, waiting for polling..."):(oF(t$("Payment authentication failed")+":"+((null==e?void 0:e.reason)||a)),v()),!1)}};window.addEventListener("message",m);let _=0,p=setInterval(async()=>{var e;_++;let a=await nt(r,o),i=null==a?void 0:null===(e=a.status)||void 0===e?void 0:e.toLowerCase();return"approved"===i?(localStorage.removeItem("mercadoPagoPaymentInfo_".concat(t)),e9(!0),oT(),nT(t),nP(),v(),clearInterval(p),!0):i&&!["pending","in_process","authorized","pending_challenge"].includes(i)&&"approved"!==i?(console.log("Polling stopped: Terminal status reached:",i),oF(t$("Payment authentication failed or was cancelled")+":"+((null==a?void 0:a.reason)||i)),v(),clearInterval(p),!1):_>=24?(oF(t$("Payment authentication timed out")),v(),clearInterval(p),!1):void 0},5e3),v=()=>{window.removeEventListener("message",m);let e=document.getElementById("three-ds-challenge");e&&document.body.removeChild(e),clearInterval(p)};return i1(),!1},no=async()=>{i0();try{var e,t,r,o,a;let i,l,n,s,d;let c="".concat(window.location.origin,"/");if(l7&&rl){if(!rp[rl.id])return oF("CVV required for saved card"),i1(),!1;if(!a8){if(console.warn("Customer ID is missing for saved card payment, attempting to fetch..."),!lm.email)return console.warn("Skipping getMercadoPagoCardsList: email is empty"),oF(t$("Customer information not available. Please try again.")),i1(),!1;try{let e=await tM(lm);if(null==e||!e.pg_customer_id)return oF(t$("Customer information not available. Please try again.")),i1(),!1;a9(e.pg_customer_id),console.log("Customer ID fetched successfully:",e.pg_customer_id)}catch(e){return console.error("Failed to fetch customer ID:",e),oF(t$("Customer information not available. Please try again.")),i1(),!1}}console.log("Processing saved card payment with customer ID:",a8);let e={restaurant_id:null==tz?void 0:tz.restaurant_id,card_id:rl.id,security_code:rp[rl.id],payment_gateway_id:ta.gateway_id,st_id:lt,session_id:oR};i=await tT(e,c,{phone_number:null==tm?void 0:tm.phone_number}),l=rl.brand_id,n=rl.payment_type,s=null==tm?void 0:tm.email,d=!1,console.log("\uD83D\uDD0D TOKEN CREATED:",{token:i?i.substring(0,10)+"...":"null",brand:l,type:n,email:s})}else{let e=localStorage.getItem("mercadoPagoPaymentInfo_".concat(rm));if(!e)return oF(t$("No Mercado Pago payment info found")),i1(),!1;let t=JSON.parse(e);i=t.token,l=t.brand,n=t.type,s=t.email,d=t.saveCard}if(!i||!l||!n||!s)return oF(t$("Invalid Mercado Pago payment info")),i1(),!1;let u=await na(1);if(!u||"success"!==u.status)return oF(t$("Something_went_wrong")),i1(),!1;let m={source:i,brand:l,installments:1,phone_number:null==tm?void 0:tm.phone_number,type:n};l7&&rl&&a8&&(m.customer_id=a8,console.log("Added customer_id to card_data:",a8));let _={orderId:u.order_id,order_amount:eK.total.toFixed(2),restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:null==aj?void 0:aj.branch_id,payment_gateway_id:ta.gateway_id,email:s,member_id:null==tm?void 0:tm.member_id,card_data:m,save_card:d,session_id:oR,st_id:lt};console.log("MercadoPago payment payload:",JSON.stringify(_,null,2));let p=await tO(_,c);if((null==p?void 0:p.status)==="success")return localStorage.removeItem("mercadoPagoPaymentInfo_".concat(rm)),i1(),e9
1(!0),oT(),nT(rm),nP(),!0;if((null==p?void 0:p.status)==="pending"&&(null==p?void 0:null===(e=p.order)||void 0===e?void 0:e.payment_status)==="pending_challenge"&&(null==p?void 0:null===(t=p.three_ds_info)||void 0===t?void 0:t.external_resource_url)&&(null==p?void 0:null===(r=p.three_ds_info)||void 0===r?void 0:r.creq)){let e=(null===(a=p.order)||void 0===a?void 0:a.payment_id)||p.payment_id;if(!e)return oF(t$("Payment ID not available")),i1(),!1;return await nr(p,rm,e,i)}if((null==p?void 0:p.reason)=="Invalid card_token_id")return oF(t$("please_refill_payment_form")),localStorage.removeItem("mercadoPagoPaymentInfo_".concat(rm)),i1(),!1;if((null==p?void 0:p.status)=="fail"&&(null==p?void 0:p.reason)=="internal_error")return oF(t$("payment_method_unavailable_temporarily")),localStorage.removeItem("mercadoPagoPaymentInfo_".concat(rm)),i1(),!1;else if((null==p?void 0:p.status)==="pending_review_manual"||(null==p?void 0:p.reason)==="pending_review_manual"||(null==p?void 0:null===(o=p.order)||void 0===o?void 0:o.payment_status)==="pending_review_manual")return oF(t$("payment_pending_review_manual")),localStorage.removeItem("mercadoPagoPaymentInfo_".concat(rm)),i1(),!1;else return oF((null==p?void 0:p.reason)||(null==p?void 0:p.message)||t$("payment_failed_message")),localStorage.removeItem("mercadoPagoPaymentInfo_".concat(rm)),i1(),!1}catch(e){return console.error("Mercado Pago payment error:",e),oF(t$("Something_went_wrong")),i1(),!1}},na=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((t,r)=>{console.log(e);try{if(!e3||0===e3.length){i1(),iC(!1),oF(t$("cart_empty_message"));return}let W=null==tg?void 0:tg.data,H="OrderPlacedData_".concat(rm),G=localStorage.getItem("scheduledOrder_".concat(rm)),Y="ASAP",K=(0,el.po)();if(G&&"pickup"===e5||G&&"delivery"===e5||G&&"dinein"===e5)try{let e=JSON.parse(G);e.time&&e.date&&(Y=e.time,K=e.date,aR(!0),localStorage.setItem("Ordertype","scheduled"))}catch(e){console.error("Error parsing scheduled order:",e),i1(),iC(!1),oF(e)}let X=localStorage.getItem("selected_delivery_partner_".concat(tU)),Z=null;if(X)try{Z=JSON.parse(X)}catch(e){i1(),oF(e),console.error("Error parsing availablePartner:",e)}if((null==Z?void 0:Z.partner_id)===10008&&(null==tm?void 0:tm.country_code)&&"52"!==tm.country_code){i1(),iC(!1),oF(t$("lalamove_country_restricted"));return}let $=null==ta?void 0:ta.payment_method_id,Q=r$;(null==W?void 0:W.final_amount)==0&&($=3,Q="Cash");try{var o,l,n,s,d,u,m,_,p,v,g,f,y,h,x,b,w,N,j,k,S,C,I,F,E,A,D,O,M,P,T,L,q,R,B,z,J,V;let G=localStorage.getItem("callin_order_".concat(tU));if(G){let e=(0,i.Jq)(tU);if(e.length>0){let{expected:t,actual:r}=(0,i.sS)(tU),o=!!t&&!!r&&t!==r;a.wd("callin_key_mismatch_at_checkout",{level:o?"error":"warning",tags:{area:"callin-order-type",mode_expected:String(t),mode_actual:String(r),mode_flip:String(o),changed_keys:e.map(e=>e.field).join(",")},extra:{alias:tU,diffs:e,url:window.location.href}})}}let X=null;if("pickup"!==e5){let e=null;try{e=JSON.parse(localStorage.getItem("selecteduserAddress_".concat(tU))||"null")}catch(t){e=null}let t=e=>!!e&&Number.isFinite(Number(e.latitude))&&0!==Number(e.latitude)&&Number.isFinite(Number(e.longitude))&&0!==Number(e.longitude)&&!!e.formatted_address,r=t(rX)?rX:t(e)?e:null;if("delivery"!==e5||t(rX)||c(r?"fallback":"missing",{alias:tU,session_id:oR,branch_id:lc,save_delivery_mode:e5,is_callin:!!G,resolved_from:r?r===e?"selecteduserAddress":"saveModedetails":"none",save_mode_details:rX,selected_branchmode_raw:localStorage.getItem("selected_branchmode_".concat(tU)),selecteduserAddress_raw:localStorage.getItem("selecteduserAddress_".concat(tU)),branch_delivery_raw:localStorage.getItem("branch_delivery_".concat(tU))}),!r&&!G&&"delivery"===e5){i1(),iC(!1),oF(t$("delivery_address_incomplete"));return}let o=r||rX||{};X={address_label:o.address_label,address_type:o.address_type,external_type:o.external_type,city:o.city,country:o.country,external_number:o.external_number,formatted_address:o.formatted_address,latitude:Number(o.latitude),longitude:Number(o.longitude),state:o.state,street:o.street,unit_number:o.unit_number,zipcode:o.zipcode,member_id:null==tm?void 0:tm.member_id,delivery_instruction:(null==rX?void 0:rX.delivery_instruction)||o.delivery_instruction||""}}let ee={restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc&&lc,order_type:"pickup"==e5?"takeout":"dinein"==e5?"dinein":"delivery",payment_methods:[{payment_method_id:$,payment_mode:Q,payment_amount:null==W?void 0:null===(o=W.final_amount)||void 0===o?void 0:o.toString()}],user_detais:{..."pickup"!==e5&&{address:X},mobile:null==tm?void 0:tm.phone_number,member_id:null==tm?void 0:tm.member_id,name:null==tm?void 0:tm.user_name,email:null==tm?void 0:tm.email,country_code:null==tm?void 0:tm.country_code},...(null==tg?void 0:null===(n=tg.data)||void 0===n?void 0:null===(l=n.order_items)||void 0===l?void 0:l.is_delivery_discount)&&{delivery_discount:null==tg?void 0:null===(d=tg.data)||void 0===d?void 0:null===(s=d.order_items)||void 0===s?void 0:s.delivery_discount},is_decimalvalue_allowed:1,final_amount:null==W?void 0:null===(u=W.final_amount)||void 0===u?void 0:u.toString(),cash_expected:ir&&""!==ia&&!isNaN(Number(ia))?ia.toString():null==W?void 0:null===(m=W.cash_expected)||void 0===m?void 0:m.toString(),table_name:a0||"",sender_id:null,cost_share:(null==Z?void 0:Z.cost_share)||0,delivery_partner_id:(null==Z?void 0:Z.partner_id)||0,actual_delivery_charges:(null==Z?void 0:Z.actual_delivery_charges)||0,delivery_charge:tg?null==tg?void 0:null===(_=tg.data)||void 0===_?void 0:_.delivery_cost:"",platform_type:1,request_id:null==W?void 0:W.request_id,store_value:tg?null==tg?void 0:null===(p=tg.data)||void 0===p?void 0:p.store_value:0,service_discount:null==tg?void 0:null===(g=tg.data)||void 0===g?void 0:null===(v=g.order_items)||void 0===v?void 0:v.service_discount,timezone:null!==(B=rX.timezone)&&void 0!==B?B:"Etc/GMT+6",order_items:{total_amount:null==W?void 0:null===(y=W.order_items)||void 0===y?void 0:null===(f=y.total)||void 0===f?void 0:f.toString(),total_after_tax:null==W?void 0:null===(x=W.order_items)||void 0===x?void 0:null===(h=x.total_after_tax)||void 0===h?void 0:h.toString(),item_details:null==W?void 0:null===(b=W.order_items)||void 0===b?void 0:b.item_details.map(e=>{var t,r,o,a,i,l,n,s,d,c,u,m,_,p;return{item_id:e.item_id,category_id:e.category_id,item_price:null===(t=e.item_price)||void 0===t?void 0:t.toString(),item_price_with_modifier:null===(r=e.item_price_with_modifier)||void 0===r?void 0:r.toString(),menu_id:e.menu_id,quantity:e.quantity,final_amount:null===(o=e.item_price_with_modifier)||void 0===o?void 0:o.toString(),item_name:e.item_name,tax_rate:e.tax_rate,item_modifiers:(null===(a=e.item_modifiers)||void 0===a?void 0:a.map(e=>{var t,r,o,a,i;return{modifer_cat:e.modifer_cat,modifier_item_id:e.modifier_item_id,modifier_sequence:e.modifier_sequence,modifier_item_price:null===(t=e.modifier_item_price)||void 0===t?void 0:t.toString(),modifier_item_name:e.modifier_item_name,is_tax_rate_same:e.is_tax_rate_same,tax_rate:e.tax_rate,quantity:e.quantity,item_id:e.item_id,tax_id:e.tax_id,points_discount:e.points_discount||0,ieps_tax:e.ieps_tax,price_list_id:e.price_list_id||"",linked_product:e.linked_product||null,tax_amount:null===(r=e.tax_amount)||void 0===r?void 0:r.toString(),total_after_tax:null===(o=e.total_after_tax)||void 0===o?void 0:o.toString(),actual_price:null===(a=e.actual_price)||void 0===a?void 0:a.toString(),tax_array:e.tax_array||[],promotion_discount:null===(i=e.promotion_discount)||void 0===i?void 0:i.toString(),redeem_promotion_id:e.redeem_promotion_id||0}}))||[],isPackage:e.isPackage,package_items:e.package_items||[],actual_price:null==W?void 0:null===(l=W.order_items)||void 0===l?void 0:null===(i=l.sub_total)||void 0===i?void 0:i.toString(),tax_id:e.tax_id,points_discount:e.points_discount||0,points_discount_modifier:e.points_discount_modifier||0,ieps_tax:e.ieps_tax,price_list_id:e.price_list_id||"",final_tax_amout:null===(n=e.tax_amount)||void 0===n?void 0:n.toString(),item_tax:null===(s=e.tax_amount)||void 0===s?void 0:s.toString(),tax_amount:null===(d=e.tax_amount)||void 0===d?void 0:d.toString(),tax_amount_modifier:null===(c=e.tax_amount_modifier)||void 0===c?void 0:c.toString(),tax_array:e.tax_array||[],total_tax_amount:null===(u=e.total_tax_amount)||void 0===u?void 0:u.toString(),promotion_discount:null===(m=e.promotion_discount)||void 0===m?void 0:m.toString(),promotion_discount_modifier:null===(_=e.promotion_discount_modifier)||void 0===_?void 0:_.toString(),redeem_promotion_id:e.redeem_promotion_id||0,item_event:e.item_event||"new",special_instruction:e.special_instruction||"",isTopPick:e.isTopPick,upsell_meta:null!==(p=e.upsell_meta)&&void 0!==p?p:null}}),actual_price:null==W?void 0:null===(N=W.order_items)||void 0===N?void 0:null===(w=N.sub_total)||void 0===w?void 0:w.toString(),order_type:(null==W?void 0:W.order_type)||"pickup",after_discount:null==W?void 0:null===(k=W.order_items)||void 0===k?void 0:null===(j=k.total_after_tax)||void 0===j?void 0:j.toString(),tax_amount:null==W?void 0:null===(C=W.order_items)||void 0===C?void 0:null===(S=C.tax_amount)||void 0===S?void 0:S.toString(),merged_tax_array:(null==W?void 0:null===(I=W.order_items)||void 0===I?void 0:I.merged_tax_array)||[],total:null==W?void 0:null===(F=W.final_amount)||void 0===F?void 0:F.toString(),discount:null==eK?void 0:eK.discount,before_discount:null==W?void 0:null===(A=W.order_items)||void 0===A?void 0:null===(E=A.cartTotal)||void 0===E?void 0:E.toString(),tip_amount:"0.00",sub_total:null==W?void 0:null===(O=W.order_items)||void 0===O?void 0:null===(D=O.sub_total)||void 0===D?void 0:D.toString(),points_discount:(null==tg?void 0:null===(P=tg.data)||void 0===P?void 0:null===(M=P.order_items)||void 0===M?void 0:M.point_discount_amount)?null==tg?void 0:null===(L=tg.data)||void 0===L?void 0:null===(T=L.order_items)||void 0===T?void 0:T.point_discount_amount:"0.00",total_discount:null==eK?void 0:eK.discount},tax_type:(null==W?void 0:W.tax_type)||(null==tz?void 0:tz.tax_type)||2,schedule_time:function(e){if(!e||"ASAP"===e)return e;let t=e.match(/^(\d{1,2}):(\d{2})\s?(AM|PM)$/i);if(!t)return e;let[,r,o,a]=t,i=parseInt(r,10);return"PM"===a.toUpperCase()&&12!==i&&(i+=12),"AM"===a.toUpperCase()&&12===i&&(i=0),"".concat(i.toString().padStart(2,"0"),":").concat(o)}(Y),schedule_date:K,service_charge:eK?null==eK?void 0:eK.service:0,tip_amount:null!==(z=null==W?void 0:W.tip_amount)&&void 0!==z?z:ry||rx,tip_value:rj,tip_type:rw,source_order_id:li,lang:null==tz?void 0:tz.bot_language,brand_id:(null==W?void 0:W.brand_id)||(null==tz?void 0:tz.brand_id)||"",session_id:oR,version:oB,source:"EcomV2",ui_request_timestamp:new Date().toISOString(),order_comment:ox||""};t8&&t8.offer_id&&((null==eK?void 0:eK.discount)&&eK.discount>0||(null==tg?void 0:null===(R=tg.data)||void 0===R?void 0:null===(q=R.order_items)||void 0===q?void 0:q.is_delivery_discount))&&(ee.promotion_applied={discount:eK.discount||0,discount_type:t8.oo_offer_type,en_id:null!==(J=null==t8?void 0:t8.en_id)&&void 0!==J?J:0,promotion_id:t8.offer_id,promotion_type:null==t8?void 0:t8.offer_discount_type});let et="order_id_".concat(rm),er="http_referrer_".concat(rm),eo="utm_campaign_".concat(rm),ea="utm_source_".concat(rm),ei=localStorage.getItem(et);ei&&(ee.order_id=ei,ee.request_id="123");let el=localStorage.getItem(er)||"";ee.http_referrer=el.replace(/["\\]/g,""),ee.utm_source=localStorage.getItem(ea)||"",ee.utm_campaign=localStorage.getItem(eo)||"";let en=localStorage.getItem("callin_order_".concat(rm));if(en)try{let e=JSON.parse(en);e.expires_at&&Date.now()>e.expires_at?(localStorage.removeItem("callin_order_".concat(rm)),localStorage.removeItem("callin_open_payment"),localStorage.removeItem("handleBranchClickCaller_".concat(rm))):(ee.channel_id=null!==(V=e.channel_id)&&void 0!==V?V:1,e.order_id&&(ee.order_id=e.order_id.toString()),ee.callin_user_id=e.callin_user_id)}catch(e){console.error("Error parsing callin_order data:",e),localStorage.removeItem("callin_order_".concat(rm)),localStorage.removeItem("callin_open_payment"),localStorage.removeItem("handleBranchClickCaller_".concat(rm))}let es=JSON.stringify(ee),ed=U.nodeRsaEncryption(es),eu=U.createSignature(es),em=JSON.stringify({payload:ed}),e_=(0,ec.z)();
1e_.append("x-foodbot-signature",eu);let ep="".concat(window.location.origin,"/"),ev="https://order.foodbot.ai/apiv2";ep&&(ev=ep+"apiv2"),fetch("".concat(ev,"/ecom/v1/saveOrderDetails"),{method:"POST",headers:e_,body:em,redirect:"follow"}).then(async r=>{let o;r.ok||console.log("HTTP error! status: ".concat(r.status));try{o=await r.json()}catch(e){iC(!1),i1(),oF("Something Went Wrong !!"),console.log("Invalid JSON response");return}if(oi(o),"success"==o.status&&"200"==o.status_code&&"Order Placed"==o.message){to(null==o?void 0:o.order_id);let r={order_id:null==o?void 0:o.order_id,restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,customer:{name:(null==tm?void 0:tm.user_name)||"",phone:(null==tm?void 0:tm.phone_number)||""}};if(console.log("Saving to localStorage with alias:",tU),console.log("Data for localStorage:",{final_amount:null==W?void 0:W.final_amount,payment_method_id:null==ta?void 0:ta.payment_method_id}),localStorage.setItem(H,JSON.stringify(r)),(null==W?void 0:W.final_amount)&&localStorage.setItem("orderTotal_".concat(tU),W.final_amount.toString()),(null==ta?void 0:ta.payment_method_id)&&localStorage.setItem("paymentMode_".concat(tU),ta.payment_method_id.toString()),eR(""),0==e){var a,i;eL(!1),eP(!1),setTimeout(()=>{var e,t;(null==rX?void 0:null===(t=rX.available_services)||void 0===t?void 0:null===(e=t.curveorder)||void 0===e?void 0:e.status)==!0&&("pickup"==e5||"takeout"==e5)?oC(!0):e9(!0)},100),oT(),nP(),(null==rX?void 0:null===(i=rX.available_services)||void 0===i?void 0:null===(a=i.curveorder)||void 0===a?void 0:a.status)==!0&&("pickup"==e5||"takeout"==e5)||nT(rm),t9({}),iC(!1),i1()}else localStorage.setItem(et,null==o?void 0:o.order_id);let l=new Date,n=l.toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}).replace(/ /g,"/"),s=l.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).replace("AM","am").replace("PM","pm");td({date:n,time:s}),t(o)}else if("201"==o.status_code)oF(t$("Payment Failed ! Please Select another payment method ")),localStorage.removeItem("request_id_".concat(tU)),iC(!1),i1();else if("success"==o.status&&"202"==o.status_code)oF(t$("invalid_user")),localStorage.removeItem("request_id_".concat(tU)),iC(!1),i1();else if("fail"==o.status&&"202"==o.status_code)oF(t$("menu not available_fail")),localStorage.removeItem("request_id_".concat(tU)),iC(!1);else if("203"==o.status_code)localStorage.removeItem("request_id_".concat(tU)),oF(t$("Payment Failed ! Please Select another payment method ")),iC(!1),i1();else if("success"==o.status&&"207"==o.status_code)oF(t$("delivery_partner_not_available")),iC(!1),i1();else if("fail"==o.status&&"409"==o.status_code){let{rejected_items:e=[],rejected_modifiers:t=[]}=o,r=e.map(e=>{let t=ee.order_items.item_details.find(t=>t.item_id==e);return t?{item_id:e,item_name:t.item_name,item_display_text:t.item_name}:null}).filter(Boolean),a=t.map(e=>{let t=null;return ee.order_items.item_details.forEach(r=>{if(r.item_modifiers){let o=r.item_modifiers.find(t=>t.modifier_item_id==e);o&&(t=o)}r.isPackage&&r.package_items&&r.package_items.forEach(r=>{if(r.modifiers){let o=r.modifiers.find(t=>t.modifier_item_id==e);o&&(t=o)}})}),t?{modifier_id:e,item_name:t.modifier_item_name,item_display_text:t.modifier_item_name}:null}).filter(Boolean),i=[...r,...a];i.length>0?(a6(i),eP(!1),setTimeout(()=>{a3(!0)},100)):oF(t$("Some items are unavailable, please review your cart.")),localStorage.removeItem("request_id_".concat(tU)),iC(!1),i1()}else"402"==o.status_code?(oF(t$("error_scheduling_past_time")),iC(!1),localStorage.removeItem("request_id_".concat(tU))):(oF(o.message||t$("Something went wrong.")),localStorage.removeItem("request_id_".concat(tU)),iC(!1)),i1()}).catch(e=>{iC(!1),i1(),console.error("API error:",e),localStorage.removeItem("request_id_".concat(tU)),r(e)})}catch(e){console.error("Error preparing cart data:",e),iC(!1),i1(),oF("Error preparing order data. Please try again.")}}catch(e){console.error("Unexpected error:",e),iC(!1),i1(),oF("An unexpected error occurred. Please try again.")}})},ni=async e=>{let t=window.location.origin?"".concat(window.location.origin,"/"):"https://order.foodbot.ai/",r=await (0,th.R)(e,rm,t);r.success?(oC(!1),nT(rm),setTimeout(()=>{e9(!0)},100)):oF(r.message)},nl=()=>{var e,t;let r=null==eB?void 0:null===(e=eB.data)||void 0===e?void 0:e.Charges_details;if("delivery"!==e5||!r||1!==r.cartvalue_based_pricing||!(null===(t=r.cartvalue_pricing_details)||void 0===t?void 0:t.length))return{isValid:!0,errorMessage:null};let o=e3.reduce((e,t)=>
1e+t.item_price_with_modifier*t.quantity,0);if(!r.cartvalue_pricing_details.find(e=>o>=parseFloat(e.cart_minvalue)&&(0===parseFloat(e.cart_maxvalue)||o<=parseFloat(e.cart_maxvalue)))){let e=(null==r?void 0:r.cartvalue_pricing_details)||[],t=e.length?Math.min(...e.map(e=>parseFloat(e.cart_minvalue||"0"))):0;return{isValid:!1,errorMessage:t$("cart_value_not_in_range",{minAmount:t})||"Your cart total is below the minimum required value of ₹".concat(t,". Please add more items to proceed.")}}return{isValid:!0,errorMessage:null}},nn=(e,t,r,o)=>{tn(t),rQ(e),console.log("selectedCard",r,"methodName",e,"item",t,"updatedTaxDetails",o),o&&(eZ(o),aL(!1))},ns=()=>{let e=e3.map(e=>{if(a7.some(t=>t.item_id==e.item_id))return null;let t={...e};if(t.item_modifiers){if(t.item_modifiers=t.item_modifiers.filter(e=>!a7.some(t=>t.modifier_id==e.modifier_item_id)),t.item_modifiers.length>0){let e=t.item_modifiers.reduce((e,t)=>e+parseFloat(t.modifier_item_price||"0")*(t.quantity||1),0);t.item_price_with_modifier=(parseFloat(t.item_price||"0")+e).toFixed(2)}else t.item_price_with_modifier=t.item_price}return t.isPackage&&t.package_items&&(t.package_items=t.package_items.map(e=>(e.modifiers&&(e.modifiers=e.modifiers.filter(e=>!a7.some(t=>t.modifier_id==e.modifier_item_id))),e))),t}).filter(Boolean);e6(e),localStorage.setItem("cartItemDetails_".concat(rm),JSON.stringify(e)),a6([]),aL(!1),setTimeout(()=>{a3(!1),0==e.length?lu():oI(t$("Unavailable items removed. Please review your cart."))},100)};(0,u.useEffect)(()=>{ar&&(console.error("Netpay 3DS script error:",ar),oF(t$("Failed to load payment script")))},[ar,oF,t$]),function(e,t){(0,u.useEffect)(()=>{e&&(document.querySelector('script[src="'.concat(e,'"]'))?t():function(e){!function(){if("function"!=typeof document.elementFromPoint)return;let e=document.elementFromPoint.bind(document);document.elementFromPoint=(t,r)=>isFinite(t)&&isFinite(r)?e(t,r):null}();let t=document.createElement("script");return t.type="text/javascript",t.src=e,document.body.appendChild(t),t}(e).onload=t)},[e])}(null==rs?void 0:rs.scriptUrl,()=>{window.NetPay&&(window.NetPay.setSandboxMode(null==rs?void 0:rs.sandboxMode),window.NetPay.setApiKey(null==rs?void 0:rs.public_key),ru(window.NetPay.form.generateDeviceFingerPrint()))});let nd=async e=>{var t,r,o;eH([]);let a=null!==(t=null==tz?void 0:tz.restaurant_id)&&void 0!==t?t:"",i=null!=lc?lc:"",l=null!==(r=null==tm?void 0:tm.phone_number)&&void 0!==r?r:"",n=null!==(o=null==e?void 0:e.gateway_id)&&void 0!==o?o:"";if(!a||!i||!n){console.error("Missing required fields for cardListapi:",{restaurant_id:a,branch_id:i,payment_gateway_id:n}),of(!0),oF(t$("Invalid payment configuration")),i1();return}try{(null==e?void 0:e.scriptUrl)&&rd(e);let t=await tQ({restaurant_id:a,branch_id:i,phone_number:l,payment_gateway_id:n});200===t.statusCode?(eU(t.cards),os||(od(!0),of(!1))):os||(od(!0),of(!0))}catch(e){console.error("Fetch Error:",e),os||(od(!0),of(!0))}finally{}},nc=()=>new Promise(e=>{if(!at){console.error("Netpay3ds not initialized"),oF("Netpay3ds not initialized"),e(null);return}let t=!1,r=setTimeout(()=>{t||(t=!0,console.error("Netpay3ds config timed out waiting for callback"),(0,eb.f)({target_path:"ecom/v1/",file_name:"ecom_error_logs",data:{error_message:"Netpay3ds config timed out waiting for callback",error_source:"cart page - getReferenceId",error_stack:"",error_line:"",error_column:"",url:window.location.href,userAgent:navigator.userAgent,resturantid:null==tz?void 0:tz.restaurant_id,timestamp:new Date().toISOString()},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()}),i1(),oF(t$("payment_init_failed")),e(null))},2e4),o=o=>{t||(t=!0,clearTimeout(r),e(o))},a=Date.now();try{at.init(()=>{var e;at.config(void 0,null==tg?void 0:null===(e=tg.data)||void 0===e?void 0:e.final_amount,(e,t)=>{if(console.log("3DS Status:",e),console.log("Reference ID:",t),t)on(t),o(t);else{var r;console.log("Failed to get reference ID. Status: ".concat(t)),(0,ew.Yj)({event:"netpay3ds_config_failed",request:{ds_script_url:null==ta?void 0:ta.ds_script_url,sandboxMode:null==ta?void 0:ta.sandboxMode,amount:null==tg?void 0:null===(r=tg.data)||void 0===r?void 0:r.final_amount,restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,session_id:oR,started_at:new Date(a).toISOString()},response:{status:e,referenceId:t,elapsed_ms:Date.now()-a}
1,userDetail:{member_id:null==tm?void 0:tm.member_id,phone_number:null==tm?void 0:tm.phone_number,email:null==tm?void 0:tm.email}}),o(null)}})})}catch(e){var i;console.error("Error in getReferenceId:",e),(0,ew.Yj)({event:"netpay3ds_init_threw",errorMessage:(null==e?void 0:e.message)||String(e),errorStack:null==e?void 0:e.stack,request:{ds_script_url:null==ta?void 0:ta.ds_script_url,sandboxMode:null==ta?void 0:ta.sandboxMode,amount:null==tg?void 0:null===(i=tg.data)||void 0===i?void 0:i.final_amount,restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,session_id:oR},userDetail:{member_id:null==tm?void 0:tm.member_id,phone_number:null==tm?void 0:tm.phone_number,email:null==tm?void 0:tm.email}}),o(null)}}),nu=async()=>{if(!(null==ta?void 0:ta.gateway_id)){console.error("No payment gateway ID available");return}try{let e=ta.ds_script_url;if(!await new Promise(t=>{document.querySelector('script[src="'.concat(e,'"]'))?t(!0):t(!1)})){let t=document.createElement("script");t.src=e,await new Promise((e,r)=>{t.onload=e,t.onerror=r,document.body.appendChild(t)})}if(at)return at.setSandboxMode(ta.sandboxMode),await nc()}catch(e){throw console.error("Error in threeDsScripturl:",e),e}},nm=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8));return i0(),new Promise(async(r,o)=>{let a=null;try{var i,l;let o=await nu();if((0,ew.Ws)("reference_id_obtained",t,{referenceId:o,amount:null==tg?void 0:null===(i=tg.data)||void 0===i?void 0:i.final_amount,device_fingerprint:rc,session_id:oR}),window.NetPay&&window.NetPay.token){let i={cardNumber:null==e?void 0:e.cardNumber,expMonth:null==e?void 0:e.dueDay,expYear:null==e?void 0:e.dueYear,cvv2:null==e?void 0:e.cvv,deviceFingerPrint:rc,referenceId:o},n=window.NetPay.card.validateNumber(i.cardNumber),s=window.NetPay.card.validateExpiry(i.expMonth,i.expYear),d=window.NetPay.card.validateCVV(i.cvv2,i.cardNumber);if((0,ew.Ws)("card_validation_result",t,{isValid:n,validateExpiry:s,validateCVV:d,card_last4:null===(l=i.cardNumber)||void 0===l?void 0:l.slice(-4),expMonth:i.expMonth,expYear:i.expYear,referenceId:o,session_id:oR}),n&&s&&d)a=e=>{e.error instanceof SyntaxError&&e.message.includes("JSON")&&(e.preventDefault(),window.removeEventListener("error",a),a=null,oF(t$("We were unable to process your card details. Please check and try again.")),i1(),r(null))},window.addEventListener("error",a),window.NetPay.token.create(i,l=>{a&&(window.removeEventListener("error",a),a=null),console.log("Token created successfully");let n=null;try{var s;let e=null==l?void 0:null===(s=l.message)||void 0===s?void 0:s.data;e&&(n=JSON.parse(e))}catch(e){}let d={target_path:"ecom/v1/",file_name:"netpay_success_logs",data:{message:"Netpay token creation successful",request:{formdata:e,cardInformation:i},response:n,url:window.location.href,userAgent:navigator.userAgent,resturantid:null==tz?void 0:tz.restaurant_id,timestamp:new Date().toISOString()},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()};if((0,eb.f)(d),n&&n.token)(0,ew.Ws)("token_created",t,{token:n.token,referenceId:o,user_detail:{member_id:null==tm?void 0:tm.member_id,phone_number:null==tm?void 0:tm.phone_number,email:null==tm?void 0:tm.email},res_detail:{restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,brand_id:null==tz?void 0:tz.brand_id},session_id:oR}),r({token:n.token,referenceId:o,traceId:t});else{oF("Please enter the valid card details");let t={target_path:"ecom/v1/",file_name:"ecom_error_logs",data:{error_message:"Token creation returned no token",error_source:"NetPay token create success callback",error_stack:"No valid card details",request:{formdata:e,cardInformation:i},response:n,url:window.location.href,userAgent:navigator.userAgent,error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()};(0,eb.f)(t),i1(),r(null)}},t=>{a&&(window.removeEventListener("error",a),a=null);let o={target_path:"ecom/v1/",file_name:"ecom_error_logs",data:{error_message:"Token creation failed",error_source:"NetPay token create error callback",error_stack:(null==t?void 0:t.message)||JSON.stringify(t)||"No stack trace",request:{formdata:e,cardInformation:i},response:t,url:window.location.href,userAgent:navigator.userAgent,resturantid:null==tz?void 0:tz.restaurant_id,timestamp:new Date().toISOString(),error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()};(0,eb.f)(o),console.error("Something went wrong!",t),oF(t$("We were unable to process your card details. Please check and try again.")),i1(),r(null)});else{let e="";n?s?d||(e=t$("Invalid Cvv.")):e=t$("Invalid Expiry."):e=t$("Invalid card number details."),oF(e);let t={target_path:"ecom/v1/",file_name:"ecom_error_logs",data:{error_message:"Validation failed: ".concat(e),error_source:"Card validation",error_stack:"No stack trace",url:window.location.href,resturantid:null==tz?void 0:tz.restaurant_id,userAgent:navigator.userAgent,error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()};(0,eb.f)(t),i1(),r(null)}}else{let e={target_path:"ecom/v1/",file_name:"ecom_error_logs",data:{error_message:"NetPay or NetPay.token is not available",error_source:"NetPay object check",error_stack:"No stack trace",url:window.location.href,userAgent:navigator.userAgent,resturantid:null==tz?void 0:tz.restaurant_id,timestamp:new Date().toISOString(),error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()};(0,eb.f)(e),oF(t$("NetPay or NetPay.token is not available.")),i1(),r(null)}}catch(t){a&&(window.removeEventListener("error",a),a=null),console.error(t);let e={target_path:"ecom/v1/",file_name:"ecom_error_logs",data:{error_message:t.message||"Unknown error in generateToken",error_source:"generateToken catch block",error_stack:t.stack||"
1No stack trace",url:window.location.href,userAgent:navigator.userAgent,resturantid:null==tz?void 0:tz.restaurant_id,error_line:"",error_column:""},source:"EcomV2",version:"1.0.0",ui_request_timestamp:new Date().toISOString()};(0,eb.f)(e),i1(),r(null)}})},n_=(0,u.useRef)(!1);(0,u.useEffect)(()=>{ae&&!ar||ar&&(console.error("Netpay script failed to load:",ar),oF(t$("Payment script failed to load")))},[ae,ar,oF,t$]),(0,u.useEffect)(()=>{n_.current&&i0()},[]);let np=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{i0();let i=await eu(e);if(200==i.status_code||201==i.status_code){console.log("Transaction confirmed successfully",i);let l=await em(e);if(console.log("NetPay - Getting transaction details.............",l),200==l.status_code){var t,r,o,a;console.log(l,"transactionResponse"),i1(),(null==rX?void 0:null===(r=rX.available_services)||void 0===r?void 0:null===(t=r.curveorder)||void 0===t?void 0:t.status)==!0&&("pickup"==e5||"takeout"==e5)?oC(!0):e9(!0),oT(),eL(!1),eP(!1),nP(),(null==rX?void 0:null===(a=rX.available_services)||void 0===a?void 0:null===(o=a.curveorder)||void 0===o?void 0:o.status)==!0&&("pickup"==e5||"takeout"==e5)||nT(rm)}else console.error("Failed to get transaction details",l),i1(),oF(null==l?void 0:l.message)}else console.error("Transaction failed",i),i1(),oF(t$(" Transaction failed "))}catch(e){console.error("Error calling netPayConfirmTransaction:",e),i1(),oF(t$("Failed to get transaction details"))}},nv=(e,t)=>(null==ta?void 0:ta.gateway_id)==7?H(e,t):"",ng=async function(e,t){var r,o,a,i,l,n,s,d;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",m=arguments.length>4&&void 0!==arguments[4]&&arguments[4],_=arguments.length>5?arguments[5]:void 0,p=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8));e$||i0(),n_.current=!0;let v=null==tg?void 0:tg.data,g=(0,ec.z)(),f=(null==c?void 0:c.cvv)||rp[null==e?void 0:e.token]||"",y={restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc&&lc,brand_id:null==tz?void 0:tz.brand_id,request_timestamp:new Date().toISOString(),payment_gateway_id:null==ta?void 0:ta.gateway_id,phone_number:null!==(o=null==tm?void 0:tm.phone_number)&&void 0!==o?o:"",order_amount:null==v?void 0:null===(r=v.final_amount)||void 0===r?void 0:r.toString(),request_id:null==v?void 0:v.request_id,save_card:!!m&&m,card_data:{paymentSource:{source:(null==e?void 0:e.token)||(null==u?void 0:u.token)||u||"",type:"card",cvv:f,device_fingerprint:(null==e?void 0:e.deviceFingerPrint)||rc||"",referenceId:_||u.referenceId||0},phone_number:(null==e?void 0:e.card_phone_number)?null==e?void 0:e.card_phone_number:(null==tm?void 0:tm.phone_number)?null==tm?void 0:tm.phone_number:""},orderId:t,session_id:oR,version:oB,source:"EcomV2"};c&&c.hasOwnProperty("firstName")&&(y.card_data.phone_number=c?null==c?void 0:c.telephone:null==tm?void 0:tm.phone_number,y.card_data.first_name=c?null==c?void 0:c.firstName:"",y.card_data.last_name=c?null==c?void 0:c.lastName:"",y.card_data.email=c?null==c?void 0:c.email:"",y.card_data.city=c?null==c?void 0:c.city:"",y.card_data.state=c?null==c?void 0:c.state:"",y.card_data.street=c?null==c?void 0:c.street:"",y.card_data.postal_code=c?null==c?void 0:c.postalCode:"",y.card_data.month=c?null==c?void 0:c.dueDay:"",y.card_data.card_number=c?null==c?void 0:c.cardNumber:"",y.card_data.year=c?null==c?void 0:c.dueYear:"",y.card_data.country=c?null==c?void 0:c.country:""),(0,ew.Ws)("make_payment_request",p,{source:y.card_data.paymentSource.source,referenceId:y.card_data.paymentSource.referenceId,amount:y.order_amount,save_card:y.save_card,orderId:t,user_detail:{member_id:null==tm?void 0:tm.member_id,phone_number:null==tm?void 0:tm.phone_number,email:null==tm?void 0:tm.email},res_detail:{restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,brand_id:null==tz?void 0:tz.brand_id},session_id:oR});let h=U.nodeRsaEncryption(JSON.stringify(y)),x=U.createSignature(JSON.stringify(y)),b=JSON.stringify({payload:h});g.append("x-foodbot-signature",x);let w="".concat(window.location.origin,"/"),N="https://order.foodbot.ai/apiv2";w&&(N=w+"apiv2");try{let e=await fetch("".concat(N,"/ecom/v1/pg/netpay/v1/make-payment"),{method:"POST",headers:g,body:b,redirect:"follow"}),r=await e.json();if((0,ew.Ws)("make_payment_response",p,{status:null==r?void 0:r.status,status_code:null==r?void 0:r.status_code,message:null==r?void 0:r.message,response:null==r?void 0:r.response,orderId:t,session_id:oR}),"success"===r.status.trim()&&"200"===r.status_code)(null==rX?void 0:null===(i=rX.available_services)||void 0===i?void 0:null===(a=i.curveorder)||void 0===a?void 0:a.status)==!0&&("pickup"==e5||"takeout"==e5)?oC(!0):e9(!0),oT(),eL(!1),eP(!1),nP(),(null==rX?void 0:null===(n=rX.available_services)||void 0===n?void 0:null===(l=n.curveorder)||void 0===l?void 0:l.status)==!0&&("pickup"==e5||"takeout"==e5)||nT(rm),i1(),n_.current=!1;else if("success"==r.status.trim()&&"203"==r.status_code){console.log("Encrypted Data:",r.data);let e=U.nodeRsaDecryption(r.data);if(e=JSON.parse(e),console.log("apiiiiiiiiiiiiiiiiiiiiiiiiiiiiii",ae,at,e),ae&&at){let t=at.canProceed(e.status,e.threeDSecureResponse.responseCode,e.threeDSecureResponse.acsUrl);if(console.log("Can proceed:",t),t){let t=!1;at.proceed(null,e.threeDSecureResponse.acsUrl,e.threeDSecureResponse.paReq,e.threeDSecureResponse.authenticationTransactionID,(o,a,i)=>{t||("success"===i?(y.card_data.paymentSource.transactionId=e.transactionTokenId,y.card_data.paymentSource.processorTransactionId=a,np(y,oa)):(oF(t$("Payment processing failed.")),console.log("Something Went Wrong:",r),i1(),n_.current=!1),t=!0)})}else{console.log("NetPay - Running 3D-Secure 2.0 (frictionless)"),y.card_data.paymentSource.transactionId=e.transactionTokenId;let t=await em(y);if(200==t.status_code||201==t.status_code)console.log("Transaction confirmed successfully",t),await np(y,oa);else{console.error("Transaction failed",t);let e=(null==t?void 0:t.message)||t$("Payment processing failed.");oF(e,nv(e,t)),i1(),n_.current=!1}}}else console.log("throwing error"),oF(t$("Payment processing failed.")),i1(),n_.current=!1}else if(409==r.status_code){let e=(null===(d=r.response)||void 0===d?void 0:null===(s=d.body)||void 0===s?void 0:s.error)||r.message||t$("Payment processing failed.");console.log("NetPay 409 Error - Invalid Business Identifier:",r),i1(),n_.current=!1,oF(e,nv(e,r)),(null==ta?void 0:ta.gateway_id)===7&&nd(ta)}else console.log("Something Went Wrong:",r),i1(),n_.current=!1,oF(r.message,nv(r.message,r)),(null==ta?void 0:ta.gateway_id)===7&&nd(ta)}catch(e){n_.current=!1,i1(),oF(t$("Payment processing failed.")),(null==ta?void 0:ta.gateway_id)===7&&nd(ta)}},nf=e=>e.map(e=>
1(0,eY.EY)(e,t3,t7)).join(", "),ny={orderID:tr,ecom_order_id:null==oa?void 0:oa.ecom_order_id,mode:null==tg?void 0:null===(P=tg.data)||void 0===P?void 0:P.order_type,hour:ts.time,date:ts.date,mobile:"delivery"===e5?null==rB?void 0:rB.phone_number:null==rX?void 0:rX.phone_number,branch:"delivery"===e5?null==rX?void 0:rX.formatted_address:null==rX?void 0:rX.branch_name},nh=e=>{var t,r;if(!e){rh(0),rN("percentage"),rk(""),rb(0);return}rh(e/100*Number(null==tg?void 0:null===(r=tg.data)||void 0===r?void 0:null===(t=r.order_items)||void 0===t?void 0:t.total)),rN("percentage"),rk(e.toString()),rb(0)},nx=e=>{let t=parseFloat(e.target.value);rh(0),rb(t),rN("absolute"),rk(t)},nb=()=>{rh(0),rN("absolute"),rk(""),rb(0),rC(!0),requestAnimationFrame(()=>{oK.current&&document.body.contains(oK.current)&&oK.current.focus()})},[nw,nN]=(0,u.useState)(!1),nj=async(e,t)=>{var r,o,a;console.log(t,"C");let i=[];if(Array.isArray(rE)&&rE.length>0?i=rE:"object"==typeof rE&&!Array.isArray(rE)&&Array.isArray(rE.menu_type)&&(i=rE.menu_type),0===i.length){let e=await (0,eN.KR)("branchMenuDetail_".concat(tU));e&&(rA(e),i=Array.isArray(e)?e:Array.isArray(e.menu_type)?e.menu_type:[])}if(0===i.length)return console.error("Menu not available for item lookup"),null;o_(null==t?void 0:t.item_key),ov((null==t?void 0:t.item_trx_id)||""),rP(t),console.log("menuArray:",i);let l=(t,r)=>Array.isArray(null==t?void 0:t.menu_category)?t.menu_category.find(t=>Array.isArray(t.cat_items)&&(null==r||t.category_id==r)&&t.cat_items.some(t=>t.item_id==e)):void 0,n=null,s=null;if(null==t?void 0:t.menu_id){let e=i.find(e=>e.menu_id==t.menu_id);if(e){let o=null!==(r=l(e,null==t?void 0:t.category_id))&&void 0!==r?r:l(e);o&&(n=e,s=o)}}if(s||(s=(n=null!==(o=i.find(e=>l(e)))&&void 0!==o?o:null)?l(n):null),n&&s){let t=s.cat_items.find(t=>t.item_id==e);if(t){let e="scheduledOrder_".concat(rm),r=localStorage.getItem(e),o=new Date,i=!1,l=!1;if(r)try{let e=JSON.parse(r);if(e.date&&e.time){if(i=!0,"ASAP"===e.time.toUpperCase())l=!0,o=new Date;else{let[t,r]=e.time.split(" "),[a,i]=t.split(":").map(Number);"PM"===r&&a<12&&(a+=12),"AM"===r&&12===a&&(a=0);let[l,n,s]=e.date.split("-").map(Number);o=new Date(l,n-1,s,a,i)}}}catch(e){console.error("Error parsing scheduled order:",e)}let d=o.getDay();if(o.getHours(),o.getMinutes(),n.menu_timing&&n.menu_timing.length>0){let e=n.menu_timing.find(e=>e.day===d.toString());if(e){let[t,r]=e.open_time.split(":").map(Number),[a,i]=e.close_time.split(":").map(Number),l=new Date(o);l.setHours(t,r,0,0);let s=new Date(o);s.setHours(a,i,0,0),(a<t||a===t&&i<=r)&&s.setDate(s.getDate()+1);let d=o>=l&&o<=s;if(!d&&o<l){let e=new Date(o);e.setDate(e.getDate()-1);let t=e.getDay(),r=n.menu_timing.find(e=>e.day===t.toString());if(r){let[t,a]=r.open_time.split(":").map(Number),[i,l]=r.close_time.split(":").map(Number),n=new Date(e);n.setHours(t,a,0,0);let s=new Date(e);s.setHours(i,l,0,0),(i<t||i===t&&l<=a)&&s.setDate(s.getDate()+1),d=o>=n&&o<=s}}console.log(o,l,s,"ioio"),console.log("isMenuAvailable:",d)}}let c=!0;if(s.menu_timing&&s.menu_timing.length>0){let e=s.menu_timing.find(e=>e.day===d.toString());if(e){let[t,r]=e.open_time.split(":").map(Number),[a,i]=e.close_time.split(":").map(Number),l=new Date(o);l.setHours(t,r,0,0);let n=new Date(o);n.setHours(a,i,0,0),c=o>=l&&o<=n}}let u=!0;if(t.menu_timing&&t.menu_timing.length>0){let e=t.menu_timing.find(e=>e.day===d.toString());if(e){let[t,r]=e.open_time.split(":").map(Number),[a,i]=e.close_time.split(":").map(Number),l=new Date(o);l.setHours(t,r,0,0);let n=new Date(o);n.setHours(a,i,0,0),u=o>=l&&o<=n}}let m=c&&u;if(console.log(!0,c,u,"popo"),l){let e=null==aE?void 0:null===(a=aE.branch)||void 0===a?void 0:a.branch_business_hours;if(e&&e.length>0){let t=e.find(e=>e.day===d.toString());if(t){let[e,r]=t.open_time.split(":").map(Number),[a,i]=t.close_time.split(":").map(Number),l=new Date(o);l.setHours(e,r,0,0);let n=new Date(o);n.setHours(a,i,0,0),o>=l&&o<=n||(m=!1)}}}let _={...t,isAvailable:m,availabilityDetails:{menu:!0,category:c,item:u},isScheduledOrder:i,isASAPOrder:l,scheduledTime:i&&!l?o:null};return console.log("itemWithAvailability:",_),rO(_),rF(!0),nN(m),_}}return console.error("No matching item found for itemid:",e),null},nk="".concat(window.location.origin,"/"),nS=async(t,r)=>{let o=localStorage.getItem("branch_delivery_".concat(rm));o&&rz(JSON.parse(o));let a=null==tz?void 0:tz.restaurant_id,i=t3||tz.bot_language;al(!0),await (0,$.x)(t,r,a,i,t6,e,null,null,null,eJ,null,e=>(0,el.YA)(e,i3),es._,j.d,rB,oR,oB,!0,tU,nk,oF,"cart"),nF(),await la(),al(!1)},[nC,nI]=(0,u.useState)("");(0,u.useEffect)(()=>{"delivery"!==e5&&(aG(null),localStorage.removeItem("selected_delivery_partner_".concat(tU)),aL(!0))},[e5,t6.query.resturant]);let nF=()=>{rn({}),rv({}),rf(null),eU([]),tn({}),rQ(null),tu(null),i1(),eR(""),ii(0),io(!1),is(!1),as(""),im(!1),rk(""),rh(0),rb(0),rC(!1),nI(""),of(!1),od(!1)},nE=e=>{rK(e),rW(!0),setTimeout(()=>{rW(!1)},3e3)},nA=(e,t)=>{oU(r=>({...r,[e]:t}))},nD=e=>{var t;(null==eB?void 0:null===(t=eB.data)||void 0===t?void 0:t.multipleoffer_redeem)==="no"&&oX&&(oZ(!1),oQ(null)),t9(e)},nO=e=>{let t=localStorage.getItem("scheduledOrder_".concat(e));t&&localStorage.setItem("scheduleOrderResponse_".concat(e),t)},nM=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rm;if(o6.current=!1,t9({}),!e)return;localStorage.removeItem("offer_details_".concat(e));let t=localStorage.getItem("cartData_".concat(e));if(t)try{let r=JSON.parse(t);(null==r?void 0:r.promotion_applied)&&(delete r.promotion_applied,localStorage.setItem("cartData_".concat(e),JSON.stringify(r)))}catch(e){console.error("Failed to clear promotion from cartData:",e)}window.dispatchEvent(new Event("promotionCleared"))};(0,u.useEffect)(()=>{var e;if((null!==(e=null==e3?void 0:e3.length)&&void 0!==e?e:0)>0){o9.current=!0;return}o9.current&&(o9.current=!1,nM())},[e3]);let nP=()=>{nO(rm),e6([]),eZ({subtotal:0,discount:0,tax:0,tip:0,service:0,total:0}),localStorage.removeItem("scheduledOrder_".concat(rm)),localStorage.removeItem("current_scheduledOrder__".concat(tU))},nT=async e=>{nO(e),nM(e);let t=["http_referrer_".concat(e),"utm_campaign_".concat(e),"utm_source_".concat(e),"cartItemDetails_".concat(e),"order_id_".concat(e),"selected_delivery_partner_".concat(e),"offer_details_".concat(e),"selected_branchmode_".concat(e),"payload_".concat(e),"payment_method_".concat(e),"scheduledOrder_".concat(e),"selecteduserAddress_".concat(e),"userAddress_".concat(e),"hasShownUpsellingPopup_".concat(e),"delivery_partners_".concat(e),"billpocket_transaction_".concat(e),"is_paying_with_saved_billpocket_card_".concat(e),"selected_billpocket_card_".concat(e),"callin_order_".concat(e),"handleBranchClickCaller_".concat(e)
1];localStorage.removeItem("callin_open_payment"),["selected_branchmode_".concat(e),"payload_".concat(e),"payment_method_".concat(e)].forEach(e=>{localStorage.removeItem(e),e2.A.remove(e)}),t.forEach(e=>localStorage.removeItem(e)),await (0,eN.B9)("branchMenuDetail_".concat(e))};if(!tN)return null;if(aM||ie||ai)return(0,o.jsx)("div",{className:"flex justify-center",children:(0,o.jsx)(en.A,{text:t$("processing")})});let nL=()=>{eP(!1),setTimeout(()=>{rG(!0)},300)};if(!aw||aN)return(0,o.jsx)("div",{className:"min-h-screen bg-gray-100 flex items-center justify-center",children:(0,o.jsxs)("div",{className:"bg-white p-8 rounded-lg shadow-md text-center",children:[(0,o.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900 mx-auto mb-4"}),(0,o.jsx)("p",{className:"text-lg font-medium",children:"Loading Maps..."})]})});let nq=(null==tg?void 0:null===(B=tg.data)||void 0===B?void 0:null===(T=B.order_items)||void 0===T?void 0:T.is_delivery_discount)&&(null!==(eA=null==e3?void 0:e3.length)&&void 0!==eA?eA:0)>0?"".concat(Number(null==tg?void 0:null===(J=tg.data)||void 0===J?void 0:J.delivery_cost)):(null==tg?void 0:null===(V=tg.data)||void 0===V?void 0:V.delivery_cost)&&(null!==(eO=null==e3?void 0:e3.length)&&void 0!==eO?eO:0)>0?"".concat(null==tg?void 0:null===(Q=tg.data)||void 0===Q?void 0:Q.delivery_cost):"0.00",nR=localStorage.getItem("orderTotal_".concat(rm));return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(ty.A,{open:oS,onClose:()=>{oC(!1),e9(!0),nT(rm)},onSubmit:ni,secondaryColor:lz,secondaryBtn:lG,secondaryText:lY,fontFamily:lV,primaryColor:lB,instruction:null==rX?void 0:null===(eg=rX.available_services)||void 0===eg?void 0:null===(ev=eg.curveorder)||void 0===ev?void 0:ev.instruction,currency:null==tz?void 0:tz.currency_symbol,ErrorPrimaryColor:lZ,secondaryBtnTxtColor:lY,saveAlias:rm,taxDetails:{total:nR?parseFloat(nR):0}}),(0,o.jsx)(L.default,{id:az,resId:o7.current,page:aJ,data:{content_ids:null==ao?void 0:ao.content_ids,content_type:null==ao?void 0:ao.content_type,value:null==ao?void 0:ao.value,currency:null==ao?void 0:ao.currency,num_items:null==ao?void 0:ao.num_items}}),(0,o.jsx)(q.default,{id:aW,settings:aD,page:aJ,data:o2,page_location:aV}),a4&&(0,o.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black bg-opacity-50",children:(0,o.jsxs)("div",{style:{backgroundColor:lK,fontFamily:"".concat(lV,", sans-serif"),color:lB},className:"p-6 rounded-lg shadow-lg w-[374px] max-h-[80vh] overflow-y-auto",children:[(0,o.jsx)("h2",{className:"text-xl font-black mb-4",children:t$("Unavailable Items")}),(0,o.jsx)("p",{className:"mb-4",children:t$("The following items are no longer available and will be removed from your cart:")}),(0,o.jsx)("ul",{className:"list-disc pl-5 mb-4",children:a7.map((e,t)=>(0,o.jsx)("li",{children:(0,eY.X5)(e,t3,t7)||(0,eY.HS)(e.item_name,e.item_name_v1,t3,t7)},t))}),(()=>{let e=0==e3.filter(e=>!a7.some(t=>t.item_id==e.item_id)).length;return(0,o.jsx)("button",{style:{backgroundColor:lG,color:lY,fontFamily:"".concat(lV,", sans-serif")},className:"w-full py-2 rounded-lg font-black",onClick:ns,children:e?t$("Back to Menu"):t$("Review Cart")})})()]})}),r3&&(0,o.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black bg-opacity-50 px-4",children:(0,o.jsxs)("div",{style:{backgroundColor:lK,fontFamily:"".concat(lV,", sans-serif"),color:lB},className:"p-6 rounded-lg shadow-lg w-full max-w-[374px] max-h-[80vh] overflow-y-auto",children:[(0,o.jsx)("h2",{className:"text-xl font-black mb-4",children:t$("upsell_remove_title")}),(0,o.jsx)("p",{className:"mb-4",children:t$("upsell_remove_message",{item:(0,eY.X5)(r3.parent,t3,t7)||(null===(eh=r3.parent)||void 0===eh?void 0:eh.item_name)})}),(0,o.jsx)("ul",{className:"list-disc pl-5 mb-4",children:r3.dependents.map((e,t)=>(0,o.jsx)("li",{children:(0,eY.X5)(e,t3,t7)||(null==e?void 0:e.item_name)},t))}),(0,o.jsx)("button",{style:{backgroundColor:lG,color:lY,fontFamily:"".concat(lV,", sans-serif")},className:"w-full py-2 rounded-lg font-black",onClick:lC,children:t$("upsell_remove_confirm")}),(0,o.jsx)("button",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"w-full py-2 mt-2 rounded-lg font-bold underline",onClick:()=>r7(null),children:t$("upsell_remove_cancel")})]})}),ow&&(0,o.jsx)(eS,{primaryColor:lB,primaryBtnColor:lW,primaryBtnTxtColor:lH,secondaryBtnColor:lG,secondaryBtnTxtColor:lY,bgColor:lK,fontFamily:lV,setShowBranchConfirmModal:oN,setChangeModeModal:rG,setOpenMode:rL,saveModedetails:"delivery"===e5?null==rX?void 0:rX.formatted_address:null==rX?void 0:rX.branch_name,handleConfirmBranch:()=>{oN(!1),"requestIdleCallback"in window?window.requestIdleCallback(ln,{timeout:500}):setTimeout(ln,0)},saveDeliveryMode:e5,pickupScheduleData:i_,localalias:"".concat(t6.query.resturant),dineintable:a0}),(0,o.jsx)(L.default,{id:az,resId:o7.current,page:aJ,data:{content_ids:null==ao?void 0:ao.content_ids,content_type:null==ao?void 0:ao.content_type,value:null==ao?void 0:ao.value,currency:null==ao?void 0:ao.currency,num_items:null==ao?void 0:ao.num_items}}),(0,o.jsxs)("div",{style:{backgroundColor:lK,fontFamily:"".concat(lV,", sans-serif")},className:"relative",children:[rU&&(0,o.jsx)(Z.default,{message:rY,onClose:()=>rW(!1)}),oA&&(0,o.jsx)(eo.default,{open:oA,setOpen:oE,modalMessage:oM,closeModal:()=>oE(!1)}),oD&&(0,o.jsx)(ea.default,{open:oD,setOpen:oO,modalMessage:oM,modalDetail
1:oP,closeModal:()=>oO(!1),redcolor:lZ,fontFamily:lV}),e8&&(0,o.jsx)(z,{open:e8,setOpen:e9,thankyouJson:ny,secondaryColor:lz,primaryColor:lB,fontFamily:lV,bgColor:lK,orderexp:()=>{let e=(0,ec.z)(),t=JSON.stringify({restaurant_id:null==tz?void 0:tz.restaurant_id,branch_id:lc,brand_id:null==tz?void 0:tz.brand_id,member_id:null==tm?void 0:tm.member_id,order_id:tr,rating:ra,comments:rr,phone_number:null==tm?void 0:tm.phone_number,session_id:oR,lang:null==tz?void 0:tz.bot_language,source:"EcomV2",version:oB,ui_request_timestamp:new Date().toISOString(),scheduled_order:aq?1:0}),r="".concat(window.location.origin,"/"),o="https://order.foodbot.ai/apiv2";r&&(o=r+"apiv2"),fetch("".concat(o,"/ecom/v1/ordering-experience"),{method:"POST",headers:e,body:t,redirect:"follow"}).then(e=>e.json()).then(e=>{"success"==e.status&&200==e.status_code?(ro(""),ri(0),e9(!1),localStorage.removeItem("branch_delivery_".concat(rm)),localStorage.removeItem("scheduleOrderResponse_".concat(rm)),eP(!1),setTimeout(()=>{tt(!0)},100)):oF(e.message)}).catch(e=>console.error("Fetch error:",e))},ratings:ra,comment:rr,setRatings:ri,setComment:ro,secondaryBtnTxtColor:lY,secondaryBtnColor:lG,saveDeliveryMode:e5,handleClick:lu,localalias:"".concat(t6.query.resturant),ErrorPrimaryColor:lZ,pixelId:az,gMeasurementId:aW,userCartData:aI,page_location:aV,shippingCost:nq}),oq&&(0,o.jsx)(ef,{message:oM,primaryColor:lB,secondaryColor:lz,fontFamily:lV,onClose:()=>oL(!1),bgColor:lK,paymentModal:eP}),rI&&rD&&(0,o.jsx)("div",{className:"transition-transform duration-1000 ease-in-out ".concat(rI?"translate-x-0 opacity-100":"translate-x-full opacity-0"),children:(0,o.jsx)(G.default,{localalias:"".concat(t6.query.resturant),sessionID:oR,open:rI,setOpen:rF,data:rD,resturant_currency:null==tz?void 0:tz.currency_symbol,selectedCartItem:rM,specialInstruction:oV[rD],onSpecialInstructionChange:e=>nA(rD,e),setSpecialInstructions:oU,secondaryBtnColor:lG,update:"update",updateId:om,updateTrxId:op,primaryColor:lB,secondaryColor:lz,fontFamily:lV,descriptionColor:lU,bgColor:lK,primaryBtnColor:lW,primaryBtnTxtColor:lG,secondaryBtnTxtColor:lY,highlightTextColor:lJ,highlightbgColor:lX,ErrorPrimaryColor:lZ,selectionLimit_text_color:l$,item_goback_button_text_color:lQ,item_goback_button_color:l0,restaurantOpen:i4,openFailureModalFunc:oF,pickupScheduleData:i_,isMenuAvailabl:nw,pixelId:az,gMeasurementId:aW,page_location:aV})}),(0,o.jsx)("div",{className:"lg:block hidden",children:(0,o.jsx)(Y.default,{open:rT,setOpen:rL,setAddress:()=>ax(""),setCheckItemurl:tA,children:rT&&(0,o.jsxs)("div",{className:"flex h-[500px]   border-4",children:[(0,o.jsx)("div",{className:"w-[75%] ",children:(0,o.jsx)("div",{className:"w-[100%] sm:w-[950px] mx-auto h-[100%]",children:(0,o.jsx)(t5,{mapContainerStyle:ad,center:ap||ac,zoom:10,onLoad:au,onClick:am,children:ap&&(0,o.jsx)(t4,{position:ap})})})}),(0,o.jsx)("div",{className:"w-[600px] overflow-y-auto   custom-scrollbar ",style:{"--scrollbar-thumb-color":lz},children:(0,o.jsx)(K.A,{localalias:"".concat(t6.query.resturant),getPickupBranches:rq,getClickedBranchId:nS,restaurantSettingsServer:tz,setIsOpen:rL,triggerError:()=>nE(t$("we_do_not_deliver")),searchAddress:ah,setSearchAddress:ax,map:af,marker:ap,setMarker:ay,handleLocationSelect:ag,autocompleteRef:av,login:localStorage.getItem("loggedin_".concat(t6.query.resturant)),setOpenLoginModal:{},schedulesetting:null==eB?void 0:eB.data,validateCartItemsAgainstMenu:lj,setIsCartUpdated:aL,setSaveCartCal:tx,setTaxDetails:eZ,setCartItemDetails:e6,cartpagevalidate:"cartpagevalidate",saveCartCal:tg,setCheckItemurl:tA,checkItemurl:tE})})]})})}),(0,o.jsx)("div",{className:"lg:hidden block",children:(0,o.jsx)(ei.default,{isOpen:rH,setIsOpen:rG,secondaycolor:lY,primarycolor:lG,setAddress:()=>ax(""),children:rH&&(0,o.jsx)(K.A,{localalias:"".concat(t6.query.resturant),getPickupBranches:rq,getClickedBranchId:nS,restaurantSettingsServer:tz,setIsOpen:rG,triggerError:()=>nE(t$("we_do_not_deliver")),searchAddress:ah,setSearchAddress:ax,map:af,marker:ap,setMarker:ay,handleLocationSelect:ag,autocompleteRef:av,login:localStorage.getItem("loggedin_".concat(t6.query.resturant)),setOpenLoginModal:{},schedulesetting:null==eB?void 0:eB.data,validateCartItemsAgainstMenu:lj,setCartItemDetails:e6,setIsCartUpdated:aL,setSaveCartCal:tx,setTaxDetails:eZ,cartpagevalidate:"cartpagevalidate",saveCartCal:tg,checkItemurl:tE,setCheckItemurl:tA})})}),(0,o.jsx)("div",{className:"absolute top-1 cursor-pointer lg:right-4 right-0 z-10 pr-6 p-4",onClick:lu,children:(0,o.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("rect",{width:"15.1632",height:"3.03264",transform:"matrix(0.707107 -0.707106 0.707107 0.707106 4.28906 15.0109)",fill:lB}),(0,o.jsx)("rect",{width:"15.1632",height:"3.03264",transform:"matrix(-0.707107 -0.707106 0.707107 -0.707106 15.0107 17.155)",fill:lB})]})}),(0,o.jsx)("div",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"py-4 first-letter:uppercase font-black text-lg border border-b-lightGray flex items-center lg:max-w-full max-w-7xl px-4 sm:px-8",children:t$("my_cart")}),(0,o.jsxs)("div",{className:"lg:hidden block",children:[" ",(0,o.jsx)(e_,{fontFamily:lV,primaryColor:lB,saveDeliveryMode:e5,saveModedetails:rX,deliveryTime:rB,setOpenMode:()=>rL(!0),handlePaymentMethod:l4,loader:e$,setChangeModeModal:nL})]}),(0,o.jsxs)("div",{className:"grid lg:grid-cols-2  ",children:[(0,o.jsxs)("div",{className:"lg:px-10 pb-[200px] lg:border lg:border-r-2 \n            ".concat((null==e3?void 0:e3.length)<=1?"h-[100vh] lg:h-auto":"","\n         \n          "),children:[(null==e3?void 0:e3.length)>0?(0,o.jsxs)("div",{style:{backgroundColor:lK,fontFamily:"".concat(lV,", sans-serif")},children:[null==e3?void 0:e3.map((e,t)=>{var r;return(0,o.jsxs)("div",{style:{borderColor:lB,backgroundColor:e.needsUpdate?"#FEF2F2":""},className:"border-b lg:mx-6 ".concat(e.needsUpdate?"py-4  ":"py-8"," lg:max-w-full max-w-7xl mx-4 sm:mx-8 px-4"),children:[(0,o.jsx)("div",{className:"flex justify-end",children:e.needsUpdate&&(0,o.jsx)("div",{className:"w-fit bg-red-500 text-white text-xs px-2 py-1 rounded-lg font-semibold",children:"Update Required"})}),(0,o.jsxs)("div",{className:"flex lg:gap-x-8  w-full",children:[(0,o.jsx)("div",{className:" ",children:e.item_image?(0,o.jsx)(y(),{src:e.item_image,width:73,height:87,alt:"Product Image",className:"h-[73px] w-[87px] rounded-md object-cover",priority:!0,sizes:"(max-width: 768px) 50vw, 73px"}):(0,o.jsx)("div",{className:"h-[73px] w-[87px] rounded-md bg-gray-200 flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-gray-500 text-sm",children:"No Image"})})}),(0,o.jsxs)("div",{className:"md:flex ",children:[(0,o.jsxs)("div",{className:"  w-[250px]  px-6 ",children:[(0,o.jsx)("div",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"font-black text-[21px] leading-6",children:(0,eY.X5)(e,t3,t7)}),(0,o.jsxs)("div",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"font-black  pb-2 text-[17px]",children:["$",e.item_price_with_modifier*e.quantity]}),e.item_modifiers&&(null!==(r=e.isPackage)&&void 0!==r?r:0)===0&&e.item_modifiers.length>0&&(0,o.jsxs)("div",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"text-[13px] leading-4 pb-2",children:[t$("extras_label"),":"," ",nf(e.item_modifiers)]}),1===e.isPackage&&e.package_items&&e.package_items.length>0&&(0,o.jsxs)("div",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"text-[13px] leading-4 pb-2",children:[(0,o.jsx)("strong",{children:"Addons:"}),(()=>{let t={},r={};
1e.package_items.forEach(e=>{t[e.item_id]=(t[e.item_id]||0)+1});let a=e.package_items.map((e,o)=>{r[e.item_id]?r[e.item_id]+=1:r[e.item_id]=1,r[e.item_id],t[e.item_id];let a=e.modifiers.map(e=>"".concat(e.quantity,"x\n                                                ").concat((0,eY.EY)(e,t3,t7))).join(", "),i="<strong>".concat(1*e.quantity,"x").concat(e.item_name,"</strong>");return"".concat(a?" ".concat(i," - ").concat(a):" ".concat(i))});return(0,o.jsx)("span",{children:a.map((e,t)=>(0,o.jsx)("span",{dangerouslySetInnerHTML:{__html:e}},t))})})()]}),(0,o.jsx)("div",{style:{color:e.needsUpdate?"#EF4444":lB,fontFamily:"".concat(lV,", sans-serif"),backgroundColor:e.needsUpdate?"#FEE2E2":"transparent"},className:"text-xs mb-4 cursor-pointer underline underline-offset-2 ".concat(e.needsUpdate?"font-semibold px-3 py-2 rounded-md border border-red-300 bg-red-50 hover:bg-red-100 transition-colors":""),onClick:()=>nj(e.item_id,e),children:e.needsUpdate?"♻ "+t$("Update_Item"):"✏️ "+t$("edit")}),(null==e?void 0:e.special_instruction)&&(0,o.jsxs)("div",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"text-xs pb-2",children:[(0,o.jsxs)("span",{className:"font-bold",children:[t$("special_instructions"),":"]})," ",(0,o.jsx)("br",{}),e.special_instruction]})]}),(0,o.jsx)("div",{className:"  w-[50px]   px-6",children:(0,o.jsxs)("div",{className:"flex items-center ",children:[1===e.quantity&&(0,o.jsx)("div",{onClick:()=>lS(t),children:(0,o.jsxs)("svg",{style:{color:lB},width:"20",height:"24",className:"cursor-pointer",viewBox:"0 0 16 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{d:"M13.3741 3.87646L12.2373 19.3045H2.8181L1.6001 3.87646",stroke:lB,strokeWidth:"1.20834","stroke-miterlimit":"10"}),(0,o.jsx)("path",{d:"M9.96362 8.34253V14.8385",stroke:lB,strokeWidth:"1.20834","stroke-miterlimit":"10"}),(0,o.jsx)("path",{d:"M5.09155 8.34253V14.8385",stroke:lB,strokeWidth:"1.20834","stroke-miterlimit":"10"}),(0,o.jsx)("path",{d:"M7.52759 7.53052V15.6505",stroke:lB,strokeWidth:"1.20834","stroke-miterlimit":"10"}),(0,o.jsx)("path",{d:"M0.625488 3.87646H14.4295",stroke:lB,strokeWidth:"1.20834","stroke-miterlimit":"10","stroke-linecap":"round"}),(0,o.jsx)("path",{d:"M10.613 3.87633L9.88221 1.76513C9.80101 1.52153 9.55741 1.35913 9.39501 1.35913H5.6598C5.4162 1.35913 5.1726 1.52153 5.1726 1.76513L4.3606 3.87633",stroke:lB,strokeWidth:"1.20834","stroke-miterlimit":"10",strokeLinejoin:"round"})]})}),e.quantity>1&&(0,o.jsx)("div",{onClick:()=>lN(t),children:(0,o.jsxs)("svg",{width:"24",height:"24",className:"mt-1 cursor-pointer",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("ellipse",{cx:"10.8575",cy:"10.195",rx:"9.207",ry:"9.207",transform:"rotate(-180 10.8575 10.195)",stroke:lB,strokeWidth:"1.54805"}),(0,o.jsx)("rect",{x:"14.6309",y:"10.9497",width:"7.54672",height:"1.50934",transform:"rotate(-180 14.6309 10.9497)",fill:lB})]})}),(0,o.jsx)("div",{style:{color:lB},className:"mx-3 font-black text-[25px]",children:e.quantity}),(0,o.jsx)("div",{onClick:()=>lw(t),children:(0,o.jsxs)("svg",{style:{color:lB},width:"24",height:"24",className:"mt-1 cursor-pointer",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("ellipse",{cx:"10.6141",cy:"10.2569",rx:"9.24899",ry:"9.24898",transform:"rotate(-180 10.6141 10.2569)",stroke:lB,strokeWidth:"1.5551"}),(0,o.jsx)("rect",{x:"14.4045",y:"11.0149",width:"7.58113",height:"1.51623",transform:"rotate(-180 14.4045 11.0149)",fill:lB}),(0,o.jsx)("rect",{x:"11.3721",y:"6.46631",width:"7.58114",height:"1.51623",transform:"rotate(90 11.3721 6.46631)",fill:lB})]})})]})})]})]})]},e.item_id||t)}),(0,o.jsxs)("div",{className:"mt-4  mx-6",children:[(0,o.jsxs)("label",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"flex items-center text-sm font-bold mb-2",children:[t$("order_comment"),(0,o.jsx)("span",{className:"ml-1 text-gray-500",children:(0,o.jsx)(tB.A,{className:"w-5 h-5 font-bold"})})]}),(0,o.jsx)("textarea",{value:ox,onChange:e=>ob(e.target.value),placeholder:t$("add_special_instructions"),maxLength:500,rows:3,style:{fontFamily:"".concat(lV,", sans-serif"),borderColor:lB},className:"w-full px-3 py-2 border rounded-md resize-none focus:outline-none focus:ring-2 focus:ring-opacity-50"}),(0,o.jsxs)("div",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"text-xs text-right mt-1 opacity-70",children:[ox.length,"/500"]})]})]}):(0,o.jsx)("div",{className:"p-8 mt-8",children:(0,o.jsxs)("div",{className:"text-center ",children:[(0,o.jsxs)("svg",{width:"180",height:"180",viewBox:"0 0 216 180",fill:"none",className:"m-auto",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsxs)("g",{clipPath:"url(#clip0_5292_1051)",children:[(0,o.jsx)("path",{d:"M201.474 55.5786H38.5686V65.121H201.474V55.5786Z",fill:lz}),(0,o.jsx)("path",{d:"M3.78418 15.4182L5.04838 3.71704H31.4538L48.0564 6.09004L54.0666 15.4182V30.912L50.6772 40.0848L35.7252 38.8206L38.5686 25.0614L37.1448 16.9974L28.7364 15.4182L16.9092 15.2586L3.78418 15.4182Z",fill:lz}),(0,o.jsx)("path",{d:"M214.439 38.7575C214.126 38.3053 213.708 37.9357 213.221 37.6804C212.734 37.4251 212.192 37.2917 211.642 37.2917H54.6294L57.2082 22.1297C57.6742 19.4116 57.5396 16.6244 56.8141 13.9638C56.0885 11.3032 54.7895 8.8336 53.0082 6.72832C51.2313 4.61998 49.0146 2.92594 46.5137 1.76507C44.0127 0.604194 41.2881 0.00460091 38.5308 0.00831796H3.402C2.95525 0.00831796 2.51287 0.0963139 2.10012 0.26728C1.68737 0.438247 1.31233 0.688836 0.996423 1.00474C0.680518 1.32065 0.429929 1.69567 0.258962 2.10842C0.0879959 2.5211
17 0 2.96355 0 3.41031V15.9137C0.00111301 16.8153 0.360032 17.6795 0.99791 18.3166C1.63579 18.9537 2.50046 19.3115 3.402 19.3115H32.8944C33.2876 19.3097 33.6759 19.3985 34.0292 19.5712C34.3825 19.7438 34.6912 19.9956 34.9314 20.3069C35.1745 20.6166 35.3433 20.978 35.4248 21.3632C35.5064 21.7483 35.4985 22.1471 35.4018 22.5287L31.017 39.8579C31.017 39.8579 31.017 39.8831 31.017 39.8915L30.9918 40.0259C30.9918 40.1015 30.9624 40.1813 30.9498 40.2569V40.3829C30.9498 40.4627 30.9498 40.5425 30.9498 40.6223V40.7399C30.9498 40.8239 30.9498 40.9121 30.9498 40.9961V41.1053C30.9498 41.1935 30.975 41.2775 30.9918 41.3657C30.9902 41.3881 30.9902 41.4105 30.9918 41.4329L34.0704 55.2341L35.7504 62.7101L36.9558 68.1197L45.003 104.16L46.683 111.653L46.7376 111.896L48.7284 120.821L45.8472 137.499C45.8052 137.743 45.7716 137.987 45.7464 138.234C45.7464 138.264 45.7464 138.293 45.7464 138.323C45.7254 138.533 45.7086 138.743 45.7002 138.944C45.7002 139.003 45.7002 139.062 45.7002 139.116C45.7002 139.297 45.7002 139.478 45.7002 139.658C45.7002 139.726 45.7002 139.793 45.7002 139.856C45.7002 140.032 45.7002 140.204 45.7254 140.376C45.7254 140.444 45.7254 140.511 45.7254 140.574C45.7254 140.755 45.759 140.931 45.7842 141.107C45.7842 141.166 45.7842 141.221 45.8052 141.28C45.8346 141.485 45.8724 141.7 45.9102 141.893C45.9126 141.919 45.9126 141.946 45.9102 141.973C46.0071 142.441 46.1334 142.902 46.2882 143.354C46.2882 143.4 46.3176 143.447 46.3344 143.493C46.3974 143.665 46.4604 143.842 46.5318 144.014C46.557 144.077 46.5864 144.14 46.6116 144.207C46.6746 144.358 46.7418 144.509 46.8132 144.656L46.914 144.866C46.9896 145.009 47.061 145.152 47.1408 145.286L47.2542 145.492C47.3382 145.635 47.4222 145.778 47.5104 145.912L47.628 146.097C47.733 146.257 47.8422 146.416 47.9598 146.571L48.0354 146.681C48.174 146.865 48.321 147.05 48.4554 147.231V147.252L48.5016 147.302C48.6402 147.466 48.783 147.626 48.9216 147.781L49.0896 147.949C49.1988 148.062 49.308 148.172 49.4214 148.277L49.7238 148.55L49.8582 148.663L50.1942 148.936L50.3622 149.066C50.4168 149.108 50.4714 149.15 50.5302 149.188C52.5734 150.685 55.0408 151.491 57.5736 151.49H186.018C186.92 151.489 187.784 151.13 188.421 150.492C189.058 149.854 189.416 148.989 189.416 148.088V141.548C189.414 138.762 188.307 136.091 186.339 134.119C184.371 132.147 181.702 131.035 178.916 131.027H53.8692L55.083 124.005H55.146L184.057 117.44C184.717 117.408 185.354 117.183 185.888 116.794C186.422 116.404 186.831 115.867 187.064 115.248L214.822 41.8907C215.016 41.3765 215.083 40.8228 215.016 40.277C214.95 39.7313 214.752 39.2099 214.439 38.7575ZM178.899 137.827C179.389 137.825 179.874 137.92 180.328 138.107C180.781 138.293 181.193 138.567 181.54 138.912C181.887 139.258 182.163 139.669 182.351 140.121C182.539 140.573 182.636 141.058 182.637 141.548V144.707H57.6366H57.4854H57.2628C56.7429 144.669 56.2316 144.553 55.7466 144.362L55.5618 144.287L55.3686 144.199C55.2468 144.136 55.125 144.077 55.0074 144.005L54.9486 143.972C54.6473 143.787 54.3658 143.572 54.1086 143.329L54.054 143.279C53.9322 143.157 53.8104 143.031 53.697 142.896C53.5878 142.766 53.487 142.632 53.3904 142.476L53.3568 142.426C53.2605 142.285 53.1735 142.138 53.0964 141.985C53.0827 141.964 53.0715 141.941 53.0628 141.918C52.9038 141.613 52.7771 141.292 52.6848 140.96C52.6848 140.935 52.6848 140.914 52.6848 140.889C52.6375 140.723 52.6011 140.555 52.5756 140.385C52.5756 140.385 52.5756 140.385 52.5756 140.355C52.5504 140.188 52.5336 140.015 52.5252 139.847C52.5232 139.835 52.5232 139.822 52.5252 139.81C52.5252 139.642 52.5252 139.469 52.5252 139.297C52.5252 139.268 52.5252 139.238 52.5252 139.213C52.5252 139.041 52.5588 138.873 52.584 138.705L52.7268 137.865H178.899V137.827ZM6.7998 6.78712H38.5266C40.297 6.78649 42.0461 7.17343 43.6511 7.92077C45.2561 8.66811 46.678 9.75773 47.817 11.1131C48.9595 12.4627 49.7928 14.0459 50.2586 15.7516C50.7244 17.4574 50.8114 19.2444 50.5134 20.9873L47.733 37.3043H38.6904L41.9916 24.1961C42.3488 22.8132 42.3831 21.3666 42.0918 19.9682C41.8005 18.5699 41.1914 17.2574 40.3116 16.1321C39.435 15.0019 38.3101 14.0886 37.0238 13.463C35.7376 12.8374 34.3247 12.5162 32.8944 12.5243H6.7998V6.78712ZM206.72 44.0789L204.057 51.1643H40.1436L38.577 44.0915L206.72 44.0789ZM201.474 57.9389L181.49 110.766L56.364 117.13L54.8898 117.205L53.3652 110.384L53.2896 110.04L52.857 108.032L52.437 106.235L52.206 105.197L51.6474 102.677L41.6598 57.9515L201.474 57.9389Z",fill:lB}),(0,o.jsx)("path",{d:"M163.22 150.234C159.749 150.238 156.42 151.619 153.965 154.074C151.51 156.529 150.129 159.858 150.125 163.329C150.128 166.802 151.509 170.131 153.964 172.586C156.419 175.041 159.748 176.422 163.22 176.425C166.696 176.427 170.03 175.049 172.49 172.593C174.95 170.137 176.334 166.805 176.337 163.329C176.332 159.854 174.948 156.523 172.489 154.067C170.03 151.611 166.696 150.233 163.22 150.234Z",fill:lz}),(0,o.jsx)("path",{d:"M70.7909 150.234C67.3191 150.238 63.9908 151.619 61.5358 154.074C59.0809 156.529 57.6998 159.858 57.6953 163.329C57.6986 166.802 59.0794 170.131 61.5346 172.586C63.9898 175.041 67.3188 176.422 70.7909 176.425C74.2631 176.422 77.592 175.041 80.0472 172.586C82.5024 170.131 83.8832 166.802 83.8865 163.329C83.8821 159.858 82.5009 156.529 80.046 154.074C77.5911 151.619 74.2627 150.238 70.7909 150.234Z",fill:lz}),(0,o.jsx)("path",{d:"M163.22 150.234C159.749 150.238 156.42 151.619 153.965 154.074C151.51 156.529 150.129 159.858 150.125 163.329C150.128 166.802 151.509 170.131 153.964 172.586C156.419 175.041 159.748 176.422 163.22 176.425C166.696 176.427 170.03 175.049 172.49 172.593C174.95 170.137 176.334 166.805 176.337 163.329C176.332 159.854 174.948 156.523 172.489 154.067C170.03 151.611 166.696 150.233 163.22 150.234Z",fill:lz}),(0,o.jsx)("path",{d:"M70.7909 150.234C67.3191 150.238 63.9908 151.619 61.5358 154.074C59.0809 156.529 57.6998 159.858 57.6953 163.329C57.6986 166.802 59.0794 170.131 61.5346 172.586C63.9898 175.041 67.3188 176.422 70.7909 176.425C74.2631 176.422 77.592 175.041 80.0472 172.586C82.5024 170.131 83.8832 166.802 83.8865 163.329C83.8821 159.858 82.5009 156.529 80.046 154.074C77.5911 151.619 74.2627 150.238 70.7909 150.234Z",fill:lz}),(0,o.jsx)("path",{d:"M163.22 150.234C159.749 150.238 156.42 151.619 153.965 154.074C151.51 156.529 150.129 159.858 150.125 163.329C150.128 166.802 151.509 170.131 153.964 172.586C156.419 175.041 159.748 176.422 163.22 176.425C166.696 176.427 170.03 175.049 172.49 172.593C174.95 170.137 176.334 166.805 176.337 163.329C176.332 159.854 174.948 156.523 172.489 154.067C170.03 151.611 166.696 150.233 163.22 150.234Z",stroke:lB,strokeWidth:"6.72","stroke-miterlimit":"10"}),(0,o.jsx)("path",{d:"M70.7909 150.234C67.3191 150.238 63.9908 151.619 61.5358 154.074C59.0809 156.529 57.6998 159.858 57.6953 163.329C57.6986 166.802 59.0794 170.131 61.5346 172.586C63.9898 175.041 67.3188 176.422 70.7909 176.425C74.2631 176.422 77.592 175.041 80.0472 172.586C82.5024 170.131 83.8832 166.802 83.8865 163.329C83.8821 159.858 82.5009 156.529 80.046 154.074C77.5911 151.619 74.2627 150.238 70.7909 150.234Z",stroke:lB,strokeWidth:"6.72","stroke-miterlimit":"10"}),(0,o.jsx)("path",{d:"M163.22 150.234C159.749 150.238 156.42 151.619 153.965 154.074C151.51 156.529 150.129 159.858 150.125 163.329C150.128 166.802 151.509 170.131 153.964 172.586C156.419 175.041 159.748 176.422 163.22 176.425C166.696 176.427 170.03 175.049 172.49 172.593C174.95 170.137 176.334 166.805 176.337 163.329C176.332 159.854 174.948 156.523 172.489 154.067C170.03 151.611 166.696 150.233 163.22 150.234Z",stroke:lB,strokeWidth:"6.72","stroke-miterlimit":"10"}),(0,o.jsx)("path",{d:"M70.7909 150.234C67.3191 150.238 63.9908 151.619 61.5358 154.074C59.0809 156.529 57.6998 159.858 57.6953 163.329C57.6986 166.802 59.0794 170.131 61.5346 172.586C63.9898 175.041 67.3188 176.422 70.7909 176.425C74.2631 176.422 77.592 175.041 80.0472 172.586C82.5024 170.131 83.8832 166.802 83.8865 163.329C83.8821 159.858 82.5009 156.529 80.046 154.074C77.5911 151.619 74.2627 150.238 70.7909 150.234Z",stroke:lB,strokeWidth:"6.72","stroke-miterlimit":"10"})]}),(0,o.jsx)("defs",{children:(0,o.jsx)("clipPath",{id:"clip0_5292_1051",children:(0,o.jsx)("rect",{width:"215.04",height:"179.785",fill:"white"})})})]}),(0,o.jsx)("h1",{style:{color:lB,fontFamily:"".concat(lV,", sans-serif")},className:"text-2xl font-black pt-5  mb-2",children:t$("Your Cart is Empty")}),(0,o.jsx)("p",{style:{fontFamily:"".concat(lV,", sans-serif"),color:lB},className:"text-lg  mb-2",children:t$("Start shopping to fill it up!")})]})}),(0,o.jsx)("div",{className:" lg:hidden flex justify-center",children:(0,o.jsx)("div",{className:"fixed bottom-3 lg:w-[40%] mx-auto w-[335px]   ",children:(0,o.jsx)(g,{onClick:()=>{eP(!0),tv(!0)},text:t$("review_order"),secondaryBtnTxtColor:lY,secondaryBtnColor:lG,fontFamily:lV,highlightTextColor:lJ,saveDeliveryMode:e5,saveModedetails:rX,deliveryTime:rB,setOpenMode:()=>rL(!0),handlePaymentMethod:l4,loader:e$,setChangeModeModal:rG,taxDetails:eK.total,currency:null==tz?void 0:tz.currency_symbol,cartItemDetails:e3})})})]}),(0,o.jsx)("div",{className:"pt-5 px-20 hidden lg:block overflow-auto  pb-52 hide-scrollbar",children:(0,o.jsx)(e1,{primaryBtnColor:lW,fontFamily:lV,primaryColor:lB,taxDetails:eK,cartItemDetails:e3,paymentMethods:null==eB?void 0:eB.data,setPaymentCardModal:eL,onPaymentMethodChange:nn,errorMessage:eq,seterror:eR,cardList:eV,currency:null==tz?void 0:tz.currency_symbol,currencySymbol:null==tz?void 0:tz.currency,secondaryBtnTxtColor:lY,secondaryBtnColor:lG,primarybtn:lW,primarybtntxt:lH,openPay:!1,cardListapi:nd,onDeleteCard:lg,handlePaymentMethod:l4,handleCardCheckboxChange:l3,setCvv:rv,cvv:rp,total:null==tg?void 0:null===(ek=tg.data)||void 0===ek?void 0:null===(ej=ek.order_items)||void 0===ej?void 0:ej.total,handleCustomTip:nx,handleTipClick:nh,openCustomTip:rS,setOpenCustomTip:rC,handleOpenCustomTip:nb,tipValue:rj,tipType:rw,calculatedTip:ry,deftax:tz,inputRef:oK,loader:e$,pointsdata:oW,addeditem:null==tg?void 0:tg.data,cvvError:rg,setCvvError:rf,setPointData:oQ,setusePoints:oZ,usePoints:oX,setTipValue:r
1k,onPromotionChange:nD,selectedCard:rl,setSelectedCard:rn,promotion:t8,setpromotion:t9,reedemable:null==eB?void 0:eB.data,setIsInitializedForOneScreen:()=>iG("screen1"),isInitializedForOneScreen:!eM,secondaryColor:lz,setIsCartUpdated:aL,setCheckedPaymentMethod:tu,checkedPaymentMethod:tc,openBtn:a$,setOpenBtn:aQ,setLoader:eQ,openFailureModalFunc:oF,initialCardListApiCalled:os,initialCardListApiError:og,localalias:"".concat(t6.query.resturant),ErrorPrimaryColor:lZ,SetNewPromoAlert:oL,setIsOpen:eP,bgColor:lK,saveCartCal:tg,isPointsDataLoaded:oG,showChangeInput:ir,setShowChangeInput:io,changeAmount:ia,setChangeAmount:ii,showTipSection:il,setShowTipSection:is,changeError:id,showChangePrompt:iu,setShowChangePrompt:im,selectedButton:an,setSelectedButton:as,minimumOrderAmount:tC,isBelowMinimum:tk,selectDeliveryPartner:ly,sessionID:oR,paymentGateway:nC,setPaymentGateway:nI,setMercadoModal:ig,MercadoList:eW,setCardRouter:l6,page_location:aV,setBillpocketModal:ih,billpocketCardsList:ix,selectedBillpocketCard:iw,onBillpocketCardSelect:l8,onDeleteBillpocketCard:e=>{iL(e),iP(!0),iX&&eP(!1)}})})]}),(0,o.jsxs)("div",{className:"h-[90px] fixed   bottom-0 left-0 right-0 lg:grid lg:grid-cols-2 hidden z-[50]",children:[(0,o.jsxs)("div",{style:{color:lH,backgroundColor:lW,fontFamily:"".concat(lV,", sans-serif")},className:"flex px-8 py-6  justify-between",children:[(0,o.jsxs)("div",{className:"flex",children:[(0,o.jsx)("div",{className:"w-10 h-10",children:(0,o.jsx)(N.r8y,{className:"w-full h-full",style:{color:lJ}})}),(0,o.jsxs)("div",{className:"ml-2",children:[(0,o.jsx)("div",{style:{color:lJ,fontFamily:"".concat(lV,", sans-serif")},className:" lg:text-sm pr-10",children:"delivery"===e5?(0,o.jsx)("div",{className:"font-normal",children:(0,o.jsxs)("div",{className:"font-black",children:[t$("delivery"),":",(0,o.jsx)("span",{className:"font-black pl-3",children:rX&&(null==rX?void 0:rX.formatted_address)})]})}):"pickup"===e5?(0,o.jsxs)("div",{className:"font-black",children:[t$("pick_up"),":",(0,o.jsx)("span",{className:"font-black  pl-3",children:rX&&rX.branch_name})]}):"dinein"===e5?(0,o.jsxs)("div",{className:"font-black",children:[t$("dine_in"),":",(0,o.jsx)("span",{className:"font-black pl-3",children:rX&&rX.branch_name})]}):null}),(0,o.jsx)("div",{style:{color:lJ,fontFamily:"".concat(lV,", sans-serif")},className:"text-sm pt-1 font-black",children:"delivery"===e5?(null==rB?void 0:rB.delivery_time_estimate)?"".concat(rB.delivery_time_estimate," - ").concat(Number(rB.delivery_time_estimate)+10," ").concat(t$("time_unit_min")):"":(null==rX?void 0:rX.pickup_time_estimate)?"".concat(rX.pickup_time_estimate," - ").concat(Number(rX.pickup_time_estimate)+10," ").concat(t$("time_unit_min")):""})]})]}),(0,o.jsx)("div",{style:{color:lJ,fontFamily:"".concat(lV,", sans-serif")},onClick:()=>rL(!0),className:"font-black lg:text-sm cursor-pointer",children:t$("changes")})]}),(0,o.jsx)("div",{style:{color:lY,backgroundColor:lG,fontFamily:"".concat(lV,", sans-serif")},className:"flex justify-center items-center font-black py-3 text-lg px-4 ".concat(((null==ta?void 0:ta.payment_method_id)||0===eK.total)&&!tk?"cursor-pointer":"opacity-50 cursor-not-allowed"),onClick:()=>{!tk&&((null==ta?void 0:ta.payment_method_id)||0===eK.total)&&l4()},children:e$?"".concat(t$("charging"),"..."):(null==ta?void 0:ta.payment_method_id)||0!==eK.total?t$("pay"):t$("place_order")})]}),iZ&&(0,o.jsx)("div",{children:(0,o.jsxs)(ep,{isOpen:eM,setIsOpen:eP,isPaymentScreen:!0,fontFamily:lV,bgColor:lK,primaryColor:lB,resetData:nF,children:[(0,o.jsx)(e_,{fontFamily:lV,primaryColor:lB,saveDeliveryMode:e5,saveModedetails:rX,deliveryTime:rB,setOpenMode:()=>{eP(!1),setTimeout(()=>{rL(!0)},200)},handlePaymentMethod:l4,loader:e$,setChangeModeModal:nL}),(0,o.jsx)(e1,{primaryBtnColor:lW,fontFamily:lV,primaryColor:lB,taxDetails:eK,cartItemDetails:e3,paymentMethods:null==eB?void 0:eB.data,setPaymentCardModal:eL,onPaymentMethodChange:nn,errorMessage:eq,openPay:tp,seterror:eR,cardList:eV,currency:null==tz?void 0:tz.currency_symbol,currencySymbol:null==tz?void 0:tz.currency,secondaryBtnTxtColor:lY,secondaryBtnColor:lG,primarybtn:lW,primarybtntxt:lH,cardListapi:nd,onDeleteCard:lg,handlePaymentMethod:l4,handleCardCheckboxChange:l3,setCvv:rv,cvv:rp,total:null==tg?void 0:null===(eF=tg.data)||void 0===eF?void 0:null===(eC=eF.order_items)||void 0===eC?void 0:eC.total,handleCustomTip:nx,handleTipClick:nh,openCustomTip:rS,setOpenCustomTip:rC,handleOpenCustomTip:nb,tipValue:rj,tipType:rw,calculatedTip:ry,deftax:tz,inputRef:oK,loader:e$,pointsdata:oW,addeditem:null==tg?void 0:tg.data,cvvError:rg,setCvvError:rf,setPointData:oQ,setusePoints:oZ,usePoints:oX,setTipValue:r
1k,onPromotionChange:nD,selectedCard:rl,setSelectedCard:rn,promotion:t8,setpromotion:t9,reedemable:null==eB?void 0:eB.data,isInitializedForOneScreen:!1,setIsInitializedForOneScreen:()=>iG("screen2"),secondaryColor:lz,setIsCartUpdated:aL,setCheckedPaymentMethod:tu,checkedPaymentMethod:tc,openBtn:a$,setOpenBtn:aQ,setLoader:eQ,openFailureModalFunc:oF,initialCardListApiCalled:os,initialCardListApiError:og,localalias:"".concat(t6.query.resturant),ErrorPrimaryColor:lZ,SetNewPromoAlert:oL,setIsOpen:eP,bgColor:lK,saveCartCal:tg,isPointsDataLoaded:oG,showChangeInput:ir,setShowChangeInput:io,changeAmount:ia,setChangeAmount:ii,showTipSection:il,setShowTipSection:is,changeError:id,showChangePrompt:iu,setShowChangePrompt:im,selectedButton:an,setSelectedButton:as,minimumOrderAmount:tC,isBelowMinimum:tk,selectDeliveryPartner:ly,sessionID:oR,paymentGateway:nC,setPaymentGateway:nI,setMercadoModal:ig,MercadoList:eW,setCardRouter:l6,page_location:aV,setBillpocketModal:ih,billpocketCardsList:ix,selectedBillpocketCard:iw,onBillpocketCardSelect:l8,onDeleteBillpocketCard:e=>{iL(e),iP(!0),iX&&eP(!1)}})]})}),eT&&(0,o.jsx)("div",{className:"relative z-[80]",children:(0,o.jsx)(M,{primaryColor:lB,fontFamily:lV,secondaryBtnTxtColor:lY,secondaryBtnColor:lG,primarybtn:lW,primarybtntxt:lH,make_payment_api:ng,orderID:tr,generateToken:nm,saveOrderdetailsapi:na,loader:e$,setPaymentCardModal:eL,open:eT,setOpen:eL,bgColor:lK,openFailureModalFunc:oF,setLoader:eQ,secondaryColor:lz,setIsOpen:eP,ErrorPrimaryColor:lZ,cardLimitReached:((null==eV?void 0:eV.length)||0)>=3})}),r5&&(0,o.jsx)(tf,{show:r5,close:ld,rules:r0,fontFamily:lV,primaryColor:lB,secondaryBtnColor:lG,secondaryBtnTxtColor:lY,currency:null==tz?void 0:tz.currency_symbol,onAddItem:lP,onUpgrade:lR,onAddCombo:lT,handlePopupClick:e=>{e.stopPropagation()}}),oy&&oj&&(0,o.jsx)("div",{className:"fixed inset-0 z-80 flex items-center justify-center bg-black bg-opacity-50",children:(0,o.jsx)("div",{className:"bg-white h-[600px] p-4 rounded-lg w-full max-w-2xl",children:(0,o.jsx)(ex,{ticket:oj.ticket,mode:oj.mode,scriptUrl:oj.script_url,restaurantId:null==tz?void 0:tz.restaurant_id,orderId:tr,branchId:null==aj?void 0:aj.branch_id,phoneNumber:null==tm?void 0:tm.phone_number,paymentGatewayId:ta.gateway_id,scheduledOrder:aq?1:0,sessionId:oR,version:oB,onSuccess:()=>{var e,t,r,o;oh(!1),(null==rX?void 0:null===(t=rX.available_services)||void 0===t?void 0:null===(e=t.curveorder)||void 0===e?void 0:e.status)==!0&&("pickup"==e5||"takeout"==e5)||nT(rm),(null==rX?void 0:null===(o=rX.available_services)||void 0===o?void 0:null===(r=o.curveorder)||void 0===r?void 0:r.status)==!0&&("pickup"==e5||"takeout"==e5)?oC(!0):e9(!0),oT(),nP()},onError:e=>{oh(!1),oF(e)},onCancel:()=>{oh(!1),oF("Payment cancelled")}})})}),te&&(0,o.jsx)(eD,{open:te,setOpen:tt,bgColor:lK,fontFamily:lV,secondaryColor:lz,primaryColor:lB,secondaryBtnColor:lG,secondaryBtnTxtColor:lY,localalias:"".concat(t6.query.resturant),setBtnLoading:aP,primaryBtnColor:lW,primaryBtnTxtColor:lH,orderId:null==ny?void 0:ny.orderID}),iv&&(0,o.jsx)(tD,{isOpen:iv,onClose:()=>{ig(!1),setTimeout(()=>eP(!0),300)},publickey:le,setIsOpen:eP,sdkready:i7,alias:"".concat(t6.query.resturant),secondaryBtnColor:lG,secondaryBtnTxtColor:lY,email:null==tm?void 0:tm.email,restaurant_id:null==tz?void 0:tz.restaurant_id,phone_number:null==tm?void 0:tm.phone_number,resetdata:()=>{rn({}),rv({}),rf(null),eU([]),tn({}),rQ(null),tu(null),nI(null),l6(!1)}}),iI&&(0,o.jsx)(tW,{publicCredentialId:iI,inTest:iE,children:(0,o.jsx)(tH,{ref:iH,isOpen:iy,onClose:()=>{ih(!1),setTimeout(()=>eP(!0),300)},onPaymentSubmit:l9,totalAmount:eK.total,primaryColor:lB,primaryTextColor:lH,secondaryColor:lG,secondaryTextColor:lY,restaurantId:null==tz?void 0:tz.restaurant_id,prefillName:"".concat((null==tm?void 0:tm.first_name)||""," ").concat((null==tm?void 0:tm.last_name)||"").trim(),profilecheckdata:tm,saveCardEnabled:iD,onRetryLoaderChange:(e,t)=>
1{e?(i0(),iW(t||"")):i1()}})}),e$&&(0,o.jsx)(tX,{isOpen:iS,primaryColor:lB,loadingText:iJ,subText:iU||void 0}),iM&&(0,o.jsx)(ez.A,{isOpen:iM,setIsOpen:e=>{iP(e),!e&&iX&&eP(!0)},onConfirm:lv,title:t$("Delete Card"),confirmText:t$("Delete Card"),variant:"danger",description:t$("confirm_delete_card"),primaryColor:lB,bgColor:lK}),iq&&(0,o.jsx)(ez.A,{isOpen:iq,setIsOpen:e=>{iR(e),!e&&iX&&eP(!0)},onConfirm:lf,title:t$("Delete Card"),confirmText:t$("Delete Card"),variant:"danger",description:t$("confirm_delete_card"),primaryColor:lB,bgColor:lK})]}),tG&&(0,o.jsx)(v,{isOpen:tG,onClose:()=>tY(!1),type:tK,onAction:()=>{tY(!1),setTimeout(()=>{iX?rG(!0):rL(!0)},500)},primaryBtnColor:lW,primaryBtnTxtColor:lH,secondaryBtnColor:lG,secondaryBtnTxtColor:lY})]})}},50477:()=>{}},e=>{var t=t=>e(e.s=t);e.O(0,[7551,3342,1791,8563,3139,5687,8758,9700,5945,8035,7057,1430,9861,4743,6130,9965,236,8051,6610,8774,6771,9758,3660,518,8952,3107,9928,636,6593,8792],()=>t(65498)),_N_E=e.O()}]);

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.