{"version":3,"file":"ColorWaveText.DBJSVezs.mjs","names":["React.useRef","spans","__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/QZcobI21bAefEyOwJBLf/9FTltZOdhfwO2Z0nspit/ColorWaveText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";// ─────────────────────────────\n// Color Wave Configuration & Helpers\n// ─────────────────────────────\nconst defaultColors=[\"#FFB592\",\"#FABA17\",\"#60E21B\",\"#24E0AF\",\"#6CD5FD\",\"#A7ABFF\",\"#F6AFFF\",\"#FFB0CD\"];let activeColors=[...defaultColors];const config={frequency:{min:2e3,max:6e3},startPoints:4,propagationLimit:6,waveSpeed:200,propagationDelay:250};function randomBetween(min,max){return Math.floor(Math.random()*(max-min+1))+min;}function isSameLine(span1,span2){const rect1=span1.getBoundingClientRect();const rect2=span2.getBoundingClientRect();return Math.abs(rect1.top-rect2.top)<2;}// ─────────────────────────────\n// Recursively wrap text nodes without altering existing HTML structure\n// ─────────────────────────────\nfunction wrapTextNodes(node){if(node.nodeType===Node.TEXT_NODE){const text=node.textContent;if(text&&text.length>0){const fragment=document.createDocumentFragment();// Wrap every character—even spaces—to preserve the layout\nfor(const char of text){const span=document.createElement(\"span\");span.textContent=char;// Add only the color transition (do not override other styles)\nspan.style.transition=`color ${config.waveSpeed}ms ease`;// Mark this span so we can target it later\nspan.setAttribute(\"data-color-wave-char\",\"true\");fragment.appendChild(span);}node.parentNode?.replaceChild(fragment,node);}}else if(node.nodeType===Node.ELEMENT_NODE){// Skip nodes that are already marked as a color-wave span.\nif(node.getAttribute(\"data-color-wave-char\")===\"true\"){return;}// Process child nodes recursively.\nconst childNodes=Array.from(node.childNodes);for(const child of childNodes){wrapTextNodes(child);}}}// ─────────────────────────────\n// ColorWaveText Override\n// ─────────────────────────────\nexport function ColorWaveText(){const ref=React.useRef(null);const timers=React.useRef([]);React.useEffect(()=>{const element=ref.current;if(!element)return;// Only wrap text nodes once so we don't interfere with any custom styling.\nif(!element.getAttribute(\"data-color-wave-initialized\")){wrapTextNodes(element);element.setAttribute(\"data-color-wave-initialized\",\"true\");}// Query only the spans that we inserted.\nconst spans=element.querySelectorAll(\"span[data-color-wave-char='true']\");// Helper: Clear any active timers.\nfunction clearTimers(){timers.current.forEach(timerId=>clearTimeout(timerId));timers.current=[];}// Function to start a wave effect from a given starting index.\nfunction startColorWave(spans,startIndex,colorCycle){const targetColors=[...colorCycle];const totalStages=targetColors.length+1;let propagationCount=0;function applyWave(index,stage){if(index<0||index>=spans.length||stage>=totalStages)return;const span=spans[index];if(stage<targetColors.length){span.style.color=targetColors[stage];}else{// Reset to inherit the original color from the parent styling.\nspan.style.color=\"\";}const timerId=window.setTimeout(()=>applyWave(index,stage+1),config.waveSpeed);timers.current.push(timerId);// Propagate to the next character only if on stage 0 and within our propagation limit.\nif(stage===0&&propagationCount<config.propagationLimit){propagationCount++;const nextIndex=index+1;if(nextIndex<spans.length&&isSameLine(spans[index],spans[nextIndex])){const timerId2=window.setTimeout(()=>applyWave(nextIndex,0),config.propagationDelay);timers.current.push(timerId2);}}}applyWave(startIndex,0);}// Function to trigger color wave effects periodically.\nfunction triggerColorEffect(){for(let i=0;i<config.startPoints;i++){const randomIndex=Math.floor(Math.random()*spans.length);const firstColorIndex=Math.floor(Math.random()*activeColors.length);const firstColor=activeColors[firstColorIndex];const secondColorIndex=(firstColorIndex+1)%activeColors.length;const secondColor=activeColors[secondColorIndex];startColorWave(spans,randomIndex,[firstColor,secondColor]);}const nextTriggerDelay=randomBetween(config.frequency.min,config.frequency.max);const timerId=window.setTimeout(triggerColorEffect,nextTriggerDelay);timers.current.push(timerId);}clearTimers();triggerColorEffect();// Cleanup on unmount.\nreturn()=>{clearTimers();};},[]);return{ref};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withColorWaveText(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...ColorWaveText(props)});};}withColorWaveText.displayName=\"ColorWaveText\";\nexport const __FramerMetadata__ = {\"exports\":{\"withColorWaveText\":{\"type\":\"reactHoc\",\"name\":\"withColorWaveText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ColorWaveText\":{\"type\":\"override\",\"name\":\"ColorWaveText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ColorWaveText.map"],"mappings":"sLAGyP,SAAS,EAAc,EAAI,EAAI,CAAC,OAAO,KAAK,MAAM,KAAK,QAAQ,EAAE,EAAI,EAAI,GAAG,CAAC,EAAK,SAAS,EAAW,EAAM,EAAM,CAAC,IAAM,EAAM,EAAM,uBAAuB,CAAO,EAAM,EAAM,uBAAuB,CAAC,OAAO,KAAK,IAAI,EAAM,IAAI,EAAM,IAAI,CAAC,EAGre,SAAS,EAAc,EAAK,CAAC,GAAG,EAAK,WAAW,KAAK,UAAU,CAAC,IAAM,EAAK,EAAK,YAAY,GAAG,GAAM,EAAK,OAAO,EAAE,CAAC,IAAM,EAAS,SAAS,wBAAwB,CACpK,IAAI,IAAM,KAAQ,EAAK,CAAC,IAAM,EAAK,SAAS,cAAc,OAAO,CAAC,EAAK,YAAY,EACnF,EAAK,MAAM,WAAW,SAAS,EAAO,UAAU,SAChD,EAAK,aAAa,uBAAuB,OAAO,CAAC,EAAS,YAAY,EAAK,CAAE,EAAK,YAAY,aAAa,EAAS,EAAK,UAAW,EAAK,WAAW,KAAK,aAAa,CACtK,GAAG,EAAK,aAAa,uBAAuB,GAAG,OAAQ,OACvD,IAAM,EAAW,MAAM,KAAK,EAAK,WAAW,CAAC,IAAI,IAAM,KAAS,EAAY,EAAc,EAAM,EAGhG,SAAgB,GAAe,CAAC,IAAM,EAAIA,EAAa,KAAK,CAAO,EAAOA,EAAa,EAAE,CAAC,CAQzD,OAR0D,MAAoB,CAAC,IAAM,EAAQ,EAAI,QA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