{"version":3,"file":"TextPath.DDbwbYcu.mjs","names":["useRef","useMemo","useCallback","__esmMin","ne","init_npm_react_18_3_1","pe","le","window","ce","init_jsx_runtime","p","de","init_ssg_sandbox_shims","useInView","init_framer_motion_DhsWWWsN","init_framer_BWFVvmND","ControlType","addPropertyControls","RenderTarget","calculateViewBoxFromPath","commands","pathData","minX","minY","maxX","maxY","cmd","coords","n","i","padding","strokeWidth","width","height","TextFollowPath","props","containerRef","svgRef","pathRef","textRef","textPathRef","offsetRef","animationRef","lastAppliedOffsetRef","pathLengthRef","textWidthRef","hasMeasured","isInViewRef","isInView","processedPath","svgPath","dMatch","viewBox","pathSize","style","repetitions","reps","text","font","repeatedText","measureElements","textElement","pathElement","measuredTextWidth","measuredPathLength","preview","speed","lastTime","directionMultiplier","direction","pixelsPerSecond","animate","deltaTime","currentTime","increment","pathLength","offsetPercent","isCanvas","showPath","pathColor","textColor","init_TextPath"],"sources":["https:/framerusercontent.com/modules/qIknDiyRLMYEVQRW0vw1/nK7aiNbDVWAOv2rxmFQ1/TextPath.js"],"sourcesContent":["// Text Path Component - Animates text along an SVG path with customizable properties\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useMemo,useCallback,useLayoutEffect}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useInView}from\"framer-motion\";// Helper function to calculate viewBox from SVG path data\nfunction calculateViewBoxFromPath(pathData,strokeWidth){try{// Parse path commands to find min/max coordinates\nconst commands=pathData.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/gi)||[];let minX=Infinity;let minY=Infinity;let maxX=-Infinity;let maxY=-Infinity;commands.forEach(cmd=>{const type=cmd[0].toUpperCase();const coords=cmd.slice(1).trim().split(/[\\s,]+/).map(Number).filter(n=>!isNaN(n));// Extract x,y coordinates based on command type\nfor(let i=0;i<coords.length;i+=2){if(coords[i]!==undefined){minX=Math.min(minX,coords[i]);maxX=Math.max(maxX,coords[i]);}if(coords[i+1]!==undefined){minY=Math.min(minY,coords[i+1]);maxY=Math.max(maxY,coords[i+1]);}}});// Add padding for stroke\nconst padding=strokeWidth/2+5;const width=maxX-minX+padding*2;const height=maxY-minY+padding*2;return`${minX-padding} ${minY-padding} ${width} ${height}`;}catch(e){// Fallback to default\nreturn\"0 0 3192 367\";}}/**\n * Text Follow Path\n *\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerDisableUnlink\n */export default function TextFollowPath(props){const{text=\"Text follows the path\",svgPath=\"M12.8009 210.181C12.8009 210.181 111.532 372.298 371.301 349.681C705.301 320.6 906.801 6.81913 1201.3 31.9999C1463.38 54.4084 1490.3 349.681 1838.8 349.681C2283.8 349.681 2356.8 15 2677.8 15C2934.6 15 3118.13 238.12 3177.8 349.681\",textColor=\"#000000\",pathColor=\"#FFA8F2\",showPath=true,direction=\"forward\",speed=50,font,pathSize=30,preview=true,style}=props;const containerRef=useRef(null);const svgRef=useRef(null);const pathRef=useRef(null);const textRef=useRef(null);const textPathRef=useRef(null);const offsetRef=useRef(0);const animationRef=useRef();const lastAppliedOffsetRef=useRef(0);// Use refs instead of state for measurements\nconst pathLengthRef=useRef(3192);const textWidthRef=useRef(100);const hasMeasured=useRef(false);const isInViewRef=useRef(false);// Track viewport visibility\nconst isInView=useInView(containerRef,{once:false,amount:.1});// Update ref when visibility changes\nuseEffect(()=>{isInViewRef.current=isInView;},[isInView]);// Extract path d attribute if full SVG is pasted\nconst processedPath=useMemo(()=>{// Check if the input contains SVG tags\nif(svgPath.includes(\"<path\")&&svgPath.includes(\"d=\")){// Extract the d attribute value\nconst dMatch=svgPath.match(/d=\"([^\"]+)\"/);if(dMatch&&dMatch[1]){return dMatch[1];}}// If it's already just a path or no match found, use as is\nreturn svgPath;},[svgPath]);// Calculate viewBox synchronously from path data\nconst viewBox=useMemo(()=>{return calculateViewBoxFromPath(processedPath,pathSize);},[processedPath,pathSize]);const width=style?.width===\"100%\"?\"100%\":600;const height=style?.height===\"100%\"?\"100%\":400;// Calculate repetitions and repeated text from refs\nconst repetitions=useMemo(()=>{const reps=Math.max(3,Math.ceil(pathLengthRef.current*2/textWidthRef.current));return Math.min(reps,50)// Cap at 50 to prevent excessive memory usage\n;},[text,font,processedPath]);const repeatedText=useMemo(()=>{return Array(repetitions).fill(text).join(\" \");},[repetitions,text]);// Measure text width and path length - optimized to run only when necessary\nconst measureElements=useCallback(()=>{if(textRef.current&&pathRef.current){const textElement=textRef.current;const pathElement=pathRef.current;try{const measuredTextWidth=textElement.getComputedTextLength()/repetitions;const measuredPathLength=pathElement.getTotalLength();if(measuredTextWidth>0&&measuredPathLength>0){// Write directly to refs - no state updates\ntextWidthRef.current=measuredTextWidth;pathLengthRef.current=measuredPathLength;}hasMeasured.current=true;}catch(e){// Fallback to defaults\n}}},[repetitions]);useEffect(()=>{// Reset measurement flag when key dependencies change\nhasMeasured.current=false;},[text,font,processedPath]);useLayoutEffect(()=>{if(!hasMeasured.current){measureElements();}},[measureElements]);// Animation loop - optimized to update DOM directly\nuseEffect(()=>{// Don't animate on canvas when preview is false\nconst isCanvas=RenderTarget.current()===RenderTarget.canvas;if(isCanvas&&!preview){return;}// Don't animate if speed is 0\nif(speed===0){return;}let lastTime=performance.now();const directionMultiplier=direction===\"forward\"?1:-1;const pixelsPerSecond=speed*2;const UPDATE_THRESHOLD=.5// Only update DOM if offset changes by at least 0.5 pixels\n;const animate=currentTime=>{// Check ref instead of dependency - no effect restart needed\nif(!isInViewRef.current){animationRef.current=requestAnimationFrame(animate);return;}const deltaTime=(currentTime-lastTime)/1e3// Convert to seconds\n;lastTime=currentTime;const increment=pixelsPerSecond*deltaTime*directionMultiplier;offsetRef.current+=increment;const pathLength=pathLengthRef.current;// Loop seamlessly using path length\nif(offsetRef.current>=pathLength){offsetRef.current=offsetRef.current%pathLength;lastAppliedOffsetRef.current=offsetRef.current;}else if(offsetRef.current<0){offsetRef.current=pathLength+offsetRef.current%pathLength;lastAppliedOffsetRef.current=offsetRef.current;}// Only update DOM if the change is significant enough to be visible\nconst offsetDelta=Math.abs(offsetRef.current-lastAppliedOffsetRef.current);if(offsetDelta>=UPDATE_THRESHOLD){// Update DOM directly for better performance\nif(textPathRef.current){const offsetPercent=offsetRef.current/pathLength*100;textPathRef.current.setAttribute(\"startOffset\",`${-offsetPercent}%`);lastAppliedOffsetRef.current=offsetRef.current;}}animationRef.current=requestAnimationFrame(animate);};if(typeof window!==\"undefined\"){animationRef.current=requestAnimationFrame(animate);}return()=>{if(animationRef.current){cancelAnimationFrame(animationRef.current);}};},[speed,direction,preview]);// Initial offset for SSR\nconst offsetPercent=offsetRef.current/pathLengthRef.current*100;// Determine if animation should be active\nconst shouldAnimate=useMemo(()=>{const isCanvas=RenderTarget.current()===RenderTarget.canvas;return isInView&&speed>0&&(preview||!isCanvas);},[isInView,speed,preview]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsxs(\"svg\",{ref:svgRef,width:\"100%\",height:\"100%\",viewBox:viewBox,preserveAspectRatio:\"xMidYMid meet\",style:{display:\"block\"},children:[/*#__PURE__*/_jsx(\"defs\",{children:/*#__PURE__*/_jsx(\"path\",{ref:pathRef,id:\"textPath\",d:processedPath})}),showPath&&/*#__PURE__*/_jsx(\"path\",{d:processedPath,fill:\"none\",stroke:pathColor,strokeWidth:pathSize,strokeLinecap:\"round\",strokeLinejoin:\"round\"}),/*#__PURE__*/_jsx(\"text\",{ref:textRef,fill:textColor,style:{...font},children:/*#__PURE__*/_jsx(\"textPath\",{ref:textPathRef,href:\"#textPath\",startOffset:`${-offsetPercent}%`,textAnchor:\"start\",dominantBaseline:\"middle\",style:{fontSize:font.fontSize||\"32px\",fontFamily:font.fontFamily,fontWeight:font.fontWeight,fontStyle:font.fontStyle,letterSpacing:font.letterSpacing,willChange:shouldAnimate?\"auto\":\"auto\"},children:repeatedText})})]})});}addPropertyControls(TextFollowPath,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Text follows the path\",displayTextArea:true},svgPath:{type:ControlType.String,title:\"SVG Path\",defaultValue:\"M12.8009 210.181C12.8009 210.181 111.532 372.298 371.301 349.681C705.301 320.6 906.801 6.81913 1201.3 31.9999C1463.38 54.4084 1490.3 349.681 1838.8 349.681C2283.8 349.681 2356.8 15 2677.8 15C2934.6 15 3118.13 238.12 3177.8 349.681\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.03em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},showPath:{type:ControlType.Boolean,title:\"Show Path\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},pathSize:{type:ControlType.Number,title:\"Path Size\",defaultValue:30,min:1,max:100,step:1},pathColor:{type:ControlType.Color,title:\"Path Color\",defaultValue:\"#FFA8F2\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"forward\",\"backward\"],optionTitles:[\"←\",\"→\"],defaultValue:\"forward\",displaySegmentedControl:true},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:0,max:200,step:1},preview:{type:ControlType.Boolean,title:\"Preview\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\",description:\"More resources at [Velox Themes](https://veloxthemes.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextFollowPath\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"600\",\"framerDisableUnlink\":\"\",\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextPath.map"],"mappings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