{"version":3,"file":"SignInCode._EYw0mHM.mjs","names":["useState","__esmMin","init_ssg_sandbox_shims","_e","p","c","init_jsx_runtime","init_npm_react_18_3_1","window","ROUTES","normalizeReturnTo","normalizeAbleLiveDoor","init_supabaseClient","supabase","normalizeStudySource","RETURN_PARAM","init_ROUTES","init_config","readCarry","top","search","nested","rt","q","pick","key","readLinkLanding","carry","tokenHash","TOKEN_HASH_SHAPE","LINK_TYPE","h","hash","onLoadAction","landing","pressVerifyArgs","normalizeCode","digits","raw","callbackAddress","params","qs","origin","path","rememberEmail","email","EMAIL_KEY","recallEmail","SIGNIN_COPY","init_signInLink","SignInCode","code","setCode","busy","setBusy","error","setError","submit","e","token","verifyError","data","err","styles","CODE_ERROR_ID","P_BODY","init_SignInCode"],"sources":["https:/framerusercontent.com/modules/YsJtajiju0eD6CdLTX92/J97mPW7Gk8w4j0YcIpiI/signInLink.js","https:/framerusercontent.com/modules/NTN4jmFQkWIJxrKXualr/fGjh681unXsFceUEUmlr/SignInCode.js"],"sourcesContent":["// SIGN IN THAT SURVIVES A MAIL SCANNER (branch build, November 20 2026).\n// NOT LIVE. Nothing here is published, and the two Supabase email templates\n// that would point men at it are unchanged. Going live waits on Eric's word.\n//\n// Why it exists: a company mail scanner (Microsoft Safe Links, by every sign)\n// opened each of a man's sign in links within a minute of delivery. The links\n// pointed straight at Supabase's /auth/v1/verify, where a plain GET spends the\n// token, so every press of his own was refused.\n//\n// The fix has two halves, and either one gets a man in:\n//   1. The emailed link lands on OUR page carrying the token hash. Loading the\n//      page spends nothing. Only his press calls verifyOtp.\n//   2. The email also carries the code, which he can type on the sign in page.\n//      That works when he reads mail on one device and signs in on another.\n//\n// This file is pure (no React, no Supabase client) so the scanner test can run\n// it under tsx. LoginCallback and LoginMagic both route through it.\nimport{normalizeAbleLiveDoor,normalizeReturnTo,normalizeStudySource,RETURN_PARAM}from\"https://framerusercontent.com/modules/9KOsKMMSsSANpMN372pX/eVrSYHyXVTDkpRnZQlmn/config.js\";/** The only verify type the new link may carry. \"email\" covers both the\n *  first email (signup confirmation) and the later one (magic link), per the\n *  Supabase passwordless and PKCE email guides read November 20 2026. */const LINK_TYPE=\"email\";// A token hash is lowercase hex (56 characters in every email read live).\n// Anything else is refused rather than sent to the server.\nconst TOKEN_HASH_SHAPE=/^[a-f0-9]{20,128}$/;/**\n * Read the carried values. The new email template places Supabase's own\n * RedirectTo at the END of the link, as `redirect_to=`. Whether Supabase\n * escapes it there is not verified, so both shapes are read:\n *   escaped: redirect_to holds the whole callback address, its query inside.\n *   raw:     redirect_to holds the address up to its first \"&\", and every\n *            later parameter (next) arrives at the top level.\n * A top level value wins; the nested one fills what is missing.\n */export function readCarry(search){const top=new URLSearchParams(search);let nested=new URLSearchParams;const rt=top.get(\"redirect_to\");if(rt){const q=rt.indexOf(\"?\");if(q>=0)nested=new URLSearchParams(rt.slice(q+1));}const pick=key=>top.get(key)??nested.get(key);return{source:normalizeStudySource(pick(\"source\")),next:normalizeReturnTo(pick(RETURN_PARAM)),door:normalizeAbleLiveDoor(pick(\"source\"))};}/** Decide what the callback page was handed. Pure: reads strings, calls\n *  nothing, spends nothing. */export function readLinkLanding(search,hash){const carry=readCarry(search);const top=new URLSearchParams(search);const tokenHash=(top.get(\"token_hash\")??\"\").trim().toLowerCase();if(tokenHash&&TOKEN_HASH_SHAPE.test(tokenHash)){return{kind:\"press\",tokenHash,type:LINK_TYPE,carry};}const h=new URLSearchParams((hash||\"\").replace(/^#/,\"\"));if(h.get(\"access_token\")&&h.get(\"refresh_token\")){return{kind:\"tokens\",carry};}if(h.get(\"error\")||h.get(\"error_code\")||h.get(\"error_description\")){return{kind:\"refused\",carry,errorCode:h.get(\"error_code\")};}// A token_hash that failed the shape check lands here: treated as a\n// spent link, never sent to the server.\nif(tokenHash)return{kind:\"refused\",carry,errorCode:\"bad_link\"};return{kind:\"none\",carry};}export function onLoadAction(landing){if(landing.kind===\"press\")return\"wait_for_press\";if(landing.kind===\"refused\")return\"show_fresh_link\";return\"restore_session\";}/** The verifyOtp arguments for his press. Built here so the test can see\n *  exactly what the page would send. */export function pressVerifyArgs(landing){if(landing.kind!==\"press\")return null;return{token_hash:landing.tokenHash,type:landing.type};}/** Codes are digits. The project's code length is a Supabase setting not\n *  readable from here (six by default), so six to ten digits are accepted. */export function normalizeCode(raw){const digits=(raw||\"\").replace(/\\s+/g,\"\");return/^[0-9]{6,10}$/.test(digits)?digits:null;}/** The callback address a fresh link (or a code sign in) returns to, with\n *  the carried values. Mirrors LoginMagic's getRedirectTo exactly. */export function callbackAddress(origin,path,carry){const params=new URLSearchParams;// One parameter, two whitelists. A Study source and the Live door can\n// never both be set: they are read from the same value.\nif(carry.source)params.set(\"source\",carry.source);else if(carry.door)params.set(\"source\",carry.door);if(carry.next)params.set(RETURN_PARAM,carry.next);const qs=params.toString();return qs?`${origin}${path}?${qs}`:`${origin}${path}`;}/* The address he typed, remembered on this device only, so a refused link\n   can offer a fresh one without asking again. Fail soft: a browser that\n   blocks storage simply shows an empty field. */const EMAIL_KEY=\"able.signin.email\";export function rememberEmail(email){try{if(typeof window!==\"undefined\"&&email)window.localStorage.setItem(EMAIL_KEY,email);}catch{/* storage blocked: the field starts empty */}}export function recallEmail(){try{if(typeof window===\"undefined\")return\"\";return window.localStorage.getItem(EMAIL_KEY)??\"\";}catch{return\"\";}}/* Every word a man reads in this build. DRAFTS for Eric's ruling: none of\n   these lines is ratified. Kept as string literals so the language gate,\n   which reads quoted strings only, reads every one. */export const SIGNIN_COPY={pressStatus:\"Your secure link is ready.\",pressBody:\"Press continue to sign in on this device.\",pressButton:\"Continue →\",pressBusy:\"Signing you in…\",refusedStatus:\"This link has already been used or has run out.\",refusedBody:\"Some work email services open links before you do. Enter your email and we will send a fresh one. The email also carries a code you can enter here instead.\",emailLabel:\"Email address\",emailPlaceholder:\"you@example.com\",emailEmpty:\"Please enter a valid email.\",sendButton:\"Send a fresh link →\",sendBusy:\"Sending…\",sent:\"A fresh link is on the way. Open it on this device, or enter the code from the email below.\",notFound:\"We could not find that email. If you are new, start from the beginning.\",startOver:\"Start your Personal Study →\",sendFailed:\"That did not send. Try once more in a minute.\",codeHint:\"If the link does not open for you, enter the code from the same email here.\",codeLabel:\"Code from your email\",codePlaceholder:\"Code\",codeButton:\"Sign in with the code →\",codeBusy:\"Checking…\",codeShape:\"Enter the code exactly as it appears in the email.\",codeRefused:\"That code did not work. It may have been used or run out. Ask for a fresh link and use the new code.\"};\nexport const __FramerMetadata__ = {\"exports\":{\"OnLoad\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"pressVerifyArgs\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"rememberEmail\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"readLinkLanding\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"normalizeCode\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"onLoadAction\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SIGNIN_COPY\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"LinkLanding\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"recallEmail\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"callbackAddress\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"Carry\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"readCarry\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./signInLink.map","\"use client\";import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";// The code half of the scanner fix (branch build, November 20 2026, NOT LIVE).\n// He types the code from the email; verifyOtp checks it against the address he\n// gave; on success he is sent to the callback page, which restores the session\n// and routes him exactly as a link would. Shared by LoginMagic (after he asks\n// for a link) and LoginCallback (after a refused link). See signInLink.ts.\nimport{useState}from\"react\";import{supabase}from\"https://framerusercontent.com/modules/Tt0bQy8fCu2hKLpH1MyG/mAc7bzUUBHrpgGIpzDY6/supabaseClient.js\";import{ROUTES}from\"https://framerusercontent.com/modules/n1H0JpfNZVcIm3Nivtgu/DfzvtrCKnr6RJt4oGnbp/ROUTES.js\";import{callbackAddress,normalizeCode,SIGNIN_COPY}from\"https://framerusercontent.com/modules/YsJtajiju0eD6CdLTX92/J97mPW7Gk8w4j0YcIpiI/signInLink.js\";const P_BODY=\"'Manrope', 'Segoe UI', Arial, sans-serif\";const CODE_ERROR_ID=\"able-signin-code-error\";export default function SignInCode({email,carry}){const[code,setCode]=useState(\"\");const[busy,setBusy]=useState(false);const[error,setError]=useState(null);async function submit(e){e.preventDefault();if(busy)return;const token=normalizeCode(code);if(!token){setError(SIGNIN_COPY.codeShape);return;}setBusy(true);setError(null);try{const{data,error:verifyError}=await supabase.auth.verifyOtp({email:email.trim(),token,type:\"email\"});if(verifyError||!data?.session){console.warn(\"verifyOtp (code) refused:\",verifyError);setError(SIGNIN_COPY.codeRefused);setBusy(false);return;}window.location.replace(callbackAddress(window.location.origin,ROUTES.authCallback,carry));}catch(err){console.error(\"verifyOtp (code) failed:\",err);setError(SIGNIN_COPY.codeRefused);setBusy(false);}}return /*#__PURE__*/_jsxs(\"form\",{onSubmit:submit,style:styles.form,children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"signin-code\",style:styles.label,children:SIGNIN_COPY.codeLabel}),/*#__PURE__*/_jsx(\"input\",{id:\"signin-code\",type:\"text\",inputMode:\"numeric\",autoComplete:\"one-time-code\",value:code,onChange:e=>setCode(e.target.value),placeholder:SIGNIN_COPY.codePlaceholder,style:styles.input,disabled:busy,\"aria-invalid\":Boolean(error)||undefined,\"aria-describedby\":error?CODE_ERROR_ID:undefined}),error&&/*#__PURE__*/_jsx(\"p\",{id:CODE_ERROR_ID,role:\"alert\",style:styles.error,children:error}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:busy,style:{...styles.button,opacity:busy?.7:1},children:busy?SIGNIN_COPY.codeBusy:SIGNIN_COPY.codeButton})]});}// Field and button mirror LoginMagic and the callback's name stop exactly.\nconst styles={form:{display:\"grid\",gap:12,marginTop:14,textAlign:\"left\"},label:{fontFamily:P_BODY,fontSize:14,fontWeight:500,lineHeight:1.5,color:\"var(--able-slate, #3C4A5E)\"},input:{minHeight:44,fontFamily:P_BODY,width:\"100%\",padding:\"12px 12px\",borderRadius:12,border:\"1px solid var(--able-border, #E7E2D6)\",background:\"var(--able-field, #FFFFFF)\",color:\"var(--able-ink, #15233B)\",fontSize:17,letterSpacing:\"0.12em\",boxSizing:\"border-box\"},error:{fontFamily:P_BODY,fontSize:17,lineHeight:1.5,fontWeight:500,margin:0,color:\"var(--able-warn, #B0533C)\"},button:{minHeight:48,fontFamily:P_BODY,width:\"100%\",padding:\"14px 0\",borderRadius:12,border:\"none\",fontWeight:600,fontSize:17,color:\"var(--able-on-strong, #FCFBF8)\",background:\"var(--able-strong, #15233B)\",transition:\"opacity .25s ease\",boxSizing:\"border-box\",cursor:\"pointer\"}};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SignInCode\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"A,yOA6BG,SAAgBkB,EAAU,EAAO,CAAC,IAAMC,EAAI,IAAI,gBAAgBC,CAAM,EAAMC,EAAO,IAAI,gBAAsBC,EAAGH,EAAI,IAAI,aAAa,EAAE,GAAGG,EAAG,CAAC,IAAMC,EAAED,EAAG,QAAQ,GAAG,EAAKC,GAAG,IAAE,EAAO,IAAI,gBAAgBD,EAAG,MAAMC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAMC,EAAK,GAAKL,EAAI,IAAIM,CAAG,GAAGJ,EAAO,IAAII,CAAG,EAAE,MAAM,CAAC,OAAOX,EAAq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