{"version":3,"file":"SlotRouletteText.C8eiQUK1.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/930wKf3K8PpJvNiRurZ4/kqFOavies31JJGl9grD4/SlotRouletteText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const ALIGN_TO_JUSTIFY={left:\"flex-start\",center:\"center\",right:\"flex-end\"};function RollingLetter({finalChar,delay,duration,repeats,font,fontSize,letterSpacing,color,lineHeight,playToken,strokeWidth,strokeColor}){const isSpace=finalChar===\" \";const lineHeightPx=fontSize*lineHeight/100;const copies=Math.max(repeats,2);const startOffset=-(copies-1)*lineHeightPx;const[translateY,setTranslateY]=useState(isSpace?0:startOffset);// Whether the reel is currently clipped (spinning) or free (settled).\n// Letters start settled (not spinning) so that if the play trigger ever\n// fails to fire, we fail safe into a normal, fully visible character\n// instead of a permanently clipped one.\nconst[isSpinning,setIsSpinning]=useState(false);const rafRef=useRef(null);const startRef=useRef(null);useEffect(()=>{if(isSpace)return;if(playToken===0)return;let cancelled=false;const totalMs=duration*1e3;const delayMs=delay*1e3;// reset to the top of the reel before spinning again\nsetIsSpinning(true);setTranslateY(startOffset);startRef.current=null;const timeout=setTimeout(()=>{const step=ts=>{if(cancelled)return;if(startRef.current===null)startRef.current=ts;const elapsed=ts-startRef.current;const progress=Math.min(elapsed/totalMs,1);// ease-out cubic: fast spin at first, settles smoothly like a real reel\nconst eased=1-Math.pow(1-progress,3);const current=startOffset+(0-startOffset)*eased;setTranslateY(current);if(progress>=1){setTranslateY(0);setIsSpinning(false);return;}rafRef.current=requestAnimationFrame(step);};rafRef.current=requestAnimationFrame(step);},delayMs);return()=>{cancelled=true;clearTimeout(timeout);if(rafRef.current)cancelAnimationFrame(rafRef.current);};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[playToken]);const charStyle={display:\"block\",height:lineHeightPx,lineHeight:`${lineHeightPx}px`,letterSpacing:letterSpacing,color:color,whiteSpace:\"pre\",textAlign:\"center\",...font,fontSize:fontSize,...strokeWidth>0?{WebkitTextStroke:`${strokeWidth}px ${strokeColor||color}`,paintOrder:\"stroke fill\"}:{}};if(isSpace){return /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",width:fontSize*.3,height:lineHeightPx}});}return /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",// Only clip while spinning. Once settled (or if the\n// animation never triggers), let the glyph render freely so\n// diacritics are never cut off.\noverflow:isSpinning?\"hidden\":\"visible\",height:lineHeightPx,verticalAlign:\"top\",// Force this clip boundary onto its own compositor layer.\n// Without this, some Android browsers can let the child's\n// rapidly-updating transform paint outside the clip for a\n// frame or two mid-animation.\n...isSpinning?{transform:\"translateZ(0)\",WebkitTransform:\"translateZ(0)\",isolation:\"isolate\",willChange:\"transform\"}:{}},children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"block\",transform:isSpinning?`translateY(${translateY}px) translateZ(0)`:\"none\"},children:isSpinning?Array.from({length:copies}).map((_,i)=>/*#__PURE__*/_jsx(\"span\",{style:charStyle,children:finalChar},i)):/*#__PURE__*/_jsx(\"span\",{style:charStyle,children:finalChar})})});}export default function SlotRouletteText(props){const{text,font,fontSize,letterSpacing,lineHeight,color,letterDuration,letterStagger,repeats,triggerOnce,loop,loopInterval,uppercase,textAlign,strokeWidth,strokeColor,style}=props;const containerRef=useRef(null);const[hasEnteredOnce,setHasEnteredOnce]=useState(false);// playToken increments every time we want to (re)play the animation\nconst[playToken,setPlayToken]=useState(0);const intervalRef=useRef(null);const hasEnteredOnceRef=useRef(false);const triggerOnceRef=useRef(triggerOnce);triggerOnceRef.current=triggerOnce;const play=()=>setPlayToken(t=>t+1);const markEntered=()=>{if(!hasEnteredOnceRef.current){hasEnteredOnceRef.current=true;setHasEnteredOnce(true);}};// Native IntersectionObserver-based trigger: works the same in the\n// Framer canvas and in the published/exported site, since it doesn't\n// depend on framer-motion's internal viewport plumbing.\nuseEffect(()=>{const node=containerRef.current;if(!node||typeof IntersectionObserver===\"undefined\"){// Environment doesn't support IntersectionObserver at all —\n// just play immediately so the component never stays inert.\nmarkEntered();play();return;}let firedOnce=false;const observer=new IntersectionObserver(entries=>{const entry=entries[0];if(!entry)return;if(entry.isIntersecting){if(!firedOnce){firedOnce=true;markEntered();play();}else if(!triggerOnceRef.current){play();}}},{root:null,rootMargin:\"0px 0px -10% 0px\",threshold:.01});observer.observe(node);// Safety net: if the observer never reports an intersection (e.g.\n// element measured with zero size at the time it's set up, or an\n// ancestor's transform/overflow confuses the browser), force the\n// first play after a short delay so letters never sit stuck mid-spin.\nconst fallback=window.setTimeout(()=>{if(!firedOnce){firedOnce=true;markEntered();play();}},1500);return()=>{observer.disconnect();window.clearTimeout(fallback);};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[]);// Optional auto-repeat on a fixed interval, independent of scroll position,\n// as long as the component has been seen at least once.\nuseEffect(()=>{if(!loop||!hasEnteredOnce)return;intervalRef.current=window.setInterval(()=>{play();},Math.max(loopInterval,1)*1e3);return()=>{if(intervalRef.current)window.clearInterval(intervalRef.current);};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[loop,loopInterval,hasEnteredOnce]);const displayText=uppercase?(text||\"\").toUpperCase():text||\"\";const lines=displayText.split(\"\\n\");let globalIndex=0;const justify=ALIGN_TO_JUSTIFY[textAlign]||\"flex-start\";return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{display:\"flex\",flexDirection:\"column\",width:\"100%\",alignItems:textAlign===\"center\"?\"center\":textAlign===\"right\"?\"flex-end\":\"flex-start\",...style},children:lines.map((line,li)=>{// Split the line into words, keeping the spaces as their own\n// tokens so we can still render a rolling \"space\" reel between\n// words while never breaking a word across two lines.\nconst tokens=line.split(/(\\s+)/).filter(t=>t.length>0);return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexWrap:\"wrap\",width:\"100%\",alignItems:\"flex-end\",justifyContent:justify},children:tokens.map((token,ti)=>{const isWhitespace=/^\\s+$/.test(token);if(isWhitespace){return Array.from(token).map((ch,wi)=>{const idx=globalIndex++;return /*#__PURE__*/_jsx(RollingLetter,{finalChar:ch,delay:idx*letterStagger,duration:letterDuration,repeats:repeats,font:font,fontSize:fontSize,letterSpacing:letterSpacing,lineHeight:lineHeight,color:color,playToken:playToken,strokeWidth:strokeWidth??0,strokeColor:strokeColor},`${li}-${ti}-${wi}`);});}// Wrap each word so it stays intact: it can wrap\n// to the next line as a whole, but never splits\n// mid-word.\nreturn /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",alignItems:\"flex-end\",whiteSpace:\"nowrap\"},children:token.split(\"\").map((ch,ci)=>{const idx=globalIndex++;return /*#__PURE__*/_jsx(RollingLetter,{finalChar:ch,delay:idx*letterStagger,duration:letterDuration,repeats:repeats,font:font,fontSize:fontSize,letterSpacing:letterSpacing,lineHeight:lineHeight,color:color,playToken:playToken,strokeWidth:strokeWidth??0,strokeColor:strokeColor},`${li}-${ti}-${ci}`);})},`${li}-${ti}`);})},li);})});}SlotRouletteText.displayName=\"Slot Roulette Text\";addPropertyControls(SlotRouletteText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"MOON IN\\nTHE 12TH\\nHOUSE\",displayTextArea:true},uppercase:{type:ControlType.Boolean,title:\"Force Uppercase\",defaultValue:true},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:80,min:10,max:300},letterSpacing:{type:ControlType.Number,title:\"Letter Spacing\",defaultValue:0,min:-10,max:20},lineHeight:{type:ControlType.Number,title:\"Line Height %\",defaultValue:100,min:60,max:200},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#F5F0E8\"},strokeWidth:{type:ControlType.Number,title:\"Stroke Width\",defaultValue:0,min:0,max:10,step:.5,description:\"Thickens the letters with an outline — useful when the font has no Bold weight available.\"},strokeColor:{type:ControlType.Color,title:\"Stroke Color\",defaultValue:undefined,description:\"Leave empty to use the same color as the text fill.\"},letterDuration:{type:ControlType.Number,title:\"Spin Duration (s)\",defaultValue:.6,min:.1,max:3,step:.05},letterStagger:{type:ControlType.Number,title:\"Letter Stagger (s)\",defaultValue:.04,min:0,max:.5,step:.01},repeats:{type:ControlType.Number,title:\"Reel Copies\",defaultValue:6,min:2,max:20},triggerOnce:{type:ControlType.Boolean,title:\"Trigger Once on Scroll\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Repeat Automatically\",defaultValue:true},loopInterval:{type:ControlType.Number,title:\"Repeat Every (s)\",defaultValue:7,min:1,max:120,step:.5,hidden:props=>!props.loop}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SlotRouletteText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SlotRouletteText.map"],"mappings":"sMAAwN,SAAS,EAAc,CAAC,YAAU,QAAM,WAAS,UAAQ,OAAK,WAAS,gBAAc,QAAM,aAAW,YAAU,cAAY,eAAa,CAAC,IAAM,EAAQ,IAAY,IAAU,EAAa,EAAS,EAAW,IAAU,EAAO,KAAK,IAAI,EAAQ,CAAC,EAAQ,EAAY,EAAE,EAAO,GAAG,EAAkB,CAAC,EAAW,GAAeA,EAAS,EAAQ,EAAE,CAAW,EAIhjB,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAQ,EAAOC,EAAO,IAAI,EAAQ,EAASA,EAAO,IAAI,EAAE,MAAc,CAAmB,GAAf,GAAkB,IAAY,EAAE,OAAO,IAAI,EAAU,GAAY,EAAQ,EAAS,IAAU,EAAQ,EAAM,IAClO,EAAc,EAAI,EAAE,EAAc,CAAW,EAAE,EAAS,QAAQ,KAAK,IAAM,EAAQ,eAAe,CAAC,IAAM,EAAK,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