@velastack/patterns 0.15.1 → 0.15.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/chunks/{_page-Cg7LjaOE.js → _page-BFUn0CG1.js} +2 -2
- package/dist/chunks/{_page-Cg7LjaOE.js.map → _page-BFUn0CG1.js.map} +1 -1
- package/dist/chunks/{auth-pages-DSBqKjO0.js → auth-pages-D8n8gfCL.js} +2 -2
- package/dist/chunks/{auth-pages-DSBqKjO0.js.map → auth-pages-D8n8gfCL.js.map} +1 -1
- package/dist/chunks/{collections-D2_2cxWD.js → collections-Daxlnbm0.js} +2 -2
- package/dist/chunks/{collections-D2_2cxWD.js.map → collections-Daxlnbm0.js.map} +1 -1
- package/dist/chunks/{constants-DbpctM1D.js → constants-E1I-__KI.js} +18 -18
- package/dist/chunks/{constants-DbpctM1D.js.map → constants-E1I-__KI.js.map} +1 -1
- package/dist/chunks/{currency.server-CFrwmYra.js → currency.server-BkzwY17R.js} +2 -2
- package/dist/chunks/{currency.server-CFrwmYra.js.map → currency.server-BkzwY17R.js.map} +1 -1
- package/dist/chunks/{env-vars-Dm3Xy4rl.js → env-vars-C3TSZc4f.js} +3 -3
- package/dist/chunks/{env-vars-Dm3Xy4rl.js.map → env-vars-C3TSZc4f.js.map} +1 -1
- package/dist/chunks/{generate-BMWoD9E2.js → generate-CAYM7OUF.js} +2 -2
- package/dist/chunks/{generate-BMWoD9E2.js.map → generate-CAYM7OUF.js.map} +1 -1
- package/dist/chunks/{generate-DZ9kT3iC.js → generate-CL7wG0ZC.js} +3 -3
- package/dist/chunks/{generate-DZ9kT3iC.js.map → generate-CL7wG0ZC.js.map} +1 -1
- package/dist/chunks/{generate-BRTIGlqT.js → generate-CbchamhA.js} +3 -3
- package/dist/chunks/{generate-BRTIGlqT.js.map → generate-CbchamhA.js.map} +1 -1
- package/dist/chunks/{generate-Cs_fdfD7.js → generate-DI58vuk1.js} +2 -2
- package/dist/chunks/{generate-Cs_fdfD7.js.map → generate-DI58vuk1.js.map} +1 -1
- package/dist/chunks/{generate-BvQ6VwYH.js → generate-DR2wkVPY.js} +2 -2
- package/dist/chunks/{generate-BvQ6VwYH.js.map → generate-DR2wkVPY.js.map} +1 -1
- package/dist/chunks/{generate.runtime-1eTnPFmA.js → generate.runtime-B11mOr45.js} +2 -2
- package/dist/chunks/{generate.runtime-1eTnPFmA.js.map → generate.runtime-B11mOr45.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CjLath7N.js → generate.runtime-B1Y2JrGW.js} +5 -5
- package/dist/chunks/{generate.runtime-CjLath7N.js.map → generate.runtime-B1Y2JrGW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CnNtG_x5.js → generate.runtime-B7VubPTW.js} +3 -3
- package/dist/chunks/{generate.runtime-CnNtG_x5.js.map → generate.runtime-B7VubPTW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BvHK8IN-.js → generate.runtime-BCv4F1Wm.js} +5 -5
- package/dist/chunks/{generate.runtime-BvHK8IN-.js.map → generate.runtime-BCv4F1Wm.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D8G8cwCr.js → generate.runtime-BEWp57Y7.js} +2 -2
- package/dist/chunks/{generate.runtime-D8G8cwCr.js.map → generate.runtime-BEWp57Y7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B4mQEW54.js → generate.runtime-BH6hHygm.js} +3 -3
- package/dist/chunks/{generate.runtime-B4mQEW54.js.map → generate.runtime-BH6hHygm.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CfCDLJ6Y.js → generate.runtime-BL6DpWFI.js} +3 -3
- package/dist/chunks/{generate.runtime-CfCDLJ6Y.js.map → generate.runtime-BL6DpWFI.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BJwSyslL.js → generate.runtime-BRV9hIl5.js} +2 -2
- package/dist/chunks/{generate.runtime-BJwSyslL.js.map → generate.runtime-BRV9hIl5.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B9nVU5iO.js → generate.runtime-BRcP6sFt.js} +2 -2
- package/dist/chunks/{generate.runtime-B9nVU5iO.js.map → generate.runtime-BRcP6sFt.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BC1GJUXE.js → generate.runtime-Bhs7ttZS.js} +2 -2
- package/dist/chunks/{generate.runtime-BC1GJUXE.js.map → generate.runtime-Bhs7ttZS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bda2_WK7.js → generate.runtime-BjrtdoYE.js} +2 -2
- package/dist/chunks/{generate.runtime-Bda2_WK7.js.map → generate.runtime-BjrtdoYE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DBQvnQmR.js → generate.runtime-Bo_s7gYB.js} +2 -2
- package/dist/chunks/{generate.runtime-DBQvnQmR.js.map → generate.runtime-Bo_s7gYB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DQUZRJH8.js → generate.runtime-Bs77Oc8P.js} +3 -3
- package/dist/chunks/{generate.runtime-DQUZRJH8.js.map → generate.runtime-Bs77Oc8P.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cd742Yqf.js → generate.runtime-C3IswX7B.js} +2 -2
- package/dist/chunks/{generate.runtime-Cd742Yqf.js.map → generate.runtime-C3IswX7B.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B-H2F-sH.js → generate.runtime-C90_2L-8.js} +3 -3
- package/dist/chunks/{generate.runtime-B-H2F-sH.js.map → generate.runtime-C90_2L-8.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B4rG6gSK.js → generate.runtime-CDY0Ot_t.js} +6 -6
- package/dist/chunks/{generate.runtime-B4rG6gSK.js.map → generate.runtime-CDY0Ot_t.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Doumu0TL.js → generate.runtime-CZMVPVjS.js} +6 -6
- package/dist/chunks/{generate.runtime-Doumu0TL.js.map → generate.runtime-CZMVPVjS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-liAz2TOE.js → generate.runtime-C_hrLPD4.js} +3 -3
- package/dist/chunks/{generate.runtime-liAz2TOE.js.map → generate.runtime-C_hrLPD4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DE-vPcn4.js → generate.runtime-CdZ3GzPS.js} +6 -6
- package/dist/chunks/{generate.runtime-DE-vPcn4.js.map → generate.runtime-CdZ3GzPS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BkQPchHe.js → generate.runtime-ChSVP7cD.js} +6 -6
- package/dist/chunks/{generate.runtime-BkQPchHe.js.map → generate.runtime-ChSVP7cD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C1HlZnLC.js → generate.runtime-Cs73i6Zf.js} +2 -2
- package/dist/chunks/{generate.runtime-C1HlZnLC.js.map → generate.runtime-Cs73i6Zf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-GmsldrGj.js → generate.runtime-D7KYlnvb.js} +3 -3
- package/dist/chunks/{generate.runtime-GmsldrGj.js.map → generate.runtime-D7KYlnvb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DFSsgOmB.js → generate.runtime-DG9LRwbt.js} +3 -3
- package/dist/chunks/{generate.runtime-DFSsgOmB.js.map → generate.runtime-DG9LRwbt.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CIOi-XSm.js → generate.runtime-DKL7VAAd.js} +6 -6
- package/dist/chunks/{generate.runtime-CIOi-XSm.js.map → generate.runtime-DKL7VAAd.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CQ_U4YTJ.js → generate.runtime-DP63Wwea.js} +4 -4
- package/dist/chunks/{generate.runtime-CQ_U4YTJ.js.map → generate.runtime-DP63Wwea.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C62ChKGg.js → generate.runtime-DRPxOLnB.js} +4 -4
- package/dist/chunks/{generate.runtime-C62ChKGg.js.map → generate.runtime-DRPxOLnB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DQI69jkX.js → generate.runtime-DW9bqOtC.js} +2 -2
- package/dist/chunks/{generate.runtime-DQI69jkX.js.map → generate.runtime-DW9bqOtC.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dtum580c.js → generate.runtime-DdY44Ulv.js} +6 -6
- package/dist/chunks/{generate.runtime-Dtum580c.js.map → generate.runtime-DdY44Ulv.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ufoTIUXA.js → generate.runtime-DjEj-n6m.js} +7 -7
- package/dist/chunks/{generate.runtime-ufoTIUXA.js.map → generate.runtime-DjEj-n6m.js.map} +1 -1
- package/dist/chunks/{generate.runtime-rxzMCECc.js → generate.runtime-DlAJQ5Js.js} +4 -4
- package/dist/chunks/{generate.runtime-rxzMCECc.js.map → generate.runtime-DlAJQ5Js.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CZA46Ghe.js → generate.runtime-JftBoKYS.js} +5 -5
- package/dist/chunks/{generate.runtime-CZA46Ghe.js.map → generate.runtime-JftBoKYS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DNjyaFml.js → generate.runtime-_426A1Ij.js} +3 -3
- package/dist/chunks/{generate.runtime-DNjyaFml.js.map → generate.runtime-_426A1Ij.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DR8z6DyZ.js → generate.runtime-fs6GEMx-.js} +5 -5
- package/dist/chunks/{generate.runtime-DR8z6DyZ.js.map → generate.runtime-fs6GEMx-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Diix70x4.js → generate.runtime-jIlQ2GMh.js} +2 -2
- package/dist/chunks/{generate.runtime-Diix70x4.js.map → generate.runtime-jIlQ2GMh.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BuQASx9Y.js → generate.runtime-v3KCv1B6.js} +2 -2
- package/dist/chunks/{generate.runtime-BuQASx9Y.js.map → generate.runtime-v3KCv1B6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-lP4eoera.js → generate.runtime-xrxAElb3.js} +3 -3
- package/dist/chunks/{generate.runtime-lP4eoera.js.map → generate.runtime-xrxAElb3.js.map} +1 -1
- package/dist/chunks/{gitignore-2XpeEFmr.js → gitignore-CBiWFRif.js} +3 -3
- package/dist/chunks/{gitignore-2XpeEFmr.js.map → gitignore-CBiWFRif.js.map} +1 -1
- package/dist/chunks/{i18n-CxT1kz8Y.js → i18n-Ho8H91Ze.js} +2 -2
- package/dist/chunks/{i18n-CxT1kz8Y.js.map → i18n-Ho8H91Ze.js.map} +1 -1
- package/dist/chunks/{modify-file-BX9-aZD1.js → modify-file-BOEKlIDw.js} +2 -2
- package/dist/chunks/{modify-file-BX9-aZD1.js.map → modify-file-BOEKlIDw.js.map} +1 -1
- package/dist/chunks/{pocketbase-Dq9UdK_j.js → pocketbase-B2ksFrvH.js} +2 -2
- package/dist/chunks/{pocketbase-Dq9UdK_j.js.map → pocketbase-B2ksFrvH.js.map} +1 -1
- package/dist/chunks/{providers-2UgxXRJW.js → providers-BEjDonyG.js} +2 -2
- package/dist/chunks/{providers-2UgxXRJW.js.map → providers-BEjDonyG.js.map} +1 -1
- package/dist/chunks/{route-BDhlro0V.js → route-9ZVJZkYu.js} +23 -19
- package/dist/chunks/route-9ZVJZkYu.js.map +1 -0
- package/dist/chunks/{schema-2frI_BS2.js → schema-DnMqw2Hn.js} +3 -3
- package/dist/chunks/{schema-2frI_BS2.js.map → schema-DnMqw2Hn.js.map} +1 -1
- package/dist/chunks/{shared-BOFCKWJs.js → shared-CSwGWMcN.js} +2 -2
- package/dist/chunks/{shared-BOFCKWJs.js.map → shared-CSwGWMcN.js.map} +1 -1
- package/dist/chunks/{shared-DJ4KvhTb.js → shared-Cdwm_-Nl.js} +40 -40
- package/dist/chunks/{shared-DJ4KvhTb.js.map → shared-Cdwm_-Nl.js.map} +1 -1
- package/dist/chunks/{site-qASrdyUt.js → site-B5zrFba9.js} +2 -2
- package/dist/chunks/{site-qASrdyUt.js.map → site-B5zrFba9.js.map} +1 -1
- package/dist/chunks/{table-core-s2xjYgRD.js → table-core-ux1xEJxN.js} +2 -2
- package/dist/chunks/{table-core-s2xjYgRD.js.map → table-core-ux1xEJxN.js.map} +1 -1
- package/dist/chunks/{ui-DZuwcswv.js → ui-CpjUq_lm.js} +3 -3
- package/dist/chunks/{ui-DZuwcswv.js.map → ui-CpjUq_lm.js.map} +1 -1
- package/dist/chunks/{whatsapp-BytvTPlS.js → whatsapp-DOSZ_zwn.js} +2 -2
- package/dist/chunks/{whatsapp-BytvTPlS.js.map → whatsapp-DOSZ_zwn.js.map} +1 -1
- package/dist/chunks/{write-result-BhfLWAXf.js → write-result-DlB-id5k.js} +50 -26
- package/dist/chunks/write-result-DlB-id5k.js.map +1 -0
- package/dist/index.js +1863 -1841
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/route-BDhlro0V.js.map +0 -1
- package/dist/chunks/write-result-BhfLWAXf.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/patterns/enable/auth/creates/src/lib/components/app-sidebar.svelte?raw
|
|
2
|
-
var e = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", t = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", n = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import { displayName, type UserIdentity } from '#lib/user.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: UserIdentity & {\n id: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", r = "<script lang=\"ts\">\n import UserRoundIcon from \"@lucide/svelte/icons/user-round\";\n import * as Avatar from \"#lib/components/ui/avatar/index.js\";\n import { displayName, userInitial, type UserIdentity } from \"#lib/user.js\";\n\n let {\n user,\n class: className,\n fallbackClass,\n }: {\n /** `avatar` is the file name on the record, when one was uploaded. */\n user: (UserIdentity & { id: string; avatar?: string }) | null | undefined;\n class?: string;\n fallbackClass?: string;\n } = $props();\n\n const initial = $derived(user ? userInitial(user) : null);\n<\/script>\n\n<Avatar.Root class={className}>\n {#if user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{user.id}/{user.avatar}\"\n alt={displayName(user)}\n />\n {/if}\n <Avatar.Fallback class={fallbackClass}>\n {#if initial}\n {initial}\n {:else}\n <UserRoundIcon class=\"size-1/2\" />\n {/if}\n </Avatar.Fallback>\n</Avatar.Root>\n", i = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", a = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", o = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", s = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", c = "import { z } from \"zod\";\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n});\n\nconst oAuth2Schema = z.object({\n type: z.literal(\"oauth2\"),\n email: z.email(),\n});\n\nexport const loginSchema = z.discriminatedUnion(\"type\", [\n otpSchema,\n passwordSchema,\n oAuth2Schema,\n]);\n", l = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", u = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", d = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", f = "import { z } from \"zod\";\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nexport const signupSchema = z.discriminatedUnion(\"type\", [\n passwordSchema,\n otpSchema,\n]);\n", p = "import { z } from \"zod\";\n\n// No `.trim()`: superforms writes the parsed value back into the field as\n// you type, which would eat every space. The action trims on save.\nexport const welcomeSchema = z.object({\n name: z\n .string()\n .max(255)\n .refine((name) => name.trim() !== \"\", \"Enter your name\")\n});\n", m = "/**\n * The fields that say who a user is. Accounts made with a phone number may\n * have no email, and nobody has a name until they add one.\n */\nexport type UserIdentity = {\n name?: string;\n email?: string;\n phone?: string;\n};\n\n/** The name, else the email, else the phone number. */\nexport function displayName(user: UserIdentity): string | undefined {\n return user.name?.trim() || user.email || user.phone || undefined;\n}\n\n/**\n * The avatar letter, from the name, else the email. A phone number has no\n * useful one (\"+\"), so it gets `null` and the avatar shows an icon instead.\n */\nexport function userInitial(user: UserIdentity): string | null {\n const source = user.name?.trim() || user.email;\n return source ? Array.from(source)[0].toUpperCase() : null;\n}\n", h = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", g = "<script lang=\"ts\">\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import AppSidebar from '#lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '#lib/components/ui/breadcrumb/index.js';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", _ = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", v = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", y = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", b = "import { superValidate, fail, withFiles } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { profileSchema } from \"#lib/schemas/profile.js\";\nimport { changeEmailSchema } from \"#lib/schemas/changeEmail.js\";\nimport { changePasswordSchema } from \"#lib/schemas/changePassword.js\";\n\nexport const load = async ({ parent }) => {\n const { user } = await parent();\n\n const profileForm = await superValidate(\n {\n avatar: user.avatar,\n name: user.name,\n emailVisibility: user.emailVisibility,\n },\n zod4(profileSchema),\n );\n const emailForm = await superValidate(zod4(changeEmailSchema));\n const passwordForm = await superValidate(zod4(changePasswordSchema));\n\n return { profileForm, emailForm, passwordForm, user };\n};\n\nexport const actions = {\n updateProfile: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(profileSchema));\n\n if (!form.valid) {\n return fail(400, { profileForm: form });\n }\n\n await locals.pb\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, form.data);\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return withFiles({ profileForm: form });\n },\n changeEmail: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changeEmailSchema));\n\n if (!form.valid) {\n return fail(400, { emailForm: form });\n }\n\n await locals.pb.collection(\"users\").requestEmailChange(form.data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { emailForm: form };\n },\n changePassword: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changePasswordSchema));\n\n if (!form.valid) {\n return fail(400, { passwordForm: form });\n }\n\n await locals.admin\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, {\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { passwordForm: form };\n },\n resendVerificationEmail: async ({ locals, cookies }) => {\n // Accounts made with a phone number may have no email to verify.\n const email = locals.pb.authStore.record?.email;\n if (!email) {\n return fail(400, { message: \"Your account has no email.\" });\n }\n\n await locals.pb.collection(\"users\").requestVerification(email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return {};\n },\n};\n", x = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { changeEmailSchema } from '#lib/schemas/changeEmail.js';\n import { changePasswordSchema } from '#lib/schemas/changePassword.js';\n import { profileSchema } from '#lib/schemas/profile.js';\n import { Button, buttonVariants } from '#lib/components/ui/button/index.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { Checkbox } from '#lib/components/ui/checkbox/index.js';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import * as FileForm from '#lib/components/ui/file-form/index.js';\n\n let { data } = $props();\n\n const profileForm = superForm(\n untrack(() => data.profileForm),\n {\n validators: zod4Client(profileSchema),\n id: 'profileForm'\n }\n );\n\n const emailForm = superForm(\n untrack(() => data.emailForm),\n {\n validators: zod4Client(changeEmailSchema),\n id: 'emailForm'\n }\n );\n\n const passwordForm = superForm(\n untrack(() => data.passwordForm),\n {\n validators: zod4Client(changePasswordSchema),\n id: 'passwordForm'\n }\n );\n\n const { form: profileFormData } = profileForm;\n const { form: emailFormData } = emailForm;\n const { form: passwordFormData } = passwordForm;\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Profile</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">Your profile information.</p>\n </div>\n\n <form\n method=\"POST\"\n action=\"?/updateProfile\"\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <FileForm.Field form={profileForm} name=\"avatar\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"flex items-center gap-3 justify-between\">\n {#if !$profileFormData.avatar}\n <div class=\"flex items-center gap-3\">\n <!-- An uploaded picture shows in the file field instead -->\n <UserAvatar user={{ ...data.user, avatar: undefined }} class=\"size-16\" />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n {/if}\n <FileForm.Single>\n {#snippet display({ file, filename, onremove })}\n <div class=\"flex-1 flex gap-2 justify-between items-center\">\n <div class=\"flex items-center gap-3\">\n <FileForm.Thumb\n {file}\n {filename}\n collectionId=\"users\"\n id={data.user.id}\n class=\"w-16 h-16 object-cover rounded-full\"\n />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <Button variant=\"outline\" onclick={() => onremove(file)}>\n Remove avatar\n </Button>\n </div>\n {/snippet}\n {#snippet input()}\n <!-- Input brings w-full, h-8, padding and a border, which win over\n sr-only and leave a card-wide invisible box off the page -->\n <FileForm.Input class=\"peer sr-only size-px border-0 p-0\" {...props} />\n <Form.Label\n class=\"{buttonVariants({\n variant: 'outline'\n })} peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-ring/50\"\n >\n Upload new picture\n </Form.Label>\n {/snippet}\n </FileForm.Single>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </FileForm.Field>\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Name</Form.Label>\n <Input\n {...props}\n type=\"text\"\n autocomplete=\"name\"\n bind:value={$profileFormData.name}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n {#if data.user.email}\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"emailVisibility\" class=\"flex items-start gap-2\">\n <Form.Control>\n {#snippet children({ props })}\n <Checkbox {...props} bind:checked={$profileFormData.emailVisibility} />\n <div class=\"grid gap-2\">\n <Form.Label>Display email publicly</Form.Label>\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed publicly.\n </p>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <!-- Accounts without an email (made with a phone number) have no\n email to verify or change, and no password to log in with. -->\n {#if data.user.email}\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Email</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex flex-wrap justify-between items-center gap-3\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\">{data.user.verified ? 'Verified' : 'Unverified'}</Badge>\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form method=\"POST\" action=\"?/resendVerificationEmail\">\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: 'outline' })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form method=\"POST\" action=\"?/changeEmail\" class=\"grid gap-4\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={emailForm} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$emailFormData.email}\n required\n autocomplete=\"email\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Password</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form method=\"POST\" action=\"?/changePassword\" class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <input\n type=\"email\"\n value={data.user.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"password\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>New password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.password}\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"passwordConfirm\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm new password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.passwordConfirm}\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n {/if}\n</div>\n", S = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", C = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmEmailChangeSchema } from \"#lib/schemas/confirmEmailChange.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async () => {\n return { form: await superValidate(zod4(confirmEmailChangeSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(confirmEmailChangeSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token, form.data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", w = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmEmailChangeSchema } from '#lib/schemas/confirmEmailChange.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmEmailChangeSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description>Enter your password to confirm your email change</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", T = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", E = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", D = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmResetSchema } from \"#lib/schemas/confirmReset.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ params }) => {\n // The reset token is a JWT carrying the account email. Expose it so the\n // page can render a hidden username field for password managers.\n const { email } = getTokenPayload(params.token);\n\n return {\n form: await superValidate(zod4(confirmResetSchema)),\n email: typeof email === \"string\" ? email : null,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies }) => {\n const form = await superValidate(request, zod4(confirmResetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token,\n form.data.password,\n form.data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Password reset successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", O = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmResetSchema } from '#lib/schemas/confirmReset.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmResetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n {#if data.email}\n <input\n type=\"email\"\n value={data.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n {/if}\n\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", k = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", A = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", j = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", M = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", N = "import { fail, superValidate, message } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { loginSchema } from \"#lib/schemas/login.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n const type: \"password\" | \"otp\" | \"oauth2\" = authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\";\n\n return {\n form: await superValidate(\n zod4(loginSchema.default({ type, email: \"\", password: \"\" })),\n ),\n authMethods,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(loginSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n if (form.data.type === \"otp\") {\n const req = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email);\n return redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (form.data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n } catch (error: any) {\n // A wrong email or password is a 400. Anything else is not the\n // visitor's doing, and the page alone would not tell them apart.\n if (error.status !== 400) console.error(\"Failed to sign in:\", error);\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n },\n};\n", P = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"#lib/schemas/login.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", F = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", I = "import { describe, it, expect } from \"vitest\";\nimport * as devalue from \"devalue\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n\ndescribe(\"POST /login\", () => {\n it(\"should login with password\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n // PocketBase turns away every request that carries an expired token, so\n // the cookie must not outlive the token in it.\n it(\"should set a session cookie that expires with its token\", async (context) => {\n const response = await context.request\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n });\n const cookies: string[] = response.get(\"Set-Cookie\") ?? [];\n const session = cookies.find((cookie) => cookie.startsWith(\"pb_auth=\"));\n expect(session).toBeDefined();\n const [pair] = session!.split(\";\");\n const { token } = JSON.parse(\n decodeURIComponent(pair!.slice(\"pb_auth=\".length)),\n );\n const expires = new Date(getTokenPayload(token).exp * 1000);\n expect(session).toContain(`Expires=${expires.toUTCString()}`);\n expect(session).not.toMatch(/max-age/i);\n });\n\n it(\"should error if the password is incorrect\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"incorrect\",\n });\n const data = devalue.parse(response.body.data);\n expect(response.body.status).toBe(400);\n expect(data.form.message.text).toBe(\"Failed to authenticate.\");\n });\n});\n", L = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n redirect(303, \"/\");\n};\n", R = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", z = "import { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(otpSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies, url }) => {\n const form = await superValidate(request, zod4(otpSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token, form.data.otp);\n } catch (error: any) {\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n },\n};\n", B = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { otpSchema } from '#lib/schemas/otp.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(otpSchema)\n }\n );\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description>Enter the code sent to your email</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"otp\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>OTP code</Form.Label>\n <Input\n {...props}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n bind:value={$formData.otp}\n required\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === 'error'}\n <div class=\"text-destructive text-sm font-medium -mt-2\">{$message.text}</div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", V = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", H = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /otp/[token]\", () => {\n it(\"should throw an error if the otp is invalid\", async (context) => {\n const response = await context.agent\n .post(\"/otp/123456\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ otp: \"123456\" });\n expect(response.body.status).toBe(400);\n });\n});\n", U = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { resetSchema } from \"#lib/schemas/reset.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(resetSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(resetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb.collection(\"users\").requestPasswordReset(form.data.email);\n } catch (error) {\n // PocketBase accepts any email, with an account or not, so a failure\n // here is not the visitor's doing: log it and say so, not a 500.\n console.error(\"Failed to request a password reset:\", error);\n setFlash(\n {\n type: \"toast\",\n message: \"We could not send the reset link. Try again in a moment.\",\n },\n cookies,\n );\n return fail(400, { form });\n }\n\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { form };\n },\n};\n", W = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { resetSchema } from '#lib/schemas/reset.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(resetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your email to reset your password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", G = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", K = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /reset\", () => {\n it(\"should request a password reset\", async (context) => {\n const response = await context.agent\n .post(\"/reset\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ email: context.user.email });\n expect(response.body.status).toBe(200);\n });\n});\n", q = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { signupSchema } from \"#lib/schemas/signup.js\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const type: \"password\" | \"otp\" =\n !authMethods.password.enabled && authMethods.otp.enabled\n ? \"otp\"\n : \"password\";\n\n return {\n form: await superValidate(\n zod4(\n signupSchema.default({\n type,\n email: \"\",\n password: \"\",\n passwordConfirm: \"\",\n }),\n ),\n ),\n authMethods,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n\n if (form.data.type === \"otp\") {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password,\n passwordConfirm: password,\n });\n } catch (error: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (error.response?.data?.email?.code !== \"validation_not_unique\") {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email));\n } catch (error: any) {\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n return redirect(\n 303,\n `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`,\n );\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email!);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n", J = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"#lib/schemas/signup.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || hasOAuth2);\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field\n {form}\n name=\"passwordConfirm\"\n class=\"col-span-1\"\n >\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button\n >\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", Y = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", X = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /signup\", () => {\n it(\"should signup with password\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n it(\"should error if the password does not match\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password2\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.passwordConfirm).toBeDefined();\n expect(data.form.errors.passwordConfirm[0]).toBe(\"Values don't match.\");\n });\n\n it(\"should error if the email is already taken\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.email).toBeDefined();\n expect(data.form.errors.email[0]).toBe(\"Value must be unique.\");\n });\n\n it(\"should error if the email is invalid for a one-time code\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ type: \"otp\", email: \"not-an-email\" });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.email).toBeDefined();\n });\n});\n", Z = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { welcomeSchema } from \"#lib/schemas/welcome.js\";\nimport { redirect } from \"@sveltejs/kit\";\n\n/**\n * Where to go next. Follows only a same-site path (`/x`, not `//host` or\n * `/\\host`): `redirect()` throws on an external URL.\n */\nfunction nextUrl(url: URL) {\n const next = url.searchParams.get(\"redirect\");\n return next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n}\n\n// Accounts made with a one-time code start without a name, so signup sends\n// them here once the code checks out, to pick the name the app shows.\nexport const load = async ({ locals, url }) => {\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n if (locals.pb.authStore.record?.name) {\n redirect(303, nextUrl(url));\n }\n\n return { form: await superValidate(zod4(welcomeSchema)), next: nextUrl(url) };\n};\n\nexport const actions = {\n default: async ({ locals, request, url }) => {\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n\n const form = await superValidate(request, zod4(welcomeSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.pb\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, { name: form.data.name.trim() });\n\n redirect(303, nextUrl(url));\n },\n};\n", Q = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { welcomeSchema } from '#lib/schemas/welcome.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(welcomeSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome!</Card.Title>\n <Card.Description>What should we call you?</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"name\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Name</Form.Label>\n <Input\n {...props}\n type=\"text\"\n autocomplete=\"name\"\n bind:value={$formData.name}\n required\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Continue</Button>\n <Button href={data.next} variant=\"ghost\" class=\"w-full\">Skip for now</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", $ = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Welcome'\n });\n\n return { ...data, pageMetaTags };\n};\n", ee = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /welcome\", () => {\n it(\"should redirect a signed out visitor to login\", async (context) => {\n const response = await context.request.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/login\");\n });\n\n it(\"should ask a signed in user for their name\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /welcome\", () => {\n it(\"should save the name and follow the redirect\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent\n .post(\"/welcome\" satisfies Match<RouteId>)\n .query({ redirect: \"/settings\" })\n .type(\"form\")\n .send({ name: \" Ada Lovelace \" });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/settings\");\n\n const user = await context.admin.collection(\"users\").getOne(context.user.id);\n expect(user.name).toBe(\"Ada Lovelace\");\n });\n\n it(\"should not save a blank name\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent\n .post(\"/welcome\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ name: \" \" });\n expect(response.body.status).toBe(400);\n });\n});\n", te = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"#lib/schemas/login.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Welcome back</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a login method\"\n : \"Use your email to login\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Login is disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for login options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n</div>\n", ne = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"#lib/schemas/signup.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || hasOAuth2);\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Create an account</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a sign up method\"\n : \"Use your email to sign up\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Signups are disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for signup options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field\n {form}\n name=\"passwordConfirm\"\n class=\"col-span-1\"\n >\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n</div>\n", re = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", ie = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", ae = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import { displayName, type UserIdentity } from '#lib/user.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: UserIdentity & {\n id: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n {#if user.name}\n <span class=\"truncate text-xs\">{user.email || user.phone}</span>\n {/if}\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n {#if user.name}\n <span class=\"truncate text-xs\">{user.email || user.phone}</span>\n {/if}\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", oe = "<script lang=\"ts\">\n import UserRoundIcon from \"@lucide/svelte/icons/user-round\";\n import * as Avatar from \"#lib/components/ui/avatar/index.js\";\n import { displayName, userInitial, type UserIdentity } from \"#lib/user.js\";\n\n let {\n user,\n class: className,\n fallbackClass,\n }: {\n /** `avatar` is the file name on the record, when one was uploaded. */\n user: (UserIdentity & { id: string; avatar?: string }) | null | undefined;\n class?: string;\n fallbackClass?: string;\n } = $props();\n\n const initial = $derived(user ? userInitial(user) : null);\n<\/script>\n\n<Avatar.Root class={className}>\n {#if user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{user.id}/{user.avatar}\"\n alt={displayName(user)}\n />\n {/if}\n <Avatar.Fallback class={fallbackClass}>\n {#if initial}\n {initial}\n {:else}\n <UserRoundIcon class=\"size-1/2\" />\n {/if}\n </Avatar.Fallback>\n</Avatar.Root>\n", se = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", ce = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", le = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", ue = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", de = "import { z } from \"zod\";\n\n// A flat shape (rather than a discriminated union) keeps\n// `loginForm.fields.password` addressable in the page regardless of mode.\nexport const loginSchema = z\n .object({\n type: z.enum([\"password\", \"otp\", \"oauth2\"]),\n email: z.email(),\n password: z.string().optional(),\n })\n .refine((data) => data.type !== \"password\" || !!data.password, {\n message: \"Password is required\",\n path: [\"password\"],\n });\n", fe = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", pe = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", me = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", he = "import { z } from \"zod\";\n\n// Flat, like the login schema, so every field stays addressable in the page.\nexport const signupSchema = z\n .object({\n type: z.enum([\"password\", \"otp\"]),\n email: z.email(),\n password: z.string().optional(),\n passwordConfirm: z.string().optional(),\n })\n .refine((data) => data.type !== \"password\" || !!data.password, {\n message: \"Password is required\",\n path: [\"password\"],\n });\n", ge = "import { z } from \"zod\";\n\n// Same as enable-auth's, where a `.trim()` would eat spaces as you type\n// (superforms writes the parsed value back). The form handler trims on save.\nexport const welcomeSchema = z.object({\n name: z\n .string()\n .max(255)\n .refine((name) => name.trim() !== \"\", \"Enter your name\")\n});\n", _e = "/**\n * The fields that say who a user is. Accounts made with a phone number may\n * have no email, and nobody has a name until they add one.\n */\nexport type UserIdentity = {\n name?: string;\n email?: string;\n phone?: string;\n};\n\n/** The name, else the email, else the phone number. */\nexport function displayName(user: UserIdentity): string | undefined {\n return user.name?.trim() || user.email || user.phone || undefined;\n}\n\n/**\n * The avatar letter, from the name, else the email. A phone number has no\n * useful one (\"+\"), so it gets `null` and the avatar shows an icon instead.\n */\nexport function userInitial(user: UserIdentity): string | null {\n const source = user.name?.trim() || user.email;\n return source ? Array.from(source)[0].toUpperCase() : null;\n}\n", ve = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", ye = "<script lang=\"ts\">\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import AppSidebar from '#lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '#lib/components/ui/breadcrumb/index.js';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", be = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", xe = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Se = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", Ce = "export const load = async ({ parent }) => {\n const { user } = await parent();\n\n return { user };\n};\n", we = "<script lang=\"ts\">\n import { Button, buttonVariants } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { Badge } from \"#lib/components/ui/badge/index.js\";\n import * as Dialog from \"#lib/components/ui/dialog/index.js\";\n import { Checkbox } from \"#lib/components/ui/checkbox/index.js\";\n import UserAvatar from \"#lib/components/user-avatar.svelte\";\n import {\n updateProfileForm,\n changeEmailForm,\n changePasswordForm,\n resendVerificationForm,\n } from \"./form.remote\";\n\n let { data } = $props();\n\n // The profile fields start from the saved values, passed to \\`.as()\\`: a\n // field left alone is then posted back as it was, and the form goes back\n // to what was saved when it resets after a save.\n\n // bits-ui's Checkbox renders a <button>, so drop the native type=\"checkbox\"\n // from the field props before spreading them.\n const emailVisibilityProps = $derived.by(() => {\n const { type, ...props } = updateProfileForm.fields.emailVisibility.as(\n \"checkbox\",\n data.user.emailVisibility,\n );\n return props;\n });\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Profile\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your profile information.\n </p>\n </div>\n\n <form\n {...updateProfileForm}\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex items-center gap-3 justify-between\">\n <div class=\"flex items-center gap-3\">\n <UserAvatar user={data.user} class=\"size-16\" />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <label\n class=\"{buttonVariants({\n variant: 'outline',\n })} has-focus-visible:border-ring has-focus-visible:ring-3 has-focus-visible:ring-ring/50\"\n >\n Upload new picture\n <input\n {...updateProfileForm.fields.avatar.as(\"file\")}\n type=\"file\"\n class=\"sr-only\"\n />\n </label>\n </div>\n {#each updateProfileForm.fields.avatar.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"name\" class=\"text-sm font-medium\">Name</label>\n <Input\n id=\"name\"\n {...updateProfileForm.fields.name.as(\"text\", data.user.name)}\n type=\"text\"\n autocomplete=\"name\"\n />\n {#each updateProfileForm.fields.name.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n {#if data.user.email}\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <div class=\"flex items-start gap-2\">\n <Checkbox id=\"emailVisibility\" {...emailVisibilityProps} />\n <div class=\"grid gap-2\">\n <label\n for=\"emailVisibility\"\n class=\"text-sm font-medium leading-none\"\n >Display email publicly</label\n >\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed\n publicly.\n </p>\n </div>\n </div>\n {#each updateProfileForm.fields.emailVisibility.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <!-- Accounts without an email (made with a phone number) have no\n email to verify or change, and no password to log in with. -->\n {#if data.user.email}\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Email\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex flex-wrap justify-between items-center gap-3\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\"\n >{data.user.verified ? \"Verified\" : \"Unverified\"}</Badge\n >\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form {...resendVerificationForm}>\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: \"outline\" })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a\n verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form {...changeEmailForm} class=\"grid gap-4\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"email\" class=\"text-sm font-medium\"\n >Email</label\n >\n <Input\n id=\"email\"\n {...changeEmailForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"email\"\n />\n {#each changeEmailForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Password\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form {...changePasswordForm} class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <input\n type=\"email\"\n value={data.user.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >New password</label\n >\n <Input\n id=\"password\"\n {...changePasswordForm.fields.password.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {#each changePasswordForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n <div class=\"grid gap-3\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm new password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...changePasswordForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {#each changePasswordForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n {/if}\n</div>\n", Te = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ee = "import { form, getRequestEvent } from \"$app/server\";\nimport { error } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { profileSchema } from \"#lib/schemas/profile.js\";\nimport { changeEmailSchema } from \"#lib/schemas/changeEmail.js\";\nimport { changePasswordSchema } from \"#lib/schemas/changePassword.js\";\n\nexport const updateProfileForm = form(profileSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n const user = locals.pb.authStore.record!;\n\n await locals.pb.collection(\"users\").update(user.id, {\n name: data.name,\n // No file chosen: `undefined`, which leaves the saved avatar alone.\n avatar: data.avatar,\n // An unticked checkbox posts nothing at all, so absent means \"off\". The\n // box is only shown to accounts with an email; the others keep theirs.\n ...(user.email ? { emailVisibility: data.emailVisibility ?? false } : {}),\n });\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const changeEmailForm = form(changeEmailSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").requestEmailChange(data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { success: true };\n});\n\nexport const changePasswordForm = form(changePasswordSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, {\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const resendVerificationForm = form(async () => {\n const { locals, cookies } = getRequestEvent();\n // Accounts made with a phone number may have no email to verify.\n const email = locals.pb.authStore.record?.email;\n if (!email) {\n error(400, \"Your account has no email.\");\n }\n\n await locals.pb.collection(\"users\").requestVerification(email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return { success: true };\n});\n", De = "export const load = async () => {\n return {};\n};\n", Oe = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { confirmEmailChangeForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description\n >Enter your password to confirm your email change</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...confirmEmailChangeForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmEmailChangeForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n autofocus\n />\n {#each confirmEmailChangeForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", ke = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ae = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmEmailChangeSchema } from \"#lib/schemas/confirmEmailChange.js\";\n\nexport const confirmEmailChangeForm = form(\n confirmEmailChangeSchema,\n async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token as string, data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n redirect(303, \"/login\");\n },\n);\n", je = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Me = "import { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ params }) => {\n // The reset token is a JWT carrying the account email. Expose it so the\n // page can render a hidden username field for password managers.\n const { email } = getTokenPayload(params.token);\n\n return { email: typeof email === \"string\" ? email : null };\n};\n", Ne = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { confirmResetForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form {...confirmResetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n {#if data.email}\n <input\n type=\"email\"\n value={data.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n {/if}\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmResetForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n autofocus\n />\n {#each confirmResetForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...confirmResetForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each confirmResetForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Pe = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", Fe = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmResetSchema } from \"#lib/schemas/confirmReset.js\";\n\nexport const confirmResetForm = form(confirmResetSchema, async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token as string,\n data.password,\n data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash({ type: \"toast\", message: \"Password reset successfully.\" }, cookies);\n redirect(303, \"/login\");\n});\n", Ie = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Le = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", Re = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", ze = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n return { authMethods };\n};\n", Be = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { loginForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const initialType: \"password\" | \"otp\" | \"oauth2\" = $derived(\n authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\",\n );\n let mode = $state<\"password\" | \"otp\" | \"oauth2\">(\"password\");\n $effect(() => {\n mode = initialType;\n });\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...loginForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...loginForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each loginForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if mode === \"password\" && authMethods.password.enabled}\n <div class=\"space-y-2 col-span-1\">\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...loginForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {#each loginForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if loginForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {loginForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"otp\")}\n type=\"button\"\n >Use one-time code instead</Button\n >\n {/if}\n {:else if mode === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"password\")}\n type=\"button\"\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input {...loginForm.fields.type.as(\"hidden\", mode)} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", Ve = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", He = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { loginSchema } from \"#lib/schemas/login.js\";\n\nexport const loginForm = form(loginSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n if (data.type === \"otp\") {\n const req = await locals.pb.collection(\"users\").requestOTP(data.email);\n redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(data.email, data.password ?? \"\");\n } catch (err: any) {\n // A wrong email or password is a 400. Anything else is not the\n // visitor's doing, and the page alone would not tell them apart.\n if (err.status !== 400) console.error(\"Failed to sign in:\", err);\n return {\n message: (err.response?.message as string) ?? \"Failed to authenticate.\",\n };\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n});\n", Ue = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n", We = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n redirect(303, \"/\");\n};\n", Ge = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", Ke = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", qe = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { otpForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description\n >Enter the code sent to your email</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...otpForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"otp\" class=\"text-sm font-medium\">OTP code</label>\n <Input\n id=\"otp\"\n {...otpForm.fields.otp.as(\"text\")}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n required\n autofocus\n />\n {#each otpForm.fields.otp.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if otpForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {otpForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Je = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ye = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\n\nexport const otpForm = form(otpSchema, async (data) => {\n const { locals, cookies, params, url } = getRequestEvent();\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token as string, data.otp);\n } catch (err: any) {\n return {\n message: (err.response?.message as string) ?? \"Failed to verify code.\",\n };\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n});\n", Xe = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ze = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", Qe = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { resetForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description\n >Enter your email to reset your password</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...resetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...resetForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each resetForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", $e = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", et = "import { form, getRequestEvent } from \"$app/server\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { resetSchema } from \"#lib/schemas/reset.js\";\n\nexport const resetForm = form(resetSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n try {\n await locals.pb.collection(\"users\").requestPasswordReset(data.email);\n } catch (err) {\n // PocketBase accepts any email, with an account or not, so a failure\n // here is not the visitor's doing: log it and say so, not a 500.\n console.error(\"Failed to request a password reset:\", err);\n setFlash(\n {\n type: \"toast\",\n message: \"We could not send the reset link. Try again in a moment.\",\n },\n cookies,\n );\n return { success: false };\n }\n\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { success: true };\n});\n", tt = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", nt = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { authMethods };\n};\n", rt = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { signupForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || hasOAuth2);\n\n type Mode = \"password\" | \"otp\";\n const initialType: Mode = $derived(\n !authMethods.password.enabled && authMethods.otp.enabled\n ? \"otp\"\n : \"password\",\n );\n let mode = $state<Mode>(\"password\");\n $effect(() => {\n mode = initialType;\n });\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...signupForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\"\n >Email</label\n >\n <Input\n id=\"email\"\n {...signupForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each signupForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if mode === \"password\" && authMethods.password.enabled}\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...signupForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each signupForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">\n {issue.message}\n </p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...signupForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each signupForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">\n {issue.message}\n </p>\n {/each}\n </div>\n\n {#if signupForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {signupForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Create account</Button\n >\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"otp\")}\n type=\"button\"\n >Use one-time code instead</Button\n >\n {/if}\n {:else if mode === \"otp\" && authMethods.otp.enabled}\n {#if signupForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {signupForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"password\")}\n type=\"button\"\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input {...signupForm.fields.type.as(\"hidden\", mode)} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", it = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", at = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { signupSchema } from \"#lib/schemas/signup.js\";\n\n/** The first field error, or the response message, of a PocketBase error. */\nfunction errorMessage(err: any, fallback: string): string {\n const response = err?.response ?? {};\n const fieldError = response?.data\n ? Object.values(response.data)[0]\n : undefined;\n return (fieldError as any)?.message ?? response?.message ?? fallback;\n}\n\nexport const signupForm = form(signupSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n\n const { email } = data;\n\n if (data.type === \"otp\") {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n } catch (err: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (err?.response?.data?.email?.code !== \"validation_not_unique\") {\n return { message: errorMessage(err, \"Failed to create account.\") };\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb.collection(\"users\").requestOTP(email));\n } catch (err: any) {\n return { message: errorMessage(err, \"Failed to send the code.\") };\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n redirect(303, `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`);\n }\n\n try {\n await locals.admin.collection(\"users\").create({\n email,\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n } catch (err: any) {\n return { message: errorMessage(err, \"Failed to create account.\") };\n }\n\n await locals.pb.collection(\"users\").requestVerification(email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(email, data.password ?? \"\");\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n redirect(303, redirectUrl);\n});\n", ot = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", st = "import { redirect } from \"@sveltejs/kit\";\nimport { nextUrl } from \"./next-url\";\n\n// Accounts made with a one-time code start without a name, so signup sends\n// them here once the code checks out, to pick the name the app shows.\nexport const load = async ({ locals, url }) => {\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n if (locals.pb.authStore.record?.name) {\n redirect(303, nextUrl(url));\n }\n\n return { next: nextUrl(url) };\n};\n", ct = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { welcomeForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome!</Card.Title>\n <Card.Description>What should we call you?</Card.Description>\n </Card.Header>\n <Card.Content>\n <form {...welcomeForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"name\" class=\"text-sm font-medium\">Name</label>\n <Input\n id=\"name\"\n {...welcomeForm.fields.name.as(\"text\")}\n autocomplete=\"name\"\n required\n autofocus\n />\n {#each welcomeForm.fields.name.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Continue</Button>\n <Button href={data.next} variant=\"ghost\" class=\"w-full\"\n >Skip for now</Button\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", lt = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Welcome'\n });\n\n return { ...data, pageMetaTags };\n};\n", ut = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { welcomeSchema } from \"#lib/schemas/welcome.js\";\nimport { nextUrl } from \"./next-url\";\n\nexport const welcomeForm = form(welcomeSchema, async (data) => {\n const { locals, url } = getRequestEvent();\n\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n\n await locals.pb\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, { name: data.name.trim() });\n\n redirect(303, nextUrl(url));\n});\n", dt = "/**\n * Where to go after the name step. Follows only a same-site path (`/x`, not\n * `//host` or `/\\host`): `redirect()` throws on an external URL.\n */\nexport function nextUrl(url: URL) {\n const next = url.searchParams.get(\"redirect\");\n return next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n}\n", ft = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /welcome\", () => {\n it(\"should redirect a signed out visitor to login\", async (context) => {\n const response = await context.request.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/login\");\n });\n\n it(\"should ask a signed in user for their name\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", pt = "import { z } from \"zod\";\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n});\n\nconst oAuth2Schema = z.object({\n type: z.literal(\"oauth2\"),\n email: z.email(),\n});\n\nconst whatsappSchema = z.object({\n type: z.literal(\"whatsapp\"),\n phone: z.string().min(1),\n});\n\nexport const loginSchema = z.discriminatedUnion(\"type\", [\n otpSchema,\n passwordSchema,\n oAuth2Schema,\n whatsappSchema,\n]);\n", mt = "import { z } from \"zod\";\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst whatsappSchema = z.object({\n type: z.literal(\"whatsapp\"),\n phone: z.string().min(1),\n});\n\nexport const signupSchema = z.discriminatedUnion(\"type\", [\n passwordSchema,\n otpSchema,\n whatsappSchema,\n]);\n", ht = "import { fail, superValidate, message } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { loginSchema } from \"#lib/schemas/login.js\";\nimport {\n requestWhatsAppOTP,\n whatsappAuthMethod,\n} from \"#lib/server/whatsapp.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n const whatsapp = whatsappAuthMethod(authMethods);\n\n const type: \"password\" | \"otp\" | \"oauth2\" | \"whatsapp\" = authMethods.otp\n .enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : whatsapp.enabled\n ? \"whatsapp\"\n : \"oauth2\";\n\n return {\n form: await superValidate(\n zod4(\n loginSchema.default({ type, email: \"\", password: \"\", phone: \"\" }),\n ),\n ),\n authMethods,\n whatsapp,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(loginSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n if (form.data.type === \"otp\") {\n const req = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email);\n return redirect(303, `/otp/${req.otpId}${redirectQuery}`);\n } else if (form.data.type === \"whatsapp\") {\n let otpId: string;\n try {\n ({ otpId } = await requestWhatsAppOTP(locals.pb, form.data.phone));\n } catch (error: any) {\n // An invalid number goes on the field; the rest (WhatsApp auth\n // disabled, rate limited) on the form.\n if (Object.keys(error.response?.data ?? {}).length) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n return redirect(303, `/whatsapp/${otpId}${redirectQuery}`);\n } else if (form.data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n } catch (error: any) {\n // A wrong email or password is a 400. Anything else is not the\n // visitor's doing, and the page alone would not tell them apart.\n if (error.status !== 400) console.error(\"Failed to sign in:\", error);\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n },\n};\n", gt = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"#lib/schemas/login.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n let whatsapp = $derived(data.whatsapp);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || whatsapp.enabled || hasOAuth2);\n // Where \"Continue with email\" goes back to from WhatsApp.\n const emailType = $derived(authMethods.otp.enabled ? \"otp\" : \"password\");\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2 || (hasEmail && whatsapp.enabled)}\n <Card.Description>Choose a login method</Card.Description>\n {:else if whatsapp.enabled}\n <Card.Description\n >Use your WhatsApp number to login</Card.Description\n >\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail || whatsapp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n {#if $formData.type === \"whatsapp\" && whatsapp.enabled}\n <Form.Field {form} name=\"phone\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>WhatsApp number</Form.Label>\n <Input\n {...props}\n type=\"tel\"\n bind:value={$formData.phone}\n required\n autocomplete=\"tel\"\n placeholder=\"+1 616 555 0123\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send code on WhatsApp</Button\n >\n {#if hasEmail}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = emailType as \"whatsapp\")}\n >Continue with email</Button\n >\n {/if}\n {:else if hasEmail && $formData.type !== \"whatsapp\"}\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n\n {#if whatsapp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = \"whatsapp\" as \"password\")}\n >Continue with WhatsApp</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", _t = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { signupSchema } from \"#lib/schemas/signup.js\";\nimport {\n requestWhatsAppOTP,\n whatsappAuthMethod,\n} from \"#lib/server/whatsapp.js\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const whatsapp = whatsappAuthMethod(authMethods);\n const whatsappSignup = whatsapp.enabled && whatsapp.allowSignup === true;\n\n const type: \"password\" | \"otp\" | \"whatsapp\" = authMethods.password.enabled\n ? \"password\"\n : authMethods.otp.enabled\n ? \"otp\"\n : whatsappSignup\n ? \"whatsapp\"\n : \"password\";\n\n return {\n form: await superValidate(\n zod4(\n signupSchema.default({\n type,\n email: \"\",\n password: \"\",\n passwordConfirm: \"\",\n phone: \"\",\n }),\n ),\n ),\n authMethods,\n whatsappSignup,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n\n if (form.data.type === \"whatsapp\") {\n // The account is created when the code is checked.\n let otpId: string;\n try {\n ({ otpId } = await requestWhatsAppOTP(locals.pb, form.data.phone));\n } catch (error: any) {\n // An invalid number goes on the field; the rest (WhatsApp auth\n // disabled, rate limited) on the form.\n if (Object.keys(error.response?.data ?? {}).length) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n return redirect(303, `/whatsapp/${otpId}${redirectQuery}`);\n }\n\n if (form.data.type === \"otp\") {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password,\n passwordConfirm: password,\n });\n } catch (error: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (error.response?.data?.email?.code !== \"validation_not_unique\") {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email));\n } catch (error: any) {\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n return redirect(\n 303,\n `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`,\n );\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email!);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n", vt = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"#lib/schemas/signup.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n let whatsappSignup = $derived(data.whatsappSignup);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || whatsappSignup || hasOAuth2);\n // Where \"Continue with email\" goes back to from WhatsApp.\n const emailType = $derived(\n authMethods.password.enabled ? \"password\" : \"otp\",\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2 || (hasEmail && whatsappSignup)}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else if whatsappSignup}\n <Card.Description\n >Use your WhatsApp number to sign up</Card.Description\n >\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail || whatsappSignup}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n {#if $formData.type === \"whatsapp\" && whatsappSignup}\n <Form.Field {form} name=\"phone\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>WhatsApp number</Form.Label>\n <Input\n {...props}\n type=\"tel\"\n bind:value={$formData.phone}\n required\n autocomplete=\"tel\"\n placeholder=\"+1 616 555 0123\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send code on WhatsApp</Button\n >\n {#if hasEmail}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = emailType as \"whatsapp\")}\n >Continue with email</Button\n >\n {/if}\n {:else if hasEmail && $formData.type !== \"whatsapp\"}\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field\n {form}\n name=\"passwordConfirm\"\n class=\"col-span-1\"\n >\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button\n >\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n\n {#if whatsappSignup}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = \"whatsapp\" as \"password\")}\n >Continue with WhatsApp</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n";
|
|
2
|
+
var e = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", t = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", n = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import { displayName, type UserIdentity } from '#lib/user.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: UserIdentity & {\n id: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", r = "<script lang=\"ts\">\n import UserRoundIcon from \"@lucide/svelte/icons/user-round\";\n import * as Avatar from \"#lib/components/ui/avatar/index.js\";\n import { displayName, userInitial, type UserIdentity } from \"#lib/user.js\";\n\n let {\n user,\n class: className,\n fallbackClass,\n }: {\n /** `avatar` is the file name on the record, when one was uploaded. */\n user: (UserIdentity & { id: string; avatar?: string }) | null | undefined;\n class?: string;\n fallbackClass?: string;\n } = $props();\n\n const initial = $derived(user ? userInitial(user) : null);\n<\/script>\n\n<Avatar.Root class={className}>\n {#if user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{user.id}/{user.avatar}\"\n alt={displayName(user)}\n />\n {/if}\n <Avatar.Fallback class={fallbackClass}>\n {#if initial}\n {initial}\n {:else}\n <UserRoundIcon class=\"size-1/2\" />\n {/if}\n </Avatar.Fallback>\n</Avatar.Root>\n", i = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", a = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", o = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", s = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", c = "import { z } from \"zod\";\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n});\n\nconst oAuth2Schema = z.object({\n type: z.literal(\"oauth2\"),\n email: z.email(),\n});\n\nexport const loginSchema = z.discriminatedUnion(\"type\", [\n otpSchema,\n passwordSchema,\n oAuth2Schema,\n]);\n", l = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", u = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", d = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", f = "import { z } from \"zod\";\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nexport const signupSchema = z.discriminatedUnion(\"type\", [\n passwordSchema,\n otpSchema,\n]);\n", p = "import { z } from \"zod\";\n\n// No `.trim()`: superforms writes the parsed value back into the field as\n// you type, which would eat every space. The action trims on save.\nexport const welcomeSchema = z.object({\n name: z\n .string()\n .max(255)\n .refine((name) => name.trim() !== \"\", \"Enter your name\")\n});\n", m = "/**\n * The fields that say who a user is. Accounts made with a phone number may\n * have no email, and nobody has a name until they add one.\n */\nexport type UserIdentity = {\n name?: string;\n email?: string;\n phone?: string;\n};\n\n/** The name, else the email, else the phone number. */\nexport function displayName(user: UserIdentity): string | undefined {\n return user.name?.trim() || user.email || user.phone || undefined;\n}\n\n/**\n * The avatar letter, from the name, else the email. A phone number has no\n * useful one (\"+\"), so it gets `null` and the avatar shows an icon instead.\n */\nexport function userInitial(user: UserIdentity): string | null {\n const source = user.name?.trim() || user.email;\n return source ? Array.from(source)[0].toUpperCase() : null;\n}\n", h = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", g = "<script lang=\"ts\">\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import AppSidebar from '#lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '#lib/components/ui/breadcrumb/index.js';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", _ = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", v = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", y = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", b = "import { superValidate, fail, withFiles } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { profileSchema } from \"#lib/schemas/profile.js\";\nimport { changeEmailSchema } from \"#lib/schemas/changeEmail.js\";\nimport { changePasswordSchema } from \"#lib/schemas/changePassword.js\";\n\nexport const load = async ({ parent }) => {\n const { user } = await parent();\n\n const profileForm = await superValidate(\n {\n avatar: user.avatar,\n name: user.name,\n emailVisibility: user.emailVisibility,\n },\n zod4(profileSchema),\n );\n const emailForm = await superValidate(zod4(changeEmailSchema));\n const passwordForm = await superValidate(zod4(changePasswordSchema));\n\n return { profileForm, emailForm, passwordForm, user };\n};\n\nexport const actions = {\n updateProfile: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(profileSchema));\n\n if (!form.valid) {\n return fail(400, { profileForm: form });\n }\n\n await locals.pb\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, form.data);\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return withFiles({ profileForm: form });\n },\n changeEmail: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changeEmailSchema));\n\n if (!form.valid) {\n return fail(400, { emailForm: form });\n }\n\n await locals.pb.collection(\"users\").requestEmailChange(form.data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { emailForm: form };\n },\n changePassword: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(changePasswordSchema));\n\n if (!form.valid) {\n return fail(400, { passwordForm: form });\n }\n\n await locals.admin\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, {\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { passwordForm: form };\n },\n resendVerificationEmail: async ({ locals, cookies }) => {\n // Accounts made with a phone number may have no email to verify.\n const email = locals.pb.authStore.record?.email;\n if (!email) {\n return fail(400, { message: \"Your account has no email.\" });\n }\n\n await locals.pb.collection(\"users\").requestVerification(email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return {};\n },\n};\n", x = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { changeEmailSchema } from '#lib/schemas/changeEmail.js';\n import { changePasswordSchema } from '#lib/schemas/changePassword.js';\n import { profileSchema } from '#lib/schemas/profile.js';\n import { Button, buttonVariants } from '#lib/components/ui/button/index.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { Checkbox } from '#lib/components/ui/checkbox/index.js';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import * as FileForm from '#lib/components/ui/file-form/index.js';\n\n let { data } = $props();\n\n const profileForm = superForm(\n untrack(() => data.profileForm),\n {\n validators: zod4Client(profileSchema),\n id: 'profileForm'\n }\n );\n\n const emailForm = superForm(\n untrack(() => data.emailForm),\n {\n validators: zod4Client(changeEmailSchema),\n id: 'emailForm'\n }\n );\n\n const passwordForm = superForm(\n untrack(() => data.passwordForm),\n {\n validators: zod4Client(changePasswordSchema),\n id: 'passwordForm'\n }\n );\n\n const { form: profileFormData } = profileForm;\n const { form: emailFormData } = emailForm;\n const { form: passwordFormData } = passwordForm;\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Profile</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">Your profile information.</p>\n </div>\n\n <form\n method=\"POST\"\n action=\"?/updateProfile\"\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <FileForm.Field form={profileForm} name=\"avatar\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"flex items-center gap-3 justify-between\">\n {#if !$profileFormData.avatar}\n <div class=\"flex items-center gap-3\">\n <!-- An uploaded picture shows in the file field instead -->\n <UserAvatar user={{ ...data.user, avatar: undefined }} class=\"size-16\" />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n {/if}\n <FileForm.Single>\n {#snippet display({ file, filename, onremove })}\n <div class=\"flex-1 flex gap-2 justify-between items-center\">\n <div class=\"flex items-center gap-3\">\n <FileForm.Thumb\n {file}\n {filename}\n collectionId=\"users\"\n id={data.user.id}\n class=\"w-16 h-16 object-cover rounded-full\"\n />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <Button variant=\"outline\" onclick={() => onremove(file)}>\n Remove avatar\n </Button>\n </div>\n {/snippet}\n {#snippet input()}\n <!-- Input brings w-full, h-8, padding and a border, which win over\n sr-only and leave a card-wide invisible box off the page -->\n <FileForm.Input class=\"peer sr-only size-px border-0 p-0\" {...props} />\n <Form.Label\n class=\"{buttonVariants({\n variant: 'outline'\n })} peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-ring/50\"\n >\n Upload new picture\n </Form.Label>\n {/snippet}\n </FileForm.Single>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </FileForm.Field>\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Name</Form.Label>\n <Input\n {...props}\n type=\"text\"\n autocomplete=\"name\"\n bind:value={$profileFormData.name}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n {#if data.user.email}\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={profileForm} name=\"emailVisibility\" class=\"flex items-start gap-2\">\n <Form.Control>\n {#snippet children({ props })}\n <Checkbox {...props} bind:checked={$profileFormData.emailVisibility} />\n <div class=\"grid gap-2\">\n <Form.Label>Display email publicly</Form.Label>\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed publicly.\n </p>\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <!-- Accounts without an email (made with a phone number) have no\n email to verify or change, and no password to log in with. -->\n {#if data.user.email}\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Email</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex flex-wrap justify-between items-center gap-3\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\">{data.user.verified ? 'Verified' : 'Unverified'}</Badge>\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form method=\"POST\" action=\"?/resendVerificationEmail\">\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: 'outline' })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form method=\"POST\" action=\"?/changeEmail\" class=\"grid gap-4\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={emailForm} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$emailFormData.email}\n required\n autocomplete=\"email\"\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Password</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form method=\"POST\" action=\"?/changePassword\" class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <input\n type=\"email\"\n value={data.user.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"password\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>New password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.password}\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n <div class=\"grid gap-3\">\n <Form.Field form={passwordForm} name=\"passwordConfirm\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm new password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$passwordFormData.passwordConfirm}\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n {/if}\n</div>\n", S = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", C = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmEmailChangeSchema } from \"#lib/schemas/confirmEmailChange.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async () => {\n return { form: await superValidate(zod4(confirmEmailChangeSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(confirmEmailChangeSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token, form.data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", w = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmEmailChangeSchema } from '#lib/schemas/confirmEmailChange.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmEmailChangeSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description>Enter your password to confirm your email change</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", T = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", E = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", D = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { confirmResetSchema } from \"#lib/schemas/confirmReset.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ params }) => {\n // The reset token is a JWT carrying the account email. Expose it so the\n // page can render a hidden username field for password managers.\n const { email } = getTokenPayload(params.token);\n\n return {\n form: await superValidate(zod4(confirmResetSchema)),\n email: typeof email === \"string\" ? email : null,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies }) => {\n const form = await superValidate(request, zod4(confirmResetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token,\n form.data.password,\n form.data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Password reset successfully.\" },\n cookies,\n );\n return redirect(303, \"/login\");\n },\n};\n", O = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { confirmResetSchema } from '#lib/schemas/confirmReset.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(confirmResetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n {#if data.email}\n <input\n type=\"email\"\n value={data.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n {/if}\n\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field {form} name=\"passwordConfirm\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", k = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", A = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", j = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", M = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", N = "import { fail, superValidate, message } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { loginSchema } from \"#lib/schemas/login.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n const type: \"password\" | \"otp\" | \"oauth2\" = authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\";\n\n return {\n form: await superValidate(\n zod4(loginSchema.default({ type, email: \"\", password: \"\" })),\n ),\n authMethods,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(loginSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n if (form.data.type === \"otp\") {\n const req = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email);\n return redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (form.data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n } catch (error: any) {\n // A wrong email or password is a 400. Anything else is not the\n // visitor's doing, and the page alone would not tell them apart.\n if (error.status !== 400) console.error(\"Failed to sign in:\", error);\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n },\n};\n", P = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"#lib/schemas/login.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", F = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", I = "import { describe, it, expect } from \"vitest\";\nimport * as devalue from \"devalue\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n\ndescribe(\"POST /login\", () => {\n it(\"should login with password\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n // PocketBase turns away every request that carries an expired token, so\n // the cookie must not outlive the token in it.\n it(\"should set a session cookie that expires with its token\", async (context) => {\n const response = await context.request\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n });\n const cookies: string[] = response.get(\"Set-Cookie\") ?? [];\n const session = cookies.find((cookie) => cookie.startsWith(\"pb_auth=\"));\n expect(session).toBeDefined();\n const [pair] = session!.split(\";\");\n const { token } = JSON.parse(\n decodeURIComponent(pair!.slice(\"pb_auth=\".length)),\n );\n const expires = new Date(getTokenPayload(token).exp * 1000);\n expect(session).toContain(`Expires=${expires.toUTCString()}`);\n expect(session).not.toMatch(/max-age/i);\n });\n\n it(\"should error if the password is incorrect\", async (context) => {\n const response = await context.agent\n .post(\"/login\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"incorrect\",\n });\n const data = devalue.parse(response.body.data);\n expect(response.body.status).toBe(400);\n expect(data.form.message.text).toBe(\"Failed to authenticate.\");\n });\n});\n", L = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n redirect(303, \"/\");\n};\n", R = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", z = "import { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(otpSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies, url }) => {\n const form = await superValidate(request, zod4(otpSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token, form.data.otp);\n } catch (error: any) {\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n },\n};\n", B = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { otpSchema } from '#lib/schemas/otp.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(otpSchema)\n }\n );\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description>Enter the code sent to your email</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"otp\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>OTP code</Form.Label>\n <Input\n {...props}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n bind:value={$formData.otp}\n required\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === 'error'}\n <div class=\"text-destructive text-sm font-medium -mt-2\">{$message.text}</div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", V = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", H = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /otp/[token]\", () => {\n it(\"should throw an error if the otp is invalid\", async (context) => {\n const response = await context.agent\n .post(\"/otp/123456\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ otp: \"123456\" });\n expect(response.body.status).toBe(400);\n });\n});\n", U = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { resetSchema } from \"#lib/schemas/reset.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(resetSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const form = await superValidate(request, zod4(resetSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb.collection(\"users\").requestPasswordReset(form.data.email);\n } catch (error) {\n // PocketBase accepts any email, with an account or not, so a failure\n // here is not the visitor's doing: log it and say so, not a 500.\n console.error(\"Failed to request a password reset:\", error);\n setFlash(\n {\n type: \"toast\",\n message: \"We could not send the reset link. Try again in a moment.\",\n },\n cookies,\n );\n return fail(400, { form });\n }\n\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { form };\n },\n};\n", W = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { resetSchema } from '#lib/schemas/reset.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(resetSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your email to reset your password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", G = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", K = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /reset\", () => {\n it(\"should request a password reset\", async (context) => {\n const response = await context.agent\n .post(\"/reset\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ email: context.user.email });\n expect(response.body.status).toBe(200);\n });\n});\n", q = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { signupSchema } from \"#lib/schemas/signup.js\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const type: \"password\" | \"otp\" =\n !authMethods.password.enabled && authMethods.otp.enabled\n ? \"otp\"\n : \"password\";\n\n return {\n form: await superValidate(\n zod4(\n signupSchema.default({\n type,\n email: \"\",\n password: \"\",\n passwordConfirm: \"\",\n }),\n ),\n ),\n authMethods,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n\n if (form.data.type === \"otp\") {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password,\n passwordConfirm: password,\n });\n } catch (error: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (error.response?.data?.email?.code !== \"validation_not_unique\") {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email));\n } catch (error: any) {\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n return redirect(\n 303,\n `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`,\n );\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email!);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n", J = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"#lib/schemas/signup.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || hasOAuth2);\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field\n {form}\n name=\"passwordConfirm\"\n class=\"col-span-1\"\n >\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button\n >\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", Y = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", X = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /signup\", () => {\n it(\"should signup with password\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/dashboard\");\n });\n\n it(\"should error if the password does not match\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password2\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.passwordConfirm).toBeDefined();\n expect(data.form.errors.passwordConfirm[0]).toBe(\"Values don't match.\");\n });\n\n it(\"should error if the email is already taken\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n type: \"password\",\n email: context.user.email,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.email).toBeDefined();\n expect(data.form.errors.email[0]).toBe(\"Value must be unique.\");\n });\n\n it(\"should error if the email is invalid for a one-time code\", async (context) => {\n const response = await context.agent\n .post(\"/signup\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ type: \"otp\", email: \"not-an-email\" });\n expect(response.body.status).toBe(400);\n const data = devalue.parse(response.body.data);\n expect(data.form.errors.email).toBeDefined();\n });\n});\n", Z = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { welcomeSchema } from \"#lib/schemas/welcome.js\";\nimport { redirect } from \"@sveltejs/kit\";\n\n/**\n * Where to go next. Follows only a same-site path (`/x`, not `//host` or\n * `/\\host`): `redirect()` throws on an external URL.\n */\nfunction nextUrl(url: URL) {\n const next = url.searchParams.get(\"redirect\");\n return next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n}\n\n// Accounts made with a one-time code start without a name, so signup sends\n// them here once the code checks out, to pick the name the app shows.\nexport const load = async ({ locals, url }) => {\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n if (locals.pb.authStore.record?.name) {\n redirect(303, nextUrl(url));\n }\n\n return { form: await superValidate(zod4(welcomeSchema)), next: nextUrl(url) };\n};\n\nexport const actions = {\n default: async ({ locals, request, url }) => {\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n\n const form = await superValidate(request, zod4(welcomeSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n await locals.pb\n .collection(\"users\")\n .update(locals.pb.authStore.record!.id, { name: form.data.name.trim() });\n\n redirect(303, nextUrl(url));\n },\n};\n", Q = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { welcomeSchema } from '#lib/schemas/welcome.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(welcomeSchema)\n }\n );\n\n const { form: formData } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome!</Card.Title>\n <Card.Description>What should we call you?</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"name\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Name</Form.Label>\n <Input\n {...props}\n type=\"text\"\n autocomplete=\"name\"\n bind:value={$formData.name}\n required\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Button type=\"submit\" class=\"w-full\">Continue</Button>\n <Button href={data.next} variant=\"ghost\" class=\"w-full\">Skip for now</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", $ = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Welcome'\n });\n\n return { ...data, pageMetaTags };\n};\n", ee = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /welcome\", () => {\n it(\"should redirect a signed out visitor to login\", async (context) => {\n const response = await context.request.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/login\");\n });\n\n it(\"should ask a signed in user for their name\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /welcome\", () => {\n it(\"should save the name and follow the redirect\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent\n .post(\"/welcome\" satisfies Match<RouteId>)\n .query({ redirect: \"/settings\" })\n .type(\"form\")\n .send({ name: \" Ada Lovelace \" });\n expect(response.body.status).toBe(303);\n expect(response.body.location).toBe(\"/settings\");\n\n const user = await context.admin.collection(\"users\").getOne(context.user.id);\n expect(user.name).toBe(\"Ada Lovelace\");\n });\n\n it(\"should not save a blank name\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent\n .post(\"/welcome\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ name: \" \" });\n expect(response.body.status).toBe(400);\n });\n});\n", te = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"#lib/schemas/login.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Welcome back</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a login method\"\n : \"Use your email to login\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Login is disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for login options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n</div>\n", ne = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"#lib/schemas/signup.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || hasOAuth2);\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"grid h-full lg:grid-cols-2\">\n <div class=\"bg-muted relative hidden lg:block\">\n <img\n src={favicon}\n alt=\"\"\n class=\"absolute inset-0 m-auto size-32 opacity-20\"\n />\n </div>\n <div class=\"flex flex-col gap-4 p-6 md:p-10\">\n <div class=\"flex justify-center gap-2 md:justify-start\">\n <a href=\"/\" class=\"flex items-center gap-2 font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n </div>\n <div class=\"flex flex-1 items-center justify-center\">\n <div class=\"w-full max-w-sm\">\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"flex flex-col items-center gap-2 text-center\">\n {#if hasAuthMethods}\n <h1 class=\"text-2xl font-bold\">Create an account</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n {hasOAuth2\n ? \"Choose a sign up method\"\n : \"Use your email to sign up\"}\n </p>\n {:else}\n <h1 class=\"text-2xl font-bold\">Signups are disabled</h1>\n <p class=\"text-muted-foreground text-sm text-balance\">\n Check back later for signup options\n </p>\n {/if}\n </div>\n\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-background text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field\n {form}\n name=\"passwordConfirm\"\n class=\"col-span-1\"\n >\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </div>\n </div>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n</div>\n", re = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & { user: any } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", ie = "<script lang=\"ts\">\n import type { Component } from 'svelte';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { page } from '$app/state';\n\n const isActive = (url: string) => {\n return page.url.pathname.startsWith(url);\n };\n\n let {\n items\n }: {\n items: {\n title: string;\n url: string;\n icon: Component;\n items?: {\n title: string;\n url: string;\n }[];\n }[];\n } = $props();\n<\/script>\n\n<Sidebar.Group>\n <Sidebar.Menu>\n {#each items as item (item.title)}\n <Sidebar.MenuItem>\n <Sidebar.MenuButton isActive={isActive(item.url)}>\n {#snippet child({ props })}\n <a href={item.url} {...props}>\n <item.icon />\n <span>{item.title}</span>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n {/each}\n </Sidebar.Menu>\n</Sidebar.Group>\n", ae = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import { displayName, type UserIdentity } from '#lib/user.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n \n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n }\n ]\n };\n\n let {\n user\n }: {\n user: UserIdentity & {\n id: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n {#if user.name}\n <span class=\"truncate text-xs\">{user.email || user.phone}</span>\n {/if}\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</span>\n {#if user.name}\n <span class=\"truncate text-xs\">{user.email || user.phone}</span>\n {/if}\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", oe = "<script lang=\"ts\">\n import UserRoundIcon from \"@lucide/svelte/icons/user-round\";\n import * as Avatar from \"#lib/components/ui/avatar/index.js\";\n import { displayName, userInitial, type UserIdentity } from \"#lib/user.js\";\n\n let {\n user,\n class: className,\n fallbackClass,\n }: {\n /** `avatar` is the file name on the record, when one was uploaded. */\n user: (UserIdentity & { id: string; avatar?: string }) | null | undefined;\n class?: string;\n fallbackClass?: string;\n } = $props();\n\n const initial = $derived(user ? userInitial(user) : null);\n<\/script>\n\n<Avatar.Root class={className}>\n {#if user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{user.id}/{user.avatar}\"\n alt={displayName(user)}\n />\n {/if}\n <Avatar.Fallback class={fallbackClass}>\n {#if initial}\n {initial}\n {:else}\n <UserRoundIcon class=\"size-1/2\" />\n {/if}\n </Avatar.Fallback>\n</Avatar.Root>\n", se = "import { z } from \"zod\";\n\nexport const changeEmailSchema = z.object({\n email: z.email(),\n});\n", ce = "import { z } from \"zod\";\n\nexport const changePasswordSchema = z\n .object({\n password: z.string(),\n passwordConfirm: z.string(),\n })\n .refine((data) => data.password === data.passwordConfirm, {\n message: \"Passwords don't match\",\n path: [\"passwordConfirm\"],\n });\n", le = "import { z } from \"zod\";\n\nexport const confirmEmailChangeSchema = z.object({\n password: z.string(),\n});\n", ue = "import { z } from \"zod\";\n\nexport const confirmResetSchema = z.object({\n password: z.string(),\n passwordConfirm: z.string(),\n});\n", de = "import { z } from \"zod\";\n\n// A flat shape (rather than a discriminated union) keeps\n// `loginForm.fields.password` addressable in the page regardless of mode.\nexport const loginSchema = z\n .object({\n type: z.enum([\"password\", \"otp\", \"oauth2\"]),\n email: z.email(),\n password: z.string().optional(),\n })\n .refine((data) => data.type !== \"password\" || !!data.password, {\n message: \"Password is required\",\n path: [\"password\"],\n });\n", fe = "import { z } from \"zod\";\n\nexport const otpSchema = z.object({\n otp: z.string(),\n});\n", pe = "import { z } from \"zod\";\n\nexport const profileSchema = z.object({\n name: z.string().optional(),\n avatar: z.union([z.instanceof(File), z.string()]).optional(),\n emailVisibility: z.boolean().optional(),\n});\n", me = "import { z } from \"zod\";\n\nexport const resetSchema = z.object({\n email: z.email(),\n});\n", he = "import { z } from \"zod\";\n\n// Flat, like the login schema, so every field stays addressable in the page.\nexport const signupSchema = z\n .object({\n type: z.enum([\"password\", \"otp\"]),\n email: z.email(),\n password: z.string().optional(),\n passwordConfirm: z.string().optional(),\n })\n .refine((data) => data.type !== \"password\" || !!data.password, {\n message: \"Password is required\",\n path: [\"password\"],\n });\n", ge = "import { z } from \"zod\";\n\n// Same as enable-auth's, where a `.trim()` would eat spaces as you type\n// (superforms writes the parsed value back). The form handler trims on save.\nexport const welcomeSchema = z.object({\n name: z\n .string()\n .max(255)\n .refine((name) => name.trim() !== \"\", \"Enter your name\")\n});\n", _e = "/**\n * The fields that say who a user is. Accounts made with a phone number may\n * have no email, and nobody has a name until they add one.\n */\nexport type UserIdentity = {\n name?: string;\n email?: string;\n phone?: string;\n};\n\n/** The name, else the email, else the phone number. */\nexport function displayName(user: UserIdentity): string | undefined {\n return user.name?.trim() || user.email || user.phone || undefined;\n}\n\n/**\n * The avatar letter, from the name, else the email. A phone number has no\n * useful one (\"+\"), so it gets `null` and the avatar shows an icon instead.\n */\nexport function userInitial(user: UserIdentity): string | null {\n const source = user.name?.trim() || user.email;\n return source ? Array.from(source)[0].toUpperCase() : null;\n}\n", ve = "export const load = ({ locals }) => {\n const user = locals.pb.authStore.record!;\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, breadcrumbs };\n};\n", ye = "<script lang=\"ts\">\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import AppSidebar from '#lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '#lib/components/ui/breadcrumb/index.js';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <AppSidebar user={data.user} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", be = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Dashboard'\n });\n\n return { pageMetaTags };\n};\n", xe = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"dashboard\", () => {\n it(\"should redirect to the login page\", async (context) => {\n const response = await context.request.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(302);\n expect(response.headers.location).toBe(\"/login?redirect=%2Fdashboard\");\n });\n\n it(\"authenticated user should be able to access the dashboard\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/dashboard\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Se = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Settings\", url: \"/settings\" }],\n };\n};\n", Ce = "export const load = async ({ parent }) => {\n const { user } = await parent();\n\n return { user };\n};\n", we = "<script lang=\"ts\">\n import { Button, buttonVariants } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { Badge } from \"#lib/components/ui/badge/index.js\";\n import * as Dialog from \"#lib/components/ui/dialog/index.js\";\n import { Checkbox } from \"#lib/components/ui/checkbox/index.js\";\n import UserAvatar from \"#lib/components/user-avatar.svelte\";\n import {\n updateProfileForm,\n changeEmailForm,\n changePasswordForm,\n resendVerificationForm,\n } from \"./form.remote\";\n\n let { data } = $props();\n\n // The profile fields start from the saved values, passed to \\`.as()\\`: a\n // field left alone is then posted back as it was, and the form goes back\n // to what was saved when it resets after a save.\n\n // bits-ui's Checkbox renders a <button>, so drop the native type=\"checkbox\"\n // from the field props before spreading them.\n const emailVisibilityProps = $derived.by(() => {\n const { type, ...props } = updateProfileForm.fields.emailVisibility.as(\n \"checkbox\",\n data.user.emailVisibility,\n );\n return props;\n });\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Profile\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your profile information.\n </p>\n </div>\n\n <form\n {...updateProfileForm}\n enctype=\"multipart/form-data\"\n class=\"md:col-span-2\"\n >\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex items-center gap-3 justify-between\">\n <div class=\"flex items-center gap-3\">\n <UserAvatar user={data.user} class=\"size-16\" />\n <div>\n <span class=\"text-sm font-medium leading-none\">Avatar</span>\n <p class=\"text-muted-foreground text-sm\">\n Upload a new avatar for your profile.\n </p>\n </div>\n </div>\n <label\n class=\"{buttonVariants({\n variant: 'outline',\n })} has-focus-visible:border-ring has-focus-visible:ring-3 has-focus-visible:ring-ring/50\"\n >\n Upload new picture\n <input\n {...updateProfileForm.fields.avatar.as(\"file\")}\n type=\"file\"\n class=\"sr-only\"\n />\n </label>\n </div>\n {#each updateProfileForm.fields.avatar.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"name\" class=\"text-sm font-medium\">Name</label>\n <Input\n id=\"name\"\n {...updateProfileForm.fields.name.as(\"text\", data.user.name)}\n type=\"text\"\n autocomplete=\"name\"\n />\n {#each updateProfileForm.fields.name.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n {#if data.user.email}\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <div class=\"flex items-start gap-2\">\n <Checkbox id=\"emailVisibility\" {...emailVisibilityProps} />\n <div class=\"grid gap-2\">\n <label\n for=\"emailVisibility\"\n class=\"text-sm font-medium leading-none\"\n >Display email publicly</label\n >\n <p class=\"text-muted-foreground text-sm\">\n By clicking this checkbox, your email will be displayed\n publicly.\n </p>\n </div>\n </div>\n {#each updateProfileForm.fields.emailVisibility.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Save changes</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n\n <!-- Accounts without an email (made with a phone number) have no\n email to verify or change, and no password to log in with. -->\n {#if data.user.email}\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Email\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n The email address associated with your account.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Content class=\"flex flex-col gap-6\">\n <div class=\"flex flex-wrap justify-between items-center gap-3\">\n <span class=\"text-sm flex items-center gap-2\">\n {data.user.email}\n <Badge variant=\"secondary\"\n >{data.user.verified ? \"Verified\" : \"Unverified\"}</Badge\n >\n </span>\n <div class=\"flex items-center gap-3\">\n {#if !data.user.verified}\n <form {...resendVerificationForm}>\n <Button type=\"submit\" variant=\"outline\" class=\"w-fit\"\n >Resend verification email</Button\n >\n </form>\n {/if}\n\n <Dialog.Root>\n <Dialog.Trigger class={buttonVariants({ variant: \"outline\" })}>\n Change email\n </Dialog.Trigger>\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>Change email</Dialog.Title>\n <Dialog.Description>\n Enter your new email address. You will receive a\n verification email.\n </Dialog.Description>\n </Dialog.Header>\n <form {...changeEmailForm} class=\"grid gap-4\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"email\" class=\"text-sm font-medium\"\n >Email</label\n >\n <Input\n id=\"email\"\n {...changeEmailForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"email\"\n />\n {#each changeEmailForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n <Dialog.Footer>\n <Button type=\"submit\" class=\"w-fit\">Change email</Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n </div>\n </Card.Content>\n </Card.Root>\n </div>\n\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">\n Password\n </h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Your password is used to log in to your account.\n </p>\n </div>\n\n <form {...changePasswordForm} class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content class=\"flex flex-col gap-6\">\n <input\n type=\"email\"\n value={data.user.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n <div class=\"grid gap-6\">\n <div class=\"grid gap-3\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >New password</label\n >\n <Input\n id=\"password\"\n {...changePasswordForm.fields.password.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {#each changePasswordForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n <div class=\"grid gap-3\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm new password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...changePasswordForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n autocomplete=\"new-password\"\n required\n minlength={8}\n />\n {#each changePasswordForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"border-t justify-end\">\n <Button type=\"submit\" class=\"w-fit\">Update password</Button>\n </Card.Footer>\n </Card.Root>\n </form>\n </div>\n {/if}\n</div>\n", Te = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Settings'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ee = "import { form, getRequestEvent } from \"$app/server\";\nimport { error } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { requireUser } from \"@velastack/pocketbase/auth\";\nimport { profileSchema } from \"#lib/schemas/profile.js\";\nimport { changeEmailSchema } from \"#lib/schemas/changeEmail.js\";\nimport { changePasswordSchema } from \"#lib/schemas/changePassword.js\";\n\n// Each of these starts with `requireUser()`. This file is under `(app)`, but\n// that does not protect a remote function: it is an endpoint of its own, and\n// what a request says about the page it came from is the caller's to write.\n\nexport const updateProfileForm = form(profileSchema, async (data) => {\n const user = requireUser();\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").update(user.id, {\n name: data.name,\n // No file chosen: `undefined`, which leaves the saved avatar alone.\n avatar: data.avatar,\n // An unticked checkbox posts nothing at all, so absent means \"off\". The\n // box is only shown to accounts with an email; the others keep theirs.\n ...(user.email ? { emailVisibility: data.emailVisibility ?? false } : {}),\n });\n\n setFlash(\n { type: \"toast\", message: \"Profile updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const changeEmailForm = form(changeEmailSchema, async (data) => {\n requireUser();\n const { locals, cookies } = getRequestEvent();\n\n await locals.pb.collection(\"users\").requestEmailChange(data.email);\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a confirmation link to your new email.\",\n },\n cookies,\n );\n return { success: true };\n});\n\nexport const changePasswordForm = form(changePasswordSchema, async (data) => {\n const user = requireUser();\n const { locals, cookies } = getRequestEvent();\n\n // As the superuser, so the current password is not asked for: `user` is\n // who PocketBase says this session is, never who the request says.\n await locals.admin.collection(\"users\").update(user.id, {\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n\n setFlash(\n { type: \"toast\", message: \"Password updated successfully.\" },\n cookies,\n );\n return { success: true };\n});\n\nexport const resendVerificationForm = form(async () => {\n const user = requireUser();\n const { locals, cookies } = getRequestEvent();\n // Accounts made with a phone number may have no email to verify.\n const email = user.email;\n if (!email) {\n error(400, \"Your account has no email.\");\n }\n\n await locals.pb.collection(\"users\").requestVerification(email);\n setFlash(\n { type: \"toast\", message: \"We sent a verification email to your email.\" },\n cookies,\n );\n return { success: true };\n});\n", De = "export const load = async () => {\n return {};\n};\n", Oe = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { confirmEmailChangeForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Confirm your email change</Card.Title>\n <Card.Description\n >Enter your password to confirm your email change</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...confirmEmailChangeForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmEmailChangeForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n autofocus\n />\n {#each confirmEmailChangeForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Confirm email change</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", ke = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm email change'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ae = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmEmailChangeSchema } from \"#lib/schemas/confirmEmailChange.js\";\n\nexport const confirmEmailChangeForm = form(\n confirmEmailChangeSchema,\n async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmEmailChange(params.token as string, data.password);\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash(\n { type: \"toast\", message: \"Email changed successfully.\" },\n cookies,\n );\n redirect(303, \"/login\");\n },\n);\n", je = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-email-change/[token]\", () => {\n it(\"should render the confirm-email-change page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-email-change/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Me = "import { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ params }) => {\n // The reset token is a JWT carrying the account email. Expose it so the\n // page can render a hidden username field for password managers.\n const { email } = getTokenPayload(params.token);\n\n return { email: typeof email === \"string\" ? email : null };\n};\n", Ne = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { confirmResetForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description>Enter your new password</Card.Description>\n </Card.Header>\n <Card.Content>\n <form {...confirmResetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n {#if data.email}\n <input\n type=\"email\"\n value={data.email}\n autocomplete=\"username\"\n readonly\n tabindex=\"-1\"\n aria-hidden=\"true\"\n class=\"sr-only\"\n />\n {/if}\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...confirmResetForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n autofocus\n />\n {#each confirmResetForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...confirmResetForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each confirmResetForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Reset password</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Pe = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Confirm password reset'\n });\n\n return { ...data, pageMetaTags };\n};\n", Fe = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { confirmResetSchema } from \"#lib/schemas/confirmReset.js\";\n\nexport const confirmResetForm = form(confirmResetSchema, async (data) => {\n const { locals, cookies, params } = getRequestEvent();\n\n await locals.admin\n .collection(\"users\")\n .confirmPasswordReset(\n params.token as string,\n data.password,\n data.passwordConfirm,\n );\n\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n\n setFlash({ type: \"toast\", message: \"Password reset successfully.\" }, cookies);\n redirect(303, \"/login\");\n});\n", Ie = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-reset/[token]\", () => {\n it(\"should render the confirm-reset page\", async (context) => {\n const response = await context.request.get(\n \"/confirm-reset/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Le = "import { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\n\nexport const GET = async ({ params, locals, cookies }) => {\n let message = \"\";\n let redirectPath = \"\";\n\n try {\n await locals.admin.collection(\"users\").confirmVerification(params.token);\n message = \"Email verified successfully.\";\n redirectPath = \"/dashboard\";\n } catch (error: any) {\n message =\n \"Invalid or expired verification token. Please request a new verification email.\";\n redirectPath = \"/login\";\n }\n\n setFlash({ type: \"toast\", message }, cookies);\n redirect(303, redirectPath);\n};\n", Re = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /confirm-verification/[token]\", () => {\n it(\"should redirect if the token is invalid\", async (context) => {\n const response = await context.request.get(\n \"/confirm-verification/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers[\"location\"]).toBe(\"/login\");\n });\n});\n", ze = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n return { authMethods };\n};\n", Be = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { loginForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasAuthMethods = $derived(\n authMethods.password.enabled || authMethods.otp.enabled || hasOAuth2,\n );\n\n const initialType: \"password\" | \"otp\" | \"oauth2\" = $derived(\n authMethods.otp.enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : \"oauth2\",\n );\n let mode = $state<\"password\" | \"otp\" | \"oauth2\">(\"password\");\n $effect(() => {\n mode = initialType;\n });\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a login method</Card.Description>\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...loginForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if authMethods.password.enabled || authMethods.otp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...loginForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each loginForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if mode === \"password\" && authMethods.password.enabled}\n <div class=\"space-y-2 col-span-1\">\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...loginForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {#each loginForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if loginForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {loginForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"otp\")}\n type=\"button\"\n >Use one-time code instead</Button\n >\n {/if}\n {:else if mode === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"password\")}\n type=\"button\"\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input {...loginForm.fields.type.as(\"hidden\", mode)} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", Ve = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Log in'\n });\n\n return { ...data, pageMetaTags };\n};\n", He = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { loginSchema } from \"#lib/schemas/login.js\";\n\nexport const loginForm = form(loginSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n if (data.type === \"otp\") {\n const req = await locals.pb.collection(\"users\").requestOTP(data.email);\n redirect(\n 303,\n `/otp/${req.otpId}${redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : \"\"}`,\n );\n } else if (data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(data.email, data.password ?? \"\");\n } catch (err: any) {\n // A wrong email or password is a 400. Anything else is not the\n // visitor's doing, and the page alone would not tell them apart.\n if (err.status !== 400) console.error(\"Failed to sign in:\", err);\n return {\n message: (err.response?.message as string) ?? \"Failed to authenticate.\",\n };\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n});\n", Ue = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /login\", () => {\n it(\"should render the login page\", async (context) => {\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n\n it(\"should redirect to the dashboard if the user is already authenticated\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/login\" satisfies Match<RouteId>);\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n });\n});\n", We = "import { redirect } from \"@sveltejs/kit\";\n\nexport const POST = ({ cookies, locals }) => {\n locals.pb.authStore.clear();\n locals.pb.authStore.clearCookie(cookies);\n redirect(303, \"/\");\n};\n", Ge = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /logout\", () => {\n it(\"should logout the user\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.post(\n \"/logout\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/\");\n });\n});\n", Ke = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", qe = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { otpForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Enter your OTP code</Card.Title>\n <Card.Description\n >Enter the code sent to your email</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...otpForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"otp\" class=\"text-sm font-medium\">OTP code</label>\n <Input\n id=\"otp\"\n {...otpForm.fields.otp.as(\"text\")}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n required\n autofocus\n />\n {#each otpForm.fields.otp.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if otpForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {otpForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Je = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ye = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\n\nexport const otpForm = form(otpSchema, async (data) => {\n const { locals, cookies, params, url } = getRequestEvent();\n\n try {\n await locals.pb\n .collection(\"users\")\n .authWithOTP(params.token as string, data.otp);\n } catch (err: any) {\n return {\n message: (err.response?.message as string) ?? \"Failed to verify code.\",\n };\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n});\n", Xe = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /otp/[token]\", () => {\n it(\"should render the otp page\", async (context) => {\n const response = await context.request.get(\n \"/otp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Ze = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", Qe = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { resetForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Reset your password</Card.Title>\n <Card.Description\n >Enter your email to reset your password</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...resetForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\">Email</label>\n <Input\n id=\"email\"\n {...resetForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each resetForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Send reset link</Button>\n </div>\n\n <div class=\"text-center text-sm\">\n Remembered your password?\n <a href=\"/login\" class=\"underline underline-offset-4\">Log in</a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", $e = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Reset password'\n });\n\n return { ...data, pageMetaTags };\n};\n", et = "import { form, getRequestEvent } from \"$app/server\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { resetSchema } from \"#lib/schemas/reset.js\";\n\nexport const resetForm = form(resetSchema, async (data) => {\n const { locals, cookies } = getRequestEvent();\n\n try {\n await locals.pb.collection(\"users\").requestPasswordReset(data.email);\n } catch (err) {\n // PocketBase accepts any email, with an account or not, so a failure\n // here is not the visitor's doing: log it and say so, not a 500.\n console.error(\"Failed to request a password reset:\", err);\n setFlash(\n {\n type: \"toast\",\n message: \"We could not send the reset link. Try again in a moment.\",\n },\n cookies,\n );\n return { success: false };\n }\n\n setFlash(\n {\n type: \"toast\",\n message: \"We sent a password reset link to your email.\",\n },\n cookies,\n );\n\n return { success: true };\n});\n", tt = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /reset\", () => {\n it(\"should render the reset page\", async (context) => {\n const response = await context.request.get(\n \"/reset\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", nt = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { authMethods };\n};\n", rt = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n import { signupForm } from \"./form.remote\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || hasOAuth2);\n\n type Mode = \"password\" | \"otp\";\n const initialType: Mode = $derived(\n !authMethods.password.enabled && authMethods.otp.enabled\n ? \"otp\"\n : \"password\",\n );\n let mode = $state<Mode>(\"password\");\n $effect(() => {\n mode = initialType;\n });\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form {...signupForm}>\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"email\" class=\"text-sm font-medium\"\n >Email</label\n >\n <Input\n id=\"email\"\n {...signupForm.fields.email.as(\"text\")}\n type=\"email\"\n required\n autocomplete=\"username\"\n autofocus\n />\n {#each signupForm.fields.email.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if mode === \"password\" && authMethods.password.enabled}\n <div class=\"space-y-2 col-span-1\">\n <label for=\"password\" class=\"text-sm font-medium\"\n >Password</label\n >\n <Input\n id=\"password\"\n {...signupForm.fields.password.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each signupForm.fields.password.issues() as issue}\n <p class=\"text-destructive text-sm\">\n {issue.message}\n </p>\n {/each}\n </div>\n\n <div class=\"space-y-2 col-span-1\">\n <label for=\"passwordConfirm\" class=\"text-sm font-medium\"\n >Confirm Password</label\n >\n <Input\n id=\"passwordConfirm\"\n {...signupForm.fields.passwordConfirm.as(\"text\")}\n type=\"password\"\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {#each signupForm.fields.passwordConfirm.issues() as issue}\n <p class=\"text-destructive text-sm\">\n {issue.message}\n </p>\n {/each}\n </div>\n\n {#if signupForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {signupForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Create account</Button\n >\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"otp\")}\n type=\"button\"\n >Use one-time code instead</Button\n >\n {/if}\n {:else if mode === \"otp\" && authMethods.otp.enabled}\n {#if signupForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {signupForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => (mode = \"password\")}\n type=\"button\"\n >Continue with password</Button\n >\n {/if}\n {/if}\n </div>\n\n <input {...signupForm.fields.type.as(\"hidden\", mode)} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", it = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Sign up'\n });\n\n return { ...data, pageMetaTags };\n};\n", at = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { signupSchema } from \"#lib/schemas/signup.js\";\n\n/** The first field error, or the response message, of a PocketBase error. */\nfunction errorMessage(err: any, fallback: string): string {\n const response = err?.response ?? {};\n const fieldError = response?.data\n ? Object.values(response.data)[0]\n : undefined;\n return (fieldError as any)?.message ?? response?.message ?? fallback;\n}\n\nexport const signupForm = form(signupSchema, async (data) => {\n const { locals, cookies, url } = getRequestEvent();\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n\n const { email } = data;\n\n if (data.type === \"otp\") {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n } catch (err: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (err?.response?.data?.email?.code !== \"validation_not_unique\") {\n return { message: errorMessage(err, \"Failed to create account.\") };\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb.collection(\"users\").requestOTP(email));\n } catch (err: any) {\n return { message: errorMessage(err, \"Failed to send the code.\") };\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n redirect(303, `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`);\n }\n\n try {\n await locals.admin.collection(\"users\").create({\n email,\n password: data.password,\n passwordConfirm: data.passwordConfirm,\n });\n } catch (err: any) {\n return { message: errorMessage(err, \"Failed to create account.\") };\n }\n\n await locals.pb.collection(\"users\").requestVerification(email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(email, data.password ?? \"\");\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n redirect(303, redirectUrl);\n});\n", ot = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /signup\", () => {\n it(\"should render the signup page\", async (context) => {\n const response = await context.request.get(\n \"/signup\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", st = "import { redirect } from \"@sveltejs/kit\";\nimport { nextUrl } from \"./next-url\";\n\n// Accounts made with a one-time code start without a name, so signup sends\n// them here once the code checks out, to pick the name the app shows.\nexport const load = async ({ locals, url }) => {\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n if (locals.pb.authStore.record?.name) {\n redirect(303, nextUrl(url));\n }\n\n return { next: nextUrl(url) };\n};\n", ct = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { welcomeForm } from \"./form.remote\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome!</Card.Title>\n <Card.Description>What should we call you?</Card.Description>\n </Card.Header>\n <Card.Content>\n <form {...welcomeForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"name\" class=\"text-sm font-medium\">Name</label>\n <Input\n id=\"name\"\n {...welcomeForm.fields.name.as(\"text\")}\n autocomplete=\"name\"\n required\n autofocus\n />\n {#each welcomeForm.fields.name.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n <Button type=\"submit\" class=\"w-full\">Continue</Button>\n <Button href={data.next} variant=\"ghost\" class=\"w-full\"\n >Skip for now</Button\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", lt = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Welcome'\n });\n\n return { ...data, pageMetaTags };\n};\n", ut = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { requireUser } from \"@velastack/pocketbase/auth\";\nimport { welcomeSchema } from \"#lib/schemas/welcome.js\";\nimport { nextUrl } from \"./next-url\";\n\nexport const welcomeForm = form(welcomeSchema, async (data) => {\n const { locals, url } = getRequestEvent();\n\n if (!locals.pb.authStore.isValid) {\n redirect(303, \"/login\");\n }\n\n const user = requireUser();\n await locals.pb\n .collection(\"users\")\n .update(user.id, { name: data.name.trim() });\n\n redirect(303, nextUrl(url));\n});\n", dt = "/**\n * Where to go after the name step. Follows only a same-site path (`/x`, not\n * `//host` or `/\\host`): `redirect()` throws on an external URL.\n */\nexport function nextUrl(url: URL) {\n const next = url.searchParams.get(\"redirect\");\n return next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n}\n", ft = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /welcome\", () => {\n it(\"should redirect a signed out visitor to login\", async (context) => {\n const response = await context.request.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/login\");\n });\n\n it(\"should ask a signed in user for their name\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\n \"/welcome\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", pt = "import { z } from \"zod\";\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n});\n\nconst oAuth2Schema = z.object({\n type: z.literal(\"oauth2\"),\n email: z.email(),\n});\n\nconst whatsappSchema = z.object({\n type: z.literal(\"whatsapp\"),\n phone: z.string().min(1),\n});\n\nexport const loginSchema = z.discriminatedUnion(\"type\", [\n otpSchema,\n passwordSchema,\n oAuth2Schema,\n whatsappSchema,\n]);\n", mt = "import { z } from \"zod\";\n\nconst passwordSchema = z.object({\n type: z.literal(\"password\"),\n email: z.email(),\n password: z.string(),\n passwordConfirm: z.string(),\n});\n\nconst otpSchema = z.object({\n type: z.literal(\"otp\"),\n email: z.email(),\n});\n\nconst whatsappSchema = z.object({\n type: z.literal(\"whatsapp\"),\n phone: z.string().min(1),\n});\n\nexport const signupSchema = z.discriminatedUnion(\"type\", [\n passwordSchema,\n otpSchema,\n whatsappSchema,\n]);\n", ht = "import { fail, superValidate, message } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { loginSchema } from \"#lib/schemas/login.js\";\nimport {\n requestWhatsAppOTP,\n whatsappAuthMethod,\n} from \"#lib/server/whatsapp.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n const whatsapp = whatsappAuthMethod(authMethods);\n\n const type: \"password\" | \"otp\" | \"oauth2\" | \"whatsapp\" = authMethods.otp\n .enabled\n ? \"otp\"\n : authMethods.password.enabled\n ? \"password\"\n : whatsapp.enabled\n ? \"whatsapp\"\n : \"oauth2\";\n\n return {\n form: await superValidate(\n zod4(\n loginSchema.default({ type, email: \"\", password: \"\", phone: \"\" }),\n ),\n ),\n authMethods,\n whatsapp,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(loginSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n if (form.data.type === \"otp\") {\n const req = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email);\n return redirect(303, `/otp/${req.otpId}${redirectQuery}`);\n } else if (form.data.type === \"whatsapp\") {\n let otpId: string;\n try {\n ({ otpId } = await requestWhatsAppOTP(locals.pb, form.data.phone));\n } catch (error: any) {\n // An invalid number goes on the field; the rest (WhatsApp auth\n // disabled, rate limited) on the form.\n if (Object.keys(error.response?.data ?? {}).length) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n return redirect(303, `/whatsapp/${otpId}${redirectQuery}`);\n } else if (form.data.type === \"password\") {\n try {\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n } catch (error: any) {\n // A wrong email or password is a 400. Anything else is not the\n // visitor's doing, and the page alone would not tell them apart.\n if (error.status !== 400) console.error(\"Failed to sign in:\", error);\n return message(\n form,\n { type: \"error\", text: error.response.message },\n { status: 400 },\n );\n }\n }\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n redirect(303, redirectUrl);\n },\n};\n", gt = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { loginSchema } from \"#lib/schemas/login.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n let whatsapp = $derived(data.whatsapp);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || whatsapp.enabled || hasOAuth2);\n // Where \"Continue with email\" goes back to from WhatsApp.\n const emailType = $derived(authMethods.otp.enabled ? \"otp\" : \"password\");\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(loginSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Welcome back</Card.Title>\n {#if hasOAuth2 || (hasEmail && whatsapp.enabled)}\n <Card.Description>Choose a login method</Card.Description>\n {:else if whatsapp.enabled}\n <Card.Description\n >Use your WhatsApp number to login</Card.Description\n >\n {:else}\n <Card.Description>Use your email to login</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Login is disabled</Card.Title>\n <Card.Description\n >Check back later for login options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Login with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail || whatsapp.enabled}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n {#if $formData.type === \"whatsapp\" && whatsapp.enabled}\n <Form.Field {form} name=\"phone\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>WhatsApp number</Form.Label>\n <Input\n {...props}\n type=\"tel\"\n bind:value={$formData.phone}\n required\n autocomplete=\"tel\"\n placeholder=\"+1 616 555 0123\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send code on WhatsApp</Button\n >\n {#if hasEmail}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = emailType as \"whatsapp\")}\n >Continue with email</Button\n >\n {/if}\n {:else if hasEmail && $formData.type !== \"whatsapp\"}\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <div class=\"grid grid-cols-[1fr_auto] gap-2\">\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"current-password\"\n class=\"col-span-2\"\n />\n <a\n href=\"/reset\"\n class=\"col-start-2 row-start-1 text-sm underline-offset-4 hover:underline\"\n >Forgot your password?</a\n >\n </div>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Login</Button>\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n\n {#if whatsapp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = \"whatsapp\" as \"password\")}\n >Continue with WhatsApp</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Don't have an account?\n <a\n href=\"/signup{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\">Sign up</a\n >\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n", _t = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\nimport { dev } from \"$app/env\";\nimport { getTokenPayload } from \"pocketbase-sveltekit\";\nimport { signupSchema } from \"#lib/schemas/signup.js\";\nimport {\n requestWhatsAppOTP,\n whatsappAuthMethod,\n} from \"#lib/server/whatsapp.js\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n const whatsapp = whatsappAuthMethod(authMethods);\n const whatsappSignup = whatsapp.enabled && whatsapp.allowSignup === true;\n\n const type: \"password\" | \"otp\" | \"whatsapp\" = authMethods.password.enabled\n ? \"password\"\n : authMethods.otp.enabled\n ? \"otp\"\n : whatsappSignup\n ? \"whatsapp\"\n : \"password\";\n\n return {\n form: await superValidate(\n zod4(\n signupSchema.default({\n type,\n email: \"\",\n password: \"\",\n passwordConfirm: \"\",\n phone: \"\",\n }),\n ),\n ),\n authMethods,\n whatsappSignup,\n };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam\n ? `?redirect=${encodeURIComponent(redirectParam)}`\n : \"\";\n\n if (form.data.type === \"whatsapp\") {\n // The account is created when the code is checked.\n let otpId: string;\n try {\n ({ otpId } = await requestWhatsAppOTP(locals.pb, form.data.phone));\n } catch (error: any) {\n // An invalid number goes on the field; the rest (WhatsApp auth\n // disabled, rate limited) on the form.\n if (Object.keys(error.response?.data ?? {}).length) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n return redirect(303, `/whatsapp/${otpId}${redirectQuery}`);\n }\n\n if (form.data.type === \"otp\") {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password,\n passwordConfirm: password,\n });\n } catch (error: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (error.response?.data?.email?.code !== \"validation_not_unique\") {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb\n .collection(\"users\")\n .requestOTP(form.data.email));\n } catch (error: any) {\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to send the code.\",\n },\n { status: 400 },\n );\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n return redirect(\n 303,\n `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`,\n );\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.pb.collection(\"users\").requestVerification(user.email!);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = redirectParam ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n // The cookie goes when its token does: PocketBase turns away every\n // request that carries an expired token, sign-in included.\n expires: new Date(getTokenPayload(locals.pb.authStore.token).exp * 1000),\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n", vt = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { untrack } from \"svelte\";\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { superForm } from \"sveltekit-superforms\";\n import { zod4Client } from \"sveltekit-superforms/adapters\";\n import { signupSchema } from \"#lib/schemas/signup.js\";\n import * as Form from \"#lib/components/ui/form/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import PocketBase from \"pocketbase-sveltekit\";\n import { goto } from \"$app/navigation\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let authMethods = $derived(data.authMethods);\n let whatsappSignup = $derived(data.whatsappSignup);\n\n const redirect = page.url.searchParams.get(\"redirect\");\n const hasOAuth2 = $derived(\n authMethods.oauth2.enabled && authMethods.oauth2.providers.length > 0,\n );\n const hasEmail = $derived(\n authMethods.password.enabled || authMethods.otp.enabled,\n );\n const hasAuthMethods = $derived(hasEmail || whatsappSignup || hasOAuth2);\n // Where \"Continue with email\" goes back to from WhatsApp.\n const emailType = $derived(\n authMethods.password.enabled ? \"password\" : \"otp\",\n );\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(signupSchema),\n },\n );\n\n const handleOAuth2 = (provider: string) => {\n const pb = new PocketBase(\"/\");\n\n pb.collection(\"users\")\n .authWithOAuth2({ provider, createData: {} })\n .then(() => goto(\"/dashboard\"));\n };\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n {#if hasAuthMethods}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Create an account</Card.Title>\n {#if hasOAuth2 || (hasEmail && whatsappSignup)}\n <Card.Description>Choose a sign up method</Card.Description>\n {:else if whatsappSignup}\n <Card.Description\n >Use your WhatsApp number to sign up</Card.Description\n >\n {:else}\n <Card.Description>Use your email to sign up</Card.Description>\n {/if}\n </Card.Header>\n {:else}\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\">Signups are disabled</Card.Title>\n <Card.Description\n >Check back later for signup options</Card.Description\n >\n </Card.Header>\n {/if}\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n {#if hasOAuth2}\n <div class=\"flex flex-col gap-4\">\n {#each authMethods.oauth2.providers as provider}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => handleOAuth2(provider.name)}\n >\n <img\n src=\"/admin/_/images/oauth2/{provider.name}.svg\"\n class=\"size-5 bg-white p-0.5 rounded-sm\"\n alt=\"\"\n />\n Sign up with {provider.displayName}\n </Button>\n {/each}\n </div>\n {/if}\n\n {#if hasEmail || whatsappSignup}\n {#if hasOAuth2}\n <div\n class=\"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t\"\n >\n <span\n class=\"bg-card text-muted-foreground relative z-10 px-2\"\n >\n Or continue with\n </span>\n </div>\n {/if}\n\n <div class=\"grid gap-2\">\n {#if $formData.type === \"whatsapp\" && whatsappSignup}\n <Form.Field {form} name=\"phone\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>WhatsApp number</Form.Label>\n <Input\n {...props}\n type=\"tel\"\n bind:value={$formData.phone}\n required\n autocomplete=\"tel\"\n placeholder=\"+1 616 555 0123\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send code on WhatsApp</Button\n >\n {#if hasEmail}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = emailType as \"whatsapp\")}\n >Continue with email</Button\n >\n {/if}\n {:else if hasEmail && $formData.type !== \"whatsapp\"}\n <Form.Field {form} name=\"email\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input\n {...props}\n type=\"email\"\n bind:value={$formData.email}\n required\n autocomplete=\"username\"\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $formData.type === \"password\" && authMethods.password.enabled}\n <Form.Field {form} name=\"password\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.password}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n <Form.Field\n {form}\n name=\"passwordConfirm\"\n class=\"col-span-1\"\n >\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Confirm Password</Form.Label>\n <Input\n {...props}\n type=\"password\"\n bind:value={$formData.passwordConfirm}\n required\n autocomplete=\"new-password\"\n minlength={8}\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Button type=\"submit\" class=\"w-full\">Create account</Button\n >\n {#if authMethods.otp.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"otp\" as \"password\")}\n >Use one-time code instead</Button\n >\n {/if}\n {:else if $formData.type === \"otp\" && authMethods.otp.enabled}\n {#if $message && $message.type === \"error\"}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {$message.text}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\"\n >Send one-time code</Button\n >\n {#if authMethods.password.enabled}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() => ($formData.type = \"password\" as \"otp\")}\n >Continue with password</Button\n >\n {/if}\n {/if}\n\n {#if whatsappSignup}\n <Button\n variant=\"outline\"\n class=\"w-full\"\n onclick={() =>\n ($formData.type = \"whatsapp\" as \"password\")}\n >Continue with WhatsApp</Button\n >\n {/if}\n {/if}\n </div>\n\n <input type=\"hidden\" name=\"type\" bind:value={$formData.type} />\n {/if}\n\n <div class=\"text-center text-sm\">\n Already have an account?\n <a\n href=\"/login{redirect\n ? `?redirect=${encodeURIComponent(redirect)}`\n : ''}\"\n class=\"underline underline-offset-4\"\n >\n Log in\n </a>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n <div\n class=\"text-muted-foreground *:[a]:hover:text-primary *:[a]:underline *:[a]:underline-offset-4 text-balance text-center text-xs\"\n >\n By clicking continue, you agree to our <a href=\"/terms\"\n >Terms of Service</a\n >\n and <a href=\"/privacy\">Privacy Policy</a>.\n </div>\n </div>\n </div>\n</div>\n";
|
|
3
3
|
export { be as $, b as $t, Ue as A, U as At, Ne as B, N as Bt, Xe as C, X as Ct, Ke as D, K as Dt, qe as E, q as Et, Re as F, R as Ft, Oe as G, O as Gt, je as H, j as Ht, Le as I, L as It, Te as J, T as Jt, De as K, D as Kt, Ie as L, I as Lt, Ve as M, V as Mt, Be as N, B as Nt, Ge as O, G as Ot, ze as P, z as Pt, xe as Q, x as Qt, Fe as R, F as Rt, Ze as S, Z as St, Je as T, J as Tt, Ae as U, A as Ut, Me as V, M as Vt, ke as W, k as Wt, Ce as X, C as Xt, we as Y, w as Yt, Se as Z, S as Zt, nt as _, n as _n, ne as _t, mt as a, m as an, me as at, $e as b, $ as bt, dt as c, d as cn, de as ct, ct as d, c as dn, ce as dt, y as en, ye as et, st as f, s as fn, se as ft, rt as g, r as gn, re as gt, it as h, i as hn, ie as ht, ht as i, h as in, he as it, He as j, H as jt, We as k, W as kt, ut as l, u as ln, ue as lt, at as m, a as mn, ae as mt, _t as n, _ as nn, _e as nt, pt as o, p as on, pe as ot, ot as p, o as pn, oe as pt, Ee as q, E as qt, gt as r, g as rn, ge as rt, ft as s, f as sn, fe as st, vt as t, v as tn, ve as tt, lt as u, l as un, le as ut, tt as v, t as vn, te as vt, Ye as w, Y as wt, Qe as x, Q as xt, et as y, e as yn, ee as yt, Pe as z, P as zt };
|
|
4
4
|
|
|
5
|
-
//# sourceMappingURL=_page-
|
|
5
|
+
//# sourceMappingURL=_page-BFUn0CG1.js.map
|