(() => {
const NS = window.VakantiehuisplatformDesignSystem_2f09bb;
const { Button, Icon, Photo, NearbyPlace, WeatherCard, WebcamCard, ErrorMessage, StickyBookBar } = NS;
const { VHSection: Section, VHSectionHead: SectionHead, VHContainer: Container, VHHeader, VHFooter, vhLabel } = window;
const CATS0 = ['Alles', 'Skiën', 'Eten', 'Kinderen', 'Boodschappen'];
const u = k => window.VH_I18N.ui(k);

function Chip({ on, children, onClick }) {
  return <button aria-pressed={on} onClick={onClick} style={{ minHeight: 44, padding: '0 16px', borderRadius: 'var(--radius-pill)', border: '1.5px solid ' + (on ? 'var(--text-1)' : 'var(--border)'), background: on ? 'var(--text-1)' : 'var(--surface-card)', color: on ? 'var(--surface-page)' : 'var(--text-1)', fontSize: 16, fontWeight: 600, cursor: 'pointer', whiteSpace: 'nowrap' }}>{children}</button>;
}
function OmgevingScreen({ m, n, house, lang, setLang, onNav, empty }) {
  const [cat, setCat] = React.useState('Alles');
  const CATS = window.vhS('cats', CATS0);
  const P = window.VH_DATA.places.filter(p => cat === 'Alles' || p.cat === cat);
  return <div>
    <VHHeader m={m} n={n} house={house} lang={lang} setLang={setLang} onNav={onNav} />
    <Section m={m} style={{ paddingBottom: 0 }}>
      <SectionHead m={m} kicker={u('Omgeving, agenda en weer')} title={u('Rond') + ' ' + house.name}>{u('Afstanden zijn een eerste schatting vanaf de voordeur. De eigenaar vult ze aan met eigen tips.')}</SectionHead>
    </Section>
    <Container m={m}>
      <div style={{ display: 'grid', gridTemplateColumns: m ? '1fr' : 'minmax(0,1.3fr) minmax(0,1fr)', gap: m ? 24 : 40, alignItems: 'start' }}>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
          <window.VHLiveMap ratio={m ? '4/3' : '16/10'} places={P} />
          <div style={{ display: 'flex', gap: 8, overflowX: 'auto', paddingBottom: 4 }}>{CATS.map(c => <Chip key={c} on={cat === c} onClick={() => setCat(c)}>{u(c)}</Chip>)}</div>
          <div>{P.map((p, i) => <NearbyPlace key={p.name} {...p} style={i === P.length - 1 ? { borderBottom: 0 } : null} />)}</div>
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
          <window.VHLiveWeather empty={empty} lang={lang} />
          {(window.VH_SITE.webcam && window.VH_SITE.webcam.src ? <WebcamCard src={window.VH_SITE.webcam.src} href={window.VH_SITE.webcam.href || window.VH_SITE.webcam.src} title={window.VH_SITE.webcam.title || window.VH_I18N.T(lang).cam} updated={window.VH_SITE.webcam.updated || 'live'} /> : <WebcamCard empty title={window.VH_I18N.T(lang).cam} />)}
          {empty && <ErrorMessage variant="info" title="Live data tijdelijk niet beschikbaar">Weer en webcam komen van externe bronnen. De rest van de pagina werkt gewoon.</ErrorMessage>}
        </div>
      </div>
    </Container>
    <Section m={m}>
      <SectionHead m={m} kicker={u('Agenda')} title={u('Wat is er te doen')} />
      {empty ? <ErrorMessage variant="info" title="Geen evenementen deze maand">De eigenaar heeft nog niets toegevoegd. Kijk ook op de site van het toeristenbureau.</ErrorMessage>
        : <div style={{ display: 'flex', flexDirection: 'column' }}>{window.VH_DATA.events.map(e => <div key={e.title} style={{ display: 'flex', gap: 20, alignItems: 'center', padding: '16px 0', borderBottom: '1px solid var(--border)' }}>
          <span style={{ ...vhLabel, width: 72, flex: 'none', color: 'var(--accent-text)', fontSize: 16 }}>{e.d} {e.m}</span>
          <div style={{ display: 'flex', flexDirection: 'column', flex: 1 }}><strong style={{ fontSize: 17 }}>{e.title}</strong><span style={{ fontSize: 16, color: 'var(--text-2)' }}>{e.where}</span></div>
          {!m && <Icon name="chevron-right" />}
        </div>)}</div>}
    </Section>
    <Section m={m} alt><SectionHead m={m} kicker={u('In beeld')} title={u('De omgeving')} /><window.VHAreaPhotos m={m} /></Section>
    <window.VHFood m={m} />
    <Section m={m} alt>
      <SectionHead m={m} kicker={u('Tips van de eigenaar')} title={u('Wat wij zelf doen')} />
      <div style={{ display: 'grid', gridTemplateColumns: m ? '1fr' : 'repeat(3,1fr)', gap: 16 }}>
        {window.VH_DATA.tips.map(([h, p]) =>
          <div key={h} style={{ display: 'flex', flexDirection: 'column', gap: 8, padding: 24, background: 'var(--surface-card)', border: 'var(--border-card)', borderRadius: 'var(--radius-lg)' }}><h3 style={{ fontSize: 20 }}>{h}</h3><p style={{ fontSize: 16, color: 'var(--text-2)' }}>{p}</p></div>)}
      </div>
    </Section>
    <VHFooter m={m} house={house} lang={lang} />
    {m && <StickyBookBar position="sticky" from={house.from} unit={window.VH_I18N.T(lang).nightS} cta={window.vhT(lang, 'price')} onCta={() => onNav('boeken')} />}
  </div>;
}
window.VHOmgeving = OmgevingScreen;
})();
