/* Local destinations for the public Fandango navigation, captured September 4, 2026. */
let navState={cart:[],library:[],theaters:[]};
let storeSlide=0,streamSlide=0,newsCount=8;
const navProducts=NAV_DATA.store.products;
function localAnchor(href,label,cls='',accessible=''){return `${label}`;}
function navSvg(name){
const paths={search:'',account:'',cart:'',heart:'',play:''};
return ``;
}
function bindNavigationChrome(){
root.querySelectorAll('[data-home-notice]').forEach(b=>b.onclick=()=>homeDialog(`
This is a local recreation. No information is sent to Fandango.
`));
}
async function navUpdate(action){navState=await api('/api/navigation/state',{method:'POST',body:JSON.stringify(action)});return navState;}
function navNotice(title,message){homeDialog(`
${esc(title)}
${esc(message)}
`);}
function storeHref(href){
const u=new URL(href,'https://store.fandango.com');
if(u.pathname.startsWith('/products/')||u.pathname.startsWith('/collections/')||u.pathname.startsWith('/pages/'))return '/fanstore'+u.pathname;
if(u.pathname==='/account')return '/account';
return '/fanstore';
}
function storeHeader(){
return `
Sign up for the Fandango FanStore newsletter and SAVE 15% on your first order!
`;
}
function storeLayout(content){
document.body.className='fanstore-page';root.innerHTML=storeHeader()+`${content}`+storeFooter();bindGlobal();
root.querySelector('[data-store-search]').onclick=()=>{const d=homeDialog('
Search FanStore
');d.querySelector('form').onsubmit=e=>{e.preventDefault();const q=new FormData(e.currentTarget).get('q');d.close();go(`/fanstore/collections/all?q=${encodeURIComponent(q)}`);};d.querySelector('input').focus();};
root.querySelector('[data-newsletter]').onsubmit=e=>{e.preventDefault();navNotice('Newsletter preview','This local recreation does not subscribe you or send your email to a mailing list.');};
}
function productCard(p){return `${localAnchor('/fanstore/products/'+p.id,`
`)}`;}
function bindProductCards(){root.querySelectorAll('[data-quick]').forEach(b=>b.onclick=()=>{const p=navProducts.find(p=>p.id===b.dataset.quick);const d=homeDialog(`
${esc(p.title)}
${money(p.price)}
${esc(p.description.slice(0,250))}
${localAnchor('/fanstore/products/'+p.id,'View full details','primary')}
`);d.querySelector('[data-link]').onclick=e=>{e.preventDefault();d.close();go('/fanstore/products/'+p.id);};});}
function storeHero(){const s=NAV_DATA.store.slides[storeSlide];return `
${esc(p.description||'Product specifications were not returned by the source during this capture. The displayed title, image and price are from the verified catalog.')}
`);
root.querySelectorAll('[data-product-image]').forEach(b=>b.onclick=()=>root.querySelector('.store-detail-image').src=b.dataset.productImage);
root.querySelectorAll('[data-variant-option]').forEach(s=>s.onchange=()=>{const values=[...root.querySelectorAll('[data-variant-option]')].map(s=>s.value);variant=p.variants.find(v=>v.options.every((o,i)=>o===values[i]));const button=root.querySelector('.store-add');button.disabled=!variant?.available;button.textContent=variant?(variant.available?'Add to cart':'Sold out'):'Option unavailable in this preview';if(variant?.image)root.querySelector('.store-detail-image').src=variant.image;root.querySelector('.store-price').textContent=money(variant?.price??p.price);if(variant)history.replaceState({},'',`/fanstore/products/${id}?variant=${variant.id}`);});
root.querySelector('[data-add-cart]').onsubmit=async e=>{e.preventDefault();if(!variant?.available)return;try{const existing=navState.cart.find(l=>l.variant===variant.id)?.quantity||0;await navUpdate({kind:'cart',product:id,variant:variant.id,quantity:existing+Number(new FormData(e.currentTarget).get('quantity'))});go('/fanstore/cart');}catch(err){notify(err.message);}};
}
function storeCart(){
storeLayout(`
`;}
function streamLayout(content){document.body.className='streaming-page';root.innerHTML=streamHeader()+`${content}`;bindGlobal();root.querySelector('[data-stream-search]').onclick=()=>{const d=homeDialog('
Search movies and TV
');d.querySelector('form').onsubmit=e=>{e.preventDefault();const q=new FormData(e.currentTarget).get('q');d.close();go('/streaming?q='+encodeURIComponent(q));};};}
function streamMovies(){const rows=[...NAV_DATA.streaming.rows.flatMap(r=>r.movies),...HOME_DATA.free.map(m=>({...m,id:m.href.split('/').pop()}))];return [...new Map(rows.map(m=>[m.id,m])).values()];}
function streamRow(title,rows,wide=false){return `
`:''}`;}
function bindStreaming(){bindRows();root.querySelectorAll('[data-stream-slide]').forEach(b=>b.onclick=()=>{streamSlide=(streamSlide+Number(b.dataset.streamSlide)+NAV_DATA.streaming.slides.length)%NAV_DATA.streaming.slides.length;streamHome();});root.querySelectorAll('[data-stream-dot]').forEach(b=>b.onclick=()=>{streamSlide=Number(b.dataset.streamDot);streamHome();});root.querySelectorAll('[data-watch]').forEach(b=>b.onclick=()=>navNotice('Watch preview','This local recreation does not include the licensed full-length movie. No streaming purchase, rental or subscription will be started.'));root.querySelectorAll('[data-library]').forEach(b=>b.onclick=async()=>{try{await navUpdate({kind:'library',id:b.dataset.library});b.textContent=navState.library.includes(b.dataset.library)?'✓ In My Library':'+ Add to My Library';}catch(e){notify(e.message);}});}
function streamHome(){const q=new URLSearchParams(location.search),term=q.get('q'),category=q.get('category');let rows=streamMovies();if(term)rows=rows.filter(m=>m.title.toLowerCase().includes(term.toLowerCase()));if(category==='tv')rows=rows.filter(m=>/season/i.test(m.title));if(category==='movies')rows=rows.filter(m=>!/season/i.test(m.title));if(term||category){streamLayout(`
`);}else streamLayout(streamHero(NAV_DATA.streaming.slides[streamSlide])+NAV_DATA.streaming.rows.map(r=>streamRow(r.title,r.movies,r.wide)).join(''));bindStreaming();}
function streamDetail(id){const hero=NAV_DATA.streaming.slides.find(m=>m.id===id),movie=streamMovies().find(m=>m.id===id);if(!hero&&!movie){notFound();return;}streamLayout(hero?streamHero(hero,true):`
${esc(movie.title)}
Free to Watch
`);bindStreaming();}
let newsResizeObserver;
function bindNewsGrid(){const grid=root.querySelector('.news-grid');const align=()=>{const css=getComputedStyle(grid),gap=parseFloat(css.rowGap),step=parseFloat(css.gridAutoRows)+gap;grid.querySelectorAll('article').forEach(card=>card.style.gridRowEnd='span '+Math.ceil((card.getBoundingClientRect().height+gap)/step));};grid.querySelectorAll('img').forEach(img=>img.addEventListener('load',align));newsResizeObserver?.disconnect();newsResizeObserver=new ResizeObserver(align);newsResizeObserver.observe(grid);document.fonts.ready.then(align);align();}
function newsPage(){layout(`
${newsBottom()}`);bindHomeCarousel();bindNewsGrid();root.querySelector('[data-news-more]')?.addEventListener('click',()=>{const y=scrollY;newsCount+=8;newsPage();window.scrollTo(0,y);});}
function newsBottom(){return `
This preview includes the captured cover and headline. The full article or licensed video was not available in the source capture.
':''}${newsBottom()}`);root.querySelector('[data-news-video]')?.addEventListener('click',()=>navNotice('Video preview','The original video media was not available for local playback. This page will not redirect you to the official site.'));}
function localTheaters(id){
const q=new URLSearchParams(location.search),onlySaved=q.get('filter')==='my-theaters',selected=q.get('theater')||id||'',chain=q.get('chain')||'',date=q.get('date')||NAV_DATA.theaters.date;let rows=NAV_DATA.theaters.rows;
if(selected)rows=rows.filter(t=>t.id===selected);if(chain)rows=rows.filter(t=>t.name.startsWith(chain));if(onlySaved)rows=rows.filter(t=>navState.theaters.includes(t.id));
layout(`
${id?esc(rows[0]?.name||'Theaters'): 'Movie times + Tickets near 90001'}
No showtimes were returned for this theater in the selected date capture.
'}`;}).join('')||'
No theaters match the selected filters.
'}
`);
root.querySelector('[data-location]').onclick=()=>homeLocationDialog(zip=>go('/theaters?zip='+zip));const change=()=>{const query=new URLSearchParams({zip:'90001',date,theater:root.querySelector('[data-theater-filter]').value,chain:root.querySelector('[data-chain-filter]').value});go('/theaters?'+query);};root.querySelector('[data-theater-filter]').onchange=change;root.querySelector('[data-chain-filter]').onchange=change;
root.querySelectorAll('[data-amenities]').forEach(b=>b.onclick=()=>{const t=NAV_DATA.theaters.rows.find(t=>t.id===b.dataset.amenities);navNotice(t.name+' — Amenities',t.amenities.join(' · '));});root.querySelectorAll('[data-map]').forEach(b=>b.onclick=()=>{const t=NAV_DATA.theaters.rows.find(t=>t.id===b.dataset.map);navNotice(t.name,t.address+' · '+t.distance+' from 90001. An external map is not loaded in this offline preview.');});root.querySelectorAll('[data-save-theater]').forEach(b=>b.onclick=async()=>{try{await navUpdate({kind:'theaters',id:b.dataset.saveTheater});localTheaters(id);}catch(e){notify(e.message);}});
root.querySelectorAll('[data-local-showtime]').forEach(b=>b.onclick=()=>navNotice(b.dataset.movie,`${longDate(date)} · ${b.dataset.time}. This captured Los Angeles showtime has no verified ticket-price or seat inventory in the local preview. No real booking will be made.`));
}
function referenceMovie(id){const m=[...HOME_DATA.now,...HOME_DATA.soon,...HOME_DATA.newSoon].find(m=>new URL(m.href,HOME_DATA.source).pathname.includes('/'+id+'/'));if(!m){notFound();return;}layout(`