-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
2 lines (2 loc) · 166 KB
/
script.js
File metadata and controls
2 lines (2 loc) · 166 KB
1
2
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/profile-BaqUOlSv.js","assets/core-C5bEFvMT.js","assets/badges-BAp4bqgy.js"])))=>i.map(i=>d[i]);
function e(){import.meta.url,import("_").catch(()=>1),async function*(){}().next()}import{L as t,s as n,a,b as o,u as r,l as i,D as s,F as c,R as l,M as d,W as u,I as m,c as f,T as p,H as v,d as y}from"./assets/core-C5bEFvMT.js";const g={},h=function(e,t,n){let a=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),n=(null==e?void 0:e.nonce)||(null==e?void 0:e.getAttribute("nonce"));a=Promise.allSettled(t.map(e=>{if((e=function(e){return"/"+e}(e))in g)return;g[e]=!0;const t=e.endsWith(".css"),a=t?'[rel="stylesheet"]':"";if(document.querySelector('link[href="'.concat(e,'"]').concat(a)))return;const o=document.createElement("link");return o.rel=t?"stylesheet":"modulepreload",t||(o.as="script"),o.crossOrigin="",o.href=e,n&&o.setAttribute("nonce",n),document.head.appendChild(o),t?new Promise((t,n)=>{o.addEventListener("load",t),o.addEventListener("error",()=>n(new Error("Unable to preload CSS for ".concat(e))))}):void 0}))}function o(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return a.then(t=>{for(const e of t||[])"rejected"===e.status&&o(e.reason);return e().catch(o)})};function w(){return window.db}function b(){return window.firebase&&window.firebase.firestore&&window.firebase.firestore.FieldValue?window.firebase.firestore.FieldValue:null}function E(e){for(var n=t.length-1;n>=0;n--)if(e>=t[n].min)return t[n];return t[0]}function I(){var e=document.getElementById("loyalty-widget");if(e){var n=A();if(n){for(var a=n.loyaltyPoints||0,o=E(a),r=null,i=0;i<t.length;i++)if(t[i].min>a){r=t[i];break}var s=100-a%100;100===s&&0===a&&(s=100);var c="";a<100?c='<span class="loyalty-progress-hint">Order ₹'+10*s+" more for your first reward!</span>":r&&(c='<span class="loyalty-progress-hint">'+(r.min-a)+" pts to "+r.icon+" "+r.name+"</span>");var l=a>=100?'<span class="loyalty-redeem-hint">₹'+10*Math.floor(a/100)+" redeemable</span>":"";e.style.display="flex",e.innerHTML='<span class="loyalty-icon">'+o.icon+'</span><span class="loyalty-pts">'+a+" pts</span>"+(l||c),e.title=o.name+" Tier | "+a+" Points | Redeem 100pts = Rs.10 off",e.style.cursor="pointer",e.onclick=function(){L()}}else e.style.display="none"}}function L(){var e=A();if(e){for(var n=e.loyaltyPoints||0,a=E(n),o=null,r=0;r<t.length;r++)if(t[r].min>n){o=t[r];break}var i=document.getElementById("loyalty-modal");i||((i=document.createElement("div")).id="loyalty-modal",i.className="modal",i.innerHTML='<div class="modal-content loyalty-modal-content"></div>',document.body.appendChild(i),i.addEventListener("click",function(e){e.target===i&&(i.style.display="none")}));var s=o?Math.min(100,(n-a.min)/(o.min-a.min)*100):100,c=o?'<p class="loyalty-next">'+(o.min-n)+" points to "+o.icon+" "+o.name+"</p>":'<p class="loyalty-next">You have reached the highest tier!</p>',l=10*Math.floor(n/100);i.querySelector(".loyalty-modal-content").innerHTML='<span class="close" onclick="document.getElementById(\'loyalty-modal\').style.display=\'none\'">×</span><div class="loyalty-header"><div class="loyalty-tier-badge" style="background:'+a.color+'">'+a.icon+" "+a.name+"</div><h2>"+n+' Points</h2></div><div class="loyalty-progress-bar"><div class="loyalty-progress-fill" style="width:'+s+"%;background:"+a.color+'"></div></div>'+c+'<div class="loyalty-info"><div class="loyalty-info-row"><span>Redeemable Value</span><span>Rs.'+l+'</span></div><div class="loyalty-info-row"><span>Points per Rs.10 spent</span><span>1 point</span></div><div class="loyalty-info-row"><span>3-Day Streak Bonus</span><span>2x points</span></div></div><div class="loyalty-tiers-list">'+t.map(function(e){var t=e.name===a.name?" active":"",o=e.min>n?" locked":"",r=(e.perks||[]).map(function(e){return"<li>"+e+"</li>"}).join("");return'<div class="loyalty-tier-item'+t+o+'"><div class="tier-header"><span>'+e.icon+" "+e.name+"</span><span>"+e.min+'+ pts</span></div><ul class="tier-perks">'+r+"</ul></div>"}).join("")+"</div>",i.style.display="block"}else"function"==typeof window.openAuthModal&&window.openAuthModal()}function C(e){if(!e||!e.dob)return!1;var t=new Date,n=e.dob.split("-");if(n.length<2)return!1;var a=parseInt(n[1],10)-1;return t.getMonth()===a}function x(e){if(e&&C(e)&&!document.getElementById("birthday-banner")){var t=(e.name||"Guest").split(" ")[0],n=document.createElement("span");n.textContent=t;var a=n.innerHTML,o=document.createElement("div");o.id="birthday-banner",o.className="birthday-banner",o.innerHTML='<span class="birthday-banner-icon">🎂</span><span class="birthday-banner-text">Happy Birthday, '+a+'! Enjoy special offers this month!</span><button class="birthday-banner-close" onclick="closeBirthdayBanner()">×</button>';var r=document.querySelector("header")||document.querySelector("nav");r&&r.nextSibling?r.parentNode.insertBefore(o,r.nextSibling):document.body.insertBefore(o,document.body.firstChild)}}Object.assign(window,{openLoyaltyModal:L,closeLoyaltyModal:function(){var e=document.getElementById("loyalty-modal");e&&(e.style.display="none")},updateLoyaltyWidget:I,awardLoyaltyPoints:function(e){var t=A();if(t){var n=Math.floor(e/10),a=(new Date).toISOString().split("T")[0],o=t.orderDates||[];if(o[o.length-1]!==a&&o.push(a),o.length>=3){var r=o.slice(-3),i=new Date(r[0]+"T12:00:00"),s=new Date(r[1]+"T12:00:00"),c=new Date(r[2]+"T12:00:00"),l=Math.round((s-i)/864e5),d=Math.round((c-s)/864e5);1===l&&1===d&&(n*=2)}o.length>30&&(o=o.slice(-30));var u=(t.loyaltyPoints||0)+n,m=E(t.loyaltyPoints||0),f=E(u);t.loyaltyPoints=u,t.loyaltyTier=f.name,t.orderDates=o,q(t);var p=w();p&&p.collection("users").doc(t.phone).update({loyaltyPoints:u,loyaltyTier:f.name,orderDates:o}).catch(function(e){console.error("Loyalty tier update error:",e)}),G("+"+n+" loyalty points earned!"+(n>Math.floor(e/10)?" (2x Streak Bonus!)":""));var v=document.getElementById("loyalty-widget");if(v){var y=document.createElement("span");y.className="loyalty-points-floater",y.textContent="+"+n,v.appendChild(y),setTimeout(function(){y.remove()},1500)}f.name!==m.name&&setTimeout(function(){G("Congratulations! You are now "+f.icon+" "+f.name+" tier!"),"function"==typeof window.launchConfetti&&window.launchConfetti()},2e3),I()}},getLoyaltyTier:E,checkBirthdayRewards:C,showBirthdayBanner:x,closeBirthdayBanner:function(){var e=document.getElementById("birthday-banner");e&&(e.style.opacity="0",e.style.transform="translateY(-100%)",setTimeout(function(){e.parentNode&&e.parentNode.removeChild(e)},400))}});var S=6048e5,k=3e5;function B(e){try{var t=JSON.parse(n("amoghaLoginAttempts")||"{}");t[e]||(t[e]={timestamps:[]});var o=Date.now();t[e].timestamps=(t[e].timestamps||[]).filter(function(e){return o-e<k}),t[e].timestamps.push(o),a("amoghaLoginAttempts",JSON.stringify(t))}catch(r){}}async function M(e){var t=e+"_amogha_salt";if("undefined"!=typeof crypto&&crypto.subtle){var n=(new TextEncoder).encode(t),a=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(a)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")}for(var o=5381,r=0;r<t.length;r++)o=(o<<5)+o+t.charCodeAt(r)>>>0;return"fb_"+o.toString(16).padStart(8,"0")}function A(){try{const a=n("amoghaUser");if(!a)return null;var e=JSON.parse(a);if(e._sessionTimestamp&&Date.now()-e._sessionTimestamp>S){try{localStorage.removeItem("amoghaUser")}catch(t){}return null}return e}catch(t){return null}}function q(e){e&&!e._sessionTimestamp&&(e._sessionTimestamp=Date.now()),a("amoghaUser",JSON.stringify(e));var t=w();if(e&&e.phone&&void 0!==t&&t&&!window._notifListenerActive){"function"==typeof window._notifListenerUnsub&&window._notifListenerUnsub();try{window._notifListenerUnsub=t.collection("notifications").where("userPhone","==",e.phone).where("read","==",!1).onSnapshot(function(e){e.docChanges().forEach(function(e){if("added"===e.type){var t=e.doc.data();"function"==typeof window.sendPushNotification&&window.sendPushNotification(t.title,t.body),e.doc.ref.update({read:!0})}})},function(e){console.error("Notification listener error:",e)}),window._notifListenerActive=!0}catch(n){console.error("Notification listener setup error:",n)}}}function T(){var e=document.getElementById("auth-modal");e&&(e.style.display="none"),r(),["signup-name","signup-phone","signup-password","signin-phone","signin-password","forgot-phone","forgot-name","forgot-new-password","forgot-confirm-password"].forEach(function(e){var t=document.getElementById(e);t&&(t.value="")}),["signup-msg","signin-msg","forgot-msg"].forEach(function(e){var t=document.getElementById(e);t&&(t.textContent="",t.className="auth-msg")});var t=document.getElementById("forgot-step-1"),n=document.getElementById("forgot-step-2");t&&(t.style.display=""),n&&(n.style.display="none"),D=null}function P(e){document.querySelectorAll(".auth-view").forEach(e=>e.classList.remove("active"));var t=document.getElementById("auth-"+e);t&&t.classList.add("active")}var N=!1;function O(){if(!N){var e=document.getElementById("signup-name").value.trim(),t=document.getElementById("signup-phone").value.trim(),n=document.getElementById("signup-password").value,a=document.getElementById("signup-msg");if(!e||e.length<2)return a.textContent="Please enter your name (at least 2 characters).",void(a.className="auth-msg error");if(e.length>100)return a.textContent="Name is too long (max 100 characters).",void(a.className="auth-msg error");if(e=e.replace(/<[^>]*>/g,"").trim(),!/^\d{10}$/.test(t))return a.textContent="Please enter a valid 10-digit phone number.",void(a.className="auth-msg error");if(!/^\d{4}$/.test(n))return a.textContent="Please enter a 4-digit PIN.",void(a.className="auth-msg error");a.textContent="Creating account...",a.className="auth-msg";var o=w();if(void 0===o||!o)return a.textContent="Service unavailable. Please refresh and try again.",void(a.className="auth-msg error");N=!0,o.collection("users").doc(t).get().then(async function(r){if(r.exists)return a.textContent="This phone number is already registered. Please sign in.",a.className="auth-msg error",void(N=!1);var i=await M(n),s={name:e,phone:t,pin:i,usedWelcomeBonus:!1,createdAt:(new Date).toISOString()};return o.collection("users").doc(t).set(s).then(function(){N=!1;try{q(s),F(s),W(),T(),G("Welcome, "+(e||"Guest")+"! 25% off applied to your first order!"),setTimeout(function(){x(s)},500);var t=document.getElementById("signup-referral"),n=t?t.value.trim():"";n&&setTimeout(function(){"function"==typeof window.applyReferralAtSignup&&window.applyReferralAtSignup(n)},2e3)}catch(a){console.error("SignUp UI error:",a),T(),G("Account created successfully!")}})}).catch(function(e){N=!1,console.error("SignUp error:",e);var t="permission-denied"===e.code?"Access denied. Please contact support.":"Connection error. Please check your internet and try again.";a.textContent=t+" ("+(e.code||e.message||"unknown")+")",a.className="auth-msg error"})}}function _(){if(!N){var e=document.getElementById("signin-phone").value.trim(),t=document.getElementById("signin-password").value,o=document.getElementById("signin-msg");if(!/^\d{10}$/.test(e))return o.textContent="Please enter a valid 10-digit phone number.",void(o.className="auth-msg error");if(!/^\d{4}$/.test(t))return o.textContent="Please enter your 4-digit PIN.",void(o.className="auth-msg error");if(function(e){var t=function(e){try{var t=JSON.parse(n("amoghaLoginAttempts")||"{}")[e];if(!t)return{count:0,timestamps:[]};var a=Date.now(),o=(t.timestamps||[]).filter(function(e){return a-e<k});return{count:o.length,timestamps:o}}catch(r){return{count:0,timestamps:[]}}}(e);return t.count>=5}(e)){var r=function(e){try{var t=JSON.parse(n("amoghaLoginAttempts")||"{}")[e];if(!t||!t.timestamps||0===t.timestamps.length)return 0;var a=t.timestamps.filter(function(e){return Date.now()-e<k});if(0===a.length)return 0;var o=Math.min.apply(null,a)+k;return Math.max(0,Math.ceil((o-Date.now())/1e3))}catch(r){return 0}}(e);return o.textContent="Too many login attempts. Please try again in "+Math.ceil(r/60)+" minute(s).",void(o.className="auth-msg error")}o.textContent="Signing in...",o.className="auth-msg";var i=w();if(void 0===i||!i)return o.textContent="Service unavailable. Please refresh and try again.",void(o.className="auth-msg error");N=!0,i.collection("users").doc(e).get().then(async function(r){if(!r.exists)return N=!1,B(e),o.textContent="No account found with this number. Please sign up.",void(o.className="auth-msg error");var i=r.data();if((i.pin||i.password||"")!==await M(t))return N=!1,B(e),o.textContent="Incorrect PIN. Please try again.",void(o.className="auth-msg error");!function(e){try{var t=JSON.parse(n("amoghaLoginAttempts")||"{}");delete t[e],a("amoghaLoginAttempts",JSON.stringify(t))}catch(o){}}(e),N=!1;try{q(i),F(i),W(),T(),G("Welcome back, "+(i.name||"Guest")+"!"+(i.usedWelcomeBonus?"":" Your 25% welcome bonus is still active!")),setTimeout(function(){x(i)},500)}catch(s){console.error("SignIn UI error:",s),T(),G("Signed in successfully!")}}).catch(function(e){N=!1,console.error("SignIn error:",e),o.textContent="Connection error. Please check your internet and try again.",o.className="auth-msg error"})}}var D=null;function R(){var e=document.getElementById("forgot-phone").value.trim(),t=document.getElementById("forgot-name").value.trim(),n=document.getElementById("forgot-msg");if(!/^\d{10}$/.test(e))return n.textContent="Please enter a valid 10-digit phone number.",void(n.className="auth-msg error");if(!t)return n.textContent="Please enter your registered name.",void(n.className="auth-msg error");n.textContent="Verifying...",n.className="auth-msg";var a=w();if(void 0===a||!a)return n.textContent="Service unavailable. Please refresh and try again.",void(n.className="auth-msg error");a.collection("users").doc(e).get().then(function(a){if(!a.exists)return n.textContent="No account found with this phone number.",void(n.className="auth-msg error");if((a.data().name||"").toLowerCase()!==t.toLowerCase())return n.textContent="Name does not match our records.",void(n.className="auth-msg error");D=e,n.textContent="Identity verified! Please create a new 4-digit PIN below.",n.className="auth-msg success",document.getElementById("forgot-step-1").style.display="none",document.getElementById("forgot-step-2").style.display="block",z("forgot-new-password"),z("forgot-confirm-password");var o=document.getElementById("forgot-new-password");o&&o.focus()}).catch(function(e){console.error("Forgot password error:",e),n.textContent="permission-denied"===e.code?"Access denied. Please contact support.":"Network error. Please check your connection and try again.",n.className="auth-msg error"})}function H(){var e=document.getElementById("forgot-new-password").value,t=document.getElementById("forgot-confirm-password").value,n=document.getElementById("forgot-msg");if(!/^\d{4}$/.test(e))return n.textContent="Please enter a 4-digit PIN.",void(n.className="auth-msg error");if(e!==t)return n.textContent="PINs do not match.",void(n.className="auth-msg error");if(!D)return n.textContent="Please verify your identity first.",void(n.className="auth-msg error");n.textContent="Resetting PIN...",n.className="auth-msg";var a=w();if(void 0===a||!a)return n.textContent="Service unavailable. Please refresh and try again.",void(n.className="auth-msg error");M(e).then(function(e){return a.collection("users").doc(D).update({pin:e})}).then(function(){D=null,n.textContent="",n.className="auth-msg",T(),G("PIN reset successful! Please sign in.")}).catch(function(){n.textContent="Something went wrong. Please try again.",n.className="auth-msg error"})}function j(){try{localStorage.removeItem("amoghaUser")}catch(t){}try{localStorage.removeItem("amoghaCart"),localStorage.removeItem("amoghaMyOrders"),localStorage.removeItem("amoghaSharedOrders"),localStorage.removeItem("amogha_referral_code"),localStorage.removeItem("amogha_referral_count"),localStorage.removeItem("amogha_streak")}catch(t){}window._appliedCoupon=null,window._lastOrderId=null,window._lastOrderTotal=null,window._lastOrderItems=null,window._lastOrderTotalForShare=null,window._notifListenerActive=!1,"function"==typeof window._notifListenerUnsub&&(window._notifListenerUnsub(),window._notifListenerUnsub=null);const e=document.getElementById("signin-btn");e&&(e.className="signin-nav-btn",e.innerHTML='<svg class="signin-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg><span id="signin-text">Sign In</span>'),W(),"function"==typeof window.updateLoyaltyWidget&&window.updateLoyaltyWidget(),G("You have been signed out.")}function F(e){const t=document.getElementById("signin-btn");if(t&&e){var n=e.name||"Guest",a=n.split(" ").filter(function(e){return e.length>0}).map(function(e){return e[0]}).join("").toUpperCase().slice(0,2)||"G";t.className="signin-nav-btn signed-in",t.innerHTML='<span class="user-avatar">'+o(a)+'</span><span id="signin-text">'+o(n.split(" ")[0])+'</span><div class="user-dropdown" id="user-dropdown"><a href="#" onclick="event.preventDefault();event.stopPropagation();openProfileModal()">My Profile</a><a href="#" onclick="event.preventDefault();event.stopPropagation();signOut()">Sign Out</a></div>',t.onclick=function(e){e.preventDefault();var t=document.getElementById("user-dropdown");t&&t.classList.toggle("show")},"function"==typeof window.updateLoyaltyWidget&&window.updateLoyaltyWidget()}}function G(e){var t=document.getElementById("auth-toast");t||((t=document.createElement("div")).id="auth-toast",document.body.appendChild(t)),t.textContent=e,t.classList.remove("visible"),t.offsetWidth,t.classList.add("visible"),setTimeout(function(){t.classList.remove("visible")},4e3)}function W(){var e=document.getElementById("carousel-greeting");if(e){var t=A();t&&t.name?e.textContent="Hey "+t.name.split(" ")[0]+", ":e.textContent=""}}function z(e){var t=document.getElementById(e);if(t&&!t.dataset.pinDotsAttached){t.dataset.pinDotsAttached="true";var n=document.createElement("div");n.className="pin-dots-indicator",n.setAttribute("aria-hidden","true");for(var a=0;a<4;a++){var o=document.createElement("span");o.className="pin-dot",n.appendChild(o)}t.parentNode.insertBefore(n,t.nextSibling),t.addEventListener("input",function(){for(var e=t.value.replace(/\D/g,"").length,a=n.querySelectorAll(".pin-dot"),o=0;o<a.length;o++)a[o].classList.toggle("filled",o<e)})}}function U(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}Object.assign(window,{openAuthModal:function(){const e=A();if(e)confirm("Signed in as "+(e.name||"Guest")+"\n\nDo you want to sign out?")&&j();else{var t=document.getElementById("auth-modal");if(t){t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.style.display="block",i(),P("signup");var n=document.getElementById("signup-phone"),a=document.getElementById("signup-name"),o=document.getElementById("signin-phone");n&&n.setAttribute("autocomplete","tel"),a&&a.setAttribute("autocomplete","name"),o&&o.setAttribute("autocomplete","tel"),t.querySelectorAll(".toggle-password, .password-toggle").forEach(function(e){e.hasAttribute("aria-label")||e.setAttribute("aria-label","Toggle PIN visibility")}),t._focusTrapAttached||(t._focusTrapAttached=!0,t.addEventListener("keydown",function(e){if("Tab"===e.key){var n=t.querySelectorAll('input, button, select, textarea, a[href], [tabindex]:not([tabindex="-1"])');if(0!==n.length){var a=n[0],o=n[n.length-1];e.shiftKey?document.activeElement===a&&(e.preventDefault(),o.focus()):document.activeElement===o&&(e.preventDefault(),a.focus())}}}))}}},closeAuthModal:T,switchAuthView:P,handleSignUp:O,handleSignIn:_,handleForgotPassword:R,handleResetPassword:H,signOut:j,updateSignInUI:F,togglePassword:function(e,t){var n=document.getElementById(e);if(n&&t){var a=t.querySelector(".eye-open"),o=t.querySelector(".eye-closed");a&&o&&("password"===n.type?(n.type="text",a.style.display="none",o.style.display=""):(n.type="password",a.style.display="",o.style.display="none"))}},showAuthToast:G,updateCarouselGreeting:W,closeUserDropdown:function(){var e=document.getElementById("user-dropdown");e&&e.classList.remove("visible")}});let V=[];var Y=[],J=null,X=[];function K(){a("amoghaCart",JSON.stringify(V))}function $(){const e=V.reduce((e,t)=>e+t.quantity,0);var t=document.getElementById("cart-count");t&&(t.hasAttribute("role")||(t.setAttribute("role","status"),t.setAttribute("aria-live","polite")),t.textContent=e,t.classList.remove("bump"),t.offsetWidth,t.classList.add("bump"),setTimeout(function(){t.classList.remove("bump")},300))}function Q(e,t,n){var a;0!==V.length||A()||((a=document.getElementById("signin-prompt"))||((a=document.createElement("div")).id="signin-prompt",a.innerHTML='<div class="signin-prompt-content"><span class="signin-prompt-icon">🎉</span><div class="signin-prompt-text"><strong>Sign up & get 25% OFF!</strong><span>Create an account to unlock your welcome bonus</span></div><button class="signin-prompt-btn" onclick="closeSignInPrompt(); openAuthModal();">Sign Up</button><button class="signin-prompt-close" onclick="closeSignInPrompt()">×</button></div>',document.body.appendChild(a)),a.classList.remove("visible"),a.offsetWidth,a.classList.add("visible"),setTimeout(function(){te()},8e3));var o="medium";if(n){var r=n.closest(".menu-item-card");if(r){var i=r.querySelector(".spice-level.active");i&&(o=i.textContent.trim().toLowerCase())}}if(Y.length>0)return J={name:e,price:parseFloat(t),spiceLevel:o,btnEl:n},X.length=0,void function(e,t){var n=document.getElementById("addon-picker-overlay"),a=document.getElementById("addon-item-name"),o=document.getElementById("addon-sheet-list");n&&a&&o&&(a.textContent=e+" — ₹"+t,o.innerHTML=Y.map(function(e,t){return'<div class="addon-option" data-idx="'+t+'" onclick="toggleAddonOption(this, '+t+')"><div class="addon-checkbox"></div><div class="addon-option-info"><div class="addon-option-name">'+U(e.name)+'</div><div class="addon-option-cat">'+U(e.category||"")+'</div></div><div class="addon-option-price">+₹'+Number(e.price||0)+"</div></div>"}).join(""),ee(),n.style.display="flex")}(e,parseFloat(t));Z(e,parseFloat(t),o,[],n)}function Z(e,t,n,a,o){var r=a.map(function(e){return e.name}).sort().join(","),i=V.find(function(t){var a=(t.addons||[]).map(function(e){return e.name}).sort().join(",");return t.name===e&&t.spiceLevel===n&&a===r});if(i?i.quantity++:V.push({name:e,price:t,quantity:1,spiceLevel:n,addons:a||[]}),o&&(o.classList.remove("cart-adding"),o.offsetWidth,o.classList.add("cart-adding"),function(e){var t=document.getElementById("cart-icon");if(e&&t){var n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=document.createElement("div");o.className="cart-fly-item",o.style.left=n.left+n.width/2-6+"px",o.style.top=n.top+n.height/2-6+"px",document.body.appendChild(o),requestAnimationFrame(function(){o.style.transition="left 0.55s cubic-bezier(0.4,0,0.2,1), top 0.55s cubic-bezier(0.4,0,0.2,1), opacity 0.55s, transform 0.55s",o.style.left=a.left+a.width/2-6+"px",o.style.top=a.top+a.height/2-6+"px",o.style.opacity="0",o.style.transform="scale(0.3)"}),setTimeout(function(){o.remove()},600),t.classList.remove("cart-jiggle"),t.offsetWidth,t.classList.add("cart-jiggle"),setTimeout(function(){t.classList.remove("cart-jiggle")},400)}}(o)),$(),K(),ne(e),ae(),oe(),window.dispatchEvent(new CustomEvent("amogha-cart-updated",{detail:{items:V}})),window._ariaAnnounce){var s=i?i.quantity:1;window._ariaAnnounce(e+" added to cart. Quantity: "+s)}try{window.analytics&&window.analytics.logEvent("add_to_cart",{item_name:e,value:t})}catch(c){}}function ee(){if(J){var e=X.reduce(function(e,t){return e+t.price},0),t=J.price+e,n=document.getElementById("addon-total");n&&(n.textContent="Total: ₹"+t)}}function te(){var e=document.getElementById("signin-prompt");e&&e.classList.remove("visible")}function ne(e){document.querySelectorAll(".add-to-cart").forEach(t=>{if(t.dataset.item===e){const a=V.find(t=>t.name===e),o=a?a.quantity:0;if(o>0&&!t.classList.contains("has-qty"))t.classList.add("has-qty"),t.innerHTML='<span class="qty-minus" data-item="'.concat(U(e),'" aria-label="Decrease quantity">−</span><span class="qty-count" aria-live="polite" aria-label="Quantity: ').concat(o,'">').concat(o,'</span><span class="qty-plus" data-item="').concat(U(e),'" aria-label="Increase quantity">+</span>');else if(o>0){var n=t.querySelector(".qty-count");n&&(n.textContent=o,n.setAttribute("aria-label","Quantity: "+o),n.classList.remove("qty-bump"),n.offsetWidth,n.classList.add("qty-bump"))}else t.classList.remove("has-qty"),t.innerHTML="Add to Order"}})}function ae(){let e=document.getElementById("floating-cart");e||(e=document.createElement("div"),e.id="floating-cart",e.innerHTML='\n <div class="fc-header">\n <span class="fc-title">Your Order</span>\n <span class="fc-close" onclick="closeFloatingCart()">×</span>\n </div>\n <div class="fc-items"></div>\n <div class="fc-footer">\n <span class="fc-total"></span>\n <button class="fc-checkout" onclick="document.getElementById(\'cart-icon\').click(); closeFloatingCart();">View Cart</button>\n </div>\n ',document.body.appendChild(e));const t=e.querySelector(".fc-items"),n=e.querySelector(".fc-total");if(0===V.length)return e.classList.remove("visible"),void re();let a="",o=0;V.forEach(e=>{const t=(e.addons||[]).reduce((e,t)=>e+t.price,0),n=(e.price+t)*e.quantity;o+=n,a+='<div class="fc-item"><span>'.concat(U(e.name)," x").concat(e.quantity,"</span><span>₹").concat(n,"</span></div>")}),t.innerHTML=a,n.textContent="Total: ₹".concat(o),e.classList.add("visible"),re()}function oe(){var e=document.getElementById("floating-cart-bar");if(e){var t=V.reduce(function(e,t){return e+t.quantity},0),n=V.reduce(function(e,t){var n=(t.addons||[]).reduce(function(e,t){return e+t.price},0);return e+(t.price+n)*t.quantity},0);if(0!==t){var a=e.querySelector(".floating-cart-count"),o=e.querySelector(".floating-cart-total"),r=e.querySelector(".floating-cart-label");a&&(a.textContent=t),o&&(o.textContent="₹"+n),r&&(r.textContent=1===t?"1 item":t+" items"),e.classList.add("visible")}else e.classList.remove("visible")}}function re(e){var t=document.getElementById("cart-fab");t||((t=document.createElement("div")).id="cart-fab",t.className="cart-fab",t.innerHTML='<svg viewBox="0 0 24 24"><path d="M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4z"/><line x1="3" y1="6" x2="21" y2="6"/><path d="M16 10a4 4 0 01-8 0"/></svg><span class="cart-fab-badge">0</span>',t.addEventListener("click",function(){var e=document.getElementById("cart-icon");e&&e.click()}),document.body.appendChild(t));var n=t.querySelector(".cart-fab-badge"),a=V.reduce(function(e,t){return e+t.quantity},0);a>0?(n.textContent=a,t.classList.add("visible"),t.classList.remove("pop"),t.offsetWidth,t.classList.add("pop")):t.classList.remove("visible")}function ie(){const e=document.getElementById("cart-items");if(!e)return;if(0===V.length){e.innerHTML='<div class="empty-cart" role="status" aria-label="Your cart is empty"><svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="empty-cart-icon"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 002 1.61h9.72a2 2 0 002-1.61L23 6H6"/></svg><span class="empty-cart-title">Your cart is empty</span><span class="empty-cart-sub">Explore our menu and discover your next favourite dish</span><a href="#menu" class="empty-cart-cta" onclick="var cm=document.getElementById(\'cart-modal\');if(cm)cm.style.display=\'none\';unlockScroll();document.getElementById(\'menu\')&&document.getElementById(\'menu\').scrollIntoView({behavior:\'smooth\'})" role="button">Browse Menu</a></div>';var t=document.getElementById("subtotal-amount"),n=document.getElementById("total-amount");return t&&(t.textContent="0.00"),void(n&&(n.textContent="0.00"))}let a="",o=0;V.forEach((e,t)=>{const n=(e.addons||[]).reduce((e,t)=>e+t.price,0),r=(e.price+n)*e.quantity;o+=r;const i=e.spiceLevel&&"medium"!==e.spiceLevel?' <span class="spice-tag">('+U(e.spiceLevel)+")</span>":"",s=(e.addons||[]).map(e=>'<span class="addon-tag">+ '+U(e.name)+" ₹"+Number(e.price||0)+"</span>").join(" ");var c=U(e.name);a+='\n <div class="cart-item">\n <div class="cart-item-info">\n <div class="cart-item-name">'.concat(c).concat(i,"</div>\n ").concat(s?'<div style="margin-top:2px">'+s+"</div>":"",'\n <div class="cart-item-price">₹').concat((e.price+n).toFixed(2),'</div>\n </div>\n <div class="cart-item-quantity">\n <button class="qty-btn" onclick="updateQuantity(').concat(t,', -1)" aria-label="Decrease quantity of ').concat(c,'">-</button>\n <span>').concat(e.quantity,'</span>\n <button class="qty-btn" onclick="updateQuantity(').concat(t,', 1)" aria-label="Increase quantity of ').concat(c,'">+</button>\n </div>\n <button class="remove-item" onclick="removeItem(').concat(t,')" aria-label="Remove ').concat(c,' from cart">Remove</button>\n </div>\n ')}),e.innerHTML=a;const r=o>=c?0:s,i=o+r;var l=document.getElementById("subtotal-amount"),d=document.getElementById("total-amount");l&&(l.textContent=o.toFixed(2)),d&&(d.textContent=i.toFixed(2));var u=document.querySelector(".delivery-note");u&&(u.textContent=0===r?"Delivery fee: FREE ✓":"Delivery fee: ₹"+s+" (Free over ₹"+c+")")}function se(){if(confirm("Are you sure you want to clear your cart?")){const t=V.map(e=>e.name);V.length=0,$(),K(),ie(),t.forEach(e=>ne(e)),ae(),oe();var e=document.getElementById("cart-modal");e&&(e.style.display="none"),r(),window._ariaAnnounce&&window._ariaAnnounce("Cart cleared")}}function ce(e){var t=document.createElement("div");return t.textContent=e,t.innerHTML}function le(e){return(e||"").replace(/<[^>]*>/g,"").trim()}window._cartGlobalsSet||(window._cartGlobalsSet=!0,Object.assign(window,{addToCart:Q,finalizeAddToCart:Z,updateQuantity:function(e,t){if(!V[e])return;const n=V[e].name;var a=V[e].quantity+t;a>50?window._ariaAnnounce&&window._ariaAnnounce("Maximum quantity is 50"):(a<=0?(V.splice(e,1),window._ariaAnnounce&&window._ariaAnnounce(n+" removed from cart")):(V[e].quantity=a,window._ariaAnnounce&&window._ariaAnnounce(n+" quantity: "+V[e].quantity)),$(),K(),ie(),ne(n),ae(),oe())},removeItem:function(e){if(!V[e])return;const t=V[e].name;V.splice(e,1),$(),K(),ie(),ne(t),ae(),oe(),window._ariaAnnounce&&window._ariaAnnounce(t+" removed from cart")},clearCart:se,closeAddonPicker:function(){var e=document.getElementById("addon-picker-overlay");e&&(e.style.display="none"),J=null,X.length=0},toggleAddonOption:function(e,t){e.classList.toggle("selected");var n=Y[t],a=e.querySelector(".addon-checkbox");if(e.classList.contains("selected"))X.push({name:n.name,price:n.price}),a.textContent="✓";else{var o=X.findIndex(function(e){return e.name===n.name});-1!==o&&X.splice(o,1),a.textContent=""}ee()},confirmAddonSelection:function(){if(J){var e=J,t=X.slice();J=null,X.length=0;var n=document.getElementById("addon-picker-overlay");n&&(n.style.display="none"),Z(e.name,e.price,e.spiceLevel,t,e.btnEl)}},closeFloatingCart:function(){const e=document.getElementById("floating-cart");e&&e.classList.remove("visible")},closeSignInPrompt:te,updateFloatingCartBar:oe}));var de=null,ue=null,me="",fe=500;function pe(){window._appliedCoupon=de}function ve(e){var t=(e.addons||[]).reduce(function(e,t){return e+t.price},0);return(e.price+t)*e.quantity}function ye(){var e=V.reduce(function(e,t){return e+ve(t)},0),n=e>=c?0:s,a=0,o=0,r=e+n,i=A();if(i){for(var l=i.loyaltyPoints||0,d=null,u=t.length-1;u>=0;u--)if(l>=t[u].min){d=t[u];break}d&&(d.freeDelivery&&(n=0),d.discount>0&&(o=Math.floor(e*d.discount/100)))}de&&("percent"===de.type?a=Math.floor(e*de.discount/100):"flat"===de.type&&(a=de.discount),a=Math.min(a,e));var m=Math.max(a,o);if(r=e-m+n,ue&&"number"==typeof ue.balance&&ue.balance>0){var f=Math.min(ue.balance,r);r=Math.max(0,r-f)}return{subtotal:e,deliveryFee:n,discount:m,loyaltyDiscount:o,total:r}}function ge(e,t){if(!e)return 0;var n="percent"===e.type?t*e.discount/100:e.discount;return e.maxDiscount&&"percent"===e.type&&(n=Math.min(n,e.maxDiscount)),Math.min(n,t)}function he(){if(0!==V.length){var e=V.reduce(function(e,t){return e+ve(t)},0),t=e>=c?0:s,n=e+t,a="";V.forEach(function(e){var t=(e.addons||[]).reduce(function(e,t){return e+t.price},0),n=(e.price+t)*e.quantity,o=t>0?" (+₹"+t+")":"";a+='<div class="co-item"><span>'+ce(e.name)+o+" x"+e.quantity+"</span><span>₹"+n+"</span></div>"});var o="";if("function"==typeof window.getUpsellItems){var r=window.getUpsellItems(V);r&&r.length>0&&(o='<div class="upsell-section" id="upsell-section"><div class="upsell-title">Customers also ordered</div><div class="upsell-items">',r.forEach(function(e){var t=ce(e.name),n=ce(e.name).replace(/"/g,"""),a=parseInt(e.price,10)||0;o+='<div class="upsell-card"><div class="upsell-info"><div class="upsell-name">'+t+'</div><div class="upsell-reason">'+ce(e.reason||"")+'</div></div><span class="upsell-price">₹'+a+'</span><button class="upsell-add-btn" data-upsell-name="'+n+'" data-upsell-price="'+a+'">+ Add</button></div>'}),o+="</div></div>")}var i=document.getElementById("checkout-items");i&&(i.innerHTML=a+o,i.querySelectorAll(".upsell-add-btn[data-upsell-name]").forEach(function(e){e.addEventListener("click",function(){Ce(e.getAttribute("data-upsell-name"),parseInt(e.getAttribute("data-upsell-price"),10)||0)})}));var l=document.getElementById("co-subtotal");l&&(l.textContent="₹"+e);var d=document.getElementById("co-delivery");d&&(d.textContent=0===t?"FREE":"₹"+t);var u=document.getElementById("co-total");u&&(u.textContent="₹"+n);var m=document.getElementById("loyalty-redeem-btn");if(m){var f=A();if(f&&f.loyaltyPoints>=100){var p=10*Math.floor(f.loyaltyPoints/100);m.textContent="Redeem "+f.loyaltyPoints+" pts (₹"+p+" off)",m.style.display="block"}else m.style.display="none"}var v=document.getElementById("co-name"),y=document.getElementById("co-phone"),g=document.getElementById("co-address");v&&v.setAttribute("aria-required","true"),y&&(y.setAttribute("aria-required","true"),y.setAttribute("inputmode","numeric"),y.setAttribute("pattern","[0-9]*")),g&&g.setAttribute("aria-required","true"),we(1);var h=document.getElementById("checkout-modal");h&&(h.style.display="block");var b=A();b&&(v&&!v.value&&(v.value=b.name||""),y&&!y.value&&(y.value=b.phone||""),g&&!g.value&&b.address&&(g.value=b.address));var E=document.getElementById("checkout-step-2");E&&!document.getElementById("order-type-selector")&&E.insertAdjacentHTML("afterbegin",'<div class="order-type-selector" id="order-type-selector" role="radiogroup" aria-label="Order type"><button type="button" class="order-type-btn active" data-type="delivery" role="radio" aria-checked="true" onclick="selectOrderType(this,\'delivery\')"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 18H3a2 2 0 01-2-2V8a2 2 0 012-2h3.93a2 2 0 011.66.9l.82 1.2a2 2 0 001.66.9H21a2 2 0 012 2v2"/><circle cx="7" cy="18" r="2"/><path d="M15 18h2"/><circle cx="20" cy="18" r="2"/></svg> Delivery</button><button type="button" class="order-type-btn" data-type="pickup" role="radio" aria-checked="false" onclick="selectOrderType(this,\'pickup\')"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4z"/><line x1="3" y1="6" x2="21" y2="6"/><path d="M16 10a4 4 0 01-8 0"/></svg> Pickup</button></div>');var I=document.getElementById("co-notes");if(I&&!document.getElementById("delivery-time-estimate")){var L=document.createElement("div");L.className="delivery-time-estimate",L.id="delivery-time-estimate",L.setAttribute("aria-live","polite"),L.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg><span>Estimated delivery: 30 - 45 mins</span>',I.parentNode.insertBefore(L,I.nextSibling)}var C=document.getElementById("coupon-code"),x=document.getElementById("coupon-msg");if(b&&!b.usedWelcomeBonus){de={discount:25,type:"percent",label:"25% off (Welcome Bonus!)"},me="WELCOME25",C&&(C.value="WELCOME25"),x&&(x.textContent="Welcome bonus applied! You get 25% off!",x.className="coupon-msg success");var S=Math.floor(.25*e),k=e-(S=Math.min(S,e))+t,B=document.getElementById("co-total");B&&(B.textContent="₹"+k);var M=document.getElementById("co-discount-row"),T=document.getElementById("co-discount"),P=document.getElementById("co-discount-label");M&&(M.style.display=""),T&&(T.textContent="-₹"+S),P&&(P.textContent="Welcome Bonus (25% off)");var N=w();N&&b.phone&&N.collection("users").doc(b.phone).get().then(function(e){e.exists&&e.data().usedWelcomeBonus&&(de=null,me="",pe(),b.usedWelcomeBonus=!0,q(b),C&&(C.value=""),x&&(x.textContent="",x.className="coupon-msg"),be())}).catch(function(e){console.error("Welcome bonus re-verify error:",e)})}else{de=null,me="",C&&(C.value=""),x&&(x.textContent="",x.className="coupon-msg");var O=document.getElementById("co-discount-row");O&&(O.style.display="none")}pe()}else G("Your cart is empty. Add items before checkout.")}function we(e){document.querySelectorAll(".checkout-step").forEach(function(e){e.classList.remove("active")});var t=document.getElementById("checkout-step-"+e);t&&(t.classList.add("active"),t.setAttribute("tabindex","-1"),t.focus({preventScroll:!0}));var n={1:"Order Summary",2:"Customer Details",3:"Payment",4:"Order Confirmation"};window._ariaAnnounce&&n[e]&&window._ariaAnnounce("Checkout step "+e+": "+n[e]),3===e&&be()}function be(){var e=ye().total,t="₹"+Math.round(e),n=document.getElementById("pay-total");n&&(n.textContent=t);var a=document.getElementById("cod-total");a&&(a.textContent=t),Ee("razorpay")}function Ee(e){var t={razorpay:"Pay with Razorpay (UPI, Cards, Net Banking)",cod:"Pay with Cash on Delivery"};["razorpay","cod"].forEach(function(n){var a=document.getElementById("tab-"+n),o=document.getElementById("pay-panel-"+n);a&&(a.classList.toggle("active",n===e),a.setAttribute("aria-selected",n===e?"true":"false"),a.hasAttribute("aria-label")||a.setAttribute("aria-label",t[n]||n)),o&&o.classList.toggle("active",n===e)});var n={razorpay:"Razorpay (UPI, Cards, Net Banking)",cod:"Cash on Delivery"};window._ariaAnnounce&&n[e]&&window._ariaAnnounce("Payment method: "+n[e])}var Ie=!1;function Le(e,t,n){if(!Ie){var a=w();if(void 0===a||!a)return G("Service unavailable. Please refresh and try again."),void(window._hidePaymentProcessing&&window._hidePaymentProcessing());Ie=!0,window._showPaymentProcessing&&window._showPaymentProcessing();var o=le(document.getElementById("co-name").value.trim()),r=document.getElementById("co-phone").value.trim(),i=le(document.getElementById("co-address").value.trim()),s=le(document.getElementById("co-notes").value.trim()),c=ye(),l=document.getElementById("schedule-order-check"),d=null;if(l&&l.checked){var m=document.getElementById("schedule-date"),f=document.getElementById("schedule-time");m&&f&&m.value&&f.value&&(d=m.value+"T"+f.value+":00")}var p=document.getElementById("confirm-detail");p&&(p.textContent="Payment: "+e+(t?" (Ref: "+t+")":"")+" | Total: ₹"+c.total.toFixed(0));var v="*New Order - Amogha Cafe*\n\n";v+="*Customer:* "+o+"\n*Phone:* "+r+"\n*Address:* "+i+"\n",s&&(v+="*Notes:* "+s+"\n"),v+="\n*Items:*\n",V.forEach(function(e){var t=(e.addons||[]).reduce(function(e,t){return e+t.price},0);v+="- "+e.name+" x"+e.quantity+" = ₹"+(e.price+t)*e.quantity+"\n"}),v+="\n*Subtotal:* ₹"+c.subtotal,v+="\n*Delivery:* "+(0===c.deliveryFee?"FREE":"₹"+c.deliveryFee),v+="\n*Total:* ₹"+c.total.toFixed(0),v+="\n*Payment:* "+e,t&&(v+="\n*Payment Ref:* "+t);var y="https://wa.me/"+u+"?text="+encodeURIComponent(v),g=document.getElementById("whatsapp-link");g&&(g.href=y),we(4);var h=A(),E={customer:o,phone:r,address:i,notes:s,items:V.map(function(e){return{name:e.name,qty:e.quantity,price:e.price,spiceLevel:e.spiceLevel||"medium",addons:e.addons||[]}}),subtotal:c.subtotal,deliveryFee:c.deliveryFee,total:c.total,payment:e,paymentRef:t||null,paymentStatus:n,paymentVerifiedAt:t?(new Date).toISOString():null,status:d?"scheduled":"pending",createdAt:(new Date).toISOString(),scheduledFor:d||null,userId:h?h.phone:null},I=V.map(function(e){return e.name});a.collection("orders").add(E).then(function(t){Ie=!1,window._hidePaymentProcessing&&window._hidePaymentProcessing(),"function"==typeof window.launchConfetti&&window.launchConfetti(),window._ariaAnnounce&&window._ariaAnnounce("Order placed successfully! Thank you for your order."),window._showToast&&window._showToast("Order placed successfully!","success");try{window.analytics&&window.analytics.logEvent("purchase",{transaction_id:t.id,value:E.total,payment_type:e})}catch(g){}window._lastOrderId=t.id,window._lastOrderTotal=E.total;var n=window.location.origin+"/track/index.html?id="+t.id,i=document.getElementById("order-tracking-link");if(i&&(i.innerHTML='<div class="order-track-card"><p class="order-track-label">Track your order in real-time:</p><a href="'+n+'" target="_blank" rel="noopener noreferrer" class="order-track-link">'+n+"</a><br><button onclick=\"safeCopy('"+n+'\',this)" class="cta-button order-track-copy">Copy Link</button></div>'),me){var s=b();s&&a.collection("coupons").doc(me).update({usedCount:s.increment(1)}).catch(function(e){console.error("Coupon usage update error:",e)})}if(h&&!h.usedWelcomeBonus&&de&&de.label&&-1!==de.label.indexOf("Welcome")&&(h.usedWelcomeBonus=!0,q(h),a.collection("users").doc(h.phone).update({usedWelcomeBonus:!0}).catch(function(e){console.error("Bonus update error:",e)})),de&&de._loyaltyPointsToDeduct){var l=A();l&&a.collection("users").doc(l.phone).update({loyaltyPoints:l.loyaltyPoints}).catch(function(e){console.error("Loyalty deduction error:",e)})}if(ue&&ue.code&&"number"==typeof ue.balance){var d=c.subtotal-c.discount+c.deliveryFee,u=Math.min(ue.balance,d),m=b();m&&a.collection("giftCards").doc(ue.code).update({balance:m.increment(-u),redeemedAt:(new Date).toISOString()}).catch(function(e){console.error("Gift card deduction error:",e)}),ue=null}if(de=null,me="",pe(),V.length=0,$(),K(),I.forEach(function(e){ne(e)}),ae(),"function"==typeof window.awardLoyaltyPoints&&window.awardLoyaltyPoints(E.total),"function"==typeof window.checkAndAwardBadges){var f=A();f&&window.checkAndAwardBadges(f,E)}if(h&&a&&a.collection("referrals").where("refereePhone","==",h.phone).where("redeemed","==",!1).limit(1).get().then(function(e){if(!e.empty){var t=e.docs[0],n=t.data().referrerPhone;t.ref.update({redeemed:!0}).then(function(){var e=b();e&&a.collection("users").doc(n).update({loyaltyPoints:e.increment(100)}).catch(function(e){console.error("Referrer points error:",e)})}).catch(function(e){console.error("Referral redeem error:",e)})}}).catch(function(e){console.error("Referral lookup error:",e)}),"function"==typeof window.scheduleReviewPrompt&&window.scheduleReviewPrompt(E.items.map(function(e){return{name:e.name}})),"function"==typeof window.sendPushNotification&&window.sendPushNotification("Order Placed!","Your order from Amogha has been placed successfully."),"function"==typeof window.awardSpin&&window.awardSpin(),"function"==typeof window.showOrderTracker&&setTimeout(function(){window.showOrderTracker(t.id)},2e3),"function"==typeof window.checkMilestones&&window.checkMilestones(A(),E),"function"==typeof window.schedulePostOrderFeedback&&window.schedulePostOrderFeedback(t.id,E.total),"function"==typeof window.updateChallengeProgress&&(window.updateChallengeProgress("spend",E.total),(new Date).getHours()<12&&window.updateChallengeProgress("morning_orders",1)),window._lastOrderItems=E.items,window._lastOrderTotalForShare=E.total,r){var p=r.replace(/\D/g,"");10===p.length&&(p="91"+p);var v="Hi "+o+"! 🙏\n\nYour order at *Amogha Cafe & Restaurant* has been placed successfully!\n\n";v+="*Order ID:* "+t.id+"\n",v+="*Items:* "+E.items.map(function(e){return e.name+" x"+e.qty}).join(", ")+"\n",v+="*Total:* ₹"+c.total.toFixed(0)+"\n\n",v+="📍 Track your order: "+window.location.origin+"/track/?id="+t.id+"\n\n",v+="Thank you for dining with us! 🍛",window.open("https://wa.me/"+p+"?text="+encodeURIComponent(v),"_blank")}var y=b();y&&a.collection("inventory").get().then(function(e){var t={};e.forEach(function(e){var n=e.data();t[(n.name||"").toLowerCase()]={id:e.id}});var n=a.batch(),o=!1;E.items.forEach(function(e){var r=e.name.toLowerCase(),i=parseInt(e.qty)||0;if(t[r]&&i>0){var s=a.collection("inventory").doc(t[r].id);n.update(s,{quantity:y.increment(-i)}),o=!0}}),o&&n.commit().catch(function(e){console.error("Inventory deduction error:",e)})}).catch(function(e){console.error("Inventory fetch error:",e)})}).catch(function(e){if(Ie=!1,window._hidePaymentProcessing&&window._hidePaymentProcessing(),console.error("Order save error:",e),de&&de._loyaltyPointsToDeduct){var t=A();t&&(t.loyaltyPoints=(t.loyaltyPoints||0)+de._loyaltyPointsToDeduct,q(t))}G("Order failed to save. Please try again or check your connection.")})}}function Ce(e,t){for(var n=!1,a=0;a<V.length;a++)if(V[a].name===e){V[a].quantity++,n=!0;break}n||V.push({name:e,price:t,quantity:1,spiceLevel:"medium",addons:[]}),$(),K(),ae(),G(e+" added to your order!"),he()}function xe(e){var t=document.createElement("div");return t.textContent=e,t.innerHTML}function Se(e,t,n,a,o,r){var i=w();if(void 0!==i&&i){try{var s=localStorage.getItem(t);if(s){var c=JSON.parse(s);if(c.ts&&Date.now()-c.ts<1e3*n)return void o(c.data)}}catch(d){}var l=i.collection(e);r&&r.orderBy&&(l=l.orderBy(r.orderBy[0])),r&&r.where&&(l=l.where(r.where[0],r.where[1],r.where[2])),l.get().then(function(e){var n=a(e);o(n);try{localStorage.setItem(t,JSON.stringify({ts:Date.now(),data:n}))}catch(d){}}).catch(function(n){console.error("cachedGet "+e+" error:",n);try{var a=localStorage.getItem(t);if(a)return void o(JSON.parse(a).data)}catch(d){}if("menu"===e){var r=document.getElementById("dynamic-menu-container");r&&(r.innerHTML='<div class="menu-error" style="text-align:center;padding:2rem;color:#ccc"><p style="font-size:1.1rem;margin-bottom:1rem">Unable to load menu. Please check your connection.</p><button onclick="location.reload()" style="padding:.6rem 1.5rem;background:#D4A017;color:#1e140e;border:none;border-radius:8px;font-weight:600;cursor:pointer">Retry</button></div>')}})}}function ke(e){var t,n=document.querySelector(".specials-grid");n&&(0!==e.length?((t=n.closest(".specials"))&&(t.style.display=""),n.innerHTML=e.map(function(e){var t=e.available?"":" item-unavailable",n=xe(e.name||""),a=xe(e.description||""),o=xe(e.badge||"Special"),r=parseInt(e.price,10)||0;return'<div class="special-card'+t+'" data-id="'+n.replace(/"/g,""")+'"><div class="glow-border"></div><div class="special-badge">'+o+"</div><h3>"+n+"</h3><p>"+a+'</p><div class="special-price"><span class="new-price">₹'+r+'</span></div><button class="add-to-cart" data-item="'+n.replace(/"/g,""")+'" data-price="'+r+'">Order Now</button></div>'}).join("")):(t=n.closest(".specials"))&&(t.style.display="none"))}window._paymentGlobalsSet||(window._paymentGlobalsSet=!0,Object.assign(window,{checkout:function(){if(!A())return G("Your session has expired. Please sign in again."),void("function"==typeof window.openAuthModal&&window.openAuthModal());if(0!==V.length){if(!A()){var e=document.getElementById("cart-modal");return e&&(e.style.display="none"),r(),"function"==typeof window.openAuthModal&&window.openAuthModal(),void G("Please sign in to continue with your order")}var t=document.getElementById("cart-modal");t&&(t.style.display="none"),i(),"function"==typeof window.checkAllergenWarning?window.checkAllergenWarning(V,function(e){e?he():r()}):he()}else G("Your cart is empty!")},openCheckout:he,closeCheckout:function(){var e=document.getElementById("checkout-modal");e&&(e.style.display="none"),r(),["co-name","co-phone","co-address","co-notes"].forEach(function(e){var t=document.getElementById(e);t&&(t.value="")})},goToStep:we,setupPayment:be,switchPayTab:Ee,validateAndPay:function(){var e=document.getElementById("co-name"),t=document.getElementById("co-phone"),n=document.getElementById("co-address");if(e&&t&&n){var a=e.value.trim(),o=t.value.trim(),r=n.value.trim(),i="pickup"===window._selectedOrderType;if(!a||!o||!i&&!r)return G("Please fill in all required fields."),void(a?o?i||n.focus():t.focus():e.focus());if(a.length>100)return G("Name is too long (max 100 characters)."),void document.getElementById("co-name").focus();if(!/^\d{10}$/.test(o))return G("Please enter a valid 10-digit phone number."),void document.getElementById("co-phone").focus();if(!i&&r.length<10)return G("Please enter a complete delivery address."),void document.getElementById("co-address").focus();if(!i&&r.length>500)return G("Address is too long (max 500 characters)."),void document.getElementById("co-address").focus();var s=window.getScheduleInfo?window.getScheduleInfo():null;!s||s.date&&s.time?we(3):G("Please select both date and time for scheduled order.")}else G("Form error. Please refresh the page.")},openRazorpay:function(){if("undefined"!=typeof Razorpay){var e=ye();if(isNaN(e.total)||e.total<0)G("Invalid order total. Please try again.");else if(0!==e.total){var t=document.getElementById("co-name").value.trim(),n=document.getElementById("co-phone").value.trim(),a={key:l,amount:Math.round(100*e.total),currency:"INR",name:d,description:"Food Order - Amogha Cafe",image:window.location.origin+"/amogha-logo.png",handler:function(e){Le("Razorpay",e.razorpay_payment_id,"paid")},prefill:{name:t,contact:n,method:"upi"},method:{upi:!0,card:!0,netbanking:!0,wallet:!0},config:{display:{blocks:{upi:{name:"Pay via UPI",instruments:[{method:"upi",flows:["qrcode","collect","intent"]}]}},sequence:["block.upi"],preferences:{show_default_blocks:!0}}},notes:{items:V.map(function(e){return e.name+" x"+e.quantity}).join(", ")},theme:{color:"#D4A017",backdrop_color:"rgba(8,6,4,0.85)"},modal:{ondismiss:function(){var e=document.getElementById("razorpay-pay-btn");e&&(e.disabled=!1,e.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M12 2L2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/></svg> Pay Now')}}},o=document.getElementById("razorpay-pay-btn");o&&(o.disabled=!0,o.innerHTML="Opening payment..."),window._showPaymentProcessing&&window._showPaymentProcessing();try{var r=new Razorpay(a);r.on("payment.failed",function(e){window._hidePaymentProcessing&&window._hidePaymentProcessing(),G("Payment failed: "+(e.error.description||"Please try again"));var t=document.getElementById("razorpay-pay-btn");t&&(t.disabled=!1,t.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M12 2L2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/></svg> Retry Payment')}),r.open(),setTimeout(function(){window._hidePaymentProcessing&&window._hidePaymentProcessing()},1500)}catch(i){window._hidePaymentProcessing&&window._hidePaymentProcessing(),G("Error opening payment: "+i.message),o&&(o.disabled=!1,o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M12 2L2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/></svg> Pay Now')}}else Le("Gift Card (Full)",null,"paid")}else G("Payment gateway loading... please try again")},placeCodOrder:function(){Le("Cash on Delivery",null,"cod-pending")},placeOrderToFirestore:Le,applyCoupon:function(){var e=document.getElementById("coupon-code"),t=document.getElementById("coupon-msg");if(e&&t){var n=e.value.trim().toUpperCase(),a={AMOGHA20:{discount:20,type:"percent",label:"20% off"},WELCOME50:{discount:50,type:"flat",label:"₹50 off"},FIRST10:{discount:10,type:"percent",label:"10% off"},WELCOME25:{discount:25,type:"percent",label:"25% off (Welcome Bonus!)"}},o=w();o?o.collection("coupons").doc(n).get().then(function(e){if(e.exists){var o=e.data(),i=(s=o,c=V.reduce(function(e,t){return e+ve(t)},0),s?s.active?s.expiresAt&&new Date(s.expiresAt)<new Date?{valid:!1,reason:"This coupon has expired."}:s.usageLimit&&s.usedCount>=s.usageLimit?{valid:!1,reason:"This coupon has reached its usage limit."}:s.minOrder&&c<s.minOrder?{valid:!1,reason:"Minimum order ₹"+s.minOrder+" required."}:{valid:!0}:{valid:!1,reason:"This coupon is no longer active."}:{valid:!1,reason:"No coupon"});if(!i.valid)return t.textContent=i.reason,t.className="coupon-msg error",de=null,void(me="");r(o,n)}else a[n]?r(a[n],n):(de=null,me="",t.textContent="Invalid coupon code. Please check and try again.",t.className="coupon-msg error");var s,c}).catch(function(){a[n]?r(a[n],n):(de=null,me="",t.textContent="Invalid coupon code.",t.className="coupon-msg error")}):a[n]?r(a[n],n):(de=null,me="",t.textContent="Invalid coupon code. Please check and try again.",t.className="coupon-msg error")}function r(e,n){de=e,me=n||"",pe(),t.textContent="Coupon applied! "+e.label,t.className="coupon-msg success";var a=V.reduce(function(e,t){return e+ve(t)},0),o=a>=c?0:s,r=ge(e,a),i=a-r+o,l=document.getElementById("co-total");l&&(l.textContent="₹"+i);var d=document.getElementById("co-discount-row"),u=document.getElementById("co-discount"),m=document.getElementById("co-discount-label");r>0&&d&&(d.style.display="",u&&(u.textContent="-₹"+r),m&&(m.textContent=e.label||"Discount"))}},removeCoupon:function(){de=null,me="";var e=document.getElementById("coupon-code"),t=document.getElementById("coupon-msg");e&&(e.value=""),t&&(t.textContent="",t.className="coupon-msg");var n=document.getElementById("co-discount-row");n&&(n.style.display="none"),be()},applyGiftCard:function(){var e=document.getElementById("giftcard-code"),t=document.getElementById("giftcard-msg");if(e&&t){var n=e.value.trim().toUpperCase();if(!n)return t.textContent="Please enter a gift card code",void(t.className="coupon-msg error");var a=w();if(!a)return t.textContent="Service unavailable",void(t.className="coupon-msg error");a.collection("giftCards").doc(n).get().then(function(e){if(!e.exists)return t.textContent="Invalid gift card code",t.className="coupon-msg error",void(ue=null);var a=e.data();if(!a.active)return t.textContent="This gift card is no longer active",t.className="coupon-msg error",void(ue=null);if(a.balance<=0)return t.textContent="This gift card has no remaining balance",t.className="coupon-msg error",void(ue=null);ue={code:n,balance:a.balance},t.textContent="Gift card applied! Balance: ₹"+a.balance,t.className="coupon-msg success";var o=V.reduce(function(e,t){return e+ve(t)},0),r=o>=c?0:s,i=o-(de?ge(de,o):0)+r,l=i-Math.min(a.balance,i),d=document.getElementById("co-total");d&&(d.textContent="₹"+l.toFixed(0))}).catch(function(e){t.textContent="Error: "+e.message,t.className="coupon-msg error"})}},removeGiftCard:function(){ue=null;var e=document.getElementById("giftcard-code"),t=document.getElementById("giftcard-msg");e&&(e.value=""),t&&(t.textContent="",t.className="coupon-msg"),be()},openGiftCardModal:function(){var e=document.getElementById("giftcard-modal");e&&(e.style.display="block",i())},closeGiftCardModal:function(){var e=document.getElementById("giftcard-modal");e&&(e.style.display="none",r())},buyGiftCard:function(){var e=document.getElementById("gc-recipient-phone").value.trim(),t=document.getElementById("gc-msg");if(!e||!/^\d{10}$/.test(e))return t.textContent="Please enter a valid 10-digit phone number",void(t.className="coupon-msg error");var n=A(),a=n?n.phone:"guest",o=fe,r="GC-"+Date.now().toString(36).toUpperCase().slice(-4)+"-"+Math.random().toString(36).toUpperCase().slice(2,6);if("undefined"==typeof Razorpay)return t.textContent="Payment system loading. Please try again.",void(t.className="coupon-msg error");var i=w();if(!i)return t.textContent="Service unavailable. Please try again.",void(t.className="coupon-msg error");var s={key:l,amount:100*o,currency:"INR",name:"Amogha Cafe",description:"Gift Card - "+r,image:"https://amogha-cafe.web.app/amogha-logo.png",handler:function(n){i.collection("giftCards").doc(r).set({code:r,amount:o,balance:o,purchaserPhone:a,recipientPhone:e,paymentRef:n.razorpay_payment_id,active:!0,createdAt:(new Date).toISOString()}).then(function(){t.textContent="Gift card "+r+" created successfully! Share this code with the recipient.",t.className="coupon-msg success",document.getElementById("gc-recipient-phone").value=""}).catch(function(e){t.textContent="Payment received but error saving: "+e.message,t.className="coupon-msg error"})},prefill:{name:n?n.name:"",contact:a},theme:{color:"#D4A017"}};new Razorpay(s).open()},selectGcAmount:function(e,t){fe=e,document.querySelectorAll(".gc-amount-btn").forEach(function(e){e.classList.remove("active")}),t&&t.classList.add("active")},redeemLoyaltyAtCheckout:function(){var e=A();if(e&&e.loyaltyPoints&&!(e.loyaltyPoints<100)){var t=10*Math.floor(e.loyaltyPoints/100),n=100*Math.floor(e.loyaltyPoints/100),a=V.reduce(function(e,t){return e+ve(t)},0),o=Math.min(t,a);if(!(o<=0)){var r=a-o+(a>=c?0:s);de={discount:o,type:"flat",label:"Rs."+o+" (Loyalty Points)",_loyaltyPointsToDeduct:n};var i=document.getElementById("co-total");i&&(i.textContent="Rs."+r.toFixed(0));var l=document.getElementById("coupon-msg");l&&(l.textContent="Redeemed "+n+" points for Rs."+o+" off!",l.className="coupon-msg success");var d=document.getElementById("coupon-code");d&&(d.value="LOYALTY"),e.loyaltyPoints=(e.loyaltyPoints||0)-n,e.loyaltyPoints<0&&(e.loyaltyPoints=0),q(e),"function"==typeof window.updateLoyaltyWidget&&window.updateLoyaltyWidget()}}},shareOrder:function(){var e="I just ordered from Amogha Cafe & Restaurant! 🍽️ Check them out at https://amoghahotels.com";function t(){var e=A();if(e){var t=[];try{t=JSON.parse(localStorage.getItem("amoghaSharedOrders")||"[]")}catch(o){}Date.now().toString();var n=t.length>0?t[t.length-1]:0;if(!(Date.now()-n<3e5)){t.push(Date.now());try{localStorage.setItem("amoghaSharedOrders",JSON.stringify(t))}catch(o){}e.loyaltyPoints=(e.loyaltyPoints||0)+10,q(e);var a=w();a&&a.collection("users").doc(e.phone).update({loyaltyPoints:e.loyaltyPoints}).catch(function(e){console.error("Share loyalty update error:",e)}),G("Thanks for sharing! +10 loyalty points")}}}navigator.share?navigator.share({text:e}).then(function(){t()}).catch(function(){}):(window.open("https://wa.me/?text="+encodeURIComponent(e),"_blank"),t())},addUpsellItem:Ce,selectOrderType:function(e,t){var n=document.getElementById("order-type-selector");if(n){n.querySelectorAll(".order-type-btn").forEach(function(e){e.classList.remove("active"),e.setAttribute("aria-checked","false")}),e.classList.add("active"),e.setAttribute("aria-checked","true");var a=document.getElementById("co-address"),o=a?a.closest(".form-group")||a.parentElement:null,r=document.getElementById("delivery-time-estimate");"pickup"===t?(o&&(o.style.display="none"),a&&a.removeAttribute("aria-required"),r&&(r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg><span>Ready for pickup in: 20 - 30 mins</span>')):(o&&(o.style.display=""),a&&a.setAttribute("aria-required","true"),r&&(r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg><span>Estimated delivery: 30 - 45 mins</span>')),window._selectedOrderType=t}}}));var Be=["Tiffins","Non-veg Biryani","Veg Biryani","Biryanis","Non-veg Starters","Veg Starters","Starters","Non-veg Curries","Veg Curries","Curries","Non-veg Rice","Veg Rice","Non-veg Noodles","Veg Noodles","Noodles & Fried Rice","Non-veg Pulao","Veg Pulao","Non-veg Soups","Veg Soups","Rice Bowls","Non-veg Rolls","Veg Rolls","Kebabs & Grill","Rotis & Naan","Rotis/Naans","French Fries","Omelette","Fried Egg","Boiled Egg","Beverages","Sweets","Extras","Others"],Me={Tiffins:"🍱","Non-veg Biryani":"🍛","Veg Biryani":"🍚",Biryanis:"🍛","Non-veg Starters":"🍗","Veg Starters":"🥗",Starters:"🍢","Non-veg Curries":"🍲","Veg Curries":"🫕",Curries:"🍲","Non-veg Rice":"🍛","Veg Rice":"🍚","Non-veg Noodles":"🍜","Veg Noodles":"🍜","Noodles & Fried Rice":"🍜","Non-veg Pulao":"🍛","Veg Pulao":"🍚","Non-veg Soups":"🍲","Veg Soups":"🥣","Rice Bowls":"🫙","Non-veg Rolls":"🌯","Veg Rolls":"🌯","Kebabs & Grill":"🔥","Rotis & Naan":"🫓","Rotis/Naans":"🫓","French Fries":"🍟",Omelette:"🍳","Fried Egg":"🍳","Boiled Egg":"🥚",Beverages:"🧃",Sweets:"🍬",Extras:"🫙",Others:"🍽️"},Ae={Starters:"pics/Gemini_Generated_Image_wnzsqxwnzsqxwnzs.png",Curries:"pics/Gemini_Generated_Image_tu348stu348stu34.png",Biryanis:"pics/Gemini_Generated_Image_h1vezgh1vezgh1ve.png","Kebabs & Grill":"pics/Gemini_Generated_Image_5jdcgq5jdcgq5jdc.png","Noodles & Fried Rice":"pics/Gemini_Generated_Image_1ojbou1ojbou1ojb.png","Rotis & Naan":"pics/Gemini_Generated_Image_6lqqu6lqqu6lqqu6.png"};function qe(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Te(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Pe(e){var t="veg"===e.type||!0===e.isVeg,n=t?'<span class="veg-badge" aria-label="Vegetarian">🟢</span>':'<span class="nonveg-badge" aria-label="Non-Vegetarian">🔴</span>',a=e.imageUrl;a&&-1!==a.indexOf("res.cloudinary.com")&&-1!==a.indexOf("/upload/")&&-1===a.indexOf("f_auto")&&(a=a.replace("/upload/","/upload/f_auto,q_auto,w_400/"));var o=a?'<div class="menu-item-img-wrap has-image"><img class="menu-item-img loaded" src="'+qe(a)+'" alt="'+qe(e.name)+'" loading="lazy" decoding="async"></div>':"",r=(e.allergens||[]).join(","),i=t?"veg":"non-veg",s=!1===e.available?" item-unavailable":"",c=!1===e.available?' style="opacity:.45;pointer-events:none;filter:grayscale(.3)"':"",l=e.description?'<p class="item-description">'+qe(e.description)+"</p>":"",d={nuts:"🥜",dairy:"🥛",gluten:"🌾",eggs:"🥚",soy:"🫘",shellfish:"🦐",sesame:"⚪",fish:"🐟"},u="";return e.allergens&&e.allergens.length&&(u='<div class="menu-allergen-icons">'+e.allergens.map(function(e){return'<span class="allergen-icon">'+(d[e]||"")+" "+qe(e)+"</span>"}).join("")+"</div>"),'<div class="menu-item-card'+s+'" data-id="'+qe(e.name)+'" data-allergens="'+qe(r)+'" data-type="'+i+'"'+c+">"+o+'<div class="item-header">'+n+"<h4>"+qe(e.name)+'</h4><span class="price">₹'+(e.price||0)+"</span></div>"+l+u+'<div class="spice-selector"><span class="label">Spice:</span><span class="spice-level" onclick="selectSpice(this)">Mild</span><span class="spice-level active" onclick="selectSpice(this)">Medium</span><span class="spice-level" onclick="selectSpice(this)">Spicy</span></div><button class="add-to-cart" data-item="'+qe(e.name)+'" data-price="'+(e.price||0)+'" aria-label="Add '+qe(e.name)+' to order. Use the spice selector above to choose your preferred spice level.">Add to Order</button></div>'}function Ne(){var e=null;try{var t=localStorage.getItem("amoghaUser");t&&(e=JSON.parse(t))}catch(a){}var n=e&&e.allergenAlerts||[];document.querySelectorAll(".menu-item-card[data-id]").forEach(function(e){if(!window._safeForMeActive||0===n.length)return e.classList.remove("allergen-hidden"),void(e.classList.contains("item-unavailable")||(e.style.display=""));(e.dataset.allergens||"").split(",").filter(Boolean).some(function(e){return-1!==n.indexOf(e)})?(e.classList.add("allergen-hidden"),e.style.display="none"):(e.classList.remove("allergen-hidden"),e.classList.contains("item-unavailable")||(e.style.display=""))})}window._safeForMeActive=!1;var Oe=[];function _e(){var e=document.querySelectorAll(".menu-item-card");e.forEach(function(e){if(0!==Oe.length){var t=!0,n=(e.dataset.allergens||"").split(",").filter(Boolean),a=e.dataset.type||"";Oe.forEach(function(e){"veg"===e&&"veg"!==a&&(t=!1),"jain"===e&&"veg"!==a&&(t=!1),"nut-free"===e&&n.indexOf("nuts")>=0&&(t=!1),"dairy-free"===e&&n.indexOf("dairy")>=0&&(t=!1),"gluten-free"===e&&n.indexOf("gluten")>=0&&(t=!1)}),e.style.display=t?"":"none"}else e.style.display=""});var t=Array.prototype.filter.call(e,function(e){return"none"!==e.style.display}).length,n=e.length;if(Oe.length>0&&t<n)!function(e,t){var n=document.getElementById("filterCount");if(!n){(n=document.createElement("div")).id="filterCount",n.className="filter-count";var a=document.getElementById("allergenFilterBar");a&&a.appendChild(n)}n.textContent="Showing "+e+" of "+t+" items"}(t,n);else{var a=document.getElementById("filterCount");a&&a.remove()}}function De(e){var t=document.getElementById("nav-links"),n=document.getElementById("mobile-menu-overlay"),a=document.getElementById("mobile-menu-toggle");t&&t.classList.remove("active"),n&&n.classList.remove("active"),a&&(a.textContent="☰",a.setAttribute("aria-expanded","false")),e?(document.body.classList.remove("modal-open"),document.body.style.top=""):r()}function Re(){if("Notification"in window)if("granted"!==Notification.permission){if("denied"!==Notification.permission){var e=document.getElementById("notif-banner");e||n("amoghaNotifDismissed")||((e=document.createElement("div")).id="notif-banner",e.className="notif-banner",e.innerHTML='<span class="notif-icon">🔔</span><span class="notif-text">Get notified when your order is ready!</span><button class="notif-allow" onclick="enableNotifications()">Enable</button><button class="notif-dismiss" onclick="dismissNotifBanner()">×</button>',document.body.appendChild(e),setTimeout(function(){e.classList.add("visible")},3e3))}}else a("amoghaNotifPerm","granted")}function He(){var e=document.getElementById("notif-banner");e&&(e.classList.remove("visible"),setTimeout(function(){e.remove()},400)),a("amoghaNotifDismissed","true")}function je(e,t){if("Notification"in window&&"granted"===Notification.permission)try{new Notification(e,{body:t,icon:"amogha-logo.png",badge:"amogha-logo.png",tag:"amogha-order"})}catch(n){navigator.serviceWorker&&navigator.serviceWorker.ready&&navigator.serviceWorker.ready.then(function(n){n.showNotification(e,{body:t,icon:"amogha-logo.png",tag:"amogha-order"})}).catch(function(){})}}function Fe(){if("undefined"!=typeof firebase&&firebase.messaging)try{var e=firebase.messaging();e.getToken({vapidKey:"BAmoghaVapidKeyPlaceholder"}).then(function(e){e&&function(e){try{var t=JSON.parse(localStorage.getItem("amoghaUser")),n=w();t&&t.phone&&n&&n.collection("users").doc(t.phone).update({fcmToken:e,fcmUpdatedAt:(new Date).toISOString()}).catch(function(e){console.error("FCM token save error:",e)})}catch(o){}a("amoghaFcmToken",e)}(e)}).catch(function(e){console.warn("FCM token error (expected on some browsers):",e.message)}),e.onMessage(function(e){var t=e.notification?e.notification.title:"Amogha Cafe",n=e.notification?e.notification.body:"";je(t,n),G(n||t)})}catch(t){}}window.toggleAllergenFilter=function(e){var t=Oe.indexOf(e);t>=0?Oe.splice(t,1):Oe.push(e),document.querySelectorAll(".allergen-filter-btn").forEach(function(e){var t=e.dataset.filter;t&&e.classList.toggle("active",Oe.indexOf(t)>=0)});var n=document.getElementById("clearFiltersBtn");n&&(n.style.display=Oe.length>0?"":"none"),_e()},window.clearAllergenFilters=function(){Oe=[],document.querySelectorAll(".allergen-filter-btn").forEach(function(e){e.classList.remove("active")});var e=document.getElementById("clearFiltersBtn");e&&(e.style.display="none"),_e()},window.toggleSafeForMe=function(){window._safeForMeActive=!window._safeForMeActive;var e=document.getElementById("safe-for-me-btn");e&&e.classList.toggle("active",window._safeForMeActive),Ne()},window.checkAllergenWarning=function(e,t){var n=null;try{var a=localStorage.getItem("amoghaUser");a&&(n=JSON.parse(a))}catch(s){}var o=n&&n.allergenAlerts||[];if(0!==o.length){var r=[];if(document.querySelectorAll(".menu-item-card[data-id]").forEach(function(t){var n=(t.dataset.allergens||"").split(",").filter(Boolean),a=t.querySelector("h4"),i=a?a.textContent.replace(/Bestseller|Must Try|New/gi,"").trim():t.dataset.id;e.forEach(function(e){if(e.name===i||e.name===t.dataset.id){var a=n.filter(function(e){return-1!==o.indexOf(e)});a.length>0&&r.push({name:e.name,allergens:a})}})}),0!==r.length){var i='<div class="allergen-warning-popup" id="allergen-warning-popup"><div class="allergen-warning-box"><h3>Allergen Warning</h3><div class="allergen-list">';r.forEach(function(e){i+="<p><strong>"+qe(e.name)+"</strong> contains: "+e.allergens.map(qe).join(", ")+"</p>"}),i+='</div><button class="btn-proceed" onclick="document.getElementById(\'allergen-warning-popup\').remove();window._allergenCb(true)">Proceed Anyway</button><button class="btn-cancel" onclick="document.getElementById(\'allergen-warning-popup\').remove();window._allergenCb(false)">Go Back</button></div></div>',window._allergenCb=t,document.body.insertAdjacentHTML("beforeend",i)}else t(!0)}else t(!0)},window._uiGlobalsSet||(window._uiGlobalsSet=!0,Object.assign(window,{closeMobileMenu:De,launchConfetti:function(){const e=document.getElementById("confetti-canvas");if(!e)return;const t=e.getContext("2d");e.width=window.innerWidth,e.height=window.innerHeight;const n=[],a=["#EFB31A","#8B1A1A","#27ae60","#e74c3c","#3498db","#f39c12","#9b59b6"];for(let r=0;r<150;r++)n.push({x:Math.random()*e.width,y:Math.random()*e.height-e.height,w:10*Math.random()+5,h:6*Math.random()+3,color:a[Math.floor(Math.random()*a.length)],vy:3*Math.random()+2,vx:2*Math.random()-1,rot:360*Math.random(),rotSpeed:6*Math.random()-3});let o=0;!function a(){t.clearRect(0,0,e.width,e.height),n.forEach(e=>{e.y+=e.vy,e.x+=e.vx,e.rot+=e.rotSpeed,t.save(),t.translate(e.x,e.y),t.rotate(e.rot*Math.PI/180),t.fillStyle=e.color,t.fillRect(-e.w/2,-e.h/2,e.w,e.h),t.restore()}),o++,o<200?requestAnimationFrame(a):t.clearRect(0,0,e.width,e.height)}()},toggleFaq:function(e){const t=e.classList.toggle("open");e.setAttribute("aria-expanded",t?"true":"false")}}));var Ge=null;function We(e){Ge&&Ge();var t=w();if(t&&e){var n=null;Ge=t.collection("orders").doc(e).onSnapshot(function(e){if(e.exists){var t=e.data(),a=t.status;if(n&&a!==n){var o={preparing:{title:"👨🍳 Order Being Prepared",body:"Your order is now being freshly prepared in our kitchen!"},ready:{title:"✅ Order Ready!",body:"delivery"===t.orderType?"Your order is ready and will be picked up soon!":"Your order is ready for pickup!"},out_for_delivery:{title:"🛵 Out for Delivery",body:"Your order is on its way! Estimated arrival: "+(t.etaMinutes||30)+" mins"},delivered:{title:"🎉 Order Delivered!",body:"Enjoy your meal! Don't forget to rate your experience."},cancelled:{title:"❌ Order Cancelled",body:"Your order has been cancelled. Contact us for help."}}[a];o&&(je(o.title,o.body),G(o.body))}n=a}})}}function ze(){var e=document.getElementById("reservation-modal");if(e){var t=document.getElementById("reservation-form");if(t&&"true"!==t.dataset.enhanced){t.dataset.enhanced="true";var n=(new Date).toISOString().split("T")[0],a=new Date(Date.now()+6048e5).toISOString().split("T")[0];t.innerHTML='<input type="text" id="res-name" placeholder="Your Name" required><input type="tel" id="res-phone" placeholder="Phone Number (10 digits)" required maxlength="10"><input type="date" id="res-date" min="'+n+'" max="'+a+'" required><div class="res-time-slots" id="res-time-slots"></div><input type="hidden" id="res-time" value=""><div class="res-party-size"><label>Party Size</label><div class="party-btns" id="party-btns"></div></div><textarea id="res-requests" placeholder="Special Requests (Optional)" rows="2"></textarea><div id="res-msg" class="auth-msg"></div><button type="submit" class="cta-button">Confirm Reservation</button>';for(var o=document.getElementById("party-btns"),r=1;r<=12;r++){var i=document.createElement("button");i.type="button",i.className="party-btn",i.textContent=r,i.dataset.size=r,i.onclick=function(){document.querySelectorAll(".party-btn").forEach(function(e){e.classList.remove("active")}),this.classList.add("active")},o.appendChild(i)}document.getElementById("res-date").addEventListener("change",function(){!function(e){var t=document.getElementById("res-time-slots");if(t){t.innerHTML='<label>Select Time</label><div class="time-grid" id="time-grid"></div>';for(var n=document.getElementById("time-grid"),a=e.split("-"),o=new Date(parseInt(a[0]),parseInt(a[1])-1,parseInt(a[2])).getDay(),r=5===o||6===o?22:21,i=0===o?12:11;i<=r;i++)for(var s=0;s<60&&!(i===r&&s>0);s+=30){var c=String(i).padStart(2,"0")+":"+String(s).padStart(2,"0"),l=(0===i?12:i>12?i-12:i)+":"+String(s).padStart(2,"0")+(i>=12?" PM":" AM"),d=document.createElement("button");d.type="button",d.className="time-slot-btn",d.textContent=l,d.dataset.time=c,d.onclick=function(){document.querySelectorAll(".time-slot-btn").forEach(function(e){e.classList.remove("active")}),this.classList.add("active"),document.getElementById("res-time").value=this.dataset.time},n.appendChild(d)}}}(this.value)}),t.onsubmit=function(e){e.preventDefault(),Ue()};var s=A();s&&(document.getElementById("res-name").value=s.name||"",document.getElementById("res-phone").value=s.phone||""),e.style.display="block"}else e.style.display="block"}}function Ue(){var e=document.getElementById("res-name").value.trim(),t=document.getElementById("res-phone").value.trim(),n=document.getElementById("res-date").value,a=document.getElementById("res-time").value,o=document.querySelector(".party-btn.active"),r=o?parseInt(o.dataset.size):0,i=document.getElementById("res-requests").value.trim(),s=document.getElementById("res-msg");if(!(e&&t&&n&&a&&r))return s.textContent="Please fill in all required fields.",void(s.className="auth-msg error");if(!/^\d{10}$/.test(t))return s.textContent="Please enter a valid 10-digit phone number.",void(s.className="auth-msg error");var c=document.querySelector('#reservation-form button[type="submit"], #reservation-form .cta-button');if(c){if(c.disabled)return;c.disabled=!0}s.textContent="Booking your table...",s.className="auth-msg";var l=w();if(!l)return s.textContent="Service unavailable. Please refresh and try again.",void(s.className="auth-msg error");var d={name:e,phone:t,date:n,time:a,partySize:r,requests:i,status:"pending",createdAt:(new Date).toISOString()};l.collection("reservations").add(d).then(function(t){var o,i=document.getElementById("reservation-form"),s=new Date(n+"T12:00:00").toLocaleDateString("en-IN",{weekday:"long",day:"numeric",month:"long"}),c=parseInt(a.split(":")[0]);o=(0===c?12:c>12?c-12:c)+":"+a.split(":")[1]+(c>=12?" PM":" AM"),i.innerHTML='<div class="res-confirmed"><div class="res-check">✓</div><h3>Reservation Confirmed!</h3><p class="res-id">Booking #'+t.id.slice(-6).toUpperCase()+'</p><div class="res-details"><p>'+s+" at "+o+"</p><p>"+r+" Guest"+(r>1?"s":"")+'</p></div><a class="whatsapp-btn" href="https://wa.me/919121004999?text='+encodeURIComponent("Hi Amogha! I have a reservation:\nDate: "+s+"\nTime: "+o+"\nGuests: "+r+"\nName: "+e+"\nBooking: #"+t.id.slice(-6).toUpperCase())+'" target="_blank">Confirm via WhatsApp</a><button class="cta-button" onclick="document.getElementById(\'reservation-modal\').style.display=\'none\'" style="margin-top:1rem">Done</button></div>'}).catch(function(){s.textContent="Failed to book. Please try again.",s.className="auth-msg error",c&&(c.disabled=!1)})}function Ve(e){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ye(e){e.parentElement.querySelectorAll(".spice-level").forEach(e=>e.classList.remove("active")),e.classList.add("active")}function Je(e){if(A()){var t=document.getElementById("review-modal");t||((t=document.createElement("div")).id="review-modal",t.className="modal",t.innerHTML='<div class="modal-content review-modal-content"></div>',document.body.appendChild(t),t.addEventListener("click",function(e){e.target===t&&(t.style.display="none")}));var n=e||V.map(function(e){return{name:e.name}}),a="<span class=\"close\" onclick=\"document.getElementById('review-modal').style.display='none'\">×</span>";a+='<h2>Rate Your Order</h2><p class="review-subtitle">Help us serve you better!</p>',a+='<div id="review-items">',n.forEach(function(e,t){a+='<div class="review-item" data-item="'+Ve(e.name)+'"><span class="review-item-name">'+Ve(e.name)+'</span><div class="review-stars" data-idx="'+t+'">';for(var n=1;n<=5;n++)a+='<span class="review-star" data-star="'+n+'" onclick="setReviewStar(this, '+t+", "+n+')">☆</span>';a+="</div></div>"}),a+="</div>",a+='<textarea id="review-text" class="review-textarea" placeholder="Share your thoughts (optional)" maxlength="200"></textarea>',a+='<button class="cta-button" onclick="submitReviews()">Submit Review</button><span style="color:#D4A017;font-size:0.75rem;margin-left:8px">Earn 25 pts</span>';var o=t.querySelector(".review-modal-content");o&&(o.innerHTML=a,t.style.display="block",window._reviewRatings=new Array(n.length).fill(0),window._reviewItems=n)}}function Xe(){for(var e=new Date,t=e.getDay(),n=e.getHours(),a=0;a<v.length;a++){var o=v[a];if(-1!==o.days.indexOf(t)&&n>=o.startHour&&n<o.endHour)return o}return null}function Ke(){var e=Xe(),t=document.getElementById("happy-hour-banner");if(!e)return t&&(t.style.display="none"),document.querySelectorAll(".hh-price").forEach(function(e){e.remove()}),void document.querySelectorAll(".price.hh-crossed").forEach(function(e){e.classList.remove("hh-crossed")});if(!t){(t=document.createElement("div")).id="happy-hour-banner",t.className="happy-hour-banner";var n=document.getElementById("menu");n&&n.insertBefore(t,n.firstChild)}var a=new Date;a.setHours(e.endHour,0,0,0);var o=Math.max(0,a-new Date),r=Math.floor(o/6e4),i=Math.floor(o%6e4/1e3);t.innerHTML='<span class="hh-icon">🔥</span> <strong class="hh-text">'+e.label+'</strong> <span class="hh-timer">Ends in '+r+"m "+i+"s</span>",t.style.display="flex",document.querySelectorAll(".menu-item-card").forEach(function(t){var n=t.querySelector(".price");if(n){var a=t.closest(".menu-category");if(a){var o=(a.id||"").toLowerCase(),r=-1!==e.categories.indexOf("all");if(r||e.categories.forEach(function(e){-1!==o.indexOf(e)&&(r=!0)}),r){var i=parseInt(n.textContent.replace(/[^\d]/g,"")),s=Math.round(i*(1-e.discount/100));n.classList.add("hh-crossed");var c=t.querySelector(".hh-price");if(c)c.textContent="₹"+s;else{var l=document.createElement("span");l.className="hh-price",l.textContent="₹"+s,n.after(l)}}}}})}function $e(){if(0===V.length)return[];var e={},t=V.map(function(e){return e.name});return t.forEach(function(n){(m[n]||[]).forEach(function(n){-1===t.indexOf(n)&&f[n]&&(e[n]=(e[n]||0)+1)})}),Object.keys(e).sort(function(t,n){return e[n]-e[t]}).slice(0,4).map(function(e){return{name:e,price:f[e]}})}function Qe(){var e=document.getElementById("cart-recommendations");if(e){var t=$e();if(0!==t.length){var n='<p class="rec-title">You might also like:</p><div class="rec-items">';t.forEach(function(e){var t=(e.name||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),a=parseInt(e.price,10)||0;n+='<button class="rec-item" data-rec-name="'+t+'" data-rec-price="'+a+'"><span class="rec-name">'+t+'</span><span class="rec-price">₹'+a+'</span><span class="rec-add">+</span></button>'}),n+="</div>",e.innerHTML=n,e.querySelectorAll(".rec-item[data-rec-name]").forEach(function(e){e.addEventListener("click",function(){var t=e.getAttribute("data-rec-name"),n=parseInt(e.getAttribute("data-rec-price"),10)||0;"function"==typeof window.addToCart&&window.addToCart(t,n),"function"==typeof window.displayCart&&window.displayCart(),Qe()})}),e.style.display="block"}else e.style.display="none"}}Object.assign(window,{enableNotifications:function(){Notification.requestPermission().then(function(e){a("amoghaNotifPerm",e),He(),"granted"===e&&G("Notifications enabled!")})},dismissNotifBanner:He,sendPushNotification:je,initFCM:Fe,sendSmartNotification:async function(e){var t=null;try{t=JSON.parse(localStorage.getItem("amoghaUser"))}catch(i){}if(t){var n=[];try{var a=JSON.parse(localStorage.getItem("amoghaMyOrders"));a&&(n=a.map(function(e){return e.data}))}catch(i){}try{var o=await fetch("/api/smart-notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:t.phone,context:e||"general",orderHistory:n.slice(0,5)})});if(!o.ok)throw new Error("Server error");var r=await o.json();je(r.title||"Amogha Cafe",r.body||"Something delicious awaits!")}catch(i){je("Amogha Cafe","We have something delicious waiting for you!")}}},watchOrderStatus:We,stopWatchingOrder:function(){Ge&&(Ge(),Ge=null)}}),Object.assign(window,{openReservationModal:ze,closeReservationModal:function(){var e=document.getElementById("reservation-modal");e&&(e.style.display="none")},submitReservation:Ue}),window.selectSpice=Ye;var Ze=!1,et=null;function tt(){var e=window.SpeechRecognition||window.webkitSpeechRecognition;if(e){(et=new e).continuous=!1,et.interimResults=!0,et.lang={en:"en-IN",hi:"hi-IN",te:"te-IN"}[rt]||"en-IN",et.onresult=function(e){for(var t,n,a="",o=e.resultIndex;o<e.results.length;o++)a+=e.results[o][0].transcript;t=a,(n=document.getElementById("voice-transcript"))&&(n.textContent=t),e.results[e.resultIndex].isFinal&&function(e){if(-1!==(e=e.toLowerCase().trim()).indexOf("my usual")||-1!==e.indexOf("same as last")||-1!==e.indexOf("last order")){var t=null;try{t=JSON.parse(localStorage.getItem("amoghaMyOrders"))}catch(c){}if(t&&t.length>0&&t[0].id)return"function"==typeof window.reorderFromHistory&&window.reorderFromHistory(t[0].id),G("Reordering your last order!"),void ot()}var n=e.match(/^(?:add\s+)?(\d+)\s+/),a=n?parseInt(n[1]):1,o=e.replace(/^(?:add\s+)?(\d+\s+)?/,"").replace(/^add\s+/,""),r=null,i=0;if(Object.keys(f).forEach(function(e){var t=e.toLowerCase(),n=0;t===o?n=100:-1!==t.indexOf(o)?n=80:-1!==o.indexOf(t)?n=70:o.split(" ").forEach(function(e){e.length>2&&-1!==t.indexOf(e)&&(n+=20)}),n>i&&(i=n,r=e)}),r&&i>=20){for(var s=0;s<a;s++)Q(r,f[r]);G("Added "+a+"x "+r+" to cart"),ot()}else-1!==e.indexOf("checkout")||-1!==e.indexOf("check out")?("function"==typeof window.checkout&&window.checkout(),ot()):-1!==e.indexOf("clear")?("function"==typeof window.clearCart&&window.clearCart(),ot()):(ot(),G("AI is interpreting your request..."),fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,cart:[]})}).then(function(e){return e.json()}).then(function(e){e.suggestedItems&&e.suggestedItems.length>0?(e.suggestedItems.forEach(function(e){Q(e.name,e.price)}),G("Added "+e.suggestedItems.length+" item(s) via AI")):G(e.reply||"Could not understand. Try again.")}).catch(function(){G('Could not find: "'+o+'". Try again.')}))}(a)},et.onend=function(){Ze&&(Ze=!1,ot())},et.onerror=function(){Ze=!1,ot()};var t=document.createElement("button");t.id="voice-order-btn",t.className="voice-order-btn",t.innerHTML='<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>',t.title="Voice Order",t.onclick=nt,document.body.appendChild(t)}}function nt(){Ze?(et.stop(),Ze=!1,ot()):(Ze=!0,at(),et.start())}function at(){var e=document.getElementById("voice-overlay");e||((e=document.createElement("div")).id="voice-overlay",e.className="voice-overlay",e.innerHTML='<div class="voice-content"><div class="voice-waves"><span></span><span></span><span></span><span></span><span></span></div><p class="voice-status">Listening...</p><p class="voice-transcript" id="voice-transcript"></p><p class="voice-hint">Say "Add chicken biryani" or "2 butter naan"</p><button class="voice-close" onclick="toggleVoice()">Cancel</button></div>',document.body.appendChild(e)),e.classList.add("active"),document.getElementById("voice-transcript").textContent=""}function ot(){var e=document.getElementById("voice-overlay");e&&e.classList.remove("active")}var rt=n("amoghaLang")||"en";function it(){var e=p[rt]||p.en;document.querySelectorAll("[data-i18n]").forEach(function(t){var n=t.dataset.i18n;e[n]&&("INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName||void 0===t.placeholder?t.textContent=e[n]:t.placeholder=e[n])})}function st(e){return e?(e.name||"USER").replace(/[^A-Za-z]/g,"").toUpperCase().slice(0,4)+(e.phone||"0000").slice(-4):""}function ct(){(function(){const e=document.getElementById("reviews-carousel")||document.querySelector(".reviews-carousel");if(!e)return window.moveCarousel=window.moveCarousel||function(){},window.moveCarousel;let t,n=0;function a(){return window.innerWidth<=768?1:window.innerWidth<=1024?2:3}function o(){const t=function(){const t=e.querySelector(".review-card");if(!t)return 0;const n=window.getComputedStyle(t),a=t.offsetWidth+parseFloat(n.marginLeft)+parseFloat(n.marginRight);return isNaN(a)?0:a}();e.style.transform="translateX(-".concat(n*t,"px)")}var r=function(t){const r=e.querySelectorAll(".review-card"),i=a(),c=Math.max(0,r.length-i);n=Math.max(0,Math.min(n+t,c)),o(),s()};function i(){const t=e.querySelectorAll(".review-card"),r=a(),i=Math.max(0,t.length-r);n++,n>i&&(n=0),o()}function s(){clearInterval(t),t=setInterval(i,4e3)}window.moveCarousel=r;const c=document.querySelector(".reviews-carousel-wrapper");c&&(c.addEventListener("mouseenter",()=>{clearInterval(t)}),c.addEventListener("mouseleave",()=>{s()})),window.addEventListener("resize",()=>{n=0,o(),s()}),t=setInterval(i,4e3)})(),function(){var e=Array.prototype.slice.call(document.querySelectorAll(".gallery-slide"));0===e.length&&(e=Array.prototype.slice.call(document.body.children).filter(function(e){return e.classList&&e.classList.contains("gallery-slide")}));const t=document.getElementById("gallery-dots");let n=0;if(window.moveGallerySlide=function(){},!e||0===e.length)return window.moveGallerySlide;function a(t){e.forEach(e=>e.classList.remove("active")),e[t]&&e[t].classList.add("active"),n=t,document.querySelectorAll(".gallery-dot").forEach((e,n)=>e.classList.toggle("active",n===t))}if(t&&e.length>1&&e.forEach((e,n)=>{const o=document.createElement("button");o.className="gallery-dot"+(0===n?" active":""),o.addEventListener("click",()=>a(n)),t.appendChild(o)}),window.moveGallerySlide=function(t){0!==e.length&&a((n+t+e.length)%e.length)},e.length>1){var o=setInterval(()=>{window.moveGallerySlide(1)},5e3);window._galleryAutoSlide=o}window.moveGallerySlide}(),function(){window.closeLightbox=function(){},window.navigateLightbox=function(){};const e=document.querySelectorAll(".gallery-item img"),t=document.querySelectorAll(".gallery-slide-item img"),n=document.querySelectorAll("img[data-lightbox], #gallery img"),a=[...e,...t],o=document.getElementById("lightbox"),s=document.getElementById("lightbox-img");let c=0;0===a.length&&n.length>0&&n.forEach(function(e){a.push(e)}),0===a.length&&document.querySelectorAll("img").forEach(function(e){"lightbox-img"!==e.id&&a.push(e)}),o&&s&&0!==a.length&&(a.forEach((e,t)=>{e.addEventListener("click",()=>{c=t,s.src=e.src,o.classList.add("active"),i()})}),window.closeLightbox=function(){o.classList.remove("active"),r()},window.navigateLightbox=function(e){if(a.length){c=(c+e+a.length)%a.length;var t=a[c];t&&s&&(s.src=t.src)}},document.addEventListener("keydown",e=>{o.classList.contains("active")&&("Escape"===e.key&&window.closeLightbox(),"ArrowLeft"===e.key&&window.navigateLightbox(-1),"ArrowRight"===e.key&&window.navigateLightbox(1))}))}(),function(){var e=[{name:"Veg Dum Biryani",price:179},{name:"Paneer Biryani",price:219},{name:"Egg Biryani",price:189},{name:"Chicken Fry Piece Biryani",price:219},{name:"Chicken 65 Biryani",price:249},{name:"Boneless Chicken Biryani",price:219}],t=[{name:"Veg Manchurian",price:169},{name:"Paneer 65",price:189},{name:"Chicken 65",price:200},{name:"Chicken Hot Wings",price:220},{name:"Chilli Chicken",price:200}],n=[{name:"Tea",price:30},{name:"Coffee",price:40},{name:"Lassi",price:50},{name:"Buttermilk",price:35},{name:"Fresh Lime Soda",price:45}],a={biryani:null,starter:null,drink:null};function o(e,t,n){var a=document.getElementById(e);a&&(a.innerHTML=t.map(function(e){return'<button class="combo-option" data-category="'+n+'" data-name="'+e.name+'" data-price="'+e.price+'"><span class="combo-opt-name">'+e.name+'</span><span class="combo-opt-price">₹'+e.price+"</span></button>"}).join(""))}function s(){var e=document.getElementById("combo-selected"),t=document.getElementById("combo-original"),n=document.getElementById("combo-total"),o=document.getElementById("combo-add-btn");if(e){var r=[],i=0;if(a.biryani&&(r.push(a.biryani.name),i+=a.biryani.price),a.starter&&(r.push(a.starter.name),i+=a.starter.price),a.drink&&(r.push(a.drink.name),i+=a.drink.price),e.textContent=r.length>0?r.join(" + "):"Select items above",i>0){var s=Math.round(.85*i);t.textContent="₹"+i,t.style.textDecoration="line-through",n.textContent="₹"+s}else t.textContent="",n.textContent="";o&&(o.disabled=!(a.biryani&&a.starter&&a.drink))}}document.addEventListener("click",function(e){var t=e.target.closest(".combo-option");if(t){var n=t.dataset.category,o=t.dataset.name,r=parseInt(t.dataset.price);t.parentElement.querySelectorAll(".combo-option").forEach(function(e){e.classList.remove("selected")}),t.classList.add("selected"),a[n]={name:o,price:r},s()}}),window.openComboModal=function(){o("combo-biryanis",e,"biryani"),o("combo-starters",t,"starter"),o("combo-drinks",n,"drink"),a={biryani:null,starter:null,drink:null},s();var r=document.getElementById("combo-modal");r&&(r.style.display="block",i())},window.closeComboModal=function(){var e=document.getElementById("combo-modal");e&&(e.style.display="none",r())};var c=document.getElementById("combo-modal");c&&c.addEventListener("click",function(e){e.target===c&&window.closeComboModal()}),window.addComboToCart=function(){if(a.biryani&&a.starter&&a.drink){var e=a.biryani.price+a.starter.price+a.drink.price,t=Math.round(.85*e),n="Combo: "+a.biryani.name+" + "+a.starter.name+" + "+a.drink.name,o=V.find(function(e){return e.name===n});o?o.quantity++:V.push({name:n,price:t,quantity:1}),$(),K(),ae(),re(),G("Combo added! You saved ₹"+(e-t)),window.closeComboModal()}}}(),Ke(),window._happyHourInterval&&clearInterval(window._happyHourInterval),window._happyHourInterval=setInterval(Ke,6e4),setTimeout(tt,1e3),setTimeout(function(){var e=document.querySelector(".nav-links");if(e&&!e.querySelector(".lang-switcher")){var t=document.createElement("li");t.className="lang-switcher",t.innerHTML='<button class="lang-btn'+("en"===rt?" active":"")+'" data-lang="en" onclick="switchLanguage(\'en\')">EN</button><button class="lang-btn'+("hi"===rt?" active":"")+'" data-lang="hi" onclick="switchLanguage(\'hi\')">हि</button><button class="lang-btn'+("te"===rt?" active":"")+'" data-lang="te" onclick="switchLanguage(\'te\')">తె</button>';var n=e.querySelector(".theme-toggle");n?e.insertBefore(t,n.parentElement):e.appendChild(t),it()}},500),setTimeout(function(){"function"==typeof window.loadMenuRatings&&window.loadMenuRatings()},2e3),function(){window.getScheduleInfo=function(){var e=document.getElementById("schedule-order-check")||document.getElementById("schedChk"),t=document.getElementById("schedule-date")||document.getElementById("schedDate"),n=document.getElementById("schedule-time")||document.getElementById("schedTime");return e&&t&&n&&e.checked?{date:t.value,time:n.value}:null};var e=document.getElementById("schedule-order-check")||document.getElementById("schedChk"),t=document.getElementById("schedule-fields"),n=document.getElementById("schedule-date")||document.getElementById("schedDate"),a=document.getElementById("schedule-time")||document.getElementById("schedTime");e&&n&&a&&e.addEventListener("change",function(){var e;t&&(t.style.display=this.checked?"block":"none"),this.checked&&(function(){var e=new Date,t=e.toISOString().split("T")[0],a=new Date(e);a.setDate(a.getDate()+3);var o=a.toISOString().split("T")[0];n.min=t,n.max=o,n.value=t}(),e=["11:00 AM","11:30 AM","12:00 PM","12:30 PM","1:00 PM","1:30 PM","2:00 PM","2:30 PM","3:00 PM","3:30 PM","4:00 PM","4:30 PM","5:00 PM","5:30 PM","6:00 PM","6:30 PM","7:00 PM","7:30 PM","8:00 PM","8:30 PM","9:00 PM"],a.innerHTML='<option value="">Select Time</option>',e.forEach(function(e){a.innerHTML+='<option value="'+e+'">'+e+"</option>"}))})}(),setTimeout(pt,1500);var e=window.displayCart;"function"==typeof e&&(window.displayCart=function(){e(),Qe()})}function lt(){var e=document.getElementById("daily-special-section");if(e){var t=w();t?t.collection("settings").doc("dailySpecial").get().then(function(t){if(t.exists&&t.data().active){var n=t.data();e.style.display="";var a=e.querySelector(".daily-special-img"),o=e.querySelector(".daily-special-img-placeholder"),r=e.querySelector(".daily-special-title"),i=e.querySelector(".daily-special-desc"),s=e.querySelector(".daily-special-price"),c=e.querySelector(".daily-special-add-btn"),l=n.imageUrl;l&&-1!==l.indexOf("res.cloudinary.com")&&-1!==l.indexOf("/upload/")&&-1===l.indexOf("f_auto")&&(l=l.replace("/upload/","/upload/f_auto,q_auto,w_600/")),l&&a&&(a.src=l,a.style.display="block",o&&(o.style.display="none")),r&&(r.textContent=n.title||"Chef's Special"),i&&(i.textContent=n.description||""),s&&(s.innerHTML="₹"+(n.price||"")),c&&n.title&&(c.dataset.item=n.title,c.dataset.price=n.price||0),d(),window._countdownInterval&&clearInterval(window._countdownInterval),window._countdownInterval=setInterval(d,1e3)}else e.style.display="none";function d(){var t=new Date,n=new Date;n.setHours(24,0,0,0);var a=Math.max(0,n-t),o=Math.floor(a/36e5),r=Math.floor(a%36e5/6e4),i=Math.floor(a%6e4/1e3),s=e.querySelector(".cd-h"),c=e.querySelector(".cd-m"),l=e.querySelector(".cd-s");s&&(s.textContent=String(o).padStart(2,"0")),c&&(c.textContent=String(r).padStart(2,"0")),l&&(l.textContent=String(i).padStart(2,"0"))}}).catch(function(){e.style.display="none"}):e.style.display="none"}}function dt(){var e=document.getElementById("combo-builder-section");if(e){var t={};try{document.querySelectorAll(".menu-item-card[data-id]").forEach(function(e){var n=e.querySelector(".add-to-cart");n&&(t[e.dataset.id]=parseFloat(n.dataset.price)||0)})}catch(i){}var n={"Veg Manchurian":169,"Paneer 65":189,"Chicken 65":200,"Chicken Hot Wings":220,"Veg Spring Rolls":149,"Chicken Lollipop":230,"Paneer Tikka":209,"Chicken Seekh Kebab":229,"Tandoori Chicken":269,"Paneer Butter Masala":199,"Dal Tadka":149,"Butter Chicken":249,"Chicken Curry":219,"Mutton Curry":319,"Gongura Chicken":239,"Veg Dum Biryani":199,"Chicken Dum Biryani":249,"Mutton Dum Biryani":349,"Butter Naan":40,"Garlic Naan":50,"Tandoori Roti":30,"Butter Roti":35,"Laccha Paratha":45,Tea:30,Coffee:40,Lassi:50,Buttermilk:35,"Fresh Lime Soda":45,"Hot Chocolate":60};Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),o("combo-starter",["Veg Manchurian","Paneer 65","Chicken 65","Chicken Hot Wings","Veg Spring Rolls","Chicken Lollipop","Paneer Tikka","Chicken Seekh Kebab","Tandoori Chicken"]),o("combo-main",["Paneer Butter Masala","Dal Tadka","Butter Chicken","Chicken Curry","Mutton Curry","Gongura Chicken","Veg Dum Biryani","Chicken Dum Biryani","Mutton Dum Biryani"]),o("combo-bread",["Butter Naan","Garlic Naan","Tandoori Roti","Butter Roti","Laccha Paratha"]),o("combo-drink",["Tea","Coffee","Lassi","Buttermilk","Fresh Lime Soda","Hot Chocolate"]),e.querySelectorAll("select").forEach(function(e){e.addEventListener("change",r)}),r();var a=e.querySelector(".combo-add-btn");a&&a.addEventListener("click",function(){var t=0;["combo-starter","combo-main","combo-bread","combo-drink"].forEach(function(n){var a=e.querySelector("#"+n);if(a&&a.value){var o=a.options[a.selectedIndex],r=parseFloat(o.dataset.price)||0,i=Math.round(.85*r);"function"==typeof window.finalizeAddToCart&&window.finalizeAddToCart(a.value,i,"medium",[]),t++}}),t>0&&(a.textContent="✓ Added to Cart!",a.style.background="linear-gradient(135deg,#27ae60,#2ecc71)",setTimeout(function(){a.textContent="Add Combo to Cart",a.style.background=""},2e3))})}function o(n,a){var o=e.querySelector("#"+n);o&&(o.innerHTML='<option value="">— Choose —</option>'+a.map(function(e){var n=t[e]||0;return'<option value="'+e+'" data-price="'+n+'">'+e+" (₹"+n+")</option>"}).join(""))}function r(){var t=0;["combo-starter","combo-main","combo-bread","combo-drink"].forEach(function(n){var a=e.querySelector("#"+n);if(a&&a.value){var o=a.options[a.selectedIndex];t+=parseFloat(o.dataset.price)||0}});var n=Math.round(.85*t),a=t-n,o=e.querySelector(".combo-original"),r=e.querySelector(".combo-discounted"),i=e.querySelector(".combo-savings"),s=e.querySelector(".combo-add-btn");o&&(o.textContent=t>0?"₹"+t:""),r&&(r.textContent=t>0?"₹"+n:"₹0"),i&&(i.textContent=t>0?"Save ₹"+a:""),s&&(s.disabled=0===t)}}function ut(){const e=w();if(!e)return;const t=document.querySelector(".bar-ticker-track");t&&e.collection("orders").orderBy("createdAt","desc").limit(6).get().then(function(e){const n=[];if(e.forEach(function(e){const t=e.data(),a=t.items&&t.items[0]&&t.items[0].name?t.items[0].name:null,o=(t.customerName||t.userName||"").split(" ")[0]||"Someone";a&&n.push({firstName:o,itemName:a})}),n.length<3)return;const a=n.map(function(e){return'<div class="bar-ticker-item"><span>🍛</span><span>'+(Ve(e.firstName)+" just ordered "+Ve(e.itemName))+'</span></div><span class="bar-dot"></span>'}).join("");t.innerHTML=a+a}).catch(function(){})}function mt(){const e=document.getElementById("catering-modal");e&&(e.classList.remove("active"),r())}function ft(){var e=document.getElementById("reorder-section"),t=document.getElementById("reorder-cards");if(e&&t)if(A()){var n=null;try{n=JSON.parse(localStorage.getItem("amoghaMyOrders"))}catch(r){}if(n&&n.length){var a=n.slice(0,3),o="";a.forEach(function(e){var t=e.data,n=(t.createdAt?new Date(t.createdAt):new Date).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"}),a=(t.items||[]).reduce(function(e,t){return e+(t.qty||1)},0),r=t.total||0;o+='<div class="reorder-card" style="min-width:220px;background:rgba(212,160,23,0.06);border:1px solid rgba(212,160,23,0.15);border-radius:14px;padding:1rem;scroll-snap-align:start;flex-shrink:0"><div style="font-size:0.8rem;color:var(--text-muted);margin-bottom:0.4rem">'+n+'</div><div style="font-size:0.95rem;font-weight:600;color:var(--text-primary,#1a0f08);margin-bottom:0.3rem">'+a+" item"+(1!==a?"s":"")+'</div><div style="font-size:1.05rem;font-weight:700;color:#D4A017;margin-bottom:0.7rem">Rs.'+r+"</div><button onclick=\"reorderFromHistory('"+e.id+'\')" style="width:100%;padding:0.5rem;background:linear-gradient(135deg,#D4A017,#B8860B);color:#1a0f08;border:none;border-radius:8px;font-weight:700;cursor:pointer;font-size:0.85rem">Reorder</button></div>'}),t.innerHTML=o,e.style.display="block"}else e.style.display="none"}else e.style.display="none"}function pt(){var e=w();e&&e.collection("settings").doc("dynamicPricing").get().then(function(e){e.exists&&e.data().rules&&(y.length=0,e.data().rules.forEach(function(e){y.push(e)}),yt())}).catch(function(e){console.error("Dynamic pricing load error:",e)})}function vt(e,t){if(!y||0===y.length)return e;for(var n=new Date,a=n.getDay(),o=n.getHours(),r=(t||"").toLowerCase(),i=0;i<y.length;i++){var s=y[i];if(("all"===s.day||parseInt(s.day)===a)&&!(o<parseInt(s.startHour)||o>=parseInt(s.endHour))){for(var c=s.categories||[],l=!1,d=0;d<c.length;d++)if(c[d].toLowerCase()===r){l=!0;break}if(l)return Math.round(e*parseFloat(s.multiplier))}}return e}function yt(){y&&0!==y.length&&document.querySelectorAll(".menu-item-card").forEach(function(e){var t=e.querySelector(".price");if(t&&!t.classList.contains("hh-crossed")){var n=e.closest(".menu-category");if(n){var a="",o=n.querySelector("h2, h3, .category-title");o&&(a=o.textContent.trim()),a||(a=(n.id||"").replace("cat-",""));var r=parseInt(t.textContent.replace(/[^\d]/g,""));if(r){var i=vt(r,a);if(i===r){var s=e.querySelector(".dp-price");return s&&s.remove(),void t.classList.remove("dp-crossed")}t.classList.add("dp-crossed");var c=e.querySelector(".dp-price");if(c)c.textContent="₹"+i;else{var l=document.createElement("span");l.className="dp-price",l.textContent="₹"+i,t.after(l)}}}}})}function gt(e,t,n){var a="";n.forEach(function(e){var t=(e.name||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),n=(e.reason||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),o=parseInt(e.price,10)||0;a+='<div class="ai-rec-card"><div class="ai-rec-name">'+t+'</div><div class="ai-rec-reason">'+n+'</div><div class="ai-rec-price">₹'+o+'</div><button class="add-to-cart" data-rec-name="'+t+'" data-rec-price="'+o+'">Add to Order</button></div>'}),t.innerHTML=a,t.querySelectorAll(".add-to-cart[data-rec-name]").forEach(function(e){e.addEventListener("click",function(){var t=e.getAttribute("data-rec-name"),n=parseInt(e.getAttribute("data-rec-price"),10)||0;"function"==typeof window.addToCart&&window.addToCart(t,n,e)})}),e.style.display="block"}function ht(){var e=(new Date).getHours();return e>=5&&e<11?"morning":e>=11&&e<15?"lunch":e>=15&&e<19?"evening":e>=19&&e<23?"night":"late"}Object.assign(window,{selectSpice:Ye,moveCarousel:window.moveCarousel,moveGallerySlide:window.moveGallerySlide,closeLightbox:window.closeLightbox,navigateLightbox:window.navigateLightbox,openVideoLightbox:function(e){if(e){var t=document.getElementById("video-lightbox"),n=document.getElementById("lightbox-video");t&&n&&(n.src=e,t.style.display="flex",n.play().catch(function(){}))}},closeVideoLightbox:function(){var e=document.getElementById("video-lightbox"),t=document.getElementById("lightbox-video");e&&(e.style.display="none"),t&&(t.pause(),t.src="")},openReviewModal:Je,setReviewStar:function(e,t,n){window._reviewRatings[t]=n,e.parentElement.querySelectorAll(".review-star").forEach(function(e,t){e.innerHTML=t<n?"★":"☆",e.classList.toggle("active",t<n)})},submitReviews:function(){var e=A();if(e){var t=document.getElementById("review-text").value.trim(),n=w();if(n){var a=n.batch(),o=!1;window._reviewItems.forEach(function(r,i){var s=window._reviewRatings[i];if(s>0){o=!0;var c=n.collection("reviews").doc();a.set(c,{itemName:r.name,rating:s,text:t,userName:e.name,userPhone:e.phone,createdAt:(new Date).toISOString()})}}),o?a.commit().then(function(){document.getElementById("review-modal").style.display="none",G("Thank you for your review!");var e=A();if(e){e.loyaltyPoints=(e.loyaltyPoints||0)+25,q(e);var t=w();t&&t.collection("users").doc(e.phone).update({loyaltyPoints:e.loyaltyPoints}).catch(function(e){console.error("Review loyalty update error:",e)}),setTimeout(function(){G("+25 loyalty points for your review!")},1500)}setTimeout(function(){"function"==typeof window.loadMenuRatings&&window.loadMenuRatings()},1e3)}).catch(function(){G("Failed to submit review. Please try again.")}):G("Please rate at least one item")}}},scheduleReviewPrompt:function(e){setTimeout(function(){A()&&Je(e)},6e4)},openComboModal:window.openComboModal,closeComboModal:window.closeComboModal,addComboToCart:window.addComboToCart,getActiveHappyHour:Xe,getRecommendations:$e,showRecommendations:Qe,initVoiceOrdering:tt,toggleVoice:nt,showVoiceOverlay:at,switchLanguage:function(e){rt=e,a("amoghaLang",e),it(),document.querySelectorAll(".lang-btn").forEach(function(t){t.classList.toggle("active",t.dataset.lang===e)})},applyTranslations:it,openReferralModal:function(){var e=A();if(e){var t=e.referralCode||st(e);if(!e.referralCode){e.referralCode=t,q(e);var n=w();n&&n.collection("users").doc(e.phone).update({referralCode:t}).catch(function(e){console.error("Referral code save error:",e)})}var a=document.getElementById("referral-modal");a||((a=document.createElement("div")).id="referral-modal",a.className="modal",a.innerHTML='<div class="modal-content referral-content"></div>',document.body.appendChild(a),a.addEventListener("click",function(e){e.target===a&&(a.style.display="none")}));var o="Order from Amogha Cafe & get Rs.50 off your first order! Use my referral code: "+t+" when signing up. Order at "+window.location.origin;a.querySelector(".referral-content").innerHTML='<span class="close" onclick="document.getElementById(\'referral-modal\').style.display=\'none\'">×</span><h2>Refer a Friend</h2><p class="referral-subtitle">Share your code and both get rewarded!</p><div class="referral-code-box"><span class="referral-code">'+t+'</span><button class="referral-copy" onclick="safeCopy(\''+String(t).replace(/[\\'"]/g,"")+'\',this)">Copy</button></div><div class="referral-rewards"><div class="referral-reward"><span class="referral-reward-icon">🎁</span><span>Your friend gets <strong>Rs.50 off</strong> first order</span></div><div class="referral-reward"><span class="referral-reward-icon">⭐</span><span>You get <strong>100 loyalty points</strong></span></div></div><a class="whatsapp-btn referral-share" href="https://wa.me/?text='+encodeURIComponent(o)+'" target="_blank">Share via WhatsApp</a>',a.style.display="block"}else"function"==typeof window.openAuthModal&&window.openAuthModal()},closeReferralModal:function(){var e=document.getElementById("referral-modal");e&&(e.style.display="none")},generateReferralCode:st,applyReferralAtSignup:function(e){if(e){var t=w();t&&(e=e.toUpperCase().trim(),t.collection("users").where("referralCode","==",e).limit(1).get().then(function(e){if(!e.empty){var n=e.docs[0].data(),a=A();a&&n.phone!==a.phone&&(t.collection("referrals").add({referrerPhone:n.phone,refereePhone:a.phone,redeemed:!1,createdAt:(new Date).toISOString()}).catch(function(e){console.error("Referral save error:",e)}),a.referralDiscount=50,q(a),G("Referral applied! Rs.50 off your first order!"))}}))}},openMyOrders:function(){var e=A();if(e){var t=document.getElementById("myorders-modal");t||((t=document.createElement("div")).id="myorders-modal",t.className="modal",t.innerHTML='<div class="modal-content myorders-content"><span class="close" onclick="document.getElementById(\'myorders-modal\').style.display=\'none\';if(typeof unlockScroll===\'function\')unlockScroll()">×</span><h2>My Orders</h2><div id="myorders-list" class="myorders-list"><p>Loading...</p></div></div>',document.body.appendChild(t),t.addEventListener("click",function(e){e.target===t&&(t.style.display="none","function"==typeof window.unlockScroll&&window.unlockScroll())})),t.style.display="block";var o=document.getElementById("myorders-list");o.innerHTML='<p style="text-align:center;color:var(--text-muted)">Loading orders...</p>';var r=w();r?r.collection("orders").where("userId","==",e.phone).orderBy("createdAt","desc").limit(10).get().then(function(e){if(e.empty)o.innerHTML='<p style="text-align:center;color:var(--text-muted);padding:2rem">No orders yet. Place your first order!</p>';else{var t="";e.forEach(function(e){var n=e.data(),a=(n.createdAt?new Date(n.createdAt):new Date).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"}),o="status-badge status-badge--"+(n.status||"pending"),r=(n.items||[]).map(function(e){return Ve(e.name)+" x"+e.qty}).join(", ");t+='<div class="myorder-card"><div class="myorder-header"><span class="myorder-date">'+Ve(a)+'</span><span class="'+o+'">'+Ve(n.status||"pending")+'</span></div><p class="myorder-items">'+r+'</p><div class="myorder-footer"><span class="myorder-total">Rs.'+(n.total||0)+'</span><button class="myorder-reorder-btn" onclick="reorderFromHistory(\''+e.id+"')\">Order Again</button></div></div>"}),o.innerHTML=t,a("amoghaMyOrders",JSON.stringify(e.docs.map(function(e){return{id:e.id,data:e.data()}})))}}).catch(function(e){console.error("Load orders error:",e);var t=n("amoghaMyOrders");if(t){var a;try{a=JSON.parse(t)}catch(i){a=null}if(!a||!Array.isArray(a))return void(o.innerHTML='<p style="text-align:center;color:#e74c3c">Failed to load orders. Please try again.</p>');var r="";a.forEach(function(e){var t=e.data,n=(t.createdAt?new Date(t.createdAt):new Date).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"}),a=(t.items||[]).map(function(e){return Ve(e.name)+" x"+e.qty}).join(", ");r+='<div class="myorder-card"><div class="myorder-header"><span class="myorder-date">'+Ve(n)+'</span><span class="myorder-status">'+Ve((t.status||"").toUpperCase())+'</span></div><p class="myorder-items">'+a+'</p><div class="myorder-footer"><span class="myorder-total">Rs.'+(t.total||0)+'</span><button class="myorder-reorder-btn" onclick="reorderFromHistory(\''+e.id+"')\">Order Again</button></div></div>"}),o.innerHTML=r}else o.innerHTML='<p style="text-align:center;color:#e74c3c">Failed to load orders. Please try again.</p>'}):o.innerHTML='<p style="text-align:center;color:var(--text-muted);padding:2rem">Service unavailable. Please refresh.</p>'}else"function"==typeof window.openAuthModal&&window.openAuthModal()},closeMyOrders:function(){var e=document.getElementById("myorders-modal");e&&(e.style.display="none")},reorderFromHistory:function(e){var t=n("amoghaMyOrders");if(t){var a;try{a=JSON.parse(t)}catch(s){return void G("Could not load order history.")}var o=a.find(function(t){return t.id===e});if(o&&o.data.items){o.data.items.forEach(function(e){for(var t=0;t<e.qty;t++)Q(e.name,e.price)});var r=document.getElementById("myorders-modal");return r&&(r.style.display="none"),void G("Items added to cart! Review and checkout.")}}var i=w();i&&i.collection("orders").doc(e).get().then(function(e){if(e.exists&&e.data().items){e.data().items.forEach(function(e){for(var t=0;t<e.qty;t++)Q(e.name,e.price)});var t=document.getElementById("myorders-modal");t&&(t.style.display="none"),G("Items added to cart! Review and checkout.")}})},loadDailySpecial:lt,initComboBuilder:dt,getUpsellItems:function(e){var t,n=[];for(t=0;t<e.length;t++)n.push(e[t].name);var a=[],o={};for(t=0;t<e.length;t++){var r=e[t].name,i=m[r];if(i)for(var s=0;s<i.length;s++){var c=i[s];if(-1===n.indexOf(c)&&!o[c]){var l=f[c];if(l&&(o[c]=!0,a.push({name:c,price:l,reason:"Goes great with "+r}),a.length>=3))return a}}}return a}}),window.initLiveOrderTicker=ut,window.openCateringModal=function(){const e=document.getElementById("catering-modal");e&&(e.classList.add("active"),i())},window.closeCateringModal=mt,window.submitCateringEnquiry=function(){var e,t,n,a,o,r;const i=w(),s=null==(e=document.getElementById("catering-name"))?void 0:e.value.trim(),c=null==(t=document.getElementById("catering-phone"))?void 0:t.value.trim(),l=null==(n=document.getElementById("catering-event"))?void 0:n.value,d=null==(a=document.getElementById("catering-guests"))?void 0:a.value,u=null==(o=document.getElementById("catering-date"))?void 0:o.value,m=null==(r=document.getElementById("catering-message"))?void 0:r.value.trim(),f=document.getElementById("catering-submit-btn");if(!(s&&c&&l&&d&&u))return void alert("Please fill in all required fields.");f&&(f.disabled=!0,f.textContent="Submitting…");const p={name:s,phone:c,eventType:l,guestCount:parseInt(d)||0,date:u,message:m||"",createdAt:(new Date).toISOString()};(i?i.collection("cateringInquiries").add(p):Promise.reject("no db")).then(function(){mt();const e=document.createElement("div");e.className="catering-toast",e.textContent="✅ Catering enquiry received! We'll contact you within 24 hours.",document.body.appendChild(e),setTimeout(function(){e.classList.add("show")},10),setTimeout(function(){e.classList.remove("show"),setTimeout(function(){e.remove()},400)},4e3)}).catch(function(){alert("Could not submit. Please call us at +91 91210 04999."),f&&(f.disabled=!1,f.textContent="Submit Enquiry")})},window.initOrderAgainSection=ft,window.loadDynamicPricingRules=pt,window.getAdjustedPrice=vt,window.applyDynamicPricing=yt,window.openMealPlannerModal=function(){var e=document.getElementById("meal-planner-overlay");e&&e.remove();var t=document.createElement("div");t.id="meal-planner-overlay",t.className="meal-planner-overlay",t.onclick=function(e){e.target===t&&t.remove()},t.innerHTML='<div class="meal-planner-card"><div class="meal-planner-header"><h2><span class="ai-badge">AI</span> 7-Day Meal Planner</h2><button onclick="closeMealPlanner()" style="background:none;border:none;color:var(--text-muted);font-size:1.5rem;cursor:pointer">×</button></div><div class="meal-planner-controls"><select id="mp-dietary"><option value="all">All</option><option value="veg">Veg Only</option><option value="non-veg">Non-Veg Only</option></select><input type="number" id="mp-budget" placeholder="Daily budget (Rs.)" min="100" max="5000" style="width:140px"><input type="number" id="mp-people" placeholder="People" min="1" max="10" value="1" style="width:80px"></div><button class="meal-planner-generate" onclick="generateMealPlan()">Generate AI Meal Plan</button><div id="meal-plan-result"></div></div>',document.body.appendChild(t)},window.closeMealPlanner=function(){var e=document.getElementById("meal-planner-overlay");e&&e.remove()},window.generateMealPlan=async function(){var e=document.getElementById("meal-plan-result");if(e){e.innerHTML='<div class="insights-loading">Generating your personalized meal plan...</div>';try{var t=await fetch("/api/meal-plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dietary:document.getElementById("mp-dietary").value,budget:parseInt(document.getElementById("mp-budget").value)||0,people:parseInt(document.getElementById("mp-people").value)||1})}),n=await t.json(),a='<div class="meal-plan-grid">';n.days&&n.days.forEach(function(e){a+='<div class="meal-day-card"><h4>'+e.day+"</h4>",(e.meals||[]).forEach(function(e){a+='<div style="font-size:.68rem;color:#D4A017;font-weight:600;text-transform:uppercase;margin-top:6px">'+e.mealType+"</div>",(e.items||[]).forEach(function(e){a+='<div class="meal-item">'+e.name+" x"+(e.qty||1)+" — ₹"+e.price+"</div>"})}),a+="</div>"}),a+="</div>",n.totalCost&&(a+='<div class="meal-plan-summary"><span>Total: ₹'+n.totalCost+"</span><span>Daily avg: ₹"+(n.dailyAverage||Math.round(n.totalCost/7))+"</span></div>"),n.tips&&n.tips.length>0&&(a+='<ul class="meal-plan-tips">',n.tips.forEach(function(e){a+="<li>"+e+"</li>"}),a+="</ul>"),e.innerHTML=a}catch(o){e.innerHTML='<p style="color:#e74c3c;font-size:.85rem;text-align:center">Failed to generate meal plan. Please try again.</p>'}}};var wt={morning:{emoji:"☀️",text:"Good Morning! Start your day with our breakfast picks"},lunch:{emoji:"🍛",text:"Lunchtime! Fresh biryanis and meals ready for you"},evening:{emoji:"🍵",text:"Good Evening! Time for chai and snacks"},night:{emoji:"🌙",text:"Dinner Time! End your day with something special"},late:{emoji:"🌃",text:"Late Night Cravings? We've got you covered"}},bt={morning:["Tiffins","Beverages"],lunch:["Biryanis","Rice","Curries"],evening:["Starters","Beverages","Snacks"],night:["Biryanis","Curries","Noodles"]};function Et(){var e=null;try{e=JSON.parse(localStorage.getItem("amoghaUser"))}catch(l){}if(e){var t=null;try{t=JSON.parse(localStorage.getItem("amoghaMyOrders"))}catch(l){}if(t&&t.length){for(var n={},a=Math.min(t.length,3),o=0;o<a;o++){var r=t[o].data;r&&r.items&&r.items.forEach(function(e){var t=e.name;t&&(n[t]=(n[t]||0)+(e.qty||1))})}var i=Object.keys(n).sort(function(e,t){return n[t]-n[e]}).slice(0,3);if(0!==i.length){var s=(e.name||"Friend").split(" ")[0],c=document.createElement("div");c.id="reorder-bar",c.className="reorder-bar",c.innerHTML='<div class="reorder-bar-inner"><span class="reorder-bar-label">Welcome back, '+s+'! 🔄 Reorder:</span><div class="reorder-bar-chips">'+i.map(function(e){var t=f[e]||0;return'<button class="reorder-chip" data-item="'+e.replace(/"/g,""")+'" data-price="'+t+'">'+e+(t?" ₹"+t:"")+"</button>"}).join("")+'</div><button class="reorder-bar-close" aria-label="Close">×</button></div>',document.body.appendChild(c),c.addEventListener("click",function(e){var t=e.target.closest(".reorder-chip");if(t){var n=t.getAttribute("data-item"),a=parseFloat(t.getAttribute("data-price"))||0;"function"==typeof window.addToCart?window.addToCart(n,a):Q(n,a),t.classList.add("reorder-chip--added"),t.textContent="✓ Added",setTimeout(function(){t.classList.remove("reorder-chip--added")},1500)}e.target.closest(".reorder-bar-close")&&It(c)}),requestAnimationFrame(function(){setTimeout(function(){c.classList.add("reorder-bar--visible")},300)}),setTimeout(function(){It(c)},1e4)}}}}function It(e){e&&!e._hiding&&(e._hiding=!0,e.classList.remove("reorder-bar--visible"),setTimeout(function(){e.parentNode&&e.remove()},500))}function Lt(e,t){return import(e).then(function(e){t&&"function"==typeof e[t]&&e[t]()}).catch(function(t){console.error("[Amogha] Module load failed: "+e,t.message||t)})}function Ct(e,t,n){var a=!1;function o(){a||(a=!0,t())}var r=setTimeout(o,n);if("undefined"!=typeof IntersectionObserver)for(var i=0;i<e.length;i++){var s=document.getElementById(e[i]);if(s){var c=new IntersectionObserver(function(e){e[0].isIntersecting&&(clearTimeout(r),o(),c.disconnect())},{rootMargin:"400px"});c.observe(s);break}}}function xt(){var e=document.getElementById("offline-banner");e&&(e.style.display=navigator.onLine?"none":"flex");var t=document.getElementById("aria-live-region");t&&(t.textContent=navigator.onLine?"":"You are currently offline. Some features may be limited.")}if(function(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),window.scrollTo(0,0);var e=document.getElementById("page-transition");e&&requestAnimationFrame(function(){e.classList.add("loaded")});var t=document.getElementById("preloader");t&&setTimeout(function(){t.classList.add("hidden")},800),function(){const e=document.getElementById("theme-toggle");e&&(e.setAttribute("aria-label","Toggle dark mode"),"true"===n("amogha-dark-mode")&&(document.body.classList.add("dark-mode"),e.textContent="☀️"),e.addEventListener("click",()=>{document.body.classList.toggle("dark-mode");const t=document.body.classList.contains("dark-mode");e.textContent=t?"☀️":"🌙",a("amogha-dark-mode",t)}))}(),function(){const e=document.querySelectorAll(".stat-number"),t=document.querySelector(".stats-section");if(t){let n=!1;const a=new IntersectionObserver(o=>{o[0].isIntersecting&&!n&&(n=!0,function(){if(window.innerWidth<=768)e.forEach(function(e){var t=parseFloat(e.dataset.target);e.textContent=t%1!=0?t.toFixed(1):t.toLocaleString()});else{var t=[];e.forEach(function(e){t.push({el:e,target:parseFloat(e.dataset.target),isDecimal:parseFloat(e.dataset.target)%1!=0,lastValue:-1})});var n=performance.now();requestAnimationFrame(function e(a){for(var o=a-n,r=Math.min(o/2e3,1),i=1-Math.pow(1-r,3),s=0;s<t.length;s++){var c=t[s],l=c.isDecimal?+(c.target*i).toFixed(1):Math.floor(c.target*i);l!==c.lastValue&&(c.el.textContent=c.isDecimal?l.toFixed(1):l.toLocaleString(),c.lastValue=l)}r<1&&requestAnimationFrame(e)})}}(),a.unobserve(t))},{threshold:.3});a.observe(t)}}(),function(){var e=document.querySelectorAll(".reveal");if(e.length&&"undefined"!=typeof IntersectionObserver){var t=new IntersectionObserver(function(e){e.forEach(function(e){e.isIntersecting&&(e.target.classList.add("in-view"),t.unobserve(e.target))})},{threshold:.12,rootMargin:"0px 0px -40px 0px"});e.forEach(function(e){t.observe(e)})}}(),function(){var e=document.getElementById("nav-links"),t=document.getElementById("mobile-menu-toggle"),n=document.getElementById("mobile-menu-overlay");if(e&&t){var a,o=e.parentElement;s(),window.addEventListener("resize",function(){clearTimeout(a),a=setTimeout(s,100)}),t.addEventListener("click",c),t.addEventListener("touchend",function(e){e.preventDefault(),c(e)},{passive:!1}),n&&n.addEventListener("click",De),e.querySelectorAll("a").forEach(function(a){a.addEventListener("click",function(o){var r=a.getAttribute("href");if("signin-btn"===a.id||a.closest("#signin-btn"))return e.classList.remove("active"),n&&n.classList.remove("active"),t.textContent="☰",void t.setAttribute("aria-expanded","false");if(r&&r.startsWith("#")){o.preventDefault(),De(!0);var i=document.querySelector(r);i&&"function"==typeof i.scrollIntoView&&setTimeout(function(){i.scrollIntoView({behavior:"smooth",block:"start"})},50)}else De()})})}function s(){window.innerWidth<=768?e.parentElement!==document.body&&document.body.appendChild(e):e.parentElement===document.body&&o.appendChild(e)}function c(a){a&&(a.preventDefault(),a.stopPropagation());var o=e.classList.toggle("active");n&&n.classList.toggle("active",o),t.textContent=o?"✕":"☰",t.setAttribute("aria-expanded",o?"true":"false"),o?i():r()}}(),document.querySelectorAll('a[href^="#"]').forEach(e=>{e.addEventListener("click",function(e){if("cart-icon"===this.id)return;e.preventDefault();var t=this.getAttribute("href");const n=document.querySelector(t);if(n&&"function"==typeof n.scrollIntoView){De(!0),n.scrollIntoView({behavior:"smooth",block:"start"});var a="#home"===t?"":t;history.pushState(null,"",a||window.location.pathname)}})}),window.addEventListener("popstate",function(){if(window.location.hash){var e=window.location.hash.split("?")[0],t=e.length>1?document.querySelector(e):null;t&&t.scrollIntoView({behavior:"smooth",block:"start"})}else window.scrollTo({top:0,behavior:"smooth"})});const o=document.getElementById("back-to-top");o&&o.addEventListener("click",()=>{window.scrollTo({top:0,behavior:"smooth"})});const s=document.querySelector(".hero-slideshow"),c=document.querySelectorAll("section[id]"),l=document.querySelectorAll('.nav-links a[href^="#"]'),d=document.querySelector("header");var u=0,m=document.querySelector(".hero-scroll-indicator"),f=document.getElementById("btt-ring-fill"),p=document.getElementById("sticky-order-bar"),v=document.querySelector(".hero"),y=2*Math.PI*16,g=v?v.offsetHeight:600,h=[];c.forEach(function(e){h.push({id:e.getAttribute("id"),top:e.offsetTop})});var w=document.querySelector(".about"),b=document.querySelector(".chef-content"),E=document.querySelector(".stats-grid"),I=w?w.offsetTop:0,L=b?b.closest("section")||b.closest(".chef-section"):null,C=L?L.offsetTop:0,x=E?E.closest(".stats-section"):null,S=x?x.offsetTop:0;window.addEventListener("resize",function(){g=v?v.offsetHeight:600,h=[],c.forEach(function(e){h.push({id:e.getAttribute("id"),top:e.offsetTop})}),I=w?w.offsetTop:0,C=L?L.offsetTop:0,S=x?x.offsetTop:0});var k,B=!1;window.addEventListener("scroll",function(){B||(B=!0,requestAnimationFrame(function(){var e=window.pageYOffset,t=window.innerWidth>768;if(s&&t&&(s.style.transform="translate3d(0,"+.15*e+"px,0)"),t){var n=window.innerHeight;if(w&&e>I-n&&e<I+w.offsetHeight){var a=.03*(e-I+n);w.style.setProperty("--section-parallax",a+"px")}b&&e>C-n&&e<C+800&&(b.style.transform="translate3d(0,"+.02*(e-C+n)+"px,0)"),E&&e>S-n&&e<S+600&&(E.style.transform="translate3d(0,"+.015*(e-S+n)+"px,0)")}if(m&&e<300?m.style.opacity=Math.max(0,1-e/300):m&&"0"!==m.style.opacity&&(m.style.opacity=0),d&&t&&(d.style.transform=e>u&&e>100?"translate3d(0,-100%,0)":"translate3d(0,0,0)"),u=e,o){var r=e>400,i=o.classList.contains("visible");r&&!i?o.classList.add("visible"):!r&&i&&o.classList.remove("visible")}if(f){var c=document.documentElement.scrollHeight-document.documentElement.clientHeight,v=c>0?e/c:0;f.style.strokeDashoffset=y*(1-v)}if(p){var L=e>g,x=p.classList.contains("visible");L&&!x?p.classList.add("visible"):!L&&x&&p.classList.remove("visible")}for(var k="",M=0;M<h.length;M++)e>=h[M].top-150&&(k=h[M].id);t&&l.forEach(function(e){e.classList.remove("active"),e.getAttribute("href")==="#"+k&&e.classList.add("active")});var A=k&&"home"!==k?"#"+k:"";window.location.hash!==A&&(A||window.location.hash)&&history.replaceState(null,"",A||window.location.pathname),B=!1}))},{passive:!0}),function(){document.querySelectorAll(".about-text, .special-card, .menu-category, .gallery-item, .review-card, .faq-item, .info-block, .contact-form-section, .stat-item, .chef-content, .trust-badge").forEach(e=>{e.classList.add("reveal");const t=(e.parentElement?Array.from(e.parentElement.children).filter(t=>t.classList.contains(e.classList[0])):[]).indexOf(e);if(t>0){var n=.07*t+.04*Math.sin(t*Math.PI/4);e.style.transitionDelay=Math.max(0,n).toFixed(3)+"s"}}),document.querySelectorAll(".menu-item-card").forEach(e=>{e.classList.add("reveal");const t=(e.parentElement?Array.from(e.parentElement.children):[]).indexOf(e);var n=Math.floor(t/2),a=t%2;e.style.transitionDelay=(.12*n+.06*a).toFixed(3)+"s"}),document.querySelectorAll(".about, .specials, .menu, .gallery, .reviews, .contact, .faq").forEach(e=>{e.classList.add("section-reveal")});const e=document.querySelector(".chef-image"),t=document.querySelector("#chef-info");e&&e.classList.add("reveal-left"),t&&t.classList.add("reveal-right"),document.querySelectorAll(".stat-item").forEach(e=>{e.classList.remove("reveal"),e.classList.add("reveal-scale")});const n=document.querySelectorAll(".reveal, .reveal-left, .reveal-right, .reveal-scale, .section-reveal"),a=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.target&&e.target.classList&&e.target.classList.add("visible")})},{threshold:.01,rootMargin:"0px 0px -30px 0px"});n.forEach(e=>a.observe(e))}(),function(){var e=document.querySelectorAll("#chef-slideshow .chef-slide"),t=document.querySelectorAll(".chef-info-slide");if(!(e.length<=1)){var n=0,a=Math.min(e.length,t.length);setInterval(function(){!function(n){for(var o=0;o<a;o++)e[o].classList.remove("active"),t[o].classList.remove("active");e[n].classList.add("active"),t[n].classList.add("active")}(n=(n+1)%a)},5e3)}}(),function(){const e=document.getElementById("category-carousel"),t=document.getElementById("cat-arrow-left"),n=document.getElementById("cat-arrow-right");function a(){t.disabled=e.scrollLeft<=5,n.disabled=e.scrollLeft>=e.scrollWidth-e.clientWidth-5}e&&t&&n&&(t.addEventListener("click",()=>{e.scrollBy({left:-250,behavior:"smooth"})}),n.addEventListener("click",()=>{e.scrollBy({left:250,behavior:"smooth"})}),e.addEventListener("scroll",a,{passive:!0}),a(),e.addEventListener("click",function(e){var t=e.target.closest(".category-item");if(t){e.preventDefault();var n=t.getAttribute("href"),a=n?document.querySelector(n):null;if(a){var o=a.getBoundingClientRect().top+window.pageYOffset-100;window.scrollTo({top:o,behavior:"smooth"})}}}))}(),(k=document.getElementById("menu-search"))&&k.addEventListener("input",function(e){var t=e.target.value.toLowerCase();document.querySelectorAll(".menu-item-card").forEach(function(e){var n=e.querySelector("h4"),a=e.querySelector(".item-description"),o=n?n.textContent.toLowerCase():"",r=a?a.textContent.toLowerCase():"";e.style.display=o.includes(t)||r.includes(t)?"":"none"})}),document.querySelectorAll(".filter-btn").forEach(e=>{e.addEventListener("click",()=>{document.querySelectorAll(".filter-btn").forEach(e=>e.classList.remove("active")),e.classList.add("active");const t=e.dataset.filter;document.querySelectorAll(".menu-item-card").forEach(e=>{const n=e.querySelector(".veg-badge"),a=e.querySelector(".nonveg-badge");"all"===t?e.style.display="":"veg"===t?e.style.display=n?"":"none":"non-veg"===t&&(e.style.display=a?"":"none")})})});var M,A,q,T,P,N,O,_=document.getElementById("contact-form");if(_&&_.addEventListener("submit",e=>{e.preventDefault(),"function"==typeof window.showAuthToast&&window.showAuthToast("Thank you for your message! We will get back to you shortly."),e.target.reset()}),function(){const e=document.getElementById("food-particles");if(!e)return;const t=["🍛","🍚","🌶️","🍗","🥘","🫓","☕","🍲"];for(let n=0;n<12;n++){const n=document.createElement("span");n.className="food-particle",n.textContent=t[Math.floor(Math.random()*t.length)],n.style.left=100*Math.random()+"%",n.style.animationDuration=15+20*Math.random()+"s",n.style.animationDelay=15*Math.random()+"s",n.style.fontSize=1+1.5*Math.random()+"rem",e.appendChild(n)}}(),function(){let e;var t=document.getElementById("pwa-prompt"),n=document.getElementById("pwa-install-btn"),a=document.getElementById("pwa-dismiss-btn");function o(){t&&(t.style.opacity="0",t.style.transform="translateX(-50%) translateY(30px)",setTimeout(function(){t.style.display="none"},400))}window.addEventListener("beforeinstallprompt",function(n){n.preventDefault(),e=n,t&&(t.style.display="flex")}),n&&n.addEventListener("click",function(){e&&(e.prompt(),e.userChoice.then(function(){e=null,o()}))}),a&&a.addEventListener("click",o)}(),window.innerWidth<=768||document.querySelectorAll(".cta-button, .add-to-cart").forEach(e=>{e.addEventListener("mousemove",t=>{const n=e.getBoundingClientRect(),a=t.clientX-n.left-n.width/2,o=t.clientY-n.top-n.height/2;e.style.transform="translate(".concat(.15*a,"px, ").concat(.15*o,"px)")}),e.addEventListener("mouseleave",()=>{e.style.transform=""})}),function(){function e(e){e.complete&&e.naturalHeight>0?e.classList.add("loaded"):e.addEventListener("load",()=>e.classList.add("loaded"))}document.querySelectorAll('img[loading="lazy"]').forEach(e);var t=[document.getElementById("dynamic-menu-container"),document.querySelector(".specials"),document.querySelector(".gallery")].filter(Boolean);if(t.length){const n=new MutationObserver(t=>{t.forEach(t=>{t.addedNodes.forEach(t=>{1===t.nodeType&&("IMG"===t.tagName&&"lazy"===t.loading&&e(t),(t.querySelectorAll?t.querySelectorAll('img[loading="lazy"]'):[]).forEach(e))})})});t.forEach(function(e){n.observe(e,{childList:!0,subtree:!0})})}}(),function(){if(window.innerWidth<=768)return;document.querySelectorAll(".menu-item-card").forEach(function(e){var t=null;e.addEventListener("mouseenter",function(){t=e.getBoundingClientRect()}),e.addEventListener("mousemove",function(n){if(!t)return;const a=n.clientX-t.left,o=n.clientY-t.top,r=t.width/2,i=t.height/2,s=(o-i)/i*-4,c=(a-r)/r*4;e.style.transform="perspective(1200px) rotateX("+.5*s+"deg) rotateY("+.5*c+"deg) translateY(-2px)"}),e.addEventListener("mouseleave",function(){t=null,e.style.transition="transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1)",e.style.transform="perspective(1200px) rotateX(0) rotateY(0) translateY(0)",setTimeout(function(){e.style.transition=""},500)})})}(),function(){if(!(window.innerWidth<=768)){var e=document.getElementById("cursor-glow");if(e){var t=0,n=0,a=0,o=0,r=!1;document.addEventListener("mousemove",function(a){t=a.clientX,n=a.clientY,r||(r=!0,e.classList.add("active"))}),document.addEventListener("mouseleave",function(){r=!1,e.classList.remove("active")}),e.style.left="0",e.style.top="0",e.style.willChange="transform",function r(){a+=.12*(t-a),o+=.12*(n-o),e.style.transform="translate3d("+a+"px,"+o+"px,0)",requestAnimationFrame(r)}()}}}(),function(){var e=document.querySelectorAll(".svg-ornament");if(0!==e.length){var t=new IntersectionObserver(function(e){e.forEach(function(e){e.isIntersecting&&e.target.classList.add("visible")})},{threshold:.5});e.forEach(function(e){t.observe(e)})}}(),function(){if(!(window.innerWidth<=768)){var e=document.getElementById("menu-preview-img");if(e){var t={starters:"pics/Gemini_Generated_Image_wnzsqxwnzsqxwnzs.png",curries:"pics/Gemini_Generated_Image_tu348stu348stu34.png",biryanis:"pics/Gemini_Generated_Image_h1vezgh1vezgh1ve.png",kebabs:"pics/Gemini_Generated_Image_5jdcgq5jdcgq5jdc.png",noodles:"pics/Gemini_Generated_Image_1ojbou1ojbou1ojb.png",friedrice:"pics/Gemini_Generated_Image_bfgo8abfgo8abfgo.png",rotis:"pics/Gemini_Generated_Image_6lqqu6lqqu6lqqu6.png"};document.querySelectorAll(".menu-item-card").forEach(function(n){n.addEventListener("mouseenter",function(){var a=n.dataset.imageUrl;if(a)e.src=a,e.style.display="",e.classList.add("active");else{var o=function(e){var t=e.closest(".menu-category");if(!t)return null;var n=t.id||"";return-1!==n.indexOf("starters")?"starters":-1!==n.indexOf("curries")?"curries":-1!==n.indexOf("biryanis")?"biryanis":-1!==n.indexOf("kebabs")?"kebabs":-1!==n.indexOf("noodles")?"noodles":-1!==n.indexOf("friedrice")?"friedrice":-1!==n.indexOf("rotis")?"rotis":null}(n);o&&t[o]&&(e.src=t[o],e.style.display="",e.classList.add("active"))}}),n.addEventListener("mousemove",function(t){e.style.left=t.clientX+20+"px",e.style.top=t.clientY-90+"px"}),n.addEventListener("mouseleave",function(){e.classList.remove("active"),e.style.display="none"})})}}}(),window.innerWidth<=768||document.querySelectorAll(".chef-slide, .gallery-slide-item img, .gallery-item img").forEach(function(e){e.classList.add("magnetic-image");var t=null;e.addEventListener("mouseenter",function(){t=e.getBoundingClientRect()}),e.addEventListener("mousemove",function(n){if(t){var a=n.clientX-t.left-t.width/2,o=n.clientY-t.top-t.height/2;e.style.transform="translate3d("+.015*a+"px,"+.015*o+"px,0) scale(1.01)"}}),e.addEventListener("mouseleave",function(){t=null,e.style.transform=""})}),window.innerWidth<=768||document.querySelectorAll(".menu-item-card, .about-text").forEach(function(e){var t=document.createElement("div");t.className="card-reflection",e.appendChild(t);var n=null;e.addEventListener("mouseenter",function(){n=e.getBoundingClientRect()}),e.addEventListener("mousemove",function(e){n&&(t.style.setProperty("--ref-x",e.clientX-n.left+"px"),t.style.setProperty("--ref-y",e.clientY-n.top+"px"))}),e.addEventListener("mouseleave",function(){n=null})}),function(){var e=document.querySelectorAll(".section-wipe");if(0!==e.length){var t=new IntersectionObserver(function(e){e.forEach(function(e){e.isIntersecting&&!e.target.classList.contains("wipe-active")&&e.target.classList.add("wipe-active")})},{threshold:.15});e.forEach(function(e){t.observe(e)})}}(),document.addEventListener("click",function(e){var t=e.target;if(t&&"function"==typeof t.closest){var n=t.closest(".add-to-cart, .cta-button, .btn-primary, .pay-now-btn, .combo-add-btn");if(n){var a=document.createElement("span");a.className="btn-ripple";var o=n.getBoundingClientRect(),r=2*Math.max(o.width,o.height);a.style.width=a.style.height=r+"px",a.style.left=e.clientX-o.left-r/2+"px",a.style.top=e.clientY-o.top-r/2+"px",n.appendChild(a),setTimeout(function(){a.remove()},700)}}}),window.innerWidth<=768||document.addEventListener("click",function(e){var t=e.target;if(t){var n=!(!t.classList||"function"!=typeof t.classList.contains||!t.classList.contains("add-to-cart")),a="function"==typeof t.closest&&!!t.closest(".add-to-cart");(n||a)&&function(e,t){for(var n=0;n<10;n++){var a=document.createElement("span");a.className="gold-particle";var o=n/10*Math.PI*2,r=40+30*Math.random(),i=Math.cos(o)*r,s=Math.sin(o)*r;a.style.left=e+"px",a.style.top=t+"px",a.style.setProperty("--tx",i+"px"),a.style.setProperty("--ty",s+"px"),a.style.animationDelay=.1*Math.random()+"s",document.body.appendChild(a),a.addEventListener("animationend",function(){this.remove()})}}(e.clientX,e.clientY)}}),M={Mild:"Subtle warmth, family-friendly",Medium:"Balanced heat, our recommendation",Spicy:"Andhra-level heat, for the brave!"},document.querySelectorAll(".spice-level").forEach(function(e){var t=e.textContent.trim();M[t]&&(e.setAttribute("data-tooltip",M[t]),e.classList.add("has-tooltip"))}),function(){function e(e,t){if(e){var n=0,a=0,o=!1;e.addEventListener("touchstart",function(e){n=e.touches[0].clientX,a=e.touches[0].clientY,o=!0},{passive:!0}),e.addEventListener("touchmove",function(e){if(o){var t=e.touches[0].clientX-n,r=e.touches[0].clientY-a;Math.abs(t)>Math.abs(r)&&Math.abs(t)>10&&e.preventDefault()}},{passive:!1}),e.addEventListener("touchend",function(e){if(o){o=!1;var a=e.changedTouches[0].clientX-n;Math.abs(a)>50&&t(a<0?1:-1)}},{passive:!0})}}e(document.querySelector(".gallery-slideshow-wrapper"),function(e){"function"==typeof window.moveGallerySlide&&window.moveGallerySlide(e)}),e(document.querySelector(".reviews-carousel-wrapper"),function(e){"function"==typeof window.moveCarousel&&window.moveCarousel(e)})}(),function(){var e=document.getElementById("menu-search");if(e){var t=document.createElement("div");t.id="search-autocomplete",t.className="search-autocomplete-dropdown",e.parentElement.classList.add("search-autocomplete-wrap"),e.parentElement.appendChild(t);var n,a,o=[];document.querySelectorAll(".menu-item-card").forEach(function(e){var t=e.querySelector("h4"),n=e.querySelector(".item-description"),a=e.querySelector(".price"),r=!!e.querySelector(".veg-badge"),i=e.closest(".menu-category"),s=i?i.querySelector(".category-title"):null,c=s?s.textContent:"";o.push({name:t?t.textContent.replace(/Bestseller|Popular|Chef's Pick|Must Try/g,"").trim():"",desc:n?n.textContent:"",price:a?a.textContent:"",isVeg:r,category:c,card:e})}),e.addEventListener("input",function(){clearTimeout(n),n=setTimeout(function(){var n=e.value.toLowerCase().trim();if(document.querySelectorAll(".menu-item-card").forEach(function(e){var t=e.querySelector("h4"),a=e.querySelector(".item-description"),o=t?t.textContent.toLowerCase():"",r=a?a.textContent.toLowerCase():"";e.style.display=!n||o.includes(n)||r.includes(n)?"":"none"}),n.length<2)return t.classList.remove("visible"),void(t.innerHTML="");var a=o.filter(function(e){return e.name.toLowerCase().includes(n)||e.desc.toLowerCase().includes(n)}).slice(0,6);if(0===a.length)return t.classList.remove("visible"),void(t.innerHTML="");t.innerHTML="",a.forEach(function(e){var n=document.createElement("button");n.className="ac-item",n.dataset.name=e.name;var a=document.createElement("div");a.className="ac-info";var o=document.createElement("span");o.className="ac-name",o.textContent=e.name;var r=document.createElement("span");r.className="ac-meta";var i=document.createElement("span");i.className=e.isVeg?"ac-badge veg":"ac-badge non-veg",i.textContent=e.isVeg?"VEG":"NON-VEG";var s=document.createElement("span");s.className="ac-cat",s.textContent=e.category,r.appendChild(i),r.appendChild(document.createTextNode(" ")),r.appendChild(s),a.appendChild(o),a.appendChild(r);var c=document.createElement("span");c.className="ac-price",c.textContent=e.price,n.appendChild(a),n.appendChild(c),t.appendChild(n)}),t.classList.add("visible")},150)}),t.addEventListener("click",function(n){var a=n.target.closest(".ac-item");if(a){var r=a.dataset.name;e.value=r,t.classList.remove("visible");var i=o.find(function(e){return e.name===r});i&&i.card&&(document.querySelectorAll(".menu-item-card").forEach(function(e){e.style.display=""}),i.card.scrollIntoView({behavior:"smooth",block:"center"}),i.card.classList.add("search-highlight"),setTimeout(function(){i.card.classList.remove("search-highlight")},2e3))}}),document.addEventListener("click",function(e){e.target&&"function"==typeof e.target.closest&&e.target.closest(".search-autocomplete-wrap")||t.classList.remove("visible")}),e.addEventListener("keydown",function(n){if("Escape"===n.key)return t.classList.remove("visible"),void e.blur();if("ArrowDown"===n.key||"ArrowUp"===n.key){var a=t.querySelectorAll(".ac-item");if(0===a.length)return;n.preventDefault();var o=t.querySelector(".ac-item.focused"),r=o?Array.from(a).indexOf(o):-1;return o&&o.classList.remove("focused"),a[r="ArrowDown"===n.key?(r+1)%a.length:r<=0?a.length-1:r-1].classList.add("focused"),void a[r].scrollIntoView({block:"nearest"})}if("Enter"===n.key){var i=t.querySelector(".ac-item.focused");i&&(n.preventDefault(),i.click())}}),e.addEventListener("input",function(){clearTimeout(a);var t=e.value.trim();t.length<4?r():a=setTimeout(async function(){try{var n=document.getElementById("ai-search-badge");n||((n=document.createElement("span")).id="ai-search-badge",n.className="ai-search-badge",e.parentElement.appendChild(n)),n.textContent="AI searching...",n.style.display="inline-block";var a=await fetch("/api/smart-search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t})}),o=await a.json();n.textContent="AI: "+(o.interpretation||"results"),o.results&&o.results.length>0&&(document.querySelectorAll(".menu-item-card").forEach(function(e){e.classList.remove("ai-highlighted")}),o.results.forEach(function(e){var t=document.querySelector('.menu-item-card[data-id="'+e.name+'"]');t&&(t.style.display="",t.classList.add("ai-highlighted"))}))}catch(i){r()}},800)})}function r(){var e=document.getElementById("ai-search-badge");e&&(e.style.display="none"),document.querySelectorAll(".menu-item-card.ai-highlighted").forEach(function(e){e.classList.remove("ai-highlighted")})}}(),document.querySelectorAll('img[loading="lazy"]').forEach(function(e){e.complete?e.classList.add("loaded"):(e.addEventListener("load",function(){e.classList.add("loaded")}),e.addEventListener("error",function(){e.classList.add("loaded")}))}),new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){1===e.nodeType&&(e.querySelectorAll?e.querySelectorAll('img[loading="lazy"]'):[]).forEach(function(e){e.complete?e.classList.add("loaded"):e.addEventListener("load",function(){e.classList.add("loaded")})})})})}).observe(document.body,{childList:!0,subtree:!0}),window.location.hash){var D=window.location.hash.split("?")[0],R=D.length>1?document.querySelector(D):null;R&&setTimeout(function(){R.scrollIntoView({behavior:"smooth",block:"start"})},2e3)}function H(e){var t=document.getElementById("aria-live-region");t&&(t.textContent="",setTimeout(function(){t.textContent=e},100))}navigator.vibrate&&document.addEventListener("click",function(e){var t=e.target;t&&"function"==typeof t.closest&&t.closest(".add-to-cart, .cta-button, .btn-primary, .filter-btn")&&navigator.vibrate(8)}),document.addEventListener("keydown",function(e){if("Escape"===e.key){var t=document.querySelector('.modal[style*="flex"], .modal[style*="block"]');if(t){var n=t.querySelector(".close");n&&n.click()}}if("/"===e.key&&!e.ctrlKey&&!e.metaKey){var a=document.activeElement;if(a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"SELECT"===a.tagName))return;var o=document.getElementById("menu-search");o&&(e.preventDefault(),o.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){o.focus()},300))}}),function(){var e=document.getElementById("dynamic-menu-container");if(e&&!(e.children.length>0)){for(var t="",n=0;n<6;n++)t+='<div class="skeleton" style="height:120px;margin-bottom:1rem;border-radius:var(--radius-md)"></div>';e.innerHTML='<div style="padding:1rem">'+t+"</div>";var a=new MutationObserver(function(t){t.forEach(function(t){if(t.addedNodes.length>0){var n=e.querySelector(".skeleton");n&&n.parentElement.remove(),a.disconnect()}})});a.observe(e,{childList:!0})}}(),function(){var e=document.getElementById("cookie-consent"),t=document.getElementById("cookie-accept"),o=document.getElementById("cookie-decline");if(e){if(window.Capacitor&&"function"==typeof window.Capacitor.isNativePlatform&&window.Capacitor.isNativePlatform())return e.style.display="none",void e.setAttribute("aria-hidden","true");n("amogha-cookie-consent")||(e.style.pointerEvents="none",setTimeout(function(){e.style.animation="none",e.style.transition="none",e.style.opacity="0",e.style.transform="translateY(30px)",e.style.display="",setTimeout(function(){e.style.transition="opacity .5s ease, transform .5s ease",e.style.opacity="1",e.style.transform="translateY(0)",e.style.pointerEvents=""},50)},2500),t&&t.addEventListener("click",function(){r("accepted")}),o&&o.addEventListener("click",function(){r("essential")}))}function r(t){a("amogha-cookie-consent",t),e.style.pointerEvents="none",e.style.opacity="0",e.style.transform="translateY(20px)",setTimeout(function(){e.style.display="none"},400)}}(),A=document.getElementById("newsletter-form"),q=document.getElementById("newsletter-email"),T=document.getElementById("newsletter-msg"),A&&q&&A.addEventListener("submit",function(e){e.preventDefault();var t=q.value.trim();if(t&&t.includes("@")){var o=JSON.parse(n("amogha-newsletter")||"[]");o.includes(t)?T&&(T.textContent="You're already subscribed!"):(o.push(t),a("amogha-newsletter",JSON.stringify(o)),q.value="",T&&(T.textContent="Welcome! You'll receive our best offers."),"function"==typeof window.showAuthToast&&window.showAuthToast("Subscribed successfully! Watch for delicious updates."),setTimeout(function(){T&&(T.textContent="")},5e3))}}),(P=document.getElementById("scroll-progress"))&&window.addEventListener("scroll",function(){var e=document.documentElement.scrollHeight-document.documentElement.clientHeight,t=e>0?window.pageYOffset/e*100:0;P.style.width=t+"%"},{passive:!0}),function(){var e=document.getElementById("offline-banner");function t(){navigator.onLine?(e.style.display="none",H("You are back online.")):(e.style.display="",H("You appear to be offline. Some features may be limited."))}e&&(window.addEventListener("online",t),window.addEventListener("offline",t),navigator.onLine||(e.style.display=""))}(),window._ariaAnnounce=H,function(){var e=document.getElementById("dynamic-menu-container");if(e){var t=new MutationObserver(function(n){var a=e.querySelectorAll(".menu-item-card");if(0!==a.length){t.disconnect();for(var o=[],r=a.length,i=Math.min(5,Math.floor(r/3));o.length<i;){var s=Math.floor(Math.random()*r);-1===o.indexOf(s)&&o.push(s)}o.forEach(function(e){var t=a[e];if(!t.querySelector(".social-proof-badge")){var n=15+Math.floor(35*Math.random()),o=document.createElement("div");o.className="social-proof-badge",o.innerHTML='<span class="proof-dot"></span>'+n+" ordered today";var r=t.querySelector(".price")||t.querySelector(".item-price");r&&r.parentElement&&r.parentElement.insertBefore(o,r.nextSibling)}})}});t.observe(e,{childList:!0,subtree:!0})}}(),document.addEventListener("keydown",function(e){if("Tab"===e.key){var t=document.querySelector('.modal[style*="flex"], .modal[style*="block"]');if(t){var n=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0!==n.length){var a=n[0],o=n[n.length-1];e.shiftKey?document.activeElement===a&&(e.preventDefault(),o.focus()):document.activeElement===o&&(e.preventDefault(),a.focus())}}}}),window.addEventListener("error",function(e){console.error("[Amogha Error]",e.message,e.filename,e.lineno)}),window.addEventListener("unhandledrejection",function(e){e.reason&&"AbortError"===e.reason.name?e.preventDefault():(console.error("[Amogha Unhandled Promise]",e.reason),e.reason&&"permission-denied"===e.reason.code&&e.preventDefault())}),(N=document.createElement("div")).className="toast-stack",N.setAttribute("aria-live","polite"),document.body.appendChild(N),window._showToast=function(e,t,n){t=t||"",n=n||3500;var a=document.createElement("div");a.className="toast-item"+(t?" "+t:""),a.textContent=e,N.appendChild(a),setTimeout(function(){a.style.opacity="0",a.style.transform="translateX(30px)",a.style.transition="opacity 0.3s, transform 0.3s",setTimeout(function(){a.remove()},300)},n)},(O=document.getElementById("payment-processing"))&&(window._showPaymentProcessing=function(){O.classList.add("active"),window._ariaAnnounce&&window._ariaAnnounce("Processing your payment, please wait")},window._hidePaymentProcessing=function(){O.classList.remove("active")})}(),function(){var e=document.querySelectorAll("#hero-slideshow .hero-slide"),t=document.getElementById("hero-sparkles"),n=0,a=window.innerWidth<=768;!function(){if(t){t.innerHTML="";for(var e=a?5:12,n=a?3:6,o=a?4:10,r=a?2:4,i=0;i<r;i++){var s=document.createElement("span");s.className="sp-glow";var c=200+250*Math.random(),l=10+i/r*70+15*Math.random(),d=20+50*Math.random(),u=10+8*Math.random(),m=3*i+2*Math.random();s.style.cssText="left:"+l+"%;top:"+d+"%;width:"+c+"px;height:"+c+"px;--glow-dur:"+u+"s;--glow-delay:"+m+"s;",t.appendChild(s)}for(var f=0;f<e;f++){var p=document.createElement("span"),v=["","thin","accent","thin",""],y=v[f%v.length];p.className="sp-line"+(y?" "+y:"");var g=140+180*Math.random(),h=3+f/e*90+6*Math.random(),w=12+10*Math.random(),b=f/e*w,E=7+6*Math.random(),I=2.5+2*Math.random();p.style.cssText="left:"+h+"%;height:"+g+"px;--line-dur:"+w+"s;--line-delay:"+b+"s;--sway-dur:"+E+"s;--shimmer-dur:"+I+"s;",t.appendChild(p)}for(var L=0;L<n;L++){var C=document.createElement("span");C.className="sp-dot";var x=4+5*Math.random(),S=8+84*Math.random(),k=18+12*Math.random(),B=3.5*L+4*Math.random();C.style.cssText="left:"+S+"%;width:"+x+"px;height:"+x+"px;--dot-dur:"+k+"s;--dot-delay:"+B+"s;",t.appendChild(C)}for(var M=0;M<o;M++){var A=document.createElement("span");A.className="sp-mote";var q=2+3*Math.random(),T=5+90*Math.random(),P=18+14*Math.random(),N=2.5*M+3*Math.random(),O=1.5+2*Math.random();A.style.cssText="left:"+T+"%;width:"+q+"px;height:"+q+"px;--mote-dur:"+P+"s;--mote-delay:"+N+"s;--twinkle-dur:"+O+"s;",t.appendChild(A)}}}();var o=["kb-zoom-left","kb-zoom-right","kb-pan-down","kb-zoom-center"],r=null;if(r&&clearInterval(r),e=document.querySelectorAll("#hero-slideshow .hero-slide"),n=0,e.length>1&&(r=setInterval(function(){e[n].classList.remove("active"),n=(n+1)%e.length;for(var t=0;t<o.length;t++)e[n].classList.remove(o[t]);e[n].classList.add(o[Math.floor(Math.random()*o.length)]),e[n].classList.add("active")},5e3)),window.updateHeroSlides=function(t){var a=document.getElementById("hero-slideshow");if(a&&0!==t.length){r&&clearInterval(r);for(var i=a.querySelectorAll(".hero-slide"),s=0;s<i.length;s++)i[s].remove();t.forEach(function(e,t){var n=document.createElement("div");if(n.className="hero-slide"+(0===t?" active":""),0===t&&n.classList.add(o[Math.floor(Math.random()*o.length)]),n.setAttribute("role","img"),n.setAttribute("aria-label",e.alt||e.name||"Hero slide "+(t+1)),"video"===e.type){n.classList.add("hero-slide-video");var r=document.createElement("video");r.src=e.url,r.autoplay=!0,r.muted=!0,r.loop=!0,r.playsInline=!0,r.setAttribute("playsinline",""),r.setAttribute("webkit-playsinline",""),n.appendChild(r)}else{var i=e.url;i&&-1!==i.indexOf("res.cloudinary.com")&&-1!==i.indexOf("/upload/")&&(i=i.replace("/upload/","/upload/f_auto,q_auto,w_1200/")),n.style.backgroundImage="url("+i+")"}a.appendChild(n)});var c=a.querySelector(".hero-slide.active video");c&&(c._playP=c.play(),c._playP&&c._playP.catch(function(){})),e=a.querySelectorAll(".hero-slide"),n=0,e.length>1&&(r=setInterval(function(){e[n].classList.remove("active");var t=e[n].querySelector("video");if(t){var a=function(e){return function(){e.pause()}}(t);t._playP?(t._playP.then(a).catch(function(){}),t._playP=null):a()}n=(n+1)%e.length;for(var r=0;r<o.length;r++)e[n].classList.remove(o[r]);e[n].classList.add(o[Math.floor(Math.random()*o.length)]),e[n].classList.add("active");var i=e[n].querySelector("video");i&&(i.currentTime=0,i._playP=i.play(),i._playP&&i._playP.catch(function(){}))},5e3))}},window.innerWidth>768){const e=document.querySelector(".hero"),t=document.querySelector(".hero-mouse-spotlight");e&&t&&e.addEventListener("mousemove",function(n){const a=e.getBoundingClientRect(),o=n.clientX-a.left,r=n.clientY-a.top;t.style.setProperty("--mouse-x",o+"px"),t.style.setProperty("--mouse-y",r+"px")})}}(),function(){const e=["Authentic Indian Cuisine","Crafted with Passion","A Legacy of Flavour","Where Taste Meets Art","Born from Tradition"],t=["Tradition, Perfection & Soul in Every Dish","Handcrafted Recipes Passed Down Generations","An Unforgettable Culinary Journey Awaits","Every Flavour Tells a Story of Heritage","Experience the Art of Indian Fine Dining"],n=document.querySelector(".hero-tagline .hero-text-inner"),a=document.querySelector(".hero-subtitle .hero-text-inner");if(!n||!a)return;let o=0;function r(){o=(o+1)%e.length,n.classList.add("fade-out"),a.classList.add("fade-out"),setTimeout(()=>{n.textContent=e[o],a.textContent=t[o],n.classList.remove("fade-out"),a.classList.remove("fade-out")},700)}setTimeout(()=>{window._heroRotateInterval&&clearInterval(window._heroRotateInterval),window._heroRotateInterval=setInterval(r,8e3)},5e3)}(),function(){const e=document.querySelectorAll(".header-slideshow .slide");if(e.length<=1)return;let t=0;window._heroSlideshowInterval&&clearInterval(window._heroSlideshowInterval),window._heroSlideshowInterval=setInterval(()=>{let n;e[t].classList.remove("active");do{n=Math.floor(Math.random()*e.length)}while(n===t&&e.length>1);t=n,e[t].classList.add("active")},3e3)}(),function(){try{var e=A();e&&(F(e),setTimeout(function(){x(e)},1e3)),W()}catch(t){console.error("Auth restore error:",t)}window.addEventListener("click",function(e){var t=document.getElementById("auth-modal");e.target===t&&T();var n=document.getElementById("user-dropdown");n&&n.classList.contains("show")&&!e.target.closest(".signin-nav-btn")&&n.classList.remove("show")}),setTimeout(function(){["signup-password","signin-password","forgot-new-password","forgot-confirm-password"].forEach(z)},500),document.addEventListener("keydown",function(e){if("Enter"===e.key){var t=document.getElementById("auth-modal");if(t&&"none"!==t.style.display){var n=t.querySelector(".auth-view.active");if(n){var a=n.id;if("INPUT"===e.target.tagName)if(e.preventDefault(),"auth-signup"===a)O();else if("auth-signin"===a)_();else if("auth-forgot"===a){var o=document.getElementById("forgot-step-2");o&&"none"!==o.style.display?H():R()}}}}}),setTimeout(function(){var e=document.getElementById("signup-form");if(e&&"true"!==e.dataset.refEnhanced){e.dataset.refEnhanced="true";var t=e.querySelector(".password-field");if(t){var n=document.createElement("input");n.type="text",n.id="signup-referral",n.placeholder="Referral Code (Optional)",n.setAttribute("aria-label","Referral code"),n.maxLength=20,n.style.textTransform="uppercase",t.after(n)}}},1e3),setTimeout(function(){var e=document.getElementById("signin-btn");if(e&&!document.getElementById("user-dropdown")){var t=document.createElement("div");t.id="user-dropdown",t.className="user-dropdown",t.innerHTML='<button onclick="openMyOrders(); closeUserDropdown();">My Orders</button><button onclick="openReferralModal(); closeUserDropdown();">Refer a Friend</button><button onclick="openLoyaltyModal(); closeUserDropdown();">Loyalty Points</button><button onclick="openAuthModal(); closeUserDropdown();">Sign Out</button>',e.parentElement.style.position="relative",e.parentElement.appendChild(t),e.addEventListener("click",function(e){A()&&(e.preventDefault(),e.stopPropagation(),t.classList.toggle("visible"))}),document.addEventListener("click",function(n){e.parentElement.contains(n.target)||t.classList.remove("visible")})}},1e3)}(),function(){try{const t=n("amoghaCart");if(t){var e=JSON.parse(t);V.length=0,e.forEach(function(e){V.push(e)}),$()}}catch(t){console.error("Failed to load cart from storage:",t),V.length=0}}(),V.forEach(e=>ne(e.name)),re(),function(){var e=document.getElementById("cart-icon"),t=document.getElementById("cart-modal");if(e&&e.addEventListener("click",e=>{e.preventDefault(),ie(),t&&(t.style.display="block"),i()}),t){var n=t.querySelector(".close");n&&n.addEventListener("click",function(){t.style.display="none",r()})}var a=document.getElementById("reservation-modal");if(a){var o=a.querySelector(".close");o&&o.addEventListener("click",function(){a.style.display="none",r()})}window.addEventListener("click",e=>{e.target===t&&(t.style.display="none",r()),e.target===document.getElementById("reservation-modal")&&(document.getElementById("reservation-modal").style.display="none",r())}),document.addEventListener("click",e=>{if(e.target.classList.contains("qty-plus")){const t=e.target.dataset.item,n=e.target.closest(".add-to-cart");return void Q(t,n.dataset.price,n)}if(e.target.classList.contains("qty-minus")){const t=e.target.dataset.item,n=V.find(e=>e.name===t);return void(n&&(n.quantity--,n.quantity<=0&&V.splice(V.indexOf(n),1),$(),K(),ne(t),ae(),oe()))}var t,n,a;e.target.classList.contains("add-to-cart")&&!e.target.classList.contains("has-qty")&&(Q(e.target.dataset.item,e.target.dataset.price,e.target),n=(t=e.target).closest(".add-to-cart")||t,(a=document.createElement("span")).className="atc-checkmark",a.textContent="✓",n.appendChild(a),setTimeout(function(){a.remove()},800))});var s=document.getElementById("clear-cart");s&&s.addEventListener("click",se);var c=document.getElementById("checkout");c&&c.addEventListener("click",function(){"function"==typeof window.checkout&&window.checkout()})}(),function(){var e=w();if(e){var t=document.getElementById("dynamic-menu-container");if(t){var n='<div class="menu-category"><h3 class="category-title"><div class="skeleton-line w-60" style="height:1.2rem;border-radius:6px;background:#2a2a3a;width:160px;margin-bottom:1rem"></div></h3><div class="menu-items">'+Array(4).fill('<div class="menu-skeleton-card"><div class="skeleton-line h-img"></div><div class="skeleton-line w-60"></div><div class="skeleton-line w-100"></div><div class="skeleton-btn"></div></div>').join("")+"</div></div>";t.innerHTML=n+n}Se("menu","menu_cache",300,function(e){var t={};return e.forEach(function(e){t[e.id]=e.data()}),t},function(e){!function(e){var t={};Object.keys(e).forEach(function(n){var a=e[n],o=(a.category||"Others").trim()||"Others";t[o]||(t[o]=[]),t[o].push(Object.assign({name:n},a))});var n=Object.keys(t).sort(function(e,t){var n=Be.indexOf(e),a=Be.indexOf(t);return-1===n&&-1===a?e.localeCompare(t):-1===n?1:-1===a?-1:n-a});n.forEach(function(e){t[e].sort(function(e,t){var n=(e.sortOrder||999)-(t.sortOrder||999);return 0!==n?n:(e.name||"").localeCompare(t.name||"")})});var a=document.getElementById("dynamic-menu-container");if(a){var o=document.createElement("div");o.innerHTML=n.map(function(e){return'<div class="menu-category" id="cat-'+Te(e)+'"><h3 class="category-title">'+qe(e)+'</h3><div class="menu-items">'+t[e].map(Pe).join("")+"</div></div>"}).join("");for(var r=document.createDocumentFragment();o.firstChild;)r.appendChild(o.firstChild);a.innerHTML="",a.appendChild(r)}var i=document.getElementById("category-carousel");i&&(i.innerHTML=n.map(function(e){var t=Te(e),n=Ae[e],a=Me[e]||"🍽️",o=n?'<div class="category-img-wrap"><img src="'+qe(n)+'" alt="'+qe(e)+'" loading="lazy"></div>':'<div class="category-img-wrap" style="display:flex;align-items:center;justify-content:center;font-size:2rem;background:rgba(212,160,23,.08)">'+a+"</div>";return'<a href="#cat-'+t+'" class="category-item" data-category="'+qe(e)+'">'+o+'<span class="category-name">'+qe(e)+"</span></a>"}).join("")),document.querySelectorAll(".menu-item-card").forEach(function(e){var t=e.querySelector(".menu-badge"),n=e.querySelector("h4"),a=t||n;if(a){var o=(t?t.textContent:"")+a.closest(".menu-item-card").dataset.id;if(/chef|spicy|hot|bestseller/i.test(o)&&!e.querySelector(".flame-badge")){var r=document.createElement("span");r.className="flame-badge",r.textContent="🔥",r.title="Popular pick!",t?t.after(r):n&&n.appendChild(r)}}}),window._safeForMeActive&&Ne()}(e)}),Se("specials","specials_cache",300,function(e){var t=[];return e.forEach(function(e){var n=e.data();n.id=e.id,t.push(n)}),t},ke,{orderBy:["sortOrder"]}),Se("heroSlides","heroSlides_cache",300,function(e){var t=[];return e.forEach(function(e){var n=e.data();n.active&&t.push(n)}),t},function(e){0!==e.length&&"function"==typeof window.updateHeroSlides&&window.updateHeroSlides(e)},{orderBy:["sortOrder"]});var a=!1;try{var o=localStorage.getItem("theme_cache");if(o){var r=JSON.parse(o);r.ts&&Date.now()-r.ts<6e5&&r.theme&&("default"!==r.theme&&document.body.classList.add("theme-"+r.theme),a=!0)}}catch(c){}a||e.collection("settings").doc("global").get().then(function(e){var t=e.exists&&e.data().activeTheme?e.data().activeTheme:"default";"default"!==t&&document.body.classList.add("theme-"+t);try{localStorage.setItem("theme_cache",JSON.stringify({ts:Date.now(),theme:t}))}catch(c){}}).catch(function(){});var i=document.getElementById("testimonials-grid");i&&Se("testimonials","testimonials_cache",600,function(e){var t=[];return e.forEach(function(e){var n=e.data();n.active&&t.push(n)}),t},function(e){if(0!==e.length)i.innerHTML=e.map(function(e){var t=e.thumbnailUrl||(e.videoUrl?e.videoUrl.replace("/upload/","/upload/f_jpg,so_1/"):"");return'<div class="testimonial-card" onclick="openVideoLightbox(\''+qe(e.videoUrl||"")+'\')"><div class="testimonial-thumb">'+(t?'<img src="'+qe(t)+'" alt="" loading="lazy">':'<div class="testimonial-placeholder">🎬</div>')+'<div class="testimonial-play">▶</div></div><p class="testimonial-name">'+qe(e.customerName||"")+"</p>"+(e.caption?'<p class="testimonial-caption">'+qe(e.caption)+"</p>":"")+"</div>"}).join("");else{var t=i.closest(".testimonials");t&&(t.style.display="none")}},{orderBy:["sortOrder"]});var s=document.getElementById("social-feed-strip");s&&Se("socialPosts","socialPosts_cache",600,function(e){var t=[];return e.forEach(function(e){var n=e.data();n.active&&t.push(n)}),t},function(e){if(0!==e.length)s.innerHTML=e.map(function(e){var t=e.link&&/^https?:\/\//i.test(e.link)?e.link:"",n=t?"</a>":"</div>";return(t?'<a href="'+qe(t)+'" target="_blank" rel="noopener">':"<div>")+'<div class="social-card"><img src="'+qe(e.imageUrl)+'" alt="" loading="lazy">'+(e.caption?'<span class="social-caption">'+qe(e.caption)+"</span>":"")+"</div>"+n}).join("");else{var t=s.closest(".social-feed");t&&(t.style.display="none")}},{orderBy:["sortOrder"]})}}(),(window.requestIdleCallback||function(e){setTimeout(e,100)})(function(){!function(){Y.length=0;try{var e=localStorage.getItem("addons_cache");if(e){var t=JSON.parse(e);if(t.ts&&Date.now()-t.ts<6e5&&t.data)return void Y.push(...t.data)}}catch(a){}var n=w();n&&n.collection("addons").where("active","==",!0).orderBy("sortOrder").get().then(function(e){e.forEach(function(e){Y.push(e.data())});try{localStorage.setItem("addons_cache",JSON.stringify({ts:Date.now(),data:Y}))}catch(a){}}).catch(function(){})}(),setTimeout(I,500),function(){setTimeout(Re,5e3),setTimeout(Fe,8e3);var e=n("amoghaLastOrderId");e&&We(e)}(),function(){var e=document.querySelector(".cta-button.secondary");e&&-1!==e.textContent.indexOf("Reserve")&&(e.onclick=function(){ze()});var t=document.getElementById("reservation-form");t&&t.addEventListener("submit",e=>{if("true"!==e.target.dataset.enhanced){e.preventDefault(),"function"==typeof showAuthToast&&showAuthToast("Reservation request received! We will confirm shortly."),e.target.reset();var t=document.getElementById("reservation-modal");t&&(t.style.display="none")}})}(),ct(),window._personalizeInitDone||(window._personalizeInitDone=!0,function(){var e=document.getElementById("time-greeting");if(e){var t=ht(),n=wt[t];e.innerHTML='<span class="time-greeting-emoji">'+n.emoji+'</span> <span class="time-greeting-text">'+n.text+"</span>",e.classList.add("time-greeting--"+t),requestAnimationFrame(function(){e.classList.add("time-greeting--visible")})}}(),function(){var e=ht(),t=bt[e]||[];if(0!==t.length)var n=0,a=setInterval(function(){n++;var e=document.getElementById("category-carousel");if(e){var o=e.querySelectorAll(".category-item");if(0!==o.length){clearInterval(a);var r=null;if(o.forEach(function(e){var n=e.getAttribute("data-category")||"";t.some(function(e){return-1!==n.toLowerCase().indexOf(e.toLowerCase())})&&(e.classList.add("active"),r||(r=e))}),r&&e.scrollTo){var i=r.offsetLeft-e.offsetLeft-16;e.scrollTo({left:i,behavior:"smooth"})}}else n>=20&&clearInterval(a)}else n>=20&&clearInterval(a)},500)}(),setTimeout(Et,3e3)),h(()=>import("./assets/profile-BaqUOlSv.js"),__vite__mapDeps([0,1])).then(function(e){e.initProfile()}),h(()=>import("./assets/badges-BAp4bqgy.js"),__vite__mapDeps([2,1]))}),Ct(["menu","dynamic-menu-container"],function(){lt(),dt(),ut(),ft(),Lt("./modules/group.js","initGroupOrdering"),Lt("./modules/chatbot.js","initChatbot"),Lt("./modules/splitbill.js"),Lt("./modules/subscriptions.js"),Lt("./modules/enhancements.js","initEnhancements"),Lt("./modules/premium.js","initPremium")},1500),(window.requestIdleCallback||function(e){setTimeout(e,2e3)})(function(){var e=null;try{e=JSON.parse(localStorage.getItem("amoghaUser"))}catch(t){}e&&function(){var e=null;try{e=JSON.parse(localStorage.getItem("amoghaMyOrders"))}catch(t){}if(e&&e.length){var n=e[0].data;if(n&&n.items&&n.items.length){if(n.createdAt&&(Date.now()-new Date(n.createdAt).getTime())/864e5<1)return;var a=n.items.slice(0,2).map(function(e){return e.name}).join(", ");n.items.length>2&&(a+=" +"+(n.items.length-2)+" more");var o=document.createElement("div");o.className="reorder-toast",o.innerHTML='<div class="reorder-toast-text"><div class="reorder-toast-title">Welcome back! 👋</div><div class="reorder-toast-sub">'+a+'</div></div><button class="reorder-toast-btn" id="reorder-toast-btn">Order Again</button><button class="reorder-toast-close" id="reorder-toast-close">×</button>',document.body.appendChild(o),setTimeout(function(){o.classList.add("show")},100);var r=e[0].id;o.querySelector("#reorder-toast-btn").addEventListener("click",function(){"function"==typeof window.reorderFromHistory&&window.reorderFromHistory(r),o.classList.remove("show"),setTimeout(function(){o.remove()},400)}),o.querySelector("#reorder-toast-close").addEventListener("click",function(){o.classList.remove("show"),setTimeout(function(){o.remove()},400)}),setTimeout(function(){o.classList.remove("show"),setTimeout(function(){o.parentNode&&o.remove()},400)},8e3)}}}()}),Ct(["reviews","gallery","menu"],function(){Lt("./modules/challenges.js","initChallenges"),Lt("./modules/spinwheel.js","initSpinWheel"),Lt("./modules/secretmenu.js","initSecretMenu"),Lt("./modules/feedback.js","initFeedback"),Lt("./modules/socialshare.js","initSocialShare"),Lt("./modules/polls.js","initPolls"),Lt("./modules/milestones.js"),Lt("./modules/ordertracker.js","initOrderTracker"),Lt("./modules/seasonal.js","initSeasonal"),Lt("./modules/weather.js","initWeather")},2500),Ct(["gallery","footer","contact"],function(){Lt("./modules/stories.js","initStories"),Lt("./modules/moodorder.js","initMoodOrder"),Lt("./modules/livequeue.js","initLiveQueue"),Lt("./modules/streaks.js","initStreaks"),Lt("./modules/giftcards.js","initGiftCards"),Lt("./modules/referral.js","initReferral"),Lt("./modules/musicplayer.js","initMusicPlayer"),Lt("./modules/arpreview.js","initARPreview"),Lt("./modules/voiceorder.js","initVoiceOrder"),Lt("./modules/geofence.js","initGeofence")},3500),Ct(["footer","contact","gallery"],function(){Lt("./modules/worldclass2.js","initWorldClass2")},5e3),(window.requestIdleCallback||function(e){setTimeout(e,3e3)})(async function(){var e=document.getElementById("ai-for-you"),t=document.getElementById("ai-for-you-cards");if(e&&t){try{var n=JSON.parse(localStorage.getItem("ai_recommendations"));if(n&&Date.now()-n.ts<18e5)return void gt(e,t,n.data)}catch(c){}var a=A(),o=[];try{var r=JSON.parse(localStorage.getItem("amoghaMyOrders"));r&&(o=r.map(function(e){return e.data}))}catch(c){}try{var i=await fetch("/api/recommend",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderHistory:o.slice(0,10),currentCart:V.map(function(e){return{name:e.name}}),timeOfDay:(new Date).getHours(),isVegOnly:a&&(a.dietaryPrefs||[]).includes("Vegetarian")})}),s=await i.json();if(s.recommendations&&s.recommendations.length>0){gt(e,t,s.recommendations);try{localStorage.setItem("ai_recommendations",JSON.stringify({ts:Date.now(),data:s.recommendations}))}catch(c){}}}catch(c){e.style.display="none"}}}),oe(),document.body.style.overflow="",document.body.classList.remove("modal-open"),window.displayCart=ie,window.loadMenuRatings=function(){var e=w();if(e){try{var t=n("amoghaRatings");if(t){var o=JSON.parse(t);if(o.ts&&Date.now()-o.ts<6e5&&o.data)return void r(o.data)}}catch(i){}e.collection("reviews").get().then(function(e){var t={};e.forEach(function(e){var n=e.data();t[n.itemName]||(t[n.itemName]={total:0,count:0}),t[n.itemName].total+=n.rating,t[n.itemName].count++}),r(t),a("amoghaRatings",JSON.stringify({ts:Date.now(),data:t}))}).catch(function(){try{var e=n("amoghaRatings");if(e){var t=JSON.parse(e);t.data&&r(t.data)}}catch(i){}})}function r(e){document.querySelectorAll(".menu-item-card").forEach(function(t){var n=t.querySelector("h4");if(n){var a=n.textContent.replace(/Bestseller|Must Try|New/gi,"").trim(),o=e[a];if(o&&o.count>0){var r=(o.total/o.count).toFixed(1),i=t.querySelector(".item-rating");i&&i.remove();var s=document.createElement("div");s.className="item-rating",s.innerHTML='<span class="rating-stars">'+function(e){for(var t="",n=1;n<=5;n++)n<=Math.floor(e)?t+='<span class="star filled">★</span>':t+=n-.5<=e?'<span class="star half">★</span>':'<span class="star empty">☆</span>';return t}(parseFloat(r))+'</span><span class="rating-text">'+r+" ("+o.count+")</span>";var c=t.querySelector(".item-description");c&&c.after(s)}}})}},window.addEventListener("online",xt),window.addEventListener("offline",xt),xt(),window.addEventListener("error",function(e){console.error("[Amogha] Unhandled error:",e.message,"at",e.filename,":",e.lineno)}),window.addEventListener("unhandledrejection",function(e){e.reason&&"AbortError"===e.reason.name?e.preventDefault():console.error("[Amogha] Unhandled promise rejection:",e.reason)}),"undefined"!=typeof performance&&performance.mark&&performance.mark("amogha-app-init-complete"),"undefined"!=typeof PerformanceObserver)try{new PerformanceObserver(function(e){var t=e.getEntries(),n=t[t.length-1];n&&Math.round(n.startTime)}).observe({type:"largest-contentful-paint",buffered:!0});var St=0;new PerformanceObserver(function(e){e.getEntries().forEach(function(e){e.hadRecentInput||(St+=e.value)})}).observe({type:"layout-shift",buffered:!0}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&St>0&&St.toFixed(4)})}catch(kt){}export{e as __vite_legacy_guard,q as a,w as b,A as g,G as s};