{"version":3,"file":"Stretchy_text.BWM0FuFP.mjs","names":["useMemo","useRef","useState","useCallback","__esmMin","pe","init_npm_react_18_3_1","ne","init_ssg_sandbox_shims","window","_e","c","init_jsx_runtime","ce","de","useSpring","motion","init_framer_motion_DhsWWWsN","init_framer_DDfsYcI0","ControlType","addPropertyControls","StretchyText","DEFAULT_FONT","props","followStrength","follow","chars","text","motionsRef","animControlsRef","activeIndexRef","originRef","draggingRef","reducedMotion","setReducedMotion","prefersReducedMotion","registerMotion","index","pair","stopAnims","control","handlePointerMove","active","deltaX","event","deltaY","isLineBreak","char","distance","getChainDistance","strength","handlePointerUp","animate","RELEASE_SPRING","handleLetterPointerDown","textAlign","font","style","ElasticLetter","DRAG_SPRING","isSpaceLike","init_Stretchy_text","from","to","lo","hi","i","x","y","onLetterPointerDown"],"sources":["https:/framerusercontent.com/modules/ZgONnMA3LSuXMDSQiMti/LKi00DVN0ia7nil56fjl/Stretchy_text.js"],"sourcesContent":["\"use client\";import{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useEffect,useMemo,useRef,useState}from\"react\";import{animate,motion,useSpring}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";const DEFAULT_FONT={fontFamily:\"Inter, system-ui, sans-serif\",fontWeight:600,fontSize:\"120px\",letterSpacing:\"-0.04em\",lineHeight:\"1em\",textAlign:\"center\"};const DRAG_SPRING={stiffness:520,damping:38,mass:.4};const RELEASE_SPRING={type:\"spring\",stiffness:240,damping:13,mass:.75};const prefersReducedMotion=()=>{if(typeof window===\"undefined\")return false;return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;};const isLineBreak=char=>char===\"\\n\";const isSpaceLike=char=>char===\" \"||char===\"\t\";/** Distance along the glyph chain on the same line; null if a newline breaks the path. Spaces count as characters. */const getChainDistance=(from,to,chars)=>{if(from===to)return 0;if(isLineBreak(chars[from])||isLineBreak(chars[to]))return null;const lo=Math.min(from,to);const hi=Math.max(from,to);for(let i=lo+1;i<hi;i+=1){if(isLineBreak(chars[i]))return null;}return hi-lo;};const ElasticLetter=({char,index,color,reducedMotion,registerMotion,onLetterPointerDown})=>{const x=useSpring(0,DRAG_SPRING);const y=useSpring(0,DRAG_SPRING);useEffect(()=>{if(isLineBreak(char)){registerMotion(index,null);return;}registerMotion(index,{x,y});return()=>registerMotion(index,null);},[char,index,registerMotion,x,y]);if(isLineBreak(char)){return /*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",style:{whiteSpace:\"pre\"},children:char});}return /*#__PURE__*/_jsx(motion.span,{\"aria-hidden\":\"true\",onPointerDown:event=>onLetterPointerDown(index,event),style:{x:reducedMotion?0:x,y:reducedMotion?0:y,display:\"inline-block\",color,cursor:reducedMotion?\"default\":\"grab\",touchAction:\"none\",userSelect:\"none\",WebkitUserSelect:\"none\",willChange:\"transform\",whiteSpace:isSpaceLike(char)?\"pre\":undefined},children:char===\" \"?\"\\xa0\":char});};/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 520\n * @framerIntrinsicHeight 160\n */export default function StretchyText(props){const{text=\"ELASTIC TEXT\",font=DEFAULT_FONT,color=\"#FFFFFF\",follow=12,style}=props;const safeFollow=Math.min(20,Math.max(0,Math.round(follow)));// Map 0–20 → 0–1 geometric falloff used along the letter chain\nconst followStrength=safeFollow/20;const chars=useMemo(()=>Array.from(text||\"STRETCHY\"),[text]);const motionsRef=useRef([]);const animControlsRef=useRef([]);const activeIndexRef=useRef(null);const originRef=useRef({x:0,y:0});const draggingRef=useRef(false);const[reducedMotion,setReducedMotion]=useState(false);useEffect(()=>{setReducedMotion(prefersReducedMotion());},[]);const registerMotion=useCallback((index,pair)=>{motionsRef.current[index]=pair;},[]);const stopAnims=useCallback(()=>{animControlsRef.current.forEach(control=>control.stop());animControlsRef.current=[];},[]);const handlePointerMove=useCallback(event=>{if(!draggingRef.current||activeIndexRef.current==null)return;const active=activeIndexRef.current;const deltaX=event.clientX-originRef.current.x;const deltaY=event.clientY-originRef.current.y;chars.forEach((char,index)=>{const pair=motionsRef.current[index];if(!pair||isLineBreak(char))return;const distance=getChainDistance(active,index,chars);// Same-line chain includes spaces; only newlines break the path\nif(distance==null){pair.x.set(0);pair.y.set(0);return;}if(distance===0){if(typeof pair.x.jump===\"function\"){pair.x.jump(deltaX);pair.y.jump(deltaY);}else{pair.x.set(deltaX);pair.y.set(deltaY);}return;}const strength=Math.pow(followStrength,distance);pair.x.set(deltaX*strength);pair.y.set(deltaY*strength);});},[chars,followStrength]);const handlePointerUp=useCallback(()=>{if(!draggingRef.current)return;draggingRef.current=false;activeIndexRef.current=null;stopAnims();motionsRef.current.forEach(pair=>{if(!pair)return;animControlsRef.current.push(animate(pair.x,0,RELEASE_SPRING),animate(pair.y,0,RELEASE_SPRING));});window.removeEventListener(\"pointermove\",handlePointerMove);window.removeEventListener(\"pointerup\",handlePointerUp);window.removeEventListener(\"pointercancel\",handlePointerUp);},[handlePointerMove,stopAnims]);const handleLetterPointerDown=useCallback((index,event)=>{if(reducedMotion)return;if(event.button!==0)return;event.preventDefault();event.currentTarget.setPointerCapture(event.pointerId);stopAnims();draggingRef.current=true;activeIndexRef.current=index;originRef.current={x:event.clientX,y:event.clientY};window.addEventListener(\"pointermove\",handlePointerMove);window.addEventListener(\"pointerup\",handlePointerUp);window.addEventListener(\"pointercancel\",handlePointerUp);},[reducedMotion,stopAnims,handlePointerMove,handlePointerUp]);useEffect(()=>{return()=>{stopAnims();window.removeEventListener(\"pointermove\",handlePointerMove);window.removeEventListener(\"pointerup\",handlePointerUp);window.removeEventListener(\"pointercancel\",handlePointerUp);};},[handlePointerMove,handlePointerUp,stopAnims]);const textAlign=font.textAlign??\"center\";const alignItems=textAlign===\"left\"||textAlign===\"start\"?\"flex-start\":textAlign===\"right\"||textAlign===\"end\"?\"flex-end\":\"center\";return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",display:\"flex\",flexDirection:\"column\",alignItems,justifyContent:\"center\",width:\"100%\",height:\"100%\",...style},children:/*#__PURE__*/_jsx(\"p\",{\"aria-label\":text,style:{...font,margin:0,color,textAlign,whiteSpace:\"pre-wrap\"},children:chars.map((char,index)=>/*#__PURE__*/_jsx(ElasticLetter,{char:char,index:index,color:color,reducedMotion:reducedMotion,registerMotion:registerMotion,onLetterPointerDown:handleLetterPointerDown},`${char}-${index}`))})});}StretchyText.defaultProps={text:\"ELASTIC TEXT\",font:{fontFamily:\"Inter, system-ui, sans-serif\",fontWeight:600,fontSize:\"120px\",letterSpacing:\"-0.04em\",lineHeight:\"1em\",variant:\"Semibold\",textAlign:\"center\"},color:\"#FFFFFF\",follow:12};addPropertyControls(StretchyText,{text:{type:ControlType.String,title:\"Text\",placeholder:\"STRETCHY\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",displayFontSize:true,displayTextAlignment:true,defaultValue:{fontSize:\"120px\",letterSpacing:\"-0.04em\",lineHeight:\"1em\",variant:\"Semibold\",textAlign:\"center\"}},color:{type:ControlType.Color,title:\"Color\"},follow:{type:ControlType.Number,title:\"Follow\",min:0,max:20,step:1,displayStepper:false,description:\"How strongly neighbors follow the dragged letter\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"StretchyText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerIntrinsicHeight\":\"160\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"520\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Stretchy_text.map"],"mappings":"A,8QAKG,SAAwBqB,EAAa,EAAM,CAAC,GAAK,CAAC,OAAK,eAAe,OAAKC,EAAa,QAAM,UAAU,SAAO,GAAG,SAAOC,EACtHC,EAD6I,KAAK,IAAI,GAAG,KAAK,IAAI,EAAE,KAAK,MAAMC,CAAM,CAAC,CAC9J,EAAE,GAASC,EAAM1B,MAAY,MAAM,KAAK2B,G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