{"version":3,"file":"ColorWaveText.DvaaExoV.mjs","names":["React.useRef","__legacyOverrideHOC_DataObserverContext","_jsx","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","oe","de","window","init_jsx_runtime","ce","init_framer_B1b760uK","randomBetween","max","min","isSameLine","rect1","span1","rect2","span2","wrapTextNodes","node","text","fragment","char","span","config","childNodes","child","ColorWaveText","ref","timers","element","spans","clearTimers","timerId","startColorWave","targetColors","colorCycle","totalStages","propagationCount","applyWave","index","stage","nextIndex","timerId2","startIndex","triggerColorEffect","i","randomIndex","firstColorIndex","activeColors","firstColor","secondColorIndex","secondColor","nextTriggerDelay","withColorWaveText","DataObserverContext","c","C","props","init_ColorWaveText"],"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":"A,sLAGyP,SAASY,EAAc,EAAI,EAAI,CAAC,OAAO,KAAK,MAAM,KAAK,OAAO,GAAGC,EAAIC,EAAI,EAAE,EAAEA,CAAI,CAAC,SAASC,EAAW,EAAM,EAAM,CAAC,IAAMC,EAAMC,EAAM,sBAAsB,EAAQC,EAAMC,EAAM,sBAAsB,EAAE,OAAO,KAAK,IAAIH,EAAM,IAAIE,EAAM,GAAG,EAAE,CAAE,CAGve,SAASE,EAAc,EAAK,CAAC,GAAGC,EAAK,WAAW,KAAK,UAAU,CAAC,IAAMC,EAAKD,EAAK,YAAY,GAAGC,GAAMA,EAAK,OAAO,EAAE,CAAC,IAAMC,EAAS,SAAS,uBAAuB,EACnK,IAAI,IAAMC,KAAQF,EAAK,CAAC,IAAMG,EAAK,SAAS,cAAc,MAAM,EAAE,EAAK,YAAYD,EACnF,EAAK,MAAM,WAAW,SAASE,EAAO,U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