{"version":3,"file":"Footnote_code.BlTY0bJE.mjs","names":["useRef","RichText"],"sources":["https:/framerusercontent.com/modules/wpUdpYQvrTqFKqJwHzHe/7SR5nZLrISDRb0crgRfQ/Footnote_code.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,RichText}from\"framer\";/**\n * Renders an essay's Body field via Framer's RichText, then finds every\n * inline `(n)` footnote marker parse.js produces (footnote refs come\n * through as inline code — `` `(1)` `` in markdown, `<code>(1)</code>`\n * once rendered) and turns it into a tap-to-expand note sourced from\n * the Footnotes CMS field, opening in place instead of jumping to the\n * bottom of the page. Bind `body` -> Body, `footnotes` -> Footnotes on\n * the Essay collection page template.\n *\n * Verified against real CMS data 2026-08-13 (`this-place-will-become-\n * your-tomb-probably`, synced live for this test). The `<code>(n)</code>`\n * marker assumption held. The footnotes-parsing assumption did NOT: a\n * synced Footnotes field renders as an actual `<ol><li>...</li></ol>`,\n * not the plain \"1. text\\n2. text\" lines this originally looked for --\n * as first written, every footnote would have silently failed to match\n * once wired to real data. Fixed to read list-item position instead of\n * a literal digit prefix, with the original line-based parsing kept as\n * a fallback for a hand-typed property-panel test. Footnote text can\n * carry real inline formatting (bold/italic) from Amanda's prose, so\n * the note now renders via innerHTML, not textContent.\n *\n * Fixed 2026-08-14: swapping the native Body text layer for this Code\n * Component broke the Archive's fonts site-wide. The Style panel's\n * \"Text Styles\" binding (the thing that maps H3/H4/H5/H6 to the\n * Madwoman/Scholar/Witness/Archivist voice fonts, and Paragraph to\n * the Archive's default serif) only exists for native Text/RichText\n * layers -- a Code Component wrapping <RichText> has no such control,\n * so it silently fell back to browser defaults. Confirmed live: the\n * component instance's Style panel has no Font/Text section at all.\n * Fix: hardcode the same font mappings the project's real Style Kit\n * defines (read directly from each style's Edit panel, not guessed),\n * scoped to this component's own container so nothing else is touched.\n */const VOICE_FONT_CSS=`\n  .essay-body-with-footnotes p {\n    font-family: \"Noto Serif Dives Akuru\", serif;\n    font-weight: 400;\n    font-size: 13px;\n    line-height: 1.3;\n  }\n  .essay-body-with-footnotes h3 {\n    font-family: \"Just Me Again Down Here\", cursive;\n    font-weight: 400;\n    font-style: normal;\n    font-size: 23px;\n    line-height: 1.4;\n  }\n  .essay-body-with-footnotes h4 {\n    font-family: \"Instrument Serif\", serif;\n    font-weight: 700;\n    font-style: italic;\n    font-size: 22px;\n    line-height: 1.4;\n  }\n  .essay-body-with-footnotes h5 {\n    font-family: \"Just Another Hand\", cursive;\n    font-weight: 400;\n    font-style: normal;\n    font-size: 18px;\n    line-height: 1.4;\n  }\n  .essay-body-with-footnotes h6 {\n    font-family: \"Zen Loop\", cursive;\n    font-weight: 700;\n    font-style: italic;\n    font-size: 16px;\n    line-height: 1.4;\n  }\n`;export default function EssayBodyWithFootnotes(props){const{body,footnotes,markerColor,noteColor}=props;const containerRef=useRef(null);useEffect(()=>{const container=containerRef.current;if(!container)return;const prefersReducedMotion=window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;// A synced Footnotes field arrives as a real ordered list --\n// \"<ol><li><p>text</p></li>...</ol>\" -- with no literal digit in\n// the markup; position in the list IS the footnote number. Read\n// each <li>'s innerHTML (not textContent) so bold/italic survives.\nconst noteMap={};const footnotesEl=document.createElement(\"div\");footnotesEl.innerHTML=String(footnotes||\"\");const listItems=Array.from(footnotesEl.querySelectorAll(\"li\"));if(listItems.length>0){listItems.forEach((li,i)=>{noteMap[String(i+1)]=li.innerHTML.trim();});}else{// Fallback: a hand-typed property-panel test value won't be\n// real Framer-rendered HTML -- accept plain \"1. text\" lines too.\nString(footnotes||\"\").split(\"\\n\").forEach(line=>{const m=line.match(/^\\s*(\\d+)\\.\\s+(.*)$/);if(m)noteMap[m[1]]=m[2];});}const cleanupFns=[];// Wires any not-yet-wired `(n)` <code> markers currently in the DOM.\n// Framer's RichText doesn't guarantee its HTML is committed in the\n// same tick this effect first runs (e.g. it can render one beat\n// after mount) -- a one-shot querySelectorAll here would silently\n// find zero markers and never look again, leaving every footnote\n// dead with no click handler. A MutationObserver below calls this\n// again whenever the container's content actually changes.\nconst wireFootnotes=()=>{const codeEls=Array.from(container.querySelectorAll(\"code\"));codeEls.forEach(el=>{const match=el.textContent?.trim().match(/^\\((\\d+)\\)$/);if(!match)return;const noteText=noteMap[match[1]];if(!noteText)return;if(el.dataset.footnoteWired)return;el.dataset.footnoteWired=\"true\";el.setAttribute(\"role\",\"button\");el.setAttribute(\"tabindex\",\"0\");el.setAttribute(\"aria-expanded\",\"false\");el.style.cursor=\"pointer\";el.style.userSelect=\"none\";const wrap=document.createElement(\"div\");wrap.style.display=\"grid\";wrap.style.gridTemplateRows=\"0fr\";if(!prefersReducedMotion){wrap.style.transition=\"grid-template-rows 0.28s ease\";}wrap.style.margin=\"0.3em 0 0.6em\";const inner=document.createElement(\"div\");inner.style.overflow=\"hidden\";const card=document.createElement(\"div\");card.style.borderLeft=`2px solid ${markerColor}`;card.style.background=noteColor;card.style.padding=\"0.6em 0.9em\";card.style.borderRadius=\"0 4px 4px 0\";card.style.fontStyle=\"italic\";card.style.fontSize=\"0.92em\";card.style.lineHeight=\"1.55\";card.innerHTML=noteText;inner.appendChild(card);wrap.appendChild(inner);const hostBlock=el.closest(\"p\")||el.parentElement;hostBlock?.insertAdjacentElement(\"afterend\",wrap);const toggle=()=>{const open=el.getAttribute(\"aria-expanded\")===\"true\";el.setAttribute(\"aria-expanded\",String(!open));el.style.background=!open?markerColor:\"\";el.style.color=!open?\"#fff\":\"\";wrap.style.gridTemplateRows=!open?\"1fr\":\"0fr\";};const onKey=e=>{if(e.key===\"Enter\"||e.key===\" \"){e.preventDefault();toggle();}};el.addEventListener(\"click\",toggle);el.addEventListener(\"keydown\",onKey);cleanupFns.push(()=>{el.removeEventListener(\"click\",toggle);el.removeEventListener(\"keydown\",onKey);wrap.remove();});});};wireFootnotes();const observer=new MutationObserver(()=>wireFootnotes());observer.observe(container,{childList:true,subtree:true});cleanupFns.push(()=>observer.disconnect());return()=>cleanupFns.forEach(fn=>fn());},[body,footnotes,markerColor,noteColor]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,className:\"essay-body-with-footnotes\",children:[/*#__PURE__*/_jsx(\"style\",{children:VOICE_FONT_CSS}),/*#__PURE__*/_jsx(RichText,{children:body})]});}addPropertyControls(EssayBodyWithFootnotes,{body:{type:ControlType.RichText,title:\"Body\"},footnotes:{type:ControlType.RichText,title:\"Footnotes\"},markerColor:{type:ControlType.Color,title:\"Marker Color\",defaultValue:\"#7a2331\"},noteColor:{type:ControlType.Color,title:\"Note Background\",defaultValue:\"#7a23310d\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EssayBodyWithFootnotes\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Footnote_code.map"],"mappings":"6MAmEE,SAAwB,EAAuB,EAAM,CAAC,GAAK,CAAC,OAAK,YAAU,cAAY,aAAW,EAAY,EAAaA,EAAO,IAAI,EAawyD,OAbtyD,MAAc,CAAC,IAAM,EAAU,EAAa,QAAQ,GAAG,CAAC,EAAU,OAAO,IAAM,EAAqB,EAAO,WAAW,kCAAkC,CAAC,CAAC,QAI9R,EAAQ,CAAC,EAAQ,EAAY,SAAS,cAAc,KAAK,EAAE,EAAY,UAAU,OAAO,GAAW,EAAE,EAAE,IAAM,EAAU,MAAM,KAAK,EAAY,iBAAiB,IAAI,CAAC,EAAK,EAAU,OAAO,EAAG,EAAU,SAAS,EAAG,IAAI,CAAC,EAAQ,OAAO,EAAE,CAAC,GAAG,EAAG,UAAU,KAAK,CAAE,CAAC,EAExQ,OAAO,GAAW,EAAE,CAAC,CAAC,MAAM;CAAI,CAAC,CAAC,QAAQ,GAAM,CAAC,IAAM,EAAE,EAAK,MAAM,qBAAqB,EAAK,IAAE,EAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,EAAG,IA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