{"version":3,"file":"TextFill.DS8J1FfZ.mjs","names":["React.useRef","React.useState","React.useMemo"],"sources":["https:/framerusercontent.com/modules/2v2xm4xO7scywIWcMLSO/nIOeETg4q9Pb194ZbBIs/TextFill.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * Scroll-driven text fill: characters sweep from a dim colour to the full colour as the block\n * travels up the viewport. Dependency-free port of the idea behind ObsidianUI's\n * \"Text Fill Animation\" (MIT, obsidianui.dev).\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TextFill(props){const{text,font,sizeDesktop,sizeTablet,sizePhone,lineHeight,letterSpacing,color,dimColor,start,end,tag,style,align}=props;const ref=React.useRef(null);const[size,setSize]=React.useState(sizeDesktop);const[count,setCount]=React.useState(-1)// -1 = everything filled (canvas, SSR-safe fallback below)\n;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const words=React.useMemo(()=>String(text||\"\").split(/\\s+/).filter(Boolean),[text]);const total=React.useMemo(()=>words.reduce((n,w)=>n+w.length,0),[words]);React.useEffect(()=>{if(isCanvas||!ref.current)return;const el=ref.current;const ro=new ResizeObserver(()=>{const w=window.innerWidth;setSize(w>=1200?sizeDesktop:w>=810?sizeTablet:sizePhone);});ro.observe(document.documentElement);let reduce=false;try{reduce=window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;}catch(e){}if(reduce)return()=>ro.disconnect();let raf=0;const update=()=>{raf=0;const r=el.getBoundingClientRect();const vh=window.innerHeight;const from=vh*start// block top reaches this line → 0\n;const to=vh*end// block bottom reaches this line → 1\n;const p=(from-r.top)/Math.max(1,from-to+r.height);setCount(Math.round(Math.min(1,Math.max(0,p))*total));};const onScroll=()=>{if(!raf)raf=requestAnimationFrame(update);};update();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll);return()=>{ro.disconnect();window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);if(raf)cancelAnimationFrame(raf);};},[isCanvas,total,start,end,sizeDesktop,sizeTablet,sizePhone]);const Tag=tag||\"p\";let index=0;return /*#__PURE__*/_jsx(Tag,{ref:ref,\"aria-label\":text,style:{...style,...font,margin:0,fontSize:size,lineHeight,letterSpacing:`${letterSpacing}em`,color:dimColor,textWrap:\"pretty\",textAlign:align||\"left\"},children:words.map((w,wi)=>/*#__PURE__*/_jsxs(\"span\",{\"aria-hidden\":\"true\",style:{display:\"inline-block\",whiteSpace:\"pre\"},children:[w.split(\"\").map((ch,ci)=>{const i=index++;const on=count<0||i<count;return /*#__PURE__*/_jsx(\"span\",{style:{color:on?color:dimColor,transition:\"color 0.35s ease\"},children:ch},ci);}),wi<words.length-1?\" \":\"\"]},wi))});}TextFill.defaultProps={text:\"Twelve routes. Eight countries. Never more than twelve travelers, and always a guide who calls the place home.\",sizeDesktop:56,sizeTablet:42,sizePhone:30,lineHeight:1.12,letterSpacing:-.03,color:\"#211D16\",dimColor:\"rgba(33, 29, 22, 0.22)\",start:.85,end:.45,tag:\"p\",align:\"left\"};addPropertyControls(TextFill,{text:{type:ControlType.String,title:\"Text\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"basic\"},sizeDesktop:{type:ControlType.Number,title:\"Size desktop\",min:16,max:400,defaultValue:56},sizeTablet:{type:ControlType.Number,title:\"Size tablet\",min:14,max:300,defaultValue:42},sizePhone:{type:ControlType.Number,title:\"Size phone\",min:12,max:200,defaultValue:30},lineHeight:{type:ControlType.Number,title:\"Line height\",min:.9,max:2,step:.01,defaultValue:1.12},letterSpacing:{type:ControlType.Number,title:\"Letter\",min:-.1,max:.2,step:.005,defaultValue:-.03},color:{type:ControlType.Color,title:\"Filled\",defaultValue:\"#211D16\"},dimColor:{type:ControlType.Color,title:\"Dim\",defaultValue:\"rgba(33, 29, 22, 0.22)\"},start:{type:ControlType.Number,title:\"Start (vh)\",min:.3,max:1.5,step:.05,defaultValue:.85},end:{type:ControlType.Number,title:\"End (vh)\",min:0,max:1.2,step:.05,defaultValue:.45},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"p\",\"h2\",\"h3\"],defaultValue:\"p\"},align:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],defaultValue:\"left\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextFill\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextFill.map"],"mappings":"2NAOG,SAAwB,EAAS,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,cAAY,aAAW,YAAU,aAAW,gBAAc,QAAM,WAAS,QAAM,MAAI,MAAI,QAAM,SAAO,EAAY,EAAIA,EAAa,IAAI,EAAO,CAAC,EAAK,GAASC,EAAe,CAAW,EAAO,CAAC,EAAM,GAAUA,EAAe,EAAE,EAClR,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAa,EAAMC,MAAkB,OAAO,GAAM,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,EAAE,CAAC,CAAI,CAAC,EAAQ,EAAMA,MAAkB,EAAM,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC,CAAK,CAAC,EAAE,MAAoB,CAAC,GAAG,GAAU,CAAC,EAAI,QAAQ,OAAO,IAAM,EAAG,EAAI,QAAc,EAAG,IAAI,mBAAmB,CAAC,IAAM,EAAE,EAAO,WAAW,EAAQ,GAAG,KAAK,EAAY,GAAG,IAAI,EAAW,CAAS,CAAE,CAAC,EAAE,EAAG,QAAQ,SAAS,eAAe,EAAE,IAAI,EAAO,GAAM,GAAG,CAAC,EAAO,EAAO,WAAW,kCAAkC,CAAC,CAAC,OAAQ,MA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