{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/dfCZhBptRU5U4BnAqghU/Y7S8WriD0KPKY3SB71fv/NegentropyText.js"],
  "sourcesContent": ["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{motion,useInView}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";function shuffle(text){const chars=text.split(\"\");for(let i=chars.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[chars[i],chars[j]]=[chars[j],chars[i]];}return chars.join(\"\");}/**\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 200\n */export default function NegentropyText(props){const{text,speed,style,font,fontColor,fontSize,fontWeight,textAlign}=props;const[displayText,setDisplayText]=useState(\"\");const ref=useRef(null);const inView=useInView(ref,{margin:\"0px\"});const frameRef=useRef(null);const lastUpdate=useRef(0);useEffect(()=>{if(!inView||!text)return;setDisplayText(\"\");let step=1;let recoveryCount=0;let inRecovery=false;const update=timestamp=>{if(lastUpdate.current===0||timestamp-lastUpdate.current>=speed){lastUpdate.current=timestamp;const currentStep=Math.min(step,text.length);const currentText=text.slice(0,currentStep);if(!inRecovery&&(currentText.endsWith(\" \")||step>text.length)){inRecovery=true;}if(inRecovery){recoveryCount++;const fixed=currentText.slice(0,recoveryCount);const shuffled=shuffle(currentText.slice(recoveryCount));setDisplayText(fixed+shuffled);}else{setDisplayText(shuffle(currentText));}if(step<text.length||recoveryCount<text.length){step++;}else{return;// Stop requesting frames\n}}frameRef.current=requestAnimationFrame(update);};frameRef.current=requestAnimationFrame(update);return()=>{if(frameRef.current)cancelAnimationFrame(frameRef.current);lastUpdate.current=0;};},[inView,text,speed]);return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",display:\"flex\",overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",translate:\"no\",lang:\"zxx\",style:{...style,...font,position:\"relative\",visibility:\"hidden\",color:fontColor,textAlign,whiteSpace:\"pre-wrap\",display:\"inline-block\",userSelect:\"none\"},children:text}),/*#__PURE__*/_jsx(motion.div,{ref:ref,\"aria-label\":text,style:{...style,...font,position:\"absolute\",top:0,left:0,color:fontColor,textAlign,whiteSpace:\"pre-wrap\",display:\"inline-block\"},children:displayText})]});}NegentropyText.defaultProps={text:\"Architecture for the web, grounded in semantics.\",speed:25,color:\"#fff\",textAlign:\"left\"};addPropertyControls(NegentropyText,{text:{type:ControlType.String,title:\"Content\",defaultValue:NegentropyText.defaultProps.text,displayTextArea:true},font:{//@ts-ignore\ntype:ControlType.Font,controls:\"extended\",displayFontSize:true,displayTextAlignment:false,displayVariable:true,defaultFontType:\"monospace\",defaultValue:{fontSize:16,lineHeight:\"1.2em\"}},fontColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#fff\"},textAlign:{type:ControlType.Enum,title:\"Text Alignment\",defaultValue:\"left\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"]},speed:{type:ControlType.Number,title:\"Typing Speed\",min:5,max:100,step:5,defaultValue:25},info:{type:ControlType.Object,title:\"info\",description:\"Want to learn more about this component? Check out the [Documentation](https://semanticground.com/resources/negentropy-text).\",controls:{help:{type:ControlType.Enum,title:\"contact\",description:\"If you have any questions or need support, you can also leave a message at [Semantic Ground](https://semanticground.com)\",defaultValue:\"needhelp\",displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",options:[\"needhelp\"],optionTitles:[\"Need Help?\"]}}}});NegentropyText.displayName=\"Negentropy Text\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NegentropyText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"200\",\"framerIntrinsicWidth\":\"200\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL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AKA,EAAY,MAAM,MAAM,aAAa,aAAa,MAAM,EAAE,UAAU,CAAC,KAAKA,EAAY,KAAK,MAAM,iBAAiB,aAAa,OAAO,wBAAwB,GAAK,0BAA0B,WAAW,QAAQ,CAAC,OAAO,SAAS,OAAO,EAAE,aAAa,CAAC,OAAO,SAAS,OAAO,CAAC,EAAE,MAAM,CAAC,KAAKA,EAAY,OAAO,MAAM,eAAe,IAAI,EAAE,IAAI,IAAI,KAAK,EAAE,aAAa,EAAE,EAAE,KAAK,CAAC,KAAKA,EAAY,OAAO,MAAM,OAAO,YAAY,gIAAgI,SAAS,CAAC,KAAK,CAAC,KAAKA,EAAY,KAAK,MAAM,UAAU,YAAY,2HAA2H,aAAa,WAAW,wBAAwB,GAAK,0BAA0B,aAAa,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAEhC,EAAe,YAAY",
  "names": ["shuffle", "text", "chars", "i", "j", "NegentropyText", "props", "speed", "style", "font", "fontColor", "fontSize", "fontWeight", "textAlign", "displayText", "setDisplayText", "ye", "ref", "pe", "inView", "useInView", "frameRef", "lastUpdate", "ue", "step", "recoveryCount", "inRecovery", "update", "timestamp", "currentStep", "currentText", "fixed", "shuffled", "u", "p", "motion", "addPropertyControls", "ControlType"]
}
