{"version":3,"file":"PasswordProtection.CorOO2jR.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/shrffXryaxkOgA32XeQn/F1NnKMA5KVMVJMcozB6P/PasswordProtection.js"],"sourcesContent":["// Full-screen password protection component with OTP-style input\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";/**\n * Password Protection\n *\n * @framerIntrinsicWidth 1200\n * @framerIntrinsicHeight 800\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function PasswordProtection(props){const{password=\"1234\",redirectUrl=\"\",rememberPassword=true,backgroundColor=\"#000000\",overlayOpacity=95,title=\"Enter Passcode\",titleFont}=props;const[digits,setDigits]=useState([\"\",\"\",\"\",\"\"]);const[isUnlocked,setIsUnlocked]=useState(false);const[isError,setIsError]=useState(false);const inputRefs=useRef([]);useEffect(()=>{if(typeof window!==\"undefined\"&&rememberPassword){const stored=localStorage.getItem(\"sitePasswordUnlocked\");if(stored===password){startTransition(()=>setIsUnlocked(true));}}},[password,rememberPassword]);useEffect(()=>{if(inputRefs.current[0]&&!isUnlocked){inputRefs.current[0].focus();}},[isUnlocked]);const handleChange=(index,value)=>{if(!/^\\d*$/.test(value))return;const newDigits=[...digits];newDigits[index]=value.slice(-1);startTransition(()=>{setDigits(newDigits);setIsError(false);});if(value&&index<3){inputRefs.current[index+1]?.focus();}};const handleKeyDown=(index,e)=>{if(e.key===\"Backspace\"&&!digits[index]&&index>0){inputRefs.current[index-1]?.focus();}};const handlePaste=e=>{e.preventDefault();const pastedData=e.clipboardData.getData(\"text\").replace(/\\D/g,\"\").slice(0,4);if(pastedData.length===4){const newDigits=pastedData.split(\"\");startTransition(()=>{setDigits(newDigits);setIsError(false);});inputRefs.current[3]?.focus();}};const handleSubmit=()=>{const enteredPassword=digits.join(\"\");if(enteredPassword===password){if(typeof window!==\"undefined\"&&rememberPassword){localStorage.setItem(\"sitePasswordUnlocked\",password);}startTransition(()=>setIsUnlocked(true));if(redirectUrl&&typeof window!==\"undefined\"){setTimeout(()=>{window.location.href=redirectUrl;},500);}}else{startTransition(()=>setIsError(true));setTimeout(()=>{startTransition(()=>{setIsError(false);setDigits([\"\",\"\",\"\",\"\"]);});inputRefs.current[0]?.focus();},500);}};// Auto-submit when all 4 digits are entered\nuseEffect(()=>{if(digits.every(d=>d!==\"\")){handleSubmit();}},[digits,password,redirectUrl,rememberPassword]);if(isUnlocked){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"}});}return /*#__PURE__*/_jsx(motion.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.5},style:{position:\"fixed\",top:0,left:0,right:0,bottom:0,width:\"100vw\",height:\"100vh\",backgroundColor:backgroundColor,opacity:overlayOpacity/100,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",zIndex:isUnlocked?0:9999,borderRadius:0,overflow:\"hidden\"},children:/*#__PURE__*/_jsxs(motion.div,{animate:isError?{x:[-10,10,-10,10,0]}:{},transition:{duration:.4},style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",gap:16,padding:40,pointerEvents:\"auto\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{textAlign:\"center\"},children:/*#__PURE__*/_jsx(\"h1\",{style:{margin:0,color:\"rgba(38, 38, 38, 0.65)\",...titleFont},children:title})}),/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",gap:12},children:digits.map((digit,index)=>/*#__PURE__*/_jsx(\"input\",{ref:el=>{inputRefs.current[index]=el;},type:\"text\",inputMode:\"numeric\",maxLength:1,value:digit,onChange:e=>handleChange(index,e.target.value),onKeyDown:e=>handleKeyDown(index,e),onPaste:index===0?handlePaste:undefined,style:{width:40,height:40,fontSize:16,fontWeight:500,textAlign:\"center\",backgroundColor:\"rgba(255, 255, 255, 0.1)\",backdropFilter:\"blur(50px)\",border:`1px solid ${isError?\"rgba(255, 88, 88, 0.5)\":\"rgba(38, 38, 38, 0.3)\"}`,borderRadius:12,color:\"#262626\",outline:\"none\",transition:\"all 0.2s ease\",caretColor:\"#262626\"},onFocus:e=>{e.target.style.border=\"1px solid #262626\";e.target.style.backgroundColor=\"rgba(255, 255, 255, 0.15)\";e.target.style.color=\"#262626\";},onBlur:e=>{e.target.style.border=`1px solid ${isError?\"rgba(255, 88, 88, 0.5)\":\"rgba(38, 38, 38, 0.3)\"}`;e.target.style.backgroundColor=\"rgba(255, 255, 255, 0.1)\";}},index))})]})});}addPropertyControls(PasswordProtection,{password:{type:ControlType.String,title:\"Password\",defaultValue:\"1234\",placeholder:\"Enter 4-digit code\"},redirectUrl:{type:ControlType.String,title:\"Redirect URL\",defaultValue:\"\",placeholder:\"https://example.com\"},rememberPassword:{type:ControlType.Boolean,title:\"Remember\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},overlayOpacity:{type:ControlType.Number,title:\"Opacity\",defaultValue:95,min:0,max:100,step:1,unit:\"%\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Enter Passcode\"},titleFont:{type:ControlType.Font,title:\"Title Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"16px\",variant:\"Regular\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PasswordProtection\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"1200\",\"framerIntrinsicHeight\":\"800\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PasswordProtection.map"],"mappings":"gQASG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,WAAS,OAAO,cAAY,GAAG,mBAAi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