1import{s as fe,p as we,r as t,J as n,j as e,L as ge}from"./vendor-CSpQeQFa.js";import{i as be,s as l,B as j}from"./entry-main-PLc9_a6q.js";import{u as ye,A as je}from"./MarketingHeader-DURgYL2j.js";import{I}from"./globalAnnouncements-nxd9yA1b.js";import{L as H}from"./contestTypes-D51N3MT-.js";import{C as ve,c as v,a as ke,b as Ce,d as Ne}from"./uploadLimits-Bk-o1hAt.js";import{m as w,r as Se,d as X,a as U}from"./brandClaimErrors-DKWl3Kz1.js";import{G as _e}from"./BrandWordmark-W5P5jQbV.js";import{L as k}from"./BonusExpiryCountdown-DZAQV4Wx.js";import{C as W}from"./PendingApproval-BMg-Cjnx.js";import{C as O}from"./modelFamilies-Dcg73pIM.js";import{a as Ee}from"./perfConfigSelect-DHd8mvGs.js";const F=be("brand").name,We=()=>{const C=fe(),[G,K]=we();ye();const p=G.get("token")||"",L=G.get("linked"),[d,r]=t.useState("loading"),[Z,g]=t.useState(""),[ee,se]=t.useState(""),[D,ae]=t.useState(""),[re,V]=t.useState(!1),[te,Y]=t.useState(!1),[N,ne]=t.useState(""),[T,oe]=t.useState(""),[ie,ce]=t.useState(!1),[b,le]=t.useState({hasGoogle:!1,hasDiscord:!1}),[de,J]=t.useState(!1),[E,B]=t.useState(null),ue=t.useCallback(async()=>{const{data:s}=await l.auth.getUser(),a=s.user?.identities??[],o={hasGoogle:a.some(i=>i.provider==="google"),hasDiscord:a.some(i=>i.provider==="discord")};le(o);const A=s.user?.email??"";return A&&!A.endsWith("@anthum-claims.invalid")&&V(!0),o},[]);t.useEffect(()=>{let s=!1,a=null;const o=async()=>{if(typeof window>"u")return null;const i=window.location.hash.startsWith("#")?window.location.hash.slice(1):"";if(!i)return null;const x=new URLSearchParams(i),m=x.get("access_token"),c=x.get("refresh_token");if(!m||!c)return null;const{data:h,error:z}=await l.auth.setSession({access_token:m,refresh_token:c});if(z||!h.session?.user)return null;try{window.history.replaceState(null,"",window.location.pathname+window.location.search)}catch{}return h.session.user.id},A=async()=>{const{data:i}=await l.auth.getSession();if(i.session?.user)return i.session.user.id;const x=await o();return x||new Promise(m=>{const c=setTimeout(()=>{a?.unsubscribe(),m(null)},6e3),h=l.auth.onAuthStateChange((z,_)=>{_?.user&&(clearTimeout(c),h.data.subscription.unsubscribe(),m(_.user.id))});a=h.data.subscription})};return(async()=>{if(!p){r("error"),g("Missing claim token.");return}const i=await A();if(s)return;if(!i){r("no_session");return}const{data:x,error:m}=await l.functions.invoke("auth-brand-claim-v1",{body:{action:"validate",token:p}});if(s)return;if(m){r("error"),g(await w(m,"This claim link could not be verified."));return}const c=x;if(c?.status==="claimed"){r("done"),setTimeout(()=>C("/company-dashboard"),800);return}if(c?.status==="revoked"){r("error"),g(`This claim link has been revoked. Reach out to your ${F} contact for a new one.`);return}if(c?.status==="expired"){r("error"),g(`This claim link has expired. Reach out to your ${F} contact for a new one.`);return}if(c?.status==="not_found"){r("error"),g("We couldnât find this claim link. It may have been revoked or never existed.");return}if(c?.status!=="valid"){r("error"),g("This claim link is no longer valid.");return}se(c.company_name||"your brand");const{data:h,error:z}=await l.from("brand_claims").select("brand_user_id").eq("token",p).maybeSingle();if(z||!h){r("mismatch");return}if(h.brand_user_id!==i){r("mismatch");return}const _=await ue(),f=L==="google"||L==="discord"?L:null,M=Se(window.location.search,window.location.hash);if(f||M){if((f==="google"?_.hasGoogle:f==="discord"?_.hasDiscord:!1)&&!M)n.success(`${f==="google"?"Google":"Discord"} connected`);else{const $=f==="google"?"Google":f==="discord"?"Discord":"that account";n.error(`Could not connect ${$}`,{description:X(f,M??"",F)})}const Q=new URLSearchParams(G);for(const $ of["linked","error","error_code","error_description"])Q.delete($);K(Q,{replace:!0}),window.location.hash&&window.history.replaceState(null,"",window.location.pathname+window.location.search)}r("ready")})(),()=>{s=!0,a?.unsubscribe()}},[p]);const me=async()=>{const s=D.trim().toLowerCase();if(!s)return n.error("Enter an email to continue"),!1;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s))return n.error("That email address doesnât look right"),!1;Y(!0);try{const{data:a,error:o}=await l.functions.invoke("auth-brand-claim-v1",{body:{action:"set-email",token:p,email:s}});return o?(n.error("Could not set email",{description:await w(o)}),!1):a?.error?(n.error("Could not set email",{description:await w(new Error(a.error))}),!1):(V(!0),!0)}catch(a){return n.error("Could not set email",{description:await w(a)}),!1}finally{Y(!1)}},he=async()=>
1{if(N.length<8)return n.error("Password must be at least 8 characters"),!1;if(N!==T)return n.error("Passwords do not match"),!1;J(!0);try{const{error:s}=await l.auth.updateUser({password:N});return s?(n.error("Could not set password",{description:U(s.message)}),!1):(ce(!0),!0)}catch(s){return n.error("Could not set password",{description:s instanceof Error?U(s.message):"Please try again."}),!1}finally{J(!1)}},q=async s=>{B(s);try{const a=`${window.location.origin}/claim-brand/setup?token=${encodeURIComponent(p)}&linked=${s}`,{error:o}=await l.auth.linkIdentity({provider:s,options:{redirectTo:a}});if(o){B(null),n.error(`Could not connect ${s==="google"?"Google":"Discord"}`,{description:X(s,o.message,F)});return}}catch(a){B(null),n.error(`Could not connect ${s==="google"?"Google":"Discord"}`,{description:a instanceof Error?U(a.message):"Please try again."})}},S=re&&ie||b.hasGoogle||b.hasDiscord,pe=D.trim().length>0&&N.length>=8&&T.length>0,u=d==="finishing"||te||de,P=t.useRef(!1),R=async()=>{r("finishing");try{const{data:s,error:a}=await l.functions.invoke("auth-brand-claim-v1",{body:{action:"complete",token:p}});if(a){r("ready"),n.error("Could not finish setup",{description:await w(a)});return}if(s?.error){r("ready"),n.error("Could not finish setup",{description:await w(new Error(s.error))});return}try{await l.auth.refreshSession()}catch(o){console.warn("[ClaimBrandSetup] post-complete session refresh failed:",o)}r("done"),setTimeout(()=>C("/company-dashboard"),800)}catch(s){r("ready"),n.error("Could not finish setup",{description:await w(s)})}},xe=async()=>{if(S){P.current=!0,await R();return}await me()&&await he()&&(P.current=!0,await R())};t.useEffect(()=>{P.current||d==="ready"&&S&&(P.current=!0,R())},[S,d]);const y=(s,a,o)=>e.jsxs(ke,{className:"space-y-4 px-6 pt-8 text-center sm:px-8 sm:pt-10",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-zinc-900 text-white shadow-[0_16px_30px_-18px_rgba(15,23,42,0.6)]",children:o}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ce,{className:"font-serif text-3xl tracking-tight text-zinc-900 sm:text-4xl",children:s}),e.jsx(Ne,{className:"text-sm text-zinc-600 sm:text-base",children:a})]})]});return e.jsxs("div",{className:"min-h-screen bg-white text-zinc-900",children:[e.jsx("div",{className:"pointer-events-none fixed inset-0 bg-[radial-gradient(circle_at_top,rgba(244,244,245,0.95),rgba(255,255,255,0)_42%)]"}),e.jsx("header",{className:"sticky top-0 z-10 border-b border-zinc-200/80 bg-white/90 backdrop-blur-sm",children:e.jsx("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-4",children:e.jsx(ge,{to:"/",className:"flex items-center gap-2 text-zinc-900 hover:text-zinc-700","aria-label":"General Creative home",children:e.jsx(_e,{surface:"light",className:"h-8",eager:!0})})})}),e.jsx("main",{className:"relative mx-auto flex min-h-[calc(100vh-57px)] max-w-5xl flex-col justify-center px-4 py-8 sm:py-10",children:e.jsxs(ve,{className:"mx-auto w-full max-w-2xl rounded-[2rem] border border-zinc-200/80 bg-white shadow-[0_22px_70px_-45px_rgba(15,23,42,0.32)]",children:[d==="loading"&&e.jsxs(e.Fragment,{children:[y("Setting things upâ¦","One moment while we verify your link.",e.jsx(k,{className:"h-7 w-7 animate-spin"})),e.jsx(v,{className:"flex flex-col items-center px-6 pb-8 sm:px-8 sm:pb-10",children:e.jsx(k,{className:"h-10 w-10 animate-spin text-zinc-900"})})]}),d==="no_session"&&e.jsxs(e.Fragment,{children:[y("Sign in expired","Your sign-in link timed out. Go back to your claim link to try again.",e.jsx(O,{className:"h-7 w-7"})),e.jsx(v,{className:"px-6 pb-8 sm:px-8 sm:pb-10",children:e.jsx(j,{onClick:()=>C("/"),className:"min-h-[48px] w-full rounded-xl bg-[#1A1A1A] text-white shadow-[0_16px_36px_rgba(17,24,39,0.18)] transition-colors hover:bg-black",children:"Go home"})})]}),d==="mismatch"&&e.jsxs(e.Fragment,{children:[y("Wrong account","You're signed in with a different account than this claim link is for. Sign out and click the claim link again.",e.jsx(O,{className:"h-7 w-7"})),e.jsx(v,{className:"px-6 pb-8 sm:px-8 sm:pb-10",children:e.jsx(j,{onClick:()=>C("/logout"),className:"min-h-[48px] w-full rounded-xl bg-[#1A1A1A] text-white shadow-[0_16px_36px_rgba(17,24,39,0.18)] transition-colors hover:bg-black",children:"Sign out"})})]}),d==="error"&&e.jsxs(e.Fragment,{children:[y("Something went wrong",Z||"Please try again or c
1ontact support.",e.jsx(O,{className:"h-7 w-7"})),e.jsx(v,{className:"px-6 pb-8 sm:px-8 sm:pb-10",children:e.jsx(j,{onClick:()=>C("/"),className:"min-h-[48px] w-full rounded-xl bg-[#1A1A1A] text-white shadow-[0_16px_36px_rgba(17,24,39,0.18)] transition-colors hover:bg-black",children:"Go home"})})]}),(d==="ready"||d==="finishing")&&e.jsxs(e.Fragment,{children:[y(`Welcome to ${ee}`,"Choose how you want to sign in from now on.",e.jsx(Ee,{className:"h-7 w-7"})),e.jsxs(v,{className:"space-y-5 px-6 pb-8 sm:px-8 sm:pb-10",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(j,{type:"button",variant:"outline",onClick:()=>q("google"),disabled:!!E||b.hasGoogle||u,className:"min-h-[44px] w-full justify-center gap-2",children:[E==="google"?e.jsx(k,{className:"h-4 w-4 animate-spin"}):e.jsx(Pe,{}),"Continue with Google",b.hasGoogle&&e.jsx(W,{className:"h-4 w-4 text-emerald-600"})]}),e.jsxs(j,{type:"button",variant:"outline",onClick:()=>q("discord"),disabled:!!E||b.hasDiscord||u,className:"min-h-[44px] w-full justify-center gap-2",children:[E==="discord"?e.jsx(k,{className:"h-4 w-4 animate-spin"}):e.jsx(Ae,{}),"Continue with Discord",b.hasDiscord&&e.jsx(W,{className:"h-4 w-4 text-emerald-600"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":"true",children:e.jsx("span",{className:"w-full border-t border-zinc-200"})}),e.jsx("div",{className:"relative flex justify-center",children:e.jsx("span",{className:"bg-card px-3 text-xs uppercase tracking-wide text-zinc-500",children:"or"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"cbs-email",className:"sr-only",children:"Email"}),e.jsx(I,{id:"cbs-email",type:"email",value:D,onChange:s=>ae(s.target.value),placeholder:"[email protected]",autoComplete:"email",disabled:u}),e.jsx(H,{htmlFor:"cbs-password",className:"sr-only",children:"Password"}),e.jsx(I,{id:"cbs-password",type:"password",value:N,onChange:s=>ne(s.target.value),placeholder:"Password (8+ characters)",autoComplete:"new-password",disabled:u}),e.jsx(H,{htmlFor:"cbs-confirm",className:"sr-only",children:"Confirm password"}),e.jsx(I,{id:"cbs-confirm",type:"password",value:T,onChange:s=>oe(s.target.value),placeholder:"Confirm password",autoComplete:"new-password",disabled:u})]}),e.jsxs(j,{onClick:xe,disabled:u||!S&&!pe,className:"min-h-[48px] w-full rounded-xl bg-[#1A1A1A] text-white shadow-[0_16px_36px_rgba(17,24,39,0.18)] transition-colors hover:bg-black",children:[u&&e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}),S?"Continue":"Create account",!u&&e.jsx(je,{className:"ml-2 h-4 w-4"})]})]})]}),d==="done"&&e.jsxs(e.Fragment,{children:[y("Youâre all set","Taking you to your dashboardâ¦",e.jsx(W,{className:"h-7 w-7"})),e.jsx(v,{className:"flex flex-col items-center px-6 pb-8 sm:px-8 sm:pb-10",children:e.jsx(k,{className:"h-10 w-10 animate-spin text-zinc-900"})})]})]})})]})};function Pe(){return e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24","aria-hidden":"true",children:[e.jsx("path",{fill:"#4285F4",d:"M23.06 12.27c0-.84-.07-1.65-.21-2.43H12v4.59h6.21c-.27 1.45-1.08 2.67-2.31 3.49v2.9h3.73c2.18-2.01 3.43-4.97 3.43-8.55z"}),e.jsx("path",{fill:"#34A853",d:"M12 24c3.11 0 5.72-1.03 7.63-2.79l-3.73-2.9c-1.03.69-2.35 1.1-3.9 1.1-3 0-5.55-2.03-6.46-4.75H1.69v2.99C3.59 21.34 7.5 24 12 24z"}),e.jsx("path",{fill:"#FBBC04",d:"M5.54 14.66c-.23-.69-.36-1.43-.36-2.18s.13-1.49.3
16-2.18V7.31H1.69A11.97 11.97 0 0 0 0 12.48c0 1.94.47 3.78 1.69 5.17l3.85-2.99z"}),e.jsx("path",{fill:"#EA4335",d:"M12 4.77c1.69 0 3.21.58 4.41 1.72l3.31-3.31C17.71 1.27 15.1 0 12 0 7.5 0 3.59 2.66 1.69 6.54l3.85 2.99C6.45 6.8 9 4.77 12 4.77z"})]})}function Ae(){return e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fill:"#5865F2",d:"M20.317 4.37a19.79 19.79 0 0 0-4.885-1.515.074.074 0 0 0-.079.036 13.84 13.84 0 0 0-.61 1.25 18.27 18.27 0 0 0-5.487 0 12.62 12.62 0 0 0-.617-1.25.077.077 0 0 0-.079-.036A19.74 19.74 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.91 19.91 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.873-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.1 13.1 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.009c.12.099.246.198.373.292a.077.077 0 0 1-.006.127 12.3 12.3 0 0 1-1.873.892.077.077 0 0 0-.04.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.84 19.84 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.06.06 0 0 0-.031-.03zM8.02 15.33c-1.182 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}export{We as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.