{"version":3,"file":"CMS_Table_of_Contents_1.BWevbKSW.mjs","names":["useMemo","useCallback","useRef"],"sources":["https:/framerusercontent.com/modules/vf8nYpKBZXvXMYBRjj1w/W8BjFEr86T5e0bPz89Z7/CMS_Table_of_Contents_1.js"],"sourcesContent":["// User request: Create a Framer code file CMS_Table_of_Contents.tsx with (1) a default component named CMSTableOfContents and (2) a code override named withCmsHeadingAnchors.\n// CMSTableOfContents: render a compact accessible semantic nav with title default “On this page” and a multiline string control named items. Each line uses `Label | target-id`; parse valid lines to an ordered list of links. Include controls: show boolean, ariaLabel string, showTitle boolean, title string, items multiline string, text color, title color, border color, font selector, and gap. Links should smooth scroll to the matching document element ID and update the URL hash. The element needs adjustable styling through controls, not hard-coded project-specific values.\n// withCmsHeadingAnchors: wrap the existing canvas CMS Rich Text layer without changing its layout/style. After mount, find h2 headings within its root and add deterministic IDs. Map by startsWith: `LETTER TO SENATE JUDICIARY COMMITTEE:` -> `letter-to-senate`; `SENATE TESTIMONY:` -> `senate-testimony`. Map exact labels: `IN-HOUSE VIDEOS` -> `in-house-videos`, `TOOLS FOR SENATORS` -> `tools-for-senators`, `TV APPEARANCES` -> `tv-appearances`, `PODCAST APPEARANCES` -> `podcast-appearances`, `SUBSTACK PIECES` -> `substack-pieces`, `PRESS RELEASES` -> `press-releases`. Other h2s get safe kebab-case IDs, all IDs unique. Keep the component client-safe and accessible.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{forwardRef,useCallback,useEffect,useMemo,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function CMSTableOfContents(props){const{show,ariaLabel,showTitle,title,items,textColor,titleColor,borderColor,font,gap}=props;const parsedItems=useMemo(()=>{return items.split(\"\\n\").map(line=>line.trim()).filter(Boolean).map(line=>{const[labelPart,idPart]=line.split(\"|\");const label=(labelPart??\"\").trim();const targetId=(idPart??\"\").trim().replace(/^#/,\"\");return{label,targetId};}).filter(item=>item.label.length>0&&item.targetId.length>0);},[items]);const handleLinkClick=useCallback((event,targetId)=>{event.preventDefault();if(typeof document===\"undefined\"||typeof window===\"undefined\")return;const targetElement=document.getElementById(targetId);if(!targetElement)return;targetElement.scrollIntoView({behavior:\"smooth\",block:\"start\"});window.history.pushState(null,\"\",`#${targetId}`);},[]);if(!show)return null;return /*#__PURE__*/_jsxs(\"nav\",{\"aria-label\":ariaLabel,style:{position:\"relative\",width:\"100%\",boxSizing:\"border-box\",border:`1px solid ${borderColor}`,borderRadius:8,padding:12,background:\"transparent\"},children:[showTitle?/*#__PURE__*/_jsx(\"p\",{style:{margin:0,marginBottom:gap,color:titleColor,fontSize:font.fontSize,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,fontFamily:font.fontFamily,fontWeight:font.fontWeight,fontStyle:font.fontStyle,textAlign:font.textAlign},children:title}):null,/*#__PURE__*/_jsx(\"ol\",{style:{margin:0,paddingLeft:18,display:\"flex\",flexDirection:\"column\",gap},children:parsedItems.map(item=>/*#__PURE__*/_jsx(\"li\",{children:/*#__PURE__*/_jsx(\"a\",{href:`#${item.targetId}`,onClick:event=>handleLinkClick(event,item.targetId),style:{color:textColor,textDecoration:\"none\",fontSize:font.fontSize,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,fontFamily:font.fontFamily,fontWeight:font.fontWeight,fontStyle:font.fontStyle,textAlign:font.textAlign},children:item.label})},item.targetId))})]});}function toSafeKebabCase(value){const cleaned=value.normalize(\"NFKD\").replace(/[^\\w\\s-]/g,\"\").trim().toLowerCase().replace(/[\\s_]+/g,\"-\").replace(/-+/g,\"-\");return cleaned||\"section\";}function getMappedHeadingId(label){const normalized=label.trim().toUpperCase();if(normalized.startsWith(\"LETTER TO SENATE JUDICIARY COMMITTEE:\"))return\"letter-to-senate\";if(normalized.startsWith(\"SENATE TESTIMONY:\"))return\"senate-testimony\";const exactMap={\"IN-HOUSE VIDEOS\":\"in-house-videos\",\"TOOLS FOR SENATORS\":\"tools-for-senators\",\"TV APPEARANCES\":\"tv-appearances\",\"PODCAST APPEARANCES\":\"podcast-appearances\",\"SUBSTACK PIECES\":\"substack-pieces\",\"PRESS RELEASES\":\"press-releases\"};return exactMap[normalized]??toSafeKebabCase(label);}export function withCmsHeadingAnchors(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const rootRef=useRef(null);const setRefs=useCallback(node=>{rootRef.current=node;if(typeof ref===\"function\"){ref(node);}else if(ref&&typeof ref===\"object\"){ref.current=node;}},[ref]);useEffect(()=>{if(typeof document===\"undefined\")return;const root=rootRef.current;if(!root)return;const applyIds=()=>{const headings=Array.from(root.querySelectorAll(\"h2\"));const usedIds=new Set;headings.forEach(heading=>{const text=(heading.textContent??\"\").trim();const baseId=getMappedHeadingId(text);let nextId=baseId;let suffix=2;while(usedIds.has(nextId)){nextId=`${baseId}-${suffix}`;suffix+=1;}heading.id=nextId;usedIds.add(nextId);});};applyIds();const observer=new MutationObserver(()=>{applyIds();});observer.observe(root,{childList:true,subtree:true,characterData:true});return()=>observer.disconnect();},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:setRefs});});}addPropertyControls(CMSTableOfContents,{show:{type:ControlType.Boolean,title:\"Show\",defaultValue:true},ariaLabel:{type:ControlType.String,title:\"Aria Label\",defaultValue:\"Table of contents\"},showTitle:{type:ControlType.Boolean,title:\"Show Title\",defaultValue:true},title:{type:ControlType.String,title:\"Title\",defaultValue:\"On this page\"},items:{type:ControlType.String,title:\"Items\",defaultValue:\"In-House Videos | in-house-videos\\nTools for Senators | tools-for-senators\\nTV Appearances | tv-appearances\",displayTextArea:true},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},titleColor:{type:ControlType.Color,title:\"Title Color\",defaultValue:\"#000000\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#EEEEEE\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:8,min:0,max:32,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSTableOfContents\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"withCmsHeadingAnchors\":{\"type\":\"reactHoc\",\"name\":\"withCmsHeadingAnchors\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMS_Table_of_Contents_1.map"],"mappings":"sSAMG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,OAAK,YAAU,YAAU,QAAM,QAAM,YAAU,aAAW,cAAY,OAAK,OAAK,EAAY,EAAYA,MAAoB,EAAM,MAAM;CAAI,CAAC,CAAC,IAAI,GAAM,EAAK,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,GAAM,CAAC,GAAK,CAAC,EAAU,GAAQ,EAAK,MAAM,GAAG,EAAyF,MAAM,CAAC,OAAjF,GAAW,GAAA,CAAI,KAAsE,EAAE,UAAjD,GAAQ,GAAA,CAAI,KAAK,CAAC,CAAC,QAAQ,KAAK,EAAwB,CAAC,CAAE,CAAC,CAAC,CAAC,OAAO,GAAM,EAAK,MAAM,OAAO,GAAG,EAAK,SAAS,OAAO,CAAC,EAAI,CAAC,CAAK,CAAC,EAAQ,EAAgBC,GAAa,EAAM,IAAW,CAAwB,GAAvB,EAAM,eAAe,EAAK,OAAO,SAAW,KAAoB,IAAS,OAAY,OAAO,IAAM,EAAc,SAAS,eAAe,CAAQ,EAAM,IAAqB,EAAc,eAAe,CAAC,SAAS,SAAS,MAAM,OAAO,CAAC,EAAE,EAAO,QAAQ,UAAU,KAAK,GAAG,IAAI,GAAU,EAAE,EAAE,CAAC,CAAC,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