/* NEO Orthodontics - Black Friday open week: app shell, location data, tweaks */
(function () {
  const { useTweaks, TweaksPanel, TweakSection, TweakSelect, TweakText, TweakToggle } = window;
  const W = window;

  const day = (d, h) => [d, h];
  const SAT = "8:30am - 12:30pm, emergency on call only";
  const LOCATIONS = {
    Ashington: {
      town: "Ashington", site: "Ashington", name: "NEO Orthodontics Ashington", address: "79 Station Road, Ashington, Northumberland, NE63 8RS",
      phone: "0167 0812 750", tel: "+441670812750",
      hours: [day("Monday", "8:30am - 5:00pm"), day("Tuesday", "8:30am - 5:00pm"), day("Wednesday", "8:30am - 5:00pm"), day("Thursday", "8:30am - 8:00pm"), day("Friday", "8:30am - 5:00pm"), day("Saturday", SAT), day("Sunday", "Closed")],
      phonesNote: "Phones are closed from 12:30pm to 1:30pm.",
      parkingIcon: "car", accessTitle: "Free parking and evening appointments", accessText: "Free on-site parking, with evening appointments until 8:00pm on Thursdays.",
    },
    Alnwick: {
      town: "Alnwick", site: "Alnwick", name: "NEO Orthodontics Alnwick", address: "2 Lagny Street, Alnwick, Northumberland, NE66 1NJ",
      phone: "01665 517 855", tel: "+441665517855",
      hours: [day("Monday", "8:30am - 5:00pm"), day("Tuesday", "8:30am - 5:00pm"), day("Wednesday", "8:30am - 5:00pm"), day("Thursday", "8:30am - 5:00pm"), day("Friday", "8:30am - 5:00pm"), day("Saturday", SAT), day("Sunday", "Closed")],
      phonesNote: "Phones are closed from 12:30pm to 1:30pm.",
      parkingIcon: "car", accessTitle: "Free parking on site", accessText: "Free on-site parking, so getting to your appointment is easy.",
    },
    Quayside: {
      town: "Newcastle", site: "Quayside", name: "NEO Orthodontics Quayside", address: "Hanover Mill, 98-100 Quayside, Newcastle upon Tyne, NE1 3RF",
      phone: "0191 232 6952", tel: "+441912326952",
      hours: [day("Monday", "8:30am - 8:00pm"), day("Tuesday", "8:30am - 5:00pm"), day("Wednesday", "8:30am - 8:00pm"), day("Thursday", "8:30am - 5:00pm"), day("Friday", "8:30am - 5:00pm"), day("Saturday", SAT), day("Sunday", "Closed")],
      phonesNote: "Phones are closed from 1:30pm to 2:30pm.",
      parkingIcon: "clock", accessTitle: "Central, with evening appointments", accessText: "Five minutes' walk from Newcastle train station, with evening appointments until 8:00pm on Mondays and Wednesdays.",
    },
    "West Road": {
      town: "Newcastle", site: "West Road", name: "NEO Orthodontics West Road", address: "Unit 3, Condercum House, 171 West Road, Newcastle upon Tyne, NE15 6PQ",
      phone: "0191 462 2262", tel: "+441914622262",
      hours: [day("Monday", "8:30am - 8:00pm"), day("Tuesday", "8:30am - 5:00pm"), day("Wednesday", "8:30am - 8:00pm"), day("Thursday", "8:30am - 5:00pm"), day("Friday", "8:30am - 5:00pm"), day("Saturday", SAT), day("Sunday", "Closed")],
      phonesNote: "",
      parkingIcon: "car", accessTitle: "Free parking and evening appointments", accessText: "Free on-site parking at Condercum House, with evening appointments until 8:00pm on Mondays and Wednesdays.",
      area: "west Newcastle", areas: "Fenham, Benwell, Elswick, Denton and Scotswood",
      findNote: "Condercum House is on West Road (A186), opposite Fenham Library, with free on-site parking, step-free access and a bus stop directly outside.",
      mapsApple: "https://maps.apple.com/?address=Unit%203,%20Condercum%20House,%20171%20West%20Road,%20Newcastle%20Upon%20Tyne,%20NE15%206PQ,%20England&auid=1616918184960121290&ll=54.976992,-1.663272&lsp=9902&q=Neo%20Orthodontics&t=m",
      mapsGoogle: "https://maps.app.goo.gl/dujEa17sYcEXp5kN6",
    },
  };

  const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
    "location": "West Road",
    "openWeek": "2nd - 6th November",
    "countdownEnd": "2026-11-06T17:00:00Z",
    "showCountdown": true
  }/*EDITMODE-END*/;

  function App() {
    const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);
    React.useEffect(() => {
      if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
      const sel = '.shead,.incx__head,.incx__row,.txp__panel,.split__copy,.split__img,.fin__img,.jhead,.jtrack,.whyx,.revx__fig,.tm,.faq details,.book .wrap,.find__info,.find__map';
      const els = [...document.querySelectorAll(sel)].filter(el => !el.closest('.hero'));
      els.forEach((el, i) => { el.classList.add('rv'); if (el.matches('.incx__row,.tm,.faq details,.txp__panel')) el.style.transitionDelay = ((i % 3) * 90) + 'ms'; });
      const io = new IntersectionObserver((ents) => ents.forEach(en => { if (en.isIntersecting) { en.target.classList.add('in'); io.unobserve(en.target); } }), { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
      els.forEach(el => io.observe(el));
      return () => io.disconnect();
    }, []);
    const cfg = { loc: LOCATIONS[t.location] || LOCATIONS["West Road"], openWeek: t.openWeek, countdownEnd: t.countdownEnd, showCountdown: t.showCountdown };
    return (
      <React.Fragment>
        <W.NeoHeader cfg={cfg} />
        <main>
          <W.NeoMarquee cfg={cfg} />
          <W.NeoHero cfg={cfg} />
          <W.NeoIncluded cfg={cfg} />
          <W.NeoTreatments />
          <W.NeoFinance />
          <W.NeoJourney cfg={cfg} />
          <W.NeoWhy cfg={cfg} />
          <W.NeoReviews />
          <W.NeoWhyStraighten />
          <W.NeoTeam />
          <W.NeoFaq cfg={cfg} />
          <W.NeoBookStrip cfg={cfg} />
          <W.NeoFindUs cfg={cfg} />
        </main>
        <W.NeoFooter cfg={cfg} />
        <W.NeoMobileBar cfg={cfg} />
        <TweaksPanel>
          <TweakSection label="Location" />
          <TweakSelect label="Practice" value={t.location} options={Object.keys(LOCATIONS)} onChange={(v) => setTweak("location", v)} />
          <TweakSection label="Offer dates" />
          <TweakText label="Open week" value={t.openWeek} onChange={(v) => setTweak("openWeek", v)} />
          <TweakText label="Countdown ends (ISO)" value={t.countdownEnd} onChange={(v) => setTweak("countdownEnd", v)} />
          <TweakToggle label="Show countdown" value={t.showCountdown} onChange={(v) => setTweak("showCountdown", v)} />
        </TweaksPanel>
      </React.Fragment>
    );
  }
  ReactDOM.createRoot(document.getElementById("root")).render(<App />);
})();
