{"version":3,"file":"ScrambleText.3hz37igg.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/93s0IauLu0Bx1NCJmMjP/RjwO2w4xKVvI8NlTi4IA/ScrambleText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useRef,useState}from\"react\";/**\n * Molaco — Scramble Text\n *\n * Hover a button and its label churns through noise, then resolves — either\n * left to right, or the whole string at once (`resolve`).\n *\n * · The real text stays in the flow and only turns transparent while\n *   scrambling, with the noise drawn over it. That pins the button's LAYOUT —\n *   it can never resize — and keeps the real string in the accessibility tree.\n *   The noise is NOT width-matched to the text it covers: random glyphs are\n *   wider than the letters they replace, so the churn renders wider than the\n *   label. Glyphs keep their natural, undistorted width and a single mask the\n *   width of the text layer clips the overhang, so nothing bleeds outside the\n *   control. (A per-character measured-slot version, which squeezed each glyph\n *   to fit instead, was built and rejected; see decision #108.)\n *\n * · The hover listener attaches to the nearest LINK OR BUTTON ancestor, so the\n *   whole control is the target. It deliberately does not sniff for\n *   `cursor: pointer` — cursor inherits, so the first parent always matches\n *   and the target ends up no bigger than the glyphs themselves.\n *\n * · Every character re-rolls independently each tick, via an avalanche mix.\n *   A plain per-character stride reads as a marching diagonal, not as noise.\n *\n * Whitespace in the label never scrambles, so word shape survives; whitespace\n * is also stripped from the glyph pool, since a space drawn over the\n * transparent real text punches a hole in the label rather than reading as\n * noise. Disabled in the canvas and under reduced motion.\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 96\n * @framerIntrinsicHeight 12\n */export default function ScrambleText(props){const{text=\"Start a Project\",font,color=\"#FFFFFF\",duration=.45,tick=30,fontTablet,fontPhone,glyphs=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ#%&@*+=-/\",resolve=\"sequential\",trigger=\"hover\",stagger=0,hold=0,mask=true,respectReducedMotion=true,style}=props;const hostRef=useRef(null);const[output,setOutput]=useState(null);const onCanvas=RenderTarget.current()===RenderTarget.canvas;// A Font control is a fixed px value, so a label standing in for a text\n// style that changes across breakpoints (Molaco's `Display`: 32 / 28 / 24)\n// would otherwise freeze at one size. These are optional — leave them\n// empty and the label just uses `font` everywhere, as before.\nconst[bp,setBp]=useState(\"desktop\");useEffect(()=>{if(typeof window===\"undefined\")return;const desktop=window.matchMedia(\"(min-width: 1200px)\");const tablet=window.matchMedia(\"(min-width: 810px)\");const read=()=>setBp(desktop.matches?\"desktop\":tablet.matches?\"tablet\":\"phone\");read();desktop.addEventListener(\"change\",read);tablet.addEventListener(\"change\",read);return()=>{desktop.removeEventListener(\"change\",read);tablet.removeEventListener(\"change\",read);};},[]);const activeFont=bp===\"phone\"&&fontPhone||bp!==\"desktop\"&&fontTablet||font;useEffect(()=>{if(typeof window===\"undefined\"||onCanvas)return;const host=hostRef.current;if(!host)return;const reduced=window.matchMedia(\"(prefers-reduced-motion: reduce)\");if(respectReducedMotion&&reduced.matches)return;// A space in the pool would render as a gap over transparent text\nconst glyphList=Array.from(glyphs).filter(g=>g.trim()!==\"\");if(!glyphList.length)return;// Hovering the control is what a visitor means, so listen there.\nlet target=host.closest(\"a, button\");if(!target){// No link or button ancestor. Climb ONLY through pure wrappers —\n// a parent that holds siblings is a shared row, and listening\n// there makes every label in the row react together (three\n// unlinked social labels in one flex row did exactly that).\n// Widening the target must never widen it past this label.\nlet n=host.parentElement;let last=host;for(let hops=0;n&&hops<4;hops++,n=n.parentElement){if(n.childElementCount!==1)break;last=n;}target=last;}const hoverTarget=target||host;const chars=Array.from(text);let raf=0;let start=0;function frame(now){if(!start)start=now;let elapsed=(now-start)/1e3;// Each character settles on its own clock, so a real pause can sit\n// between them. Dividing by 1.3 keeps the zero-stagger timing\n// identical to before: the last character lands at 77% of the run.\nconst gap=Math.max(0,stagger)/1e3;const perChar=duration/Math.max(1,chars.length)/1.3;const lastSettle=chars.length*perChar+(chars.length-1)*gap;const sequential=resolve===\"sequential\";// `hold` keeps the resolved string on screen before \"always\"\n// starts over; the 0.23 tail is the original trailing beat.\nconst runFor=(sequential?lastSettle+duration*.23:duration)+Math.max(0,hold)/1e3;if(elapsed/Math.max(.05,runFor)>=1){if(trigger===\"always\"){// Reset the clock AND the elapsed time in the same frame;\n// leaving it at the end would settle every character for\n// one frame, flashing the real string on every loop.\nstart=now;elapsed=0;}else{setOutput(null);raf=0;return;}}const step=Math.floor((now-start)/Math.max(8,tick));let out=\"\";for(let i=0;i<chars.length;i++){const c=chars[i];if(c.trim()===\"\"){out+=c;continue;}if(sequential&&elapsed>=(i+1)*perChar+i*gap){out+=c;continue;}let h=(step+1)*374761393+(i+1)*668265263;h=Math.imul(h^h>>>13,1274126177);const pick=((h^h>>>16)>>>0)%glyphList.length;out+=glyphList[pick]||c;}setOutput(out);raf=requestAnimationFrame(frame);}const onEnter=()=>{if(raf)cancelAnimationFrame(raf);start=0;raf=requestAnimationFrame(frame);};const onLeave=()=>{if(raf)cancelAnimationFrame(raf);raf=0;setOutput(null)// never leave a half-resolved label on screen\n;};if(trigger!==\"hover\"){// \"load\" runs once and settles; \"always\" never settles, which is\n// the whole point on a 404 — the page that never resolved.\nraf=requestAnimationFrame(frame);return()=>{if(raf)cancelAnimationFrame(raf);};}hoverTarget.addEventListener(\"mouseenter\",onEnter);hoverTarget.addEventListener(\"mouseleave\",onLeave);return()=>{if(raf)cancelAnimationFrame(raf);hoverTarget.removeEventListener(\"mouseenter\",onEnter);hoverTarget.removeEventListener(\"mouseleave\",onLeave);};},[text,duration,tick,glyphs,resolve,trigger,stagger,hold,respectReducedMotion,onCanvas]);const type={...activeFont,color,whiteSpace:\"pre\"};return /*#__PURE__*/_jsxs(\"span\",{ref:hostRef,style:{...style,...type,position:\"relative\",display:\"inline-block\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{color:output?\"transparent\":undefined},children:text}),output&&/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",style:{position:\"absolute\",left:0,top:0,right:0,bottom:0,color,// One mask, the width of the text layer. Random glyphs\n// are wider than the letters they replace, so the noise\n// runs past the label; this clips it back to the text's\n// own box so it can never bleed outside the control.\n// clip-path, NOT overflow: hidden — overflow clips both\n// axes, and at line-height 100% that shaves the bottom\n// off any descender in the glyph set (measured: 7px at\n// 6x on \"gjpqy,;Q@\"). Negative vertical insets leave the\n// glyphs full height and mask horizontally only.\nclipPath:mask?\"inset(-100% 0 -100% 0)\":undefined},children:output})]});}ScrambleText.displayName=\"Scramble Text\";addPropertyControls(ScrambleText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Start a Project\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",// matches the Caption Tight text style this label used before.\n// NOTE: an extended Font control's defaultValue cannot name a family\n// (the type rejects fontFamily/fontSelector), so Framer shows Inter\n// until a value is set. Every instance therefore carries explicit\n// font / fontTablet / fontPhone values — see decision #108.\ndefaultValue:{fontSize:\"12px\",variant:\"Regular\",letterSpacing:\"-0.02em\",lineHeight:\"100%\",textAlign:\"left\"}},fontTablet:{type:ControlType.Font,title:\"Font Tablet\",controls:\"extended\",defaultFontType:\"sans-serif\",description:\"Optional. For 810-1199px. Only needed if the text style changes size here.\"},fontPhone:{type:ControlType.Font,title:\"Font Phone\",controls:\"extended\",defaultFontType:\"sans-serif\",description:\"Optional. Under 810px. Falls back to Font Tablet, then Font.\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#FFFFFF\"},duration:{type:ControlType.Number,title:\"Duration\",min:.1,max:1.5,step:.05,unit:\"s\",defaultValue:.45,displayStepper:false},tick:{type:ControlType.Number,title:\"Churn\",min:10,max:120,step:5,unit:\"ms\",defaultValue:30,displayStepper:false,description:\"How fast unresolved characters change.\"},glyphs:{type:ControlType.String,title:\"Glyphs\",defaultValue:\"ABCDEFGHIJKLMNOPQRSTUVWXYZ#%&@*+=-/\"},resolve:{type:ControlType.Enum,title:\"Resolve\",options:[\"sequential\",\"together\"],optionTitles:[\"Left to right\",\"All at once\"],defaultValue:\"sequential\"},trigger:{type:ControlType.Enum,title:\"Trigger\",options:[\"hover\",\"load\",\"always\"],optionTitles:[\"On hover\",\"Once on load\",\"Never settles\"],defaultValue:\"hover\",description:'\"Never settles\" churns forever — use sparingly.'},stagger:{type:ControlType.Number,title:\"Stagger\",min:0,max:400,step:10,unit:\"ms\",defaultValue:0,displayStepper:false,description:\"Extra pause between each character resolving.\"},hold:{type:ControlType.Number,title:\"Hold\",min:0,max:5e3,step:100,unit:\"ms\",defaultValue:0,displayStepper:false,description:'Pause on the resolved text before \"Never settles\" loops.'},mask:{type:ControlType.Boolean,title:\"Mask\",defaultValue:true,description:\"Clips the noise to the text width. Off lets wide glyphs spill.\"},respectReducedMotion:{type:ControlType.Boolean,title:\"Reduced motion\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrambleText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerIntrinsicHeight\":\"12\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"96\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrambleText.map"],"mappings":"oNAiCG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,OAAK,kBAAkB,OAAK,QAAM,UAAU,WAAS,IAAI,OAAK,GAAG,aAAW,YAAU,SAAO,sCAAsC,UAAQ,aAAa,UAAQ,QAAQ,UAAQ,EAAE,OAAK,EAAE,OAAK,GAAK,uBAAqB,GAAK,SAAO,EAAY,EAAQA,EAAO,IAAI,EAAO,CAAC,EAAO,GAAWC,EAAS,IAAI,EAAQ,EAAS,EAAa,QAAQ,IAAI,EAAa,OAIjZ,CAAC,EAAG,GAAOA,EAAS,SAAS,EAAE,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAQ,EAAO,WAAW,qBAAqB,EAAQ,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