1(function(){'use strict';var api=window.axios;if(!api)return; 2function el(t,c,v){var n=document.createElement(t);if(c)n.className=c;if(v!==undefined)n.textContent=String(v);return n}function viewer(){var k='404eats_discovery_viewer',v=localStorage.getItem(k);if(!v){v=(crypto&&crypto.randomUUID)?crypto.randomUUID():Date.now()+Math.random().toString(16);localStorage.setItem(k,v)}return v}function stored(a){for(var i=0;i<a.length;i++){var v=localStorage.getItem(a[i]);if(v)return v}return null}function ctx(){return{viewer_key:viewer(),lat:stored(['latitude','lat','location_lat']),lng:stored(['longitude','lng','location_lng']),fulfillment:stored(['transaction_type','fulfillment'])==='pickup'?'pickup':'delivery'}}function details(r){var d=r&&r.data?r.data:r;return d&&d.details!==undefined?d.details:d}function get(u,d){return api.get(u,{params:Object.assign({viewer_key:viewer()},d||{}),headers:{'X-Requested-With':'XMLHttpRequest'}})}function post(u,d){var b=new URLSearchParams(),m=document.querySelector('meta[name="YII_CSRF_TOKEN"]');Object.keys(d||{}).forEach(function(k){b.append(k,typeof d[k]==='object'?JSON.stringify(d[k]):d[k])});b.append('viewer_key',viewer());if(m)b.append('YII_CSRF_TOKEN',m.content);return api.post(u,b,{headers:{'X-Requested-With':'XMLHttpRequest'}})}function safe(u){try{var x=new URL(u||'#',location.origin);return x.origin===location.origin?x.href:'#'}catch(e){return'#'}}function slug(v){return String(v||'').toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')}function image(v){if(!v)return'';return/^https?:|^\//.test(v)?v:'/upload/'+v}function money(v){if(v===null||v===undefined)return'';try{return new Intl.NumberFormat(undefined,{style:'currency',currency:stored(['currency_code'])||'USD'}).format(Number(v))}catch(e){return'$'+Number(v).toFixed(2)}} 3function initHome(){var r=document.getElementById('customer-personalized-discovery');if(!r)return;post(r.dataset.homeEndpoint,ctx()).then(function(x){var d=details(x)||{},target=r.querySelector('[data-discovery-sections]'),status=r.querySelector('.customer-discovery__status');target.textContent='';if(!(d.sections||[]).length){status.textContent='Browse restaurants near you to start discovering favorites.';return}status.hidden=true;(d.sections||[]).slice(0,7).forEach(function(s){if(!s.items||!s.items.length)return;var w=el('section','customer-discovery-row'),h=el('div','customer-discovery-row__head'),title=el('h3','',s.title),rail=el('div','customer-discovery-row__rail');h.appendChild(title);w.appendChild(h);w.appendChild(rail);s.items.forEach(function(i){var a=el('a','customer-discovery-card'),im=el('img'),body=el('span','customer-discovery-card__body');a.href=safe(i.url);im.src=image(i.image);im.alt='';imgLoading(im);body.appendChild(el('strong','',i.name||i.restaurant_name||i.item_name||'Option'));body.appendChild(el('span','customer-discovery-card__reason',i.reason||''));a.append(im,body);rail.appendChild(a)});target.appendChild(w)})}).catch(function(){r.querySelector('.customer-discovery__status').textContent='Personalized picks are unavailable right now.'})}function imgLoading(img){img.loading='lazy';img.decoding='async'} 4function initSearch(){var root=document.getElementById('customer-search-discovery');if(!root)return;var form=root.querySelector('form'),input=root.querySelector('#customer-search-query'),clear=root.querySelector('[data-search-clear]'),box=root.querySelector('[role="listbox"]'),start=root.querySelector('[data-search-starting]'),section=root.querySelector('[data-search-results-section]'),groups=root.querySelector('[data-search-result-groups]'),loading=root.querySelector('[data-search-loading]'),empty=root.querySelector('[data-search-empty]'),announce=root.querySelector('[data-search-announcement]'),more=root.querySelector('[data-load-more]'),sheet=root.querySelector('[data-filter-sheet]'),active=root.querySelector('[data-active-filters]'),count=root.querySelector('[data-filter-count]'),sort=root.querySelector('[data-search-sort]'),state={query:root.dataset.initialQuery||'',page:1,sort:'recommended',fulfillment:ctx().fulfillment,filters:{},busy:false,index:-1},timer,recentKey='404eats_recent_searches';input.dataset.discoveryReady='1'; 5function localRecent(){try{return JSON.parse(localStorage.getItem(recentKey)||'[]')}catch(e){return[]}}function saveRecent(q){var a=localRecent().filter(function(x){return x.toLowerCase()!==q.toLowerCase()});a.unshift(q);localStorage.setItem(recentKey,JSON.stringify(a.slice(0,10)))}function chip(v,go,remove){var w=el('span','search-discovery__chip'),b=el('button','',v);b.type='button';b.onclick=go;w.appendChild(b);if(remove){var x=el('button','search-discovery__chip-remove','x');x.type='button';x.setAttribute('aria-label','Remove '+v);x.onclick=remove;w.appendChild(x)}return w} 6function starting(d){var rt=root.querySelector('[data-recent-searches]'),ct=root.querySelector('[data-popular-cuisines]'),cr=root.querySelector('[data-clear-recent]'),server=d&&d.recent&&d.recent.items?d.recent.items:[],recent=server.length?server.map(function(x){return typeof x==='string'?x:(x.query||x.search_query||'')}):localRecent();rt.textContent='';ct.textContent='';recent.filter(Boolean).slice(0,8).forEach(function(q,i){rt.appendChild(chip(q,function(){use(q)},function(){if(root.dataset.authenticated==='1'&&server[i]&&server[i].id)post(root.dataset.deleteRecentEndpoint,{id:server[i].id}).then(loadStart);else{localStorage.setItem(recentKey,JSON.stringify(localRecent().filter(function(x){return x!==q})));loadStart()}}))});if(!recent.length)rt.appendChild(el('p','search-discovery__muted','Your recent searches will appear here.'));cr.hidden=!recent.length;
6(d&&d.cuisines||[]).forEach(function(c){var a=el('a','search-discovery__cuisine-tile'),ic=el('i','zmdi zmdi-cutlery'),o=el('option','',c.label);a.href='/cuisine/'+slug(c.label);a.append(ic,el('strong','',c.label));ct.appendChild(a);o.value=c.id;root.querySelector('[data-filter-select="cuisine_id"]').appendChild(o)});root.querySelector('[data-trending-status]').hidden=!(d&&String(d.trending_status).indexOf('DEFERRED')>=0)}function loadStart(){get(root.dataset.suggestionsEndpoint,{limit:12}).then(function(r){starting(details(r)||{})}).catch(function(){starting({})})}function showStart(){start.hidden=false;section.hidden=true;groups.textContent='';history.replaceState(null,'',location.pathname);loadStart()} 7function use(q){state.query=String(q||'').trim();input.value=state.query;clear.hidden=!state.query;box.hidden=true;input.setAttribute('aria-expanded','false');if(state.query.length>=2){state.page=1;saveRecent(state.query);search(false)}else showStart()}function params(){var c=ctx(),p={q:state.query,page:state.page,limit:24,sort:state.sort,fulfillment:state.fulfillment};if(c.lat&&c.lng){p.lat=c.lat;p.lng=c.lng}Object.keys(state.filters).forEach(function(k){p[k]=state.filters[k]});return p}function busy(v,append){state.busy=v;form.classList.toggle('is-loading',v);input.setAttribute('aria-busy',v?'true':'false');if(!append)loading.hidden=!v;if(v){empty.hidden=true;announce.textContent='Loading search results'}} 8function url(i){var t=String(i.result_type||'').toUpperCase(),r=i.restaurant||{},base=r.slug?'/'+encodeURIComponent(r.slug):'#';if(t==='RESTAURANT')return r.slug?base:'#';if(t==='CUISINE')return'/cuisine/'+slug(i.title);if(t==='MENU_ITEM'&&base!=='#')return base+'?item_id='+encodeURIComponent(i.id)+'&from=search&q='+encodeURIComponent(state.query);if(t==='CATEGORY'&&base!=='#')return base+'?category='+encodeURIComponent(i.id)+'&from=search';return base}function availability(i){var a=i.availability||{},c=String(a.code||'').replace(/_/g,' ');if(a.pickup_only)return'PICKUP ONLY';if(a.available_later)return'AVAILABLE LATER';if(c&&c!=='UNKNOWN'&&c!=='ORDERABLE')return c;if(a.orderable)return'OPEN';return'UNAVAILABLE'} 9function card(i){var t=String(i.result_type||'').toUpperCase(),c=el('article','search-result-card search-result-card--'+t.toLowerCase()),a=el('a','search-result-card__media'),src=image(i.image);a.href=safe(url(i));if(src){var im=el('img');im.src=src;im.alt='';imgLoading(im);a.appendChild(im)}else a.appendChild(el('i','search-result-card__placeholder zmdi '+(t==='RESTAURANT'?'zmdi-store':t==='CUISINE'?'zmdi-cutlery':'zmdi-local-dining')));c.appendChild(a);var b=el('div','search-result-card__body'),top=el('div','search-result-card__top'),type=el('span','search-result-card__type',t==='MENU_ITEM'?'Dish':t.charAt(0)+t.slice(1).toLowerCase());top.appendChild(type);if(t==='RESTAURANT'||t==='MENU_ITEM')top.appendChild(el('span','search-result-card__status search-result-card__status--'+String((i.availability||{}).code||'unknown').toLowerCase(),availability(i)));b.appendChild(top);var h=el('h3'),hl=el('a','',i.title||'Result');hl.href=safe(url(i));h.appendChild(hl);b.appendChild(h);if(i.subtitle)b.appendChild(el('p','search-result-card__subtitle',i.subtitle));var m=el('div','search-result-card__meta');if(i.rating)m.appendChild(el('span','',Number(i.rating).toFixed(1)+' rating'));if(i.delivery_estimate)m.appendChild(el('span','',i.delivery_estimate+' min'));if(i.distance!==null&&i.distance!==undefined)m.appendChild(el('span','',i.distance+' '+(i.distance_unit||'mi')));if(i.price!==null&&i.price!==undefined)m.appendChild(el('span','search-result-card__price',money(i.price)));if(i.promotion_eligible)m.appendChild(el('span','search-result-card__offer','Offer'));b.appendChild(m);if(i.personalization_label)b.appendChild(el('p','search-result-card__personalization',i.personalization_label));var actions=el('div','search-result-card__actions'),primary=el('a','search-result-card__primary',t==='MENU_ITEM'?'View Item':t==='RESTAURANT'?'View Restaurant':'Explore '+(i.title||'Cuisine'));primary.href=safe(url(i));actions.appendChild(primary);if(t==='MENU_ITEM'&&i.restaurant&&i.restaurant.slug){var rest=el('a','search-result-card__secondary','View Restaurant');rest.href=safe('/'+encodeURIComponent(i.restaurant.slug));actions.appendChild(rest)}b.appendChild(actions);c.appendChild(b);return c} 10function render(d,append){var rows=d&&d.results?d.results:[],meta=d&&d.meta?d.meta:{},map={MENU_ITEM:[],RESTAURANT:[],CUISINE:[],CATEGORY:[],PROMOTION:[]},labels={MENU_ITEM:'Dishes',RESTAURANT:'Restaurants',CUISINE:'Cuisines',CATEGORY:'Menu categories',PROMOTION:'Offers'};more.hidden=!meta.has_more;if(!append)groups.textContent='';var correction=root.querySelector('[data-query-correction]'),corrected=meta.
10corrected_query||meta.correction||'';correction.hidden=!corrected;if(corrected)correction.textContent='Showing results for '+corrected+' instead of '+state.query+'.';rows.forEach(function(i){var t=String(i.result_type||'').toUpperCase();if(map[t])map[t].push(i)});Object.keys(map).forEach(function(t){if(!map[t].length)return;var s=groups.querySelector('[data-result-type="'+t+'"]');if(!s){s=el('section','search-result-group');s.dataset.resultType=t;var head=el('div','search-discovery__section-head'),h=el('h2','',labels[t]);h.id='result-'+t.toLowerCase();s.setAttribute('aria-labelledby',h.id);head.appendChild(h);s.append(head,el('div','search-result-grid'));groups.appendChild(s)}map[t].forEach(function(i){s.querySelector('.search-result-grid').appendChild(card(i))})});empty.hidden=rows.length>0||append;announce.textContent=rows.length?rows.length+' search results loaded':'No exact matches found';root.querySelector('[data-results-heading]').textContent='Results for "'+state.query+'"'}function search(append){if(state.busy||state.query.length<2)return;start.hidden=true;section.hidden=false;busy(true,append);get(root.dataset.searchEndpoint,params()).then(function(r){render(details(r)||{},append);history.replaceState(null,'','?q='+encodeURIComponent(state.query))}).catch(function(){if(!append){groups.textContent='';empty.hidden=false}announce.textContent='Search is temporarily unavailable. Please try again.'}).then(function(){busy(false,append)})} 11function renderAutocomplete(rows){box.textContent='';state.index=-1;(rows||[]).slice(0,8).forEach(function(i,n){var b=el('button','search-discovery__autocomplete-option');b.type='button';b.setAttribute('role','option');b.dataset.index=n;var text=el('span');text.append(el('strong','',i.label),el('small','',i.context||''));b.append(text,el('span','search-discovery__autocomplete-type',String(i.result_type||'').replace('_',' ')));b.onclick=function(){use(i.label)};box.appendChild(b)});box.hidden=!rows.length;input.setAttribute('aria-expanded',rows.length?'true':'false')}function requestAutocomplete(){var q=input.value.trim();if(q.length<2){renderAutocomplete([]);return}form.classList.add('is-suggesting');get(root.dataset.autocompleteEndpoint,{q:q,limit:8}).then(function(r){renderAutocomplete((details(r)||{}).suggestions||[])}).catch(function(){renderAutocomplete([])}).then(function(){form.classList.remove('is-suggesting')})} 12function updateFilters(){var list=[];root.querySelectorAll('[data-filter][aria-pressed="true"]').forEach(function(b){list.push({key:b.dataset.filter,label:b.textContent.trim()})});root.querySelectorAll('[data-filter-select]').forEach(function(s){if(s.value)list.push({key:s.dataset.filterSelect,label:s.options[s.selectedIndex].text})});active.textContent='';list.forEach(function(i){active.appendChild(chip(i.label,function(){delete state.filters[i.key];var b=root.querySelector('[data-filter="'+i.key+'"]'),s=root.querySelector('[data-filter-select="'+i.key+'"]');if(b)b.setAttribute('aria-pressed','false');if(s)s.value='';updateFilters();state.page=1;search(false)}))});if(list.length){var all=el('button','search-discovery__clear-all','Clear all');all.type='button';all.onclick=clearFilters;active.appendChild(all)}active.hidden=!list.length;count.textContent=list.length;count.hidden=!list.length}function clearFilters(){state.filters={};root.querySelectorAll('[data-filter]').forEach(function(b){b.setAttribute('aria-pressed','false')});root.querySelectorAll('[data-filter-select]').forEach(function(s){s.value=''});updateFilters()}function closeSheet(){sheet.hidden=true;document.body.classList.remove('search-filter-open');root.querySelector('[data-open-filters]').focus()}function applyFilters(){state.filters={};root.querySelectorAll('[data-filter][aria-pressed="true"]').forEach(function(b){state.filters[b.dataset.filter]=b.dataset.value||1});root.querySelectorAll('[data-filter-select]').forEach(function(s){if(s.value)state.filters[s.dataset.filterSelect]=s.value});updateFilters();closeSheet();state.page=1;search(false)} 13form.onsubmit=function(e){e.preventDefault();use(input.value);input.blur()};input.oninput=function(){clear.hidden=!input.value;clearTimeout(timer);timer=setTimeout(requestAutocomplete,240)};input.onkeydown=function(e){var o=box.querySelectorAll('[role="option"]');
13if((e.key==='ArrowDown'||e.key==='ArrowUp')&&o.length){e.preventDefault();state.index=e.key==='ArrowDown'?Math.min(state.index+1,o.length-1):Math.max(state.index-1,0);o.forEach(function(x,n){x.setAttribute('aria-selected',n===state.index?'true':'false')});o[state.index].focus()}else if(e.key==='Escape')renderAutocomplete([])};clear.onclick=function(){input.value='';state.query='';clear.hidden=true;renderAutocomplete([]);showStart();input.focus()};root.querySelector('[data-clear-recent]').onclick=function(){localStorage.removeItem(recentKey);if(root.dataset.authenticated==='1')post(root.dataset.clearRecentEndpoint,{}).then(loadStart).catch(loadStart);else loadStart()};root.querySelectorAll('[data-fulfillment]').forEach(function(b){b.setAttribute('aria-pressed',b.dataset.fulfillment===state.fulfillment?'true':'false');b.onclick=function(){state.fulfillment=b.dataset.fulfillment;localStorage.setItem('transaction_type',state.fulfillment);root.querySelectorAll('[data-fulfillment]').forEach(function(x){x.setAttribute('aria-pressed',x===b?'true':'false')});if(state.query.length>=2){state.page=1;search(false)}}});root.querySelector('[data-open-filters]').onclick=function(){sheet.hidden=false;document.body.classList.add('search-filter-open');sheet.querySelector('[data-filter]').focus()};root.querySelectorAll('[data-close-filters]').forEach(function(b){b.onclick=closeSheet});root.querySelectorAll('[data-filter]').forEach(function(b){b.onclick=function(){b.setAttribute('aria-pressed',b.getAttribute('aria-pressed')==='true'?'false':'true')}});root.querySelector('[data-apply-filters]').onclick=applyFilters;root.querySelector('[data-clear-filters]').onclick=clearFilters;sort.onchange=function(){state.sort=sort.value;state.page=1;search(false)};root.querySelector('[data-recovery-clear]').onclick=function(){clearFilters();state.page=1;search(false)};root.querySelector('[data-recovery-later]').onclick=function(){clearFilters();state.filters.available_later=1;root.querySelector('[data-filter="available_later"]').setAttribute('aria-pressed','true');updateFilters();state.page=1;search(false)};more.onclick=function(){state.page++;search(true)};document.addEventListener('click',function(e){if(!form.contains(e.target))renderAutocomplete([])});document.addEventListener('keydown',function(e){if(e.key==='Escape'&&!sheet.hidden)closeSheet()});window.addEventListener('pageshow',function(){if(state.query.length>=2&&!groups.children.length)search(false)});loadStart();if(state.query.length>=2){input.value=state.query;clear.hidden=false;search(false)}else showStart()} 14function initGeneric(){var timer;document.querySelectorAll('input[placeholder*="Search" i],input[aria-label*="Search" i]').forEach(function(i){if(i.dataset.discoveryReady)return;i.dataset.discoveryReady='1';var p=i.parentElement,b=el('div','discovery-search-suggestions');p.classList.add('discovery-search-wrap');b.hidden=true;b.setAttribute('role','listbox');p.appendChild(b);i.addEventListener('input',function(){clearTimeout(timer);var q=i.value.trim();if(q.length<2){b.hidden=true;b.textContent='';return}timer=setTimeout(function(){post('/interface/discoverysearchsuggestions',{query:q,limit:8}).then(function(r){b.textContent='';(details(r)||[]).forEach(function(x){var a=el('a');a.href=safe(x.url);a.append(el('span','',x.label),el('span','discovery-search-suggestions__type',x.type));b.appendChild(a)});b.hidden=!b.children.length}).catch(function(){b.hidden=true})},240)})})} 15function loadAiSearchAssets(){if(!document.getElementById('customer-search-discovery')||document.querySelector('script[data-customer-ai-search]'))return;var css=document.createElement('link');css.rel='stylesheet';css.href='/themes/karenderia_v2/assets/css/customer-ai-search.css';css.dataset.customerAiSearch='1';var js=document.createElement('script');js.src='/assets/js/customer-ai-search.js';js.defer=true;js.dataset.customerAiSearch='1';document.head.appendChild(css);document.body.appendChild(js)} 16function start(){initHome();initSearch();initGeneric();loadAiSearchAssets()}if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start);else start()})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.