// Main app — hash router + tweaks integration
const { useState: useStateA, useEffect: useEffectA } = React;
function parseHash() {
const h = (window.location.hash || "#/").replace(/^#/, "");
const parts = h.split("/").filter(Boolean);
if (parts.length === 0) return { name: "home" };
if (parts[0] === "collections") return { name: "collections" };
if (parts[0] === "collection" && parts[1]) return { name: "collection", slug: parts[1] };
if (parts[0] === "product" && parts[1]) return { name: "product", id: parts[1] };
if (parts[0] === "the-artist") return { name: "artist" };
if (parts[0] === "the-craft") return { name: "craft" };
if (parts[0] === "showroom") return { name: "showroom" };
if (parts[0] === "contact") return { name: "contact" };
return { name: "home" };
}
function routeToHash(r) {
switch (r.name) {
case "home": return "#/";
case "collections": return "#/collections";
case "collection": return `#/collection/${r.slug}`;
case "product": return `#/product/${r.id}`;
case "artist": return "#/the-artist";
case "craft": return "#/the-craft";
case "showroom": return "#/showroom";
case "contact": return "#/contact";
default: return "#/";
}
}
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
"hero": "p14",
"accent": "#7A2E3B",
"type": "cormorant",
"showLotusPattern": true
}/*EDITMODE-END*/;
function App() {
const [route, setRoute] = useStateA(parseHash());
const [tweaks, setTweak] = useTweaks(TWEAK_DEFAULTS);
useEffectA(() => {
const on = () => setRoute(parseHash());
window.addEventListener("hashchange", on);
return () => window.removeEventListener("hashchange", on);
}, []);
const go = (r) => {
window.location.hash = routeToHash(r);
setRoute(r);
// Scroll to top on navigation
setTimeout(() => window.scrollTo({ top: 0, behavior: "instant" in window ? "instant" : "auto" }), 0);
};
// Push accent to CSS var
useEffectA(() => {
document.documentElement.style.setProperty("--accent", tweaks.accent || "#7A2E3B");
if (tweaks.type === "fraunces") {
document.documentElement.style.setProperty("--serif", '"Fraunces", Georgia, serif');
} else {
document.documentElement.style.setProperty("--serif", '"Cormorant Garamond", "Fraunces", Georgia, serif');
}
}, [tweaks.accent, tweaks.type]);
let page = null;
if (route.name === "home") page =