// ============================================================
// Monarch — L'Encyclopédie patrimoniale du dirigeant (composant)
// Définit window.EncyclopediePage. Requiert React + window.MONARCH_ENCYCLO.
// ============================================================
(function () {
const { useState, useEffect, useRef } = React;
const C = {
vert: "#1E3A2B", ivoire: "#F7F3E9", encre: "#222222", or: "#C8A45C",
fond: "#FDFCF9", gris: "#6B6B66", grisC: "#9A9A92", trait: "#E6E1D4", blanc: "#FFFFFF"
};
const SERIF = "'Fraunces', Georgia, serif";
const BODY = "'Archivo', system-ui, sans-serif";
const CAL_URL = "https://cal.eu/hugo-groslambert/diagnostic1h";
const TYPES = {
notion: { label: "Notion", color: C.vert, bg: "#E8EEEA" },
dispositif: { label: "Dispositif", color: "#9A7B22", bg: "#F4ECD7" },
montage: { label: "Montage", color: "#3D5468", bg: "#E7EDF2" },
cas: { label: "Cas pratique", color: "#5C6F5C", bg: "#E9EEE9" },
glossaire: { label: "Glossaire", color: "#6B6B66", bg: "#ECEAE3" }
};
function injectStyles() {
if (document.getElementById("encyclo-styles")) return;
const s = document.createElement("style");
s.id = "encyclo-styles";
s.textContent = `
.enc-body h2 { font-family:${SERIF}; font-size:clamp(22px,2.6vw,28px); font-weight:500; color:${C.vert}; letter-spacing:-0.01em; margin:40px 0 14px; }
.enc-body h3 { font-family:${SERIF}; font-size:20px; font-weight:500; color:${C.vert}; margin:28px 0 10px; }
.enc-body p { font-family:${BODY}; font-size:17px; line-height:1.7; color:${C.encre}; margin:0 0 18px; }
.enc-body ul { font-family:${BODY}; font-size:17px; line-height:1.7; color:${C.encre}; padding-left:22px; margin:0 0 18px; }
.enc-body li { margin-bottom:8px; }
.enc-body strong { color:${C.encre}; font-weight:700; }
.enc-body a[data-entry] { color:${C.vert}; text-decoration:none; border-bottom:1px solid ${C.or}; cursor:pointer; padding-bottom:1px; }
.enc-body a[data-entry]:hover { background:${C.ivoire}; }
.enc-body span[data-def] { border-bottom:1px dotted ${C.or}; cursor:help; position:relative; }
.enc-body span[data-def]:hover::after { content:attr(data-def); position:absolute; left:0; top:calc(100% + 8px); width:260px; background:${C.vert}; color:#fff; font-family:${BODY}; font-size:12.5px; font-weight:400; line-height:1.5; letter-spacing:0; text-transform:none; padding:10px 12px; border-radius:3px; z-index:40; box-shadow:0 12px 30px -12px rgba(0,0,0,.4); }
.enc-toc a.on { color:${C.vert} !important; font-weight:600 !important; }
.enc-toc a.on { color:${C.vert} !important; font-weight:600 !important; }
.enc-mobilebar { display:none; }
@media (max-width:1040px){ .enc-toc { display:none !important; } }
@media (max-width:900px){
.enc-sidebar { display:none !important; }
.enc-grid { grid-template-columns:1fr !important; }
.enc-entry-grid { grid-template-columns:1fr !important; gap:0 !important; }
.enc-shell { grid-template-columns:1fr !important; gap:0 !important; }
.enc-mobilebar { display:block !important; }
}
`;
document.head.appendChild(s);
}
function slugifyH(s) {
return (s || "").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
}
function Badge({ type }) {
const t = TYPES[type] || TYPES.notion;
return {t.label} ;
}
// ---------- Sidebar ----------
function Sidebar({ data, current, onOpen, query, setQuery }) {
const q = query.trim().toLowerCase();
const TYPE_ORDER = ["notion", "dispositif", "montage", "cas", "glossaire"];
// modules dans l'ordre déclaré, + tout module utilisé non listé
const modNames = (data.modules || []).map((m) => m.name);
(data.entries || []).forEach((e) => { if (e.module && !modNames.includes(e.module)) modNames.push(e.module); });
return (
⌕
setQuery(e.target.value)} placeholder="Rechercher…"
style={{ width: "100%", fontFamily: BODY, fontSize: 14, color: C.encre, background: "#fff", border: `1px solid ${C.trait}`, borderRadius: 2, padding: "10px 12px 10px 32px", outline: "none" }} />
{modNames.map((modName) => {
const inMod = (data.entries || []).filter((e) => e.module === modName && (!q || (e.title + " " + e.definition).toLowerCase().includes(q)));
if (!inMod.length) return null;
const groups = TYPE_ORDER.map((tp) => ({ tp, list: inMod.filter((e) => e.type === tp) })).filter((g) => g.list.length);
return (
{modName}
{groups.map((g) =>
{(TYPES[g.tp] || {}).label || g.tp}
{g.list.map((e) => {
const on = current === e.slug;
return (
onOpen(e.slug)}
style={{ display: "block", width: "100%", textAlign: "left", fontFamily: BODY, fontSize: 13.5, lineHeight: 1.4, padding: "6px 0 6px 14px", marginLeft: "-1px", borderLeft: `2px solid ${on ? C.vert : "transparent"}`, color: on ? C.vert : C.encre, fontWeight: on ? 600 : 500, background: "none", border: "none", borderLeftWidth: 2, borderLeftStyle: "solid", cursor: "pointer" }}>
{e.title}
);
})}
)}
);
})}
);
}
// ---------- Overview (index) ----------
function Overview({ data, onOpen, query }) {
const q = (query || "").trim().toLowerCase();
const azList = data.entries.slice().sort((a, b) => a.title.localeCompare(b.title, "fr"));
// Mode recherche : liste plate filtrée
if (q) {
const hits = data.entries.filter((e) => (e.title + " " + e.definition + " " + (e.body || "").replace(/<[^>]+>/g, " ")).toLowerCase().includes(q));
return (
Recherche
{hits.length} résultat{hits.length > 1 ? "s" : ""}
pour « {query.trim()} »
{hits.length === 0 ?
Aucune entrée ne correspond. Essayez un autre terme.
:
{hits.map((e) =>
onOpen(e.slug)}
style={{ textAlign: "left", background: "#fff", border: `1px solid ${C.trait}`, borderRadius: 2, padding: "18px 20px", cursor: "pointer" }}
onMouseEnter={(ev) => ev.currentTarget.style.borderColor = C.or}
onMouseLeave={(ev) => ev.currentTarget.style.borderColor = C.trait}>
{e.module}
{e.title}
{e.definition}
)}
}
);
}
return (
L'Encyclopédie patrimoniale
L'Encyclopédie patrimoniale du dirigeant
Le dirigeant, souverain sur son patrimoine.
Un corpus de référence interconnecté et pédagogique sur les holdings, la structuration de groupe, la fiscalité et la transmission du patrimoine des dirigeants. Chaque entrée va à l'essentiel — en euros et en conséquences concrètes.
{data.modules.map((mod) => {
const entries = data.entries.filter((e) => e.module === mod.name);
return (
{mod.name}
{mod.intro}
{entries.map((e) =>
onOpen(e.slug)}
style={{ textAlign: "left", background: "#fff", border: `1px solid ${C.trait}`, borderRadius: 2, padding: "20px 22px", cursor: "pointer", transition: "border-color .2s, box-shadow .2s" }}
onMouseEnter={(ev) => { ev.currentTarget.style.borderColor = C.or; ev.currentTarget.style.boxShadow = "0 10px 30px -18px rgba(0,0,0,.3)"; }}
onMouseLeave={(ev) => { ev.currentTarget.style.borderColor = C.trait; ev.currentTarget.style.boxShadow = "none"; }}>
{e.title}
{e.definition}
)}
);
})}
{/* Index A–Z */}
Index A–Z
{azList.map((e) =>
onOpen(e.slug)} style={{ fontFamily: BODY, fontSize: 14.5, color: C.encre, background: "none", border: "none", cursor: "pointer", padding: 0, borderBottom: `1px solid ${C.or}` }}>{e.title}
)}
Information générale à vocation pédagogique — ne constitue pas une consultation juridique.
{data.publishedAt &&
Encyclopédie mise à jour le {new Date(data.publishedAt).toLocaleDateString("fr-FR", { day: "numeric", month: "long", year: "numeric" })}.
}
);
}
// ---------- Entry ----------
function Entry({ data, entry, onOpen, goHome }) {
const bodyRef = useRef(null);
const [toc, setToc] = useState([]);
const [activeId, setActiveId] = useState("");
useEffect(() => {
const root = bodyRef.current;
if (!root) return;
// liens internes
root.querySelectorAll("a[data-entry]").forEach((a) => {
a.onclick = (ev) => { ev.preventDefault(); onOpen(a.getAttribute("data-entry")); };
});
// sommaire
const hs = Array.from(root.querySelectorAll("h2"));
const items = hs.map((h, i) => { const id = h.id || slugifyH(h.textContent) || "s" + i; h.id = id; h.style.scrollMarginTop = "100px"; return { id, text: h.textContent }; });
setToc(items);
const obs = new IntersectionObserver((es) => es.forEach((e) => { if (e.isIntersecting) setActiveId(e.target.id); }), { rootMargin: "-90px 0px -65% 0px" });
hs.forEach((h) => obs.observe(h));
return () => obs.disconnect();
}, [entry.slug]);
// JSON-LD
useEffect(() => {
const isTerm = entry.type === "notion" || entry.type === "glossaire";
const graph = [{
"@type": isTerm ? "DefinedTerm" : "Article",
"name": entry.title, "headline": entry.title, "description": entry.definition,
"inDefinedTermSet": isTerm ? "L'Encyclopédie patrimoniale du dirigeant — Monarch" : undefined,
"author": { "@type": "Person", "name": "Hugo Groslambert" },
"publisher": { "@type": "LegalService", "name": "Monarch", "areaServed": "Toulouse" }
}];
const old = document.getElementById("enc-jsonld"); if (old) old.remove();
const el = document.createElement("script"); el.type = "application/ld+json"; el.id = "enc-jsonld";
el.textContent = JSON.stringify({ "@context": "https://schema.org", "@graph": graph });
document.head.appendChild(el);
return () => { el.remove(); };
}, [entry.slug]);
const related = (entry.voirAussi || []).map((s) => data.entries.find((e) => e.slug === s)).filter(Boolean);
const crumb = { color: C.gris };
return (
{/* fil d'Ariane */}
Encyclopédie
/
{entry.module}
/
{entry.title}
Niveau : {entry.niveau}
{entry.title}
{/* Définition canonique — liseré or */}
Définition
{entry.definition}
{/* En bref */}
{entry.enBref && entry.enBref.length > 0 &&
En bref
{entry.enBref.map((b, i) =>
— {b}
)}
}
{/* Corps */}
{/* À ne pas confondre */}
{entry.confusion &&
}
{/* Voir aussi */}
{related.length > 0 &&
Voir aussi
{related.map((e) =>
onOpen(e.slug)}
style={{ textAlign: "left", background: "#fff", border: `1px solid ${C.trait}`, borderRadius: 2, padding: "14px 16px", cursor: "pointer" }}
onMouseEnter={(ev) => ev.currentTarget.style.borderColor = C.or}
onMouseLeave={(ev) => ev.currentTarget.style.borderColor = C.trait}>
{e.title}
)}
}
{/* Fondements */}
{entry.fondements && entry.fondements.length > 0 &&
Fondements
{entry.fondements.map((f, i) =>
{f} )}
}
{/* CTA discret */}
Dernière mise à jour : {entry.maj}
Information générale à vocation pédagogique — ne constitue pas une consultation juridique.
{/* ToC sticky droite */}
{toc.length > 0 &&
Sur cette page
}
);
}
// ---------- Page ----------
function EncyclopediePage({ go, slug }) {
useEffect(injectStyles, []);
const data = window.MONARCH_ENCYCLO || { modules: [], entries: [] };
const [query, setQuery] = useState("");
const [navOpen, setNavOpen] = useState(false);
const entry = slug ? data.entries.find((e) => e.slug === slug) : null;
const open = (s) => { setNavOpen(false); go("encyclo", s); window.scrollTo({ top: 0 }); };
const home = () => { go("encyclo"); window.scrollTo({ top: 0 }); };
// recherche depuis le mobile : on revient à l'index (qui affiche les résultats)
const onMobileSearch = (v) => {
setQuery(v);
if (entry && v.trim()) { go("encyclo"); window.scrollTo({ top: 0 }); }
};
// liste des modules pour le tiroir mobile
const modNames = (data.modules || []).map((m) => m.name);
(data.entries || []).forEach((e) => { if (e.module && !modNames.includes(e.module)) modNames.push(e.module); });
return (
{/* Barre mobile : recherche + tiroir de navigation */}
⌕
onMobileSearch(e.target.value)} placeholder="Rechercher dans l'encyclopédie…"
style={{ width: "100%", fontFamily: BODY, fontSize: 15, color: C.encre, background: "#fff", border: `1px solid ${C.trait}`, borderRadius: 2, padding: "12px 38px 12px 36px", outline: "none" }} />
{query && setQuery("")} aria-label="Effacer" style={{ position: "absolute", right: 8, top: "50%", transform: "translateY(-50%)", background: "none", border: "none", color: C.grisC, fontSize: 18, cursor: "pointer", padding: 6 }}>× }
setNavOpen((o) => !o)} style={{ marginTop: 10, width: "100%", display: "flex", alignItems: "center", justifyContent: "space-between", fontFamily: BODY, fontSize: 14, fontWeight: 600, color: C.vert, background: "#fff", border: `1px solid ${C.trait}`, borderRadius: 2, padding: "11px 14px", cursor: "pointer" }}>
Parcourir par module
▾
{navOpen &&
{modNames.map((mod) => {
const inMod = (data.entries || []).filter((e) => e.module === mod);
if (!inMod.length) return null;
return (
{mod}
{inMod.map((e) =>
open(e.slug)}
style={{ display: "block", width: "100%", textAlign: "left", fontFamily: BODY, fontSize: 14.5, lineHeight: 1.4, padding: "8px 0", color: slug === e.slug ? C.vert : C.encre, fontWeight: slug === e.slug ? 600 : 500, background: "none", border: "none", borderBottom: `1px solid ${C.trait}`, cursor: "pointer" }}>
{e.title}
)}
);
})}
}
);
}
window.EncyclopediePage = EncyclopediePage;
})();