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

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 se from"react";import{useForm as Zo}from"react-hook-form";import{Mail as Jo}from"lucide-react";import*as y from"react";import{Slot as qo}from"@radix-ui/react-slot";import{Controller as jo,FormProvider as Wo,useFormContext as tt}from"react-hook-form";import{useQuery as Rt}from"@tanstack/react-query";import{clsx as zo}from"clsx";import{twMerge as Oo}from"tailwind-merge";import{auth as Te}from"@niledatabase/client";import Ze,{useContext as zt,useRef as Lo,useState as To}from"react";import{QueryClient as Ut,QueryClientContext as Ot,QueryClientProvider as Uo}from"@tanstack/react-query";function z(e){let t=zt(Ot),[o]=To(()=>e||t?null:new Ut),r=Lo(null);return e||t||o||(r.current||(r.current=new Ut),r.current)}function Q({client:e,children:t}){let o=zt(Ot),r=z(e);return!e&&o?Ze.createElement(Ze.Fragment,null,t):Ze.createElement(Uo,{client:r},t)}function f(...e){return Oo(zo(e))}function Ro(...e){let t=new Headers;for(let o of e)o&&new Headers(o).forEach((r,n)=>{t.set(n,r)});return t}function we(e,t={},o){let r,n,i={};if(t&&typeof t=="object"){let u=t;"init"in u&&u.init&&typeof u.init=="object"&&(r=u.init),"auth"in u&&u.auth&&typeof u.auth=="object"&&(n=u.auth);let c=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))!c.has(d)&&g!==void 0&&(i[d]=g)}let s={...o?.auth?.requestInit??{},...o?.init??{},...n?.requestInit??{},...r??{},...i,headers:Ro({"content-type":"application/json; charset=UTF-8"},o?.auth?.requestInit?.headers,o?.init?.headers,n?.requestInit?.headers,r?.headers,i.headers)},a=e;if(!(!!o?.fetchUrl||!!(t&&typeof t=="object"&&"fetchUrl"in t&&t.fetchUrl))&&e.startsWith("/")){let u=n??o?.auth,c=Ho(o,t,u);a=`${Ao(o,t,u)}${c}${e}`}return fetch(a,s)}var Ao=(e,t={},o)=>e?.baseUrl?e.baseUrl:"baseUrl"in t&&t.baseUrl?t.baseUrl:o?.state?.baseUrl?o.state.baseUrl:Te.state.baseUrl?Te.state.baseUrl:"",Ho=(e,t={},o)=>e?.basePath?e.basePath:"basePath"in t&&t.basePath?t.basePath:o?.state?.basePath?o.state.basePath:Te.state.basePath?Te.state.basePath:"";function At(e){let{baseUrl:t="",basePath:o="/api",disableQuery:r,init:n,client:i,providersUrl:s,csrfUrl:a}=e??{},l=z(i);Rt({queryKey:["providers",t,o,s],queryFn:async()=>{let u=await fetch(s??`${t}${o}/auth/providers`,n);if(!u.ok)throw new Error(`Failed to fetch providers (${u.status})`);return await u.json()},enabled:r!==!0},l),Ue({baseUrl:t,basePath:o,disableQuery:r,init:n,client:i,csrfUrl:a})}function Ue(e){let{baseUrl:t="",basePath:o="/api",disableQuery:r,init:n,client:i,csrfUrl:s}=e??{},a=z(i);Rt({queryKey:["csrf",t,o,s],queryFn:async()=>{let l=await fetch(s??`${t}${o}/auth/csrf`,n);if(!l.ok)throw new Error(`Failed to fetch CSRF token (${l.status})`);return await l.json()},enabled:r!==!0},a)}import*as ze from"react";import*as Je from"@radix-ui/react-label";import{cva as Vo}from"class-variance-authority";var Qo=Vo("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),et=ze.forwardRef(({className:e,...t},o)=>ze.createElement(Je.Root,{ref:o,className:f(Qo(),e),...t}));et.displayName=Je.Root.displayName;import*as Oe from"react";var j=Oe.forwardRef(({className:e,type:t,...o},r)=>Oe.createElement("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:r,...o}));j.displayName="Input";var W=Wo,Ht=y.createContext({}),ge=({...e})=>y.createElement(Ht.Provider,{value:{name:e.name}},y.createElement(jo,{...e})),Re=()=>{let e=y.useContext(Ht),t=y.useContext(Vt),{getFieldState:o,formState:r}=tt(),n=o(e.name,r);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`,...n}},Vt=y.createContext({}),oe=y.forwardRef(({className:e,...t},o)=>{let r=y.useId();return y.createElement(Vt.Provider,{value:{id:r}},y.createElement("div",{ref:o,className:f("py-2",e),...t}))});oe.displayName="FormItem";var re=y.forwardRef(({className:e,...t},o)=>{let{error:r,formItemId:n}=Re();return y.createElement(et,{ref:o,className:f(r&&"text-destructive",e),htmlFor:n,...t})});re.displayName="FormLabel";var ne=y.forwardRef(({...e},t)=>{let{error:o,formItemId:r,formDescriptionId:n,formMessageId:i}=Re();return y.createElement(qo,{ref:t,id:r,"aria-describedby":o?`${n} ${i}`:`${n}`,"aria-invalid":!!o,...e})});ne.displayName="FormControl";var he=y.forwardRef(({className:e,...t},o)=>{let{formDescriptionId:r}=Re();return y.createElement("p",{ref:o,id:r,className:f("text-sm text-muted-foreground",e),...t})});he.displayName="FormDescription";var ye=y.forwardRef(({className:e,children:t,...o},r)=>{let{error:n,formMessageId:i}=Re(),s=n?String(n?.message):t;return s?y.createElement("p",{ref:r,id:i,className:f("text-sm font-medium text-destructive",e),...o},s):null});ye.displayName="FormMessage";var Z=({hide:e})=>{let t=tt();return y.createElement(ge,{control:t.control,name:"email",render:({field:o})=>e?y.createElement("input",{type:"hidden",...o}):y.createElement(oe,null,y.createElement(re,null,"Email"),y.createElement(ne,null,y.createElement(j,{placeholder:"Email",...o,type:"email","aria-label":o.name,autoComplete:"email",required:!0})),y.createElement(he,null,"Your email address"),y.createElement(ye,null))})},be=({autoComplete:e="current-password"}={})=>{let t=tt();return y.createElement(ge,{control:t.control,name:"password",render:({field:o})=>y.createElement(oe,null,y.createElement(re,null,"Password"),y.createElement(ne,null,y.createElement(j,{placeholder:"Password",...o,type:"password","aria-label":o.name,autoComplete:e,required:!0})),y.createElement(he,null,"The desired password"),y.createElement(ye,null))})};import*as J from"react";import{Slottable as $o,Slot as Ko}from"@radix-ui/react-slot";import{cva as Go}from"class-variance-authority";import{Loader2 as _o}from"lucide-react";var ie=Go("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"}}),E=J.forwardRef(({asChild:e=!1,children:t,className:o,disabled:r,loading:n,size:i,variant:s,...a},l)=>J.createElement(e?Ko:"button",{className:f(ie({variant:s,size:i,className:o})),ref:l,disabled:n||r,...a},J.createElement($o,null,n?J.createElement("div",{className:"relative flex items-center justify-center"},J.createElement("div",{className:"absolute"},J.createElement(_o,{className:"animate-spin"})),J.createElement("span",{className:"opacity-0"},t)):t)));E.displayName="Button";import{useMutation as Xo}from"@tanstack/react-query";import{signIn as Yo}from"@niledatabase/client";function ot(e){let{onSuccess:t,onError:o,beforeMutate:r,callbackUrl:n,redirect:i=!1,init:s,client:a}=e??{},l=z(a);return Xo({mutationFn:async u=>{let c={...u,callbackUrl:n,redirect:i},g=(r&&r(c))??c,m=await Yo("email",{init:s,...g});if(i===!1&&!m||m&&(!m.ok||m.error))throw new Error(m?.error??"Email sign in failed");return m},onSuccess:t,onError:o},l)}function Qt(e){return ot(e).mutate}function rt(e){let{client:t}=e??{};return se.createElement(Q,{client:t},se.createElement(er,{...e}))}function er(e){let t=ot(e),o=Zo({defaultValues:{email:""}});return se.createElement(W,{...o},se.createElement("form",{onSubmit:o.handleSubmit(({email:r})=>t.mutate({email:r})),className:"space-y-8"},se.createElement(Z,null),!e.onError&&t.error?se.createElement("p",{role:"alert",className:"text-sm font-medium text-destructive"},t.error instanceof Error?t.error.message:"Email sign in failed"):null,se.createElement(E,{type:"submit",className:"flex flex-row gap-2",loading:t.isPending},se.createElement(Jo,{"aria-hidden":"true"}),e.buttonText??"Sign in with email")))}import{Slot as tr}from"@radix-ui/react-slot";import nt from"react";import{Mail as or}from"lucide-react";import{signIn as rr}from"@niledatabase/client";var qt=({callbackUrl:e,className:t,variant:o,size:r,asChild:n=!1,redirect:i=!1,buttonText:s="Continue with Email",email:a,onFailure:l,onSent:u,fetchUrl:c,baseUrl:d,auth:g,init:m,loading:p,type:v="button",onClick:M,children:F,...x})=>nt.createElement(n?tr:"button",{...x,...n?{}:{type:v},className:f(ie({variant:o,size:r,className:t})),"data-slot":"email-signin-button",onClick:async S=>{let N=await rr("email",{email:a,callbackUrl:e,redirect:i,fetchUrl:c,baseUrl:d,auth:g,init:m});M?.(S,N),i===!1&&!N||N&&(!N.ok||N.error)?l?.(N):u?.()}},F||nt.createElement("div",{className:"flex flex-row gap-2 items-center"},nt.createElement(or,{"aria-hidden":"true"}),s));qt.displayName="EmailSignInButton";var jt=qt;import G from"react";import _ from"react";import{Slot as nr,Slottable as ir}from"@radix-ui/react-slot";import{Loader2 as sr}from"lucide-react";import{signIn as ar}from"@niledatabase/client";function R({provider:e,dataSlot:t,defaultButtonText:o,providerClassName:r,icon:n,renderDefaultContent:i,callbackUrl:s,className:a,buttonText:l=o,variant:u,size:c,init:d,auth:g,fetchUrl:m,baseUrl:p,onClick:v,asChild:M=!1,loading:F=!1,disabled:x,type:B="button",children:S,...N}){let L=M&&_.isValidElement(S),I=async H=>{if(F||x){H.preventDefault();return}let Y=await ar(e,{callbackUrl:s,init:d,auth:g,fetchUrl:m,baseUrl:p});v?.(H,Y)},X=i?i(l,n):_.createElement(_.Fragment,null,n,l),pe=()=>{let H=S??X;return F?_.createElement("span",{className:"relative inline-flex items-center justify-center"},_.createElement("span",{className:"absolute"},_.createElement(sr,{className:"animate-spin","aria-hidden":"true"})),_.createElement("span",{className:"opacity-0 inline-flex items-center gap-4"},H)):H};return L?_.createElement(nr,{...N,"aria-disabled":F||x||void 0,"data-slot":t,className:f(ie({variant:u,size:c,className:a}),r),onClick:I},n,_.createElement(ir,null,S)):_.createElement("button",{...N,type:B,disabled:F||x,"data-slot":t,className:f(ie({variant:u,size:c,className:a}),r),onClick:I},pe())}var Wt=e=>G.createElement(R,{provider:"google",dataSlot:"google-button",defaultButtonText:"Continue with Google",providerClassName:"bg-[#4285f4] hover:bg-[#4285f4] hover:bg-opacity-85 pl-[3px] text-white",icon:G.createElement(lr,null),renderDefaultContent:(t,o)=>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"}},o),t),...e});Wt.displayName="GoogleSSOButton";var $t=Wt;function lr(){return G.createElement("svg",{"aria-hidden":"true",focusable:"false",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 ae from"react";var Kt=e=>ae.createElement(R,{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:ae.createElement(mr,null),...e});Kt.displayName="AzureSignInButton";var ur=Kt,mr=()=>ae.createElement("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"},ae.createElement("path",{fill:"#f3f3f3",d:"M0 0h23v23H0z"}),ae.createElement("path",{fill:"#f35325",d:"M1 1h10v10H1z"}),ae.createElement("path",{fill:"#81bc06",d:"M12 1h10v10H12z"}),ae.createElement("path",{fill:"#05a6f0",d:"M1 12h10v10H1z"}),ae.createElement("path",{fill:"#ffba08",d:"M12 12h10v10H12z"}));import xe from"react";var Gt=e=>xe.createElement(R,{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:xe.createElement(dr,null),...e});Gt.displayName="DiscordSignInButton";var cr=Gt,dr=()=>xe.createElement("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"},xe.createElement("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd"},xe.createElement("g",{id:"discord-icon",transform:"translate(2.000000, 2.411745)",fillRule:"nonzero",stroke:"#636262",strokeWidth:"0"},xe.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";var _t=e=>Ae.createElement(R,{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:Ae.createElement(pr,null),...e});_t.displayName="GitHubSignInButton";var fr=_t,pr=()=>Ae.createElement("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"},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 He from"react";var Xt=e=>He.createElement(R,{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:He.createElement(hr,null),...e});Xt.displayName="HubSpotSignInButton";var gr=Xt,hr=()=>He.createElement("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"},He.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 Pe from"react";var Yt=e=>Pe.createElement(R,{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:Pe.createElement(br,null),...e});Yt.displayName="LinkedInSignInButton";var yr=Yt,br=()=>Pe.createElement("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"},Pe.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"}),Pe.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 le from"react";var Zt=e=>le.createElement(R,{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:le.createElement(wr,null),...e});Zt.displayName="SlackSignInButton";var vr=Zt,wr=()=>le.createElement("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"},le.createElement("g",{clipRule:"evenodd",fillRule:"evenodd"},le.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"}),le.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"}),le.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"}),le.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 Ve from"react";var Jt=e=>Ve.createElement(R,{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:Ve.createElement(Sr,null),...e});Jt.displayName="XSignInButton";var xr=Jt,Sr=()=>Ve.createElement("svg",{"aria-hidden":"true",focusable:"false",className:"w-5 h-5 ml-3",viewBox:"0 0 24 24",version:"1.1"},Ve.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 Ce from"react";var eo=e=>Ce.createElement(R,{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:Ce.createElement(Cr,null),...e});eo.displayName="OktaSignInButton";var Pr=eo,Cr=()=>Ce.createElement("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"},Ce.createElement("g",null,Ce.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
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 st from"react";import ue,{useState as to}from"react";import{useForm as Dr}from"react-hook-form";import{useMutation as Mr}from"@tanstack/react-query";import{signUp as Nr}from"@niledatabase/client";function Fr(e={},t){let{onSuccess:o,onError:r,beforeMutate:n,client:i,...s}=e??{},a=z(t??i),l=Mr({mutationFn:async u=>{let c=n&&n(u),d={...u,...c},g=await Nr({...s,...d});if(!g)return;let{data:m,error:p}=g;if(p)throw new Error(p);return m},onSuccess:o,onError:r},a);return At(e),l}function Qe(e={},t){return Fr(e,t).mutate}function it(e){let{client:t}=e??{};return ue.createElement(Q,{client:t},ue.createElement(Er,{...e}))}function Er(e){let[t,o]=to(!1),[r,n]=to(null),i=Qe({...e,onSuccess:(a,l)=>{o(!1),n(null),e.onSuccess?.(a,l)},onError:(a,l)=>{o(!1),n(a instanceof Error?a.message:"Sign up failed"),e.onError?.(a,l)}}),s=Dr({defaultValues:{email:"",password:""}});return ue.createElement(W,{...s},ue.createElement("form",{onSubmit:s.handleSubmit(({email:a,password:l})=>{o(!0),n(null),i?.({email:a,password:l})}),className:"space-y-8"},ue.createElement(Z,null),ue.createElement(be,{autoComplete:"new-password"}),!e.onError&&r?ue.createElement("p",{role:"alert",className:"text-sm font-medium text-destructive"},r):null,ue.createElement(E,{type:"submit",loading:t},e.buttonText??"Sign up")))}function at({className:e,...t}){return st.createElement("div",{className:f(e,"flex flex-col gap-4")},st.createElement("h2",{className:"font-sans text-3xl"},"Sign up"),st.createElement(it,{...t}))}import ut from"react";import me,{useState as oo}from"react";import{useForm as Lr}from"react-hook-form";import{useMutation as Ir}from"@tanstack/react-query";import{signIn as kr}from"@niledatabase/client";function Br(e){let{onSuccess:t,onError:o,beforeMutate:r,callbackUrl:n,init:i,baseUrl:s,fetchUrl:a,resetUrl:l,auth:u,redirect:c,client:d}=e??{},g=z(d);return Ir({mutationFn:async m=>{let p={...m,callbackUrl:n},M=(r&&r(p))??p,F=await kr(M.provider,{init:i,auth:u,baseUrl:s,fetchUrl:a,redirect:c,resetUrl:l,...M});if(c===!1&&!F)throw new Error("Sign in failed");if(F&&(!F.ok||F.error))throw new Error(F.error??"Sign in failed");return F},onSuccess:t,onError:o},g)}function qe(e){return Br(e).mutate}function lt(e){let{client:t}=e??{};return me.createElement(Q,{client:t},me.createElement(Tr,{...e}))}function Tr(e){let[t,o]=oo(!1),[r,n]=oo(null),i=qe({...e,onSuccess:(...a)=>{o(!1),n(null),e.onSuccess?.(...a)},onError:(a,l)=>{o(!1),n(a instanceof Error?a.message:"Sign in failed"),e.onError?.(a,l)}}),s=Lr({defaultValues:{email:"",password:""}});return me.createElement(W,{...s},me.createElement("form",{onSubmit:s.handleSubmit(({email:a,password:l})=>{o(!0),n(null),i?.({provider:"credentials",email:a,password:l})}),className:"space-y-8"},me.createElement(Z,null),me.createElement(be,{autoComplete:"current-password"}),!e.onError&&r?me.createElement("p",{role:"alert",className:"text-sm font-medium text-destructive"},r):null,me.createElement(E,{type:"submit",loading:t},e.buttonText??"Sign In")))}function mt({className:e,...t}){return ut.createElement("div",{className:f(e,"flex flex-col gap-4")},ut.createElement("h2",{className:"font-sans text-3xl"},"Sign In"),ut.createElement(lt,{...t}))}import ct from"react";import{Slot as Ur}from"@radix-ui/react-slot";import{LogOut as zr}from"lucide-react";import{signOut as Or}from"@niledatabase/client";var ro=({callbackUrl:e,redirect:t,className:o,buttonText:r="Sign out",variant:n,size:i,baseUrl:s,fetchUrl:a,basePath:l,auth:u,init:c,loading:d,type:g="button",asChild:m=!1,onClick:p,children:v,...M})=>ct.createElement(m?Ur:"button",{...M,...m?{}:{type:g},"data-slot":"signout-button",className:ie({variant:n,size:i,className:o}),onClick:x=>{Or({callbackUrl:e,redirect:t,baseUrl:s,auth:u,fetchUrl:a,basePath:l,init:c}),p?.(x)}},v||ct.createElement("div",{className:"flex flex-row gap-2 items-center"},ct.createElement(zr,{"aria-hidden":"true"}),r));ro.displayName="SignOutButton";var Rr=ro;import ft,{useMemo as Kr}from"react";import $ from"react";import{auth as k,getStatus as Ar,broadcast as Hr}from"@niledatabase/client";function Vr(){let[e,t]=$.useState(!0);return $.useEffect(()=>{typeof navigator<"u"&&typeof navigator.onLine=="boolean"&&t(navigator.onLine);let o=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",o),window.addEventListener("offline",r),()=>{window.removeEventListener("online",o),window.removeEventListener("offline",r)}},[]),e}var dt=()=>({basePath:k.state.basePath,baseUrl:k.state.baseUrl,lastSync:k.state.lastSync,getSession:k.state.getSession,session:k.state.session,loading:k.state.loading}),Qr=Object.freeze({basePath:k.state.basePath,baseUrl:k.state.baseUrl,lastSync:0,getSession:()=>{},session:void 0,loading:!0}),ee=dt(),qr=e=>{let t=()=>{ee=dt(),e()};return k.addListener(t),()=>k.removeListener(t)},jr=()=>{let e=k.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=dt()),ee},Wr=()=>Qr;function $r(){return $.useSyncExternalStore(qr,jr,Wr)}var Me=$.createContext?.(void 0);function Ne(e){if(!Me)throw new Error("React Context is unavailable in Server Components");let t=$.useContext(Me);if(!t)throw new Error("useSession must be wrapped in a <SessionProvider />");let{required:o,onUnauthenticated:r}=e??{},n=o&&t.status==="unauthenticated",i=t.state?.basePath||k.state.basePath||"/api";return $.useEffect(()=>{if(n&&typeof window<"u"){let s=`${i}/auth/signin?${new URLSearchParams({error:"SessionRequired",callbackUrl:window.location.href})}`;r?r():window.location.href=s}},[n,r,i]),n?{data:t.data,update:t.update,status:"loading",state:t.state}:t}function no(e){return typeof Response<"u"&&e instanceof Response}function Fe(e){if(!Me)throw new Error("React Context is unavailable in Server Components");let{children:t,refetchWhenOffline:o,refetchInterval:r,refetchOnWindowFocus:n=!0}=e,i=$r(),s=e.session!==void 0&&!no(e.session)?e.session:void 0,a=i.session===void 0?s??null:i.session??null;$.useEffect(()=>{(e.basePath||e.baseUrl)&&k.configure({basePath:e.basePath,baseUrl:e.baseUrl}),e.session!==void 0&&!no(e.session)?k.initialize({baseUrl:e.baseUrl,session:e.session}):k.status||k.getSession({baseUrl:e.baseUrl})},[e.basePath,e.baseUrl,e.session]);let l=Vr(),u=o!==!1||l,c=$.useCallback(()=>{document.visibilityState==="visible"&&k.sync("visibilitychange")},[]);$.useEffect(()=>{if(r&&u){let p=setInterval(()=>{k.state.session&&k.getSession({event:"poll"})},r*1e3);return()=>clearInterval(p)}},[r,u]),$.useEffect(()=>{n?document.addEventListener("visibilitychange",c,!1):document.removeEventListener("visibilitychange",c);let p=Hr.receive(()=>k.sync("storage"));return()=>{p(),document.removeEventListener("visibilitychange",c,!1)}},[n,c]);let d=i.session===void 0&&s!==void 0?!1:i.loading,g=Ar(d,a),m=$.useMemo(()=>({data:a??null,status:g,state:i,async update(){return await k.refreshSession()}}),[a,i,g]);return $.createElement(Me.Provider,{value:m},t)}function pt(e){return e&&"exp"in e?{...e,expires:new Date(e.exp*1e3).toISOString()}:e}function io({children:e,session:t,...o}){let r=typeof Response<"u"&&t instanceof Response,n=Kr(()=>r?null:pt(t),[r,t]);return r?null:ft.createElement(Fe,{...o,session:n},ft.createElement(Gr,{className:o.className},e))}function Gr({children:e,className:t}){let{status:o}=Ne();return o==="authenticated"?t?ft.createElement("div",{className:t},e):e:null}import gt,{useMemo as _r}from"react";function so({children:e,session:t,...o}){let r=_r(()=>typeof Response<"u"&&t instanceof Response?t.ok?void 0:null:pt(t),[t]);return gt.createElement(Fe,{...o,session:r},gt.createElement(Xr,{className:o.className},e))}function Xr({className:e,children:t}){let{status:o}=Ne();return o==="unauthenticated"?e?gt.createElement("div",{className:e},t):t:null}import{mfa as mo,sanitizeRedirectUrl as co}from"@niledatabase/client";import{useState as De,useEffect as Zr,useCallback as Ge}from"react";var je=e=>typeof e=="object"&&e!==null,ao=e=>e==="setup"||e==="challenge",Yr=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},lo=e=>!je(e)||e.method!=="authenticator"||!ao(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:Yr(e.recoveryKeys)},uo=e=>!je(e)||e.method!=="email"||!ao(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 $e(e){if(!(typeof window>"u"))try{window.sessionStorage.setItem(We,JSON.stringify(e))}catch{}}function Ke(){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 Se(){if(!(typeof window>"u"))try{window.sessionStorage.removeItem(We)}catch{}}var fo="/mfa/prompt",go=({method:e,currentMethod:t,promptPath:o=fo,onRedirect:r,onChallengeRedirect:n})=>{let[i,s]=De(null),[a,l]=De(null),[u,c]=De(null),[d,g]=De(!1),[m,p]=De(!1),v=e==="authenticator"?lo:uo,M=Ge(S=>{let N=co(S);if(r){r(N);return}typeof window<"u"&&window.location.assign(N)},[r]),F=Ge(S=>{if(n){n(S);return}$e(S);let N=new URLSearchParams({method:S.method,scope:S.scope});S.destination&&N.set("destination",S.destination);let L=co(o,{fallback:fo}),I=L.includes("?")?"&":"?";M(`${L}${I}${N.toString()}`)},[M,n,o]),x=Ge(async()=>{g(!0),l(null),c(null);try{let S=await mo({scope:"setup",method:e}),N=po(S);if(N){s(null),l("setup"),c(N);return}let L=ht(S);if(L){M(L);return}let I=v(S);if(!I){s(null),l("parseSetup");return}if(I.scope==="challenge"){F({token:I.token,method:I.method,scope:I.scope,destination:"maskedEmail"in I?I.maskedEmail:void 0});return}s(I)}catch{l("setup"),s(null)}finally{g(!1)}},[e,M,v,F]),B=Ge(async()=>{p(!0),l(null),c(null);try{let S=await mo({method:e}),N=po(S);if(N){l("disable"),c(N);return}let L=ht(S);if(L){M(L);return}let I=v(S);if(!I){l("parseDisable");return}s(I)}catch{l("disable")}finally{p(!1)}},[e,M,v]);return Zr(()=>(l(null),c(null),s(null),()=>{s(null)}),[t]),{setup:i,loading:d||m,errorType:a,errorMessage:u,startSetup:x,startDisable:B}},ht=e=>je(e)&&typeof e.url=="string"||typeof Response<"u"&&e instanceof Response&&typeof e.url=="string"?e.url:null,po=e=>{let t=ht(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 fe from"react";import vt from"react-qr-code";import q from"react";import{Copy as Jr,Download as en}from"lucide-react";import{useState as tn,useMemo as on,useEffect as rn}from"react";function yt({setup:e,onError:t}){let[o,r]=tn("idle"),n=on(()=>e.recoveryKeys?.join(`
28
+ `)??"",[e.recoveryKeys]);return rn(()=>{r("idle")},[e.token]),q.createElement("div",{className:"mt-4 flex w-full flex-col items-center gap-3 text-left"},q.createElement("div",{className:"w-full max-w-sm space-y-2"},q.createElement("p",{className:"text-sm font-medium"},"Recovery codes"),q.createElement("p",{className:"text-xs text-muted-foreground"},"Store these somewhere safe. Use one if you lose your authenticator device."),q.createElement("div",{className:"rounded-md border border-dashed bg-muted/30 p-4"},q.createElement("ul",{className:"grid gap-2 font-mono text-sm"},e.recoveryKeys?.map(i=>q.createElement("li",{key:i},i)))),q.createElement("div",{className:"flex flex-wrap items-center gap-2"},q.createElement(E,{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")}}}},q.createElement(Jr,{className:"size-4","aria-hidden":"true"}),"Copy"),q.createElement(E,{type:"button",size:"sm",variant:"outline",onClick:()=>{if(n)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
+ `,s=new Blob([i,n],{type:"text/plain"}),a=URL.createObjectURL(s),l=document.createElement("a");l.href=a,l.download="nile-mfa-recovery-codes.txt",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}catch{t("We were unable to download the recovery keys. Please try again.")}}},q.createElement(en,{className:"size-4","aria-hidden":"true"}),"Download"),o==="copied"?q.createElement("span",{className:"text-xs text-muted-foreground"},"Recovery codes copied to clipboard."):o==="error"?q.createElement("span",{className:"text-xs text-destructive"},"Unable to copy automatically. Please copy the codes manually."):null)))}import*as w from"react";import{mfa as an,sanitizeRedirectUrl as ln}from"@niledatabase/client";import A,{useEffect as nn}from"react";import{mfa as sn}from"@niledatabase/client";function bt({token:e,scope:t,method:o,remove:r,onSuccess:n,onCancel:i}){let[s,a]=A.useState(""),[l,u]=A.useState(null),[c,d]=A.useState(!1),[g,m]=A.useState(!1),[p,v]=A.useState(""),M=A.useRef(null),F=A.useId(),x=A.useId(),B=A.useRef(null);nn(()=>(a(""),u(null),m(!1),d(!1),()=>{B.current&&(clearTimeout(B.current),B.current=null)}),[e]);let S=async I=>{if(I.preventDefault(),c||g)return;if(!e){u("Missing MFA challenge token. Please restart the sign-in flow.");return}let X=s.trim();if(!X.length){u("Enter your recovery code to continue.");return}d(!0),u(null);let pe=!1;try{let H=await sn({token:e,code:X,scope:t,method:o,remove:r});if(H?.ok){pe=!0,m(!0),Se();let Y=typeof H.recoveryCodesRemaining=="number"?H.recoveryCodesRemaining:null;v(Y!==null?`You have ${Y} recovery ${Y===1?"code":"codes"} remaining.`:"Recovery code verified."),B.current=setTimeout(()=>{n?.(H.scope??t)},2e3);return}if(H&&typeof H=="object"&&"url"in H){let Y=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",Be=new URL(String(H.url),Y);u(Be.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{pe||d(!1)}},N=I=>{a(I.target.value),l&&u(null)},L=c||g;return A.createElement("form",{className:"space-y-6",onSubmit:S},A.createElement("fieldset",{className:"flex flex-col gap-6",disabled:L},A.createElement("label",{htmlFor:F,className:"sr-only"},"Recovery code"),A.createElement(j,{id:F,ref:M,className:"h-14",type:"text",autoComplete:"one-time-code","aria-label":"Recovery code","aria-invalid":!!l,"aria-describedby":l?x:void 0,placeholder:"Enter a recovery code",value:s,onChange:N}),A.createElement(E,{className:"w-full",type:"submit",size:"lg",disabled:L},c?"Verifying...":"Submit")),A.createElement("div",{className:"flex justify-center"},A.createElement(E,{type:"button",variant:"link",className:"p-0 text-sm",onClick:i,disabled:L},"Use verification code instead")),l?A.createElement("p",{className:"text-sm font-medium text-destructive",id:x,role:"alert"},l):null,p?A.createElement("p",{className:"text-sm font-medium text-orange-600",role:"alert"},p):null)}var ce=6;function de({token:e,scope:t,method:o,remove:r,signInHref:n="/mfa",onSuccess:i}){let[s,a]=w.useState(Array(ce).fill("")),[l,u]=w.useState(e),[c,d]=w.useState(null),[g,m]=w.useState(null),[p,v]=w.useState(!1),[M,F]=w.useState(!1),x=w.useId(),B=w.useRef([]),S=ln(n,{fallback:"/mfa"});w.useEffect(()=>{M||B.current[0]?.focus()},[M]),w.useEffect(()=>{if(e){u(e);return}let D=Ke();D?.token?u(D.token):u("")},[e]);let N=D=>P=>{let K=P.target.value.replace(/\D+/g,"");if(!K.length){X(D,"");return}let te=K.at(-1)??"";X(D,te),D<ce-1&&B.current[D+1]?.focus()},L=D=>P=>{P.key==="Backspace"&&(s[D]?X(D,""):D>0&&(B.current[D-1]?.focus(),X(D-1,"")),P.preventDefault()),P.key==="ArrowLeft"&&D>0&&(B.current[D-1]?.focus(),P.preventDefault()),P.key==="ArrowRight"&&D<ce-1&&(B.current[D+1]?.focus(),P.preventDefault())},I=D=>{D.preventDefault();let P=D.clipboardData.getData("text").replace(/\D+/g,"").slice(0,ce).split("");if(!P.length)return;let K=[...s];for(let Le=0;Le<ce;Le+=1)K[Le]=P[Le]??"";a(K);let te=Math.min(P.length,ce-1);B.current[te]?.focus()},X=(D,P)=>{a(K=>{let te=[...K];return te[D]=P,te}),d(null),m(null)},pe=w.useMemo(()=>s.join(""),[s]),H=async D=>{if(D.preventDefault(),!l){d("Missing MFA challenge token. Please restart the sign-in flow.");return}if(pe.length!==ce){d("Enter the full 6-digit code to continue.");return}v(!0),d(null),m(null);try{let P=await an({token:l,code:pe,scope:t,method:o,remove:r});if(P?.ok)Se(),i?.(P.scope??t);else if(P&&typeof P=="object"&&"url"in P&&typeof P.url=="string"){let K=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",te=new URL(P.url,K);d(te.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{v(!1)}},Y=()=>{F(!1),a(Array(ce).fill("")),d(null),m(null)},Be=async()=>{M||(d(null),m(null),F(!0))};return w.createElement("div",{className:"space-y-6"},M?w.createElement(bt,{token:l,scope:t,method:o,remove:r,onSuccess:i,onCancel:Y}):w.createElement("form",{className:"space-y-6",onSubmit:H},w.createElement("fieldset",{className:"flex flex-col gap-6",disabled:p||M},w.createElement("div",{className:"flex justify-center gap-3"},s.map((D,P)=>w.createElement(j,{key:P,ref:K=>{B.current[P]=K},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 ${P+1}`,"aria-invalid":!!c,"aria-describedby":c?x:void 0,pattern:"[0-9]*",maxLength:1,value:D,onChange:N(P),onKeyDown:L(P),onPaste:I}))),w.createElement(E,{className:"w-full",type:"submit",size:"lg",disabled:p},p?"Verifying...":"Submit")),c?w.createElement("div",{className:"flex flex-col gap-2"},w.createElement("p",{className:"text-sm font-medium text-destructive",id:x,role:"alert"},"Error: ",c),w.createElement(E,{variant:"outline",asChild:!0},w.createElement("a",{href:S},"Back to sign in"))):null),c==="Invalid MFA code"?w.createElement(E,{variant:"link",asChild:!0},w.createElement("a",{href:S},"Return to sign in")):null,M?null:w.createElement("div",{className:"flex justify-center"},w.createElement(E,{type:"button",variant:"link",className:"p-0 text-sm",onClick:Be,disabled:p||M},"Use a recovery code")),g?w.createElement("p",{className:"text-sm font-medium text-emerald-600",role:"status"},g):null)}function ho({setup:e,onError:t,onSuccess:o}){let r=vt.default?vt.default:vt;return fe.createElement("div",{className:"flex flex-col items-center gap-4 text-center"},e.otpauthUrl?fe.createElement(fe.Fragment,null,fe.createElement("div",{className:"rounded-md border border-border bg-background p-3"},fe.createElement(r,{value:e.otpauthUrl,size:192,className:"h-48 w-48"})),fe.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?fe.createElement(yt,{setup:e,onError:t,onSuccess:o}):null,fe.createElement(de,{token:e.token,scope:e.scope,method:e.method,onSuccess:o}))}import wt from"react";function yo({setup:e,onSuccess:t}){return wt.createElement("div",{className:"flex w-full max-w-sm flex-col items-center gap-3 text-center"},wt.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."),wt.createElement(de,{token:e.token,scope:e.scope,method:e.method,onSuccess:t}))}import xt from"react";function bo({payload:e,message:t,isEnrolled:o,signInHref:r,onSuccess:n}){return xt.createElement("div",{className:"flex w-full max-w-sm flex-col items-center gap-3 text-center"},xt.createElement("p",{className:"text-sm text-muted-foreground"},t),xt.createElement(de,{token:e.token,scope:e.scope,method:e.method,remove:o,signInHref:r,onSuccess:n}))}import h,{useCallback as Co,useEffect as Fn,useState as Et}from"react";import{useMutation as Dn}from"@tanstack/react-query";import{ArrowLeftRight as En,ChevronDown as In,Plus as Mo}from"lucide-react";import{useForm as kn}from"react-hook-form";import*as C from"react";import*as b from"@radix-ui/react-dropdown-menu";import{Check as un,ChevronRight as mn,Circle as cn}from"lucide-react";var vo=b.Root,St=C.forwardRef(({className:e,...t},o)=>C.createElement(b.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}));St.displayName=b.Trigger.displayName;var dn=C.forwardRef(({className:e,inset:t,children:o,...r},n)=>C.createElement(b.SubTrigger,{ref:n,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),...r},o,C.createElement(mn,{className:"ml-auto"})));dn.displayName=b.SubTrigger.displayName;var fn=C.forwardRef(({className:e,...t},o)=>C.createElement(b.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}));fn.displayName=b.SubContent.displayName;var Pt=C.forwardRef(({className:e,sideOffset:t=4,...o},r)=>C.createElement(b.Portal,null,C.createElement(b.Content,{ref:r,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})));Pt.displayName=b.Content.displayName;var _e=C.forwardRef(({className:e,inset:t,active:o,...r},n)=>C.createElement(b.Item,{ref:n,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),...r}));_e.displayName=b.Item.displayName;var pn=C.forwardRef(({className:e,children:t,checked:o,...r},n)=>C.createElement(b.CheckboxItem,{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),checked:o,...r},C.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},C.createElement(b.ItemIndicator,null,C.createElement(un,{className:"h-4 w-4"}))),t));pn.displayName=b.CheckboxItem.displayName;var gn=C.forwardRef(({className:e,children:t,...o},r)=>C.createElement(b.RadioItem,{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),...o},C.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},C.createElement(b.ItemIndicator,null,C.createElement(cn,{className:"h-2 w-2 fill-current"}))),t));gn.displayName=b.RadioItem.displayName;var hn=C.forwardRef(({className:e,inset:t,...o},r)=>C.createElement(b.Label,{ref:r,className:f("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...o}));hn.displayName=b.Label.displayName;var Ct=C.forwardRef(({className:e,...t},o)=>C.createElement(b.Separator,{ref:o,className:f("-mx-1 my-1 h-px bg-muted",e),...t}));Ct.displayName=b.Separator.displayName;var yn=({className:e,...t})=>C.createElement("span",{className:f("ml-auto text-xs tracking-widest opacity-60",e),...t});yn.displayName="DropdownMenuShortcut";import*as V from"react";import*as T from"@radix-ui/react-dialog";import{X as bn}from"lucide-react";var wo=T.Root,xo=T.Trigger,vn=T.Portal;var So=V.forwardRef(({className:e,...t},o)=>V.createElement(T.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}));So.displayName=T.Overlay.displayName;var Mt=V.forwardRef(({className:e,children:t,...o},r)=>V.createElement(vn,null,V.createElement(So,null),V.createElement(T.Content,{ref:r,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},t,V.createElement(T.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"},V.createElement(bn,{className:"h-4 w-4"}),V.createElement("span",{className:"sr-only"},"Close")))));Mt.displayName=T.Content.displayName;var Nt=({className:e,...t})=>V.createElement("div",{className:f("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Nt.displayName="DialogHeader";var wn=({className:e,...t})=>V.createElement("div",{className:f("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});wn.displayName="DialogFooter";var Ft=V.forwardRef(({className:e,...t},o)=>V.createElement(T.Title,{ref:o,className:f("text-lg font-semibold leading-none tracking-tight",e),...t}));Ft.displayName=T.Title.displayName;var Dt=V.forwardRef(({className:e,...t},o)=>V.createElement(T.Description,{ref:o,className:f("text-sm text-muted-foreground",e),...t}));Dt.displayName=T.Description.displayName;import xn,{useCallback as Sn,useEffect as Pn}from"react";import{useQuery as Cn}from"@tanstack/react-query";var Po="nile.tenant-id";function Ee(e){let{disableQuery:t,tenants:o,baseUrl:r="",basePath:n,auth:i,init:s}=e,a=z(e.client);return Cn({queryKey:["tenants",r,n,e.fetchUrl],queryFn:async()=>{let u=await we(e.fetchUrl??"/tenants",{headers:{"content-type":"application/json"}},{auth:i,init:s,baseUrl:r,basePath:n,fetchUrl:e.fetchUrl});if(!u.ok)throw new Error("Failed to fetch tenants");return u.json()},enabled:t!==!0,initialData:o},a)}function Xe(e){let t=e?.useCookie!==!1,[o,r]=xn.useState(e?.activeTenant??e?.tenant?.id),{refetch:n}=Ee({...e,disableQuery:!0});Pn(()=>{if(!o){let a=t?Mn(Po):null;a?r(a):!e?.disableQuery&&!e?.tenants?.length&&n()}},[n,o,t,e?.disableQuery,e?.tenants?.length]);let{onTenantChange:i}=e??{},s=Sn(a=>{r(a),t&&Nn(Po,a),i?.(a)},[i,t]);return[o,s]}var Mn=e=>{if(typeof document>"u")return null;let t=document.cookie.split(";");for(let o of t){let r=o.trim(),n=r.indexOf("=");if(n===-1)continue;if(r.slice(0,n).trim()===e){let s=r.slice(n+1);try{return decodeURIComponent(s)}catch{return s}}}return null},Nn=(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}`};function Fo(e){let{client:t}=e??{};return h.createElement(Q,{client:t},h.createElement(Bn,{...e}))}function Bn(e){let{data:t=e.tenants??[],isLoading:o,refetch:r}=Ee(e),{buttonText:n="Create an organization",emptyText:i="You are not part of an organization."}=e,[s,a]=Xe(e),[l,u]=Et(!1),[c,d]=Et(!1),g=t.find(m=>m.id===s);return Fn(()=>{!e.tenants?.length&&t?.length>0&&!g&&a(t[0].id)},[e.tenants?.length,t]),!o&&t.length===0?h.createElement("div",{className:f("flex flex-col items-center gap-2",e.className)},h.createElement("p",null,i),h.createElement(No,{...e,onSuccess:m=>{a(m.id),u(!1),r()},trigger:h.createElement(E,{type:"button"},h.createElement(Mo,{size:18})," ",n)})):h.createElement("div",null,h.createElement("div",{className:f(e.className)},h.createElement("div",{className:"text-sm pb-1.5 opacity-70 flex flex-row gap-1 items-center"},h.createElement(En,{size:14}),"Switch organization"),h.createElement("div",{className:"flex flex-row w-full flex-1 items-center gap-1"},h.createElement(vo,{open:l,onOpenChange:u},h.createElement(St,{className:"group w-80 font-medium text-sm",disabled:!g?.name,onClick:()=>{u(!0)}},g?.name??"Loading...",h.createElement(In,{className:"transition-transform duration-200 ease-in-out group-data-[state=open]:rotate-180"})),h.createElement(Pt,{className:"flex flex-col gap-0.5 max-h-96 overflow-auto custom-scrollbar w-80"},t?.map(m=>h.createElement(_e,{key:m.id,onClick:()=>a(m.id),active:m.id===g?.id},m.name)),h.createElement(Ct,null),h.createElement(_e,{onSelect:m=>{m.preventDefault(),u(!1),d(!0)}},h.createElement("span",{className:"flex items-center gap-1 mx-auto"},h.createElement(Mo,{size:18})," Create new organization")))),h.createElement(No,{...e,open:c,onOpenChange:d,onSuccess:m=>{u(!1),d(!1),a(m.id),r()}}))))}function No(e){let[t,o]=Et(!1),r=e.open!==void 0,n=r?e.open:t,{trigger:i,beforeMutate:s,onSuccess:a,onError:l,auth:u,init:c,baseUrl:d,basePath:g}=e,m=z(e.client),p=kn({defaultValues:{name:""}}),v=Dn({mutationFn:async x=>{let B={...x,name:x.name.trim()},N=(s&&s(B))??B,L=await we(e?.fetchUrl??"/tenants",{method:"POST",body:JSON.stringify(N)},{auth:u,init:c,baseUrl:d,basePath:g,fetchUrl:e.fetchUrl});if(!L.ok){let I=await L.text().catch(()=>"");throw new Error(I||"Failed to create organization")}return L.json()},onSuccess:async x=>{p.reset({name:""}),r||o(!1),e.onOpenChange?.(!1),a&&a(x)},onError:l},m),M=Co(x=>{r||o(x),e.onOpenChange?.(x),x||(p.reset({name:""}),v.reset())},[p,r,v,e]),F=Co(x=>{v.mutate(x)},[v]);return h.createElement(wo,{open:n,onOpenChange:M},i?h.createElement(xo,{asChild:!0},i):null,h.createElement(Mt,null,h.createElement(Nt,null,h.createElement(Ft,null,"Create an organization"),h.createElement(Dt,null,"An organization is a group of users.")),h.createElement(W,{...p},h.createElement("form",{onSubmit:p.handleSubmit(F)},h.createElement(ge,{control:p.control,name:"name",rules:{validate:x=>x.trim().length>0||"Organization name is required."},render:({field:x})=>h.createElement(oe,null,h.createElement(re,null,"Name"),h.createElement(ne,null,h.createElement(j,{placeholder:"Organization name",...x,autoFocus:!0})),h.createElement(he,null,"This is the name of your organization."),h.createElement(ye,null))}),v.error?h.createElement("p",{role:"alert",className:"text-sm text-destructive py-1"},v.error instanceof Error?v.error.message:"Failed to create organization"):null,h.createElement(E,{type:"submit",className:"py-2",loading:v.isPending},"Submit")))))}import{BadgeCheck as Do,CalendarCheck as Tn,CircleUserRound as Un,Mail as zn}from"lucide-react";import U,{useMemo as On}from"react";import{useQuery as Ln}from"@tanstack/react-query";function Ye(e){let{baseUrl:t="",basePath:o,fetchUrl:r,client:n,user:i,auth:s,init:a}=e??{},l=z(n),{data:u,isLoading:c}=Ln({queryKey:["me",t,o,r],queryFn:async()=>{let d=await we(r??"/me",void 0,{auth:s,init:a,baseUrl:t,basePath:o,fetchUrl:r});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:s&&!(i&&c)?s.state?.session?.user??u??null:null}function Eo(e){return U.createElement(Q,{client:e.client},U.createElement(An,{...e}))}function Rn(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 An(e){let t=Ye(e),o=U.useMemo(()=>t&&typeof t=="object"&&"picture"in t&&t.picture?U.createElement("img",{src:t.picture,alt:`${t.name??t.email} profile picture`,referrerPolicy:"no-referrer"}):e.profilePicturePlaceholder?e.profilePicturePlaceholder:U.createElement("div",{className:"drop-shadow-md",style:{background:"linear-gradient(90deg, #F4C587, #D6D3E9, #99D2EC)"}},U.createElement(Un,{size:100,className:"opacity-70 stroke-black",style:{strokeWidth:".5px"}})),[t,e.profilePicturePlaceholder]),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?U.createElement("div",{className:f(e.className,"flex flex-col gap-2 items-center")},U.createElement("div",{className:"flex flex-col gap-5 pb-2 items-center"},U.createElement("div",{className:"flex flex-col gap-2 items-center w-36 mx-auto"},U.createElement("div",{className:"rounded-full border border-background overflow-hidden shadow-md"},o)),U.createElement("div",{className:"font-bold flex flex-row gap-1 capitalize"},r)),U.createElement("div",{className:"flex flex-row gap-5 justify-between w-full"},U.createElement("div",{className:"flex flex-row gap-2 text-sm items-center w-36"},U.createElement(zn,{size:14}),"Email:"),U.createElement("div",{className:"flex flex-row gap-1 items-center"},t.emailVerified?U.createElement(Do,{className:"stroke-white fill-green-700",size:14}):U.createElement(Do,{className:"opacity-40",size:14}),t.email," ")),t.created?U.createElement("div",{className:"flex flex-row gap-5 justify-between w-full"},U.createElement("div",{className:"flex flex-row gap-2 text-sm items-center w-36"},U.createElement(Tn,{size:14}),"Created:"),Rn(t.created)):null):"Loading..."}import kt from"react";import{useForm as Qn}from"react-hook-form";import ve from"react";import{useMutation as Io}from"@tanstack/react-query";import{resetPassword as Hn,forgotPassword as Vn}from"@niledatabase/client";function Ie(e){let{auth:t,baseUrl:o="",beforeMutate:r,client:n,callbackUrl:i,fetchUrl:s,init:a,onError:l,onSuccess:u,redirect:c=!1}=e??{},d=z(n),g=Io({mutationFn:async m=>{let v=(r&&r(m))??m;return await Hn({auth:t,baseUrl:o,callbackUrl:i,fetchUrl:s,init:a,redirect:c,...v})},onSuccess:m=>{u&&u(m)},onError:l},d);return Ue(e),g}function ko(e){return Ie(e).mutate}function Bo(e){let{auth:t,baseUrl:o="",beforeMutate:r,callbackUrl:n,fetchUrl:i,init:s,client:a,onError:l,onSuccess:u,redirect:c=!1}=e??{},d=z(a),g=Io({mutationFn:async m=>{let v=(r&&r(m))??m;return await Vn({auth:t,baseUrl:o,callbackUrl:n,fetchUrl:i,init:s,redirect:c,...v})},onSuccess:m=>{u&&u(m)},onError:l},d);return Ue(e),g}function It(e){return ve.createElement(Q,{client:e.client},ve.createElement(qn,{...e}))}function qn(e){let{defaultValues:t,buttonText:o="Reset password",...r}=e,n=Qn({defaultValues:{email:"",...t}}),i=Ie({...r,redirect:!0});return ve.createElement(W,{...n},ve.createElement("form",{className:"py-2",onSubmit:n.handleSubmit(({email:s})=>{i.mutate({email:s})})},ve.createElement(Z,null),!e.onError&&i.error?ve.createElement("p",{role:"alert",className:"text-sm font-medium text-destructive"},i.error instanceof Error?i.error.message:"Password reset request failed"):null,ve.createElement(E,{type:"submit",loading:i.isPending},o)))}function Bt(e){return kt.createElement("div",{className:"flex flex-col gap-4"},kt.createElement("h2",{className:"font-sans text-3xl"},"Request password reset"),kt.createElement(It,{...e}))}import ke from"react";import{useForm as jn}from"react-hook-form";import O,{useEffect as Wn,useState as $n}from"react";function Lt(e){return O.createElement(Q,{client:e.client},O.createElement(Kn,{...e}))}function Kn(e){let{defaultValues:t,mode:o,buttonText:r="Update password",...n}=e,i=jn({defaultValues:{email:"",password:"",confirmPassword:"",...t}}),s=Bo(n),a=Ie(n),l=i.watch("password"),u=i.watch("confirmPassword"),[c,d]=$n(!0),g=s.isPending||a.isPending,m=s.error||a.error;return Wn(()=>{i.clearErrors(),!l||!u?d(!0):l!==u?(i.setError("confirmPassword",{message:"Passwords must match."}),d(!0)):d(!1)},[l,u,i]),O.createElement(W,{...i},O.createElement("form",{onSubmit:i.handleSubmit(({email:p,password:v})=>{o==="forgot"||!o&&!p?s.mutate({password:v}):a.mutate({email:p,password:v})}),className:"py-2"},t?.email?O.createElement(ge,{control:i.control,name:"email",render:({field:p})=>O.createElement(oe,null,O.createElement(re,null,"Email address"),O.createElement(ne,null,O.createElement(j,{...p,disabled:!0})))}):null,O.createElement(be,{autoComplete:"new-password"}),O.createElement(ge,{control:i.control,name:"confirmPassword",render:({field:p})=>O.createElement(oe,null,O.createElement(re,null,"Confirm password"),O.createElement(ne,null,O.createElement(j,{placeholder:"Password",...p,type:"password",autoComplete:"new-password"})),O.createElement(he,null,"Confirm your new password"),O.createElement(ye,null))}),!e.onError&&m?O.createElement("p",{role:"alert",className:"text-sm font-medium text-destructive"},m instanceof Error?m.message:"Password update failed"):null,O.createElement(E,{type:"submit",loading:g,disabled:Object.keys(i.formState.errors).length>0||c},r)))}function Tt(e){return ke.createElement(Q,{client:e.client},ke.createElement(Gn,{...e}))}function Gn({className:e,...t}){return ke.createElement("div",{className:f(e,"flex flex-col gap-4")},ke.createElement("h2",{className:"font-sans text-3xl"},"Reset password"),ke.createElement(Lt,{...t}))}import{getSession as bm,getCsrfToken as vm,getProviders as wm,signIn as xm,signOut as Sm,auth as Pm,Authorizer as Cm}from"@niledatabase/client";export{Cm as Authorizer,ur as Azure,cr as Discord,Z as Email,rt as EmailSignIn,jt as EmailSignInButton,fr as GitHub,$t as Google,gr as HubSpot,yr as LinkedIn,ho as MultiFactorAuthenticator,bo as MultiFactorChallenge,yo as MultiFactorEmail,de as MultiFactorVerify,Pr as Okta,be as Password,Tt as PasswordResetForm,Bt as PasswordResetRequestForm,Me as SessionContext,Fe as SessionProvider,mt as SignInForm,Rr as SignOutButton,at as SignUpForm,io as SignedIn,so as SignedOut,vr as Slack,Fo as TenantSelector,Eo as UserInfo,xr as X,Pm as auth,Se as clearMfaChallenge,vm as getCsrfToken,wm as getProviders,bm as getSession,Ke as readMfaChallenge,xm as signIn,Sm as signOut,$e as storeMfaChallenge,Qt as useEmailSignIn,Ye as useMe,go as useMultiFactor,ko as useResetPassword,Ne as useSession,qe as useSignIn,Qe as useSignUp,Xe as useTenantId,Ee as useTenants};
31
31
  //# sourceMappingURL=index.mjs.map