{"version":3,"file":"Morphed_text.DFmSwpOs.mjs","names":["React.useRef","React.useId"],"sources":["https:/framerusercontent.com/modules/JYYpjhQlbdgk8esTZr0v/a5c7gM62oijnukov97q6/Morphed_text.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";export default function MorphedText(props){const{texts=[\"Launch\",\"Create\",\"Scale\"],transition=1.5,delay=.8,fontSize=170,color=\"#EEFF00\",font}=props;const isStatic=useIsStaticRenderer();const containerRef=React.useRef(null);const text1Ref=React.useRef(null);const text2Ref=React.useRef(null);const frameRef=React.useRef(null);const filterId=React.useId().replace(/:/g,\"\");React.useEffect(()=>{const text1=text1Ref.current;const text2=text2Ref.current;if(!text1||!text2)return;const firstText=texts?.[0]||\"Text\";text1.textContent=firstText;text2.textContent=\"\";text1.style.opacity=\"1\";text1.style.filter=\"none\";text2.style.opacity=\"0\";text2.style.filter=\"none\";},[texts]);React.useEffect(()=>{if(isStatic)return;if(!texts||texts.length<=1)return;const container=containerRef.current;const text1=text1Ref.current;const text2=text2Ref.current;if(!container||!text1||!text2)return;let isVisible=false;let textIndex=texts.length-1;let time=Date.now();let morph=0;let cooldown=delay;let observer=null;text1.textContent=texts[textIndex];text2.textContent=texts[(textIndex+1)%texts.length];const setMorph=fraction=>{fraction=Math.max(fraction,1e-4);text2.style.filter=`blur(${Math.min(8/fraction-8,100)}px)`;text2.style.opacity=`${Math.pow(fraction,.4)}`;const reverse=Math.max(1-fraction,1e-4);text1.style.filter=`blur(${Math.min(8/reverse-8,100)}px)`;text1.style.opacity=`${Math.pow(reverse,.4)}`;};const doCooldown=()=>{morph=0;text2.style.filter=\"none\";text2.style.opacity=\"1\";text1.style.filter=\"none\";text1.style.opacity=\"0\";};const doMorph=()=>{morph-=cooldown;cooldown=0;let fraction=morph/transition;if(fraction>1){cooldown=delay;fraction=1;}setMorph(fraction);};const animate=()=>{if(!isVisible)return;frameRef.current=requestAnimationFrame(animate);const now=Date.now();const dt=(now-time)/1e3;time=now;const shouldIncrementIndex=cooldown>0;cooldown-=dt;if(cooldown<=0){if(shouldIncrementIndex){textIndex=(textIndex+1)%texts.length;text1.textContent=texts[textIndex];text2.textContent=texts[(textIndex+1)%texts.length];}doMorph();}else{doCooldown();}};const startAnimation=()=>{if(isVisible)return;isVisible=true;time=Date.now();if(frameRef.current){cancelAnimationFrame(frameRef.current);}animate();};const stopAnimation=()=>{isVisible=false;if(frameRef.current){cancelAnimationFrame(frameRef.current);frameRef.current=null;}};observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){startAnimation();}else{stopAnimation();}},{threshold:.1});observer.observe(container);return()=>{stopAnimation();if(observer){observer.disconnect();}};},[texts,transition,delay,isStatic]);const textStyle={...font,position:\"absolute\",left:\"50%\",top:\"50%\",transform:\"translate(-50%, -50%)\",color,fontSize,whiteSpace:\"nowrap\",textAlign:\"center\",userSelect:\"none\",pointerEvents:\"none\"};return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"visible\"},children:[/*#__PURE__*/_jsx(\"svg\",{width:\"0\",height:\"0\",style:{position:\"absolute\"},children:/*#__PURE__*/_jsx(\"defs\",{children:/*#__PURE__*/_jsx(\"filter\",{id:filterId,children:/*#__PURE__*/_jsx(\"feColorMatrix\",{in:\"SourceGraphic\",type:\"matrix\",values:\" 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 255 -140 \"})})})}),/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\",filter:`url(#${filterId})`},children:[/*#__PURE__*/_jsx(\"span\",{ref:text1Ref,style:textStyle}),/*#__PURE__*/_jsx(\"span\",{ref:text2Ref,style:textStyle})]})]});}MorphedText.defaultProps={texts:[\"Launch\",\"Create\",\"Scale\"],transition:1.5,delay:.8,fontSize:170,color:\"#EEFF00\",font:{fontFamily:\"Inter Display\",fontWeight:600,lineHeight:\"1em\",letterSpacing:\"0em\"}};addPropertyControls(MorphedText,{texts:{type:ControlType.Array,title:\"Texts\",control:{type:ControlType.String},defaultValue:[\"Launch\",\"Create\",\"Scale\"]},transition:{type:ControlType.Number,title:\"Transition\",defaultValue:1.5,min:.2,max:5,step:.1},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:.8,min:0,max:5,step:.1},fontSize:{type:ControlType.Number,title:\"Size\",defaultValue:170,min:12,max:300,step:1},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#EEFF00\"},font:{type:ControlType.Font,title:\"Font\",controls:\"family-weight-lineHeight-letterSpacing\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MorphedText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Morphed_text.map"],"mappings":"uMAA6J,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,SAAS,SAAS,OAAO,EAAE,aAAW,IAAI,QAAM,GAAG,WAAS,IAAI,QAAM,UAAU,QAAM,EAAY,EAAS,EAAoB,EAAQ,EAAaA,EAAa,IAAI,EAAQ,EAASA,EAAa,IAAI,EAAQ,EAASA,EAAa,IAAI,EAAQ,EAASA,EAAa,IAAI,EAAQ,EAASC,EAAY,CAAC,CAAC,QAAQ,KAAK,EAAE,EAAE,MAAoB,CAAC,IAAM,EAAM,EAAS,QAAc,EAAM,EAAS,QAAW,CAAC,GAAO,CAAC,IAAgD,EAAM,YAAzB,IAAQ,IAAI,OAAmC,EAAM,YAAY,GAAG,EAAM,MAAM,QAAQ,IAAI,EAAM,MAAM,OAAO,OAAO,EAAM,MAAM,QAAQ,IAAI,EAAM,MAAM,OAAO,OAAO,EAAE,CAAC,CAAK,CAAC,EAAE,MAAoB,CAAoB,GAAhB,GAAmB,CAAC,GAAO,EAAM,QAAQ,EAAE,OAAO,IAAM,E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