{"version":3,"file":"ChapterAccessibility.CDnstO-4.mjs","names":["React.useState","React.useRef","React.useCallback","_Fragment"],"sources":["https:/framerusercontent.com/modules/4MZUYoHMZhBzTTFTr7P7/g5J8Y3WLX6SrS1wjVyS5/ChapterAccessibility.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import*as React from\"react\";import{useIsStaticRenderer}from\"framer\";// The Framer track retains its native 0 / -2100 / -4200 scroll keyframes.\n// Only their measured distance is calibrated here. All copy, marks, caption\n// variants, scroll targets and sticky layout remain editable native layers.\nconst NATIVE_TRAVEL=4200;const STAGE='[data-framer-name=\"Chapter - Pinned reading stage\"]';const TRACK='[data-framer-name=\"Sentence - Horizontal track\"]';const SENTENCE='[data-framer-name=\"Sentence - Edit the whole thought here\"]';const CORRECTION=\"--ruckus-chapter-correction\";// Optional campaign images set between the sentence parts. Native, linked, removable.\nconst INLINE='[data-framer-name^=\"Inline image\"]';const CHAPTER=\"[data-ruckus-chapter]\";// Keep CSS identical on the server, the first client render and later renders.\n// Framer's SSR escapes ordinary <style>{text}</style> children as &quot;.\n// A style element is raw text in HTML, so those entities are not decoded:\n// selectors break before hydration and React reports a text mismatch (#425).\n// This trusted, module-owned stylesheet contains no buyer-provided content.\nfunction fallbackCSS(scope){return`${scope}{height:auto!important;min-height:0!important}\n${scope} ${STAGE}{position:relative!important;height:auto!important;min-height:0!important;overflow:visible!important;gap:32px!important}\n${scope} [data-framer-name^=\"Scroll -\"]{display:none!important}\n${scope} ${TRACK}{width:100%!important;transform:none!important;translate:none!important;flex-wrap:wrap!important;column-gap:16px!important;row-gap:8px!important}\n${scope} ${TRACK} > [data-framer-name^=\"Sentence\"]{width:auto!important;max-width:100%!important;white-space:normal!important}\n${scope} ${INLINE}{width:84px!important;height:56px!important;border-radius:12px!important}\n${scope} ${TRACK} h2{font-size:56px!important;line-height:1.05!important;letter-spacing:-2px!important;white-space:normal!important}\n${scope} [data-framer-name^=\"Beat 0\"],${scope} [data-framer-name=\"Chapter label\"]{position:relative!important;inset:auto!important;opacity:1!important;transform:none!important;max-width:100%!important}\n${scope} [data-framer-name^=\"Mark -\"]{display:none!important}`;}const CHAPTER_CSS=`${CHAPTER} ${TRACK} em{font-family:\"Instrument Serif\",serif!important;font-weight:400!important;font-variation-settings:normal!important;letter-spacing:-3px!important}\n${CHAPTER} ${TRACK}{translate:var(${CORRECTION},0px) 0}\n${fallbackCSS(`${CHAPTER}:not([data-ruckus-chapter-ready])`)}\n@media(prefers-reduced-motion:reduce){${fallbackCSS(CHAPTER)}}`;function nativeX(element){const transform=element.style.transform;if(!transform||transform===\"none\")return 0;try{return new DOMMatrixReadOnly(transform).m41;}catch{return 0;}}function lastWordRect(sentence){const emphasis=sentence.querySelectorAll(\"em\");if(emphasis.length)return emphasis[emphasis.length-1].getBoundingClientRect();const walker=document.createTreeWalker(sentence,NodeFilter.SHOW_TEXT);let finalText=null;let node;while(node=walker.nextNode()){if(node.textContent?.trim())finalText=node;}if(!finalText)return null;const match=finalText.data.match(/\\S+\\s*$/);if(!match||match.index===undefined)return null;const range=document.createRange();range.setStart(finalText,match.index);range.setEnd(finalText,finalText.length);return range.getBoundingClientRect();}export function withChapterAccessibility(Component){return /*#__PURE__*/React.forwardRef(function ChapterAccessibility(props,ref){const isStatic=useIsStaticRenderer();const[ready,setReady]=React.useState(false);const rootRef=React.useRef(null);const attachRef=React.useCallback(node=>{rootRef.current=node;if(typeof ref===\"function\")ref(node);else if(ref)ref.current=node;},[ref]);React.useEffect(()=>{setReady(true);},[]);React.useEffect(()=>{const root=rootRef.current;if(!root||isStatic||!ready)return;const reduced=window.matchMedia(\"(prefers-reduced-motion: reduce)\");const previous=root.style.getPropertyValue(CORRECTION);let active=true;let frame=0;let track=null;let stage=null;let sentence=null;let ratio=0;let currentCorrection=0;let previousNativeX=Number.NaN;const writeCorrection=value=>{if(Math.abs(value-currentCorrection)<.01)return;currentCorrection=value;// Write to the ancestor, never the observed track's style.\nroot.style.setProperty(CORRECTION,`${value.toFixed(3)}px`);};const update=()=>{if(!active||!track||reduced.matches)return;const x=nativeX(track);if(x===previousNativeX)return;previousNativeX=x;writeCorrection(x*ratio);};const transformObserver=new MutationObserver(update);const resizeObserver=new ResizeObserver(()=>queueMeasurement());const measure=()=>{frame=0;if(!active)return;const nextStage=root.querySelector(STAGE);const nextTrack=root.querySelector(TRACK);const nextSentence=root.querySelector(SENTENCE);if(track!==nextTrack||stage!==nextStage||sentence!==nextSentence){transformObserver.disconnect();resizeObserver.disconnect();track=nextTrack;stage=nextStage;sentence=nextSentence;resizeObserver.observe(root);if(track)transformObserver.observe(track,{attributes:true,attributeFilter:[\"style\"]});if(stage)resizeObserver.observe(stage);if(sentence)resizeObserver.observe(sentence);previousNativeX=Number.NaN;}if(reduced.matches||!track||!stage||!sentence){ratio=0;writeCorrection(0);root.removeAttribute(\"data-ruckus-chapter-travel\");return;}const stageRect=stage.getBoundingClientRect();const end=lastWordRect(sentence);if(!end||stageRect.width<1)return;const x=nativeX(track);// Measured rects include any page zoom (big-screen fit); the\n// native transform is in unzoomed px. Compare in one unit.\nconst zoom=parseFloat(getComputedStyle(document.body).zoom)||1;const untransformedEndCenter=(end.left+end.width/2)/zoom-x-currentCorrection;const distance=Math.max(0,untransformedEndCenter-(stageRect.left+stageRect.width/2)/zoom);ratio=distance/NATIVE_TRAVEL-1;root.setAttribute(\"data-ruckus-chapter-travel\",distance.toFixed(2));previousNativeX=Number.NaN;update();};function queueMeasurement(){if(active&&!frame)frame=requestAnimationFrame(measure);}// Breakpoint swaps replace native descendants; text edits can alter\n// the final-word width. Neither observer runs an animation loop.\nconst contentObserver=new MutationObserver(queueMeasurement);contentObserver.observe(root,{childList:true,subtree:true,characterData:true});reduced.addEventListener(\"change\",queueMeasurement);window.addEventListener(\"resize\",queueMeasurement,{passive:true});document.fonts?.ready.then(queueMeasurement);document.fonts?.addEventListener(\"loadingdone\",queueMeasurement);queueMeasurement();return()=>{active=false;cancelAnimationFrame(frame);transformObserver.disconnect();resizeObserver.disconnect();contentObserver.disconnect();reduced.removeEventListener(\"change\",queueMeasurement);window.removeEventListener(\"resize\",queueMeasurement);document.fonts?.removeEventListener(\"loadingdone\",queueMeasurement);if(previous)root.style.setProperty(CORRECTION,previous);else root.style.removeProperty(CORRECTION);root.removeAttribute(\"data-ruckus-chapter-travel\");};},[isStatic,ready]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:CHAPTER_CSS}}),/*#__PURE__*/_jsx(Component,{...props,ref:attachRef,\"data-ruckus-chapter\":\"\",\"data-ruckus-chapter-ready\":ready&&!isStatic?\"\":undefined})]});});}export function withViewCursor(Component){return /*#__PURE__*/React.forwardRef(function ViewCursor(props,ref){return /*#__PURE__*/_jsx(Component,{...props,ref:ref,\"data-ruckus-view\":\"\"});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withViewCursor\":{\"type\":\"reactHoc\",\"name\":\"withViewCursor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withChapterAccessibility\":{\"type\":\"reactHoc\",\"name\":\"withChapterAccessibility\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ChapterAccessibility.map"],"mappings":"4NASA,SAAS,EAAY,EAAM,CAAC,MAAM,GAAG,EAAM;EACzC,EAAM,GAAG,EAAM;EACf,EAAM;EACN,EAAM,GAAG,EAAM;EACf,EAAM,GAAG,EAAM;EACf,EAAM,GAAG,EAAO;EAChB,EAAM,GAAG,EAAM;EACf,EAAM,gCAAgC,EAAM;EAC5C,EAAM,sDAAuD,CAGC,SAAS,EAAQ,EAAQ,CAAC,IAAM,EAAU,EAAQ,MAAM,UAAU,GAAG,CAAC,GAAW,IAAY,OAAO,MAAO,GAAE,GAAG,CAAC,OAAO,IAAI,kBAAkB,CAAS,CAAC,CAAC,GAAI,MAAM,CAAC,MAAO,EAAE,CAAC,CAA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