{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/hB0d6gqmsNIfIUrXpK5G/IbIxHgMmMV0zmVfjwCxS/TextDecrypt_Prod.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useState,useRef}from\"react\";import{useScroll}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n *\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n */export default function TextDecrypt(props){var _props_style;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const componentRef=useRef(null);const lastUpdatePosition=useRef(0);const lastScrollY=useRef(0);const encryptedText=useRef(randomString(props));const[text,setText]=useState(encryptedText.current);// Setup scroll tracking with raw values instead of progress\nconst{scrollY}=useScroll({target:componentRef,offset:[\"start end\",\"center center\"]});// Update text on scroll\nuseEffect(()=>{const unsubscribe=scrollY.on(\"change\",value=>{// Skip if we haven't actually scrolled\nif(value===lastScrollY.current)return;lastScrollY.current=value;// Get component's position relative to viewport\nconst element=componentRef.current;if(!element)return;const rect=element.getBoundingClientRect();const viewportHeight=window.innerHeight;const elementTop=rect.top;const relativePosition=elementTop/viewportHeight;// If element is above the 0.5 threshold, keep it fully decrypted\nif(relativePosition<=.5){setText(props.text);return;}// Update random characters every 10px\nif(Math.abs(value-lastUpdatePosition.current)>=10){encryptedText.current=randomString(props);lastUpdatePosition.current=value;}// Calculate encryption percentage based on position\n// 0.8 = 100% encrypted, 0.5 = 0% encrypted\nconst encryptionRangeStart=.8;const encryptionRangeEnd=.5;const encryptionRange=encryptionRangeStart-encryptionRangeEnd;if(relativePosition>encryptionRangeEnd&&relativePosition<=encryptionRangeStart){const percentage=(relativePosition-encryptionRangeEnd)/encryptionRange;const numberOfEncryptedCharacters=Math.floor((props.text.length-1)*percentage)+1;if(numberOfEncryptedCharacters===0){setText(props.text);}else{setText(props.text.slice(0,-numberOfEncryptedCharacters)+encryptedText.current.slice(-numberOfEncryptedCharacters));}}else if(relativePosition>encryptionRangeStart){// Ensure it stays fully encrypted above the 0.8 threshold\nsetText(encryptedText.current);}});return()=>unsubscribe();},[props.text,props.characters,props.options.matchCase,props.options.keepSpaces,scrollY]);const Tag=props.tag;return /*#__PURE__*/_jsx(Tag,{ref:componentRef,style:{color:props.color,userSelect:props.userSelect?\"auto\":\"none\",margin:0,whiteSpace:((_props_style=props.style)===null||_props_style===void 0?void 0:_props_style.width)?undefined:\"nowrap\",...props.font,...props.style},children:isCanvas?randomString(props):text});}TextDecrypt.displayName=\"Scroll Decrypt\";addPropertyControls(TextDecrypt,{text:{type:ControlType.String,defaultValue:\"Text Decrypt\",displayTextArea:true},characters:{type:ControlType.String,defaultValue:\"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?~\",displayTextArea:true},options:{type:ControlType.Object,buttonTitle:\"Options\",controls:{matchCase:{type:ControlType.Boolean,defaultValue:true},keepSpaces:{type:ControlType.Boolean,defaultValue:false}}},font:{type:\"font\",controls:\"extended\",defaultFontType:\"monospace\",defaultValue:{fontSize:24,lineHeight:1.4}},color:{type:ControlType.Color,defaultValue:\"#000\"},userSelect:{type:ControlType.Boolean,defaultValue:true},tag:{type:ControlType.Enum,title:\"Tag\",defaultValue:\"p\",displaySegmentedControl:true,options:[\"h1\",\"h2\",\"h3\",\"p\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"P\"],description:\"More components at [Framer University](https://frameruni.link/cc).\"}});const randomString=props=>{const length=props.text.length;const characters=props.characters;const originalText=props.text;const matchCase=props.options.matchCase;const keepSpaces=props.options.keepSpaces;if(length<=0){return\"\";}let result=\"\";let lastChar=\"\";for(let i=0;i<length;i++){const originalChar=originalText[i];// Preserve spaces and tabs if keepSpaces is true\nif(keepSpaces&&(originalChar===\" \"||originalChar===\"\t\")){result+=originalChar;continue;}let newChar;do{newChar=characters[Math.floor(Math.random()*characters.length)];// Match case if matchCase is true\nif(matchCase&&originalChar){newChar=originalChar===originalChar.toUpperCase()?newChar.toUpperCase():newChar.toLowerCase();}}while(newChar===lastChar&&characters.length>=8)result+=newChar;lastChar=newChar;}return result;};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextDecrypt\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerDisableUnlink\":\"*\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicHeight\":\"200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextDecrypt_Prod.map"],
  "mappings": "sIAQkB,SAARA,EAA6BC,EAAM,CAAC,IAAIC,EAAa,IAAMC,EAASC,EAAa,QAAQ,IAAIA,EAAa,OAAaC,EAAaC,EAAO,IAAI,EAAQC,EAAmBD,EAAO,CAAC,EAAQE,EAAYF,EAAO,CAAC,EAAQG,EAAcH,EAAOI,EAAaT,CAAK,CAAC,EAAO,CAACU,EAAKC,CAAO,EAAEC,EAASJ,EAAc,OAAO,EACvT,CAAC,QAAAK,CAAO,EAAEC,EAAU,CAAC,OAAOV,EAAa,OAAO,CAAC,YAAY,eAAe,CAAC,CAAC,EACnFW,EAAU,IAAI,CAAC,IAAMC,EAAYH,EAAQ,GAAG,SAASI,GAAO,CAC5D,GAAGA,IAAQV,EAAY,QAAQ,OAAOA,EAAY,QAAQU,EAC1D,IAAMC,EAAQd,EAAa,QAAQ,GAAG,CAACc,EAAQ,OAAO,IAAMC,EAAKD,EAAQ,sBAAsB,EAAQE,EAAeC,EAAO,YAA4CC,EAAfH,EAAK,IAAsCC,EACrM,GAAGE,GAAkB,GAAG,CAACX,EAAQX,EAAM,IAAI,EAAE,MAAO,CACjD,KAAK,IAAIiB,EAAMX,EAAmB,OAAO,GAAG,KAAIE,EAAc,QAAQC,EAAaT,CAAK,EAAEM,EAAmB,QAA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K,OAAO,SAAS,WAAW,gBAAgB,YAAY,aAAa,CAAC,SAAS,GAAG,WAAW,GAAG,CAAC,EAAE,MAAM,CAAC,KAAKA,EAAY,MAAM,aAAa,MAAM,EAAE,WAAW,CAAC,KAAKA,EAAY,QAAQ,aAAa,EAAI,EAAE,IAAI,CAAC,KAAKA,EAAY,KAAK,MAAM,MAAM,aAAa,IAAI,wBAAwB,GAAK,QAAQ,CAAC,KAAK,KAAK,KAAK,GAAG,EAAE,aAAa,CAAC,KAAK,KAAK,KAAK,GAAG,EAAE,YAAY,oEAAoE,CAAC,CAAC,EAAE,IAAMtB,EAAaT,GAAO,CAAC,IAAMgC,EAAOhC,EAAM,KAAK,OAAaiC,EAAWjC,EAAM,WAAiBkC,EAAalC,EAAM,KAAWmC,EAAUnC,EAAM,QAAQ,UAAgBoC,EAAWpC,EAAM,QAAQ,WAAW,GAAGgC,GAAQ,EAAG,MAAM,GAAI,IAAIK,EAAO,GAAOC,EAAS,GAAG,QAAQC,EAAE,EAAEA,EAAEP,EAAOO,IAAI,CAAC,IAAMC,EAAaN,EAAaK,CAAC,EACprD,GAAGH,IAAaI,IAAe,KAAKA,IAAe,KAAK,CAACH,GAAQG,EAAa,QAAS,CAAC,IAAIC,EAAQ,GAAGA,EAAQR,EAAW,KAAK,MAAM,KAAK,OAAO,EAAEA,EAAW,MAAM,CAAC,EAClKE,GAAWK,IAAcC,EAAQD,IAAeA,EAAa,YAAY,EAAEC,EAAQ,YAAY,EAAEA,EAAQ,YAAY,SAAUA,IAAUH,GAAUL,EAAW,QAAQ,GAAEI,GAAQI,EAAQH,EAASG,CAAQ,CAAC,OAAOJ,CAAO",
  "names": ["TextDecrypt", "props", "_props_style", "isCanvas", "RenderTarget", "componentRef", "pe", "lastUpdatePosition", "lastScrollY", "encryptedText", "randomString", "text", "setText", "ye", "scrollY", "useScroll", "ue", "unsubscribe", "value", "element", "rect", "viewportHeight", "window", "relativePosition", "encryptionRangeStart", "encryptionRangeEnd", "encryptionRange", "percentage", "numberOfEncryptedCharacters", "Tag", "p", "addPropertyControls", "ControlType", "length", "characters", "originalText", "matchCase", "keepSpaces", "result", "lastChar", "i", "originalChar", "newChar"]
}
