@niledatabase/react 5.3.3-alpha.1 → 5.3.3-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client"
2
- import ce from"react";import{useForm as qo}from"react-hook-form";import{Mail as Wo}from"lucide-react";import*as g from"react";import{Slot as To}from"@radix-ui/react-slot";import{Controller as Uo,FormProvider as zo,useFormContext as Ze}from"react-hook-form";import{useQuery as zt}from"@tanstack/react-query";import{clsx as Do}from"clsx";import{twMerge as Io}from"tailwind-merge";import{auth as Le}from"@niledatabase/client";import Xe,{useContext as Tt,useRef as Mo,useState as No}from"react";import{QueryClient as Bt,QueryClientContext as Ut,QueryClientProvider as Fo}from"@tanstack/react-query";function L(e){let t=Tt(Ut),[o]=No(()=>e||t?null:new Bt),r=Mo(null);return e||t||o||(r.current||(r.current=new Bt),r.current)}function U({client:e,children:t}){let o=Tt(Ut),r=L(e);return!e&&o?Xe.createElement(Xe.Fragment,null,t):Xe.createElement(Fo,{client:r},t)}function d(...e){return Io(Do(e))}function he(e,t={},o){let r,n=t;if("init"in t){let{init:u,...a}=t;r=u,n=a}if("auth"in t){let{auth:u,...a}=t;r={...r,...u?.requestInit?u.requestInit:{}},n=a}let s={...n,...r||{},...o?.init?o.init:{},...o?.auth?.requestInit?o.auth.requestInit:{},...n||{}};s.headers={..."headers"in t?t.headers:{},"content-type":"application/json; charset=UTF-8"};let i=e;if(!("fetchUrl"in t)&&e.startsWith("/")){let u="auth"in t?t.auth:o?.auth,a=ko(o,t,u);i=`${Eo(o,t,u)}${a}${e}`}return fetch(i,s)}var Eo=(e,t={},o)=>{if(e?.baseUrl)return e.baseUrl;if("baseUrl"in t)return t.baseUrl;if(o?.state?.baseUrl)return o?.state?.baseUrl;if(Le.state.baseUrl)return Le.state.baseUrl},ko=(e,t={},o)=>{if(e?.basePath)return e.basePath;if("basePath"in t)return t.basePath;if(o?.state?.basePath)return o?.state?.basePath;if(Le.state.basePath)return Le.state.basePath};function Rt(e){let{baseUrl:t="",disableQuery:o,init:r,client:n,fetchUrl:s}=e??{},i=L(n);zt({queryKey:["providers",t],queryFn:async()=>await fetch(s??`${t}/api/auth/providers`,r),enabled:o!==!0},i),Be(e)}function Be(e){let{baseUrl:t="",disableQuery:o,init:r,client:n,fetchUrl:s}=e??{},i=L(n);zt({queryKey:["csrf",t],queryFn:async()=>await fetch(s??`${t}/api/auth/csrf`,r),enabled:o!==!0},i)}import*as Te from"react";import*as Ye from"@radix-ui/react-label";import{cva as Lo}from"class-variance-authority";var Bo=Lo("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Je=Te.forwardRef(({className:e,...t},o)=>Te.createElement(Ye.Root,{ref:o,className:d(Bo(),e),...t}));Je.displayName=Ye.Root.displayName;import*as Ue from"react";var V=Ue.forwardRef(({className:e,type:t,...o},r)=>Ue.createElement("input",{type:t,className:d("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...o}));V.displayName="Input";var q=zo,At=g.createContext({}),ye=({...e})=>g.createElement(At.Provider,{value:{name:e.name}},g.createElement(Uo,{...e})),ze=()=>{let e=g.useContext(At),t=g.useContext(Ot),{getFieldState:o,formState:r}=Ze(),n=o(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return{id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...n}},Ot=g.createContext({}),Z=g.forwardRef(({className:e,...t},o)=>{let r=g.useId();return g.createElement(Ot.Provider,{value:{id:r}},g.createElement("div",{ref:o,className:d("py-2",e),...t}))});Z.displayName="FormItem";var ee=g.forwardRef(({className:e,...t},o)=>{let{error:r,formItemId:n}=ze();return g.createElement(Je,{ref:o,className:d(r&&"text-destructive",e),htmlFor:n,...t})});ee.displayName="FormLabel";var ae=g.forwardRef(({...e},t)=>{let{error:o,formItemId:r,formDescriptionId:n,formMessageId:s}=ze();return g.createElement(To,{ref:t,id:r,"aria-describedby":o?`${n} ${s}`:`${n}`,"aria-invalid":!!o,...e})});ae.displayName="FormControl";var le=g.forwardRef(({className:e,...t},o)=>{let{formDescriptionId:r}=ze();return g.createElement("p",{ref:o,id:r,className:d("text-sm text-muted-foreground",e),...t})});le.displayName="FormDescription";var ue=g.forwardRef(({className:e,children:t,...o},r)=>{let{error:n,formMessageId:s}=ze(),i=n?String(n?.message):t;return i?g.createElement("p",{ref:r,id:s,className:d("text-sm font-medium text-destructive",e),...o},i):null});ue.displayName="FormMessage";var _=({hide:e})=>{let t=Ze();return g.createElement(ye,{control:t.control,name:"email",render:({field:o})=>e?g.createElement("input",{type:"hidden",...o}):g.createElement(Z,null,g.createElement(ee,{htmlFor:o.name},"Email"),g.createElement(ae,null,g.createElement(V,{placeholder:"Email",...o,"aria-label":o.name,autoComplete:"current-email",required:!0})),g.createElement(le,null,"Your email address"),g.createElement(ue,null))})},me=()=>{let e=Ze();return g.createElement(ye,{control:e.control,name:"password",render:({field:t})=>g.createElement(Z,null,g.createElement(ee,{htmlFor:t.name},"Password"),g.createElement(ae,null,g.createElement(V,{placeholder:"Password",...t,type:"password","aria-label":t.name,autoComplete:"current-password",required:!0})),g.createElement(le,null,"The desired password"),g.createElement(ue,null))})};import*as X from"react";import{Slottable as Ro,Slot as Ao}from"@radix-ui/react-slot";import{cva as Oo}from"class-variance-authority";import{Loader2 as Ho}from"lucide-react";var M=Oo("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 gap-1",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),P=X.forwardRef(({asChild:e=!1,children:t,className:o,disabled:r,loading:n,size:s,variant:i,...u},a)=>X.createElement(e?Ao:"button",{className:d(M({variant:i,size:s,className:o})),ref:a,disabled:n||r,...u},X.createElement(Ro,null,n?X.createElement("div",{className:"relative flex items-center justify-center"},X.createElement("div",{className:"absolute"},X.createElement(Ho,{className:"animate-spin"})),X.createElement("span",{className:"opacity-0"},t)):t)));P.displayName="Button";import{useMutation as Vo}from"@tanstack/react-query";import{signIn as Qo}from"@niledatabase/client";function Re(e){let{onSuccess:t,onError:o,beforeMutate:r,callbackUrl:n,redirect:s=!1,init:i,client:u}=e??{},a=L(u);return Vo({mutationFn:async m=>{let l={...m,callbackUrl:n,redirect:s},p=(r&&r(l))??l,f=await Qo("email",{init:i,...p});if(f?.error)throw new Error(f.error);return f},onSuccess:t,onError:o},a).mutate}function et(e){let{client:t}=e??{};return ce.createElement(U,{client:t},ce.createElement(jo,{...e}))}function jo(e){let t=Re(e),o=qo({defaultValues:{email:""}});return ce.createElement(q,{...o},ce.createElement("form",{onSubmit:o.handleSubmit(({email:r})=>t&&t({email:r})),className:"space-y-8"},ce.createElement(_,null),ce.createElement(P,{type:"submit",className:"flex flex-row gap-2"},ce.createElement(Wo,null),"Sign in with email")))}import{Slot as $o}from"@radix-ui/react-slot";import tt from"react";import{Mail as Ko}from"lucide-react";import{signIn as Go}from"@niledatabase/client";var Ht=({callbackUrl:e,className:t,variant:o,size:r,asChild:n=!1,redirect:s=!1,buttonText:i="Continue with Email",email:u,onFailure:a,onSent:c,fetchUrl:m,baseUrl:l,auth:b,...p})=>tt.createElement(n?$o:"button",{className:d(M({variant:o,size:r,className:t})),"data-slot":"email-signin-button",onClick:async()=>{let E=await Go("email",{email:u,callbackUrl:e,redirect:s,fetchUrl:m,baseUrl:l,auth:b});E&&"error"in E?a&&a(E):c&&c()},...p},p.children?p.children:tt.createElement("div",{className:"flex flex-row gap-2 items-center"},tt.createElement(Ko,null),i));Ht.displayName="EmailSignInButton";var Vt=Ht;import G from"react";import{Slot as _o}from"@radix-ui/react-slot";import{signIn as Xo}from"@niledatabase/client";var Qt=({callbackUrl:e,className:t,variant:o,size:r,buttonText:n="Continue with Google",asChild:s=!1,init:i,auth:u,fetchUrl:a,baseUrl:c,onClick:m,...l})=>G.createElement(s?_o:"button",{"data-slot":"google-button",className:d(M({variant:o,size:r,className:t}),"bg-[#4285f4] hover:bg-[#4285f4] hover:bg-opacity-85 pl-[3px] text-white"),onClick:async p=>{let f=await Xo("google",{callbackUrl:e,init:i,auth:u,fetchUrl:a,baseUrl:c});m&&m(p,f)},...l},G.createElement("div",{className:"inline-flex items-center flex-1 justify-between font-roboto rounded-[4px] gap-4 google-logo"},G.createElement("div",{style:{background:"white",borderRadius:"4px",padding:"0.5rem"}},G.createElement(Yo,null)),n));Qt.displayName="GoogleSSOButton";var qt=Qt;function Yo(){return G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18"},G.createElement("g",{fill:"#000",fillRule:"evenodd"},G.createElement("path",{d:"M9 3.48c1.69 0 2.83.73 3.48 1.34l2.54-2.48C13.46.89 11.43 0 9 0 5.48 0 2.44 2.02.96 4.96l2.91 2.26C4.6 5.05 6.62 3.48 9 3.48z",fill:"#EA4335"}),G.createElement("path",{d:"M17.64 9.2c0-.74-.06-1.28-.19-1.84H9v3.34h4.96c-.1.83-.64 2.08-1.84 2.92l2.84 2.2c1.7-1.57 2.68-3.88 2.68-6.62z",fill:"#4285F4"}),G.createElement("path",{d:"M3.88 10.78A5.54 5.54 0 0 1 3.58 9c0-.62.11-1.22.29-1.78L.96 4.96A9.008 9.008 0 0 0 0 9c0 1.45.35 2.82.96 4.04l2.92-2.26z",fill:"#FBBC05"}),G.createElement("path",{d:"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.84-2.2c-.76.53-1.78.9-3.12.9-2.38 0-4.4-1.57-5.12-3.74L.97 13.04C2.45 15.98 5.48 18 9 18z",fill:"#34A853"}),G.createElement("path",{fill:"none",d:"M0 0h18v18H0z"})))}import te from"react";import{Slot as Jo}from"@radix-ui/react-slot";import{signIn as Zo}from"@niledatabase/client";var Wt=({callbackUrl:e,className:t,buttonText:o="Continue with Microsoft",variant:r,size:n,init:s,asChild:i=!1,auth:u,fetchUrl:a,baseUrl:c,onClick:m,...l})=>te.createElement(i?Jo:"button",{"data-slot":"azure-button",className:d(M({variant:r,size:n,className:t}),"bg-[#0078d4] hover:bg-[#0078d4] hover:bg-opacity-85 pl-[3px] text-white gap-4 transition-colors shadow-md"),onClick:async p=>{let f=await Zo("azure-ad",{callbackUrl:e,init:s,auth:u,fetchUrl:a,baseUrl:c});m&&m(p,f)},...l},te.createElement(tr,null),o);Wt.displayName="AzureSignInButton";var er=Wt,tr=()=>te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 23 23",className:"w-5 h-5 ml-3"},te.createElement("path",{fill:"#f3f3f3",d:"M0 0h23v23H0z"}),te.createElement("path",{fill:"#f35325",d:"M1 1h10v10H1z"}),te.createElement("path",{fill:"#81bc06",d:"M12 1h10v10H12z"}),te.createElement("path",{fill:"#05a6f0",d:"M1 12h10v10H1z"}),te.createElement("path",{fill:"#ffba08",d:"M12 12h10v10H12z"}));import de from"react";import{Slot as or}from"@radix-ui/react-slot";import{signIn as rr}from"@niledatabase/client";var jt=({callbackUrl:e,className:t,buttonText:o="Continue with Discord",variant:r,size:n,asChild:s=!1,init:i,auth:u,fetchUrl:a,baseUrl:c,onClick:m,...l})=>de.createElement(s?or:"button",{className:d(M({variant:r,size:n,className:t}),"bg-[#5865F2] hover:bg-[#5865F2] hover:bg-opacity-85 pl-[3px] gap-4 transition-colors border shadow-md text-white"),"data-slot":"discord-button",onClick:async p=>{let f=await rr("discord",{callbackUrl:e,init:i,auth:u,fetchUrl:a,baseUrl:c});m&&m(p,f)},...l},de.createElement(ir,null),o);jt.displayName="DiscordSignInButton";var nr=jt,ir=()=>de.createElement("svg",{className:"w-5 h-5 ml-3",viewBox:"0 0 75 59",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},de.createElement("title",null,"discord-icon"),de.createElement("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd"},de.createElement("g",{id:"discord-icon",transform:"translate(2.000000, 2.411745)",fillRule:"nonzero",stroke:"#636262",strokeWidth:"0"},de.createElement("path",{d:"M60.1044999,4.48605546 C55.5791999,2.40965546 50.7264999,0.879855461 45.6526999,0.00367546142 C45.5602999,-0.0132345386 45.4679999,0.0290244614 45.4203999,0.113544461 C44.7962999,1.22355546 44.1049999,2.67165546 43.6208999,3.80985546 C38.1636999,2.99285546 32.7344999,2.99285546 27.3891999,3.80985546 C26.9049999,2.64635546 26.1885999,1.22355546 25.5616999,0.113544461 C25.5140999,0.0318444614 25.4217999,-0.0104145386 25.3293999,0.00367546142 C20.2583999,0.877055461 15.4056999,2.40685546 10.8775999,4.48605546 C10.8383999,4.50295546 10.8047999,4.53115546 10.7824999,4.56775546 C1.57794989,18.3191555 -0.94356111,31.7325555 0.29340789,44.9796555 C0.29900489,45.0444555 0.33538589,45.1064555 0.38576089,45.1458555 C6.45865989,49.6056555 12.3412999,52.3131555 18.1146999,54.1077555 C18.2070999,54.1359555 18.3049999,54.1021555 18.3637999,54.0260555 C19.7294999,52.1610555 20.9468999,50.1945555 21.9906999,48.1265555 C22.0522999,48.0054555 21.9934999,47.8617555 21.8675999,47.8138555 C19.9365999,47.0813555 18.0978999,46.1882555 16.3291999,45.1740555 C16.1892999,45.0923555 16.1780999,44.8922555 16.3067999,44.7964555 C16.6789999,44.5175555 17.0512999,44.2273555 17.4066999,43.9343555 C17.4709999,43.8808555 17.5605999,43.8695555 17.6361999,43.9033555 C29.2557999,49.2084555 41.8353999,49.2084555 53.3178999,43.9033555 C53.3934999,43.8667555 53.4830999,43.8780555 53.5501999,43.9315555 C53.9056999,44.2245555 54.2778999,44.5175555 54.6528999,44.7964555 C54.7815999,44.8922555 54.7731999,45.0923555 54.6332999,45.1740555 C52.8645999,46.2079555 51.0258999,47.0813555 49.0920999,47.8110555 C48.9661999,47.8589555 48.9101999,48.0054555 48.9717999,48.1265555 C50.0379999,50.1916555 51.2553999,52.1581555 52.5958999,54.0232555 C52.6518999,54.1021555 52.7525999,54.1359555 52.8449999,54.1077555 C58.6463999,52.3131555 64.5289999,49.6056555 70.6018999,45.1458555 C70.6550999,45.1064555 70.6886999,45.0472555 70.6942999,44.9824555 C72.1746999,29.6673555 68.2146999,16.3639555 60.1967999,4.57055546 C60.1771999,4.53115546 60.1436999,4.50295546 60.1044999,4.48605546 Z M23.7258999,36.9135555 C20.2275999,36.9135555 17.3450999,33.7018555 17.3450999,29.7575555 C17.3450999,25.8132555 20.1716999,22.6015555 23.7258999,22.6015555 C27.3079999,22.6015555 30.1625999,25.8414555 30.1065999,29.7575555 C30.1065999,33.7018555 27.2799999,36.9135555 23.7258999,36.9135555 Z M47.3177999,36.9135555 C43.8195999,36.9135555 40.9370999,33.7018555 40.9370999,29.7575555 C40.9370999,25.8132555 43.7635999,22.6015555 47.3177999,22.6015555 C50.8999999,22.6015555 53.7544999,25.8414555 53.6985999,29.7575555 C53.6985999,33.7018555 50.8999999,36.9135555 47.3177999,36.9135555 Z",id:"Shape",fill:"white"}))));import Ae from"react";import{Slot as sr}from"@radix-ui/react-slot";import{signIn as ar}from"@niledatabase/client";var $t=({callbackUrl:e,className:t,buttonText:o="Continue with GitHub",variant:r,size:n,init:s,asChild:i=!1,auth:u,fetchUrl:a,baseUrl:c,onClick:m,...l})=>Ae.createElement(i?sr:"button",{"data-slot":"github-button",className:d(M({variant:r,size:n,className:t}),"bg-black hover:bg-slate-800 pl-[3px] text-white gap-4 transition-colors shadow-md"),onClick:async p=>{let f=await ar("github",{callbackUrl:e,init:s,auth:u,fetchUrl:a,baseUrl:c});m&&m(p,f)},...l},Ae.createElement(ur,null),o);$t.displayName="GitHubSignInButton";var lr=$t,ur=()=>Ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32.58 31.77",fill:"currentColor",className:"w-5 h-5 ml-3"},Ae.createElement("path",{fill:"#FFFFFF",d:"M16.29,0a16.29,16.29,0,0,0-5.15,31.75c.82.15,1.11-.36,1.11-.79s0-1.41,0-2.77C7.7,29.18,6.74,26,6.74,26a4.36,4.36,0,0,0-1.81-2.39c-1.47-1,.12-1,.12-1a3.43,3.43,0,0,1,2.49,1.68,3.48,3.48,0,0,0,4.74,1.36,3.46,3.46,0,0,1,1-2.18c-3.62-.41-7.42-1.81-7.42-8a6.3,6.3,0,0,1,1.67-4.37,5.94,5.94,0,0,1,.16-4.31s1.37-.44,4.48,1.67a15.41,15.41,0,0,1,8.16,0c3.11-2.11,4.47-1.67,4.47-1.67A5.91,5.91,0,0,1,25,11.07a6.3,6.3,0,0,1,1.67,4.37c0,6.26-3.81,7.63-7.44,8a3.85,3.85,0,0,1,1.11,3c0,2.18,0,3.94,0,4.47s.29.94,1.12.78A16.29,16.29,0,0,0,16.29,0Z"}));import Oe from"react";import{Slot as mr}from"@radix-ui/react-slot";import{signIn as cr}from"@niledatabase/client";var Kt=({callbackUrl:e,className:t,buttonText:o="Continue with HubSpot",variant:r,size:n,init:s,asChild:i=!1,auth:u,fetchUrl:a,baseUrl:c,onClick:m,...l})=>Oe.createElement(i?mr:"button",{"data-slot":"hubspot-button",className:d(M({variant:r,size:n,className:t}),"bg-[#ff7a59] hover:bg-[#ff7a59] hover:bg-opacity-85 pl-[3px] text-white gap-4 transition-colors shadow-md"),onClick:async p=>{let f=await cr("hubspot",{callbackUrl:e,init:s,auth:u,fetchUrl:a,baseUrl:c});m&&m(p,f)},...l},Oe.createElement(fr,null),o);Kt.displayName="HubSpotSignInButton";var dr=Kt,fr=()=>Oe.createElement("svg",{className:"w-5 h-5 ml-3",viewBox:"6.20856283 .64498824 244.26943717 251.24701176",xmlns:"http://www.w3.org/2000/svg"},Oe.createElement("path",{d:"m191.385 85.694v-29.506a22.722 22.722 0 0 0 13.101-20.48v-.677c0-12.549-10.173-22.722-22.721-22.722h-.678c-12.549 0-22.722 10.173-22.722 22.722v.677a22.722 22.722 0 0 0 13.101 20.48v29.506a64.342 64.342 0 0 0 -30.594 13.47l-80.922-63.03c.577-2.083.878-4.225.912-6.375a25.6 25.6 0 1 0 -25.633 25.55 25.323 25.323 0 0 0 12.607-3.43l79.685 62.007c-14.65 22.131-14.258 50.974.987 72.7l-24.236 24.243c-1.96-.626-4-.959-6.057-.987-11.607.01-21.01 9.423-21.007 21.03.003 11.606 9.412 21.014 21.018 21.017 11.607.003 21.02-9.4 21.03-21.007a20.747 20.747 0 0 0 -.988-6.056l23.976-23.985c21.423 16.492 50.846 17.913 73.759 3.562 22.912-14.352 34.475-41.446 28.985-67.918-5.49-26.473-26.873-46.734-53.603-50.792m-9.938 97.044a33.17 33.17 0 1 1 0-66.316c17.85.625 32 15.272 32.01 33.134.008 17.86-14.127 32.522-31.977 33.165",fill:"white"}));import xe from"react";import{Slot as pr}from"@radix-ui/react-slot";import{signIn as gr}from"@niledatabase/client";var Gt=({callbackUrl:e,className:t,buttonText:o="Continue with LinkedIn",variant:r,size:n,asChild:s=!1,init:i,auth:u,fetchUrl:a,baseUrl:c,onClick:m,...l})=>xe.createElement(s?pr:"button",{"data-slot":"linkedin-button",className:d(M({variant:r,size:n,className:t}),"bg-[#0288D1] hover:bg-[#0288D1] pl-[3px] hover:bg-opacity-85 gap-4 transition-colors shadow-md text-white"),onClick:async p=>{let f=await gr("linkedin",{callbackUrl:e,init:i,auth:u,fetchUrl:a,baseUrl:c});m&&m(p,f)},...l},xe.createElement(yr,null),o);Gt.displayName="LinkedInSignInButton";var hr=Gt,yr=()=>xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",className:"w-6 h-6 ml-3"},xe.createElement("path",{fill:"#fff",d:"M42,37c0,2.762-2.238,5-5,5H11c-2.761,0-5-2.238-5-5V11c0-2.762,2.239-5,5-5h26c2.762,0,5,2.238,5,5V37z"}),xe.createElement("path",{fill:"#0288D1",d:"M12 19H17V36H12zM14.485 17h-.028C12.965 17 12 15.888 12 14.499 12 13.08 12.995 12 14.514 12c1.521 0 2.458 1.08 2.486 2.499C17 15.887 16.035 17 14.485 17zM36 36h-5v-9.099c0-2.198-1.225-3.698-3.192-3.698-1.501 0-2.313 1.012-2.707 1.99C24.957 25.543 25 26.511 25 27v9h-5V19h5v2.616C25.721 20.5 26.85 19 29.738 19c3.578 0 6.261 2.25 6.261 7.274L36 36 36 36z"}));import oe from"react";import{Slot as br}from"@radix-ui/react-slot";import{signIn as vr}from"@niledatabase/client";var _t=({callbackUrl:e,className:t,buttonText:o="Continue with Slack",variant:r,size:n,init:s,onClick:i,asChild:u=!1,...a})=>oe.createElement(u?br:"button",{className:d(M({variant:r,size:n,className:t}),"bg-[#4A154B] pl-[3px] hover:bg-opacity-85 gap-4 transition-colors shadow-md text-white"),"data-slot":"slack-button",onClick:async m=>{let l=await vr("slack",{callbackUrl:e,init:s});i&&i(m,l)},...a},oe.createElement(Cr,null),o);_t.displayName="SlackSignInButton";var wr=_t,Cr=()=>oe.createElement("svg",{enableBackground:"new 0 0 2447.6 2452.5",viewBox:"0 0 2447.6 2452.5",className:"w-5 h-5 ml-3",xmlns:"http://www.w3.org/2000/svg"},oe.createElement("g",{clipRule:"evenodd",fillRule:"evenodd"},oe.createElement("path",{d:"m897.4 0c-135.3.1-244.8 109.9-244.7 245.2-.1 135.3 109.5 245.1 244.8 245.2h244.8v-245.1c.1-135.3-109.5-245.1-244.9-245.3.1 0 .1 0 0 0m0 654h-652.6c-135.3.1-244.9 109.9-244.8 245.2-.2 135.3 109.4 245.1 244.7 245.3h652.7c135.3-.1 244.9-109.9 244.8-245.2.1-135.4-109.5-245.2-244.8-245.3z",fill:"#36c5f0"}),oe.createElement("path",{d:"m2447.6 899.2c.1-135.3-109.5-245.1-244.8-245.2-135.3.1-244.9 109.9-244.8 245.2v245.3h244.8c135.3-.1 244.9-109.9 244.8-245.3zm-652.7 0v-654c.1-135.2-109.4-245-244.7-245.2-135.3.1-244.9 109.9-244.8 245.2v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.3z",fill:"#2eb67d"}),oe.createElement("path",{d:"m1550.1 2452.5c135.3-.1 244.9-109.9 244.8-245.2.1-135.3-109.5-245.1-244.8-245.2h-244.8v245.2c-.1 135.2 109.5 245 244.8 245.2zm0-654.1h652.7c135.3-.1 244.9-109.9 244.8-245.2.2-135.3-109.4-245.1-244.7-245.3h-652.7c-135.3.1-244.9 109.9-244.8 245.2-.1 135.4 109.4 245.2 244.7 245.3z",fill:"#ecb22e"}),oe.createElement("path",{d:"m0 1553.2c-.1 135.3 109.5 245.1 244.8 245.2 135.3-.1 244.9-109.9 244.8-245.2v-245.2h-244.8c-135.3.1-244.9 109.9-244.8 245.2zm652.7 0v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.2v-653.9c.2-135.3-109.4-245.1-244.7-245.3-135.4 0-244.9 109.8-244.8 245.1 0 0 0 .1 0 0",fill:"#e01e5a"})));import He from"react";import{Slot as xr}from"@radix-ui/react-slot";import{signIn as Pr}from"@niledatabase/client";var Xt=({callbackUrl:e,className:t,buttonText:o="Continue with X",variant:r,size:n,init:s,onClick:i,asChild:u=!1,auth:a,fetchUrl:c,baseUrl:m,...l})=>He.createElement(u?xr:"button",{className:d(M({variant:r,size:n,className:t}),"bg-black hover:bg-slate-800 pl-[3px] text-white gap-4 transition-colors shadow-md"),"data-slot":"twitter-button",onClick:async p=>{let f=await Pr("twitter",{callbackUrl:e,init:s,auth:a,fetchUrl:c,baseUrl:m});i&&i(p,f)},...l},He.createElement(Mr,null),o);Xt.displayName="XSignInButton";var Sr=Xt,Mr=()=>He.createElement("svg",{className:"w-5 h-5 ml-3",viewBox:"0 0 24 24",version:"1.1"},He.createElement("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",fill:"#ffffff"}));import Pe from"react";import{Slot as Nr}from"@radix-ui/react-slot";import{signIn as Fr}from"@niledatabase/client";var Yt=({callbackUrl:e,className:t,buttonText:o="Continue with Okta",variant:r,size:n,asChild:s=!1,init:i,auth:u,fetchUrl:a,baseUrl:c,onClick:m,...l})=>Pe.createElement(s?Nr:"button",{"data-slot":"okta-button",className:d(M({variant:r,size:n,className:t}),"bg-[#181818] hover:bg-[#3f59e4] pl-[3px] gap-4 transition-colors shadow-md text-white"),onClick:async p=>{let f=await Fr("okta",{callbackUrl:e,init:i,auth:u,fetchUrl:a,baseUrl:c});m&&m(p,f)},...l},Pe.createElement(Ir,null),o);Yt.displayName="OktaSignInButton";var Dr=Yt,Ir=()=>Pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 63 63",fill:"currentColor",className:"w-5 h-5 ml-3",width:"18",height:"18"},Pe.createElement("g",null,Pe.createElement("path",{d:`M34.6,0.4l-1.3,16c-0.6-0.1-1.2-0.1-1.9-0.1c-0.8,0-1.6,0.1-2.3,0.2l-0.7-7.7c0-0.2,0.2-0.5,0.4-0.5h1.3
2
+ import{useForm as Pn}from"react-hook-form";import{Mail as Cn}from"lucide-react";import*as H from"react";import{Slot as dn}from"@radix-ui/react-slot";import{Controller as fn,FormProvider as pn,useFormContext as st}from"react-hook-form";import{useQuery as Qt}from"@tanstack/react-query";import{clsx as on}from"clsx";import{twMerge as nn}from"tailwind-merge";import{auth as He}from"@niledatabase/client";import{useContext as Ht,useRef as Jo,useState as jo}from"react";import{QueryClient as Ot,QueryClientContext as Vt,QueryClientProvider as en}from"@tanstack/react-query";import{Fragment as tn,jsx as At}from"react/jsx-runtime";function B(e){let t=Ht(Vt),[o]=jo(()=>e||t?null:new Ot),n=Jo(null);return e||t||o||(n.current||(n.current=new Ot),n.current)}function U({client:e,children:t}){let o=Ht(Vt),n=B(e);return!e&&o?At(tn,{children:t}):At(en,{client:n,children:t})}function f(...e){return nn(on(e))}function rn(...e){let t=new Headers;for(let o of e)o&&new Headers(o).forEach((n,r)=>{t.set(r,n)});return t}function Se(e,t={},o){let n,r,i={};if(t&&typeof t=="object"){let u=t;"init"in u&&u.init&&typeof u.init=="object"&&(n=u.init),"auth"in u&&u.auth&&typeof u.auth=="object"&&(r=u.auth);let m=new Set(["init","auth","baseUrl","basePath","fetchUrl","client","user","tenants","disableQuery","onError","onSuccess","beforeMutate","onTenantChange","activeTenant","useCookie","className","emptyText","buttonText","profilePicturePlaceholder"]);for(let[d,g]of Object.entries(u))!m.has(d)&&g!==void 0&&(i[d]=g)}let a={...o?.auth?.requestInit??{},...o?.init??{},...r?.requestInit??{},...n??{},...i,headers:rn({"content-type":"application/json; charset=UTF-8"},o?.auth?.requestInit?.headers,o?.init?.headers,r?.requestInit?.headers,n?.headers,i.headers)},s=e;if(!(!!o?.fetchUrl||!!(t&&typeof t=="object"&&"fetchUrl"in t&&t.fetchUrl))&&e.startsWith("/")){let u=r??o?.auth,m=sn(o,t,u);s=`${an(o,t,u)}${m}${e}`}return fetch(s,a)}var an=(e,t={},o)=>e?.baseUrl?e.baseUrl:"baseUrl"in t&&t.baseUrl?t.baseUrl:o?.state?.baseUrl?o.state.baseUrl:He.state.baseUrl?He.state.baseUrl:"",sn=(e,t={},o)=>e?.basePath?e.basePath:"basePath"in t&&t.basePath?t.basePath:o?.state?.basePath?o.state.basePath:He.state.basePath?He.state.basePath:"";function qt(e){let{baseUrl:t="",basePath:o="/api",disableQuery:n,init:r,client:i,providersUrl:a,csrfUrl:s}=e??{},l=B(i);Qt({queryKey:["providers",t,o,a],queryFn:async()=>{let u=await fetch(a??`${t}${o}/auth/providers`,r);if(!u.ok)throw new Error(`Failed to fetch providers (${u.status})`);return await u.json()},enabled:n!==!0},l),Ve({baseUrl:t,basePath:o,disableQuery:n,init:r,client:i,csrfUrl:s})}function Ve(e){let{baseUrl:t="",basePath:o="/api",disableQuery:n,init:r,client:i,csrfUrl:a}=e??{},s=B(i);Qt({queryKey:["csrf",t,o,a],queryFn:async()=>{let l=await fetch(a??`${t}${o}/auth/csrf`,r);if(!l.ok)throw new Error(`Failed to fetch CSRF token (${l.status})`);return await l.json()},enabled:n!==!0},s)}import*as Wt from"react";import*as it from"@radix-ui/react-label";import{cva as ln}from"class-variance-authority";import{jsx as cn}from"react/jsx-runtime";var un=ln("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),at=Wt.forwardRef(({className:e,...t},o)=>cn(it.Root,{ref:o,className:f(un(),e),...t}));at.displayName=it.Root.displayName;import*as $t from"react";import{jsx as mn}from"react/jsx-runtime";var Q=$t.forwardRef(({className:e,type:t,...o},n)=>mn("input",{type:t,className:f("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...o}));Q.displayName="Input";import{jsx as F,jsxs as _t}from"react/jsx-runtime";var q=pn,Kt=H.createContext({}),me=({...e})=>F(Kt.Provider,{value:{name:e.name},children:F(fn,{...e})}),Qe=()=>{let e=H.useContext(Kt),t=H.useContext(Gt),{getFieldState:o,formState:n}=st(),r=o(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...r}},Gt=H.createContext({}),ne=H.forwardRef(({className:e,...t},o)=>{let n=H.useId();return F(Gt.Provider,{value:{id:n},children:F("div",{ref:o,className:f("py-2",e),...t})})});ne.displayName="FormItem";var re=H.forwardRef(({className:e,...t},o)=>{let{error:n,formItemId:r}=Qe();return F(at,{ref:o,className:f(n&&"text-destructive",e),htmlFor:r,...t})});re.displayName="FormLabel";var ie=H.forwardRef(({...e},t)=>{let{error:o,formItemId:n,formDescriptionId:r,formMessageId:i}=Qe();return F(dn,{ref:t,id:n,"aria-describedby":o?`${r} ${i}`:`${r}`,"aria-invalid":!!o,...e})});ie.displayName="FormControl";var de=H.forwardRef(({className:e,...t},o)=>{let{formDescriptionId:n}=Qe();return F("p",{ref:o,id:n,className:f("text-sm text-muted-foreground",e),...t})});de.displayName="FormDescription";var fe=H.forwardRef(({className:e,children:t,...o},n)=>{let{error:r,formMessageId:i}=Qe(),a=r?String(r?.message):t;return a?F("p",{ref:n,id:i,className:f("text-sm font-medium text-destructive",e),...o,children:a}):null});fe.displayName="FormMessage";var J=({hide:e})=>{let t=st();return F(me,{control:t.control,name:"email",render:({field:o})=>e?F("input",{type:"hidden",...o}):_t(ne,{children:[F(re,{children:"Email"}),F(ie,{children:F(Q,{placeholder:"Email",...o,type:"email","aria-label":o.name,autoComplete:"email",required:!0})}),F(de,{children:"Your email address"}),F(fe,{})]})})},pe=({autoComplete:e="current-password"}={})=>{let t=st();return F(me,{control:t.control,name:"password",render:({field:o})=>_t(ne,{children:[F(re,{children:"Password"}),F(ie,{children:F(Q,{placeholder:"Password",...o,type:"password","aria-label":o.name,autoComplete:e,required:!0})}),F(de,{children:"The desired password"}),F(fe,{})]})})};import*as Xt from"react";import{Slottable as gn,Slot as hn}from"@radix-ui/react-slot";import{cva as yn}from"class-variance-authority";import{Loader2 as bn}from"lucide-react";import{jsx as Me,jsxs as vn}from"react/jsx-runtime";var ae=yn("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 gap-1",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),R=Xt.forwardRef(({asChild:e=!1,children:t,className:o,disabled:n,loading:r,size:i,variant:a,...s},l)=>Me(e?hn:"button",{className:f(ae({variant:a,size:i,className:o})),ref:l,disabled:r||n,...s,children:Me(gn,{children:r?vn("div",{className:"relative flex items-center justify-center",children:[Me("div",{className:"absolute",children:Me(bn,{className:"animate-spin"})}),Me("span",{className:"opacity-0",children:t})]}):t})}));R.displayName="Button";import{useMutation as wn}from"@tanstack/react-query";import{signIn as Sn}from"@niledatabase/client";function lt(e){let{onSuccess:t,onError:o,beforeMutate:n,callbackUrl:r,redirect:i=!1,init:a,client:s}=e??{},l=B(s);return wn({mutationFn:async u=>{let m={...u,callbackUrl:r,redirect:i},g=(n&&n(m))??m,c=await Sn("email",{init:a,...g});if(i===!1&&!c||c&&(!c.ok||c.error))throw new Error(c?.error??"Email sign in failed");return c},onSuccess:t,onError:o},l)}function Yt(e){return lt(e).mutate}import{jsx as Pe,jsxs as Zt}from"react/jsx-runtime";function ut(e){let{client:t}=e??{};return Pe(U,{client:t,children:Pe(xn,{...e})})}function xn(e){let t=lt(e),o=Pn({defaultValues:{email:""}});return Pe(q,{...o,children:Zt("form",{onSubmit:o.handleSubmit(({email:n})=>t.mutate({email:n})),className:"space-y-8",children:[Pe(J,{}),!e.onError&&t.error?Pe("p",{role:"alert",className:"text-sm font-medium text-destructive",children:t.error instanceof Error?t.error.message:"Email sign in failed"}):null,Zt(R,{type:"submit",className:"flex flex-row gap-2",loading:t.isPending,children:[Pe(Cn,{"aria-hidden":"true"}),e.buttonText??"Sign in with email"]})]})})}import{Slot as Rn}from"@radix-ui/react-slot";import{Mail as Mn}from"lucide-react";import{signIn as Nn}from"@niledatabase/client";import{jsx as Jt,jsxs as Fn}from"react/jsx-runtime";var jt=({callbackUrl:e,className:t,variant:o,size:n,asChild:r=!1,redirect:i=!1,buttonText:a="Continue with Email",email:s,onFailure:l,onSent:u,fetchUrl:m,baseUrl:d,auth:g,init:c,loading:p,type:y="button",onClick:S,children:C,...b})=>Jt(r?Rn:"button",{...b,...r?{}:{type:y},className:f(ae({variant:o,size:n,className:t})),"data-slot":"email-signin-button",onClick:async v=>{let P=await Nn("email",{email:s,callbackUrl:e,redirect:i,fetchUrl:m,baseUrl:d,auth:g,init:c});S?.(v,P),i===!1&&!P||P&&(!P.ok||P.error)?l?.(P):u?.()},children:C||Fn("div",{className:"flex flex-row gap-2 items-center",children:[Jt(Mn,{"aria-hidden":"true"}),a]})});jt.displayName="EmailSignInButton";var eo=jt;import Dn from"react";import{Slot as En,Slottable as In}from"@radix-ui/react-slot";import{Loader2 as kn}from"lucide-react";import{signIn as Bn}from"@niledatabase/client";import{Fragment as Ln,jsx as Ne,jsxs as ct}from"react/jsx-runtime";function L({provider:e,dataSlot:t,defaultButtonText:o,providerClassName:n,icon:r,renderDefaultContent:i,callbackUrl:a,className:s,buttonText:l=o,variant:u,size:m,init:d,auth:g,fetchUrl:c,baseUrl:p,onClick:y,asChild:S=!1,loading:C=!1,disabled:b,type:E="button",children:v,...P}){let I=S&&Dn.isValidElement(v),N=async T=>{if(C||b){T.preventDefault();return}let Z=await Bn(e,{callbackUrl:a,init:d,auth:g,fetchUrl:c,baseUrl:p});y?.(T,Z)},Y=i?i(l,r):ct(Ln,{children:[r,l]}),ce=()=>{let T=v??Y;return C?ct("span",{className:"relative inline-flex items-center justify-center",children:[Ne("span",{className:"absolute",children:Ne(kn,{className:"animate-spin","aria-hidden":"true"})}),Ne("span",{className:"opacity-0 inline-flex items-center gap-4",children:T})]}):T};return I?ct(En,{...P,"aria-disabled":C||b||void 0,"data-slot":t,className:f(ae({variant:u,size:m,className:s}),n),onClick:N,children:[r,Ne(In,{children:v})]}):Ne("button",{...P,type:E,disabled:C||b,"data-slot":t,className:f(ae({variant:u,size:m,className:s}),n),onClick:N,children:ce()})}import{jsx as j,jsxs as no}from"react/jsx-runtime";var to=e=>j(L,{provider:"google",dataSlot:"google-button",defaultButtonText:"Continue with Google",providerClassName:"bg-[#4285f4] hover:bg-[#4285f4] hover:bg-opacity-85 pl-[3px] text-white",icon:j(Tn,{}),renderDefaultContent:(t,o)=>no("div",{className:"inline-flex items-center flex-1 justify-between font-roboto rounded-[4px] gap-4 google-logo",children:[j("div",{style:{background:"white",borderRadius:"4px",padding:"0.5rem"},children:o}),t]}),...e});to.displayName="GoogleSSOButton";var oo=to;function Tn(){return j("svg",{"aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",children:no("g",{fill:"#000",fillRule:"evenodd",children:[j("path",{d:"M9 3.48c1.69 0 2.83.73 3.48 1.34l2.54-2.48C13.46.89 11.43 0 9 0 5.48 0 2.44 2.02.96 4.96l2.91 2.26C4.6 5.05 6.62 3.48 9 3.48z",fill:"#EA4335"}),j("path",{d:"M17.64 9.2c0-.74-.06-1.28-.19-1.84H9v3.34h4.96c-.1.83-.64 2.08-1.84 2.92l2.84 2.2c1.7-1.57 2.68-3.88 2.68-6.62z",fill:"#4285F4"}),j("path",{d:"M3.88 10.78A5.54 5.54 0 0 1 3.58 9c0-.62.11-1.22.29-1.78L.96 4.96A9.008 9.008 0 0 0 0 9c0 1.45.35 2.82.96 4.04l2.92-2.26z",fill:"#FBBC05"}),j("path",{d:"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.84-2.2c-.76.53-1.78.9-3.12.9-2.38 0-4.4-1.57-5.12-3.74L.97 13.04C2.45 15.98 5.48 18 9 18z",fill:"#34A853"}),j("path",{fill:"none",d:"M0 0h18v18H0z"})]})})}import{jsx as ge,jsxs as On}from"react/jsx-runtime";var ro=e=>ge(L,{provider:"azure-ad",dataSlot:"azure-button",defaultButtonText:"Continue with Microsoft",providerClassName:"bg-[#0078d4] hover:bg-[#0078d4] hover:bg-opacity-85 pl-[3px] text-white gap-4 transition-colors shadow-md",icon:ge(zn,{}),...e});ro.displayName="AzureSignInButton";var Un=ro,zn=()=>On("svg",{"aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 23 23",className:"w-5 h-5 ml-3",children:[ge("path",{fill:"#f3f3f3",d:"M0 0h23v23H0z"}),ge("path",{fill:"#f35325",d:"M1 1h10v10H1z"}),ge("path",{fill:"#81bc06",d:"M12 1h10v10H12z"}),ge("path",{fill:"#05a6f0",d:"M1 12h10v10H1z"}),ge("path",{fill:"#ffba08",d:"M12 12h10v10H12z"})]});import{jsx as Ce}from"react/jsx-runtime";var io=e=>Ce(L,{provider:"discord",dataSlot:"discord-button",defaultButtonText:"Continue with Discord",providerClassName:"bg-[#5865F2] hover:bg-[#5865F2] hover:bg-opacity-85 pl-[3px] gap-4 transition-colors border shadow-md text-white",icon:Ce(Hn,{}),...e});io.displayName="DiscordSignInButton";var An=io,Hn=()=>Ce("svg",{"aria-hidden":"true",focusable:"false",className:"w-5 h-5 ml-3",viewBox:"0 0 75 59",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:Ce("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:Ce("g",{id:"discord-icon",transform:"translate(2.000000, 2.411745)",fillRule:"nonzero",stroke:"#636262",strokeWidth:"0",children:Ce("path",{d:"M60.1044999,4.48605546 C55.5791999,2.40965546 50.7264999,0.879855461 45.6526999,0.00367546142 C45.5602999,-0.0132345386 45.4679999,0.0290244614 45.4203999,0.113544461 C44.7962999,1.22355546 44.1049999,2.67165546 43.6208999,3.80985546 C38.1636999,2.99285546 32.7344999,2.99285546 27.3891999,3.80985546 C26.9049999,2.64635546 26.1885999,1.22355546 25.5616999,0.113544461 C25.5140999,0.0318444614 25.4217999,-0.0104145386 25.3293999,0.00367546142 C20.2583999,0.877055461 15.4056999,2.40685546 10.8775999,4.48605546 C10.8383999,4.50295546 10.8047999,4.53115546 10.7824999,4.56775546 C1.57794989,18.3191555 -0.94356111,31.7325555 0.29340789,44.9796555 C0.29900489,45.0444555 0.33538589,45.1064555 0.38576089,45.1458555 C6.45865989,49.6056555 12.3412999,52.3131555 18.1146999,54.1077555 C18.2070999,54.1359555 18.3049999,54.1021555 18.3637999,54.0260555 C19.7294999,52.1610555 20.9468999,50.1945555 21.9906999,48.1265555 C22.0522999,48.0054555 21.9934999,47.8617555 21.8675999,47.8138555 C19.9365999,47.0813555 18.0978999,46.1882555 16.3291999,45.1740555 C16.1892999,45.0923555 16.1780999,44.8922555 16.3067999,44.7964555 C16.6789999,44.5175555 17.0512999,44.2273555 17.4066999,43.9343555 C17.4709999,43.8808555 17.5605999,43.8695555 17.6361999,43.9033555 C29.2557999,49.2084555 41.8353999,49.2084555 53.3178999,43.9033555 C53.3934999,43.8667555 53.4830999,43.8780555 53.5501999,43.9315555 C53.9056999,44.2245555 54.2778999,44.5175555 54.6528999,44.7964555 C54.7815999,44.8922555 54.7731999,45.0923555 54.6332999,45.1740555 C52.8645999,46.2079555 51.0258999,47.0813555 49.0920999,47.8110555 C48.9661999,47.8589555 48.9101999,48.0054555 48.9717999,48.1265555 C50.0379999,50.1916555 51.2553999,52.1581555 52.5958999,54.0232555 C52.6518999,54.1021555 52.7525999,54.1359555 52.8449999,54.1077555 C58.6463999,52.3131555 64.5289999,49.6056555 70.6018999,45.1458555 C70.6550999,45.1064555 70.6886999,45.0472555 70.6942999,44.9824555 C72.1746999,29.6673555 68.2146999,16.3639555 60.1967999,4.57055546 C60.1771999,4.53115546 60.1436999,4.50295546 60.1044999,4.48605546 Z M23.7258999,36.9135555 C20.2275999,36.9135555 17.3450999,33.7018555 17.3450999,29.7575555 C17.3450999,25.8132555 20.1716999,22.6015555 23.7258999,22.6015555 C27.3079999,22.6015555 30.1625999,25.8414555 30.1065999,29.7575555 C30.1065999,33.7018555 27.2799999,36.9135555 23.7258999,36.9135555 Z M47.3177999,36.9135555 C43.8195999,36.9135555 40.9370999,33.7018555 40.9370999,29.7575555 C40.9370999,25.8132555 43.7635999,22.6015555 47.3177999,22.6015555 C50.8999999,22.6015555 53.7544999,25.8414555 53.6985999,29.7575555 C53.6985999,33.7018555 50.8999999,36.9135555 47.3177999,36.9135555 Z",id:"Shape",fill:"white"})})})});import{jsx as qe}from"react/jsx-runtime";var ao=e=>qe(L,{provider:"github",dataSlot:"github-button",defaultButtonText:"Continue with GitHub",providerClassName:"bg-black hover:bg-slate-800 pl-[3px] text-white gap-4 transition-colors shadow-md",icon:qe(Qn,{}),...e});ao.displayName="GitHubSignInButton";var Vn=ao,Qn=()=>qe("svg",{"aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32.58 31.77",fill:"currentColor",className:"w-5 h-5 ml-3",children:qe("path",{fill:"#FFFFFF",d:"M16.29,0a16.29,16.29,0,0,0-5.15,31.75c.82.15,1.11-.36,1.11-.79s0-1.41,0-2.77C7.7,29.18,6.74,26,6.74,26a4.36,4.36,0,0,0-1.81-2.39c-1.47-1,.12-1,.12-1a3.43,3.43,0,0,1,2.49,1.68,3.48,3.48,0,0,0,4.74,1.36,3.46,3.46,0,0,1,1-2.18c-3.62-.41-7.42-1.81-7.42-8a6.3,6.3,0,0,1,1.67-4.37,5.94,5.94,0,0,1,.16-4.31s1.37-.44,4.48,1.67a15.41,15.41,0,0,1,8.16,0c3.11-2.11,4.47-1.67,4.47-1.67A5.91,5.91,0,0,1,25,11.07a6.3,6.3,0,0,1,1.67,4.37c0,6.26-3.81,7.63-7.44,8a3.85,3.85,0,0,1,1.11,3c0,2.18,0,3.94,0,4.47s.29.94,1.12.78A16.29,16.29,0,0,0,16.29,0Z"})});import{jsx as We}from"react/jsx-runtime";var so=e=>We(L,{provider:"hubspot",dataSlot:"hubspot-button",defaultButtonText:"Continue with HubSpot",providerClassName:"bg-[#ff7a59] hover:bg-[#ff7a59] hover:bg-opacity-85 pl-[3px] text-white gap-4 transition-colors shadow-md",icon:We(Wn,{}),...e});so.displayName="HubSpotSignInButton";var qn=so,Wn=()=>We("svg",{"aria-hidden":"true",focusable:"false",className:"w-5 h-5 ml-3",viewBox:"6.20856283 .64498824 244.26943717 251.24701176",xmlns:"http://www.w3.org/2000/svg",children:We("path",{d:"m191.385 85.694v-29.506a22.722 22.722 0 0 0 13.101-20.48v-.677c0-12.549-10.173-22.722-22.721-22.722h-.678c-12.549 0-22.722 10.173-22.722 22.722v.677a22.722 22.722 0 0 0 13.101 20.48v29.506a64.342 64.342 0 0 0 -30.594 13.47l-80.922-63.03c.577-2.083.878-4.225.912-6.375a25.6 25.6 0 1 0 -25.633 25.55 25.323 25.323 0 0 0 12.607-3.43l79.685 62.007c-14.65 22.131-14.258 50.974.987 72.7l-24.236 24.243c-1.96-.626-4-.959-6.057-.987-11.607.01-21.01 9.423-21.007 21.03.003 11.606 9.412 21.014 21.018 21.017 11.607.003 21.02-9.4 21.03-21.007a20.747 20.747 0 0 0 -.988-6.056l23.976-23.985c21.423 16.492 50.846 17.913 73.759 3.562 22.912-14.352 34.475-41.446 28.985-67.918-5.49-26.473-26.873-46.734-53.603-50.792m-9.938 97.044a33.17 33.17 0 1 1 0-66.316c17.85.625 32 15.272 32.01 33.134.008 17.86-14.127 32.522-31.977 33.165",fill:"white"})});import{jsx as $e,jsxs as Gn}from"react/jsx-runtime";var lo=e=>$e(L,{provider:"linkedin",dataSlot:"linkedin-button",defaultButtonText:"Continue with LinkedIn",providerClassName:"bg-[#0288D1] hover:bg-[#0288D1] pl-[3px] hover:bg-opacity-85 gap-4 transition-colors shadow-md text-white",icon:$e(Kn,{}),...e});lo.displayName="LinkedInSignInButton";var $n=lo,Kn=()=>Gn("svg",{"aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",className:"w-6 h-6 ml-3",children:[$e("path",{fill:"#fff",d:"M42,37c0,2.762-2.238,5-5,5H11c-2.761,0-5-2.238-5-5V11c0-2.762,2.239-5,5-5h26c2.762,0,5,2.238,5,5V37z"}),$e("path",{fill:"#0288D1",d:"M12 19H17V36H12zM14.485 17h-.028C12.965 17 12 15.888 12 14.499 12 13.08 12.995 12 14.514 12c1.521 0 2.458 1.08 2.486 2.499C17 15.887 16.035 17 14.485 17zM36 36h-5v-9.099c0-2.198-1.225-3.698-3.192-3.698-1.501 0-2.313 1.012-2.707 1.99C24.957 25.543 25 26.511 25 27v9h-5V19h5v2.616C25.721 20.5 26.85 19 29.738 19c3.578 0 6.261 2.25 6.261 7.274L36 36 36 36z"})]});import{jsx as he,jsxs as Yn}from"react/jsx-runtime";var uo=e=>he(L,{provider:"slack",dataSlot:"slack-button",defaultButtonText:"Continue with Slack",providerClassName:"bg-[#4A154B] pl-[3px] hover:bg-opacity-85 gap-4 transition-colors shadow-md text-white",icon:he(Xn,{}),...e});uo.displayName="SlackSignInButton";var _n=uo,Xn=()=>he("svg",{"aria-hidden":"true",focusable:"false",enableBackground:"new 0 0 2447.6 2452.5",viewBox:"0 0 2447.6 2452.5",className:"w-5 h-5 ml-3",xmlns:"http://www.w3.org/2000/svg",children:Yn("g",{clipRule:"evenodd",fillRule:"evenodd",children:[he("path",{d:"m897.4 0c-135.3.1-244.8 109.9-244.7 245.2-.1 135.3 109.5 245.1 244.8 245.2h244.8v-245.1c.1-135.3-109.5-245.1-244.9-245.3.1 0 .1 0 0 0m0 654h-652.6c-135.3.1-244.9 109.9-244.8 245.2-.2 135.3 109.4 245.1 244.7 245.3h652.7c135.3-.1 244.9-109.9 244.8-245.2.1-135.4-109.5-245.2-244.8-245.3z",fill:"#36c5f0"}),he("path",{d:"m2447.6 899.2c.1-135.3-109.5-245.1-244.8-245.2-135.3.1-244.9 109.9-244.8 245.2v245.3h244.8c135.3-.1 244.9-109.9 244.8-245.3zm-652.7 0v-654c.1-135.2-109.4-245-244.7-245.2-135.3.1-244.9 109.9-244.8 245.2v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.3z",fill:"#2eb67d"}),he("path",{d:"m1550.1 2452.5c135.3-.1 244.9-109.9 244.8-245.2.1-135.3-109.5-245.1-244.8-245.2h-244.8v245.2c-.1 135.2 109.5 245 244.8 245.2zm0-654.1h652.7c135.3-.1 244.9-109.9 244.8-245.2.2-135.3-109.4-245.1-244.7-245.3h-652.7c-135.3.1-244.9 109.9-244.8 245.2-.1 135.4 109.4 245.2 244.7 245.3z",fill:"#ecb22e"}),he("path",{d:"m0 1553.2c-.1 135.3 109.5 245.1 244.8 245.2 135.3-.1 244.9-109.9 244.8-245.2v-245.2h-244.8c-135.3.1-244.9 109.9-244.8 245.2zm652.7 0v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.2v-653.9c.2-135.3-109.4-245.1-244.7-245.3-135.4 0-244.9 109.8-244.8 245.1 0 0 0 .1 0 0",fill:"#e01e5a"})]})});import{jsx as Ke}from"react/jsx-runtime";var co=e=>Ke(L,{provider:"twitter",dataSlot:"twitter-button",defaultButtonText:"Continue with X",providerClassName:"bg-black hover:bg-slate-800 pl-[3px] text-white gap-4 transition-colors shadow-md",icon:Ke(Jn,{}),...e});co.displayName="XSignInButton";var Zn=co,Jn=()=>Ke("svg",{"aria-hidden":"true",focusable:"false",className:"w-5 h-5 ml-3",viewBox:"0 0 24 24",version:"1.1",children:Ke("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",fill:"#ffffff"})});import{jsx as Fe}from"react/jsx-runtime";var mo=e=>Fe(L,{provider:"okta",dataSlot:"okta-button",defaultButtonText:"Continue with Okta",providerClassName:"bg-[#181818] hover:bg-[#3f59e4] pl-[3px] gap-4 transition-colors shadow-md text-white",icon:Fe(er,{}),...e});mo.displayName="OktaSignInButton";var jn=mo,er=()=>Fe("svg",{"aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 63 63",fill:"currentColor",className:"w-5 h-5 ml-3",width:"18",height:"18",children:Fe("g",{children:Fe("path",{d:`M34.6,0.4l-1.3,16c-0.6-0.1-1.2-0.1-1.9-0.1c-0.8,0-1.6,0.1-2.3,0.2l-0.7-7.7c0-0.2,0.2-0.5,0.4-0.5h1.3
3
3
  l-0.6-7.8c0-0.2,0.2-0.5,0.4-0.5h4.3C34.5,0,34.7,0.2,34.6,0.4L34.6,0.4L34.6,0.4z M23.8,1.2c-0.1-0.2-0.3-0.4-0.5-0.3l-4,1.5
4
4
  C19,2.5,18.9,2.8,19,3l3.3,7.1l-1.2,0.5c-0.2,0.1-0.3,0.3-0.2,0.6l3.3,7c1.2-0.7,2.5-1.2,3.9-1.5L23.8,1.2L23.8,1.2z M14,5.7
5
5
  l9.3,13.1c-1.2,0.8-2.2,1.7-3.1,2.7L14.5,16c-0.2-0.2-0.2-0.5,0-0.6l1-0.8L10,9c-0.2-0.2-0.2-0.5,0-0.6l3.3-2.7
@@ -24,8 +24,8 @@ import ce from"react";import{useForm as qo}from"react-hook-form";import{Mail as
24
24
  L52.2,42l7.1,3.4c0.2,0.1,0.3,0.4,0.2,0.6L57.4,49.6C57.4,49.6,57.4,49.6,57.4,49.6z M39.7,44.2L49,57.3c0.1,0.2,0.4,0.2,0.6,0.1
25
25
  l3.3-2.7c0.2-0.2,0.2-0.4,0-0.6l-5.5-5.6l1-0.8c0.2-0.2,0.2-0.4,0-0.6l-5.5-5.5C42,42.6,40.9,43.5,39.7,44.2L39.7,44.2L39.7,44.2z
26
26
  M39.7,62c-0.2,0.1-0.5-0.1-0.5-0.3l-4.2-15.4c1.4-0.3,2.7-0.8,3.9-1.5l3.3,7c0.1,0.2,0,0.5-0.2,0.6l-1.2,0.5l3.3,7.1
27
- c0.1,0.2,0,0.5-0.2,0.6L39.7,62L39.7,62L39.7,62z`})));import rt from"react";import fe from"react";import{useForm as Lr}from"react-hook-form";import{useMutation as Er}from"@tanstack/react-query";import{signUp as kr}from"@niledatabase/client";function Ve(e,t){let{onSuccess:o,onError:r,beforeMutate:n,...s}=e,i=L(t),u=Er({mutationFn:async a=>{let c=n&&n(a),m={...a,...c},{data:l,error:b}=await kr({...s,...m});if(b)throw new Error(b);return l},onSuccess:o,onError:r},i);return Rt(e),u.mutate}function ot(e){let{client:t}=e??{};return fe.createElement(U,{client:t},fe.createElement(Br,{...e}))}function Br(e){let t=Ve(e),o=Lr({defaultValues:{email:"",password:""}});return fe.createElement(q,{...o},fe.createElement("form",{onSubmit:o.handleSubmit(({email:r,password:n})=>t({email:r,password:n})),className:"space-y-8"},fe.createElement(_,null),fe.createElement(me,null),fe.createElement(P,null,"Sign up")))}function nt({className:e,...t}){return rt.createElement("div",{className:d(e,"flex flex-col gap-4")},rt.createElement("div",{className:"font-sans text-3xl"},"Sign up"),rt.createElement(ot,{...t}))}import st from"react";import pe from"react";import{useForm as zr}from"react-hook-form";import{useMutation as Tr}from"@tanstack/react-query";import{signIn as Ur}from"@niledatabase/client";function Qe(e){let{onSuccess:t,onError:o,beforeMutate:r,callbackUrl:n,init:s,baseUrl:i,fetchUrl:u,resetUrl:a,auth:c,redirect:m,client:l}=e??{},b=L(l);return Tr({mutationFn:async f=>{let E={...f,callbackUrl:n},j=(r&&r(E))??E,Q=await Ur(j.provider,{init:s,auth:c,baseUrl:i,fetchUrl:u,redirect:m,resetUrl:a,...j});if(!Q?.ok&&Q?.error)throw new Error(Q.error);return Q},onSuccess:t,onError:o},b).mutate}function it(e){let{client:t}=e??{};return pe.createElement(U,{client:t},pe.createElement(Rr,{...e}))}function Rr(e){let t=Qe(e),o=zr({defaultValues:{email:"",password:""}});return pe.createElement(q,{...o},pe.createElement("form",{onSubmit:o.handleSubmit(({email:r,password:n})=>t&&t({provider:"credentials",email:r,password:n})),className:"space-y-8"},pe.createElement(_,null),pe.createElement(me,null),pe.createElement(P,{type:"submit"},"Sign In")))}function at({className:e,...t}){return st.createElement("div",{className:d(e,"flex flex-col gap-4")},st.createElement("h2",{className:"font-sans text-3xl"},"Sign In"),st.createElement(it,{...t}))}import lt from"react";import{Slot as Ar}from"@radix-ui/react-slot";import{LogOut as Or}from"lucide-react";import{signOut as Hr}from"@niledatabase/client";var Jt=({callbackUrl:e,redirect:t,className:o,buttonText:r="Sign out",variant:n,size:s,baseUrl:i,fetchUrl:u,basePath:a,auth:c,asChild:m=!1,...l})=>lt.createElement(m?Ar:"button",{"data-slot":"signout-button",className:M({variant:n,size:s,className:o}),onClick:()=>{Hr({callbackUrl:e,redirect:t,baseUrl:i,auth:c,fetchUrl:u,basePath:a})},...l},l.children?l.children:lt.createElement("div",{className:"flex flex-row gap-2 items-center"},lt.createElement(Or,null),r));Jt.displayName="SignOutButton";var Vr=Jt;import mt from"react";import W from"react";import{auth as N,getStatus as Qr,broadcast as qr}from"@niledatabase/client";function Wr(){let[e,t]=W.useState(typeof navigator<"u"?navigator.onLine:!1),o=()=>t(!0),r=()=>t(!1);return W.useEffect(()=>(window.addEventListener("online",o),window.addEventListener("offline",r),()=>{window.removeEventListener("online",o),window.removeEventListener("offline",r)}),[]),e}var ut=()=>({basePath:N.state.basePath,baseUrl:N.state.baseUrl,lastSync:N.state.lastSync,getSession:N.state.getSession,session:N.state.session,loading:N.state.loading}),jr=Object.freeze({basePath:N.state.basePath,baseUrl:N.state.baseUrl,lastSync:0,getSession:()=>{},session:void 0,loading:!0}),Y=ut(),$r=e=>{let t=()=>{Y=ut(),e()};return N.addListener(t),()=>N.removeListener(t)},Kr=()=>{let e=N.state;return(Y.session!==e.session||Y.loading!==e.loading||Y.basePath!==e.basePath||Y.baseUrl!==e.baseUrl||Y.lastSync!==e.lastSync||Y.getSession!==e.getSession)&&(Y=ut()),Y},Gr=()=>jr;function _r(){return W.useSyncExternalStore($r,Kr,Gr)}var Se=W.createContext?.(void 0);function Me(e){if(!Se)throw new Error("React Context is unavailable in Server Components");let t=W.useContext(Se),{required:o,onUnauthenticated:r}=e??{},n=o&&t.status==="unauthenticated";return W.useEffect(()=>{if(n){let s=`/api/auth/signin?${new URLSearchParams({error:"SessionRequired",callbackUrl:window.location.href})}`;r?r():window.location.href=s}},[n,r]),n?{data:t.data,update:t.update,status:"loading",state:t.state}:t}function Ne(e){if(!Se)throw new Error("React Context is unavailable in Server Components");let{children:t,refetchWhenOffline:o,refetchInterval:r,refetchOnWindowFocus:n}=e,s=_r(),i=e.session&&!(e.session instanceof Response)?e.session:void 0,u=s.session===void 0?i??null:s.session??null;W.useEffect(()=>{e.basePath&&(N.state.basePath=e.basePath),e.session&&!(e.session instanceof Response)?N.initialize({baseUrl:e.baseUrl,session:e.session}):N.status||N.getSession({baseUrl:e.baseUrl})},[e.basePath,e.baseUrl,e.session]);let a=Wr(),c=o!==!1||a,m=W.useCallback(()=>{document.visibilityState==="visible"&&N.sync("visibilitychange")},[]);W.useEffect(()=>{if(r&&c){let f=setInterval(()=>{N.state.session&&N.getSession({event:"poll"})},r*1e3);return()=>clearInterval(f)}},[r,c]),W.useEffect(()=>{n?document.addEventListener("visibilitychange",m,!1):document.removeEventListener("visibilitychange",m);let f=qr.receive(()=>N.sync("storage"));return()=>{N.state.lastSync=0,N.state.session=void 0,f(),document.removeEventListener("visibilitychange",m,!1)}},[n,m]);let l=s.session===void 0&&i!==void 0?!1:s.loading,b=Qr(l,u),p=W.useMemo(()=>({data:u??null,status:b,state:s,async update(){return await N.refreshSession()}}),[u,s,b]);return W.createElement(Se.Provider,{value:p},t)}function ct(e){return e&&"exp"in e?{...e,expires:new Date(e.exp*1e3).toISOString()}:e}function Zt({children:e,session:t,...o}){if(t instanceof Response)return null;let r=ct(t);return mt.createElement(Ne,{...o,session:r},mt.createElement(Xr,{className:o.className},e))}function Xr({children:e,className:t}){let{status:o}=Me();return o==="authenticated"?t?mt.createElement("div",{className:t},e):e:null}import dt from"react";function eo({children:e,session:t,...o}){if(t instanceof Response)return null;let r=ct(t);return dt.createElement(Ne,{...o,session:r},dt.createElement(Yr,{className:o.className},e))}function Yr({className:e,children:t}){let{status:o}=Me();return o==="unauthenticated"?e?dt.createElement("div",{className:e},t):t:null}import{mfa as no,sanitizeRedirectUrl as io}from"@niledatabase/client";import{useState as Fe,useEffect as Zr,useCallback as Ke}from"react";var qe=e=>typeof e=="object"&&e!==null,to=e=>e==="setup"||e==="challenge",Jr=e=>{if(!Array.isArray(e))return;let t=e.filter(o=>typeof o=="string"&&o.trim().length>0);return t.length>0?t:void 0},oo=e=>!qe(e)||e.method!=="authenticator"||!to(e.scope)||typeof e.token!="string"?null:{method:"authenticator",token:e.token,scope:e.scope,otpauthUrl:typeof e.otpauthUrl=="string"?e.otpauthUrl:void 0,secret:typeof e.secret=="string"?e.secret:void 0,recoveryKeys:Jr(e.recoveryKeys)},ro=e=>!qe(e)||e.method!=="email"||!to(e.scope)||typeof e.token!="string"?null:{method:"email",token:e.token,scope:e.scope,maskedEmail:typeof e.maskedEmail=="string"&&e.maskedEmail.trim().length>0?e.maskedEmail:void 0};var We="nile.mfa.challenge";function je(e){if(!(typeof window>"u"))try{window.sessionStorage.setItem(We,JSON.stringify(e))}catch{}}function $e(){if(typeof window>"u")return null;try{let e=window.sessionStorage.getItem(We);if(!e)return null;let t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.token=="string"&&(t.method==="email"||t.method==="authenticator")&&(t.scope==="setup"||t.scope==="challenge"))return{token:t.token,method:t.method,scope:t.scope,destination:typeof t.destination=="string"?t.destination:void 0}}catch{}return null}function be(){if(!(typeof window>"u"))try{window.sessionStorage.removeItem(We)}catch{}}var so="/mfa/prompt",lo=({method:e,currentMethod:t,promptPath:o=so,onRedirect:r,onChallengeRedirect:n})=>{let[s,i]=Fe(null),[u,a]=Fe(null),[c,m]=Fe(null),[l,b]=Fe(!1),[p,f]=Fe(!1),E=e==="authenticator"?oo:ro,F=Ke(S=>{let R=io(S);if(r){r(R);return}typeof window<"u"&&window.location.assign(R)},[r]),j=Ke(S=>{if(n){n(S);return}je(S);let R=new URLSearchParams({method:S.method,scope:S.scope});S.destination&&R.set("destination",S.destination);let O=io(o,{fallback:so}),k=O.includes("?")?"&":"?";F(`${O}${k}${R.toString()}`)},[F,n,o]),Q=Ke(async()=>{b(!0),a(null),m(null);try{let S=await no({scope:"setup",method:e}),R=ao(S);if(R){i(null),a("setup"),m(R);return}let O=ft(S);if(O){F(O);return}let k=E(S);if(!k){i(null),a("parseSetup");return}if(k.scope==="challenge"){j({token:k.token,method:k.method,scope:k.scope,destination:"maskedEmail"in k?k.maskedEmail:void 0});return}i(k)}catch{a("setup"),i(null)}finally{b(!1)}},[e,F,E,j]),A=Ke(async()=>{f(!0),a(null),m(null);try{let S=await no({method:e}),R=ao(S);if(R){a("disable"),m(R);return}let O=ft(S);if(O){F(O);return}let k=E(S);if(!k){a("parseDisable");return}i(k)}catch{a("disable")}finally{f(!1)}},[e,F,E]);return Zr(()=>(a(null),m(null),i(null),()=>{i(null)}),[t]),{setup:s,loading:l||p,errorType:u,errorMessage:c,startSetup:Q,startDisable:A}},ft=e=>qe(e)&&typeof e.url=="string"||typeof Response<"u"&&e instanceof Response&&typeof e.url=="string"?e.url:null,ao=e=>{let t=ft(e);if(!t)return null;try{let o=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(t,o).searchParams.get("error");if(n)return n}catch{return null}return null};import ne from"react";import ht from"react-qr-code";import H from"react";import{Copy as en,Download as tn}from"lucide-react";import{useState as on,useMemo as rn,useEffect as nn}from"react";function pt({setup:e,onError:t}){let[o,r]=on("idle"),n=rn(()=>e.recoveryKeys?.join(`
28
- `)??"",[e.recoveryKeys]);return nn(()=>{r("idle")},[e.token]),H.createElement("div",{className:"mt-4 flex w-full flex-col items-center gap-3 text-left"},H.createElement("div",{className:"w-full max-w-sm space-y-2"},H.createElement("p",{className:"text-sm font-medium"},"Recovery codes"),H.createElement("p",{className:"text-xs text-muted-foreground"},"Store these somewhere safe. Use one if you lose your authenticator device."),H.createElement("div",{className:"rounded-md border border-dashed bg-muted/30 p-4"},H.createElement("ul",{className:"grid gap-2 font-mono text-sm"},e.recoveryKeys?.map(s=>H.createElement("li",{key:s},s)))),H.createElement("div",{className:"flex flex-wrap items-center gap-2"},H.createElement(P,{type:"button",size:"sm",onClick:async()=>{if(n){if(!("clipboard"in navigator)){r("error");return}try{await navigator.clipboard.writeText(n),r("copied")}catch{r("error")}}}},H.createElement(en,{className:"size-4","aria-hidden":"true"}),"Copy"),H.createElement(P,{type:"button",size:"sm",variant:"outline",onClick:()=>{if(n)try{let s=`Nile MFA recovery codes
27
+ c0.1,0.2,0,0.5-0.2,0.6L39.7,62L39.7,62L39.7,62z`})})});import{useState as fo}from"react";import{useForm as rr}from"react-hook-form";import{useMutation as tr}from"@tanstack/react-query";import{signUp as or}from"@niledatabase/client";function nr(e={},t){let{onSuccess:o,onError:n,beforeMutate:r,client:i,...a}=e??{},s=B(t??i),l=tr({mutationFn:async u=>{let m=r&&r(u),d={...u,...m},g=await or({...a,...d});if(!g)return;let{data:c,error:p}=g;if(p)throw new Error(p);return c},onSuccess:o,onError:n},s);return qt(e),l}function Ge(e={},t){return nr(e,t).mutate}import{jsx as ye,jsxs as ar}from"react/jsx-runtime";function mt(e){let{client:t}=e??{};return ye(U,{client:t,children:ye(ir,{...e})})}function ir(e){let[t,o]=fo(!1),[n,r]=fo(null),i=Ge({...e,onSuccess:(s,l)=>{o(!1),r(null),e.onSuccess?.(s,l)},onError:(s,l)=>{o(!1),r(s instanceof Error?s.message:"Sign up failed"),e.onError?.(s,l)}}),a=rr({defaultValues:{email:"",password:""}});return ye(q,{...a,children:ar("form",{onSubmit:a.handleSubmit(({email:s,password:l})=>{o(!0),r(null),i?.({email:s,password:l})}),className:"space-y-8",children:[ye(J,{}),ye(pe,{autoComplete:"new-password"}),!e.onError&&n?ye("p",{role:"alert",className:"text-sm font-medium text-destructive",children:n}):null,ye(R,{type:"submit",loading:t,children:e.buttonText??"Sign up"})]})})}import{jsx as po,jsxs as sr}from"react/jsx-runtime";function dt({className:e,...t}){return sr("div",{className:f(e,"flex flex-col gap-4"),children:[po("h2",{className:"font-sans text-3xl",children:"Sign up"}),po(mt,{...t})]})}import{useState as go}from"react";import{useForm as mr}from"react-hook-form";import{useMutation as lr}from"@tanstack/react-query";import{signIn as ur}from"@niledatabase/client";function cr(e){let{onSuccess:t,onError:o,beforeMutate:n,callbackUrl:r,init:i,baseUrl:a,fetchUrl:s,resetUrl:l,auth:u,redirect:m,client:d}=e??{},g=B(d);return lr({mutationFn:async c=>{let p={...c,callbackUrl:r},S=(n&&n(p))??p,C=await ur(S.provider,{init:i,auth:u,baseUrl:a,fetchUrl:s,redirect:m,resetUrl:l,...S});if(m===!1&&!C)throw new Error("Sign in failed");if(C&&(!C.ok||C.error))throw new Error(C.error??"Sign in failed");return C},onSuccess:t,onError:o},g)}function _e(e){return cr(e).mutate}import{jsx as be,jsxs as fr}from"react/jsx-runtime";function ft(e){let{client:t}=e??{};return be(U,{client:t,children:be(dr,{...e})})}function dr(e){let[t,o]=go(!1),[n,r]=go(null),i=_e({...e,onSuccess:(...s)=>{o(!1),r(null),e.onSuccess?.(...s)},onError:(s,l)=>{o(!1),r(s instanceof Error?s.message:"Sign in failed"),e.onError?.(s,l)}}),a=mr({defaultValues:{email:"",password:""}});return be(q,{...a,children:fr("form",{onSubmit:a.handleSubmit(({email:s,password:l})=>{o(!0),r(null),i?.({provider:"credentials",email:s,password:l})}),className:"space-y-8",children:[be(J,{}),be(pe,{autoComplete:"current-password"}),!e.onError&&n?be("p",{role:"alert",className:"text-sm font-medium text-destructive",children:n}):null,be(R,{type:"submit",loading:t,children:e.buttonText??"Sign In"})]})})}import{jsx as ho,jsxs as pr}from"react/jsx-runtime";function pt({className:e,...t}){return pr("div",{className:f(e,"flex flex-col gap-4"),children:[ho("h2",{className:"font-sans text-3xl",children:"Sign In"}),ho(ft,{...t})]})}import{Slot as gr}from"@radix-ui/react-slot";import{LogOut as hr}from"lucide-react";import{signOut as yr}from"@niledatabase/client";import{jsx as yo,jsxs as vr}from"react/jsx-runtime";var bo=({callbackUrl:e,redirect:t,className:o,buttonText:n="Sign out",variant:r,size:i,baseUrl:a,fetchUrl:s,basePath:l,auth:u,init:m,loading:d,type:g="button",asChild:c=!1,onClick:p,children:y,...S})=>yo(c?gr:"button",{...S,...c?{}:{type:g},"data-slot":"signout-button",className:ae({variant:r,size:i,className:o}),onClick:b=>{yr({callbackUrl:e,redirect:t,baseUrl:a,auth:u,fetchUrl:s,basePath:l,init:m}),p?.(b)},children:y||vr("div",{className:"flex flex-row gap-2 items-center",children:[yo(hr,{"aria-hidden":"true"}),n]})});bo.displayName="SignOutButton";var br=bo;import{useMemo as Dr}from"react";import K from"react";import{auth as D,getStatus as wr,broadcast as Sr}from"@niledatabase/client";import{jsx as Fr}from"react/jsx-runtime";function Pr(){let[e,t]=K.useState(!0);return K.useEffect(()=>{typeof navigator<"u"&&typeof navigator.onLine=="boolean"&&t(navigator.onLine);let o=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",o),window.addEventListener("offline",n),()=>{window.removeEventListener("online",o),window.removeEventListener("offline",n)}},[]),e}var gt=()=>({basePath:D.state.basePath,baseUrl:D.state.baseUrl,lastSync:D.state.lastSync,getSession:D.state.getSession,session:D.state.session,loading:D.state.loading}),Cr=Object.freeze({basePath:D.state.basePath,baseUrl:D.state.baseUrl,lastSync:0,getSession:()=>{},session:void 0,loading:!0}),ee=gt(),xr=e=>{let t=()=>{ee=gt(),e()};return D.addListener(t),()=>D.removeListener(t)},Rr=()=>{let e=D.state;return(ee.session!==e.session||ee.loading!==e.loading||ee.basePath!==e.basePath||ee.baseUrl!==e.baseUrl||ee.lastSync!==e.lastSync||ee.getSession!==e.getSession)&&(ee=gt()),ee},Mr=()=>Cr;function Nr(){return K.useSyncExternalStore(xr,Rr,Mr)}var De=K.createContext?.(void 0);function Ee(e){if(!De)throw new Error("React Context is unavailable in Server Components");let t=K.useContext(De);if(!t)throw new Error("useSession must be wrapped in a <SessionProvider />");let{required:o,onUnauthenticated:n}=e??{},r=o&&t.status==="unauthenticated",i=t.state?.basePath||D.state.basePath||"/api";return K.useEffect(()=>{if(r&&typeof window<"u"){let a=`${i}/auth/signin?${new URLSearchParams({error:"SessionRequired",callbackUrl:window.location.href})}`;n?n():window.location.href=a}},[r,n,i]),r?{data:t.data,update:t.update,status:"loading",state:t.state}:t}function vo(e){return typeof Response<"u"&&e instanceof Response}function Ie(e){if(!De)throw new Error("React Context is unavailable in Server Components");let{children:t,refetchWhenOffline:o,refetchInterval:n,refetchOnWindowFocus:r=!0}=e,i=Nr(),a=e.session!==void 0&&!vo(e.session)?e.session:void 0,s=i.session===void 0?a??null:i.session??null;K.useEffect(()=>{(e.basePath||e.baseUrl)&&D.configure({basePath:e.basePath,baseUrl:e.baseUrl}),e.session!==void 0&&!vo(e.session)?D.initialize({baseUrl:e.baseUrl,session:e.session}):D.status||D.getSession({baseUrl:e.baseUrl})},[e.basePath,e.baseUrl,e.session]);let l=Pr(),u=o!==!1||l,m=K.useCallback(()=>{document.visibilityState==="visible"&&D.sync("visibilitychange")},[]);K.useEffect(()=>{if(n&&u){let p=setInterval(()=>{D.state.session&&D.getSession({event:"poll"})},n*1e3);return()=>clearInterval(p)}},[n,u]),K.useEffect(()=>{r?document.addEventListener("visibilitychange",m,!1):document.removeEventListener("visibilitychange",m);let p=Sr.receive(()=>D.sync("storage"));return()=>{p(),document.removeEventListener("visibilitychange",m,!1)}},[r,m]);let d=i.session===void 0&&a!==void 0?!1:i.loading,g=wr(d,s),c=K.useMemo(()=>({data:s??null,status:g,state:i,async update(){return await D.refreshSession()}}),[s,i,g]);return Fr(De.Provider,{value:c,children:t})}import{jsx as ht}from"react/jsx-runtime";function yt(e){return e&&"exp"in e?{...e,expires:new Date(e.exp*1e3).toISOString()}:e}function wo({children:e,session:t,...o}){let n=typeof Response<"u"&&t instanceof Response,r=Dr(()=>n?null:yt(t),[n,t]);return n?null:ht(Ie,{...o,session:r,children:ht(Er,{className:o.className,children:e})})}function Er({children:e,className:t}){let{status:o}=Ee();return o==="authenticated"?t?ht("div",{className:t,children:e}):e:null}import{useMemo as Ir}from"react";import{jsx as bt}from"react/jsx-runtime";function So({children:e,session:t,...o}){let n=Ir(()=>typeof Response<"u"&&t instanceof Response?t.ok?void 0:null:yt(t),[t]);return bt(Ie,{...o,session:n,children:bt(kr,{className:o.className,children:e})})}function kr({className:e,children:t}){let{status:o}=Ee();return o==="unauthenticated"?e?bt("div",{className:e,children:t}):t:null}import{mfa as Ro,sanitizeRedirectUrl as Mo}from"@niledatabase/client";import{useState as ke,useEffect as Lr,useCallback as je}from"react";var Xe=e=>typeof e=="object"&&e!==null,Po=e=>e==="setup"||e==="challenge",Br=e=>{if(!Array.isArray(e))return;let t=e.filter(o=>typeof o=="string"&&o.trim().length>0);return t.length>0?t:void 0},Co=e=>!Xe(e)||e.method!=="authenticator"||!Po(e.scope)||typeof e.token!="string"?null:{method:"authenticator",token:e.token,scope:e.scope,otpauthUrl:typeof e.otpauthUrl=="string"?e.otpauthUrl:void 0,secret:typeof e.secret=="string"?e.secret:void 0,recoveryKeys:Br(e.recoveryKeys)},xo=e=>!Xe(e)||e.method!=="email"||!Po(e.scope)||typeof e.token!="string"?null:{method:"email",token:e.token,scope:e.scope,maskedEmail:typeof e.maskedEmail=="string"&&e.maskedEmail.trim().length>0?e.maskedEmail:void 0};var Ye="nile.mfa.challenge";function Ze(e){if(!(typeof window>"u"))try{window.sessionStorage.setItem(Ye,JSON.stringify(e))}catch{}}function Je(){if(typeof window>"u")return null;try{let e=window.sessionStorage.getItem(Ye);if(!e)return null;let t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.token=="string"&&(t.method==="email"||t.method==="authenticator")&&(t.scope==="setup"||t.scope==="challenge"))return{token:t.token,method:t.method,scope:t.scope,destination:typeof t.destination=="string"?t.destination:void 0}}catch{}return null}function xe(){if(!(typeof window>"u"))try{window.sessionStorage.removeItem(Ye)}catch{}}var No="/mfa/prompt",Do=({method:e,currentMethod:t,promptPath:o=No,onRedirect:n,onChallengeRedirect:r})=>{let[i,a]=ke(null),[s,l]=ke(null),[u,m]=ke(null),[d,g]=ke(!1),[c,p]=ke(!1),y=e==="authenticator"?Co:xo,S=je(v=>{let P=Mo(v);if(n){n(P);return}typeof window<"u"&&window.location.assign(P)},[n]),C=je(v=>{if(r){r(v);return}Ze(v);let P=new URLSearchParams({method:v.method,scope:v.scope});v.destination&&P.set("destination",v.destination);let I=Mo(o,{fallback:No}),N=I.includes("?")?"&":"?";S(`${I}${N}${P.toString()}`)},[S,r,o]),b=je(async()=>{g(!0),l(null),m(null);try{let v=await Ro({scope:"setup",method:e}),P=Fo(v);if(P){a(null),l("setup"),m(P);return}let I=vt(v);if(I){S(I);return}let N=y(v);if(!N){a(null),l("parseSetup");return}if(N.scope==="challenge"){C({token:N.token,method:N.method,scope:N.scope,destination:"maskedEmail"in N?N.maskedEmail:void 0});return}a(N)}catch{l("setup"),a(null)}finally{g(!1)}},[e,S,y,C]),E=je(async()=>{p(!0),l(null),m(null);try{let v=await Ro({method:e}),P=Fo(v);if(P){l("disable"),m(P);return}let I=vt(v);if(I){S(I);return}let N=y(v);if(!N){l("parseDisable");return}a(N)}catch{l("disable")}finally{p(!1)}},[e,S,y]);return Lr(()=>(l(null),m(null),a(null),()=>{a(null)}),[t]),{setup:i,loading:d||c,errorType:s,errorMessage:u,startSetup:b,startDisable:E}},vt=e=>Xe(e)&&typeof e.url=="string"||typeof Response<"u"&&e instanceof Response&&typeof e.url=="string"?e.url:null,Fo=e=>{let t=vt(e);if(!t)return null;try{let o=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",r=new URL(t,o).searchParams.get("error");if(r)return r}catch{return null}return null};import Pt from"react-qr-code";import{Copy as Tr,Download as Ur}from"lucide-react";import{useState as zr,useMemo as Or,useEffect as Ar}from"react";import{jsx as _,jsxs as et}from"react/jsx-runtime";function wt({setup:e,onError:t}){let[o,n]=zr("idle"),r=Or(()=>e.recoveryKeys?.join(`
28
+ `)??"",[e.recoveryKeys]);return Ar(()=>{n("idle")},[e.token]),_("div",{className:"mt-4 flex w-full flex-col items-center gap-3 text-left",children:et("div",{className:"w-full max-w-sm space-y-2",children:[_("p",{className:"text-sm font-medium",children:"Recovery codes"}),_("p",{className:"text-xs text-muted-foreground",children:"Store these somewhere safe. Use one if you lose your authenticator device."}),_("div",{className:"rounded-md border border-dashed bg-muted/30 p-4",children:_("ul",{className:"grid gap-2 font-mono text-sm",children:e.recoveryKeys?.map(i=>_("li",{children:i},i))})}),et("div",{className:"flex flex-wrap items-center gap-2",children:[et(R,{type:"button",size:"sm",onClick:async()=>{if(r){if(!("clipboard"in navigator)){n("error");return}try{await navigator.clipboard.writeText(r),n("copied")}catch{n("error")}}},children:[_(Tr,{className:"size-4","aria-hidden":"true"}),"Copy"]}),et(R,{type:"button",size:"sm",variant:"outline",onClick:()=>{if(r)try{let i=`Nile MFA recovery codes
29
29
 
30
- `,i=new Blob([s,n],{type:"text/plain"}),u=URL.createObjectURL(i),a=document.createElement("a");a.href=u,a.download="nile-mfa-recovery-codes.txt",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(u)}catch{t("We were unable to download the recovery keys. Please try again.")}}},H.createElement(tn,{className:"size-4","aria-hidden":"true"}),"Download"),o==="copied"?H.createElement("span",{className:"text-xs text-muted-foreground"},"Recovery codes copied to clipboard."):o==="error"?H.createElement("span",{className:"text-xs text-destructive"},"Unable to copy automatically. Please copy the codes manually."):null)))}import*as v from"react";import{mfa as ln,sanitizeRedirectUrl as un}from"@niledatabase/client";import B,{useEffect as sn}from"react";import{mfa as an}from"@niledatabase/client";function gt({token:e,scope:t,method:o,remove:r,onSuccess:n,onCancel:s}){let[i,u]=B.useState(""),[a,c]=B.useState(null),[m,l]=B.useState(!1),[b,p]=B.useState(!1),[f,E]=B.useState(""),F=B.useRef(null),j=B.useId(),Q=B.useId(),A=B.useRef(null);sn(()=>(u(""),c(null),p(!1),l(!1),()=>{A.current&&(clearTimeout(A.current),A.current=null)}),[e]);let S=async k=>{if(k.preventDefault(),m||b)return;if(!e){c("Missing MFA challenge token. Please restart the sign-in flow.");return}let ie=i.trim();if(!ie.length){c("Enter your recovery code to continue.");return}l(!0),c(null);let Ce=!1;try{let $=await an({token:e,code:ie,scope:t,method:o,remove:r});if($?.ok){Ce=!0,p(!0),be();let se=typeof $.recoveryCodesRemaining=="number"?$.recoveryCodesRemaining:null;E(se!==null?`You have ${se} recovery ${se===1?"code":"codes"} remaining.`:"Recovery code verified."),A.current=setTimeout(()=>{n?.($.scope??t)},2e3);return}if($&&typeof $=="object"&&"url"in $){let se=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",Ee=new URL(String($.url),se);c(Ee.searchParams.get("error")??"We couldn't verify that recovery code. Please try again.");return}c("We couldn't verify that recovery code. Please try again.")}catch{c("We ran into a problem verifying the code. Please try again.")}finally{Ce||l(!1)}},R=k=>{u(k.target.value),a&&c(null)},O=m||b;return B.createElement("form",{className:"space-y-6",onSubmit:S},B.createElement("fieldset",{className:"flex flex-col gap-6",disabled:O},B.createElement("label",{htmlFor:j,className:"sr-only"},"Recovery code"),B.createElement(V,{id:j,ref:F,className:"h-14",type:"text",autoComplete:"one-time-code","aria-label":"Recovery code","aria-invalid":!!a,"aria-describedby":a?Q:void 0,placeholder:"Enter a recovery code",value:i,onChange:R}),B.createElement(P,{className:"w-full",type:"submit",size:"lg",disabled:O},m?"Verifying...":"Submit")),B.createElement("div",{className:"flex justify-center"},B.createElement(P,{type:"button",variant:"link",className:"p-0 text-sm",onClick:s,disabled:O},"Use verification code instead")),a?B.createElement("p",{className:"text-sm font-medium text-destructive",id:Q,role:"alert"},a):null,f?B.createElement("p",{className:"text-sm font-medium text-orange-600",role:"alert"},f):null)}var re=6;function ge({token:e,scope:t,method:o,remove:r,signInHref:n="/mfa",onSuccess:s}){let[i,u]=v.useState(Array(re).fill("")),[a,c]=v.useState(e),[m,l]=v.useState(null),[b,p]=v.useState(null),[f,E]=v.useState(!1),[F,j]=v.useState(!1),Q=v.useId(),A=v.useRef([]),S=un(n,{fallback:"/mfa"});v.useEffect(()=>{F||A.current[0]?.focus()},[F]),v.useEffect(()=>{if(e){c(e);return}let x=$e();x?.token?c(x.token):c("")},[e]);let R=x=>w=>{let K=w.target.value.replace(/\D+/g,"");if(!K.length){ie(x,"");return}let J=K.at(-1)??"";ie(x,J),x<re-1&&A.current[x+1]?.focus()},O=x=>w=>{w.key==="Backspace"&&(i[x]?ie(x,""):x>0&&(A.current[x-1]?.focus(),ie(x-1,"")),w.preventDefault()),w.key==="ArrowLeft"&&x>0&&(A.current[x-1]?.focus(),w.preventDefault()),w.key==="ArrowRight"&&x<re-1&&(A.current[x+1]?.focus(),w.preventDefault())},k=x=>{x.preventDefault();let w=x.clipboardData.getData("text").replace(/\D+/g,"").slice(0,re).split("");if(!w.length)return;let K=[...i];for(let ke=0;ke<re;ke+=1)K[ke]=w[ke]??"";u(K);let J=Math.min(w.length,re-1);A.current[J]?.focus()},ie=(x,w)=>{u(K=>{let J=[...K];return J[x]=w,J}),l(null),p(null)},Ce=v.useMemo(()=>i.join(""),[i]),$=async x=>{if(x.preventDefault(),!a){l("Missing MFA challenge token. Please restart the sign-in flow.");return}if(Ce.length!==re){l("Enter the full 6-digit code to continue.");return}E(!0),l(null),p(null);try{let w=await ln({token:a,code:Ce,scope:t,method:o,remove:r});if(w?.ok)be(),s?.(w.scope??t);else if(w&&typeof w=="object"&&"url"in w&&typeof w.url=="string"){let K=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",J=new URL(w.url,K);l(J.searchParams.get("error")??"We ran into a problem verifying the code. Please try again.")}else l("We ran into a problem verifying the code. Please try again.")}catch{l("We ran into a problem verifying the code. Please try again.")}finally{E(!1)}},se=()=>{j(!1),u(Array(re).fill("")),l(null),p(null)},Ee=async()=>{F||(l(null),p(null),j(!0))};return v.createElement("div",{className:"space-y-6"},F?v.createElement(gt,{token:a,scope:t,method:o,remove:r,onSuccess:s,onCancel:se}):v.createElement("form",{className:"space-y-6",onSubmit:$},v.createElement("fieldset",{className:"flex flex-col gap-6",disabled:f||F},v.createElement("div",{className:"flex justify-center gap-3"},i.map((x,w)=>v.createElement(V,{key:w,ref:K=>{A.current[w]=K},className:d("h-14 w-12 rounded-lg border border-input/80 bg-muted/40 text-center text-2xl font-medium tracking-[0.25em]","placeholder:text-muted-foreground/80 focus-visible:ring-2 focus-visible:ring-primary/40"),inputMode:"numeric",type:"text",autoComplete:"one-time-code","aria-label":`Digit ${w+1}`,"aria-invalid":!!m,"aria-describedby":m?Q:void 0,pattern:"[0-9]*",maxLength:1,value:x,onChange:R(w),onKeyDown:O(w),onPaste:k}))),v.createElement(P,{className:"w-full",type:"submit",size:"lg",disabled:f},f?"Verifying...":"Submit")),m?v.createElement("div",{className:"flex flex-col gap-2"},v.createElement("p",{className:"text-sm font-medium text-destructive",id:Q,role:"alert"},"Error: ",m),v.createElement(P,{variant:"outline",asChild:!0},v.createElement("a",{href:S},"Back to sign in"))):null),m==="Invalid MFA code"?v.createElement(P,{variant:"link",asChild:!0},v.createElement("a",{href:S},"Return to sign in")):null,F?null:v.createElement("div",{className:"flex justify-center"},v.createElement(P,{type:"button",variant:"link",className:"p-0 text-sm",onClick:Ee,disabled:f||F},"Use a recovery code")),b?v.createElement("p",{className:"text-sm font-medium text-emerald-600",role:"status"},b):null)}function uo({setup:e,onError:t,onSuccess:o}){let r=ht.default?ht.default:ht;return ne.createElement("div",{className:"flex flex-col items-center gap-4 text-center"},e.otpauthUrl?ne.createElement(ne.Fragment,null,ne.createElement("div",{className:"rounded-md border border-border bg-background p-3"},ne.createElement(r,{value:e.otpauthUrl,size:192,className:"h-48 w-48"})),ne.createElement("p",{className:"text-sm text-muted-foreground"},"Scan the code with your authenticator app, then enter the 6-digit code below.")):null,e.recoveryKeys?ne.createElement(pt,{setup:e,onError:t,onSuccess:o}):null,ne.createElement(ge,{token:e.token,scope:e.scope,method:e.method,onSuccess:o}))}import yt from"react";function mo({setup:e,onSuccess:t}){return yt.createElement("div",{className:"flex w-full max-w-sm flex-col items-center gap-3 text-center"},yt.createElement("p",{className:"text-sm text-muted-foreground"},e.maskedEmail?`We sent a 6-digit code to ${e.maskedEmail}. Enter it below to finish.`:"Check your email for a 6-digit code and enter it below to finish."),yt.createElement(ge,{token:e.token,scope:e.scope,method:e.method,onSuccess:t}))}import bt from"react";function co({payload:e,message:t,isEnrolled:o,signInHref:r,onSuccess:n}){return bt.createElement("div",{className:"flex w-full max-w-sm flex-col items-center gap-3 text-center"},bt.createElement("p",{className:"text-sm text-muted-foreground"},t),bt.createElement(ge,{token:e.token,scope:e.scope,method:e.method,remove:o,signInHref:r,onSuccess:n}))}import y,{useCallback as Dn,useEffect as In,useState as vo}from"react";import{useMutation as En}from"@tanstack/react-query";import{ArrowLeftRight as kn,ChevronDown as Ln,Plus as yo}from"lucide-react";import{useForm as Bn}from"react-hook-form";import*as C from"react";import*as h from"@radix-ui/react-dropdown-menu";import{Check as mn,ChevronRight as cn,Circle as dn}from"lucide-react";var fo=h.Root,vt=C.forwardRef(({className:e,...t},o)=>C.createElement(h.Trigger,{ref:o,className:d("focus-visible:outline-hidden hover:bg-accent focus:bg-accent flex flex-row gap-2 items-center justify-between px-4 py-2 rounded-lg border data-disabled:pointer-events-none data-disabled:opacity-50",e),...t}));vt.displayName=h.Trigger.displayName;var fn=C.forwardRef(({className:e,inset:t,children:o,...r},n)=>C.createElement(h.SubTrigger,{ref:n,className:d("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r},o,C.createElement(cn,{className:"ml-auto"})));fn.displayName=h.SubTrigger.displayName;var pn=C.forwardRef(({className:e,...t},o)=>C.createElement(h.SubContent,{ref:o,className:d("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));pn.displayName=h.SubContent.displayName;var wt=C.forwardRef(({className:e,sideOffset:t=4,...o},r)=>C.createElement(h.Portal,null,C.createElement(h.Content,{ref:r,sideOffset:t,className:d("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})));wt.displayName=h.Content.displayName;var Ct=C.forwardRef(({className:e,inset:t,active:o,...r},n)=>C.createElement(h.Item,{ref:n,className:d("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",o&&"bg-accent text-accent-foreground",e),...r}));Ct.displayName=h.Item.displayName;var gn=C.forwardRef(({className:e,children:t,checked:o,...r},n)=>C.createElement(h.CheckboxItem,{ref:n,className:d("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),checked:o,...r},C.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},C.createElement(h.ItemIndicator,null,C.createElement(mn,{className:"h-4 w-4"}))),t));gn.displayName=h.CheckboxItem.displayName;var hn=C.forwardRef(({className:e,children:t,...o},r)=>C.createElement(h.RadioItem,{ref:r,className:d("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),...o},C.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},C.createElement(h.ItemIndicator,null,C.createElement(dn,{className:"h-2 w-2 fill-current"}))),t));hn.displayName=h.RadioItem.displayName;var yn=C.forwardRef(({className:e,inset:t,...o},r)=>C.createElement(h.Label,{ref:r,className:d("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...o}));yn.displayName=h.Label.displayName;var xt=C.forwardRef(({className:e,...t},o)=>C.createElement(h.Separator,{ref:o,className:d("-mx-1 my-1 h-px bg-muted",e),...t}));xt.displayName=h.Separator.displayName;var bn=({className:e,...t})=>C.createElement("span",{className:d("ml-auto text-xs tracking-widest opacity-60",e),...t});bn.displayName="DropdownMenuShortcut";import*as T from"react";import*as D from"@radix-ui/react-dialog";import{X as vn}from"lucide-react";var po=D.Root,go=D.Trigger,wn=D.Portal;var ho=T.forwardRef(({className:e,...t},o)=>T.createElement(D.Overlay,{ref:o,className:d("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ho.displayName=D.Overlay.displayName;var Pt=T.forwardRef(({className:e,children:t,...o},r)=>T.createElement(wn,null,T.createElement(ho,null),T.createElement(D.Content,{ref:r,className:d("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...o},t,T.createElement(D.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"},T.createElement(vn,{className:"h-4 w-4"}),T.createElement("span",{className:"sr-only"},"Close")))));Pt.displayName=D.Content.displayName;var St=({className:e,...t})=>T.createElement("div",{className:d("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});St.displayName="DialogHeader";var Cn=({className:e,...t})=>T.createElement("div",{className:d("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Cn.displayName="DialogFooter";var Mt=T.forwardRef(({className:e,...t},o)=>T.createElement(D.Title,{ref:o,className:d("text-lg font-semibold leading-none tracking-tight",e),...t}));Mt.displayName=D.Title.displayName;var Nt=T.forwardRef(({className:e,...t},o)=>T.createElement(D.Description,{ref:o,className:d("text-sm text-muted-foreground",e),...t}));Nt.displayName=D.Description.displayName;import xn,{useCallback as Pn,useEffect as Sn}from"react";import{useQuery as Mn}from"@tanstack/react-query";var Ft="nile.tenant-id";function De(e){let{disableQuery:t,tenants:o,baseUrl:r=""}=e,n=L(e.client);return Mn({queryKey:["tenants",r],queryFn:async()=>{let i=await he(e.fetchUrl??"/tenants",{headers:{"content-type":"application/json"}},e);if(!i.ok)throw new Error("Failed to fetch tenants");return i.json()},enabled:!t||o?.length===0,initialData:o},n)}function Ge(e){let[t,o]=xn.useState(e?.activeTenant??e?.tenant?.id),{refetch:r}=De({disableQuery:!0,...e});Sn(()=>{if(!t){let i=Nn(Ft);i?o(i):r()}},[r,t]);let{onTenantChange:n}=e??{},s=Pn(i=>{o(i),Fn(Ft,i),n&&n(i)},[n]);return[t,s]}var Nn=e=>{let t=document.cookie.split("; ");for(let o of t){let[r,n]=o.split("=");if(r===e)return n}return null},Fn=(e,t)=>{document.cookie=`${e}=${t}; path=/; samesite=lax`};function wo(e){let{client:t}=e??{};return y.createElement(U,{client:t},y.createElement(Tn,{...e}))}function Tn(e){let{data:t=e.tenants??[],isLoading:o,refetch:r}=De(e),{buttonText:n="Create an organization",emptyText:s="You are not part of an organization."}=e,[i,u]=Ge(e),[a,c]=vo(!1),m=t.find(l=>l.id===i);return In(()=>{!e.tenants?.length&&t?.length>0&&!m&&u(t[0].id)},[e.tenants?.length,t]),!o&&!i||!m?.name?y.createElement("div",{className:d("flex flex-col items-center gap-2",e.className)},y.createElement("p",null,s),y.createElement(bo,{...e,onSuccess:l=>{u(l.id),c(!1),r()},trigger:y.createElement(P,null,y.createElement(yo,{size:18})," ",n)})):y.createElement("div",null,y.createElement("div",{className:d(e.className)},y.createElement("div",{className:"text-sm pb-1.5 opacity-70 flex flex-row gap-1 items-center"},y.createElement(kn,{size:14}),"Switch organization"),y.createElement("div",{className:"flex flex-row w-full flex-1 items-center gap-1"},y.createElement(fo,{open:a,onOpenChange:c},y.createElement(vt,{className:"group w-80 font-medium text-sm",disabled:!m?.name,onClick:()=>{c(!0)}},m?.name??"Loading...",y.createElement(Ln,{className:"transition-transform duration-200 ease-in-out group-data-[state=open]:rotate-180"})),y.createElement(wt,{className:"flex flex-col gap-0.5 max-h-96 overflow-auto custom-scrollbar w-80"},t?.map(l=>y.createElement(Ct,{key:l.id,onClick:()=>u(l.id),active:l.id===m?.id},l.name)),y.createElement(xt,null),y.createElement(bo,{...e,onSuccess:l=>{c(!1),u(l.id),r()},trigger:y.createElement(P,{variant:"ghost",className:"self-center"},y.createElement(yo,{size:18})," Create new organization")}))))))}function bo(e){let[t,o]=vo(!1),{trigger:r,beforeMutate:n,onSuccess:s,onError:i}=e,u=L(e.client),a=Bn({defaultValues:{name:""}}),c=En({mutationFn:async l=>{let p=(n&&n(l))??l,f=await he(e?.fetchUrl??"/tenants",{method:"POST",body:JSON.stringify(p)},e);if(!f.ok)throw new Error("Failed to fetch tenants");return f.json()},onSuccess:async l=>{o(!1),s&&s(l)},onError:i},u),m=Dn(l=>{c.mutate(l)},[c]);return y.createElement(po,{open:t,onOpenChange:o},y.createElement(go,{asChild:!0},r),y.createElement(Pt,null,y.createElement(St,null,y.createElement(Mt,null,"Create an organization"),y.createElement(Nt,null,"An organization is a group of users.")),y.createElement(q,{...a},y.createElement("form",{onSubmit:a.handleSubmit(m)},y.createElement(ye,{control:a.control,name:"name",render:({field:l})=>y.createElement(Z,null,y.createElement(ee,null,"Name"),y.createElement(ae,null,y.createElement(V,{placeholder:"Organization name",...l,autoFocus:!0})),y.createElement(le,null,"This is the name of your organization."),y.createElement(ue,null))}),y.createElement(P,{type:"submit",className:"py-2",loading:c.isPending},"Submit")))))}import{BadgeCheck as Co,CalendarCheck as zn,CircleUserRound as Rn,Mail as An}from"lucide-react";import I,{useMemo as On}from"react";import{useQuery as Un}from"@tanstack/react-query";function _e(e){let{baseUrl:t="",fetchUrl:o,client:r,user:n,auth:s}=e??{},i=L(r),{data:u,isLoading:a}=Un({queryKey:["me",t],queryFn:async()=>await(await he(o??"/me",e)).json(),enabled:n==null},i);return n||u?n??u:s&&!(n&&a)?s.state?.session?.user??u:null}function xo(e){return I.createElement(U,{client:e.client},I.createElement(Hn,{...e}))}function Hn(e){let t=_e(e),o=I.useMemo(()=>t&&typeof t=="object"&&"picture"in t&&t.picture?I.createElement("img",{src:t.picture,alt:`${t.name} profile picture`,referrerPolicy:"no-referrer"}):e.profilePicturePlaceholder?e.profilePicturePlaceholder:I.createElement("div",{className:"drop-shadow-md",style:{background:"linear-gradient(90deg, #F4C587, #D6D3E9, #99D2EC)"}},I.createElement(Rn,{size:100,className:"opacity-70 stroke-black",style:{strokeWidth:".5px"}})),[t==null]),r=On(()=>{if(t?.name)return t?.name;let n="";return t?.givenName&&(n=t?.givenName),t?.familyName&&(n=`${n} ${t?.familyName}`),n},[t?.familyName,t?.givenName,t?.name]);return t?I.createElement("div",{className:d(e.className,"flex flex-col gap-2 items-center")},I.createElement("div",{className:"flex flex-col gap-5 pb-2 items-center"},I.createElement("div",{className:"flex flex-col gap-2 items-center w-36 mx-auto"},I.createElement("div",{className:"rounded-full border border-background overflow-hidden shadow-md"},o)),I.createElement("div",{className:"font-bold flex flex-row gap-1 capitalize"},r)),I.createElement("div",{className:"flex flex-row gap-5 justify-between w-full"},I.createElement("div",{className:"flex flex-row gap-2 text-sm items-center w-36"},I.createElement(An,{size:14}),"Email:"),I.createElement("div",{className:"flex flex-row gap-1 items-center"},t.emailVerified?I.createElement(Co,{className:"stroke-white fill-green-700",size:14}):I.createElement(Co,{className:"opacity-40",size:14}),t.email," ")),t.created?I.createElement("div",{className:"flex flex-row gap-5 justify-between w-full"},I.createElement("div",{className:"flex flex-row gap-2 text-sm items-center w-36"},I.createElement(zn,{size:14}),"Created:"),new Date(t.created).toLocaleString()):null):"Loading..."}import It from"react";import{useForm as qn}from"react-hook-form";import we from"react";import{useMutation as Po}from"@tanstack/react-query";import{resetPassword as Vn,forgotPassword as Qn}from"@niledatabase/client";function ve(e){let{auth:t,baseUrl:o="",beforeMutate:r,client:n,callbackUrl:s,fetchUrl:i,init:u,onError:a,onSuccess:c,redirect:m=!1,client:l}=e??{},b=L(n??l),p=Po({mutationFn:async f=>{let F=(r&&r(f))??f;return await Vn({auth:t,baseUrl:o,callbackUrl:s,fetchUrl:i,init:u,redirect:m,...F})},onSuccess:f=>{c&&c(f)},onError:a},b);return Be(e),p.mutate}function So(e){let{auth:t,baseUrl:o="",beforeMutate:r,callbackUrl:n,fetchUrl:s,init:i,client:u,onError:a,onSuccess:c,redirect:m=!1,client:l}=e??{},b=L(u??l),p=Po({mutationFn:async f=>{let F=(r&&r(f))??f;return await Qn({auth:t,baseUrl:o,callbackUrl:n,fetchUrl:s,init:i,redirect:m,...F})},onSuccess:f=>{c&&c(f)},onError:a},b);return Be(e),p.mutate}function Dt(e){return we.createElement(U,{client:e.client},we.createElement(Wn,{...e}))}function Wn(e){let{defaultValues:t,...o}=e,r=qn({defaultValues:{email:"",...t}}),n=ve({...o,redirect:!0});return we.createElement(q,{...r},we.createElement("form",{className:"py-2",onSubmit:r.handleSubmit(({email:s})=>{n({email:s})})},we.createElement(_,null),we.createElement(P,{type:"submit"},"Reset password")))}function Et(e){return It.createElement("div",{className:"flex flex-col gap-4"},It.createElement("h2",{className:"font-sans text-3xl"},"Request password reset"),It.createElement(Dt,{...e}))}import Ie from"react";import{useForm as jn}from"react-hook-form";import z,{useEffect as $n,useState as Kn}from"react";function kt(e){return z.createElement(U,{client:e.client},z.createElement(Gn,{...e}))}function Gn(e){let{defaultValues:t,...o}=e,r=jn({defaultValues:{email:"",password:"",confirmPassword:"",...t}}),n=So(o),s=ve(o),i=r.watch("password"),u=r.watch("confirmPassword"),[a,c]=Kn(!0);return $n(()=>{r.clearErrors(),!i||!u?c(!0):u&&i!==u?i!==u&&(r.setError("confirmPassword",{message:"Passwords must match."}),a||c(!0)):c(!1)},[i,u,a,r]),z.createElement(q,{...r},z.createElement("form",{onSubmit:r.handleSubmit(({email:m,password:l})=>{m?s({email:m,password:l}):n({password:l})}),className:"py-2"},t?.email?z.createElement(Z,null,z.createElement(ee,null,"Email address"),z.createElement(V,{value:t.email,disabled:!0})):null,z.createElement(me,null),z.createElement(ye,{control:r.control,name:"confirmPassword",render:({field:m})=>z.createElement(Z,null,z.createElement(ee,null,"Confirm password"),z.createElement(ae,null,z.createElement(V,{placeholder:"Password",...m,type:"password",autoComplete:"new-password"})),z.createElement(le,null,"Confirm your new password"),z.createElement(ue,null))}),z.createElement(P,{type:"submit",disabled:Object.keys(r.formState.errors).length>0||a},"Update password")))}function Lt(e){return Ie.createElement(U,{client:e.client},Ie.createElement(_n,{...e}))}function _n({className:e,...t}){return Ie.createElement("div",{className:d(e,"flex flex-col gap-4")},Ie.createElement("h2",{className:"font-sans text-3xl"},"Reset password"),Ie.createElement(kt,{...t}))}import{getSession as Gm,getCsrfToken as _m,getProviders as Xm,signIn as Ym,signOut as Jm,auth as Zm,Authorizer as ec}from"@niledatabase/client";export{ec as Authorizer,er as Azure,nr as Discord,_ as Email,et as EmailSignIn,Vt as EmailSignInButton,lr as GitHub,qt as Google,dr as HubSpot,hr as LinkedIn,uo as MultiFactorAuthenticator,co as MultiFactorChallenge,mo as MultiFactorEmail,Dr as Okta,me as Password,Lt as PasswordResetForm,Et as PasswordResetRequestForm,Se as SessionContext,Ne as SessionProvider,at as SignInForm,Vr as SignOutButton,nt as SignUpForm,Zt as SignedIn,eo as SignedOut,wr as Slack,wo as TenantSelector,xo as UserInfo,Sr as X,Zm as auth,be as clearMfaChallenge,_m as getCsrfToken,Xm as getProviders,Gm as getSession,$e as readMfaChallenge,Ym as signIn,Jm as signOut,je as storeMfaChallenge,Re as useEmailSignIn,_e as useMe,lo as useMultiFactor,ve as useResetPassword,Me as useSession,Qe as useSignIn,Ve as useSignUp,Ge as useTenantId,De as useTenants};
30
+ `,a=new Blob([i,r],{type:"text/plain"}),s=URL.createObjectURL(a),l=document.createElement("a");l.href=s,l.download="nile-mfa-recovery-codes.txt",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}catch{t("We were unable to download the recovery keys. Please try again.")}},children:[_(Ur,{className:"size-4","aria-hidden":"true"}),"Download"]}),o==="copied"?_("span",{className:"text-xs text-muted-foreground",children:"Recovery codes copied to clipboard."}):o==="error"?_("span",{className:"text-xs text-destructive",children:"Unable to copy automatically. Please copy the codes manually."}):null]})]})})}import*as z from"react";import{mfa as Qr,sanitizeRedirectUrl as qr}from"@niledatabase/client";import te,{useEffect as Hr}from"react";import{mfa as Vr}from"@niledatabase/client";import{jsx as ve,jsxs as Eo}from"react/jsx-runtime";function St({token:e,scope:t,method:o,remove:n,onSuccess:r,onCancel:i}){let[a,s]=te.useState(""),[l,u]=te.useState(null),[m,d]=te.useState(!1),[g,c]=te.useState(!1),[p,y]=te.useState(""),S=te.useRef(null),C=te.useId(),b=te.useId(),E=te.useRef(null);Hr(()=>(s(""),u(null),c(!1),d(!1),()=>{E.current&&(clearTimeout(E.current),E.current=null)}),[e]);let v=async N=>{if(N.preventDefault(),m||g)return;if(!e){u("Missing MFA challenge token. Please restart the sign-in flow.");return}let Y=a.trim();if(!Y.length){u("Enter your recovery code to continue.");return}d(!0),u(null);let ce=!1;try{let T=await Vr({token:e,code:Y,scope:t,method:o,remove:n});if(T?.ok){ce=!0,c(!0),xe();let Z=typeof T.recoveryCodesRemaining=="number"?T.recoveryCodesRemaining:null;y(Z!==null?`You have ${Z} recovery ${Z===1?"code":"codes"} remaining.`:"Recovery code verified."),E.current=setTimeout(()=>{r?.(T.scope??t)},2e3);return}if(T&&typeof T=="object"&&"url"in T){let Z=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",Oe=new URL(String(T.url),Z);u(Oe.searchParams.get("error")??"We couldn't verify that recovery code. Please try again.");return}u("We couldn't verify that recovery code. Please try again.")}catch{u("We ran into a problem verifying the code. Please try again.")}finally{ce||d(!1)}},P=N=>{s(N.target.value),l&&u(null)},I=m||g;return Eo("form",{className:"space-y-6",onSubmit:v,children:[Eo("fieldset",{className:"flex flex-col gap-6",disabled:I,children:[ve("label",{htmlFor:C,className:"sr-only",children:"Recovery code"}),ve(Q,{id:C,ref:S,className:"h-14",type:"text",autoComplete:"one-time-code","aria-label":"Recovery code","aria-invalid":!!l,"aria-describedby":l?b:void 0,placeholder:"Enter a recovery code",value:a,onChange:P}),ve(R,{className:"w-full",type:"submit",size:"lg",disabled:I,children:m?"Verifying...":"Submit"})]}),ve("div",{className:"flex justify-center",children:ve(R,{type:"button",variant:"link",className:"p-0 text-sm",onClick:i,disabled:I,children:"Use verification code instead"})}),l?ve("p",{className:"text-sm font-medium text-destructive",id:b,role:"alert",children:l}):null,p?ve("p",{className:"text-sm font-medium text-orange-600",role:"alert",children:p}):null]})}import{jsx as G,jsxs as Be}from"react/jsx-runtime";var se=6;function le({token:e,scope:t,method:o,remove:n,signInHref:r="/mfa",onSuccess:i}){let[a,s]=z.useState(Array(se).fill("")),[l,u]=z.useState(e),[m,d]=z.useState(null),[g,c]=z.useState(null),[p,y]=z.useState(!1),[S,C]=z.useState(!1),b=z.useId(),E=z.useRef([]),v=qr(r,{fallback:"/mfa"});z.useEffect(()=>{S||E.current[0]?.focus()},[S]),z.useEffect(()=>{if(e){u(e);return}let x=Je();x?.token?u(x.token):u("")},[e]);let P=x=>w=>{let $=w.target.value.replace(/\D+/g,"");if(!$.length){Y(x,"");return}let oe=$.at(-1)??"";Y(x,oe),x<se-1&&E.current[x+1]?.focus()},I=x=>w=>{w.key==="Backspace"&&(a[x]?Y(x,""):x>0&&(E.current[x-1]?.focus(),Y(x-1,"")),w.preventDefault()),w.key==="ArrowLeft"&&x>0&&(E.current[x-1]?.focus(),w.preventDefault()),w.key==="ArrowRight"&&x<se-1&&(E.current[x+1]?.focus(),w.preventDefault())},N=x=>{x.preventDefault();let w=x.clipboardData.getData("text").replace(/\D+/g,"").slice(0,se).split("");if(!w.length)return;let $=[...a];for(let Ae=0;Ae<se;Ae+=1)$[Ae]=w[Ae]??"";s($);let oe=Math.min(w.length,se-1);E.current[oe]?.focus()},Y=(x,w)=>{s($=>{let oe=[...$];return oe[x]=w,oe}),d(null),c(null)},ce=z.useMemo(()=>a.join(""),[a]),T=async x=>{if(x.preventDefault(),!l){d("Missing MFA challenge token. Please restart the sign-in flow.");return}if(ce.length!==se){d("Enter the full 6-digit code to continue.");return}y(!0),d(null),c(null);try{let w=await Qr({token:l,code:ce,scope:t,method:o,remove:n});if(w?.ok)xe(),i?.(w.scope??t);else if(w&&typeof w=="object"&&"url"in w&&typeof w.url=="string"){let $=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",oe=new URL(w.url,$);d(oe.searchParams.get("error")??"We ran into a problem verifying the code. Please try again.")}else d("We ran into a problem verifying the code. Please try again.")}catch{d("We ran into a problem verifying the code. Please try again.")}finally{y(!1)}},Z=()=>{C(!1),s(Array(se).fill("")),d(null),c(null)},Oe=async()=>{S||(d(null),c(null),C(!0))};return Be("div",{className:"space-y-6",children:[S?G(St,{token:l,scope:t,method:o,remove:n,onSuccess:i,onCancel:Z}):Be("form",{className:"space-y-6",onSubmit:T,children:[Be("fieldset",{className:"flex flex-col gap-6",disabled:p||S,children:[G("div",{className:"flex justify-center gap-3",children:a.map((x,w)=>G(Q,{ref:$=>{E.current[w]=$},className:f("h-14 w-12 rounded-lg border border-input/80 bg-muted/40 text-center text-2xl font-medium tracking-[0.25em]","placeholder:text-muted-foreground/80 focus-visible:ring-2 focus-visible:ring-primary/40"),inputMode:"numeric",type:"text",autoComplete:"one-time-code","aria-label":`Digit ${w+1}`,"aria-invalid":!!m,"aria-describedby":m?b:void 0,pattern:"[0-9]*",maxLength:1,value:x,onChange:P(w),onKeyDown:I(w),onPaste:N},w))}),G(R,{className:"w-full",type:"submit",size:"lg",disabled:p,children:p?"Verifying...":"Submit"})]}),m?Be("div",{className:"flex flex-col gap-2",children:[Be("p",{className:"text-sm font-medium text-destructive",id:b,role:"alert",children:["Error: ",m]}),G(R,{variant:"outline",asChild:!0,children:G("a",{href:v,children:"Back to sign in"})})]}):null]}),m==="Invalid MFA code"?G(R,{variant:"link",asChild:!0,children:G("a",{href:v,children:"Return to sign in"})}):null,S?null:G("div",{className:"flex justify-center",children:G(R,{type:"button",variant:"link",className:"p-0 text-sm",onClick:Oe,disabled:p||S,children:"Use a recovery code"})}),g?G("p",{className:"text-sm font-medium text-emerald-600",role:"status",children:g}):null]})}import{Fragment as Wr,jsx as Le,jsxs as Io}from"react/jsx-runtime";function ko({setup:e,onError:t,onSuccess:o}){let n=Pt.default?Pt.default:Pt;return Io("div",{className:"flex flex-col items-center gap-4 text-center",children:[e.otpauthUrl?Io(Wr,{children:[Le("div",{className:"rounded-md border border-border bg-background p-3",children:Le(n,{value:e.otpauthUrl,size:192,className:"h-48 w-48"})}),Le("p",{className:"text-sm text-muted-foreground",children:"Scan the code with your authenticator app, then enter the 6-digit code below."})]}):null,e.recoveryKeys?Le(wt,{setup:e,onError:t,onSuccess:o}):null,Le(le,{token:e.token,scope:e.scope,method:e.method,onSuccess:o})]})}import{jsx as Bo,jsxs as $r}from"react/jsx-runtime";function Lo({setup:e,onSuccess:t}){return $r("div",{className:"flex w-full max-w-sm flex-col items-center gap-3 text-center",children:[Bo("p",{className:"text-sm text-muted-foreground",children:e.maskedEmail?`We sent a 6-digit code to ${e.maskedEmail}. Enter it below to finish.`:"Check your email for a 6-digit code and enter it below to finish."}),Bo(le,{token:e.token,scope:e.scope,method:e.method,onSuccess:t})]})}import{jsx as To,jsxs as Kr}from"react/jsx-runtime";function Uo({payload:e,message:t,isEnrolled:o,signInHref:n,onSuccess:r}){return Kr("div",{className:"flex w-full max-w-sm flex-col items-center gap-3 text-center",children:[To("p",{className:"text-sm text-muted-foreground",children:t}),To(le,{token:e.token,scope:e.scope,method:e.method,remove:o,signInHref:n,onSuccess:r})]})}import{useCallback as Qo,useEffect as mi,useState as kt}from"react";import{useMutation as di}from"@tanstack/react-query";import{ArrowLeftRight as fi,ChevronDown as pi,Plus as qo}from"lucide-react";import{useForm as gi}from"react-hook-form";import*as X from"react";import*as h from"@radix-ui/react-dropdown-menu";import{Check as Gr,ChevronRight as _r,Circle as Xr}from"lucide-react";import{jsx as A,jsxs as Mt}from"react/jsx-runtime";var zo=h.Root,Ct=X.forwardRef(({className:e,...t},o)=>A(h.Trigger,{ref:o,className:f("focus-visible:outline-hidden hover:bg-accent focus:bg-accent flex flex-row gap-2 items-center justify-between px-4 py-2 rounded-lg border data-disabled:pointer-events-none data-disabled:opacity-50",e),...t}));Ct.displayName=h.Trigger.displayName;var Yr=X.forwardRef(({className:e,inset:t,children:o,...n},r)=>Mt(h.SubTrigger,{ref:r,className:f("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...n,children:[o,A(_r,{className:"ml-auto"})]}));Yr.displayName=h.SubTrigger.displayName;var Zr=X.forwardRef(({className:e,...t},o)=>A(h.SubContent,{ref:o,className:f("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));Zr.displayName=h.SubContent.displayName;var xt=X.forwardRef(({className:e,sideOffset:t=4,...o},n)=>A(h.Portal,{children:A(h.Content,{ref:n,sideOffset:t,className:f("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));xt.displayName=h.Content.displayName;var tt=X.forwardRef(({className:e,inset:t,active:o,...n},r)=>A(h.Item,{ref:r,className:f("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",o&&"bg-accent text-accent-foreground",e),...n}));tt.displayName=h.Item.displayName;var Jr=X.forwardRef(({className:e,children:t,checked:o,...n},r)=>Mt(h.CheckboxItem,{ref:r,className:f("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),checked:o,...n,children:[A("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:A(h.ItemIndicator,{children:A(Gr,{className:"h-4 w-4"})})}),t]}));Jr.displayName=h.CheckboxItem.displayName;var jr=X.forwardRef(({className:e,children:t,...o},n)=>Mt(h.RadioItem,{ref:n,className:f("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),...o,children:[A("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:A(h.ItemIndicator,{children:A(Xr,{className:"h-2 w-2 fill-current"})})}),t]}));jr.displayName=h.RadioItem.displayName;var ei=X.forwardRef(({className:e,inset:t,...o},n)=>A(h.Label,{ref:n,className:f("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...o}));ei.displayName=h.Label.displayName;var Rt=X.forwardRef(({className:e,...t},o)=>A(h.Separator,{ref:o,className:f("-mx-1 my-1 h-px bg-muted",e),...t}));Rt.displayName=h.Separator.displayName;var ti=({className:e,...t})=>A("span",{className:f("ml-auto text-xs tracking-widest opacity-60",e),...t});ti.displayName="DropdownMenuShortcut";import*as Te from"react";import*as k from"@radix-ui/react-dialog";import{X as oi}from"lucide-react";import{jsx as ue,jsxs as Nt}from"react/jsx-runtime";var Oo=k.Root,Ao=k.Trigger,ni=k.Portal;var Ho=Te.forwardRef(({className:e,...t},o)=>ue(k.Overlay,{ref:o,className:f("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Ho.displayName=k.Overlay.displayName;var Ft=Te.forwardRef(({className:e,children:t,...o},n)=>Nt(ni,{children:[ue(Ho,{}),Nt(k.Content,{ref:n,className:f("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...o,children:[t,Nt(k.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[ue(oi,{className:"h-4 w-4"}),ue("span",{className:"sr-only",children:"Close"})]})]})]}));Ft.displayName=k.Content.displayName;var Dt=({className:e,...t})=>ue("div",{className:f("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Dt.displayName="DialogHeader";var ri=({className:e,...t})=>ue("div",{className:f("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});ri.displayName="DialogFooter";var Et=Te.forwardRef(({className:e,...t},o)=>ue(k.Title,{ref:o,className:f("text-lg font-semibold leading-none tracking-tight",e),...t}));Et.displayName=k.Title.displayName;var It=Te.forwardRef(({className:e,...t},o)=>ue(k.Description,{ref:o,className:f("text-sm text-muted-foreground",e),...t}));It.displayName=k.Description.displayName;import ii,{useCallback as ai,useEffect as si}from"react";import{useQuery as li}from"@tanstack/react-query";var Vo="nile.tenant-id";function Ue(e){let{disableQuery:t,tenants:o,baseUrl:n="",basePath:r,auth:i,init:a}=e,s=B(e.client);return li({queryKey:["tenants",n,r,e.fetchUrl],queryFn:async()=>{let u=await Se(e.fetchUrl??"/tenants",{headers:{"content-type":"application/json"}},{auth:i,init:a,baseUrl:n,basePath:r,fetchUrl:e.fetchUrl});if(!u.ok)throw new Error("Failed to fetch tenants");return u.json()},enabled:t!==!0,initialData:o},s)}function ot(e){let t=e?.useCookie!==!1,[o,n]=ii.useState(e?.activeTenant??e?.tenant?.id),{refetch:r}=Ue({...e,disableQuery:!0});si(()=>{if(!o){let s=t?ui(Vo):null;s?n(s):!e?.disableQuery&&!e?.tenants?.length&&r()}},[r,o,t,e?.disableQuery,e?.tenants?.length]);let{onTenantChange:i}=e??{},a=ai(s=>{n(s),t&&ci(Vo,s),i?.(s)},[i,t]);return[o,a]}var ui=e=>{if(typeof document>"u")return null;let t=document.cookie.split(";");for(let o of t){let n=o.trim(),r=n.indexOf("=");if(r===-1)continue;if(n.slice(0,r).trim()===e){let a=n.slice(r+1);try{return decodeURIComponent(a)}catch{return a}}}return null},ci=(e,t)=>{if(typeof document>"u")return;let o=typeof window<"u"&&window.location?.protocol==="https:"?"; Secure":"";document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/; SameSite=Lax${o}`};import{jsx as M,jsxs as V}from"react/jsx-runtime";function $o(e){let{client:t}=e??{};return M(U,{client:t,children:M(hi,{...e})})}function hi(e){let{data:t=e.tenants??[],isLoading:o,refetch:n}=Ue(e),{buttonText:r="Create an organization",emptyText:i="You are not part of an organization."}=e,[a,s]=ot(e),[l,u]=kt(!1),[m,d]=kt(!1),g=t.find(c=>c.id===a);return mi(()=>{!e.tenants?.length&&t?.length>0&&!g&&s(t[0].id)},[e.tenants?.length,t]),!o&&t.length===0?V("div",{className:f("flex flex-col items-center gap-2",e.className),children:[M("p",{children:i}),M(Wo,{...e,onSuccess:c=>{s(c.id),u(!1),n()},trigger:V(R,{type:"button",children:[M(qo,{size:18})," ",r]})})]}):M("div",{children:V("div",{className:f(e.className),children:[V("div",{className:"text-sm pb-1.5 opacity-70 flex flex-row gap-1 items-center",children:[M(fi,{size:14}),"Switch organization"]}),V("div",{className:"flex flex-row w-full flex-1 items-center gap-1",children:[V(zo,{open:l,onOpenChange:u,children:[V(Ct,{className:"group w-80 font-medium text-sm",disabled:!g?.name,onClick:()=>{u(!0)},children:[g?.name??"Loading...",M(pi,{className:"transition-transform duration-200 ease-in-out group-data-[state=open]:rotate-180"})]}),V(xt,{className:"flex flex-col gap-0.5 max-h-96 overflow-auto custom-scrollbar w-80",children:[t?.map(c=>M(tt,{onClick:()=>s(c.id),active:c.id===g?.id,children:c.name},c.id)),M(Rt,{}),M(tt,{onSelect:c=>{c.preventDefault(),u(!1),d(!0)},children:V("span",{className:"flex items-center gap-1 mx-auto",children:[M(qo,{size:18})," Create new organization"]})})]})]}),M(Wo,{...e,open:m,onOpenChange:d,onSuccess:c=>{u(!1),d(!1),s(c.id),n()}})]})]})})}function Wo(e){let[t,o]=kt(!1),n=e.open!==void 0,r=n?e.open:t,{trigger:i,beforeMutate:a,onSuccess:s,onError:l,auth:u,init:m,baseUrl:d,basePath:g}=e,c=B(e.client),p=gi({defaultValues:{name:""}}),y=di({mutationFn:async b=>{let E={...b,name:b.name.trim()},P=(a&&a(E))??E,I=await Se(e?.fetchUrl??"/tenants",{method:"POST",body:JSON.stringify(P)},{auth:u,init:m,baseUrl:d,basePath:g,fetchUrl:e.fetchUrl});if(!I.ok){let N=await I.text().catch(()=>"");throw new Error(N||"Failed to create organization")}return I.json()},onSuccess:async b=>{p.reset({name:""}),n||o(!1),e.onOpenChange?.(!1),s?.(b)},onError:l},c),S=Qo(b=>{n||o(b),e.onOpenChange?.(b),b||(p.reset({name:""}),y.reset())},[p,n,y,e]),C=Qo(b=>{y.mutate(b)},[y]);return V(Oo,{open:r,onOpenChange:S,children:[i?M(Ao,{asChild:!0,children:i}):null,V(Ft,{children:[V(Dt,{children:[M(Et,{children:"Create an organization"}),M(It,{children:"An organization is a group of users."})]}),M(q,{...p,children:V("form",{onSubmit:p.handleSubmit(C),children:[M(me,{control:p.control,name:"name",rules:{validate:b=>b.trim().length>0||"Organization name is required."},render:({field:b})=>V(ne,{children:[M(re,{children:"Name"}),M(ie,{children:M(Q,{placeholder:"Organization name",...b,autoFocus:!0})}),M(de,{children:"This is the name of your organization."}),M(fe,{})]})}),y.error?M("p",{role:"alert",className:"text-sm text-destructive py-1",children:y.error instanceof Error?y.error.message:"Failed to create organization"}):null,M(R,{type:"submit",className:"py-2",loading:y.isPending,children:"Submit"})]})})]})]})}import{BadgeCheck as Ko,CalendarCheck as bi,CircleUserRound as vi,Mail as wi}from"lucide-react";import Si,{useMemo as Pi}from"react";import{useQuery as yi}from"@tanstack/react-query";function nt(e){let{baseUrl:t="",basePath:o,fetchUrl:n,client:r,user:i,auth:a,init:s}=e??{},l=B(r),{data:u,isLoading:m}=yi({queryKey:["me",t,o,n],queryFn:async()=>{let d=await Se(n??"/me",void 0,{auth:a,init:s,baseUrl:t,basePath:o,fetchUrl:n});if(!d.ok)throw new Error(`Failed to fetch user (${d.status})`);return await d.json()},enabled:i==null},l);return i||u?i??u??null:a&&!(i&&m)?a.state?.session?.user??u??null:null}import{jsx as W,jsxs as we}from"react/jsx-runtime";function Go(e){return W(U,{client:e.client,children:W(xi,{...e})})}function Ci(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(t)}function xi(e){let t=nt(e),o=Si.useMemo(()=>t&&typeof t=="object"&&"picture"in t&&t.picture?W("img",{src:t.picture,alt:`${t.name??t.email} profile picture`,referrerPolicy:"no-referrer"}):e.profilePicturePlaceholder?e.profilePicturePlaceholder:W("div",{className:"drop-shadow-md",style:{background:"linear-gradient(90deg, #F4C587, #D6D3E9, #99D2EC)"},children:W(vi,{size:100,className:"opacity-70 stroke-black",style:{strokeWidth:".5px"}})}),[t,e.profilePicturePlaceholder]),n=Pi(()=>{if(t?.name)return t?.name;let r="";return t?.givenName&&(r=t?.givenName),t?.familyName&&(r=`${r} ${t?.familyName}`),r},[t?.familyName,t?.givenName,t?.name]);return t?we("div",{className:f(e.className,"flex flex-col gap-2 items-center"),children:[we("div",{className:"flex flex-col gap-5 pb-2 items-center",children:[W("div",{className:"flex flex-col gap-2 items-center w-36 mx-auto",children:W("div",{className:"rounded-full border border-background overflow-hidden shadow-md",children:o})}),W("div",{className:"font-bold flex flex-row gap-1 capitalize",children:n})]}),we("div",{className:"flex flex-row gap-5 justify-between w-full",children:[we("div",{className:"flex flex-row gap-2 text-sm items-center w-36",children:[W(wi,{size:14}),"Email:"]}),we("div",{className:"flex flex-row gap-1 items-center",children:[t.emailVerified?W(Ko,{className:"stroke-white fill-green-700",size:14}):W(Ko,{className:"opacity-40",size:14}),t.email," "]})]}),t.created?we("div",{className:"flex flex-row gap-5 justify-between w-full",children:[we("div",{className:"flex flex-row gap-2 text-sm items-center w-36",children:[W(bi,{size:14}),"Created:"]}),Ci(t.created)]}):null]}):"Loading..."}import{useForm as Ni}from"react-hook-form";import{useMutation as _o}from"@tanstack/react-query";import{resetPassword as Ri,forgotPassword as Mi}from"@niledatabase/client";function ze(e){let{auth:t,baseUrl:o="",beforeMutate:n,client:r,callbackUrl:i,fetchUrl:a,init:s,onError:l,onSuccess:u,redirect:m=!1}=e??{},d=B(r),g=_o({mutationFn:async c=>{let y=(n&&n(c))??c;return await Ri({auth:t,baseUrl:o,callbackUrl:i,fetchUrl:a,init:s,redirect:m,...y})},onSuccess:c=>{u?.(c)},onError:l},d);return Ve(e),g}function Xo(e){return ze(e).mutate}function Yo(e){let{auth:t,baseUrl:o="",beforeMutate:n,callbackUrl:r,fetchUrl:i,init:a,client:s,onError:l,onSuccess:u,redirect:m=!1}=e??{},d=B(s),g=_o({mutationFn:async c=>{let y=(n&&n(c))??c;return await Mi({auth:t,baseUrl:o,callbackUrl:r,fetchUrl:i,init:a,redirect:m,...y})},onSuccess:c=>{u?.(c)},onError:l},d);return Ve(e),g}import{jsx as Re,jsxs as Di}from"react/jsx-runtime";function Bt(e){return Re(U,{client:e.client,children:Re(Fi,{...e})})}function Fi(e){let{defaultValues:t,buttonText:o="Reset password",...n}=e,r=Ni({defaultValues:{email:"",...t}}),i=ze({...n,redirect:!0});return Re(q,{...r,children:Di("form",{className:"py-2",onSubmit:r.handleSubmit(({email:a})=>{i.mutate({email:a})}),children:[Re(J,{}),!e.onError&&i.error?Re("p",{role:"alert",className:"text-sm font-medium text-destructive",children:i.error instanceof Error?i.error.message:"Password reset request failed"}):null,Re(R,{type:"submit",loading:i.isPending,children:o})]})})}import{jsx as Zo,jsxs as Ei}from"react/jsx-runtime";function Lt(e){return Ei("div",{className:"flex flex-col gap-4",children:[Zo("h2",{className:"font-sans text-3xl",children:"Request password reset"}),Zo(Bt,{...e})]})}import{useForm as Ii}from"react-hook-form";import{useEffect as ki,useState as Bi}from"react";import{jsx as O,jsxs as Tt}from"react/jsx-runtime";function Ut(e){return O(U,{client:e.client,children:O(Li,{...e})})}function Li(e){let{defaultValues:t,mode:o,buttonText:n="Update password",...r}=e,i=Ii({defaultValues:{email:"",password:"",confirmPassword:"",...t}}),a=Yo(r),s=ze(r),l=i.watch("password"),u=i.watch("confirmPassword"),[m,d]=Bi(!0),g=a.isPending||s.isPending,c=a.error||s.error;return ki(()=>{i.clearErrors(),!l||!u?d(!0):l!==u?(i.setError("confirmPassword",{message:"Passwords must match."}),d(!0)):d(!1)},[l,u,i]),O(q,{...i,children:Tt("form",{onSubmit:i.handleSubmit(({email:p,password:y})=>{o==="forgot"||!o&&!p?a.mutate({password:y}):s.mutate({email:p,password:y})}),className:"py-2",children:[t?.email?O(me,{control:i.control,name:"email",render:({field:p})=>Tt(ne,{children:[O(re,{children:"Email address"}),O(ie,{children:O(Q,{...p,disabled:!0})})]})}):null,O(pe,{autoComplete:"new-password"}),O(me,{control:i.control,name:"confirmPassword",render:({field:p})=>Tt(ne,{children:[O(re,{children:"Confirm password"}),O(ie,{children:O(Q,{placeholder:"Password",...p,type:"password",autoComplete:"new-password"})}),O(de,{children:"Confirm your new password"}),O(fe,{})]})}),!e.onError&&c?O("p",{role:"alert",className:"text-sm font-medium text-destructive",children:c instanceof Error?c.message:"Password update failed"}):null,O(R,{type:"submit",loading:g,disabled:Object.keys(i.formState.errors).length>0||m,children:n})]})})}import{jsx as rt,jsxs as Ui}from"react/jsx-runtime";function zt(e){return rt(U,{client:e.client,children:rt(Ti,{...e})})}function Ti({className:e,...t}){return Ui("div",{className:f(e,"flex flex-col gap-4"),children:[rt("h2",{className:"font-sans text-3xl",children:"Reset password"}),rt(Ut,{...t})]})}import{getSession as Im,getCsrfToken as km,getProviders as Bm,signIn as Lm,signOut as Tm,auth as Um,Authorizer as zm}from"@niledatabase/client";export{zm as Authorizer,Un as Azure,An as Discord,J as Email,ut as EmailSignIn,eo as EmailSignInButton,Vn as GitHub,oo as Google,qn as HubSpot,$n as LinkedIn,ko as MultiFactorAuthenticator,Uo as MultiFactorChallenge,Lo as MultiFactorEmail,le as MultiFactorVerify,jn as Okta,pe as Password,zt as PasswordResetForm,Lt as PasswordResetRequestForm,De as SessionContext,Ie as SessionProvider,pt as SignInForm,br as SignOutButton,dt as SignUpForm,wo as SignedIn,So as SignedOut,_n as Slack,$o as TenantSelector,Go as UserInfo,Zn as X,Um as auth,xe as clearMfaChallenge,km as getCsrfToken,Bm as getProviders,Im as getSession,Je as readMfaChallenge,Lm as signIn,Tm as signOut,Ze as storeMfaChallenge,Yt as useEmailSignIn,nt as useMe,Do as useMultiFactor,Xo as useResetPassword,Ee as useSession,_e as useSignIn,Ge as useSignUp,ot as useTenantId,Ue as useTenants};
31
31
  //# sourceMappingURL=index.mjs.map