From 05f8e2e3b655737dfa9d9574b379689a23ad9db1 Mon Sep 17 00:00:00 2001 From: aewing Date: Wed, 21 Jan 2026 05:12:25 +0000 Subject: [PATCH] Add ModeTemplate with Svelte 5 frontend and components - Create reusable components: auth, api-client, shared-types - ModeTemplate with Hono backend and SvelteKit frontend - Auth store refactored to class-based Svelte 5 pattern - SSR-safe hydrate() pattern for localStorage access - Frontend builds successfully with Svelte 5 runes --- ModeTemplate/README.md | 55 + ModeTemplate/backend/modules/auth/index.ts | 28 + .../backend/modules/auth/microsoft-oauth.ts | 208 + ModeTemplate/backend/modules/auth/types.ts | 99 + ModeTemplate/backend/server.ts | 72 + ModeTemplate/bun.lock | 27 + .../frontend/.svelte-kit/ambient.d.ts | 175 + .../generated/client-optimized/app.js | 31 + .../generated/client-optimized/matchers.js | 1 + .../generated/client-optimized/nodes/0.js | 1 + .../generated/client-optimized/nodes/1.js | 1 + .../generated/client-optimized/nodes/2.js | 1 + .../generated/client-optimized/nodes/3.js | 1 + .../.svelte-kit/generated/client/app.js | 31 + .../.svelte-kit/generated/client/matchers.js | 1 + .../.svelte-kit/generated/client/nodes/0.js | 1 + .../.svelte-kit/generated/client/nodes/1.js | 1 + .../.svelte-kit/generated/client/nodes/2.js | 1 + .../.svelte-kit/generated/client/nodes/3.js | 1 + .../frontend/.svelte-kit/generated/root.js | 3 + .../.svelte-kit/generated/root.svelte | 68 + .../.svelte-kit/generated/server/internal.js | 53 + .../frontend/.svelte-kit/non-ambient.d.ts | 42 + .../.svelte-kit/output/client/.gitkeep | 1 + .../output/client/.vite/manifest.json | 153 + .../_app/immutable/assets/0.r7T8fV5B.css | 1 + .../client/_app/immutable/chunks/974AMC2H.js | 1 + .../client/_app/immutable/chunks/BRRLaaPq.js | 1 + .../client/_app/immutable/chunks/Bgo_ZO3W.js | 1 + .../client/_app/immutable/chunks/BtkHyJOA.js | 1 + .../client/_app/immutable/chunks/CqqhLxdp.js | 1 + .../client/_app/immutable/chunks/CuIyQV9Z.js | 1 + .../client/_app/immutable/chunks/DZNd3jEa.js | 2 + .../client/_app/immutable/chunks/fsu08h6h.js | 1 + .../client/_app/immutable/chunks/hV77cT_P.js | 1 + .../_app/immutable/entry/app.B9iOASPK.js | 2 + .../_app/immutable/entry/start.JQZ0kVpy.js | 1 + .../client/_app/immutable/nodes/0.C7lVdKJN.js | 1 + .../client/_app/immutable/nodes/1.DhhPkK36.js | 1 + .../client/_app/immutable/nodes/2.MK_aCw-P.js | 1 + .../client/_app/immutable/nodes/3.DVfrbbic.js | 1 + .../output/client/_app/version.json | 1 + .../prerendered/dependencies/_app/env.js | 1 + .../output/server/.vite/manifest.json | 155 + .../immutable/assets/_layout.r7T8fV5B.css | 1 + .../output/server/chunks/auth.svelte.js | 70 + .../output/server/chunks/context.js | 70 + .../output/server/chunks/environment.js | 36 + .../output/server/chunks/equality.js | 14 + .../output/server/chunks/exports.js | 174 + .../.svelte-kit/output/server/chunks/index.js | 60 + .../output/server/chunks/index2.js | 1002 +++++ .../output/server/chunks/internal.js | 2669 ++++++++++++ .../output/server/chunks/shared.js | 542 +++ .../output/server/chunks/state.svelte.js | 16 + .../.svelte-kit/output/server/chunks/utils.js | 43 + .../output/server/chunks/utils2.js | 39 + .../server/entries/fallbacks/error.svelte.js | 44 + .../server/entries/pages/_layout.svelte.js | 25 + .../server/entries/pages/_page.svelte.js | 26 + .../entries/pages/callback/_page.svelte.js | 19 + .../.svelte-kit/output/server/index.js | 3863 +++++++++++++++++ .../.svelte-kit/output/server/internal.js | 13 + .../output/server/manifest-full.js | 47 + .../.svelte-kit/output/server/manifest.js | 47 + .../.svelte-kit/output/server/nodes/0.js | 8 + .../.svelte-kit/output/server/nodes/1.js | 8 + .../.svelte-kit/output/server/nodes/2.js | 8 + .../.svelte-kit/output/server/nodes/3.js | 8 + .../.svelte-kit/output/server/remote-entry.js | 540 +++ .../frontend/.svelte-kit/tsconfig.json | 58 + .../.svelte-kit/types/route_meta_data.json | 4 + .../.svelte-kit/types/src/routes/$types.d.ts | 24 + .../types/src/routes/callback/$types.d.ts | 18 + ModeTemplate/frontend/build/.gitkeep | 1 + ModeTemplate/frontend/build/_app/env.js | 1 + .../_app/immutable/assets/0.r7T8fV5B.css | 1 + .../build/_app/immutable/chunks/974AMC2H.js | 1 + .../build/_app/immutable/chunks/BRRLaaPq.js | 1 + .../build/_app/immutable/chunks/Bgo_ZO3W.js | 1 + .../build/_app/immutable/chunks/BtkHyJOA.js | 1 + .../build/_app/immutable/chunks/CqqhLxdp.js | 1 + .../build/_app/immutable/chunks/CuIyQV9Z.js | 1 + .../build/_app/immutable/chunks/DZNd3jEa.js | 2 + .../build/_app/immutable/chunks/fsu08h6h.js | 1 + .../build/_app/immutable/chunks/hV77cT_P.js | 1 + .../_app/immutable/entry/app.B9iOASPK.js | 2 + .../_app/immutable/entry/start.JQZ0kVpy.js | 1 + .../build/_app/immutable/nodes/0.C7lVdKJN.js | 1 + .../build/_app/immutable/nodes/1.DhhPkK36.js | 1 + .../build/_app/immutable/nodes/2.MK_aCw-P.js | 1 + .../build/_app/immutable/nodes/3.DVfrbbic.js | 1 + ModeTemplate/frontend/build/_app/version.json | 1 + ModeTemplate/frontend/build/index.html | 38 + ModeTemplate/frontend/bun.lock | 210 + ModeTemplate/frontend/package.json | 20 + ModeTemplate/frontend/src/app.html | 12 + ModeTemplate/frontend/src/lib/api.ts | 70 + .../frontend/src/lib/stores/auth.svelte.ts | 79 + .../frontend/src/routes/+layout.svelte | 67 + ModeTemplate/frontend/src/routes/+page.svelte | 17 + .../frontend/src/routes/callback/+page.svelte | 38 + ModeTemplate/frontend/static/.gitkeep | 1 + ModeTemplate/frontend/svelte.config.js | 21 + ModeTemplate/frontend/vite.config.ts | 19 + ModeTemplate/package.json | 17 + ModeTemplate/tsconfig.json | 12 + ModeTemplate/types/README.md | 51 + ModeTemplate/types/index.ts | 15 + ModeTemplate/types/types.ts | 87 + components/api-client/README.md | 59 + components/api-client/api-client.ts | 97 + components/api-client/index.ts | 2 + components/auth/README.md | 84 + components/auth/index.ts | 28 + components/auth/microsoft-oauth.ts | 208 + components/auth/types.ts | 99 + components/shared-types/README.md | 51 + components/shared-types/index.ts | 15 + components/shared-types/types.ts | 87 + 120 files changed, 12252 insertions(+) create mode 100644 ModeTemplate/README.md create mode 100644 ModeTemplate/backend/modules/auth/index.ts create mode 100644 ModeTemplate/backend/modules/auth/microsoft-oauth.ts create mode 100644 ModeTemplate/backend/modules/auth/types.ts create mode 100644 ModeTemplate/backend/server.ts create mode 100644 ModeTemplate/bun.lock create mode 100644 ModeTemplate/frontend/.svelte-kit/ambient.d.ts create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client-optimized/app.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client-optimized/matchers.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/0.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/1.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/2.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/3.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client/app.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client/matchers.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client/nodes/0.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client/nodes/1.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client/nodes/2.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/client/nodes/3.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/root.js create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/root.svelte create mode 100644 ModeTemplate/frontend/.svelte-kit/generated/server/internal.js create mode 100644 ModeTemplate/frontend/.svelte-kit/non-ambient.d.ts create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/.gitkeep create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/.vite/manifest.json create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/assets/0.r7T8fV5B.css create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/974AMC2H.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BRRLaaPq.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/Bgo_ZO3W.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BtkHyJOA.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/CqqhLxdp.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/CuIyQV9Z.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/DZNd3jEa.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/fsu08h6h.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/hV77cT_P.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/app.B9iOASPK.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/start.JQZ0kVpy.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/0.C7lVdKJN.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/1.DhhPkK36.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/2.MK_aCw-P.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/3.DVfrbbic.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/client/_app/version.json create mode 100644 ModeTemplate/frontend/.svelte-kit/output/prerendered/dependencies/_app/env.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/.vite/manifest.json create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/_app/immutable/assets/_layout.r7T8fV5B.css create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/auth.svelte.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/context.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/environment.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/equality.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/exports.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/index.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/index2.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/internal.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/shared.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/state.svelte.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils2.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/entries/fallbacks/error.svelte.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_layout.svelte.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_page.svelte.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/callback/_page.svelte.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/index.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/internal.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/manifest-full.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/manifest.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/nodes/0.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/nodes/1.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/nodes/2.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/nodes/3.js create mode 100644 ModeTemplate/frontend/.svelte-kit/output/server/remote-entry.js create mode 100644 ModeTemplate/frontend/.svelte-kit/tsconfig.json create mode 100644 ModeTemplate/frontend/.svelte-kit/types/route_meta_data.json create mode 100644 ModeTemplate/frontend/.svelte-kit/types/src/routes/$types.d.ts create mode 100644 ModeTemplate/frontend/.svelte-kit/types/src/routes/callback/$types.d.ts create mode 100644 ModeTemplate/frontend/build/.gitkeep create mode 100644 ModeTemplate/frontend/build/_app/env.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/assets/0.r7T8fV5B.css create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/974AMC2H.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/BRRLaaPq.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/Bgo_ZO3W.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/BtkHyJOA.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/CqqhLxdp.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/CuIyQV9Z.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/DZNd3jEa.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/fsu08h6h.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/chunks/hV77cT_P.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/entry/app.B9iOASPK.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/entry/start.JQZ0kVpy.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/nodes/0.C7lVdKJN.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/nodes/1.DhhPkK36.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/nodes/2.MK_aCw-P.js create mode 100644 ModeTemplate/frontend/build/_app/immutable/nodes/3.DVfrbbic.js create mode 100644 ModeTemplate/frontend/build/_app/version.json create mode 100644 ModeTemplate/frontend/build/index.html create mode 100644 ModeTemplate/frontend/bun.lock create mode 100644 ModeTemplate/frontend/package.json create mode 100644 ModeTemplate/frontend/src/app.html create mode 100644 ModeTemplate/frontend/src/lib/api.ts create mode 100644 ModeTemplate/frontend/src/lib/stores/auth.svelte.ts create mode 100644 ModeTemplate/frontend/src/routes/+layout.svelte create mode 100644 ModeTemplate/frontend/src/routes/+page.svelte create mode 100644 ModeTemplate/frontend/src/routes/callback/+page.svelte create mode 100644 ModeTemplate/frontend/static/.gitkeep create mode 100644 ModeTemplate/frontend/svelte.config.js create mode 100644 ModeTemplate/frontend/vite.config.ts create mode 100644 ModeTemplate/package.json create mode 100644 ModeTemplate/tsconfig.json create mode 100644 ModeTemplate/types/README.md create mode 100644 ModeTemplate/types/index.ts create mode 100644 ModeTemplate/types/types.ts create mode 100644 components/api-client/README.md create mode 100644 components/api-client/api-client.ts create mode 100644 components/api-client/index.ts create mode 100644 components/auth/README.md create mode 100644 components/auth/index.ts create mode 100644 components/auth/microsoft-oauth.ts create mode 100644 components/auth/types.ts create mode 100644 components/shared-types/README.md create mode 100644 components/shared-types/index.ts create mode 100644 components/shared-types/types.ts diff --git a/ModeTemplate/README.md b/ModeTemplate/README.md new file mode 100644 index 0000000..4070e62 --- /dev/null +++ b/ModeTemplate/README.md @@ -0,0 +1,55 @@ +# Mode Template + +Base template for creating new Modes. Copy this entire folder and rename it. + +## Structure + +``` +ModeTemplate/ +├── backend/ +│ ├── server.ts # Hono API server +│ └── modules/ +│ └── auth/ # Copy of components/auth +├── frontend/ +│ ├── src/ +│ │ ├── routes/ +│ │ │ ├── +page.svelte +│ │ │ └── +layout.svelte +│ │ ├── lib/ +│ │ │ ├── api.ts # API client instance +│ │ │ └── stores/ +│ │ │ └── auth.ts +│ │ └── app.html +│ ├── static/ +│ ├── svelte.config.js +│ ├── vite.config.ts +│ └── package.json +├── types/ # Copy of components/shared-types +├── package.json +├── .env +└── README.md +``` + +## Quick Start + +1. Copy folder: `cp -r ModeTemplate Mode7YourProject` +2. Update `package.json` name +3. Install deps: `cd Mode7YourProject && bun install` +4. Start backend: `bun run backend/server.ts` +5. Start frontend: `cd frontend && bun run dev` + +## Ports + +- Backend runs on PORT from env (orchestrator sets to 3005) +- Frontend dev server runs on 5173 (proxies API to backend) + +## Adding to Orchestrator + +Edit `ModeSwitch/backend/orchestrator.ts`: + +```typescript +const MODE_FOLDERS: Record = { + 'Mode6Test': 'Mode6Test', + 'Mode7YourProject': 'Mode7YourProject', // Add this +}; +``` diff --git a/ModeTemplate/backend/modules/auth/index.ts b/ModeTemplate/backend/modules/auth/index.ts new file mode 100644 index 0000000..6857c77 --- /dev/null +++ b/ModeTemplate/backend/modules/auth/index.ts @@ -0,0 +1,28 @@ +export { + getAuthUrl, + handleCallback, + exchangeCodeForToken, + getMicrosoftUserInfo, + getPocketBaseToken, + getConfigFromEnv, +} from './microsoft-oauth'; + +export type { + AuthResult, + OAuthConfig +} from './microsoft-oauth'; + +export { + HEADERS, + CONTENT_TYPES, + STORAGE_KEYS, + pbAuthHeader, + pbHeaders, + isSessionExpired, +} from './types'; + +export type { + MicrosoftTokens, + PocketBaseTokens, + AuthSession, +} from './types'; diff --git a/ModeTemplate/backend/modules/auth/microsoft-oauth.ts b/ModeTemplate/backend/modules/auth/microsoft-oauth.ts new file mode 100644 index 0000000..9a6c3b2 --- /dev/null +++ b/ModeTemplate/backend/modules/auth/microsoft-oauth.ts @@ -0,0 +1,208 @@ +/** + * Microsoft OAuth Module + * + * Handles Microsoft OAuth flow to authenticate users and retrieve: + * - User's email + * - User's display name + * - PocketBase auth token (user must already exist) + * + * Environment Variables Used: + * - MICROSOFT_CLIENT_ID + * - MICROSOFT_CLIENT_SECRET + * - MICROSOFT_TENANT_ID + * - MICROSOFT_REDIRECT_URI + * - MICROSOFT_SCOPES + * - PB_URL + */ + +interface MicrosoftTokenResponse { + access_token: string; + token_type: string; + expires_in: number; + scope: string; + refresh_token?: string; +} + +interface MicrosoftUserInfo { + id: string; + displayName: string; + mail: string; + userPrincipalName: string; +} + +export interface AuthResult { + email: string; + displayName: string; + pocketbaseToken: string; +} + +export interface OAuthConfig { + clientId: string; + clientSecret: string; + tenantId: string; + redirectUri: string; + scopes: string; + pbUrl: string; +} + +/** + * Build config from process.env + */ +export function getConfigFromEnv(): OAuthConfig { + const clientId = process.env.MICROSOFT_CLIENT_ID; + const clientSecret = process.env.MICROSOFT_CLIENT_SECRET; + const tenantId = process.env.MICROSOFT_TENANT_ID; + const redirectUri = process.env.MICROSOFT_REDIRECT_URI; + const scopes = process.env.MICROSOFT_SCOPES; + const pbUrl = process.env.PB_URL; + + if (!clientId || !clientSecret || !tenantId || !redirectUri || !scopes || !pbUrl) { + throw new Error('Missing required OAuth environment variables'); + } + + return { clientId, clientSecret, tenantId, redirectUri, scopes, pbUrl }; +} + +/** + * Generate the Microsoft OAuth authorization URL + */ +export function getAuthUrl(config: OAuthConfig): string { + const params = new URLSearchParams({ + client_id: config.clientId, + response_type: 'code', + redirect_uri: config.redirectUri, + response_mode: 'query', + scope: config.scopes, + state: crypto.randomUUID(), + }); + + return `https://login.microsoftonline.com/${config.tenantId}/oauth2/v2.0/authorize?${params}`; +} + +/** + * Exchange authorization code for access token + */ +export async function exchangeCodeForToken( + code: string, + config: OAuthConfig +): Promise { + const response = await fetch( + `https://login.microsoftonline.com/${config.tenantId}/oauth2/v2.0/token`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: new URLSearchParams({ + client_id: config.clientId, + client_secret: config.clientSecret, + code, + redirect_uri: config.redirectUri, + grant_type: 'authorization_code', + scope: config.scopes, + }), + } + ); + + if (!response.ok) { + const error = await response.text(); + throw new Error(`Token exchange failed: ${error}`); + } + + return response.json(); +} + +/** + * Get user info from Microsoft Graph API + */ +export async function getMicrosoftUserInfo( + accessToken: string +): Promise { + const response = await fetch('https://graph.microsoft.com/v1.0/me', { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); + + if (!response.ok) { + const error = await response.text(); + throw new Error(`Failed to get user info: ${error}`); + } + + return response.json(); +} + +/** + * Authenticate existing user with PocketBase + * User MUST already exist - no user creation + */ +export async function getPocketBaseToken( + email: string, + pbUrl: string +): Promise { + // Look up user by email - user must exist + const searchResponse = await fetch( + `${pbUrl}/api/collections/users/records?filter=(email='${encodeURIComponent(email)}')`, + { + headers: { + 'Content-Type': 'application/json', + }, + } + ); + + if (!searchResponse.ok) { + throw new Error('Failed to query PocketBase'); + } + + const searchData = await searchResponse.json(); + + if (!searchData.items || searchData.items.length === 0) { + throw new Error('Access denied: User does not exist'); + } + + // User exists - authenticate via OAuth + const authResponse = await fetch(`${pbUrl}/api/collections/users/auth-with-oauth2`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + provider: 'microsoft', + }), + }); + + if (!authResponse.ok) { + const error = await authResponse.text(); + throw new Error(`PocketBase auth failed: ${error}`); + } + + const data = await authResponse.json(); + return data.token; +} + +/** + * Complete OAuth flow: code -> user info + PocketBase token + * Denies access if user doesn't exist in PocketBase + */ +export async function handleCallback( + code: string, + config: OAuthConfig +): Promise { + // 1. Exchange code for Microsoft access token + const tokenResponse = await exchangeCodeForToken(code, config); + + // 2. Get user info from Microsoft Graph + const userInfo = await getMicrosoftUserInfo(tokenResponse.access_token); + + const email = userInfo.mail || userInfo.userPrincipalName; + const displayName = userInfo.displayName; + + // 3. Get PocketBase auth token (user must exist) + const pocketbaseToken = await getPocketBaseToken(email, config.pbUrl); + + return { + email, + displayName, + pocketbaseToken, + }; +} diff --git a/ModeTemplate/backend/modules/auth/types.ts b/ModeTemplate/backend/modules/auth/types.ts new file mode 100644 index 0000000..9b32e5f --- /dev/null +++ b/ModeTemplate/backend/modules/auth/types.ts @@ -0,0 +1,99 @@ +/** + * Auth Constants & Types + * + * Standard naming conventions for auth-related values. + * Use these throughout all modes to maintain consistency. + */ + +// ============================================ +// TOKEN TYPES +// ============================================ + +/** Token received from Microsoft OAuth */ +export interface MicrosoftTokens { + accessToken: string; + refreshToken?: string; + expiresIn: number; +} + +/** Token received from PocketBase */ +export interface PocketBaseTokens { + token: string; + // PB tokens don't have separate refresh - they expire and re-auth is needed +} + +/** Combined auth state after successful login */ +export interface AuthSession { + email: string; + displayName: string; + pbToken: string; // PocketBase auth token + msAccessToken?: string; // Microsoft access token (if needed for Graph API calls) + expiresAt?: number; // Unix timestamp when session expires +} + +// ============================================ +// HEADER NAMES +// ============================================ + +export const HEADERS = { + /** Authorization header for PocketBase API calls */ + PB_AUTH: 'Authorization', + + /** Content type for JSON requests */ + CONTENT_TYPE: 'Content-Type', +} as const; + +// ============================================ +// HEADER VALUES +// ============================================ + +export const CONTENT_TYPES = { + JSON: 'application/json', + FORM: 'application/x-www-form-urlencoded', +} as const; + +// ============================================ +// COOKIE/STORAGE KEYS +// ============================================ + +export const STORAGE_KEYS = { + /** PocketBase token storage key */ + PB_TOKEN: 'pb_token', + + /** Session data storage key */ + SESSION: 'auth_session', +} as const; + +// ============================================ +// HELPER FUNCTIONS +// ============================================ + +/** + * Create Authorization header value for PocketBase + */ +export function pbAuthHeader(token: string): string { + return `Bearer ${token}`; +} + +/** + * Create headers object for PocketBase API calls + */ +export function pbHeaders(token?: string): Record { + const headers: Record = { + [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.JSON, + }; + + if (token) { + headers[HEADERS.PB_AUTH] = pbAuthHeader(token); + } + + return headers; +} + +/** + * Check if session is expired + */ +export function isSessionExpired(session: AuthSession): boolean { + if (!session.expiresAt) return false; + return Date.now() > session.expiresAt; +} diff --git a/ModeTemplate/backend/server.ts b/ModeTemplate/backend/server.ts new file mode 100644 index 0000000..a7b589e --- /dev/null +++ b/ModeTemplate/backend/server.ts @@ -0,0 +1,72 @@ +/** + * Backend Server + * + * Hono API server with auth routes pre-configured. + */ + +import { Hono } from 'hono'; +import { cors } from 'hono/cors'; +import { getAuthUrl, handleCallback, getConfigFromEnv } from './modules/auth'; + +const app = new Hono(); + +// CORS for frontend +app.use('/*', cors({ + origin: ['http://localhost:5173', 'http://localhost:3005'], + credentials: true, +})); + +// Health check +app.get('/health', (c) => c.json({ status: 'ok' })); + +// ============================================ +// AUTH ROUTES +// ============================================ + +const authConfig = getConfigFromEnv(); + +app.get('/auth/login', (c) => { + return c.redirect(getAuthUrl(authConfig)); +}); + +app.get('/auth/callback', async (c) => { + const code = c.req.query('code'); + + if (!code) { + return c.json({ error: 'No authorization code' }, 400); + } + + try { + const result = await handleCallback(code, authConfig); + + // Return token and user info + // Frontend should store token and redirect + return c.json(result); + } catch (err) { + const message = err instanceof Error ? err.message : 'Auth failed'; + return c.json({ error: message }, 403); + } +}); + +// ============================================ +// API ROUTES +// ============================================ + +app.get('/api/me', async (c) => { + // TODO: Validate token from Authorization header + // Return current user info + return c.json({ message: 'Implement me' }); +}); + +// ============================================ +// START SERVER +// ============================================ + +const port = Number(process.env.PORT) || 3005; + +console.log(`[Server] Starting on port ${port}...`); + +export default { + port, + fetch: app.fetch, +}; diff --git a/ModeTemplate/bun.lock b/ModeTemplate/bun.lock new file mode 100644 index 0000000..e4dc136 --- /dev/null +++ b/ModeTemplate/bun.lock @@ -0,0 +1,27 @@ +{ + "lockfileVersion": 1, + "configVersion": 1, + "workspaces": { + "": { + "name": "mode-template", + "dependencies": { + "hono": "^4.0.0", + }, + "devDependencies": { + "bun-types": "latest", + "typescript": "^5.0.0", + }, + }, + }, + "packages": { + "@types/node": ["@types/node@25.0.9", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw=="], + + "bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="], + + "hono": ["hono@4.11.4", "", {}, "sha512-U7tt8JsyrxSRKspfhtLET79pU8K+tInj5QZXs1jSugO1Vq5dFj3kmZsRldo29mTBfcjDRVRXrEZ6LS63Cog9ZA=="], + + "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + + "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], + } +} diff --git a/ModeTemplate/frontend/.svelte-kit/ambient.d.ts b/ModeTemplate/frontend/.svelte-kit/ambient.d.ts new file mode 100644 index 0000000..36cd65f --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/ambient.d.ts @@ -0,0 +1,175 @@ + +// this file is generated — do not edit it + + +/// + +/** + * Environment variables [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env`. Like [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), this module cannot be imported into client-side code. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured). + * + * _Unlike_ [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), the values exported from this module are statically injected into your bundle at build time, enabling optimisations like dead code elimination. + * + * ```ts + * import { API_KEY } from '$env/static/private'; + * ``` + * + * Note that all environment variables referenced in your code should be declared (for example in an `.env` file), even if they don't have a value until the app is deployed: + * + * ``` + * MY_FEATURE_FLAG="" + * ``` + * + * You can override `.env` values from the command line like so: + * + * ```sh + * MY_FEATURE_FLAG="enabled" npm run dev + * ``` + */ +declare module '$env/static/private' { + export const SHELL: string; + export const npm_command: string; + export const COLORTERM: string; + export const HISTCONTROL: string; + export const TERM_PROGRAM_VERSION: string; + export const NODE: string; + export const npm_config_local_prefix: string; + export const PWD: string; + export const LOGNAME: string; + export const XDG_SESSION_TYPE: string; + export const _: string; + export const VSCODE_GIT_ASKPASS_NODE: string; + export const MOTD_SHOWN: string; + export const HOME: string; + export const LANG: string; + export const npm_package_version: string; + export const SSL_CERT_DIR: string; + export const GIT_ASKPASS: string; + export const SSH_CONNECTION: string; + export const npm_lifecycle_script: string; + export const VSCODE_GIT_ASKPASS_EXTRA_ARGS: string; + export const VSCODE_PYTHON_AUTOACTIVATE_GUARD: string; + export const XDG_SESSION_CLASS: string; + export const TERM: string; + export const npm_package_name: string; + export const USER: string; + export const GIT_PAGER: string; + export const VSCODE_GIT_IPC_HANDLE: string; + export const npm_lifecycle_event: string; + export const SHLVL: string; + export const XDG_SESSION_ID: string; + export const npm_config_user_agent: string; + export const npm_execpath: string; + export const XDG_RUNTIME_DIR: string; + export const SSL_CERT_FILE: string; + export const SSH_CLIENT: string; + export const DEBUGINFOD_URLS: string; + export const npm_package_json: string; + export const BUN_INSTALL: string; + export const VSCODE_GIT_ASKPASS_MAIN: string; + export const BROWSER: string; + export const PATH: string; + export const DBUS_SESSION_BUS_ADDRESS: string; + export const MAIL: string; + export const npm_node_execpath: string; + export const OLDPWD: string; + export const TERM_PROGRAM: string; + export const VSCODE_IPC_HOOK_CLI: string; + export const NODE_ENV: string; +} + +/** + * Similar to [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private), except that it only includes environment variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code. + * + * Values are replaced statically at build time. + * + * ```ts + * import { PUBLIC_BASE_URL } from '$env/static/public'; + * ``` + */ +declare module '$env/static/public' { + +} + +/** + * This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured). + * + * This module cannot be imported into client-side code. + * + * ```ts + * import { env } from '$env/dynamic/private'; + * console.log(env.DEPLOYMENT_SPECIFIC_VARIABLE); + * ``` + * + * > [!NOTE] In `dev`, `$env/dynamic` always includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter. + */ +declare module '$env/dynamic/private' { + export const env: { + SHELL: string; + npm_command: string; + COLORTERM: string; + HISTCONTROL: string; + TERM_PROGRAM_VERSION: string; + NODE: string; + npm_config_local_prefix: string; + PWD: string; + LOGNAME: string; + XDG_SESSION_TYPE: string; + _: string; + VSCODE_GIT_ASKPASS_NODE: string; + MOTD_SHOWN: string; + HOME: string; + LANG: string; + npm_package_version: string; + SSL_CERT_DIR: string; + GIT_ASKPASS: string; + SSH_CONNECTION: string; + npm_lifecycle_script: string; + VSCODE_GIT_ASKPASS_EXTRA_ARGS: string; + VSCODE_PYTHON_AUTOACTIVATE_GUARD: string; + XDG_SESSION_CLASS: string; + TERM: string; + npm_package_name: string; + USER: string; + GIT_PAGER: string; + VSCODE_GIT_IPC_HANDLE: string; + npm_lifecycle_event: string; + SHLVL: string; + XDG_SESSION_ID: string; + npm_config_user_agent: string; + npm_execpath: string; + XDG_RUNTIME_DIR: string; + SSL_CERT_FILE: string; + SSH_CLIENT: string; + DEBUGINFOD_URLS: string; + npm_package_json: string; + BUN_INSTALL: string; + VSCODE_GIT_ASKPASS_MAIN: string; + BROWSER: string; + PATH: string; + DBUS_SESSION_BUS_ADDRESS: string; + MAIL: string; + npm_node_execpath: string; + OLDPWD: string; + TERM_PROGRAM: string; + VSCODE_IPC_HOOK_CLI: string; + NODE_ENV: string; + [key: `PUBLIC_${string}`]: undefined; + [key: `${string}`]: string | undefined; + } +} + +/** + * Similar to [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), but only includes variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code. + * + * Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead. + * + * ```ts + * import { env } from '$env/dynamic/public'; + * console.log(env.PUBLIC_DEPLOYMENT_SPECIFIC_VARIABLE); + * ``` + */ +declare module '$env/dynamic/public' { + export const env: { + [key: `PUBLIC_${string}`]: string | undefined; + } +} diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/app.js b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/app.js new file mode 100644 index 0000000..e924ffb --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/app.js @@ -0,0 +1,31 @@ +export { matchers } from './matchers.js'; + +export const nodes = [ + () => import('./nodes/0'), + () => import('./nodes/1'), + () => import('./nodes/2'), + () => import('./nodes/3') +]; + +export const server_loads = []; + +export const dictionary = { + "/": [2], + "/callback": [3] + }; + +export const hooks = { + handleError: (({ error }) => { console.error(error) }), + + reroute: (() => {}), + transport: {} +}; + +export const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode])); +export const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode])); + +export const hash = false; + +export const decode = (type, value) => decoders[type](value); + +export { default as root } from '../root.js'; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/matchers.js b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/matchers.js new file mode 100644 index 0000000..f6bd30a --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/matchers.js @@ -0,0 +1 @@ +export const matchers = {}; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/0.js b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/0.js new file mode 100644 index 0000000..fed1375 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/0.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/+layout.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/1.js b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/1.js new file mode 100644 index 0000000..bf58bad --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/1.js @@ -0,0 +1 @@ +export { default as component } from "../../../../node_modules/@sveltejs/kit/src/runtime/components/svelte-5/error.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/2.js b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/2.js new file mode 100644 index 0000000..1cb4f85 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/2.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/+page.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/3.js b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/3.js new file mode 100644 index 0000000..cd3d8b8 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client-optimized/nodes/3.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/callback/+page.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client/app.js b/ModeTemplate/frontend/.svelte-kit/generated/client/app.js new file mode 100644 index 0000000..e924ffb --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client/app.js @@ -0,0 +1,31 @@ +export { matchers } from './matchers.js'; + +export const nodes = [ + () => import('./nodes/0'), + () => import('./nodes/1'), + () => import('./nodes/2'), + () => import('./nodes/3') +]; + +export const server_loads = []; + +export const dictionary = { + "/": [2], + "/callback": [3] + }; + +export const hooks = { + handleError: (({ error }) => { console.error(error) }), + + reroute: (() => {}), + transport: {} +}; + +export const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode])); +export const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode])); + +export const hash = false; + +export const decode = (type, value) => decoders[type](value); + +export { default as root } from '../root.js'; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client/matchers.js b/ModeTemplate/frontend/.svelte-kit/generated/client/matchers.js new file mode 100644 index 0000000..f6bd30a --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client/matchers.js @@ -0,0 +1 @@ +export const matchers = {}; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/0.js b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/0.js new file mode 100644 index 0000000..fed1375 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/0.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/+layout.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/1.js b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/1.js new file mode 100644 index 0000000..bf58bad --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/1.js @@ -0,0 +1 @@ +export { default as component } from "../../../../node_modules/@sveltejs/kit/src/runtime/components/svelte-5/error.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/2.js b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/2.js new file mode 100644 index 0000000..1cb4f85 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/2.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/+page.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/3.js b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/3.js new file mode 100644 index 0000000..cd3d8b8 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/client/nodes/3.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/callback/+page.svelte"; \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/root.js b/ModeTemplate/frontend/.svelte-kit/generated/root.js new file mode 100644 index 0000000..4d1e892 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/root.js @@ -0,0 +1,3 @@ +import { asClassComponent } from 'svelte/legacy'; +import Root from './root.svelte'; +export default asClassComponent(Root); \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/root.svelte b/ModeTemplate/frontend/.svelte-kit/generated/root.svelte new file mode 100644 index 0000000..0795183 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/root.svelte @@ -0,0 +1,68 @@ + + + + +{#if constructors[1]} + {@const Pyramid_0 = constructors[0]} + + + + + + +{:else} + {@const Pyramid_0 = constructors[0]} + + + +{/if} + +{#if mounted} +
+ {#if navigated} + {title} + {/if} +
+{/if} \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/generated/server/internal.js b/ModeTemplate/frontend/.svelte-kit/generated/server/internal.js new file mode 100644 index 0000000..b36bf4b --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/generated/server/internal.js @@ -0,0 +1,53 @@ + +import root from '../root.js'; +import { set_building, set_prerendering } from '__sveltekit/environment'; +import { set_assets } from '$app/paths/internal/server'; +import { set_manifest, set_read_implementation } from '__sveltekit/server'; +import { set_private_env, set_public_env } from '../../../node_modules/@sveltejs/kit/src/runtime/shared-server.js'; + +export const options = { + app_template_contains_nonce: false, + async: false, + csp: {"mode":"auto","directives":{"upgrade-insecure-requests":false,"block-all-mixed-content":false},"reportOnly":{"upgrade-insecure-requests":false,"block-all-mixed-content":false}}, + csrf_check_origin: true, + csrf_trusted_origins: [], + embedded: false, + env_public_prefix: 'PUBLIC_', + env_private_prefix: '', + hash_routing: false, + hooks: null, // added lazily, via `get_hooks` + preload_strategy: "modulepreload", + root, + service_worker: false, + service_worker_options: undefined, + templates: { + app: ({ head, body, assets, nonce, env }) => "\n\n \n \n \n Mode Template\n " + head + "\n \n \n
" + body + "
\n \n\n", + error: ({ status, message }) => "\n\n\t\n\t\t\n\t\t" + message + "\n\n\t\t\n\t\n\t\n\t\t
\n\t\t\t" + status + "\n\t\t\t
\n\t\t\t\t

" + message + "

\n\t\t\t
\n\t\t
\n\t\n\n" + }, + version_hash: "1u12ak4" +}; + +export async function get_hooks() { + let handle; + let handleFetch; + let handleError; + let handleValidationError; + let init; + + + let reroute; + let transport; + + + return { + handle, + handleFetch, + handleError, + handleValidationError, + init, + reroute, + transport + }; +} + +export { set_assets, set_building, set_manifest, set_prerendering, set_private_env, set_public_env, set_read_implementation }; diff --git a/ModeTemplate/frontend/.svelte-kit/non-ambient.d.ts b/ModeTemplate/frontend/.svelte-kit/non-ambient.d.ts new file mode 100644 index 0000000..956d7b3 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/non-ambient.d.ts @@ -0,0 +1,42 @@ + +// this file is generated — do not edit it + + +declare module "svelte/elements" { + export interface HTMLAttributes { + 'data-sveltekit-keepfocus'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-preload-code'?: + | true + | '' + | 'eager' + | 'viewport' + | 'hover' + | 'tap' + | 'off' + | undefined + | null; + 'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null; + 'data-sveltekit-reload'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-replacestate'?: true | '' | 'off' | undefined | null; + } +} + +export {}; + + +declare module "$app/types" { + export interface AppTypes { + RouteId(): "/" | "/callback"; + RouteParams(): { + + }; + LayoutParams(): { + "/": Record; + "/callback": Record + }; + Pathname(): "/" | "/callback" | "/callback/"; + ResolvedPathname(): `${"" | `/${string}`}${ReturnType}`; + Asset(): "/.gitkeep" | string & {}; + } +} \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/.gitkeep b/ModeTemplate/frontend/.svelte-kit/output/client/.gitkeep new file mode 100644 index 0000000..e12d700 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/.gitkeep @@ -0,0 +1 @@ +/* Empty file - SvelteKit requires this */ diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/.vite/manifest.json b/ModeTemplate/frontend/.svelte-kit/output/client/.vite/manifest.json new file mode 100644 index 0000000..b5bf041 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/.vite/manifest.json @@ -0,0 +1,153 @@ +{ + ".svelte-kit/generated/client-optimized/app.js": { + "file": "_app/immutable/entry/app.B9iOASPK.js", + "name": "entry/app", + "src": ".svelte-kit/generated/client-optimized/app.js", + "isEntry": true, + "imports": [ + "_CqqhLxdp.js", + "_DZNd3jEa.js", + "_BtkHyJOA.js", + "_fsu08h6h.js", + "_hV77cT_P.js" + ], + "dynamicImports": [ + ".svelte-kit/generated/client-optimized/nodes/0.js", + ".svelte-kit/generated/client-optimized/nodes/1.js", + ".svelte-kit/generated/client-optimized/nodes/2.js", + ".svelte-kit/generated/client-optimized/nodes/3.js" + ] + }, + ".svelte-kit/generated/client-optimized/nodes/0.js": { + "file": "_app/immutable/nodes/0.C7lVdKJN.js", + "name": "nodes/0", + "src": ".svelte-kit/generated/client-optimized/nodes/0.js", + "isEntry": true, + "isDynamicEntry": true, + "imports": [ + "_DZNd3jEa.js", + "_BtkHyJOA.js", + "_CqqhLxdp.js", + "_fsu08h6h.js", + "_BRRLaaPq.js" + ], + "css": [ + "_app/immutable/assets/0.r7T8fV5B.css" + ] + }, + ".svelte-kit/generated/client-optimized/nodes/1.js": { + "file": "_app/immutable/nodes/1.DhhPkK36.js", + "name": "nodes/1", + "src": ".svelte-kit/generated/client-optimized/nodes/1.js", + "isEntry": true, + "isDynamicEntry": true, + "imports": [ + "_DZNd3jEa.js", + "_974AMC2H.js", + "_CqqhLxdp.js", + "_CuIyQV9Z.js" + ] + }, + ".svelte-kit/generated/client-optimized/nodes/2.js": { + "file": "_app/immutable/nodes/2.MK_aCw-P.js", + "name": "nodes/2", + "src": ".svelte-kit/generated/client-optimized/nodes/2.js", + "isEntry": true, + "isDynamicEntry": true, + "imports": [ + "_DZNd3jEa.js", + "_974AMC2H.js", + "_CqqhLxdp.js", + "_fsu08h6h.js", + "_BRRLaaPq.js" + ] + }, + ".svelte-kit/generated/client-optimized/nodes/3.js": { + "file": "_app/immutable/nodes/3.DVfrbbic.js", + "name": "nodes/3", + "src": ".svelte-kit/generated/client-optimized/nodes/3.js", + "isEntry": true, + "isDynamicEntry": true, + "imports": [ + "_DZNd3jEa.js", + "_BtkHyJOA.js", + "_CqqhLxdp.js", + "_fsu08h6h.js", + "_hV77cT_P.js", + "_CuIyQV9Z.js", + "_BRRLaaPq.js" + ] + }, + "_974AMC2H.js": { + "file": "_app/immutable/chunks/974AMC2H.js", + "name": "legacy", + "imports": [ + "_CqqhLxdp.js" + ] + }, + "_BRRLaaPq.js": { + "file": "_app/immutable/chunks/BRRLaaPq.js", + "name": "auth.svelte", + "imports": [ + "_CqqhLxdp.js" + ] + }, + "_Bgo_ZO3W.js": { + "file": "_app/immutable/chunks/Bgo_ZO3W.js", + "name": "index", + "imports": [ + "_CqqhLxdp.js" + ] + }, + "_BtkHyJOA.js": { + "file": "_app/immutable/chunks/BtkHyJOA.js", + "name": "index-client", + "imports": [ + "_CqqhLxdp.js" + ] + }, + "_CqqhLxdp.js": { + "file": "_app/immutable/chunks/CqqhLxdp.js", + "name": "runtime" + }, + "_CuIyQV9Z.js": { + "file": "_app/immutable/chunks/CuIyQV9Z.js", + "name": "entry", + "imports": [ + "_CqqhLxdp.js", + "_Bgo_ZO3W.js", + "_BtkHyJOA.js" + ] + }, + "_DZNd3jEa.js": { + "file": "_app/immutable/chunks/DZNd3jEa.js", + "name": "disclose-version", + "imports": [ + "_CqqhLxdp.js" + ] + }, + "_fsu08h6h.js": { + "file": "_app/immutable/chunks/fsu08h6h.js", + "name": "if", + "imports": [ + "_CqqhLxdp.js" + ] + }, + "_hV77cT_P.js": { + "file": "_app/immutable/chunks/hV77cT_P.js", + "name": "store", + "imports": [ + "_Bgo_ZO3W.js", + "_CqqhLxdp.js" + ] + }, + "node_modules/@sveltejs/kit/src/runtime/client/entry.js": { + "file": "_app/immutable/entry/start.JQZ0kVpy.js", + "name": "entry/start", + "src": "node_modules/@sveltejs/kit/src/runtime/client/entry.js", + "isEntry": true, + "imports": [ + "_CuIyQV9Z.js" + ] + } +} \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/assets/0.r7T8fV5B.css b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/assets/0.r7T8fV5B.css new file mode 100644 index 0000000..5c42dbb --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/assets/0.r7T8fV5B.css @@ -0,0 +1 @@ +.app.svelte-12qhfyh{display:flex;flex-direction:column;min-height:100vh}header.svelte-12qhfyh{padding:1rem;background:#f5f5f5;border-bottom:1px solid #ddd}nav.svelte-12qhfyh{display:flex;gap:1rem;align-items:center}nav.svelte-12qhfyh a:where(.svelte-12qhfyh){text-decoration:none;color:#333}main.svelte-12qhfyh{flex:1;padding:1rem}button.svelte-12qhfyh{padding:.5rem 1rem;cursor:pointer} diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/974AMC2H.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/974AMC2H.js new file mode 100644 index 0000000..86271a4 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/974AMC2H.js @@ -0,0 +1 @@ +import{i as g,j as d,k as c,l as m,o as i,q as b,g as p,v,w as k,x as h}from"./CqqhLxdp.js";function y(n=!1){const s=g,e=s.l.u;if(!e)return;let f=()=>v(s.s);if(n){let o=0,t={};const _=k(()=>{let l=!1;const r=s.s;for(const a in r)r[a]!==t[a]&&(t[a]=r[a],l=!0);return l&&o++,o});f=()=>p(_)}e.b.length&&d(()=>{u(s,f),i(e.b)}),c(()=>{const o=m(()=>e.m.map(b));return()=>{for(const t of o)typeof t=="function"&&t()}}),e.a.length&&c(()=>{u(s,f),i(e.a)})}function u(n,s){if(n.l.s)for(const e of n.l.s)p(e);s()}h();export{y as i}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BRRLaaPq.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BRRLaaPq.js new file mode 100644 index 0000000..e2fa7d4 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BRRLaaPq.js @@ -0,0 +1 @@ +var S=t=>{throw TypeError(t)};var c=(t,e,i)=>e.has(t)||S("Cannot "+i);var s=(t,e,i)=>(c(t,e,"read from private field"),i?i.call(t):e.get(t)),n=(t,e,i)=>e.has(t)?S("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i);import{h as d,g,e as h,u as _}from"./CqqhLxdp.js";const o={PB_TOKEN:"pb_token",SESSION:"auth_session"};var a,r,l,u;class f{constructor(){n(this,a,d(null));n(this,r,d(!0));n(this,l,_(()=>this._session!==null));n(this,u,_(()=>this._session?{email:this._session.email,displayName:this._session.displayName}:null))}get _session(){return g(s(this,a))}set _session(e){h(s(this,a),e,!0)}get _loading(){return g(s(this,r))}set _loading(e){h(s(this,r),e,!0)}get isAuthenticated(){return g(s(this,l))}set isAuthenticated(e){h(s(this,l),e)}get session(){return this._session}get loading(){return this._loading}get user(){return g(s(this,u))}set user(e){h(s(this,u),e)}hydrate(){if(typeof localStorage>"u")return;const e=localStorage.getItem(o.SESSION);if(e)try{this._session=JSON.parse(e)}catch{localStorage.removeItem(o.SESSION),localStorage.removeItem(o.PB_TOKEN)}this._loading=!1}login(e){typeof localStorage<"u"&&(localStorage.setItem(o.SESSION,JSON.stringify(e)),localStorage.setItem(o.PB_TOKEN,e.pbToken)),this._session=e,this._loading=!1}logout(){typeof localStorage<"u"&&(localStorage.removeItem(o.SESSION),localStorage.removeItem(o.PB_TOKEN)),this._session=null}redirectToLogin(){typeof window<"u"&&(window.location.href="/auth/login")}}a=new WeakMap,r=new WeakMap,l=new WeakMap,u=new WeakMap;const I=new f;export{I as a}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/Bgo_ZO3W.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/Bgo_ZO3W.js new file mode 100644 index 0000000..5f7272a --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/Bgo_ZO3W.js @@ -0,0 +1 @@ +import{n as o,l as a,z as d}from"./CqqhLxdp.js";function p(s,u,e){if(s==null)return u(void 0),o;const t=a(()=>s.subscribe(u,e));return t.unsubscribe?()=>t.unsubscribe():t}const i=[];function _(s,u=o){let e=null;const t=new Set;function c(r){if(d(s,r)&&(s=r,e)){const b=!i.length;for(const n of t)n[1](),i.push(n,s);if(b){for(let n=0;n{t.delete(n),t.size===0&&e&&(e(),e=null)}}return{set:c,update:f,subscribe:l}}function h(s){let u;return p(s,e=>u=e)(),u}export{h as g,p as s,_ as w}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BtkHyJOA.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BtkHyJOA.js new file mode 100644 index 0000000..7cb1533 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/BtkHyJOA.js @@ -0,0 +1 @@ +import{k as o,i as t,A as c,l}from"./CqqhLxdp.js";function u(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function r(n){t===null&&u(),c&&t.l!==null?a(t).m.push(n):o(()=>{const e=l(n);if(typeof e=="function")return e})}function a(n){var e=n.l;return e.u??(e.u={a:[],b:[],m:[]})}export{r as o}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/CqqhLxdp.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/CqqhLxdp.js new file mode 100644 index 0000000..7f6543b --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/CqqhLxdp.js @@ -0,0 +1 @@ +var nn=Object.defineProperty;var ct=e=>{throw TypeError(e)};var rn=(e,t,n)=>t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>rn(e,typeof t!="symbol"?t+"":t,n),Ge=(e,t,n)=>t.has(e)||ct("Cannot "+n);var y=(e,t,n)=>(Ge(e,t,"read from private field"),n?n.call(e):t.get(e)),L=(e,t,n)=>t.has(e)?ct("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),oe=(e,t,n,r)=>(Ge(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),W=(e,t,n)=>(Ge(e,t,"access private method"),n);var sn=Array.isArray,fn=Array.prototype.indexOf,Kn=Array.from,zn=Object.defineProperty,me=Object.getOwnPropertyDescriptor,ln=Object.getOwnPropertyDescriptors,an=Object.prototype,un=Array.prototype,wt=Object.getPrototypeOf,_t=Object.isExtensible;const $n=()=>{};function Zn(e){return e()}function on(e){for(var t=0;t{e=r,t=s});return{promise:n,resolve:e,reject:t}}const T=2,Ie=4,xe=8,gt=1<<24,Y=16,U=32,ue=64,mt=128,N=512,A=1024,k=2048,$=4096,M=8192,V=16384,tt=32768,Fe=65536,vt=1<<17,Tt=1<<18,Oe=1<<19,At=1<<20,se=32768,ze=1<<21,nt=1<<22,G=1<<23,Te=Symbol("$state"),Jn=Symbol("legacy props"),ce=new class extends Error{constructor(){super(...arguments);B(this,"name","StaleReactionError");B(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}},rt=3,Rt=8;function cn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function _n(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function vn(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function dn(e){throw new Error("https://svelte.dev/e/effect_orphan")}function pn(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Xn(){throw new Error("https://svelte.dev/e/hydration_failed")}function Qn(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function hn(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function yn(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function wn(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function er(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const tr=1,nr=2,rr=4,sr=8,fr=16,ir=1,lr=2,En="[",gn="[!",mn="]",st={},E=Symbol();function ft(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function ar(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let fe=!1;function ur(e){fe=e}let g;function he(e){if(e===null)throw ft(),st;return g=e}function or(){return he(Z(g))}function cr(e){if(fe){if(Z(g)!==null)throw ft(),st;g=e}}function _r(e=1){if(fe){for(var t=e,n=g;t--;)n=Z(n);g=n}}function vr(e=!0){for(var t=0,n=g;;){if(n.nodeType===Rt){var r=n.data;if(r===mn){if(t===0)return n;t-=1}else(r===En||r===gn)&&(t+=1)}var s=Z(n);e&&n.remove(),n=s}}function dr(e){if(!e||e.nodeType!==Rt)throw ft(),st;return e.data}function bt(e){return e===this.v}function Tn(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function St(e){return!Tn(e,this.v)}let Be=!1;function pr(){Be=!0}let S=null;function Ce(e){S=e}function hr(e,t=!1,n){S={p:S,i:!1,c:null,e:null,s:e,x:null,l:Be&&!t?{s:null,u:null,$:[]}:null}}function yr(e){var t=S,n=t.e;if(n!==null){t.e=null;for(var r of n)Ht(r)}return t.i=!0,S=t.p,{}}function ke(){return!Be||S!==null&&S.l===null}let Q=[];function xt(){var e=Q;Q=[],on(e)}function An(e){if(Q.length===0&&!Ae){var t=Q;queueMicrotask(()=>{t===Q&&xt()})}Q.push(e)}function Rn(){for(;Q.length>0;)xt()}function bn(e){var t=h;if(t===null)return _.f|=G,e;if(t.f&tt)Me(e,t);else{if(!(t.f&mt))throw e;t.b.error(e)}}function Me(e,t){for(;t!==null;){if(t.f&mt)try{t.b.error(e);return}catch(n){e=n}t=t.parent}throw e}const Sn=-7169;function R(e,t){e.f=e.f&Sn|t}function it(e){e.f&N||e.deps===null?R(e,A):R(e,$)}function Ot(e){if(e!==null)for(const t of e)!(t.f&T)||!(t.f&se)||(t.f^=se,Ot(t.deps))}function xn(e,t,n){e.f&k?t.add(e):e.f&$&&n.add(e),Ot(e.deps),R(e,A)}const Ne=new Set;let p=null,m=null,P=[],He=null,$e=!1,Ae=!1;var _e,ve,ee,te,Se,de,pe,I,Ze,Je,kt,Dt;const Ue=class Ue{constructor(){L(this,I);B(this,"committed",!1);B(this,"current",new Map);B(this,"previous",new Map);L(this,_e,new Set);L(this,ve,new Set);L(this,ee,0);L(this,te,0);L(this,Se,null);L(this,de,new Set);L(this,pe,new Set);B(this,"skipped_effects",new Set);B(this,"is_fork",!1)}is_deferred(){return this.is_fork||y(this,te)>0}process(t){var s;P=[],this.apply();var n=[],r=[];for(const f of t)W(this,I,Ze).call(this,f,n,r);this.is_fork||W(this,I,kt).call(this),this.is_deferred()?(W(this,I,Je).call(this,r),W(this,I,Je).call(this,n)):(p=null,dt(r),dt(n),(s=y(this,Se))==null||s.resolve()),m=null}capture(t,n){n!==E&&!this.previous.has(t)&&this.previous.set(t,n),t.f&G||(this.current.set(t,t.v),m==null||m.set(t,t.v))}activate(){p=this,this.apply()}deactivate(){p===this&&(p=null,m=null)}flush(){if(this.activate(),P.length>0){if(Pt(),p!==null&&p!==this)return}else y(this,ee)===0&&this.process([]);this.deactivate()}discard(){for(const t of y(this,ve))t(this);y(this,ve).clear()}increment(t){oe(this,ee,y(this,ee)+1),t&&oe(this,te,y(this,te)+1)}decrement(t){oe(this,ee,y(this,ee)-1),t&&oe(this,te,y(this,te)-1),this.revive()}revive(){for(const t of y(this,de))y(this,pe).delete(t),R(t,k),ie(t);for(const t of y(this,pe))R(t,$),ie(t);this.flush()}oncommit(t){y(this,_e).add(t)}ondiscard(t){y(this,ve).add(t)}settled(){return(y(this,Se)??oe(this,Se,Et())).promise}static ensure(){if(p===null){const t=p=new Ue;Ne.add(p),Ae||Ue.enqueue(()=>{p===t&&t.flush()})}return p}static enqueue(t){An(t)}apply(){}};_e=new WeakMap,ve=new WeakMap,ee=new WeakMap,te=new WeakMap,Se=new WeakMap,de=new WeakMap,pe=new WeakMap,I=new WeakSet,Ze=function(t,n,r){t.f^=A;for(var s=t.first,f=null;s!==null;){var i=s.f,u=(i&(U|ue))!==0,l=u&&(i&A)!==0,a=l||(i&M)!==0||this.skipped_effects.has(s);if(!a&&s.fn!==null){u?s.f^=A:f!==null&&i&(Ie|xe|gt)?f.b.defer_effect(s):i&Ie?n.push(s):De(s)&&(i&Y&&y(this,de).add(s),be(s));var o=s.first;if(o!==null){s=o;continue}}var c=s.parent;for(s=s.next;s===null&&c!==null;)c===f&&(f=null),s=c.next,c=c.parent}},Je=function(t){for(var n=0;n1){this.previous.clear();var t=m,n=!0;for(const f of Ne){if(f===this){n=!1;continue}const i=[];for(const[l,a]of this.current){if(f.current.has(l))if(n&&a!==f.current.get(l))f.current.set(l,a);else continue;i.push(l)}if(i.length===0)continue;const u=[...f.current.keys()].filter(l=>!this.current.has(l));if(u.length>0){var r=P;P=[];const l=new Set,a=new Map;for(const o of i)Nt(o,u,l,a);if(P.length>0){p=f,f.apply();for(const o of P)W(s=f,I,Ze).call(s,o,[],[]);f.deactivate()}P=r}}p=null,m=t}this.committed=!0,Ne.delete(this)};let ye=Ue;function On(e){var t=Ae;Ae=!0;try{for(var n;;){if(Rn(),P.length===0&&(p==null||p.flush(),P.length===0))return He=null,n;Pt()}}finally{Ae=t}}function Pt(){var e=ne;$e=!0;var t=null;try{var n=0;for(Le(!0);P.length>0;){var r=ye.ensure();if(n++>1e3){var s,f;kn()}r.process(P),K.clear()}}finally{$e=!1,Le(e),He=null}}function kn(){try{pn()}catch(e){Me(e,He)}}let F=null;function dt(e){var t=e.length;if(t!==0){for(var n=0;n0)){K.clear();for(const s of F){if(s.f&(V|M))continue;const f=[s];let i=s.parent;for(;i!==null;)F.has(i)&&(F.delete(i),f.push(i)),i=i.parent;for(let u=f.length-1;u>=0;u--){const l=f[u];l.f&(V|M)||be(l)}}F.clear()}}F=null}}function Nt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const s of e.reactions){const f=s.f;f&T?Nt(s,t,n,r):f&(nt|Y)&&!(f&k)&&It(s,t,r)&&(R(s,k),ie(s))}}function It(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const s of e.deps){if(t.includes(s))return!0;if(s.f&T&&It(s,t,n))return n.set(s,!0),!0}return n.set(e,!1),!1}function ie(e){for(var t=He=e;t.parent!==null;){t=t.parent;var n=t.f;if($e&&t===h&&n&Y&&!(n&Tt))return;if(n&(ue|U)){if(!(n&A))return;t.f^=A}}P.push(t)}function Dn(e,t,n,r){const s=ke()?lt:In;if(n.length===0&&e.length===0){r(t.map(s));return}var f=p,i=h,u=Pn();function l(){Promise.all(n.map(a=>Nn(a))).then(a=>{u();try{r([...t.map(s),...a])}catch(o){i.f&V||Me(o,i)}f==null||f.deactivate(),je()}).catch(a=>{Me(a,i)})}e.length>0?Promise.all(e).then(()=>{u();try{return l()}finally{f==null||f.deactivate(),je()}}):l()}function Pn(){var e=h,t=_,n=S,r=p;return function(f=!0){we(e),z(t),Ce(n),f&&(r==null||r.activate())}}function je(){we(null),z(null),Ce(null)}function lt(e){var t=T|k,n=_!==null&&_.f&T?_:null;return h!==null&&(h.f|=Oe),{ctx:S,deps:null,effects:null,equals:bt,f:t,fn:e,reactions:null,rv:0,v:E,wv:0,parent:n??h,ac:null}}function Nn(e,t,n){let r=h;r===null&&cn();var s=r.b,f=void 0,i=ut(E),u=!_,l=new Map;return Ln(()=>{var d;var a=Et();f=a.promise;try{Promise.resolve(e()).then(a.resolve,a.reject).then(()=>{o===p&&o.committed&&o.deactivate(),je()})}catch(w){a.reject(w),je()}var o=p;if(u){var c=s.is_rendered();s.update_pending_count(1),o.increment(c),(d=l.get(o))==null||d.reject(ce),l.delete(o),l.set(o,a)}const v=(w,q=void 0)=>{if(o.activate(),q)q!==ce&&(i.f|=G,Xe(i,q));else{i.f&G&&(i.f^=G),Xe(i,w);for(const[J,Pe]of l){if(l.delete(J),J===o)break;Pe.reject(ce)}}u&&(s.update_pending_count(-1),o.decrement(c))};a.promise.then(v,w=>v(null,w||"unknown"))}),qn(()=>{for(const a of l.values())a.reject(ce)}),new Promise(a=>{function o(c){function v(){c===f?a(i):o(f)}c.then(v,v)}o(f)})}function wr(e){const t=lt(e);return Zt(t),t}function In(e){const t=lt(e);return t.equals=St,t}function Ft(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n0&&!Mt&&Cn()}return t}function Cn(){Mt=!1;var e=ne;Le(!0);const t=Array.from(We);try{for(const n of t)n.f&A&&R(n,$),De(n)&&be(n)}finally{Le(e)}We.clear()}function Ke(e){X(e,e.v+1)}function jt(e,t){var n=e.reactions;if(n!==null)for(var r=ke(),s=n.length,f=0;f{if(re===f)return u();var l=_,a=re;z(null),yt(f);var o=u();return z(l),yt(a),o};return r&&n.set("length",H(e.length)),new Proxy(e,{defineProperty(u,l,a){(!("value"in a)||a.configurable===!1||a.enumerable===!1||a.writable===!1)&&hn();var o=n.get(l);return o===void 0?o=i(()=>{var c=H(a.value);return n.set(l,c),c}):X(o,a.value,!0),!0},deleteProperty(u,l){var a=n.get(l);if(a===void 0){if(l in u){const o=i(()=>H(E));n.set(l,o),Ke(s)}}else X(a,E),Ke(s);return!0},get(u,l,a){var d;if(l===Te)return e;var o=n.get(l),c=l in u;if(o===void 0&&(!c||(d=me(u,l))!=null&&d.writable)&&(o=i(()=>{var w=Ee(c?u[l]:E),q=H(w);return q}),n.set(l,o)),o!==void 0){var v=ge(o);return v===E?void 0:v}return Reflect.get(u,l,a)},getOwnPropertyDescriptor(u,l){var a=Reflect.getOwnPropertyDescriptor(u,l);if(a&&"value"in a){var o=n.get(l);o&&(a.value=ge(o))}else if(a===void 0){var c=n.get(l),v=c==null?void 0:c.v;if(c!==void 0&&v!==E)return{enumerable:!0,configurable:!0,value:v,writable:!0}}return a},has(u,l){var v;if(l===Te)return!0;var a=n.get(l),o=a!==void 0&&a.v!==E||Reflect.has(u,l);if(a!==void 0||h!==null&&(!o||(v=me(u,l))!=null&&v.writable)){a===void 0&&(a=i(()=>{var d=o?Ee(u[l]):E,w=H(d);return w}),n.set(l,a));var c=ge(a);if(c===E)return!1}return o},set(u,l,a,o){var ot;var c=n.get(l),v=l in u;if(r&&l==="length")for(var d=a;dH(E)),n.set(d+"",w))}if(c===void 0)(!v||(ot=me(u,l))!=null&&ot.writable)&&(c=i(()=>H(void 0)),X(c,Ee(a)),n.set(l,c));else{v=c.v!==E;var q=i(()=>Ee(a));X(c,q)}var J=Reflect.getOwnPropertyDescriptor(u,l);if(J!=null&&J.set&&J.set.call(o,a),!v){if(r&&typeof l=="string"){var Pe=n.get("length"),Ve=Number(l);Number.isInteger(Ve)&&Ve>=Pe.v&&X(Pe,Ve+1)}Ke(s)}return!0},ownKeys(u){ge(s);var l=Reflect.ownKeys(u).filter(c=>{var v=n.get(c);return v===void 0||v.v!==E});for(var[a,o]of n)o.v!==E&&!(a in u)&&l.push(a);return l},setPrototypeOf(){yn()}})}var pt,Mn,qt,Lt;function gr(){if(pt===void 0){pt=window,Mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;qt=me(t,"firstChild").get,Lt=me(t,"nextSibling").get,_t(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),_t(n)&&(n.__t=void 0)}}function qe(e=""){return document.createTextNode(e)}function Qe(e){return qt.call(e)}function Z(e){return Lt.call(e)}function mr(e,t){if(!fe)return Qe(e);var n=Qe(g);if(n===null)n=g.appendChild(qe());else if(t&&n.nodeType!==rt){var r=qe();return n==null||n.before(r),he(r),r}return he(n),n}function Tr(e,t=!1){if(!fe){var n=Qe(e);return n instanceof Comment&&n.data===""?Z(n):n}if(t&&(g==null?void 0:g.nodeType)!==rt){var r=qe();return g==null||g.before(r),he(r),r}return g}function Ar(e,t=1,n=!1){let r=fe?g:e;for(var s;t--;)s=r,r=Z(r);if(!fe)return r;if(n&&(r==null?void 0:r.nodeType)!==rt){var f=qe();return r===null?s==null||s.after(f):r.before(f),he(f),f}return he(r),r}function Rr(e){e.textContent=""}function br(){return!1}function Yt(e){var t=_,n=h;z(null),we(null);try{return e()}finally{z(t),we(n)}}function Ut(e){h===null&&(_===null&&dn(),vn()),ae&&_n()}function jn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function j(e,t,n){var r=h;r!==null&&r.f&M&&(e|=M);var s={ctx:S,deps:null,nodes:null,f:e|k|N,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(n)try{be(s),s.f|=tt}catch(u){throw le(s),u}else t!==null&&ie(s);var f=s;if(n&&f.deps===null&&f.teardown===null&&f.nodes===null&&f.first===f.last&&!(f.f&Oe)&&(f=f.first,e&Y&&e&Fe&&f!==null&&(f.f|=Fe)),f!==null&&(f.parent=r,r!==null&&jn(f,r),_!==null&&_.f&T&&!(e&ue))){var i=_;(i.effects??(i.effects=[])).push(f)}return s}function Bt(){return _!==null&&!C}function qn(e){const t=j(xe,null,!1);return R(t,A),t.teardown=e,t}function Sr(e){Ut();var t=h.f,n=!_&&(t&U)!==0&&(t&tt)===0;if(n){var r=S;(r.e??(r.e=[])).push(e)}else return Ht(e)}function Ht(e){return j(Ie|At,e,!1)}function xr(e){return Ut(),j(xe|At,e,!0)}function Or(e){ye.ensure();const t=j(ue|Oe,e,!0);return(n={})=>new Promise(r=>{n.outro?Bn(t,()=>{le(t),r(void 0)}):(le(t),r(void 0))})}function kr(e){return j(Ie,e,!1)}function Ln(e){return j(nt|Oe,e,!0)}function Dr(e,t=0){return j(xe|t,e,!0)}function Pr(e,t=[],n=[],r=[]){Dn(r,t,n,s=>{j(xe,()=>e(...s.map(ge)),!0)})}function Nr(e,t=0){var n=j(Y|t,e,!0);return n}function Ir(e){return j(U|Oe,e,!0)}function Vt(e){var t=e.teardown;if(t!==null){const n=ae,r=_;ht(!0),z(null);try{t.call(null)}finally{ht(n),z(r)}}}function Gt(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const s=n.ac;s!==null&&Yt(()=>{s.abort(ce)});var r=n.next;n.f&ue?n.parent=null:le(n,t),n=r}}function Yn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&U||le(t),t=n}}function le(e,t=!0){var n=!1;(t||e.f&Tt)&&e.nodes!==null&&e.nodes.end!==null&&(Un(e.nodes.start,e.nodes.end),n=!0),Gt(e,t&&!n),Ye(e,0),R(e,V);var r=e.nodes&&e.nodes.t;if(r!==null)for(const f of r)f.stop();Vt(e);var s=e.parent;s!==null&&s.first!==null&&Kt(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Un(e,t){for(;e!==null;){var n=e===t?null:Z(e);e.remove(),e=n}}function Kt(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Bn(e,t,n=!0){var r=[];zt(e,r,!0);var s=()=>{n&&le(e),t&&t()},f=r.length;if(f>0){var i=()=>--f||s();for(var u of r)u.out(i)}else s()}function zt(e,t,n){if(!(e.f&M)){e.f^=M;var r=e.nodes&&e.nodes.t;if(r!==null)for(const u of r)(u.is_global||n)&&t.push(u);for(var s=e.first;s!==null;){var f=s.next,i=(s.f&Fe)!==0||(s.f&U)!==0&&(e.f&Y)!==0;zt(s,t,i?n:!1),s=f}}}function Fr(e){$t(e,!0)}function $t(e,t){if(e.f&M){e.f^=M,e.f&A||(R(e,k),ie(e));for(var n=e.first;n!==null;){var r=n.next,s=(n.f&Fe)!==0||(n.f&U)!==0;$t(n,s?t:!1),n=r}var f=e.nodes&&e.nodes.t;if(f!==null)for(const i of f)(i.is_global||t)&&i.in()}}function Cr(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var s=n===r?null:Z(n);t.append(n),n=s}}let ne=!1;function Le(e){ne=e}let ae=!1;function ht(e){ae=e}let _=null,C=!1;function z(e){_=e}let h=null;function we(e){h=e}let x=null;function Zt(e){_!==null&&(x===null?x=[e]:x.push(e))}let b=null,O=0,D=null;function Hn(e){D=e}let Jt=1,Re=0,re=Re;function yt(e){re=e}function Wt(){return++Jt}function De(e){var t=e.f;if(t&k)return!0;if(t&T&&(e.f&=~se),t&$){for(var n=e.deps,r=n.length,s=0;se.wv)return!0}t&N&&m===null&&R(e,A)}return!1}function Xt(e,t,n=!0){var r=e.reactions;if(r!==null&&!(x!=null&&x.includes(e)))for(var s=0;s{e.ac.abort(ce)}),e.ac=null);try{e.f|=ze;var o=e.fn,c=o(),v=e.deps;if(b!==null){var d;if(Ye(e,O),v!==null&&O>0)for(v.length=O+b.length,d=0;d{throw TypeError(t)};var Oe=(t,e,n)=>e.has(t)||Xt("Cannot "+n);var w=(t,e,n)=>(Oe(t,e,"read from private field"),n?n.call(t):e.get(t)),A=(t,e,n)=>e.has(t)?Xt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n);import{h as T,g as I,e as O,ad as ht,aM as Pe}from"./CqqhLxdp.js";import{w as jt}from"./Bgo_ZO3W.js";import{o as Qt}from"./BtkHyJOA.js";class Nt{constructor(e,n){this.status=e,typeof n=="string"?this.body={message:n}:n?this.body=n:this.body={message:`Error: ${e}`}}toString(){return JSON.stringify(this.body)}}class Dt{constructor(e,n){this.status=e,this.location=n}}class Vt extends Error{constructor(e,n,r){super(r),this.status=e,this.text=n}}new URL("sveltekit-internal://");function Ce(t,e){return t==="/"||e==="ignore"?t:e==="never"?t.endsWith("/")?t.slice(0,-1):t:e==="always"&&!t.endsWith("/")?t+"/":t}function $e(t){return t.split("%25").map(decodeURI).join("%25")}function je(t){for(const e in t)t[e]=decodeURIComponent(t[e]);return t}function Lt({href:t}){return t.split("#")[0]}function Ne(...t){let e=5381;for(const n of t)if(typeof n=="string"){let r=n.length;for(;r;)e=e*33^n.charCodeAt(--r)}else if(ArrayBuffer.isView(n)){const r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);let a=r.length;for(;a;)e=e*33^r[--a]}else throw new TypeError("value must be a string or TypedArray");return(e>>>0).toString(36)}new TextEncoder;new TextDecoder;function De(t){const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r((t instanceof Request?t.method:(e==null?void 0:e.method)||"GET")!=="GET"&&Y.delete(qt(t)),Ve(t,e));const Y=new Map;function qe(t,e){const n=qt(t,e),r=document.querySelector(n);if(r!=null&&r.textContent){r.remove();let{body:a,...s}=JSON.parse(r.textContent);const o=r.getAttribute("data-ttl");return o&&Y.set(n,{body:a,init:s,ttl:1e3*Number(o)}),r.getAttribute("data-b64")!==null&&(a=De(a)),Promise.resolve(new Response(a,s))}return window.fetch(t,e)}function Be(t,e,n){if(Y.size>0){const r=qt(t,n),a=Y.get(r);if(a){if(performance.now(){const a=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(r);if(a)return e.push({name:a[1],matcher:a[2],optional:!1,rest:!0,chained:!0}),"(?:/([^]*))?";const s=/^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(r);if(s)return e.push({name:s[1],matcher:s[2],optional:!0,rest:!1,chained:!0}),"(?:/([^/]+))?";if(!r)return;const o=r.split(/\[(.+?)\](?!\])/);return"/"+o.map((c,l)=>{if(l%2){if(c.startsWith("x+"))return Ut(String.fromCharCode(parseInt(c.slice(2),16)));if(c.startsWith("u+"))return Ut(String.fromCharCode(...c.slice(2).split("-").map(_=>parseInt(_,16))));const d=Ke.exec(c),[,u,y,f,h]=d;return e.push({name:f,matcher:h,optional:!!u,rest:!!y,chained:y?l===1&&o[0]==="":!1}),y?"([^]*?)":u?"([^/]*)?":"([^/]+?)"}return Ut(c)}).join("")}).join("")}/?$`),params:e}}function Fe(t){return t!==""&&!/^\([^)]+\)$/.test(t)}function Ge(t){return t.slice(1).split("/").filter(Fe)}function We(t,e,n){const r={},a=t.slice(1),s=a.filter(i=>i!==void 0);let o=0;for(let i=0;id).join("/"),o=0),l===void 0){c.rest&&(r[c.name]="");continue}if(!c.matcher||n[c.matcher](l)){r[c.name]=l;const d=e[i+1],u=a[i+1];d&&!d.rest&&d.optional&&u&&c.chained&&(o=0),!d&&!u&&Object.keys(r).length===s.length&&(o=0);continue}if(c.optional&&c.chained){o++;continue}return}if(!o)return r}function Ut(t){return t.normalize().replace(/[[\]]/g,"\\$&").replace(/%/g,"%25").replace(/\//g,"%2[Ff]").replace(/\?/g,"%3[Ff]").replace(/#/g,"%23").replace(/[.*+?^${}()|\\]/g,"\\$&")}function Ye({nodes:t,server_loads:e,dictionary:n,matchers:r}){const a=new Set(e);return Object.entries(n).map(([i,[c,l,d]])=>{const{pattern:u,params:y}=Me(i),f={id:i,exec:h=>{const _=u.exec(h);if(_)return We(_,y,r)},errors:[1,...d||[]].map(h=>t[h]),layouts:[0,...l||[]].map(o),leaf:s(c)};return f.errors.length=f.layouts.length=Math.max(f.errors.length,f.layouts.length),f});function s(i){const c=i<0;return c&&(i=~i),[c,t[i]]}function o(i){return i===void 0?i:[a.has(i),t[i]]}}function ue(t,e=JSON.parse){try{return e(sessionStorage[t])}catch{}}function Zt(t,e,n=JSON.stringify){const r=n(e);try{sessionStorage[t]=r}catch{}}var se;const U=((se=globalThis.__sveltekit_1u12ak4)==null?void 0:se.base)??"";var ie;const ze=((ie=globalThis.__sveltekit_1u12ak4)==null?void 0:ie.assets)??U??"",He="1768972126462",de="sveltekit:snapshot",he="sveltekit:scroll",pe="sveltekit:states",Je="sveltekit:pageurl",F="sveltekit:history",H="sveltekit:navigation",D={tap:1,hover:2,viewport:3,eager:4,off:-1,false:-1},kt=location.origin;function Bt(t){if(t instanceof URL)return t;let e=document.baseURI;if(!e){const n=document.getElementsByTagName("base");e=n.length?n[0].href:document.URL}return new URL(t,e)}function Et(){return{x:pageXOffset,y:pageYOffset}}function M(t,e){return t.getAttribute(`data-sveltekit-${e}`)}const te={...D,"":D.hover};function ge(t){let e=t.assignedSlot??t.parentNode;return(e==null?void 0:e.nodeType)===11&&(e=e.host),e}function me(t,e){for(;t&&t!==e;){if(t.nodeName.toUpperCase()==="A"&&t.hasAttribute("href"))return t;t=ge(t)}}function It(t,e,n){let r;try{if(r=new URL(t instanceof SVGAElement?t.href.baseVal:t.href,document.baseURI),n&&r.hash.match(/^#[^/]/)){const i=location.hash.split("#")[1]||"/";r.hash=`#${i}${r.hash}`}}catch{}const a=t instanceof SVGAElement?t.target.baseVal:t.target,s=!r||!!a||St(r,e,n)||(t.getAttribute("rel")||"").split(/\s+/).includes("external"),o=(r==null?void 0:r.origin)===kt&&t.hasAttribute("download");return{url:r,external:s,target:a,download:o}}function pt(t){let e=null,n=null,r=null,a=null,s=null,o=null,i=t;for(;i&&i!==document.documentElement;)r===null&&(r=M(i,"preload-code")),a===null&&(a=M(i,"preload-data")),e===null&&(e=M(i,"keepfocus")),n===null&&(n=M(i,"noscroll")),s===null&&(s=M(i,"reload")),o===null&&(o=M(i,"replacestate")),i=ge(i);function c(l){switch(l){case"":case"true":return!0;case"off":case"false":return!1;default:return}}return{preload_code:te[r??"off"],preload_data:te[a??"off"],keepfocus:c(e),noscroll:c(n),reload:c(s),replace_state:c(o)}}function ee(t){const e=jt(t);let n=!0;function r(){n=!0,e.update(o=>o)}function a(o){n=!1,e.set(o)}function s(o){let i;return e.subscribe(c=>{(i===void 0||n&&c!==i)&&o(i=c)})}return{notify:r,set:a,subscribe:s}}const _e={v:()=>{}};function Xe(){const{set:t,subscribe:e}=jt(!1);let n;async function r(){clearTimeout(n);try{const a=await fetch(`${ze}/_app/version.json`,{headers:{pragma:"no-cache","cache-control":"no-cache"}});if(!a.ok)return!1;const o=(await a.json()).version!==He;return o&&(t(!0),_e.v(),clearTimeout(n)),o}catch{return!1}}return{subscribe:e,check:r}}function St(t,e,n){return t.origin!==kt||!t.pathname.startsWith(e)?!0:n?t.pathname!==location.pathname:!1}function Ln(t){}const we=new Set(["load","prerender","csr","ssr","trailingSlash","config"]);[...we];const Qe=new Set([...we]);[...Qe];function Ze(t){return t.filter(e=>e!=null)}function Kt(t){return t instanceof Nt||t instanceof Vt?t.status:500}function tn(t){return t instanceof Vt?t.text:"Internal Error"}let R,J,At;const en=Qt.toString().includes("$$")||/function \w+\(\) \{\}/.test(Qt.toString());var et,nt,at,rt,ot,st,it,ct,ce,lt,le,ft,fe;en?(R={data:{},form:null,error:null,params:{},route:{id:null},state:{},status:-1,url:new URL("https://example.com")},J={current:null},At={current:!1}):(R=new(ce=class{constructor(){A(this,et,T({}));A(this,nt,T(null));A(this,at,T(null));A(this,rt,T({}));A(this,ot,T({id:null}));A(this,st,T({}));A(this,it,T(-1));A(this,ct,T(new URL("https://example.com")))}get data(){return I(w(this,et))}set data(e){O(w(this,et),e)}get form(){return I(w(this,nt))}set form(e){O(w(this,nt),e)}get error(){return I(w(this,at))}set error(e){O(w(this,at),e)}get params(){return I(w(this,rt))}set params(e){O(w(this,rt),e)}get route(){return I(w(this,ot))}set route(e){O(w(this,ot),e)}get state(){return I(w(this,st))}set state(e){O(w(this,st),e)}get status(){return I(w(this,it))}set status(e){O(w(this,it),e)}get url(){return I(w(this,ct))}set url(e){O(w(this,ct),e)}},et=new WeakMap,nt=new WeakMap,at=new WeakMap,rt=new WeakMap,ot=new WeakMap,st=new WeakMap,it=new WeakMap,ct=new WeakMap,ce),J=new(le=class{constructor(){A(this,lt,T(null))}get current(){return I(w(this,lt))}set current(e){O(w(this,lt),e)}},lt=new WeakMap,le),At=new(fe=class{constructor(){A(this,ft,T(!1))}get current(){return I(w(this,ft))}set current(e){O(w(this,ft),e)}},ft=new WeakMap,fe),_e.v=()=>At.current=!0);function nn(t){Object.assign(R,t)}const an=new Set(["icon","shortcut icon","apple-touch-icon"]),q=ue(he)??{},X=ue(de)??{},N={url:ee({}),page:ee({}),navigating:jt(null),updated:Xe()};function Mt(t){q[t]=Et()}function rn(t,e){let n=t+1;for(;q[n];)delete q[n],n+=1;for(n=e+1;X[n];)delete X[n],n+=1}function Q(t,e=!1){return e?location.replace(t.href):location.href=t.href,new Promise(()=>{})}async function ve(){if("serviceWorker"in navigator){const t=await navigator.serviceWorker.getRegistration(U||"/");t&&await t.update()}}function ne(){}let Ft,Ot,gt,C,Pt,b;const mt=[],_t=[];let v=null;function Ct(){var t;(t=v==null?void 0:v.fork)==null||t.then(e=>e==null?void 0:e.discard()),v=null}const dt=new Map,ye=new Set,on=new Set,z=new Set;let m={branch:[],error:null,url:null},be=!1,wt=!1,ae=!0,Z=!1,W=!1,ke=!1,Gt=!1,Ee,E,L,V;const vt=new Set,re=new Map;async function In(t,e,n){var s,o,i,c,l;(s=globalThis.__sveltekit_1u12ak4)!=null&&s.data&&globalThis.__sveltekit_1u12ak4.data,document.URL!==location.href&&(location.href=location.href),b=t,await((i=(o=t.hooks).init)==null?void 0:i.call(o)),Ft=Ye(t),C=document.documentElement,Pt=e,Ot=t.nodes[0],gt=t.nodes[1],Ot(),gt(),E=(c=history.state)==null?void 0:c[F],L=(l=history.state)==null?void 0:l[H],E||(E=L=Date.now(),history.replaceState({...history.state,[F]:E,[H]:L},""));const r=q[E];function a(){r&&(history.scrollRestoration="manual",scrollTo(r.x,r.y))}n?(a(),await vn(Pt,n)):(await G({type:"enter",url:Bt(b.hash?kn(new URL(location.href)):location.href),replace_state:!0}),a()),wn()}function sn(){mt.length=0,Gt=!1}function Se(t){_t.some(e=>e==null?void 0:e.snapshot)&&(X[t]=_t.map(e=>{var n;return(n=e==null?void 0:e.snapshot)==null?void 0:n.capture()}))}function Re(t){var e;(e=X[t])==null||e.forEach((n,r)=>{var a,s;(s=(a=_t[r])==null?void 0:a.snapshot)==null||s.restore(n)})}function oe(){Mt(E),Zt(he,q),Se(L),Zt(de,X)}async function xe(t,e,n,r){let a;e.invalidateAll&&Ct(),await G({type:"goto",url:Bt(t),keepfocus:e.keepFocus,noscroll:e.noScroll,replace_state:e.replaceState,state:e.state,redirect_count:n,nav_token:r,accept:()=>{e.invalidateAll&&(Gt=!0,a=[...re.keys()]),e.invalidate&&e.invalidate.forEach(_n)}}),e.invalidateAll&&ht().then(ht).then(()=>{re.forEach(({resource:s},o)=>{var i;a!=null&&a.includes(o)&&((i=s.refresh)==null||i.call(s))})})}async function cn(t){if(t.id!==(v==null?void 0:v.id)){Ct();const e={};vt.add(e),v={id:t.id,token:e,promise:Ue({...t,preload:e}).then(n=>(vt.delete(e),n.type==="loaded"&&n.state.error&&Ct(),n)),fork:null}}return v.promise}async function Tt(t){var n;const e=(n=await Rt(t,!1))==null?void 0:n.route;e&&await Promise.all([...e.layouts,e.leaf].map(r=>r==null?void 0:r[1]()))}async function Le(t,e,n){var a;m=t.state;const r=document.querySelector("style[data-sveltekit]");if(r&&r.remove(),Object.assign(R,t.props.page),Ee=new b.root({target:e,props:{...t.props,stores:N,components:_t},hydrate:n,sync:!1}),await Promise.resolve(),Re(L),n){const s={from:null,to:{params:m.params,route:{id:((a=m.route)==null?void 0:a.id)??null},url:new URL(location.href)},willUnload:!1,type:"enter",complete:Promise.resolve()};z.forEach(o=>o(s))}wt=!0}function yt({url:t,params:e,branch:n,status:r,error:a,route:s,form:o}){let i="never";if(U&&(t.pathname===U||t.pathname===U+"/"))i="always";else for(const f of n)(f==null?void 0:f.slash)!==void 0&&(i=f.slash);t.pathname=Ce(t.pathname,i),t.search=t.search;const c={type:"loaded",state:{url:t,params:e,branch:n,error:a,route:s},props:{constructors:Ze(n).map(f=>f.node.component),page:Jt(R)}};o!==void 0&&(c.props.form=o);let l={},d=!R,u=0;for(let f=0;fi(new URL(o))))return!0;return!1}function Yt(t,e){return(t==null?void 0:t.type)==="data"?t:(t==null?void 0:t.type)==="skip"?e??null:null}function un(t,e){if(!t)return new Set(e.searchParams.keys());const n=new Set([...t.searchParams.keys(),...e.searchParams.keys()]);for(const r of n){const a=t.searchParams.getAll(r),s=e.searchParams.getAll(r);a.every(o=>s.includes(o))&&s.every(o=>a.includes(o))&&n.delete(r)}return n}function dn({error:t,url:e,route:n,params:r}){return{type:"loaded",state:{error:t,url:e,route:n,params:r,branch:[]},props:{page:Jt(R),constructors:[]}}}async function Ue({id:t,invalidating:e,url:n,params:r,route:a,preload:s}){if((v==null?void 0:v.id)===t)return vt.delete(v.token),v.promise;const{errors:o,layouts:i,leaf:c}=a,l=[...i,c];o.forEach(g=>g==null?void 0:g().catch(()=>{})),l.forEach(g=>g==null?void 0:g[1]().catch(()=>{}));const d=m.url?t!==bt(m.url):!1,u=m.route?a.id!==m.route.id:!1,y=un(m.url,n);let f=!1;const h=l.map(async(g,p)=>{var $;if(!g)return;const k=m.branch[p];return g[1]===(k==null?void 0:k.loader)&&!fn(f,u,d,y,($=k.universal)==null?void 0:$.uses,r)?k:(f=!0,Wt({loader:g[1],url:n,params:r,route:a,parent:async()=>{var ut;const P={};for(let B=0;B{});const _=[];for(let g=0;gPromise.resolve({}),server_data_node:Yt(s)}),i={node:await gt(),loader:gt,universal:null,server:null,data:null};return yt({url:n,params:a,branch:[o,i],status:t,error:e,route:null})}catch(o){if(o instanceof Dt)return xe(new URL(o.location,location.href),{},0);throw o}}async function pn(t){const e=t.href;if(dt.has(e))return dt.get(e);let n;try{const r=(async()=>{let a=await b.hooks.reroute({url:new URL(t),fetch:async(s,o)=>ln(s,o,t).promise})??t;if(typeof a=="string"){const s=new URL(t);b.hash?s.hash=a:s.pathname=a,a=s}return a})();dt.set(e,r),n=await r}catch{dt.delete(e);return}return n}async function Rt(t,e){if(t&&!St(t,U,b.hash)){const n=await pn(t);if(!n)return;const r=gn(n);for(const a of Ft){const s=a.exec(r);if(s)return{id:bt(t),invalidating:e,route:a,params:je(s),url:t}}}}function gn(t){return $e(b.hash?t.hash.replace(/^#/,"").replace(/[?#].+/,""):t.pathname.slice(U.length))||"/"}function bt(t){return(b.hash?t.hash.replace(/^#/,""):t.pathname)+t.search}function Ae({url:t,type:e,intent:n,delta:r,event:a}){let s=!1;const o=Ht(m,n,t,e);r!==void 0&&(o.navigation.delta=r),a!==void 0&&(o.navigation.event=a);const i={...o.navigation,cancel:()=>{s=!0,o.reject(new Error("navigation cancelled"))}};return Z||ye.forEach(c=>c(i)),s?null:o}async function G({type:t,url:e,popped:n,keepfocus:r,noscroll:a,replace_state:s,state:o={},redirect_count:i=0,nav_token:c={},accept:l=ne,block:d=ne,event:u}){var B;const y=V;V=c;const f=await Rt(e,!1),h=t==="enter"?Ht(m,f,e,t):Ae({url:e,type:t,delta:n==null?void 0:n.delta,intent:f,event:u});if(!h){d(),V===c&&(V=y);return}const _=E,g=L;l(),Z=!0,wt&&h.navigation.type!=="enter"&&N.navigating.set(J.current=h.navigation);let p=f&&await Ue(f);if(!p){if(St(e,U,b.hash))return await Q(e,s);p=await Te(e,{id:null},await tt(new Vt(404,"Not Found",`Not found: ${e.pathname}`),{url:e,params:{},route:{id:null}}),404,s)}if(e=(f==null?void 0:f.url)||e,V!==c)return h.reject(new Error("navigation aborted")),!1;if(p.type==="redirect"){if(i<20){await G({type:t,url:new URL(p.location,e),popped:n,keepfocus:r,noscroll:a,replace_state:s,state:o,redirect_count:i+1,nav_token:c}),h.fulfil(void 0);return}p=await zt({status:500,error:await tt(new Error("Redirect loop"),{url:e,params:{},route:{id:null}}),url:e,route:{id:null}})}else p.props.page.status>=400&&await N.updated.check()&&(await ve(),await Q(e,s));if(sn(),Mt(_),Se(g),p.props.page.url.pathname!==e.pathname&&(e.pathname=p.props.page.url.pathname),o=n?n.state:o,!n){const S=s?0:1,K={[F]:E+=S,[H]:L+=S,[pe]:o};(s?history.replaceState:history.pushState).call(history,K,"",e),s||rn(E,L)}const k=f&&(v==null?void 0:v.id)===f.id?v.fork:null;v=null,p.props.page.state=o;let x;if(wt){const S=(await Promise.all(Array.from(on,j=>j(h.navigation)))).filter(j=>typeof j=="function");if(S.length>0){let j=function(){S.forEach(xt=>{z.delete(xt)})};S.push(j),S.forEach(xt=>{z.add(xt)})}m=p.state,p.props.page&&(p.props.page.url=e);const K=k&&await k;K?x=K.commit():(Ee.$set(p.props),nn(p.props.page),x=(B=Pe)==null?void 0:B()),ke=!0}else await Le(p,Pt,!1);const{activeElement:$}=document;await x,await ht(),await ht();let P=n?n.scroll:a?Et():null;if(ae){const S=e.hash&&document.getElementById(Ie(e));if(P)scrollTo(P.x,P.y);else if(S){S.scrollIntoView();const{top:K,left:j}=S.getBoundingClientRect();P={x:pageXOffset+j,y:pageYOffset+K}}else scrollTo(0,0)}const ut=document.activeElement!==$&&document.activeElement!==document.body;!r&&!ut&&bn(e,P),ae=!0,p.props.page&&Object.assign(R,p.props.page),Z=!1,t==="popstate"&&Re(L),h.fulfil(void 0),z.forEach(S=>S(h.navigation)),N.navigating.set(J.current=null)}async function Te(t,e,n,r,a){return t.origin===kt&&t.pathname===location.pathname&&!be?await zt({status:r,error:n,url:t,route:e}):await Q(t,a)}function mn(){let t,e,n;C.addEventListener("mousemove",i=>{const c=i.target;clearTimeout(t),t=setTimeout(()=>{s(c,D.hover)},20)});function r(i){i.defaultPrevented||s(i.composedPath()[0],D.tap)}C.addEventListener("mousedown",r),C.addEventListener("touchstart",r,{passive:!0});const a=new IntersectionObserver(i=>{for(const c of i)c.isIntersecting&&(Tt(new URL(c.target.href)),a.unobserve(c.target))},{threshold:0});async function s(i,c){const l=me(i,C),d=l===e&&c>=n;if(!l||d)return;const{url:u,external:y,download:f}=It(l,U,b.hash);if(y||f)return;const h=pt(l),_=u&&bt(m.url)===bt(u);if(!(h.reload||_))if(c<=h.preload_data){e=l,n=D.tap;const g=await Rt(u,!1);if(!g)return;cn(g)}else c<=h.preload_code&&(e=l,n=c,Tt(u))}function o(){a.disconnect();for(const i of C.querySelectorAll("a")){const{url:c,external:l,download:d}=It(i,U,b.hash);if(l||d)continue;const u=pt(i);u.reload||(u.preload_code===D.viewport&&a.observe(i),u.preload_code===D.eager&&Tt(c))}}z.add(o),o()}function tt(t,e){if(t instanceof Nt)return t.body;const n=Kt(t),r=tn(t);return b.hooks.handleError({error:t,event:e,status:n,message:r})??{message:r}}function On(t,e={}){return t=new URL(Bt(t)),t.origin!==kt?Promise.reject(new Error("goto: invalid URL")):xe(t,e,0)}function _n(t){if(typeof t=="function")mt.push(t);else{const{href:e}=new URL(t,location.href);mt.push(n=>n.href===e)}}function wn(){var e;history.scrollRestoration="manual",addEventListener("beforeunload",n=>{let r=!1;if(oe(),!Z){const a=Ht(m,void 0,null,"leave"),s={...a.navigation,cancel:()=>{r=!0,a.reject(new Error("navigation cancelled"))}};ye.forEach(o=>o(s))}r?(n.preventDefault(),n.returnValue=""):history.scrollRestoration="auto"}),addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&oe()}),(e=navigator.connection)!=null&&e.saveData||mn(),C.addEventListener("click",async n=>{if(n.button||n.which!==1||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.defaultPrevented)return;const r=me(n.composedPath()[0],C);if(!r)return;const{url:a,external:s,target:o,download:i}=It(r,U,b.hash);if(!a)return;if(o==="_parent"||o==="_top"){if(window.parent!==window)return}else if(o&&o!=="_self")return;const c=pt(r);if(!(r instanceof SVGAElement)&&a.protocol!==location.protocol&&!(a.protocol==="https:"||a.protocol==="http:")||i)return;const[d,u]=(b.hash?a.hash.replace(/^#/,""):a.href).split("#"),y=d===Lt(location);if(s||c.reload&&(!y||!u)){Ae({url:a,type:"link",event:n})?Z=!0:n.preventDefault();return}if(u!==void 0&&y){const[,f]=m.url.href.split("#");if(f===u){if(n.preventDefault(),u===""||u==="top"&&r.ownerDocument.getElementById("top")===null)scrollTo({top:0});else{const h=r.ownerDocument.getElementById(decodeURIComponent(u));h&&(h.scrollIntoView(),h.focus())}return}if(W=!0,Mt(E),t(a),!c.replace_state)return;W=!1}n.preventDefault(),await new Promise(f=>{requestAnimationFrame(()=>{setTimeout(f,0)}),setTimeout(f,100)}),await G({type:"link",url:a,keepfocus:c.keepfocus,noscroll:c.noscroll,replace_state:c.replace_state??a.href===location.href,event:n})}),C.addEventListener("submit",n=>{if(n.defaultPrevented)return;const r=HTMLFormElement.prototype.cloneNode.call(n.target),a=n.submitter;if(((a==null?void 0:a.formTarget)||r.target)==="_blank"||((a==null?void 0:a.formMethod)||r.method)!=="get")return;const i=new URL((a==null?void 0:a.hasAttribute("formaction"))&&(a==null?void 0:a.formAction)||r.action);if(St(i,U,!1))return;const c=n.target,l=pt(c);if(l.reload)return;n.preventDefault(),n.stopPropagation();const d=new FormData(c,a);i.search=new URLSearchParams(d).toString(),G({type:"form",url:i,keepfocus:l.keepfocus,noscroll:l.noscroll,replace_state:l.replace_state??i.href===location.href,event:n})}),addEventListener("popstate",async n=>{var r;if(!$t){if((r=n.state)!=null&&r[F]){const a=n.state[F];if(V={},a===E)return;const s=q[a],o=n.state[pe]??{},i=new URL(n.state[Je]??location.href),c=n.state[H],l=m.url?Lt(location)===Lt(m.url):!1;if(c===L&&(ke||l)){o!==R.state&&(R.state=o),t(i),q[E]=Et(),s&&scrollTo(s.x,s.y),E=a;return}const u=a-E;await G({type:"popstate",url:i,popped:{state:o,scroll:s,delta:u},accept:()=>{E=a,L=c},block:()=>{history.go(-u)},nav_token:V,event:n})}else if(!W){const a=new URL(location.href);t(a),b.hash&&location.reload()}}}),addEventListener("hashchange",()=>{W&&(W=!1,history.replaceState({...history.state,[F]:++E,[H]:L},"",location.href))});for(const n of document.querySelectorAll("link"))an.has(n.rel)&&(n.href=n.href);addEventListener("pageshow",n=>{n.persisted&&N.navigating.set(J.current=null)});function t(n){m.url=R.url=n,N.page.set(Jt(R)),N.page.notify()}}async function vn(t,{status:e=200,error:n,node_ids:r,params:a,route:s,server_route:o,data:i,form:c}){be=!0;const l=new URL(location.href);let d;({params:a={},route:s={id:null}}=await Rt(l,!1)||{}),d=Ft.find(({id:f})=>f===s.id);let u,y=!0;try{const f=r.map(async(_,g)=>{const p=i[g];return p!=null&&p.uses&&(p.uses=yn(p.uses)),Wt({loader:b.nodes[_],url:l,params:a,route:s,parent:async()=>{const k={};for(let x=0;x{const i=history.state;$t=!0,location.replace(`#${r}`),b.hash&&location.replace(t.hash),history.replaceState(i,"",t.hash),scrollTo(s,o),$t=!1})}else{const s=document.body,o=s.getAttribute("tabindex");s.tabIndex=-1,s.focus({preventScroll:!0,focusVisible:!1}),o!==null?s.setAttribute("tabindex",o):s.removeAttribute("tabindex")}const a=getSelection();if(a&&a.type!=="None"){const s=[];for(let o=0;o{if(a.rangeCount===s.length){for(let o=0;o{a=d,s=u});return o.catch(()=>{}),{navigation:{from:{params:t.params,route:{id:((c=t.route)==null?void 0:c.id)??null},url:t.url},to:n&&{params:(e==null?void 0:e.params)??null,route:{id:((l=e==null?void 0:e.route)==null?void 0:l.id)??null},url:n},willUnload:!e,type:r,complete:o},fulfil:a,reject:s}}function Jt(t){return{data:t.data,error:t.error,form:t.form,params:t.params,route:t.route,state:t.state,status:t.status,url:t.url}}function kn(t){const e=new URL(t);return e.hash=decodeURIComponent(t.hash),e}function Ie(t){let e;if(b.hash){const[,,n]=t.hash.split("#",3);e=n??""}else e=t.hash.slice(1);return decodeURIComponent(e)}export{In as a,On as g,Ln as l,R as p,N as s}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/DZNd3jEa.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/DZNd3jEa.js new file mode 100644 index 0000000..1d73be3 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/DZNd3jEa.js @@ -0,0 +1,2 @@ +var Ie=Object.defineProperty;var ce=t=>{throw TypeError(t)};var Me=(t,e,s)=>e in t?Ie(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var ee=(t,e,s)=>Me(t,typeof e!="symbol"?e+"":e,s),te=(t,e,s)=>e.has(t)||ce("Cannot "+s);var r=(t,e,s)=>(te(t,e,"read from private field"),s?s.call(t):e.get(t)),h=(t,e,s)=>e.has(t)?ce("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),a=(t,e,s,i)=>(te(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),p=(t,e,s)=>(te(t,e,"access private method"),s);import{ae as ke,g as be,af as we,Y as Ce,l as Le,ag as pe,Z as Ne,I as v,H as E,a5 as L,L as Pe,M as Re,V as de,P as Ye,G as I,ah as j,E as se,F as q,ai as Be,aj as Q,ak as B,al as ge,am as He,an as ne,i as Se,J as Ve,ao as ve,ap as xe,aq as me,ar as qe,as as Ue,D as re,R as U,y as We,Q as Ge,at as ye,au as je,N as Je,av as $e,aw as ze,ax as Ke,d as Qe,U as ie,ay as Xe,az as Ze,aA as et,aB as tt,aC as st,aD as ae,aE as rt,W as nt,aF as oe,S as J,aG as it,aH as at,aI as ot,aJ as ft,p as lt,aK as ht,aL as ut,a as dt}from"./CqqhLxdp.js";function _t(t){let e=0,s=we(0),i;return()=>{ke()&&(be(s),Ce(()=>(e===0&&(i=Le(()=>t(()=>pe(s)))),e+=1,()=>{Ne(()=>{e-=1,e===0&&(i==null||i(),i=void 0,pe(s))})})))}}var ct=Je|$e|ze;function pt(t,e,s){new gt(t,e,s)}var g,W,T,M,b,y,_,w,S,D,k,A,C,H,V,F,X,l,Ae,De,fe,z,K,le;class gt{constructor(e,s,i){h(this,l);ee(this,"parent");ee(this,"is_pending",!1);h(this,g);h(this,W,E?v:null);h(this,T);h(this,M);h(this,b);h(this,y,null);h(this,_,null);h(this,w,null);h(this,S,null);h(this,D,null);h(this,k,0);h(this,A,0);h(this,C,!1);h(this,H,new Set);h(this,V,new Set);h(this,F,null);h(this,X,_t(()=>(a(this,F,we(r(this,k))),()=>{a(this,F,null)})));a(this,g,e),a(this,T,s),a(this,M,i),this.parent=L.b,this.is_pending=!!r(this,T).pending,a(this,b,Pe(()=>{if(L.b=this,E){const n=r(this,W);Re(),n.nodeType===de&&n.data===Ye?p(this,l,De).call(this):(p(this,l,Ae).call(this),r(this,A)===0&&(this.is_pending=!1))}else{var o=p(this,l,fe).call(this);try{a(this,y,I(()=>i(o)))}catch(n){this.error(n)}r(this,A)>0?p(this,l,K).call(this):this.is_pending=!1}return()=>{var n;(n=r(this,D))==null||n.remove()}},ct)),E&&a(this,g,v)}defer_effect(e){Be(e,r(this,H),r(this,V))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!r(this,T).pending}update_pending_count(e){p(this,l,le).call(this,e),a(this,k,r(this,k)+e),r(this,F)&&Ue(r(this,F),r(this,k))}get_effect_pending(){return r(this,X).call(this),be(r(this,F))}error(e){var s=r(this,T).onerror;let i=r(this,T).failed;if(r(this,C)||!s&&!i)throw e;r(this,y)&&(re(r(this,y)),a(this,y,null)),r(this,_)&&(re(r(this,_)),a(this,_,null)),r(this,w)&&(re(r(this,w)),a(this,w,null)),E&&(U(r(this,W)),We(),U(Ge()));var o=!1,n=!1;const f=()=>{if(o){Ke();return}o=!0,n&&je(),j.ensure(),a(this,k,0),r(this,w)!==null&&se(r(this,w),()=>{a(this,w,null)}),this.is_pending=this.has_pending_snippet(),a(this,y,p(this,l,z).call(this,()=>(a(this,C,!1),I(()=>r(this,M).call(this,r(this,g)))))),r(this,A)>0?p(this,l,K).call(this):this.is_pending=!1};var m=ne;try{B(null),n=!0,s==null||s(e,f),n=!1}catch(c){ye(c,r(this,b)&&r(this,b).parent)}finally{B(m)}i&&Ne(()=>{a(this,w,p(this,l,z).call(this,()=>{j.ensure(),a(this,C,!0);try{return I(()=>{i(r(this,g),()=>e,()=>f)})}catch(c){return ye(c,r(this,b).parent),null}finally{a(this,C,!1)}}))})}}g=new WeakMap,W=new WeakMap,T=new WeakMap,M=new WeakMap,b=new WeakMap,y=new WeakMap,_=new WeakMap,w=new WeakMap,S=new WeakMap,D=new WeakMap,k=new WeakMap,A=new WeakMap,C=new WeakMap,H=new WeakMap,V=new WeakMap,F=new WeakMap,X=new WeakMap,l=new WeakSet,Ae=function(){try{a(this,y,I(()=>r(this,M).call(this,r(this,g))))}catch(e){this.error(e)}},De=function(){const e=r(this,T).pending;e&&(a(this,_,I(()=>e(r(this,g)))),j.enqueue(()=>{var s=p(this,l,fe).call(this);a(this,y,p(this,l,z).call(this,()=>(j.ensure(),I(()=>r(this,M).call(this,s))))),r(this,A)>0?p(this,l,K).call(this):(se(r(this,_),()=>{a(this,_,null)}),this.is_pending=!1)}))},fe=function(){var e=r(this,g);return this.is_pending&&(a(this,D,q()),r(this,g).before(r(this,D)),e=r(this,D)),e},z=function(e){var s=L,i=ne,o=Se;Q(r(this,b)),B(r(this,b)),ge(r(this,b).ctx);try{return e()}catch(n){return He(n),null}finally{Q(s),B(i),ge(o)}},K=function(){const e=r(this,T).pending;r(this,y)!==null&&(a(this,S,document.createDocumentFragment()),r(this,S).append(r(this,D)),Ve(r(this,y),r(this,S))),r(this,_)===null&&a(this,_,I(()=>e(r(this,g))))},le=function(e){var s;if(!this.has_pending_snippet()){this.parent&&p(s=this.parent,l,le).call(s,e);return}if(a(this,A,r(this,A)+e),r(this,A)===0){this.is_pending=!1;for(const i of r(this,H))ve(i,xe),me(i);for(const i of r(this,V))ve(i,qe),me(i);r(this,H).clear(),r(this,V).clear(),r(this,_)&&se(r(this,_),()=>{a(this,_,null)}),r(this,S)&&(r(this,g).before(r(this,S)),a(this,S,null))}};const vt=["touchstart","touchmove"];function mt(t){return vt.includes(t)}const Fe=new Set,he=new Set;function Nt(t){for(var e=0;e{throw G});throw u}}finally{t.__root=e,delete t.currentTarget,B(Z),Q(N)}}}function yt(t){var e=document.createElement("template");return e.innerHTML=t.replaceAll("",""),e.content}function O(t,e){var s=L;s.nodes===null&&(s.nodes={start:t,end:e,a:null,t:null})}function Rt(t,e){var s=(e&Ze)!==0,i=(e&et)!==0,o,n=!t.startsWith("");return()=>{if(E)return O(v,null),v;o===void 0&&(o=yt(n?t:""+t),s||(o=ie(o)));var f=i||Xe?document.importNode(o,!0):o.cloneNode(!0);if(s){var m=ie(f),c=f.lastChild;O(m,c)}else O(f,f);return f}}function St(t=""){if(!E){var e=q(t+"");return O(e,e),e}var s=v;return s.nodeType!==st&&(s.before(s=q()),U(s)),O(s,s),s}function At(){if(E)return O(v,null),v;var t=document.createDocumentFragment(),e=document.createComment(""),s=q();return t.append(e,s),O(e,s),t}function Dt(t,e){if(E){var s=L;(!(s.f&tt)||s.nodes.end===null)&&(s.nodes.end=v),Re();return}t!==null&&t.before(e)}function Ft(t,e){var s=e==null?"":typeof e=="object"?e+"":e;s!==(t.__t??(t.__t=t.nodeValue))&&(t.__t=s,t.nodeValue=s+"")}function Et(t,e){return Oe(t,e)}function Ot(t,e){ae(),e.intro=e.intro??!1;const s=e.target,i=E,o=v;try{for(var n=ie(s);n&&(n.nodeType!==de||n.data!==rt);)n=nt(n);if(!n)throw oe;J(!0),U(n);const f=Oe(t,{...e,anchor:n});return J(!1),f}catch(f){if(f instanceof Error&&f.message.split(` +`).some(m=>m.startsWith("https://svelte.dev/e/")))throw f;return f!==oe&&console.warn("Failed to hydrate: ",f),e.recover===!1&&it(),ae(),at(s),J(!1),Et(t,e)}finally{J(i),U(o)}}const Y=new Map;function Oe(t,{target:e,anchor:s,props:i={},events:o,context:n,intro:f=!0}){ae();var m=new Set,c=N=>{for(var u=0;u{var N=s??e.appendChild(q());return pt(N,{pending:()=>{}},u=>{if(n){lt({});var d=Se;d.c=n}if(o&&(i.$$events=o),E&&O(u,null),P=t(u,i)||{},E&&(L.nodes.end=v,v===null||v.nodeType!==de||v.data!==ht))throw ut(),oe;n&&dt()}),()=>{var R;for(var u of m){e.removeEventListener(u,$);var d=Y.get(u);--d===0?(document.removeEventListener(u,$),Y.delete(u)):Y.set(u,d)}he.delete(c),N!==s&&((R=N.parentNode)==null||R.removeChild(N))}});return ue.set(P,Z),P}let ue=new WeakMap;function It(t,e){const s=ue.get(t);return s?(ue.delete(t),s(e)):Promise.resolve()}const Tt="5";var Te;typeof window<"u"&&((Te=window.__svelte??(window.__svelte={})).v??(Te.v=new Set)).add(Tt);export{Dt as a,At as c,Nt as d,Rt as f,Ot as h,Et as m,Ft as s,St as t,It as u}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/fsu08h6h.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/fsu08h6h.js new file mode 100644 index 0000000..19a7a7b --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/fsu08h6h.js @@ -0,0 +1 @@ +var S=Object.defineProperty;var y=a=>{throw TypeError(a)};var D=(a,e,t)=>e in a?S(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var A=(a,e,t)=>D(a,typeof e!="symbol"?e+"":e,t),E=(a,e,t)=>e.has(a)||y("Cannot "+t);var s=(a,e,t)=>(E(a,e,"read from private field"),t?t.call(a):e.get(a)),u=(a,e,t)=>e.has(a)?y("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,t),T=(a,e,t,i)=>(E(a,e,"write to private field"),i?i.call(a,t):e.set(a,t),t);import{B as w,C as N,D as k,E as x,F,G as M,H as g,I as B,J as C,K as H,L as I,M as L,N as O,O as P,P as G,Q as J,R as K,S as R}from"./CqqhLxdp.js";var d,l,c,_,v,m,b;class Q{constructor(e,t=!0){A(this,"anchor");u(this,d,new Map);u(this,l,new Map);u(this,c,new Map);u(this,_,new Set);u(this,v,!0);u(this,m,()=>{var e=w;if(s(this,d).has(e)){var t=s(this,d).get(e),i=s(this,l).get(t);if(i)N(i),s(this,_).delete(t);else{var n=s(this,c).get(t);n&&(s(this,l).set(t,n.effect),s(this,c).delete(t),n.fragment.lastChild.remove(),this.anchor.before(n.fragment),i=n.effect)}for(const[f,r]of s(this,d)){if(s(this,d).delete(f),f===e)break;const h=s(this,c).get(r);h&&(k(h.effect),s(this,c).delete(r))}for(const[f,r]of s(this,l)){if(f===t||s(this,_).has(f))continue;const h=()=>{if(Array.from(s(this,d).values()).includes(f)){var p=document.createDocumentFragment();C(r,p),p.append(F()),s(this,c).set(f,{effect:r,fragment:p})}else k(r);s(this,_).delete(f),s(this,l).delete(f)};s(this,v)||!i?(s(this,_).add(f),x(r,h,!1)):h()}}});u(this,b,e=>{s(this,d).delete(e);const t=Array.from(s(this,d).values());for(const[i,n]of s(this,c))t.includes(i)||(k(n.effect),s(this,c).delete(i))});this.anchor=e,T(this,v,t)}ensure(e,t){var i=w,n=H();if(t&&!s(this,l).has(e)&&!s(this,c).has(e))if(n){var f=document.createDocumentFragment(),r=F();f.append(r),s(this,c).set(e,{effect:M(()=>t(r)),fragment:f})}else s(this,l).set(e,M(()=>t(this.anchor)));if(s(this,d).set(i,e),n){for(const[h,o]of s(this,l))h===e?i.skipped_effects.delete(o):i.skipped_effects.add(o);for(const[h,o]of s(this,c))h===e?i.skipped_effects.delete(o.effect):i.skipped_effects.add(o.effect);i.oncommit(s(this,m)),i.ondiscard(s(this,b))}else g&&(this.anchor=B),s(this,m).call(this)}}d=new WeakMap,l=new WeakMap,c=new WeakMap,_=new WeakMap,v=new WeakMap,m=new WeakMap,b=new WeakMap;function q(a,e,t=!1){g&&L();var i=new Q(a),n=t?O:0;function f(r,h){if(g){const p=P(a)===G;if(r===p){var o=J();K(o),i.anchor=o,R(!1),i.ensure(r,h),R(!0);return}}i.ensure(r,h)}I(()=>{var r=!1;e((h,o=!0)=>{r=!0,f(o,h)}),r||f(!1,null)},n)}export{Q as B,q as i}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/hV77cT_P.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/hV77cT_P.js new file mode 100644 index 0000000..ef1f2b7 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/chunks/hV77cT_P.js @@ -0,0 +1 @@ +import{s as c,g as l}from"./Bgo_ZO3W.js";import{b as o,d as b,n as a,m as d,g as p,e as g}from"./CqqhLxdp.js";let s=!1,i=Symbol();function m(e,u,r){const n=r[u]??(r[u]={store:null,source:d(void 0),unsubscribe:a});if(n.store!==e&&!(i in r))if(n.unsubscribe(),n.store=e??null,e==null)n.source.v=void 0,n.unsubscribe=a;else{var t=!0;n.unsubscribe=c(e,f=>{t?n.source.v=f:g(n.source,f)}),t=!1}return e&&i in r?l(e):p(n.source)}function y(){const e={};function u(){o(()=>{for(var r in e)e[r].unsubscribe();b(e,i,{enumerable:!1,value:!0})})}return[e,u]}function N(e){var u=s;try{return s=!1,[e(),s]}finally{s=u}}export{m as a,N as c,y as s}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/app.B9iOASPK.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/app.B9iOASPK.js new file mode 100644 index 0000000..98b50ce --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/app.B9iOASPK.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../nodes/0.C7lVdKJN.js","../chunks/DZNd3jEa.js","../chunks/CqqhLxdp.js","../chunks/BtkHyJOA.js","../chunks/fsu08h6h.js","../chunks/BRRLaaPq.js","../assets/0.r7T8fV5B.css","../nodes/1.DhhPkK36.js","../chunks/974AMC2H.js","../chunks/CuIyQV9Z.js","../chunks/Bgo_ZO3W.js","../nodes/2.MK_aCw-P.js","../nodes/3.DVfrbbic.js","../chunks/hV77cT_P.js"])))=>i.map(i=>d[i]); +var F=t=>{throw TypeError(t)};var Z=(t,e,r)=>e.has(t)||F("Cannot "+r);var h=(t,e,r)=>(Z(t,e,"read from private field"),r?r.call(t):e.get(t)),B=(t,e,r)=>e.has(t)?F("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),D=(t,e,r,i)=>(Z(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r);import{H as ee,M as te,L as re,N as ae,X as se,Y as ne,l as H,Z as ie,_ as W,$ as oe,a0 as ce,a1 as ue,g as P,w as fe,a2 as le,a3 as de,e as L,a4 as _e,a5 as me,a6 as he,a7 as ve,A as ge,a8 as Ee,a9 as Pe,aa as ye,ab as X,ac as be,d as Re,m as Se,p as Oe,j as we,k as Ae,h as j,ad as Le,f as T,s as Ie,a as Te,c as xe,r as ke,u as C,t as Be}from"../chunks/CqqhLxdp.js";import{h as De,m as je,u as Ce,f as J,a as w,c as N,t as Ne,s as Ue}from"../chunks/DZNd3jEa.js";import{o as Ye}from"../chunks/BtkHyJOA.js";import{B as qe,i as U}from"../chunks/fsu08h6h.js";import{c as Me}from"../chunks/hV77cT_P.js";function Y(t,e,r){ee&&te();var i=new qe(t);re(()=>{var n=e()??null;i.ensure(n,n&&(o=>r(o,n)))},ae)}function z(t,e){return t===e||(t==null?void 0:t[W])===e}function q(t={},e,r,i){return se(()=>{var n,o;return ne(()=>{n=o,o=[],H(()=>{t!==r(...o)&&(e(t,...o),n&&z(r(...n),t)&&e(null,...n))})}),()=>{ie(()=>{o&&z(r(...o),t)&&e(null,...o)})}}),t}function M(t,e,r,i){var b;var n=!ge||(r&Ee)!==0,o=(r&ve)!==0,s=(r&ye)!==0,a=i,l=!0,d=()=>(l&&(l=!1,a=s?H(i):i),a),_;if(o){var A=W in t||X in t;_=((b=oe(t,e))==null?void 0:b.set)??(A&&e in t?c=>t[e]=c:void 0)}var S,v=!1;o?[S,v]=Me(()=>t[e]):S=t[e],S===void 0&&i!==void 0&&(S=d(),_&&(n&&ce(),_(S)));var m;if(n?m=()=>{var c=t[e];return c===void 0?d():(l=!0,c)}:m=()=>{var c=t[e];return c!==void 0&&(a=void 0),c===void 0?a:c},n&&!(r&ue))return m;if(_){var u=t.$$legacy;return function(c,f){return arguments.length>0?((!n||!f||u||v)&&_(f?m():c),c):m()}}var y=!1,g=(r&Pe?fe:le)(()=>(y=!1,m()));o&&P(g);var O=me;return function(c,f){if(arguments.length>0){const k=f?P(g):n&&o?de(c):c;return L(g,k),y=!0,a!==void 0&&(a=k),c}return _e&&y||O.f&he?g.v:P(g)}}function Ve(t){return class extends Fe{constructor(e){super({component:t,...e})}}}var R,E;class Fe{constructor(e){B(this,R);B(this,E);var o;var r=new Map,i=(s,a)=>{var l=Se(a,!1,!1);return r.set(s,l),l};const n=new Proxy({...e.props||{},$$events:{}},{get(s,a){return P(r.get(a)??i(a,Reflect.get(s,a)))},has(s,a){return a===X?!0:(P(r.get(a)??i(a,Reflect.get(s,a))),Reflect.has(s,a))},set(s,a,l){return L(r.get(a)??i(a,l),l),Reflect.set(s,a,l)}});D(this,E,(e.hydrate?De:je)(e.component,{target:e.target,anchor:e.anchor,props:n,context:e.context,intro:e.intro??!1,recover:e.recover})),(!((o=e==null?void 0:e.props)!=null&&o.$$host)||e.sync===!1)&&be(),D(this,R,n.$$events);for(const s of Object.keys(h(this,E)))s==="$set"||s==="$destroy"||s==="$on"||Re(this,s,{get(){return h(this,E)[s]},set(a){h(this,E)[s]=a},enumerable:!0});h(this,E).$set=s=>{Object.assign(n,s)},h(this,E).$destroy=()=>{Ce(h(this,E))}}$set(e){h(this,E).$set(e)}$on(e,r){h(this,R)[e]=h(this,R)[e]||[];const i=(...n)=>r.call(this,...n);return h(this,R)[e].push(i),()=>{h(this,R)[e]=h(this,R)[e].filter(n=>n!==i)}}$destroy(){h(this,E).$destroy()}}R=new WeakMap,E=new WeakMap;const Ze="modulepreload",ze=function(t,e){return new URL(t,e).href},G={},x=function(e,r,i){let n=Promise.resolve();if(r&&r.length>0){const s=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.allSettled(r.map(d=>{if(d=ze(d,i),d in G)return;G[d]=!0;const _=d.endsWith(".css"),A=_?'[rel="stylesheet"]':"";if(!!i)for(let m=s.length-1;m>=0;m--){const u=s[m];if(u.href===d&&(!_||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${A}`))return;const v=document.createElement("link");if(v.rel=_?"stylesheet":Ze,_||(v.as="script"),v.crossOrigin="",v.href=d,l&&v.setAttribute("nonce",l),document.head.appendChild(v),_)return new Promise((m,u)=>{v.addEventListener("load",m),v.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return n.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return e().catch(o)})},tt={};var Ge=J('
'),He=J(" ",1);function We(t,e){Oe(e,!0);let r=M(e,"components",23,()=>[]),i=M(e,"data_0",3,null),n=M(e,"data_1",3,null);we(()=>e.stores.page.set(e.page)),Ae(()=>{e.stores,e.page,e.constructors,r(),e.form,i(),n(),e.stores.page.notify()});let o=j(!1),s=j(!1),a=j(null);Ye(()=>{const u=e.stores.page.subscribe(()=>{P(o)&&(L(s,!0),Le().then(()=>{L(a,document.title||"untitled page",!0)}))});return L(o,!0),u});const l=C(()=>e.constructors[1]);var d=He(),_=T(d);{var A=u=>{const y=C(()=>e.constructors[0]);var g=N(),O=T(g);Y(O,()=>P(y),(b,c)=>{q(c(b,{get data(){return i()},get form(){return e.form},get params(){return e.page.params},children:(f,k)=>{var V=N(),Q=T(V);Y(Q,()=>P(l),(p,$)=>{q($(p,{get data(){return n()},get form(){return e.form},get params(){return e.page.params}}),I=>r()[1]=I,()=>{var I;return(I=r())==null?void 0:I[1]})}),w(f,V)},$$slots:{default:!0}}),f=>r()[0]=f,()=>{var f;return(f=r())==null?void 0:f[0]})}),w(u,g)},S=u=>{const y=C(()=>e.constructors[0]);var g=N(),O=T(g);Y(O,()=>P(y),(b,c)=>{q(c(b,{get data(){return i()},get form(){return e.form},get params(){return e.page.params}}),f=>r()[0]=f,()=>{var f;return(f=r())==null?void 0:f[0]})}),w(u,g)};U(_,u=>{e.constructors[1]?u(A):u(S,!1)})}var v=Ie(_,2);{var m=u=>{var y=Ge(),g=xe(y);{var O=b=>{var c=Ne();Be(()=>Ue(c,P(a))),w(b,c)};U(g,b=>{P(s)&&b(O)})}ke(y),w(u,y)};U(v,u=>{P(o)&&u(m)})}w(t,d),Te()}const rt=Ve(We),at=[()=>x(()=>import("../nodes/0.C7lVdKJN.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url),()=>x(()=>import("../nodes/1.DhhPkK36.js"),__vite__mapDeps([7,1,2,8,9,10,3]),import.meta.url),()=>x(()=>import("../nodes/2.MK_aCw-P.js"),__vite__mapDeps([11,1,2,8,4,5]),import.meta.url),()=>x(()=>import("../nodes/3.DVfrbbic.js"),__vite__mapDeps([12,1,2,3,4,13,10,9,5]),import.meta.url)],st=[],nt={"/":[2],"/callback":[3]},K={handleError:({error:t})=>{console.error(t)},reroute:()=>{},transport:{}},Xe=Object.fromEntries(Object.entries(K.transport).map(([t,e])=>[t,e.decode])),it=Object.fromEntries(Object.entries(K.transport).map(([t,e])=>[t,e.encode])),ot=!1,ct=(t,e)=>Xe[t](e);export{ct as decode,Xe as decoders,nt as dictionary,it as encoders,ot as hash,K as hooks,tt as matchers,at as nodes,rt as root,st as server_loads}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/start.JQZ0kVpy.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/start.JQZ0kVpy.js new file mode 100644 index 0000000..b8d4625 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/entry/start.JQZ0kVpy.js @@ -0,0 +1 @@ +import{l as o,a as r}from"../chunks/CuIyQV9Z.js";export{o as load_css,r as start}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/0.C7lVdKJN.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/0.C7lVdKJN.js new file mode 100644 index 0000000..d077919 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/0.C7lVdKJN.js @@ -0,0 +1 @@ +import{d as F,f as c,a as d,s as M}from"../chunks/DZNd3jEa.js";import{o as A}from"../chunks/BtkHyJOA.js";import{L as q,N as C,F as L,T as w,H as p,U as H,V as R,W as g,S as b,R as T,I as B,p as D,a as O,c as l,s as u,r as v,f as S,t as W}from"../chunks/CqqhLxdp.js";import{B as I,i as P}from"../chunks/fsu08h6h.js";import{a as f}from"../chunks/BRRLaaPq.js";function U(i,o,...t){var r=new I(i);q(()=>{const e=o()??null;r.ensure(e,e&&(a=>e(a,...t)))},C)}function V(i,o){let t=null,r=p;var e;if(p){t=B;for(var a=H(document.head);a!==null&&(a.nodeType!==R||a.data!==i);)a=g(a);if(a===null)b(!1);else{var h=g(a);a.remove(),T(h)}}p||(e=document.head.appendChild(L()));try{q(()=>o(e),w)}finally{r&&(b(!0),T(t))}}var j=c(''),z=c(' ',1),G=c(''),J=c('');function $(i,o){D(o,!0),A(()=>{f.hydrate()});var t=J();V("12qhfyh",s=>{var n=j();d(s,n)});var r=l(t),e=l(r),a=u(l(e),2);{var h=s=>{var n=z(),m=S(n),k=l(m);v(m);var x=u(m,2);x.__click=()=>f.logout(),W(()=>{var y;return M(k,`Welcome, ${((y=f.user)==null?void 0:y.displayName)??""}`)}),d(s,n)},E=s=>{var n=G();n.__click=()=>f.redirectToLogin(),d(s,n)};P(a,s=>{f.isAuthenticated?s(h):s(E,!1)})}v(e),v(r);var _=u(r,2),N=l(_);U(N,()=>o.children),v(_),v(t),d(i,t),O()}F(["click"]);export{$ as component}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/1.DhhPkK36.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/1.DhhPkK36.js new file mode 100644 index 0000000..03a5861 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/1.DhhPkK36.js @@ -0,0 +1 @@ +import{f as h,a as g,s as e}from"../chunks/DZNd3jEa.js";import{i as l}from"../chunks/974AMC2H.js";import{p as v,f as d,t as _,a as x,c as o,r as p,s as $}from"../chunks/CqqhLxdp.js";import{s as k,p as m}from"../chunks/CuIyQV9Z.js";const b={get error(){return m.error},get status(){return m.status}};k.updated.check;const f=b;var E=h("

",1);function z(i,c){v(c,!1),l();var t=E(),r=d(t),n=o(r,!0);p(r);var s=$(r,2),u=o(s,!0);p(s),_(()=>{var a;e(n,f.status),e(u,(a=f.error)==null?void 0:a.message)}),g(i,t),x()}export{z as component}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/2.MK_aCw-P.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/2.MK_aCw-P.js new file mode 100644 index 0000000..f0106d8 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/2.MK_aCw-P.js @@ -0,0 +1 @@ +import{d as E,f as m,a as o,c as N,s as _}from"../chunks/DZNd3jEa.js";import{i as P}from"../chunks/974AMC2H.js";import{p as S,s as n,f as p,a as W,c as g,r as d,t as j}from"../chunks/CqqhLxdp.js";import{i as u}from"../chunks/fsu08h6h.js";import{a as i}from"../chunks/BRRLaaPq.js";var q=m("

Loading...

"),z=m("

",1),B=m("

Please log in to continue.

",1),C=m("

Mode Template

",1);function J(h,b){S(b,!1),P();var f=C(),x=n(p(f),2);{var k=a=>{var s=q();o(a,s)},L=a=>{var s=N(),M=p(s);{var T=t=>{var r=z(),e=p(r),y=g(e);d(e);var l=n(e,2),A=g(l);d(l),j(()=>{var v,c;_(y,`Welcome, ${((v=i.user)==null?void 0:v.displayName)??""}!`),_(A,`Email: ${((c=i.user)==null?void 0:c.email)??""}`)}),o(t,r)},w=t=>{var r=B(),e=n(p(r),2);e.__click=()=>i.redirectToLogin(),o(t,r)};u(M,t=>{i.isAuthenticated?t(T):t(w,!1)},!0)}o(a,s)};u(x,a=>{i.loading?a(k):a(L,!1)})}o(h,f),W()}E(["click"]);export{J as component}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/3.DVfrbbic.js b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/3.DVfrbbic.js new file mode 100644 index 0000000..86e2f55 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/immutable/nodes/3.DVfrbbic.js @@ -0,0 +1 @@ +import{f as p,a as n,s as y}from"../chunks/DZNd3jEa.js";import{o as $}from"../chunks/BtkHyJOA.js";import{p as k,s as x,f as g,a as M,e as l,h as N,g as u,c as P,r as w,y as A,t as I}from"../chunks/CqqhLxdp.js";import{i as R}from"../chunks/fsu08h6h.js";import{s as S,a as T}from"../chunks/hV77cT_P.js";import{s as j,g as q}from"../chunks/CuIyQV9Z.js";import{a as z}from"../chunks/BRRLaaPq.js";const B=()=>{const e=j;return{page:{subscribe:e.page.subscribe},navigating:{subscribe:e.navigating.subscribe},updated:e.updated}},C={subscribe(e){return B().page.subscribe(e)}};var D=p('

Return home',1),E=p("

Please wait...

"),F=p("

Authenticating...

",1);function U(e,i){k(i,!0);const f=()=>T(C,"$page",b),[b,v]=S();let r=N(null);$(async()=>{const s=f().url.searchParams,a=s.get("email"),t=s.get("displayName"),o=s.get("token"),m=s.get("error");if(m){l(r,m,!0);return}a&&t&&o?(z.login({email:a,displayName:t,pbToken:o}),q("/")):l(r,"Invalid callback parameters")});var c=F(),h=x(g(c),2);{var _=s=>{var a=D(),t=g(a),o=P(t,!0);w(t),A(2),I(()=>y(o,u(r))),n(s,a)},d=s=>{var a=E();n(s,a)};R(h,s=>{u(r)?s(_):s(d,!1)})}n(e,c),M(),v()}export{U as component}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/client/_app/version.json b/ModeTemplate/frontend/.svelte-kit/output/client/_app/version.json new file mode 100644 index 0000000..dd94682 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/client/_app/version.json @@ -0,0 +1 @@ +{"version":"1768972126462"} \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/output/prerendered/dependencies/_app/env.js b/ModeTemplate/frontend/.svelte-kit/output/prerendered/dependencies/_app/env.js new file mode 100644 index 0000000..f5427da --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/prerendered/dependencies/_app/env.js @@ -0,0 +1 @@ +export const env={} \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/.vite/manifest.json b/ModeTemplate/frontend/.svelte-kit/output/server/.vite/manifest.json new file mode 100644 index 0000000..22039d2 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/.vite/manifest.json @@ -0,0 +1,155 @@ +{ + ".svelte-kit/generated/server/internal.js": { + "file": "internal.js", + "name": "internal", + "src": ".svelte-kit/generated/server/internal.js", + "isEntry": true, + "imports": [ + "_internal.js", + "_environment.js" + ] + }, + "_auth.svelte.js": { + "file": "chunks/auth.svelte.js", + "name": "auth.svelte", + "imports": [ + "_index2.js" + ] + }, + "_context.js": { + "file": "chunks/context.js", + "name": "context" + }, + "_environment.js": { + "file": "chunks/environment.js", + "name": "environment" + }, + "_equality.js": { + "file": "chunks/equality.js", + "name": "equality" + }, + "_exports.js": { + "file": "chunks/exports.js", + "name": "exports" + }, + "_index.js": { + "file": "chunks/index.js", + "name": "index", + "imports": [ + "_utils2.js", + "_equality.js" + ] + }, + "_index2.js": { + "file": "chunks/index2.js", + "name": "index", + "imports": [ + "_context.js" + ] + }, + "_internal.js": { + "file": "chunks/internal.js", + "name": "internal", + "imports": [ + "_index2.js", + "_environment.js", + "_utils2.js", + "_equality.js", + "_context.js" + ] + }, + "_shared.js": { + "file": "chunks/shared.js", + "name": "shared", + "imports": [ + "_utils.js" + ] + }, + "_state.svelte.js": { + "file": "chunks/state.svelte.js", + "name": "state.svelte", + "imports": [ + "_utils2.js" + ] + }, + "_utils.js": { + "file": "chunks/utils.js", + "name": "utils" + }, + "_utils2.js": { + "file": "chunks/utils2.js", + "name": "utils" + }, + "node_modules/@sveltejs/kit/src/runtime/app/server/remote/index.js": { + "file": "remote-entry.js", + "name": "remote-entry", + "src": "node_modules/@sveltejs/kit/src/runtime/app/server/remote/index.js", + "isEntry": true, + "imports": [ + "_shared.js", + "_environment.js" + ] + }, + "node_modules/@sveltejs/kit/src/runtime/components/svelte-5/error.svelte": { + "file": "entries/fallbacks/error.svelte.js", + "name": "entries/fallbacks/error.svelte", + "src": "node_modules/@sveltejs/kit/src/runtime/components/svelte-5/error.svelte", + "isEntry": true, + "imports": [ + "_context.js", + "_state.svelte.js", + "_exports.js", + "_utils.js", + "_index.js" + ] + }, + "node_modules/@sveltejs/kit/src/runtime/server/index.js": { + "file": "index.js", + "name": "index", + "src": "node_modules/@sveltejs/kit/src/runtime/server/index.js", + "isEntry": true, + "imports": [ + "_environment.js", + "_shared.js", + "_exports.js", + "_utils.js", + "_index.js", + "_internal.js" + ] + }, + "src/routes/+layout.svelte": { + "file": "entries/pages/_layout.svelte.js", + "name": "entries/pages/_layout.svelte", + "src": "src/routes/+layout.svelte", + "isEntry": true, + "imports": [ + "_index2.js", + "_auth.svelte.js", + "_context.js" + ], + "css": [ + "_app/immutable/assets/_layout.r7T8fV5B.css" + ] + }, + "src/routes/+page.svelte": { + "file": "entries/pages/_page.svelte.js", + "name": "entries/pages/_page.svelte", + "src": "src/routes/+page.svelte", + "isEntry": true, + "imports": [ + "_context.js", + "_auth.svelte.js" + ] + }, + "src/routes/callback/+page.svelte": { + "file": "entries/pages/callback/_page.svelte.js", + "name": "entries/pages/callback/_page.svelte", + "src": "src/routes/callback/+page.svelte", + "isEntry": true, + "imports": [ + "_exports.js", + "_utils.js", + "_state.svelte.js" + ] + } +} \ No newline at end of file diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/_app/immutable/assets/_layout.r7T8fV5B.css b/ModeTemplate/frontend/.svelte-kit/output/server/_app/immutable/assets/_layout.r7T8fV5B.css new file mode 100644 index 0000000..5c42dbb --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/_app/immutable/assets/_layout.r7T8fV5B.css @@ -0,0 +1 @@ +.app.svelte-12qhfyh{display:flex;flex-direction:column;min-height:100vh}header.svelte-12qhfyh{padding:1rem;background:#f5f5f5;border-bottom:1px solid #ddd}nav.svelte-12qhfyh{display:flex;gap:1rem;align-items:center}nav.svelte-12qhfyh a:where(.svelte-12qhfyh){text-decoration:none;color:#333}main.svelte-12qhfyh{flex:1;padding:1rem}button.svelte-12qhfyh{padding:.5rem 1rem;cursor:pointer} diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/auth.svelte.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/auth.svelte.js new file mode 100644 index 0000000..022defe --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/auth.svelte.js @@ -0,0 +1,70 @@ +import { x as derived } from "./index2.js"; +const STORAGE_KEYS = { PB_TOKEN: "pb_token", SESSION: "auth_session" }; +class AuthStore { + _session = null; + _loading = true; + #isAuthenticated = derived(() => this._session !== null); + get isAuthenticated() { + return this.#isAuthenticated(); + } + set isAuthenticated($$value) { + return this.#isAuthenticated($$value); + } + get session() { + return this._session; + } + get loading() { + return this._loading; + } + #user = derived(() => this._session ? { + email: this._session.email, + displayName: this._session.displayName + } : null); + get user() { + return this.#user(); + } + set user($$value) { + return this.#user($$value); + } + constructor() { + } + /** Call this in onMount to hydrate from localStorage */ + hydrate() { + if (typeof localStorage === "undefined") return; + const stored = localStorage.getItem(STORAGE_KEYS.SESSION); + if (stored) { + try { + this._session = JSON.parse(stored); + } catch { + localStorage.removeItem(STORAGE_KEYS.SESSION); + localStorage.removeItem(STORAGE_KEYS.PB_TOKEN); + } + } + this._loading = false; + } + login(session) { + if (typeof localStorage !== "undefined") { + localStorage.setItem(STORAGE_KEYS.SESSION, JSON.stringify(session)); + localStorage.setItem(STORAGE_KEYS.PB_TOKEN, session.pbToken); + } + this._session = session; + this._loading = false; + } + logout() { + if (typeof localStorage !== "undefined") { + localStorage.removeItem(STORAGE_KEYS.SESSION); + localStorage.removeItem(STORAGE_KEYS.PB_TOKEN); + } + this._session = null; + } + /** Redirect to backend auth login */ + redirectToLogin() { + if (typeof window !== "undefined") { + window.location.href = "/auth/login"; + } + } +} +const auth = new AuthStore(); +export { + auth as a +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/context.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/context.js new file mode 100644 index 0000000..16593b0 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/context.js @@ -0,0 +1,70 @@ +function lifecycle_outside_component(name) { + { + throw new Error(`https://svelte.dev/e/lifecycle_outside_component`); + } +} +const ATTR_REGEX = /[&"<]/g; +const CONTENT_REGEX = /[&<]/g; +function escape_html(value, is_attr) { + const str = String(value ?? ""); + const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX; + pattern.lastIndex = 0; + let escaped = ""; + let last = 0; + while (pattern.test(str)) { + const i = pattern.lastIndex - 1; + const ch = str[i]; + escaped += str.substring(last, i) + (ch === "&" ? "&" : ch === '"' ? """ : "<"); + last = i + 1; + } + return escaped + str.substring(last); +} +var ssr_context = null; +function set_ssr_context(v) { + ssr_context = v; +} +function getContext(key) { + const context_map = get_or_init_context_map(); + const result = ( + /** @type {T} */ + context_map.get(key) + ); + return result; +} +function setContext(key, context) { + get_or_init_context_map().set(key, context); + return context; +} +function get_or_init_context_map(name) { + if (ssr_context === null) { + lifecycle_outside_component(); + } + return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0); +} +function push(fn) { + ssr_context = { p: ssr_context, c: null, r: null }; +} +function pop() { + ssr_context = /** @type {SSRContext} */ + ssr_context.p; +} +function get_parent_context(ssr_context2) { + let parent = ssr_context2.p; + while (parent !== null) { + const context_map = parent.c; + if (context_map !== null) { + return context_map; + } + parent = parent.p; + } + return null; +} +export { + set_ssr_context as a, + ssr_context as b, + pop as c, + escape_html as e, + getContext as g, + push as p, + setContext as s +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/environment.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/environment.js new file mode 100644 index 0000000..421fed0 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/environment.js @@ -0,0 +1,36 @@ +const BROWSER = false; +let base = ""; +let assets = base; +const app_dir = "_app"; +const relative = true; +const initial = { base, assets }; +function override(paths) { + base = paths.base; + assets = paths.assets; +} +function reset() { + base = initial.base; + assets = initial.assets; +} +function set_assets(path) { + assets = initial.assets = path; +} +let prerendering = false; +function set_building() { +} +function set_prerendering() { + prerendering = true; +} +export { + BROWSER as B, + assets as a, + base as b, + app_dir as c, + reset as d, + set_building as e, + set_prerendering as f, + override as o, + prerendering as p, + relative as r, + set_assets as s +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/equality.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/equality.js new file mode 100644 index 0000000..3c6fc90 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/equality.js @@ -0,0 +1,14 @@ +function equals(value) { + return value === this.v; +} +function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function"; +} +function safe_equals(value) { + return !safe_not_equal(value, this.v); +} +export { + safe_not_equal as a, + equals as e, + safe_equals as s +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/exports.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/exports.js new file mode 100644 index 0000000..81554d4 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/exports.js @@ -0,0 +1,174 @@ +const SCHEME = /^[a-z][a-z\d+\-.]+:/i; +const internal = new URL("sveltekit-internal://"); +function resolve(base, path) { + if (path[0] === "/" && path[1] === "/") return path; + let url = new URL(base, internal); + url = new URL(path, url); + return url.protocol === internal.protocol ? url.pathname + url.search + url.hash : url.href; +} +function normalize_path(path, trailing_slash) { + if (path === "/" || trailing_slash === "ignore") return path; + if (trailing_slash === "never") { + return path.endsWith("/") ? path.slice(0, -1) : path; + } else if (trailing_slash === "always" && !path.endsWith("/")) { + return path + "/"; + } + return path; +} +function decode_pathname(pathname) { + return pathname.split("%25").map(decodeURI).join("%25"); +} +function decode_params(params) { + for (const key in params) { + params[key] = decodeURIComponent(params[key]); + } + return params; +} +function make_trackable(url, callback, search_params_callback, allow_hash = false) { + const tracked = new URL(url); + Object.defineProperty(tracked, "searchParams", { + value: new Proxy(tracked.searchParams, { + get(obj, key) { + if (key === "get" || key === "getAll" || key === "has") { + return (param, ...rest) => { + search_params_callback(param); + return obj[key](param, ...rest); + }; + } + callback(); + const value = Reflect.get(obj, key); + return typeof value === "function" ? value.bind(obj) : value; + } + }), + enumerable: true, + configurable: true + }); + const tracked_url_properties = ["href", "pathname", "search", "toString", "toJSON"]; + if (allow_hash) tracked_url_properties.push("hash"); + for (const property of tracked_url_properties) { + Object.defineProperty(tracked, property, { + get() { + callback(); + return url[property]; + }, + enumerable: true, + configurable: true + }); + } + { + tracked[Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => { + return inspect(url, opts); + }; + tracked.searchParams[Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => { + return inspect(url.searchParams, opts); + }; + } + if (!allow_hash) { + disable_hash(tracked); + } + return tracked; +} +function disable_hash(url) { + allow_nodejs_console_log(url); + Object.defineProperty(url, "hash", { + get() { + throw new Error( + "Cannot access event.url.hash. Consider using `page.url.hash` inside a component instead" + ); + } + }); +} +function disable_search(url) { + allow_nodejs_console_log(url); + for (const property of ["search", "searchParams"]) { + Object.defineProperty(url, property, { + get() { + throw new Error(`Cannot access url.${property} on a page with prerendering enabled`); + } + }); + } +} +function allow_nodejs_console_log(url) { + { + url[Symbol.for("nodejs.util.inspect.custom")] = (depth, opts, inspect) => { + return inspect(new URL(url), opts); + }; + } +} +function validator(expected) { + function validate(module, file) { + if (!module) return; + for (const key in module) { + if (key[0] === "_" || expected.has(key)) continue; + const values = [...expected.values()]; + const hint = hint_for_supported_files(key, file?.slice(file.lastIndexOf("."))) ?? `valid exports are ${values.join(", ")}, or anything with a '_' prefix`; + throw new Error(`Invalid export '${key}'${file ? ` in ${file}` : ""} (${hint})`); + } + } + return validate; +} +function hint_for_supported_files(key, ext = ".js") { + const supported_files = []; + if (valid_layout_exports.has(key)) { + supported_files.push(`+layout${ext}`); + } + if (valid_page_exports.has(key)) { + supported_files.push(`+page${ext}`); + } + if (valid_layout_server_exports.has(key)) { + supported_files.push(`+layout.server${ext}`); + } + if (valid_page_server_exports.has(key)) { + supported_files.push(`+page.server${ext}`); + } + if (valid_server_exports.has(key)) { + supported_files.push(`+server${ext}`); + } + if (supported_files.length > 0) { + return `'${key}' is a valid export in ${supported_files.slice(0, -1).join(", ")}${supported_files.length > 1 ? " or " : ""}${supported_files.at(-1)}`; + } +} +const valid_layout_exports = /* @__PURE__ */ new Set([ + "load", + "prerender", + "csr", + "ssr", + "trailingSlash", + "config" +]); +const valid_page_exports = /* @__PURE__ */ new Set([...valid_layout_exports, "entries"]); +const valid_layout_server_exports = /* @__PURE__ */ new Set([...valid_layout_exports]); +const valid_page_server_exports = /* @__PURE__ */ new Set([...valid_layout_server_exports, "actions", "entries"]); +const valid_server_exports = /* @__PURE__ */ new Set([ + "GET", + "POST", + "PATCH", + "PUT", + "DELETE", + "OPTIONS", + "HEAD", + "fallback", + "prerender", + "trailingSlash", + "config", + "entries" +]); +const validate_layout_exports = validator(valid_layout_exports); +const validate_page_exports = validator(valid_page_exports); +const validate_layout_server_exports = validator(valid_layout_server_exports); +const validate_page_server_exports = validator(valid_page_server_exports); +const validate_server_exports = validator(valid_server_exports); +export { + SCHEME as S, + decode_params as a, + validate_layout_exports as b, + validate_page_server_exports as c, + disable_search as d, + validate_page_exports as e, + decode_pathname as f, + validate_server_exports as g, + make_trackable as m, + normalize_path as n, + resolve as r, + validate_layout_server_exports as v +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/index.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/index.js new file mode 100644 index 0000000..148262f --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/index.js @@ -0,0 +1,60 @@ +import { n as noop } from "./utils2.js"; +import { a as safe_not_equal } from "./equality.js"; +import "clsx"; +const subscriber_queue = []; +function readable(value, start) { + return { + subscribe: writable(value, start).subscribe + }; +} +function writable(value, start = noop) { + let stop = null; + const subscribers = /* @__PURE__ */ new Set(); + function set(new_value) { + if (safe_not_equal(value, new_value)) { + value = new_value; + if (stop) { + const run_queue = !subscriber_queue.length; + for (const subscriber of subscribers) { + subscriber[1](); + subscriber_queue.push(subscriber, value); + } + if (run_queue) { + for (let i = 0; i < subscriber_queue.length; i += 2) { + subscriber_queue[i][0](subscriber_queue[i + 1]); + } + subscriber_queue.length = 0; + } + } + } + } + function update(fn) { + set(fn( + /** @type {T} */ + value + )); + } + function subscribe(run, invalidate = noop) { + const subscriber = [run, invalidate]; + subscribers.add(subscriber); + if (subscribers.size === 1) { + stop = start(set, update) || noop; + } + run( + /** @type {T} */ + value + ); + return () => { + subscribers.delete(subscriber); + if (subscribers.size === 0 && stop) { + stop(); + stop = null; + } + }; + } + return { set, update, subscribe }; +} +export { + readable as r, + writable as w +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/index2.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/index2.js new file mode 100644 index 0000000..30db006 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/index2.js @@ -0,0 +1,1002 @@ +import { e as escape_html, a as set_ssr_context, b as ssr_context, p as push, c as pop } from "./context.js"; +import { clsx as clsx$1 } from "clsx"; +import * as devalue from "devalue"; +const DERIVED = 1 << 1; +const EFFECT = 1 << 2; +const RENDER_EFFECT = 1 << 3; +const MANAGED_EFFECT = 1 << 24; +const BLOCK_EFFECT = 1 << 4; +const BRANCH_EFFECT = 1 << 5; +const ROOT_EFFECT = 1 << 6; +const BOUNDARY_EFFECT = 1 << 7; +const CONNECTED = 1 << 9; +const CLEAN = 1 << 10; +const DIRTY = 1 << 11; +const MAYBE_DIRTY = 1 << 12; +const INERT = 1 << 13; +const DESTROYED = 1 << 14; +const EFFECT_RAN = 1 << 15; +const EFFECT_TRANSPARENT = 1 << 16; +const EAGER_EFFECT = 1 << 17; +const HEAD_EFFECT = 1 << 18; +const EFFECT_PRESERVED = 1 << 19; +const USER_EFFECT = 1 << 20; +const WAS_MARKED = 1 << 15; +const REACTION_IS_UPDATING = 1 << 21; +const ASYNC = 1 << 22; +const ERROR_VALUE = 1 << 23; +const STATE_SYMBOL = Symbol("$state"); +const LEGACY_PROPS = Symbol("legacy props"); +const STALE_REACTION = new class StaleReactionError extends Error { + name = "StaleReactionError"; + message = "The reaction that called `getAbortSignal()` was re-run or destroyed"; +}(); +const COMMENT_NODE = 8; +const HYDRATION_START = "["; +const HYDRATION_START_ELSE = "[!"; +const HYDRATION_END = "]"; +const HYDRATION_ERROR = {}; +const ELEMENT_IS_NAMESPACED = 1; +const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1; +const ELEMENT_IS_INPUT = 1 << 2; +const UNINITIALIZED = Symbol(); +const DOM_BOOLEAN_ATTRIBUTES = [ + "allowfullscreen", + "async", + "autofocus", + "autoplay", + "checked", + "controls", + "default", + "disabled", + "formnovalidate", + "indeterminate", + "inert", + "ismap", + "loop", + "multiple", + "muted", + "nomodule", + "novalidate", + "open", + "playsinline", + "readonly", + "required", + "reversed", + "seamless", + "selected", + "webkitdirectory", + "defer", + "disablepictureinpicture", + "disableremoteplayback" +]; +function is_boolean_attribute(name) { + return DOM_BOOLEAN_ATTRIBUTES.includes(name); +} +const PASSIVE_EVENTS = ["touchstart", "touchmove"]; +function is_passive_event(name) { + return PASSIVE_EVENTS.includes(name); +} +const replacements = { + translate: /* @__PURE__ */ new Map([ + [true, "yes"], + [false, "no"] + ]) +}; +function attr(name, value, is_boolean = false) { + if (name === "hidden" && value !== "until-found") { + is_boolean = true; + } + if (value == null || !value && is_boolean) return ""; + const normalized = name in replacements && replacements[name].get(value) || value; + const assignment = is_boolean ? "" : `="${escape_html(normalized, true)}"`; + return ` ${name}${assignment}`; +} +function clsx(value) { + if (typeof value === "object") { + return clsx$1(value); + } else { + return value ?? ""; + } +} +const whitespace = [..." \n\r\f \v\uFEFF"]; +function to_class(value, hash, directives) { + var classname = value == null ? "" : "" + value; + if (hash) { + classname = classname ? classname + " " + hash : hash; + } + if (directives) { + for (var key in directives) { + if (directives[key]) { + classname = classname ? classname + " " + key : key; + } else if (classname.length) { + var len = key.length; + var a = 0; + while ((a = classname.indexOf(key, a)) >= 0) { + var b = a + len; + if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) { + classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1); + } else { + a = b; + } + } + } + } + } + return classname === "" ? null : classname; +} +function append_styles(styles, important = false) { + var separator = important ? " !important;" : ";"; + var css = ""; + for (var key in styles) { + var value = styles[key]; + if (value != null && value !== "") { + css += " " + key + ": " + value + separator; + } + } + return css; +} +function to_css_name(name) { + if (name[0] !== "-" || name[1] !== "-") { + return name.toLowerCase(); + } + return name; +} +function to_style(value, styles) { + if (styles) { + var new_style = ""; + var normal_styles; + var important_styles; + if (Array.isArray(styles)) { + normal_styles = styles[0]; + important_styles = styles[1]; + } else { + normal_styles = styles; + } + if (value) { + value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim(); + var in_str = false; + var in_apo = 0; + var in_comment = false; + var reserved_names = []; + if (normal_styles) { + reserved_names.push(...Object.keys(normal_styles).map(to_css_name)); + } + if (important_styles) { + reserved_names.push(...Object.keys(important_styles).map(to_css_name)); + } + var start_index = 0; + var name_index = -1; + const len = value.length; + for (var i = 0; i < len; i++) { + var c = value[i]; + if (in_comment) { + if (c === "/" && value[i - 1] === "*") { + in_comment = false; + } + } else if (in_str) { + if (in_str === c) { + in_str = false; + } + } else if (c === "/" && value[i + 1] === "*") { + in_comment = true; + } else if (c === '"' || c === "'") { + in_str = c; + } else if (c === "(") { + in_apo++; + } else if (c === ")") { + in_apo--; + } + if (!in_comment && in_str === false && in_apo === 0) { + if (c === ":" && name_index === -1) { + name_index = i; + } else if (c === ";" || i === len - 1) { + if (name_index !== -1) { + var name = to_css_name(value.substring(start_index, name_index).trim()); + if (!reserved_names.includes(name)) { + if (c !== ";") { + i++; + } + var property = value.substring(start_index, i).trim(); + new_style += " " + property + ";"; + } + } + start_index = i + 1; + name_index = -1; + } + } + } + } + if (normal_styles) { + new_style += append_styles(normal_styles); + } + if (important_styles) { + new_style += append_styles(important_styles, true); + } + new_style = new_style.trim(); + return new_style === "" ? null : new_style; + } + return value == null ? null : String(value); +} +const BLOCK_OPEN = ``; +const BLOCK_CLOSE = ``; +const EMPTY_COMMENT = ``; +let controller = null; +function abort() { + controller?.abort(STALE_REACTION); + controller = null; +} +function await_invalid() { + const error = new Error(`await_invalid +Encountered asynchronous work while rendering synchronously. +https://svelte.dev/e/await_invalid`); + error.name = "Svelte error"; + throw error; +} +function invalid_csp() { + const error = new Error(`invalid_csp +\`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously. +https://svelte.dev/e/invalid_csp`); + error.name = "Svelte error"; + throw error; +} +function server_context_required() { + const error = new Error(`server_context_required +Could not resolve \`render\` context. +https://svelte.dev/e/server_context_required`); + error.name = "Svelte error"; + throw error; +} +function unresolved_hydratable(key, stack) { + { + console.warn(`https://svelte.dev/e/unresolved_hydratable`); + } +} +function get_render_context() { + const store = als?.getStore(); + { + server_context_required(); + } + return store; +} +let als = null; +let text_encoder; +let crypto; +async function sha256(data) { + text_encoder ??= new TextEncoder(); + crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : ( + // @ts-ignore - we don't install node types in the prod build + (await import("node:crypto")).webcrypto + ); + const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data)); + return base64_encode(hash_buffer); +} +function base64_encode(bytes) { + if (globalThis.Buffer) { + return globalThis.Buffer.from(bytes).toString("base64"); + } + let binary = ""; + for (let i = 0; i < bytes.length; i++) { + binary += String.fromCharCode(bytes[i]); + } + return btoa(binary); +} +class Renderer { + /** + * The contents of the renderer. + * @type {RendererItem[]} + */ + #out = []; + /** + * Any `onDestroy` callbacks registered during execution of this renderer. + * @type {(() => void)[] | undefined} + */ + #on_destroy = void 0; + /** + * Whether this renderer is a component body. + * @type {boolean} + */ + #is_component_body = false; + /** + * The type of string content that this renderer is accumulating. + * @type {RendererType} + */ + type; + /** @type {Renderer | undefined} */ + #parent; + /** + * Asynchronous work associated with this renderer + * @type {Promise | undefined} + */ + promise = void 0; + /** + * State which is associated with the content tree as a whole. + * It will be re-exposed, uncopied, on all children. + * @type {SSRState} + * @readonly + */ + global; + /** + * State that is local to the branch it is declared in. + * It will be shallow-copied to all children. + * + * @type {{ select_value: string | undefined }} + */ + local; + /** + * @param {SSRState} global + * @param {Renderer | undefined} [parent] + */ + constructor(global, parent) { + this.#parent = parent; + this.global = global; + this.local = parent ? { ...parent.local } : { select_value: void 0 }; + this.type = parent ? parent.type : "body"; + } + /** + * @param {(renderer: Renderer) => void} fn + */ + head(fn) { + const head2 = new Renderer(this.global, this); + head2.type = "head"; + this.#out.push(head2); + head2.child(fn); + } + /** + * @param {Array>} blockers + * @param {(renderer: Renderer) => void} fn + */ + async_block(blockers, fn) { + this.#out.push(BLOCK_OPEN); + this.async(blockers, fn); + this.#out.push(BLOCK_CLOSE); + } + /** + * @param {Array>} blockers + * @param {(renderer: Renderer) => void} fn + */ + async(blockers, fn) { + let callback = fn; + if (blockers.length > 0) { + const context = ssr_context; + callback = (renderer) => { + return Promise.all(blockers).then(() => { + const previous_context = ssr_context; + try { + set_ssr_context(context); + return fn(renderer); + } finally { + set_ssr_context(previous_context); + } + }); + }; + } + this.child(callback); + } + /** + * @param {Array<() => void>} thunks + */ + run(thunks) { + const context = ssr_context; + let promise = Promise.resolve(thunks[0]()); + const promises = [promise]; + for (const fn of thunks.slice(1)) { + promise = promise.then(() => { + const previous_context = ssr_context; + set_ssr_context(context); + try { + return fn(); + } finally { + set_ssr_context(previous_context); + } + }); + promises.push(promise); + } + return promises; + } + /** + * Create a child renderer. The child renderer inherits the state from the parent, + * but has its own content. + * @param {(renderer: Renderer) => MaybePromise} fn + */ + child(fn) { + const child = new Renderer(this.global, this); + this.#out.push(child); + const parent = ssr_context; + set_ssr_context({ + ...ssr_context, + p: parent, + c: null, + r: child + }); + const result = fn(child); + set_ssr_context(parent); + if (result instanceof Promise) { + if (child.global.mode === "sync") { + await_invalid(); + } + result.catch(() => { + }); + child.promise = result; + } + return child; + } + /** + * Create a component renderer. The component renderer inherits the state from the parent, + * but has its own content. It is treated as an ordering boundary for ondestroy callbacks. + * @param {(renderer: Renderer) => MaybePromise} fn + * @param {Function} [component_fn] + * @returns {void} + */ + component(fn, component_fn) { + push(); + const child = this.child(fn); + child.#is_component_body = true; + pop(); + } + /** + * @param {Record} attrs + * @param {(renderer: Renderer) => void} fn + * @param {string | undefined} [css_hash] + * @param {Record | undefined} [classes] + * @param {Record | undefined} [styles] + * @param {number | undefined} [flags] + * @param {boolean | undefined} [is_rich] + * @returns {void} + */ + select(attrs, fn, css_hash, classes, styles, flags, is_rich) { + const { value, ...select_attrs } = attrs; + this.push(``); + this.child((renderer) => { + renderer.local.select_value = value; + fn(renderer); + }); + this.push(`${is_rich ? "" : ""}`); + } + /** + * @param {Record} attrs + * @param {string | number | boolean | ((renderer: Renderer) => void)} body + * @param {string | undefined} [css_hash] + * @param {Record | undefined} [classes] + * @param {Record | undefined} [styles] + * @param {number | undefined} [flags] + * @param {boolean | undefined} [is_rich] + */ + option(attrs, body, css_hash, classes, styles, flags, is_rich) { + this.#out.push(` { + if ("value" in attrs) { + value = attrs.value; + } + if (value === this.local.select_value) { + renderer.#out.push(" selected"); + } + renderer.#out.push(`>${body2}${is_rich ? "" : ""}`); + if (head2) { + renderer.head((child) => child.push(head2)); + } + }; + if (typeof body === "function") { + this.child((renderer) => { + const r = new Renderer(this.global, this); + body(r); + if (this.global.mode === "async") { + return r.#collect_content_async().then((content) => { + close(renderer, content.body.replaceAll("", ""), content); + }); + } else { + const content = r.#collect_content(); + close(renderer, content.body.replaceAll("", ""), content); + } + }); + } else { + close(this, body, { body }); + } + } + /** + * @param {(renderer: Renderer) => void} fn + */ + title(fn) { + const path = this.get_path(); + const close = (head2) => { + this.global.set_title(head2, path); + }; + this.child((renderer) => { + const r = new Renderer(renderer.global, renderer); + fn(r); + if (renderer.global.mode === "async") { + return r.#collect_content_async().then((content) => { + close(content.head); + }); + } else { + const content = r.#collect_content(); + close(content.head); + } + }); + } + /** + * @param {string | (() => Promise)} content + */ + push(content) { + if (typeof content === "function") { + this.child(async (renderer) => renderer.push(await content())); + } else { + this.#out.push(content); + } + } + /** + * @param {() => void} fn + */ + on_destroy(fn) { + (this.#on_destroy ??= []).push(fn); + } + /** + * @returns {number[]} + */ + get_path() { + return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : []; + } + /** + * @deprecated this is needed for legacy component bindings + */ + copy() { + const copy = new Renderer(this.global, this.#parent); + copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item); + copy.promise = this.promise; + return copy; + } + /** + * @param {Renderer} other + * @deprecated this is needed for legacy component bindings + */ + subsume(other) { + if (this.global.mode !== other.global.mode) { + throw new Error( + "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!" + ); + } + this.local = other.local; + this.#out = other.#out.map((item) => { + if (item instanceof Renderer) { + item.subsume(item); + } + return item; + }); + this.promise = other.promise; + this.type = other.type; + } + get length() { + return this.#out.length; + } + /** + * Only available on the server and when compiling with the `server` option. + * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app. + * @template {Record} Props + * @param {Component} component + * @param {{ props?: Omit; context?: Map; idPrefix?: string; csp?: Csp }} [options] + * @returns {RenderOutput} + */ + static render(component, options = {}) { + let sync; + const result = ( + /** @type {RenderOutput} */ + {} + ); + Object.defineProperties(result, { + html: { + get: () => { + return (sync ??= Renderer.#render(component, options)).body; + } + }, + head: { + get: () => { + return (sync ??= Renderer.#render(component, options)).head; + } + }, + body: { + get: () => { + return (sync ??= Renderer.#render(component, options)).body; + } + }, + hashes: { + value: { + script: "" + } + }, + then: { + value: ( + /** + * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function. + * + * @template TResult1 + * @template [TResult2=never] + * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled + * @param { (reason: unknown) => TResult2 } onrejected + */ + (onfulfilled, onrejected) => { + { + const result2 = sync ??= Renderer.#render(component, options); + const user_result = onfulfilled({ + head: result2.head, + body: result2.body, + html: result2.body, + hashes: { script: [] } + }); + return Promise.resolve(user_result); + } + } + ) + } + }); + return result; + } + /** + * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call + * after awaiting `collect_async`. + * + * Child renderers are "porous" and don't affect execution order, but component body renderers + * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary. + * @returns {Iterable<() => void>} + */ + *#collect_on_destroy() { + for (const component of this.#traverse_components()) { + yield* component.#collect_ondestroy(); + } + } + /** + * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree. + * @returns {Iterable} + */ + *#traverse_components() { + for (const child of this.#out) { + if (typeof child !== "string") { + yield* child.#traverse_components(); + } + } + if (this.#is_component_body) { + yield this; + } + } + /** + * @returns {Iterable<() => void>} + */ + *#collect_ondestroy() { + if (this.#on_destroy) { + for (const fn of this.#on_destroy) { + yield fn; + } + } + for (const child of this.#out) { + if (child instanceof Renderer && !child.#is_component_body) { + yield* child.#collect_ondestroy(); + } + } + } + /** + * Render a component. Throws if any of the children are performing asynchronous work. + * + * @template {Record} Props + * @param {Component} component + * @param {{ props?: Omit; context?: Map; idPrefix?: string }} options + * @returns {AccumulatedContent} + */ + static #render(component, options) { + var previous_context = ssr_context; + try { + const renderer = Renderer.#open_render("sync", component, options); + const content = renderer.#collect_content(); + return Renderer.#close_render(content, renderer); + } finally { + abort(); + set_ssr_context(previous_context); + } + } + /** + * Render a component. + * + * @template {Record} Props + * @param {Component} component + * @param {{ props?: Omit; context?: Map; idPrefix?: string; csp?: Csp }} options + * @returns {Promise} + */ + static async #render_async(component, options) { + const previous_context = ssr_context; + try { + const renderer = Renderer.#open_render("async", component, options); + const content = await renderer.#collect_content_async(); + const hydratables = await renderer.#collect_hydratables(); + if (hydratables !== null) { + content.head = hydratables + content.head; + } + return Renderer.#close_render(content, renderer); + } finally { + set_ssr_context(previous_context); + abort(); + } + } + /** + * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string. + * @param {AccumulatedContent} content + * @returns {AccumulatedContent} + */ + #collect_content(content = { head: "", body: "" }) { + for (const item of this.#out) { + if (typeof item === "string") { + content[this.type] += item; + } else if (item instanceof Renderer) { + item.#collect_content(content); + } + } + return content; + } + /** + * Collect all of the code from the `out` array and return it as a string. + * @param {AccumulatedContent} content + * @returns {Promise} + */ + async #collect_content_async(content = { head: "", body: "" }) { + await this.promise; + for (const item of this.#out) { + if (typeof item === "string") { + content[this.type] += item; + } else if (item instanceof Renderer) { + await item.#collect_content_async(content); + } + } + return content; + } + async #collect_hydratables() { + const ctx = get_render_context().hydratable; + for (const [_, key] of ctx.unresolved_promises) { + unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? ""); + } + for (const comparison of ctx.comparisons) { + await comparison; + } + return await this.#hydratable_block(ctx); + } + /** + * @template {Record} Props + * @param {'sync' | 'async'} mode + * @param {import('svelte').Component} component + * @param {{ props?: Omit; context?: Map; idPrefix?: string; csp?: Csp }} options + * @returns {Renderer} + */ + static #open_render(mode, component, options) { + const renderer = new Renderer( + new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp) + ); + renderer.push(BLOCK_OPEN); + if (options.context) { + push(); + ssr_context.c = options.context; + ssr_context.r = renderer; + } + component(renderer, options.props ?? {}); + if (options.context) { + pop(); + } + renderer.push(BLOCK_CLOSE); + return renderer; + } + /** + * @param {AccumulatedContent} content + * @param {Renderer} renderer + * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }} + */ + static #close_render(content, renderer) { + for (const cleanup of renderer.#collect_on_destroy()) { + cleanup(); + } + let head2 = content.head + renderer.global.get_title(); + let body = content.body; + for (const { hash, code } of renderer.global.css) { + head2 += ``; + } + return { + head: head2, + body, + hashes: { + script: renderer.global.csp.script_hashes + } + }; + } + /** + * @param {HydratableContext} ctx + */ + async #hydratable_block(ctx) { + if (ctx.lookup.size === 0) { + return null; + } + let entries = []; + let has_promises = false; + for (const [k, v] of ctx.lookup) { + if (v.promises) { + has_promises = true; + for (const p of v.promises) await p; + } + entries.push(`[${devalue.uneval(k)},${v.serialized}]`); + } + let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`; + if (has_promises) { + prelude = `const r = (v) => Promise.resolve(v); + ${prelude}`; + } + const body = ` + { + ${prelude} + + for (const [k, v] of [ + ${entries.join(",\n ")} + ]) { + h.set(k, v); + } + } + `; + let csp_attr = ""; + if (this.global.csp.nonce) { + csp_attr = ` nonce="${this.global.csp.nonce}"`; + } else if (this.global.csp.hash) { + const hash = await sha256(body); + this.global.csp.script_hashes.push(`sha256-${hash}`); + } + return ` + ${body}<\/script>`; + } +} +class SSRState { + /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */ + csp; + /** @readonly @type {'sync' | 'async'} */ + mode; + /** @readonly @type {() => string} */ + uid; + /** @readonly @type {Set<{ hash: string; code: string }>} */ + css = /* @__PURE__ */ new Set(); + /** @type {{ path: number[], value: string }} */ + #title = { path: [], value: "" }; + /** + * @param {'sync' | 'async'} mode + * @param {string} id_prefix + * @param {Csp} csp + */ + constructor(mode, id_prefix = "", csp = { hash: false }) { + this.mode = mode; + this.csp = { ...csp, script_hashes: [] }; + let uid = 1; + this.uid = () => `${id_prefix}s${uid++}`; + } + get_title() { + return this.#title.value; + } + /** + * Performs a depth-first (lexicographic) comparison using the path. Rejects sets + * from earlier than or equal to the current value. + * @param {string} value + * @param {number[]} path + */ + set_title(value, path) { + const current = this.#title.path; + let i = 0; + let l = Math.min(path.length, current.length); + while (i < l && path[i] === current[i]) i += 1; + if (path[i] === void 0) return; + if (current[i] === void 0 || path[i] > current[i]) { + this.#title.path = path; + this.#title.value = value; + } + } +} +const INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u; +function render(component, options = {}) { + if (options.csp?.hash && options.csp.nonce) { + invalid_csp(); + } + return Renderer.render( + /** @type {Component} */ + component, + options + ); +} +function head(hash, renderer, fn) { + renderer.head((renderer2) => { + renderer2.push(``); + renderer2.child(fn); + renderer2.push(EMPTY_COMMENT); + }); +} +function attributes(attrs, css_hash, classes, styles, flags = 0) { + if (styles) { + attrs.style = to_style(attrs.style, styles); + } + if (attrs.class) { + attrs.class = clsx(attrs.class); + } + if (css_hash || classes) { + attrs.class = to_class(attrs.class, css_hash, classes); + } + let attr_str = ""; + let name; + const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0; + const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0; + const is_input = (flags & ELEMENT_IS_INPUT) !== 0; + for (name in attrs) { + if (typeof attrs[name] === "function") continue; + if (name[0] === "$" && name[1] === "$") continue; + if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue; + var value = attrs[name]; + if (lowercase) { + name = name.toLowerCase(); + } + if (is_input) { + if (name === "defaultvalue" || name === "defaultchecked") { + name = name === "defaultvalue" ? "value" : "checked"; + if (attrs[name]) continue; + } + } + attr_str += attr(name, value, is_html && is_boolean_attribute(name)); + } + return attr_str; +} +function once(get_value) { + let value = ( + /** @type {V} */ + UNINITIALIZED + ); + return () => { + if (value === UNINITIALIZED) { + value = get_value(); + } + return value; + }; +} +function derived(fn) { + const get_value = once(fn); + let updated_value; + return function(new_value) { + if (arguments.length === 0) { + return updated_value ?? get_value(); + } + updated_value = new_value; + return updated_value; + }; +} +export { + ASYNC as A, + BOUNDARY_EFFECT as B, + COMMENT_NODE as C, + DIRTY as D, + ERROR_VALUE as E, + HYDRATION_ERROR as H, + INERT as I, + LEGACY_PROPS as L, + MAYBE_DIRTY as M, + ROOT_EFFECT as R, + STATE_SYMBOL as S, + UNINITIALIZED as U, + WAS_MARKED as W, + HYDRATION_END as a, + HYDRATION_START as b, + HYDRATION_START_ELSE as c, + EFFECT_RAN as d, + CONNECTED as e, + CLEAN as f, + DERIVED as g, + EFFECT as h, + BLOCK_EFFECT as i, + BRANCH_EFFECT as j, + RENDER_EFFECT as k, + MANAGED_EFFECT as l, + DESTROYED as m, + HEAD_EFFECT as n, + EFFECT_TRANSPARENT as o, + EFFECT_PRESERVED as p, + EAGER_EFFECT as q, + STALE_REACTION as r, + USER_EFFECT as s, + REACTION_IS_UPDATING as t, + is_passive_event as u, + render as v, + head as w, + derived as x +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/internal.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/internal.js new file mode 100644 index 0000000..5226ad2 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/internal.js @@ -0,0 +1,2669 @@ +import { H as HYDRATION_ERROR, C as COMMENT_NODE, a as HYDRATION_END, b as HYDRATION_START, c as HYDRATION_START_ELSE, B as BOUNDARY_EFFECT, E as ERROR_VALUE, d as EFFECT_RAN, e as CONNECTED, f as CLEAN, M as MAYBE_DIRTY, D as DIRTY, g as DERIVED, W as WAS_MARKED, I as INERT, h as EFFECT, i as BLOCK_EFFECT, U as UNINITIALIZED, j as BRANCH_EFFECT, R as ROOT_EFFECT, k as RENDER_EFFECT, l as MANAGED_EFFECT, m as DESTROYED, A as ASYNC, n as HEAD_EFFECT, o as EFFECT_TRANSPARENT, p as EFFECT_PRESERVED, q as EAGER_EFFECT, S as STATE_SYMBOL, r as STALE_REACTION, s as USER_EFFECT, t as REACTION_IS_UPDATING, u as is_passive_event, L as LEGACY_PROPS, v as render } from "./index2.js"; +import { B as BROWSER } from "./environment.js"; +import { r as run_all, d as deferred, o as object_prototype, a as array_prototype, g as get_descriptor, b as get_prototype_of, i as is_array, c as is_extensible, e as index_of, f as define_property, h as array_from } from "./utils2.js"; +import { s as safe_equals, e as equals } from "./equality.js"; +import "clsx"; +import { s as setContext } from "./context.js"; +let public_env = {}; +function set_private_env(environment) { +} +function set_public_env(environment) { + public_env = environment; +} +function effect_update_depth_exceeded() { + { + throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`); + } +} +function hydration_failed() { + { + throw new Error(`https://svelte.dev/e/hydration_failed`); + } +} +function state_descriptors_fixed() { + { + throw new Error(`https://svelte.dev/e/state_descriptors_fixed`); + } +} +function state_prototype_fixed() { + { + throw new Error(`https://svelte.dev/e/state_prototype_fixed`); + } +} +function state_unsafe_mutation() { + { + throw new Error(`https://svelte.dev/e/state_unsafe_mutation`); + } +} +function svelte_boundary_reset_onerror() { + { + throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`); + } +} +function hydration_mismatch(location) { + { + console.warn(`https://svelte.dev/e/hydration_mismatch`); + } +} +function svelte_boundary_reset_noop() { + { + console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`); + } +} +let hydrating = false; +function set_hydrating(value) { + hydrating = value; +} +let hydrate_node; +function set_hydrate_node(node) { + if (node === null) { + hydration_mismatch(); + throw HYDRATION_ERROR; + } + return hydrate_node = node; +} +function hydrate_next() { + return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node)); +} +function next(count = 1) { + if (hydrating) { + var i = count; + var node = hydrate_node; + while (i--) { + node = /** @type {TemplateNode} */ + /* @__PURE__ */ get_next_sibling(node); + } + hydrate_node = node; + } +} +function skip_nodes(remove = true) { + var depth = 0; + var node = hydrate_node; + while (true) { + if (node.nodeType === COMMENT_NODE) { + var data = ( + /** @type {Comment} */ + node.data + ); + if (data === HYDRATION_END) { + if (depth === 0) return node; + depth -= 1; + } else if (data === HYDRATION_START || data === HYDRATION_START_ELSE) { + depth += 1; + } + } + var next2 = ( + /** @type {TemplateNode} */ + /* @__PURE__ */ get_next_sibling(node) + ); + if (remove) node.remove(); + node = next2; + } +} +let tracing_mode_flag = false; +let component_context = null; +function set_component_context(context) { + component_context = context; +} +function push(props, runes = false, fn) { + component_context = { + p: component_context, + i: false, + c: null, + e: null, + s: props, + x: null, + l: null + }; +} +function pop(component) { + var context = ( + /** @type {ComponentContext} */ + component_context + ); + var effects = context.e; + if (effects !== null) { + context.e = null; + for (var fn of effects) { + create_user_effect(fn); + } + } + context.i = true; + component_context = context.p; + return ( + /** @type {T} */ + {} + ); +} +function is_runes() { + return true; +} +let micro_tasks = []; +function run_micro_tasks() { + var tasks = micro_tasks; + micro_tasks = []; + run_all(tasks); +} +function queue_micro_task(fn) { + if (micro_tasks.length === 0 && !is_flushing_sync) { + var tasks = micro_tasks; + queueMicrotask(() => { + if (tasks === micro_tasks) run_micro_tasks(); + }); + } + micro_tasks.push(fn); +} +function flush_tasks() { + while (micro_tasks.length > 0) { + run_micro_tasks(); + } +} +function handle_error(error) { + var effect = active_effect; + if (effect === null) { + active_reaction.f |= ERROR_VALUE; + return error; + } + if ((effect.f & EFFECT_RAN) === 0) { + if ((effect.f & BOUNDARY_EFFECT) === 0) { + throw error; + } + effect.b.error(error); + } else { + invoke_error_boundary(error, effect); + } +} +function invoke_error_boundary(error, effect) { + while (effect !== null) { + if ((effect.f & BOUNDARY_EFFECT) !== 0) { + try { + effect.b.error(error); + return; + } catch (e) { + error = e; + } + } + effect = effect.parent; + } + throw error; +} +const STATUS_MASK = -7169; +function set_signal_status(signal, status) { + signal.f = signal.f & STATUS_MASK | status; +} +function update_derived_status(derived) { + if ((derived.f & CONNECTED) !== 0 || derived.deps === null) { + set_signal_status(derived, CLEAN); + } else { + set_signal_status(derived, MAYBE_DIRTY); + } +} +function clear_marked(deps) { + if (deps === null) return; + for (const dep of deps) { + if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) { + continue; + } + dep.f ^= WAS_MARKED; + clear_marked( + /** @type {Derived} */ + dep.deps + ); + } +} +function defer_effect(effect, dirty_effects, maybe_dirty_effects) { + if ((effect.f & DIRTY) !== 0) { + dirty_effects.add(effect); + } else if ((effect.f & MAYBE_DIRTY) !== 0) { + maybe_dirty_effects.add(effect); + } + clear_marked(effect.deps); + set_signal_status(effect, CLEAN); +} +const batches = /* @__PURE__ */ new Set(); +let current_batch = null; +let batch_values = null; +let queued_root_effects = []; +let last_scheduled_effect = null; +let is_flushing = false; +let is_flushing_sync = false; +class Batch { + committed = false; + /** + * The current values of any sources that are updated in this batch + * They keys of this map are identical to `this.#previous` + * @type {Map} + */ + current = /* @__PURE__ */ new Map(); + /** + * The values of any sources that are updated in this batch _before_ those updates took place. + * They keys of this map are identical to `this.#current` + * @type {Map} + */ + previous = /* @__PURE__ */ new Map(); + /** + * When the batch is committed (and the DOM is updated), we need to remove old branches + * and append new ones by calling the functions added inside (if/each/key/etc) blocks + * @type {Set<() => void>} + */ + #commit_callbacks = /* @__PURE__ */ new Set(); + /** + * If a fork is discarded, we need to destroy any effects that are no longer needed + * @type {Set<(batch: Batch) => void>} + */ + #discard_callbacks = /* @__PURE__ */ new Set(); + /** + * The number of async effects that are currently in flight + */ + #pending = 0; + /** + * The number of async effects that are currently in flight, _not_ inside a pending boundary + */ + #blocking_pending = 0; + /** + * A deferred that resolves when the batch is committed, used with `settled()` + * TODO replace with Promise.withResolvers once supported widely enough + * @type {{ promise: Promise, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null} + */ + #deferred = null; + /** + * Deferred effects (which run after async work has completed) that are DIRTY + * @type {Set} + */ + #dirty_effects = /* @__PURE__ */ new Set(); + /** + * Deferred effects that are MAYBE_DIRTY + * @type {Set} + */ + #maybe_dirty_effects = /* @__PURE__ */ new Set(); + /** + * A set of branches that still exist, but will be destroyed when this batch + * is committed — we skip over these during `process` + * @type {Set} + */ + skipped_effects = /* @__PURE__ */ new Set(); + is_fork = false; + is_deferred() { + return this.is_fork || this.#blocking_pending > 0; + } + /** + * + * @param {Effect[]} root_effects + */ + process(root_effects) { + queued_root_effects = []; + this.apply(); + var effects = []; + var render_effects = []; + for (const root2 of root_effects) { + this.#traverse_effect_tree(root2, effects, render_effects); + } + if (!this.is_fork) { + this.#resolve(); + } + if (this.is_deferred()) { + this.#defer_effects(render_effects); + this.#defer_effects(effects); + } else { + current_batch = null; + flush_queued_effects(render_effects); + flush_queued_effects(effects); + this.#deferred?.resolve(); + } + batch_values = null; + } + /** + * Traverse the effect tree, executing effects or stashing + * them for later execution as appropriate + * @param {Effect} root + * @param {Effect[]} effects + * @param {Effect[]} render_effects + */ + #traverse_effect_tree(root2, effects, render_effects) { + root2.f ^= CLEAN; + var effect = root2.first; + var pending_boundary = null; + while (effect !== null) { + var flags2 = effect.f; + var is_branch = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0; + var is_skippable_branch = is_branch && (flags2 & CLEAN) !== 0; + var skip = is_skippable_branch || (flags2 & INERT) !== 0 || this.skipped_effects.has(effect); + if (!skip && effect.fn !== null) { + if (is_branch) { + effect.f ^= CLEAN; + } else if (pending_boundary !== null && (flags2 & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0) { + pending_boundary.b.defer_effect(effect); + } else if ((flags2 & EFFECT) !== 0) { + effects.push(effect); + } else if (is_dirty(effect)) { + if ((flags2 & BLOCK_EFFECT) !== 0) this.#dirty_effects.add(effect); + update_effect(effect); + } + var child = effect.first; + if (child !== null) { + effect = child; + continue; + } + } + var parent = effect.parent; + effect = effect.next; + while (effect === null && parent !== null) { + if (parent === pending_boundary) { + pending_boundary = null; + } + effect = parent.next; + parent = parent.parent; + } + } + } + /** + * @param {Effect[]} effects + */ + #defer_effects(effects) { + for (var i = 0; i < effects.length; i += 1) { + defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects); + } + } + /** + * Associate a change to a given source with the current + * batch, noting its previous and current values + * @param {Source} source + * @param {any} value + */ + capture(source2, value) { + if (value !== UNINITIALIZED && !this.previous.has(source2)) { + this.previous.set(source2, value); + } + if ((source2.f & ERROR_VALUE) === 0) { + this.current.set(source2, source2.v); + batch_values?.set(source2, source2.v); + } + } + activate() { + current_batch = this; + this.apply(); + } + deactivate() { + if (current_batch !== this) return; + current_batch = null; + batch_values = null; + } + flush() { + this.activate(); + if (queued_root_effects.length > 0) { + flush_effects(); + if (current_batch !== null && current_batch !== this) { + return; + } + } else if (this.#pending === 0) { + this.process([]); + } + this.deactivate(); + } + discard() { + for (const fn of this.#discard_callbacks) fn(this); + this.#discard_callbacks.clear(); + } + #resolve() { + if (this.#blocking_pending === 0) { + for (const fn of this.#commit_callbacks) fn(); + this.#commit_callbacks.clear(); + } + if (this.#pending === 0) { + this.#commit(); + } + } + #commit() { + if (batches.size > 1) { + this.previous.clear(); + var previous_batch_values = batch_values; + var is_earlier = true; + for (const batch of batches) { + if (batch === this) { + is_earlier = false; + continue; + } + const sources = []; + for (const [source2, value] of this.current) { + if (batch.current.has(source2)) { + if (is_earlier && value !== batch.current.get(source2)) { + batch.current.set(source2, value); + } else { + continue; + } + } + sources.push(source2); + } + if (sources.length === 0) { + continue; + } + const others = [...batch.current.keys()].filter((s) => !this.current.has(s)); + if (others.length > 0) { + var prev_queued_root_effects = queued_root_effects; + queued_root_effects = []; + const marked = /* @__PURE__ */ new Set(); + const checked = /* @__PURE__ */ new Map(); + for (const source2 of sources) { + mark_effects(source2, others, marked, checked); + } + if (queued_root_effects.length > 0) { + current_batch = batch; + batch.apply(); + for (const root2 of queued_root_effects) { + batch.#traverse_effect_tree(root2, [], []); + } + batch.deactivate(); + } + queued_root_effects = prev_queued_root_effects; + } + } + current_batch = null; + batch_values = previous_batch_values; + } + this.committed = true; + batches.delete(this); + } + /** + * + * @param {boolean} blocking + */ + increment(blocking) { + this.#pending += 1; + if (blocking) this.#blocking_pending += 1; + } + /** + * + * @param {boolean} blocking + */ + decrement(blocking) { + this.#pending -= 1; + if (blocking) this.#blocking_pending -= 1; + this.revive(); + } + revive() { + for (const e of this.#dirty_effects) { + this.#maybe_dirty_effects.delete(e); + set_signal_status(e, DIRTY); + schedule_effect(e); + } + for (const e of this.#maybe_dirty_effects) { + set_signal_status(e, MAYBE_DIRTY); + schedule_effect(e); + } + this.flush(); + } + /** @param {() => void} fn */ + oncommit(fn) { + this.#commit_callbacks.add(fn); + } + /** @param {(batch: Batch) => void} fn */ + ondiscard(fn) { + this.#discard_callbacks.add(fn); + } + settled() { + return (this.#deferred ??= deferred()).promise; + } + static ensure() { + if (current_batch === null) { + const batch = current_batch = new Batch(); + batches.add(current_batch); + if (!is_flushing_sync) { + Batch.enqueue(() => { + if (current_batch !== batch) { + return; + } + batch.flush(); + }); + } + } + return current_batch; + } + /** @param {() => void} task */ + static enqueue(task) { + queue_micro_task(task); + } + apply() { + return; + } +} +function flushSync(fn) { + var was_flushing_sync = is_flushing_sync; + is_flushing_sync = true; + try { + var result; + if (fn) ; + while (true) { + flush_tasks(); + if (queued_root_effects.length === 0) { + current_batch?.flush(); + if (queued_root_effects.length === 0) { + last_scheduled_effect = null; + return ( + /** @type {T} */ + result + ); + } + } + flush_effects(); + } + } finally { + is_flushing_sync = was_flushing_sync; + } +} +function flush_effects() { + var was_updating_effect = is_updating_effect; + is_flushing = true; + var source_stacks = null; + try { + var flush_count = 0; + set_is_updating_effect(true); + while (queued_root_effects.length > 0) { + var batch = Batch.ensure(); + if (flush_count++ > 1e3) { + var updates, entry; + if (BROWSER) ; + infinite_loop_guard(); + } + batch.process(queued_root_effects); + old_values.clear(); + if (BROWSER) ; + } + } finally { + is_flushing = false; + set_is_updating_effect(was_updating_effect); + last_scheduled_effect = null; + } +} +function infinite_loop_guard() { + try { + effect_update_depth_exceeded(); + } catch (error) { + invoke_error_boundary(error, last_scheduled_effect); + } +} +let eager_block_effects = null; +function flush_queued_effects(effects) { + var length = effects.length; + if (length === 0) return; + var i = 0; + while (i < length) { + var effect = effects[i++]; + if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) { + eager_block_effects = /* @__PURE__ */ new Set(); + update_effect(effect); + if (effect.deps === null && effect.first === null && effect.nodes === null) { + if (effect.teardown === null && effect.ac === null) { + unlink_effect(effect); + } else { + effect.fn = null; + } + } + if (eager_block_effects?.size > 0) { + old_values.clear(); + for (const e of eager_block_effects) { + if ((e.f & (DESTROYED | INERT)) !== 0) continue; + const ordered_effects = [e]; + let ancestor = e.parent; + while (ancestor !== null) { + if (eager_block_effects.has(ancestor)) { + eager_block_effects.delete(ancestor); + ordered_effects.push(ancestor); + } + ancestor = ancestor.parent; + } + for (let j = ordered_effects.length - 1; j >= 0; j--) { + const e2 = ordered_effects[j]; + if ((e2.f & (DESTROYED | INERT)) !== 0) continue; + update_effect(e2); + } + } + eager_block_effects.clear(); + } + } + } + eager_block_effects = null; +} +function mark_effects(value, sources, marked, checked) { + if (marked.has(value)) return; + marked.add(value); + if (value.reactions !== null) { + for (const reaction of value.reactions) { + const flags2 = reaction.f; + if ((flags2 & DERIVED) !== 0) { + mark_effects( + /** @type {Derived} */ + reaction, + sources, + marked, + checked + ); + } else if ((flags2 & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags2 & DIRTY) === 0 && depends_on(reaction, sources, checked)) { + set_signal_status(reaction, DIRTY); + schedule_effect( + /** @type {Effect} */ + reaction + ); + } + } + } +} +function depends_on(reaction, sources, checked) { + const depends = checked.get(reaction); + if (depends !== void 0) return depends; + if (reaction.deps !== null) { + for (const dep of reaction.deps) { + if (sources.includes(dep)) { + return true; + } + if ((dep.f & DERIVED) !== 0 && depends_on( + /** @type {Derived} */ + dep, + sources, + checked + )) { + checked.set( + /** @type {Derived} */ + dep, + true + ); + return true; + } + } + } + checked.set(reaction, false); + return false; +} +function schedule_effect(signal) { + var effect = last_scheduled_effect = signal; + while (effect.parent !== null) { + effect = effect.parent; + var flags2 = effect.f; + if (is_flushing && effect === active_effect && (flags2 & BLOCK_EFFECT) !== 0 && (flags2 & HEAD_EFFECT) === 0) { + return; + } + if ((flags2 & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) { + if ((flags2 & CLEAN) === 0) return; + effect.f ^= CLEAN; + } + } + queued_root_effects.push(effect); +} +function createSubscriber(start) { + let subscribers = 0; + let version = source(0); + let stop; + return () => { + if (effect_tracking()) { + get(version); + render_effect(() => { + if (subscribers === 0) { + stop = untrack(() => start(() => increment(version))); + } + subscribers += 1; + return () => { + queue_micro_task(() => { + subscribers -= 1; + if (subscribers === 0) { + stop?.(); + stop = void 0; + increment(version); + } + }); + }; + }); + } + }; +} +var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT; +function boundary(node, props, children) { + new Boundary(node, props, children); +} +class Boundary { + /** @type {Boundary | null} */ + parent; + is_pending = false; + /** @type {TemplateNode} */ + #anchor; + /** @type {TemplateNode | null} */ + #hydrate_open = hydrating ? hydrate_node : null; + /** @type {BoundaryProps} */ + #props; + /** @type {((anchor: Node) => void)} */ + #children; + /** @type {Effect} */ + #effect; + /** @type {Effect | null} */ + #main_effect = null; + /** @type {Effect | null} */ + #pending_effect = null; + /** @type {Effect | null} */ + #failed_effect = null; + /** @type {DocumentFragment | null} */ + #offscreen_fragment = null; + /** @type {TemplateNode | null} */ + #pending_anchor = null; + #local_pending_count = 0; + #pending_count = 0; + #is_creating_fallback = false; + /** @type {Set} */ + #dirty_effects = /* @__PURE__ */ new Set(); + /** @type {Set} */ + #maybe_dirty_effects = /* @__PURE__ */ new Set(); + /** + * A source containing the number of pending async deriveds/expressions. + * Only created if `$effect.pending()` is used inside the boundary, + * otherwise updating the source results in needless `Batch.ensure()` + * calls followed by no-op flushes + * @type {Source | null} + */ + #effect_pending = null; + #effect_pending_subscriber = createSubscriber(() => { + this.#effect_pending = source(this.#local_pending_count); + return () => { + this.#effect_pending = null; + }; + }); + /** + * @param {TemplateNode} node + * @param {BoundaryProps} props + * @param {((anchor: Node) => void)} children + */ + constructor(node, props, children) { + this.#anchor = node; + this.#props = props; + this.#children = children; + this.parent = /** @type {Effect} */ + active_effect.b; + this.is_pending = !!this.#props.pending; + this.#effect = block(() => { + active_effect.b = this; + if (hydrating) { + const comment = this.#hydrate_open; + hydrate_next(); + const server_rendered_pending = ( + /** @type {Comment} */ + comment.nodeType === COMMENT_NODE && /** @type {Comment} */ + comment.data === HYDRATION_START_ELSE + ); + if (server_rendered_pending) { + this.#hydrate_pending_content(); + } else { + this.#hydrate_resolved_content(); + if (this.#pending_count === 0) { + this.is_pending = false; + } + } + } else { + var anchor = this.#get_anchor(); + try { + this.#main_effect = branch(() => children(anchor)); + } catch (error) { + this.error(error); + } + if (this.#pending_count > 0) { + this.#show_pending_snippet(); + } else { + this.is_pending = false; + } + } + return () => { + this.#pending_anchor?.remove(); + }; + }, flags); + if (hydrating) { + this.#anchor = hydrate_node; + } + } + #hydrate_resolved_content() { + try { + this.#main_effect = branch(() => this.#children(this.#anchor)); + } catch (error) { + this.error(error); + } + } + #hydrate_pending_content() { + const pending = this.#props.pending; + if (!pending) { + return; + } + this.#pending_effect = branch(() => pending(this.#anchor)); + Batch.enqueue(() => { + var anchor = this.#get_anchor(); + this.#main_effect = this.#run(() => { + Batch.ensure(); + return branch(() => this.#children(anchor)); + }); + if (this.#pending_count > 0) { + this.#show_pending_snippet(); + } else { + pause_effect( + /** @type {Effect} */ + this.#pending_effect, + () => { + this.#pending_effect = null; + } + ); + this.is_pending = false; + } + }); + } + #get_anchor() { + var anchor = this.#anchor; + if (this.is_pending) { + this.#pending_anchor = create_text(); + this.#anchor.before(this.#pending_anchor); + anchor = this.#pending_anchor; + } + return anchor; + } + /** + * Defer an effect inside a pending boundary until the boundary resolves + * @param {Effect} effect + */ + defer_effect(effect) { + defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects); + } + /** + * Returns `false` if the effect exists inside a boundary whose pending snippet is shown + * @returns {boolean} + */ + is_rendered() { + return !this.is_pending && (!this.parent || this.parent.is_rendered()); + } + has_pending_snippet() { + return !!this.#props.pending; + } + /** + * @param {() => Effect | null} fn + */ + #run(fn) { + var previous_effect = active_effect; + var previous_reaction = active_reaction; + var previous_ctx = component_context; + set_active_effect(this.#effect); + set_active_reaction(this.#effect); + set_component_context(this.#effect.ctx); + try { + return fn(); + } catch (e) { + handle_error(e); + return null; + } finally { + set_active_effect(previous_effect); + set_active_reaction(previous_reaction); + set_component_context(previous_ctx); + } + } + #show_pending_snippet() { + const pending = ( + /** @type {(anchor: Node) => void} */ + this.#props.pending + ); + if (this.#main_effect !== null) { + this.#offscreen_fragment = document.createDocumentFragment(); + this.#offscreen_fragment.append( + /** @type {TemplateNode} */ + this.#pending_anchor + ); + move_effect(this.#main_effect, this.#offscreen_fragment); + } + if (this.#pending_effect === null) { + this.#pending_effect = branch(() => pending(this.#anchor)); + } + } + /** + * Updates the pending count associated with the currently visible pending snippet, + * if any, such that we can replace the snippet with content once work is done + * @param {1 | -1} d + */ + #update_pending_count(d) { + if (!this.has_pending_snippet()) { + if (this.parent) { + this.parent.#update_pending_count(d); + } + return; + } + this.#pending_count += d; + if (this.#pending_count === 0) { + this.is_pending = false; + for (const e of this.#dirty_effects) { + set_signal_status(e, DIRTY); + schedule_effect(e); + } + for (const e of this.#maybe_dirty_effects) { + set_signal_status(e, MAYBE_DIRTY); + schedule_effect(e); + } + this.#dirty_effects.clear(); + this.#maybe_dirty_effects.clear(); + if (this.#pending_effect) { + pause_effect(this.#pending_effect, () => { + this.#pending_effect = null; + }); + } + if (this.#offscreen_fragment) { + this.#anchor.before(this.#offscreen_fragment); + this.#offscreen_fragment = null; + } + } + } + /** + * Update the source that powers `$effect.pending()` inside this boundary, + * and controls when the current `pending` snippet (if any) is removed. + * Do not call from inside the class + * @param {1 | -1} d + */ + update_pending_count(d) { + this.#update_pending_count(d); + this.#local_pending_count += d; + if (this.#effect_pending) { + internal_set(this.#effect_pending, this.#local_pending_count); + } + } + get_effect_pending() { + this.#effect_pending_subscriber(); + return get( + /** @type {Source} */ + this.#effect_pending + ); + } + /** @param {unknown} error */ + error(error) { + var onerror = this.#props.onerror; + let failed = this.#props.failed; + if (this.#is_creating_fallback || !onerror && !failed) { + throw error; + } + if (this.#main_effect) { + destroy_effect(this.#main_effect); + this.#main_effect = null; + } + if (this.#pending_effect) { + destroy_effect(this.#pending_effect); + this.#pending_effect = null; + } + if (this.#failed_effect) { + destroy_effect(this.#failed_effect); + this.#failed_effect = null; + } + if (hydrating) { + set_hydrate_node( + /** @type {TemplateNode} */ + this.#hydrate_open + ); + next(); + set_hydrate_node(skip_nodes()); + } + var did_reset = false; + var calling_on_error = false; + const reset = () => { + if (did_reset) { + svelte_boundary_reset_noop(); + return; + } + did_reset = true; + if (calling_on_error) { + svelte_boundary_reset_onerror(); + } + Batch.ensure(); + this.#local_pending_count = 0; + if (this.#failed_effect !== null) { + pause_effect(this.#failed_effect, () => { + this.#failed_effect = null; + }); + } + this.is_pending = this.has_pending_snippet(); + this.#main_effect = this.#run(() => { + this.#is_creating_fallback = false; + return branch(() => this.#children(this.#anchor)); + }); + if (this.#pending_count > 0) { + this.#show_pending_snippet(); + } else { + this.is_pending = false; + } + }; + var previous_reaction = active_reaction; + try { + set_active_reaction(null); + calling_on_error = true; + onerror?.(error, reset); + calling_on_error = false; + } catch (error2) { + invoke_error_boundary(error2, this.#effect && this.#effect.parent); + } finally { + set_active_reaction(previous_reaction); + } + if (failed) { + queue_micro_task(() => { + this.#failed_effect = this.#run(() => { + Batch.ensure(); + this.#is_creating_fallback = true; + try { + return branch(() => { + failed( + this.#anchor, + () => error, + () => reset + ); + }); + } catch (error2) { + invoke_error_boundary( + error2, + /** @type {Effect} */ + this.#effect.parent + ); + return null; + } finally { + this.#is_creating_fallback = false; + } + }); + }); + } + } +} +function destroy_derived_effects(derived) { + var effects = derived.effects; + if (effects !== null) { + derived.effects = null; + for (var i = 0; i < effects.length; i += 1) { + destroy_effect( + /** @type {Effect} */ + effects[i] + ); + } + } +} +function get_derived_parent_effect(derived) { + var parent = derived.parent; + while (parent !== null) { + if ((parent.f & DERIVED) === 0) { + return (parent.f & DESTROYED) === 0 ? ( + /** @type {Effect} */ + parent + ) : null; + } + parent = parent.parent; + } + return null; +} +function execute_derived(derived) { + var value; + var prev_active_effect = active_effect; + set_active_effect(get_derived_parent_effect(derived)); + { + try { + derived.f &= ~WAS_MARKED; + destroy_derived_effects(derived); + value = update_reaction(derived); + } finally { + set_active_effect(prev_active_effect); + } + } + return value; +} +function update_derived(derived) { + var value = execute_derived(derived); + if (!derived.equals(value)) { + derived.wv = increment_write_version(); + if (!current_batch?.is_fork || derived.deps === null) { + derived.v = value; + if (derived.deps === null) { + set_signal_status(derived, CLEAN); + return; + } + } + } + if (is_destroying_effect) { + return; + } + if (batch_values !== null) { + if (effect_tracking() || current_batch?.is_fork) { + batch_values.set(derived, value); + } + } else { + update_derived_status(derived); + } +} +let eager_effects = /* @__PURE__ */ new Set(); +const old_values = /* @__PURE__ */ new Map(); +let eager_effects_deferred = false; +function source(v, stack) { + var signal = { + f: 0, + // TODO ideally we could skip this altogether, but it causes type errors + v, + reactions: null, + equals, + rv: 0, + wv: 0 + }; + return signal; +} +// @__NO_SIDE_EFFECTS__ +function state(v, stack) { + const s = source(v); + push_reaction_value(s); + return s; +} +// @__NO_SIDE_EFFECTS__ +function mutable_source(initial_value, immutable = false, trackable = true) { + const s = source(initial_value); + if (!immutable) { + s.equals = safe_equals; + } + return s; +} +function set(source2, value, should_proxy = false) { + if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check + // to ensure we error if state is set inside an inspect effect + (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && !current_sources?.includes(source2)) { + state_unsafe_mutation(); + } + let new_value = should_proxy ? proxy(value) : value; + return internal_set(source2, new_value); +} +function internal_set(source2, value) { + if (!source2.equals(value)) { + var old_value = source2.v; + if (is_destroying_effect) { + old_values.set(source2, value); + } else { + old_values.set(source2, old_value); + } + source2.v = value; + var batch = Batch.ensure(); + batch.capture(source2, old_value); + if ((source2.f & DERIVED) !== 0) { + const derived = ( + /** @type {Derived} */ + source2 + ); + if ((source2.f & DIRTY) !== 0) { + execute_derived(derived); + } + update_derived_status(derived); + } + source2.wv = increment_write_version(); + mark_reactions(source2, DIRTY); + if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) { + if (untracked_writes === null) { + set_untracked_writes([source2]); + } else { + untracked_writes.push(source2); + } + } + if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) { + flush_eager_effects(); + } + } + return value; +} +function flush_eager_effects() { + eager_effects_deferred = false; + var prev_is_updating_effect = is_updating_effect; + set_is_updating_effect(true); + const inspects = Array.from(eager_effects); + try { + for (const effect of inspects) { + if ((effect.f & CLEAN) !== 0) { + set_signal_status(effect, MAYBE_DIRTY); + } + if (is_dirty(effect)) { + update_effect(effect); + } + } + } finally { + set_is_updating_effect(prev_is_updating_effect); + } + eager_effects.clear(); +} +function increment(source2) { + set(source2, source2.v + 1); +} +function mark_reactions(signal, status) { + var reactions = signal.reactions; + if (reactions === null) return; + var length = reactions.length; + for (var i = 0; i < length; i++) { + var reaction = reactions[i]; + var flags2 = reaction.f; + var not_dirty = (flags2 & DIRTY) === 0; + if (not_dirty) { + set_signal_status(reaction, status); + } + if ((flags2 & DERIVED) !== 0) { + var derived = ( + /** @type {Derived} */ + reaction + ); + batch_values?.delete(derived); + if ((flags2 & WAS_MARKED) === 0) { + if (flags2 & CONNECTED) { + reaction.f |= WAS_MARKED; + } + mark_reactions(derived, MAYBE_DIRTY); + } + } else if (not_dirty) { + if ((flags2 & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) { + eager_block_effects.add( + /** @type {Effect} */ + reaction + ); + } + schedule_effect( + /** @type {Effect} */ + reaction + ); + } + } +} +function proxy(value) { + if (typeof value !== "object" || value === null || STATE_SYMBOL in value) { + return value; + } + const prototype = get_prototype_of(value); + if (prototype !== object_prototype && prototype !== array_prototype) { + return value; + } + var sources = /* @__PURE__ */ new Map(); + var is_proxied_array = is_array(value); + var version = /* @__PURE__ */ state(0); + var parent_version = update_version; + var with_parent = (fn) => { + if (update_version === parent_version) { + return fn(); + } + var reaction = active_reaction; + var version2 = update_version; + set_active_reaction(null); + set_update_version(parent_version); + var result = fn(); + set_active_reaction(reaction); + set_update_version(version2); + return result; + }; + if (is_proxied_array) { + sources.set("length", /* @__PURE__ */ state( + /** @type {any[]} */ + value.length + )); + } + return new Proxy( + /** @type {any} */ + value, + { + defineProperty(_, prop, descriptor) { + if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) { + state_descriptors_fixed(); + } + var s = sources.get(prop); + if (s === void 0) { + s = with_parent(() => { + var s2 = /* @__PURE__ */ state(descriptor.value); + sources.set(prop, s2); + return s2; + }); + } else { + set(s, descriptor.value, true); + } + return true; + }, + deleteProperty(target, prop) { + var s = sources.get(prop); + if (s === void 0) { + if (prop in target) { + const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED)); + sources.set(prop, s2); + increment(version); + } + } else { + set(s, UNINITIALIZED); + increment(version); + } + return true; + }, + get(target, prop, receiver) { + if (prop === STATE_SYMBOL) { + return value; + } + var s = sources.get(prop); + var exists = prop in target; + if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) { + s = with_parent(() => { + var p = proxy(exists ? target[prop] : UNINITIALIZED); + var s2 = /* @__PURE__ */ state(p); + return s2; + }); + sources.set(prop, s); + } + if (s !== void 0) { + var v = get(s); + return v === UNINITIALIZED ? void 0 : v; + } + return Reflect.get(target, prop, receiver); + }, + getOwnPropertyDescriptor(target, prop) { + var descriptor = Reflect.getOwnPropertyDescriptor(target, prop); + if (descriptor && "value" in descriptor) { + var s = sources.get(prop); + if (s) descriptor.value = get(s); + } else if (descriptor === void 0) { + var source2 = sources.get(prop); + var value2 = source2?.v; + if (source2 !== void 0 && value2 !== UNINITIALIZED) { + return { + enumerable: true, + configurable: true, + value: value2, + writable: true + }; + } + } + return descriptor; + }, + has(target, prop) { + if (prop === STATE_SYMBOL) { + return true; + } + var s = sources.get(prop); + var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop); + if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) { + if (s === void 0) { + s = with_parent(() => { + var p = has ? proxy(target[prop]) : UNINITIALIZED; + var s2 = /* @__PURE__ */ state(p); + return s2; + }); + sources.set(prop, s); + } + var value2 = get(s); + if (value2 === UNINITIALIZED) { + return false; + } + } + return has; + }, + set(target, prop, value2, receiver) { + var s = sources.get(prop); + var has = prop in target; + if (is_proxied_array && prop === "length") { + for (var i = value2; i < /** @type {Source} */ + s.v; i += 1) { + var other_s = sources.get(i + ""); + if (other_s !== void 0) { + set(other_s, UNINITIALIZED); + } else if (i in target) { + other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED)); + sources.set(i + "", other_s); + } + } + } + if (s === void 0) { + if (!has || get_descriptor(target, prop)?.writable) { + s = with_parent(() => /* @__PURE__ */ state(void 0)); + set(s, proxy(value2)); + sources.set(prop, s); + } + } else { + has = s.v !== UNINITIALIZED; + var p = with_parent(() => proxy(value2)); + set(s, p); + } + var descriptor = Reflect.getOwnPropertyDescriptor(target, prop); + if (descriptor?.set) { + descriptor.set.call(receiver, value2); + } + if (!has) { + if (is_proxied_array && typeof prop === "string") { + var ls = ( + /** @type {Source} */ + sources.get("length") + ); + var n = Number(prop); + if (Number.isInteger(n) && n >= ls.v) { + set(ls, n + 1); + } + } + increment(version); + } + return true; + }, + ownKeys(target) { + get(version); + var own_keys = Reflect.ownKeys(target).filter((key2) => { + var source3 = sources.get(key2); + return source3 === void 0 || source3.v !== UNINITIALIZED; + }); + for (var [key, source2] of sources) { + if (source2.v !== UNINITIALIZED && !(key in target)) { + own_keys.push(key); + } + } + return own_keys; + }, + setPrototypeOf() { + state_prototype_fixed(); + } + } + ); +} +var $window; +var first_child_getter; +var next_sibling_getter; +function init_operations() { + if ($window !== void 0) { + return; + } + $window = window; + var element_prototype = Element.prototype; + var node_prototype = Node.prototype; + var text_prototype = Text.prototype; + first_child_getter = get_descriptor(node_prototype, "firstChild").get; + next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get; + if (is_extensible(element_prototype)) { + element_prototype.__click = void 0; + element_prototype.__className = void 0; + element_prototype.__attributes = null; + element_prototype.__style = void 0; + element_prototype.__e = void 0; + } + if (is_extensible(text_prototype)) { + text_prototype.__t = void 0; + } +} +function create_text(value = "") { + return document.createTextNode(value); +} +// @__NO_SIDE_EFFECTS__ +function get_first_child(node) { + return ( + /** @type {TemplateNode | null} */ + first_child_getter.call(node) + ); +} +// @__NO_SIDE_EFFECTS__ +function get_next_sibling(node) { + return ( + /** @type {TemplateNode | null} */ + next_sibling_getter.call(node) + ); +} +function clear_text_content(node) { + node.textContent = ""; +} +function without_reactive_context(fn) { + var previous_reaction = active_reaction; + var previous_effect = active_effect; + set_active_reaction(null); + set_active_effect(null); + try { + return fn(); + } finally { + set_active_reaction(previous_reaction); + set_active_effect(previous_effect); + } +} +function push_effect(effect, parent_effect) { + var parent_last = parent_effect.last; + if (parent_last === null) { + parent_effect.last = parent_effect.first = effect; + } else { + parent_last.next = effect; + effect.prev = parent_last; + parent_effect.last = effect; + } +} +function create_effect(type, fn, sync) { + var parent = active_effect; + if (parent !== null && (parent.f & INERT) !== 0) { + type |= INERT; + } + var effect = { + ctx: component_context, + deps: null, + nodes: null, + f: type | DIRTY | CONNECTED, + first: null, + fn, + last: null, + next: null, + parent, + b: parent && parent.b, + prev: null, + teardown: null, + wv: 0, + ac: null + }; + if (sync) { + try { + update_effect(effect); + effect.f |= EFFECT_RAN; + } catch (e2) { + destroy_effect(effect); + throw e2; + } + } else if (fn !== null) { + schedule_effect(effect); + } + var e = effect; + if (sync && e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child + (e.f & EFFECT_PRESERVED) === 0) { + e = e.first; + if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) { + e.f |= EFFECT_TRANSPARENT; + } + } + if (e !== null) { + e.parent = parent; + if (parent !== null) { + push_effect(e, parent); + } + if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) { + var derived = ( + /** @type {Derived} */ + active_reaction + ); + (derived.effects ??= []).push(e); + } + } + return effect; +} +function effect_tracking() { + return active_reaction !== null && !untracking; +} +function create_user_effect(fn) { + return create_effect(EFFECT | USER_EFFECT, fn, false); +} +function component_root(fn) { + Batch.ensure(); + const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn, true); + return (options2 = {}) => { + return new Promise((fulfil) => { + if (options2.outro) { + pause_effect(effect, () => { + destroy_effect(effect); + fulfil(void 0); + }); + } else { + destroy_effect(effect); + fulfil(void 0); + } + }); + }; +} +function render_effect(fn, flags2 = 0) { + return create_effect(RENDER_EFFECT | flags2, fn, true); +} +function block(fn, flags2 = 0) { + var effect = create_effect(BLOCK_EFFECT | flags2, fn, true); + return effect; +} +function branch(fn) { + return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn, true); +} +function execute_effect_teardown(effect) { + var teardown = effect.teardown; + if (teardown !== null) { + const previously_destroying_effect = is_destroying_effect; + const previous_reaction = active_reaction; + set_is_destroying_effect(true); + set_active_reaction(null); + try { + teardown.call(null); + } finally { + set_is_destroying_effect(previously_destroying_effect); + set_active_reaction(previous_reaction); + } + } +} +function destroy_effect_children(signal, remove_dom = false) { + var effect = signal.first; + signal.first = signal.last = null; + while (effect !== null) { + const controller = effect.ac; + if (controller !== null) { + without_reactive_context(() => { + controller.abort(STALE_REACTION); + }); + } + var next2 = effect.next; + if ((effect.f & ROOT_EFFECT) !== 0) { + effect.parent = null; + } else { + destroy_effect(effect, remove_dom); + } + effect = next2; + } +} +function destroy_block_effect_children(signal) { + var effect = signal.first; + while (effect !== null) { + var next2 = effect.next; + if ((effect.f & BRANCH_EFFECT) === 0) { + destroy_effect(effect); + } + effect = next2; + } +} +function destroy_effect(effect, remove_dom = true) { + var removed = false; + if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) { + remove_effect_dom( + effect.nodes.start, + /** @type {TemplateNode} */ + effect.nodes.end + ); + removed = true; + } + destroy_effect_children(effect, remove_dom && !removed); + remove_reactions(effect, 0); + set_signal_status(effect, DESTROYED); + var transitions = effect.nodes && effect.nodes.t; + if (transitions !== null) { + for (const transition of transitions) { + transition.stop(); + } + } + execute_effect_teardown(effect); + var parent = effect.parent; + if (parent !== null && parent.first !== null) { + unlink_effect(effect); + } + effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = null; +} +function remove_effect_dom(node, end) { + while (node !== null) { + var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node); + node.remove(); + node = next2; + } +} +function unlink_effect(effect) { + var parent = effect.parent; + var prev = effect.prev; + var next2 = effect.next; + if (prev !== null) prev.next = next2; + if (next2 !== null) next2.prev = prev; + if (parent !== null) { + if (parent.first === effect) parent.first = next2; + if (parent.last === effect) parent.last = prev; + } +} +function pause_effect(effect, callback, destroy = true) { + var transitions = []; + pause_children(effect, transitions, true); + var fn = () => { + if (destroy) destroy_effect(effect); + if (callback) callback(); + }; + var remaining = transitions.length; + if (remaining > 0) { + var check = () => --remaining || fn(); + for (var transition of transitions) { + transition.out(check); + } + } else { + fn(); + } +} +function pause_children(effect, transitions, local) { + if ((effect.f & INERT) !== 0) return; + effect.f ^= INERT; + var t = effect.nodes && effect.nodes.t; + if (t !== null) { + for (const transition of t) { + if (transition.is_global || local) { + transitions.push(transition); + } + } + } + var child = effect.first; + while (child !== null) { + var sibling = child.next; + var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent, + // it means the parent block effect was pruned. In that case, + // transparency information was transferred to the branch effect. + (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0; + pause_children(child, transitions, transparent ? local : false); + child = sibling; + } +} +function move_effect(effect, fragment) { + if (!effect.nodes) return; + var node = effect.nodes.start; + var end = effect.nodes.end; + while (node !== null) { + var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node); + fragment.append(node); + node = next2; + } +} +let is_updating_effect = false; +function set_is_updating_effect(value) { + is_updating_effect = value; +} +let is_destroying_effect = false; +function set_is_destroying_effect(value) { + is_destroying_effect = value; +} +let active_reaction = null; +let untracking = false; +function set_active_reaction(reaction) { + active_reaction = reaction; +} +let active_effect = null; +function set_active_effect(effect) { + active_effect = effect; +} +let current_sources = null; +function push_reaction_value(value) { + if (active_reaction !== null && true) { + if (current_sources === null) { + current_sources = [value]; + } else { + current_sources.push(value); + } + } +} +let new_deps = null; +let skipped_deps = 0; +let untracked_writes = null; +function set_untracked_writes(value) { + untracked_writes = value; +} +let write_version = 1; +let read_version = 0; +let update_version = read_version; +function set_update_version(value) { + update_version = value; +} +function increment_write_version() { + return ++write_version; +} +function is_dirty(reaction) { + var flags2 = reaction.f; + if ((flags2 & DIRTY) !== 0) { + return true; + } + if (flags2 & DERIVED) { + reaction.f &= ~WAS_MARKED; + } + if ((flags2 & MAYBE_DIRTY) !== 0) { + var dependencies = ( + /** @type {Value[]} */ + reaction.deps + ); + var length = dependencies.length; + for (var i = 0; i < length; i++) { + var dependency = dependencies[i]; + if (is_dirty( + /** @type {Derived} */ + dependency + )) { + update_derived( + /** @type {Derived} */ + dependency + ); + } + if (dependency.wv > reaction.wv) { + return true; + } + } + if ((flags2 & CONNECTED) !== 0 && // During time traveling we don't want to reset the status so that + // traversal of the graph in the other batches still happens + batch_values === null) { + set_signal_status(reaction, CLEAN); + } + } + return false; +} +function schedule_possible_effect_self_invalidation(signal, effect, root2 = true) { + var reactions = signal.reactions; + if (reactions === null) return; + if (current_sources?.includes(signal)) { + return; + } + for (var i = 0; i < reactions.length; i++) { + var reaction = reactions[i]; + if ((reaction.f & DERIVED) !== 0) { + schedule_possible_effect_self_invalidation( + /** @type {Derived} */ + reaction, + effect, + false + ); + } else if (effect === reaction) { + if (root2) { + set_signal_status(reaction, DIRTY); + } else if ((reaction.f & CLEAN) !== 0) { + set_signal_status(reaction, MAYBE_DIRTY); + } + schedule_effect( + /** @type {Effect} */ + reaction + ); + } + } +} +function update_reaction(reaction) { + var previous_deps = new_deps; + var previous_skipped_deps = skipped_deps; + var previous_untracked_writes = untracked_writes; + var previous_reaction = active_reaction; + var previous_sources = current_sources; + var previous_component_context = component_context; + var previous_untracking = untracking; + var previous_update_version = update_version; + var flags2 = reaction.f; + new_deps = /** @type {null | Value[]} */ + null; + skipped_deps = 0; + untracked_writes = null; + active_reaction = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null; + current_sources = null; + set_component_context(reaction.ctx); + untracking = false; + update_version = ++read_version; + if (reaction.ac !== null) { + without_reactive_context(() => { + reaction.ac.abort(STALE_REACTION); + }); + reaction.ac = null; + } + try { + reaction.f |= REACTION_IS_UPDATING; + var fn = ( + /** @type {Function} */ + reaction.fn + ); + var result = fn(); + var deps = reaction.deps; + if (new_deps !== null) { + var i; + remove_reactions(reaction, skipped_deps); + if (deps !== null && skipped_deps > 0) { + deps.length = skipped_deps + new_deps.length; + for (i = 0; i < new_deps.length; i++) { + deps[skipped_deps + i] = new_deps[i]; + } + } else { + reaction.deps = deps = new_deps; + } + if (effect_tracking() && (reaction.f & CONNECTED) !== 0) { + for (i = skipped_deps; i < deps.length; i++) { + (deps[i].reactions ??= []).push(reaction); + } + } + } else if (deps !== null && skipped_deps < deps.length) { + remove_reactions(reaction, skipped_deps); + deps.length = skipped_deps; + } + if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) { + for (i = 0; i < /** @type {Source[]} */ + untracked_writes.length; i++) { + schedule_possible_effect_self_invalidation( + untracked_writes[i], + /** @type {Effect} */ + reaction + ); + } + } + if (previous_reaction !== null && previous_reaction !== reaction) { + read_version++; + if (untracked_writes !== null) { + if (previous_untracked_writes === null) { + previous_untracked_writes = untracked_writes; + } else { + previous_untracked_writes.push(.../** @type {Source[]} */ + untracked_writes); + } + } + } + if ((reaction.f & ERROR_VALUE) !== 0) { + reaction.f ^= ERROR_VALUE; + } + return result; + } catch (error) { + return handle_error(error); + } finally { + reaction.f ^= REACTION_IS_UPDATING; + new_deps = previous_deps; + skipped_deps = previous_skipped_deps; + untracked_writes = previous_untracked_writes; + active_reaction = previous_reaction; + current_sources = previous_sources; + set_component_context(previous_component_context); + untracking = previous_untracking; + update_version = previous_update_version; + } +} +function remove_reaction(signal, dependency) { + let reactions = dependency.reactions; + if (reactions !== null) { + var index = index_of.call(reactions, signal); + if (index !== -1) { + var new_length = reactions.length - 1; + if (new_length === 0) { + reactions = dependency.reactions = null; + } else { + reactions[index] = reactions[new_length]; + reactions.pop(); + } + } + } + if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear + // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps` + // allows us to skip the expensive work of disconnecting and immediately reconnecting it + (new_deps === null || !new_deps.includes(dependency))) { + var derived = ( + /** @type {Derived} */ + dependency + ); + if ((derived.f & CONNECTED) !== 0) { + derived.f ^= CONNECTED; + derived.f &= ~WAS_MARKED; + } + update_derived_status(derived); + destroy_derived_effects(derived); + remove_reactions(derived, 0); + } +} +function remove_reactions(signal, start_index) { + var dependencies = signal.deps; + if (dependencies === null) return; + for (var i = start_index; i < dependencies.length; i++) { + remove_reaction(signal, dependencies[i]); + } +} +function update_effect(effect) { + var flags2 = effect.f; + if ((flags2 & DESTROYED) !== 0) { + return; + } + set_signal_status(effect, CLEAN); + var previous_effect = active_effect; + var was_updating_effect = is_updating_effect; + active_effect = effect; + is_updating_effect = true; + try { + if ((flags2 & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) { + destroy_block_effect_children(effect); + } else { + destroy_effect_children(effect); + } + execute_effect_teardown(effect); + var teardown = update_reaction(effect); + effect.teardown = typeof teardown === "function" ? teardown : null; + effect.wv = write_version; + var dep; + if (BROWSER && tracing_mode_flag && (effect.f & DIRTY) !== 0 && effect.deps !== null) ; + } finally { + is_updating_effect = was_updating_effect; + active_effect = previous_effect; + } +} +function get(signal) { + var flags2 = signal.f; + var is_derived = (flags2 & DERIVED) !== 0; + if (active_reaction !== null && !untracking) { + var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0; + if (!destroyed && !current_sources?.includes(signal)) { + var deps = active_reaction.deps; + if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) { + if (signal.rv < read_version) { + signal.rv = read_version; + if (new_deps === null && deps !== null && deps[skipped_deps] === signal) { + skipped_deps++; + } else if (new_deps === null) { + new_deps = [signal]; + } else if (!new_deps.includes(signal)) { + new_deps.push(signal); + } + } + } else { + (active_reaction.deps ??= []).push(signal); + var reactions = signal.reactions; + if (reactions === null) { + signal.reactions = [active_reaction]; + } else if (!reactions.includes(active_reaction)) { + reactions.push(active_reaction); + } + } + } + } + if (is_destroying_effect && old_values.has(signal)) { + return old_values.get(signal); + } + if (is_derived) { + var derived = ( + /** @type {Derived} */ + signal + ); + if (is_destroying_effect) { + var value = derived.v; + if ((derived.f & CLEAN) === 0 && derived.reactions !== null || depends_on_old_values(derived)) { + value = execute_derived(derived); + } + old_values.set(derived, value); + return value; + } + var should_connect = (derived.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0); + var is_new = derived.deps === null; + if (is_dirty(derived)) { + if (should_connect) { + derived.f |= CONNECTED; + } + update_derived(derived); + } + if (should_connect && !is_new) { + reconnect(derived); + } + } + if (batch_values?.has(signal)) { + return batch_values.get(signal); + } + if ((signal.f & ERROR_VALUE) !== 0) { + throw signal.v; + } + return signal.v; +} +function reconnect(derived) { + if (derived.deps === null) return; + derived.f |= CONNECTED; + for (const dep of derived.deps) { + (dep.reactions ??= []).push(derived); + if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) { + reconnect( + /** @type {Derived} */ + dep + ); + } + } +} +function depends_on_old_values(derived) { + if (derived.v === UNINITIALIZED) return true; + if (derived.deps === null) return false; + for (const dep of derived.deps) { + if (old_values.has(dep)) { + return true; + } + if ((dep.f & DERIVED) !== 0 && depends_on_old_values( + /** @type {Derived} */ + dep + )) { + return true; + } + } + return false; +} +function untrack(fn) { + var previous_untracking = untracking; + try { + untracking = true; + return fn(); + } finally { + untracking = previous_untracking; + } +} +const all_registered_events = /* @__PURE__ */ new Set(); +const root_event_handles = /* @__PURE__ */ new Set(); +let last_propagated_event = null; +function handle_event_propagation(event) { + var handler_element = this; + var owner_document = ( + /** @type {Node} */ + handler_element.ownerDocument + ); + var event_name = event.type; + var path = event.composedPath?.() || []; + var current_target = ( + /** @type {null | Element} */ + path[0] || event.target + ); + last_propagated_event = event; + var path_idx = 0; + var handled_at = last_propagated_event === event && event.__root; + if (handled_at) { + var at_idx = path.indexOf(handled_at); + if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */ + window)) { + event.__root = handler_element; + return; + } + var handler_idx = path.indexOf(handler_element); + if (handler_idx === -1) { + return; + } + if (at_idx <= handler_idx) { + path_idx = at_idx; + } + } + current_target = /** @type {Element} */ + path[path_idx] || event.target; + if (current_target === handler_element) return; + define_property(event, "currentTarget", { + configurable: true, + get() { + return current_target || owner_document; + } + }); + var previous_reaction = active_reaction; + var previous_effect = active_effect; + set_active_reaction(null); + set_active_effect(null); + try { + var throw_error; + var other_errors = []; + while (current_target !== null) { + var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */ + current_target.host || null; + try { + var delegated = current_target["__" + event_name]; + if (delegated != null && (!/** @type {any} */ + current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well + // -> the target could not have been disabled because it emits the event in the first place + event.target === current_target)) { + delegated.call(current_target, event); + } + } catch (error) { + if (throw_error) { + other_errors.push(error); + } else { + throw_error = error; + } + } + if (event.cancelBubble || parent_element === handler_element || parent_element === null) { + break; + } + current_target = parent_element; + } + if (throw_error) { + for (let error of other_errors) { + queueMicrotask(() => { + throw error; + }); + } + throw throw_error; + } + } finally { + event.__root = handler_element; + delete event.currentTarget; + set_active_reaction(previous_reaction); + set_active_effect(previous_effect); + } +} +function assign_nodes(start, end) { + var effect = ( + /** @type {Effect} */ + active_effect + ); + if (effect.nodes === null) { + effect.nodes = { start, end, a: null, t: null }; + } +} +function mount(component, options2) { + return _mount(component, options2); +} +function hydrate(component, options2) { + init_operations(); + options2.intro = options2.intro ?? false; + const target = options2.target; + const was_hydrating = hydrating; + const previous_hydrate_node = hydrate_node; + try { + var anchor = /* @__PURE__ */ get_first_child(target); + while (anchor && (anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */ + anchor.data !== HYDRATION_START)) { + anchor = /* @__PURE__ */ get_next_sibling(anchor); + } + if (!anchor) { + throw HYDRATION_ERROR; + } + set_hydrating(true); + set_hydrate_node( + /** @type {Comment} */ + anchor + ); + const instance = _mount(component, { ...options2, anchor }); + set_hydrating(false); + return ( + /** @type {Exports} */ + instance + ); + } catch (error) { + if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) { + throw error; + } + if (error !== HYDRATION_ERROR) { + console.warn("Failed to hydrate: ", error); + } + if (options2.recover === false) { + hydration_failed(); + } + init_operations(); + clear_text_content(target); + set_hydrating(false); + return mount(component, options2); + } finally { + set_hydrating(was_hydrating); + set_hydrate_node(previous_hydrate_node); + } +} +const document_listeners = /* @__PURE__ */ new Map(); +function _mount(Component, { target, anchor, props = {}, events, context, intro = true }) { + init_operations(); + var registered_events = /* @__PURE__ */ new Set(); + var event_handle = (events2) => { + for (var i = 0; i < events2.length; i++) { + var event_name = events2[i]; + if (registered_events.has(event_name)) continue; + registered_events.add(event_name); + var passive = is_passive_event(event_name); + target.addEventListener(event_name, handle_event_propagation, { passive }); + var n = document_listeners.get(event_name); + if (n === void 0) { + document.addEventListener(event_name, handle_event_propagation, { passive }); + document_listeners.set(event_name, 1); + } else { + document_listeners.set(event_name, n + 1); + } + } + }; + event_handle(array_from(all_registered_events)); + root_event_handles.add(event_handle); + var component = void 0; + var unmount2 = component_root(() => { + var anchor_node = anchor ?? target.appendChild(create_text()); + boundary( + /** @type {TemplateNode} */ + anchor_node, + { + pending: () => { + } + }, + (anchor_node2) => { + if (context) { + push({}); + var ctx = ( + /** @type {ComponentContext} */ + component_context + ); + ctx.c = context; + } + if (events) { + props.$$events = events; + } + if (hydrating) { + assign_nodes( + /** @type {TemplateNode} */ + anchor_node2, + null + ); + } + component = Component(anchor_node2, props) || {}; + if (hydrating) { + active_effect.nodes.end = hydrate_node; + if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */ + hydrate_node.data !== HYDRATION_END) { + hydration_mismatch(); + throw HYDRATION_ERROR; + } + } + if (context) { + pop(); + } + } + ); + return () => { + for (var event_name of registered_events) { + target.removeEventListener(event_name, handle_event_propagation); + var n = ( + /** @type {number} */ + document_listeners.get(event_name) + ); + if (--n === 0) { + document.removeEventListener(event_name, handle_event_propagation); + document_listeners.delete(event_name); + } else { + document_listeners.set(event_name, n); + } + } + root_event_handles.delete(event_handle); + if (anchor_node !== anchor) { + anchor_node.parentNode?.removeChild(anchor_node); + } + }; + }); + mounted_components.set(component, unmount2); + return component; +} +let mounted_components = /* @__PURE__ */ new WeakMap(); +function unmount(component, options2) { + const fn = mounted_components.get(component); + if (fn) { + mounted_components.delete(component); + return fn(options2); + } + return Promise.resolve(); +} +function asClassComponent$1(component) { + return class extends Svelte4Component { + /** @param {any} options */ + constructor(options2) { + super({ + component, + ...options2 + }); + } + }; +} +class Svelte4Component { + /** @type {any} */ + #events; + /** @type {Record} */ + #instance; + /** + * @param {ComponentConstructorOptions & { + * component: any; + * }} options + */ + constructor(options2) { + var sources = /* @__PURE__ */ new Map(); + var add_source = (key, value) => { + var s = /* @__PURE__ */ mutable_source(value, false, false); + sources.set(key, s); + return s; + }; + const props = new Proxy( + { ...options2.props || {}, $$events: {} }, + { + get(target, prop) { + return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop))); + }, + has(target, prop) { + if (prop === LEGACY_PROPS) return true; + get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop))); + return Reflect.has(target, prop); + }, + set(target, prop, value) { + set(sources.get(prop) ?? add_source(prop, value), value); + return Reflect.set(target, prop, value); + } + } + ); + this.#instance = (options2.hydrate ? hydrate : mount)(options2.component, { + target: options2.target, + anchor: options2.anchor, + props, + context: options2.context, + intro: options2.intro ?? false, + recover: options2.recover + }); + if (!options2?.props?.$$host || options2.sync === false) { + flushSync(); + } + this.#events = props.$$events; + for (const key of Object.keys(this.#instance)) { + if (key === "$set" || key === "$destroy" || key === "$on") continue; + define_property(this, key, { + get() { + return this.#instance[key]; + }, + /** @param {any} value */ + set(value) { + this.#instance[key] = value; + }, + enumerable: true + }); + } + this.#instance.$set = /** @param {Record} next */ + (next2) => { + Object.assign(props, next2); + }; + this.#instance.$destroy = () => { + unmount(this.#instance); + }; + } + /** @param {Record} props */ + $set(props) { + this.#instance.$set(props); + } + /** + * @param {string} event + * @param {(...args: any[]) => any} callback + * @returns {any} + */ + $on(event, callback) { + this.#events[event] = this.#events[event] || []; + const cb = (...args) => callback.call(this, ...args); + this.#events[event].push(cb); + return () => { + this.#events[event] = this.#events[event].filter( + /** @param {any} fn */ + (fn) => fn !== cb + ); + }; + } + $destroy() { + this.#instance.$destroy(); + } +} +let read_implementation = null; +function set_read_implementation(fn) { + read_implementation = fn; +} +function set_manifest(_) { +} +function asClassComponent(component) { + const component_constructor = asClassComponent$1(component); + const _render = (props, { context, csp } = {}) => { + const result = render(component, { props, context, csp }); + const munged = Object.defineProperties( + /** @type {LegacyRenderResult & PromiseLike} */ + {}, + { + css: { + value: { code: "", map: null } + }, + head: { + get: () => result.head + }, + html: { + get: () => result.body + }, + then: { + /** + * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function. + * + * @template TResult1 + * @template [TResult2=never] + * @param { (value: LegacyRenderResult) => TResult1 } onfulfilled + * @param { (reason: unknown) => TResult2 } onrejected + */ + value: (onfulfilled, onrejected) => { + { + const user_result = onfulfilled({ + css: munged.css, + head: munged.head, + html: munged.html + }); + return Promise.resolve(user_result); + } + } + } + } + ); + return munged; + }; + component_constructor.render = _render; + return component_constructor; +} +function Root($$renderer, $$props) { + $$renderer.component(($$renderer2) => { + let { + stores, + page, + constructors, + components = [], + form, + data_0 = null, + data_1 = null + } = $$props; + { + setContext("__svelte__", stores); + } + { + stores.page.set(page); + } + const Pyramid_1 = constructors[1]; + if (constructors[1]) { + $$renderer2.push(""); + const Pyramid_0 = constructors[0]; + $$renderer2.push(``); + Pyramid_0($$renderer2, { + data: data_0, + form, + params: page.params, + children: ($$renderer3) => { + $$renderer3.push(``); + Pyramid_1($$renderer3, { data: data_1, form, params: page.params }); + $$renderer3.push(``); + }, + $$slots: { default: true } + }); + $$renderer2.push(``); + } else { + $$renderer2.push(""); + const Pyramid_0 = constructors[0]; + $$renderer2.push(``); + Pyramid_0($$renderer2, { data: data_0, form, params: page.params }); + $$renderer2.push(``); + } + $$renderer2.push(` `); + { + $$renderer2.push(""); + } + $$renderer2.push(``); + }); +} +const root = asClassComponent(Root); +const options = { + app_template_contains_nonce: false, + async: false, + csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false }, "reportOnly": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } }, + csrf_check_origin: true, + csrf_trusted_origins: [], + embedded: false, + env_public_prefix: "PUBLIC_", + env_private_prefix: "", + hash_routing: false, + hooks: null, + // added lazily, via `get_hooks` + preload_strategy: "modulepreload", + root, + service_worker: false, + service_worker_options: void 0, + templates: { + app: ({ head, body, assets, nonce, env }) => '\n\n \n \n \n Mode Template\n ' + head + '\n \n \n
' + body + "
\n \n\n", + error: ({ status, message }) => '\n\n \n \n ' + message + ` + + + + +
+ ` + status + '\n
\n

' + message + "

\n
\n
\n \n\n" + }, + version_hash: "1u12ak4" +}; +async function get_hooks() { + let handle; + let handleFetch; + let handleError; + let handleValidationError; + let init; + let reroute; + let transport; + return { + handle, + handleFetch, + handleError, + handleValidationError, + init, + reroute, + transport + }; +} +export { + set_public_env as a, + set_read_implementation as b, + set_manifest as c, + get_hooks as g, + options as o, + public_env as p, + read_implementation as r, + set_private_env as s +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/shared.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/shared.js new file mode 100644 index 0000000..be2c743 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/shared.js @@ -0,0 +1,542 @@ +import * as devalue from "devalue"; +import { t as text_decoder, b as base64_encode, c as base64_decode } from "./utils.js"; +import { SvelteKitError } from "@sveltejs/kit/internal"; +function set_nested_value(object, path_string, value) { + if (path_string.startsWith("n:")) { + path_string = path_string.slice(2); + value = value === "" ? void 0 : parseFloat(value); + } else if (path_string.startsWith("b:")) { + path_string = path_string.slice(2); + value = value === "on"; + } + deep_set(object, split_path(path_string), value); +} +function convert_formdata(data) { + const result = {}; + for (let key of data.keys()) { + const is_array = key.endsWith("[]"); + let values = data.getAll(key); + if (is_array) key = key.slice(0, -2); + if (values.length > 1 && !is_array) { + throw new Error(`Form cannot contain duplicated keys — "${key}" has ${values.length} values`); + } + values = values.filter( + (entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0 + ); + if (key.startsWith("n:")) { + key = key.slice(2); + values = values.map((v) => v === "" ? void 0 : parseFloat( + /** @type {string} */ + v + )); + } else if (key.startsWith("b:")) { + key = key.slice(2); + values = values.map((v) => v === "on"); + } + set_nested_value(result, key, is_array ? values : values[0]); + } + return result; +} +const BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata"; +const BINARY_FORM_VERSION = 0; +const HEADER_BYTES = 1 + 4 + 2; +async function deserialize_binary_form(request) { + if (request.headers.get("content-type") !== BINARY_FORM_CONTENT_TYPE) { + const form_data = await request.formData(); + return { data: convert_formdata(form_data), meta: {}, form_data }; + } + if (!request.body) { + throw deserialize_error("no body"); + } + const content_length = parseInt(request.headers.get("content-length") ?? ""); + if (Number.isNaN(content_length)) { + throw deserialize_error("invalid Content-Length header"); + } + const reader = request.body.getReader(); + const chunks = []; + function get_chunk(index) { + if (index in chunks) return chunks[index]; + let i = chunks.length; + while (i <= index) { + chunks[i] = reader.read().then((chunk) => chunk.value); + i++; + } + return chunks[index]; + } + async function get_buffer(offset, length) { + let start_chunk; + let chunk_start = 0; + let chunk_index; + for (chunk_index = 0; ; chunk_index++) { + const chunk = await get_chunk(chunk_index); + if (!chunk) return null; + const chunk_end = chunk_start + chunk.byteLength; + if (offset >= chunk_start && offset < chunk_end) { + start_chunk = chunk; + break; + } + chunk_start = chunk_end; + } + if (offset + length <= chunk_start + start_chunk.byteLength) { + return start_chunk.subarray(offset - chunk_start, offset + length - chunk_start); + } + const chunks2 = [start_chunk.subarray(offset - chunk_start)]; + let cursor = start_chunk.byteLength - offset + chunk_start; + while (cursor < length) { + chunk_index++; + let chunk = await get_chunk(chunk_index); + if (!chunk) return null; + if (chunk.byteLength > length - cursor) { + chunk = chunk.subarray(0, length - cursor); + } + chunks2.push(chunk); + cursor += chunk.byteLength; + } + const buffer = new Uint8Array(length); + cursor = 0; + for (const chunk of chunks2) { + buffer.set(chunk, cursor); + cursor += chunk.byteLength; + } + return buffer; + } + const header = await get_buffer(0, HEADER_BYTES); + if (!header) throw deserialize_error("too short"); + if (header[0] !== BINARY_FORM_VERSION) { + throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`); + } + const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength); + const data_length = header_view.getUint32(1, true); + if (HEADER_BYTES + data_length > content_length) { + throw deserialize_error("data overflow"); + } + const file_offsets_length = header_view.getUint16(5, true); + if (HEADER_BYTES + data_length + file_offsets_length > content_length) { + throw deserialize_error("file offset table overflow"); + } + const data_buffer = await get_buffer(HEADER_BYTES, data_length); + if (!data_buffer) throw deserialize_error("data too short"); + let file_offsets; + let files_start_offset; + if (file_offsets_length > 0) { + const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length); + if (!file_offsets_buffer) throw deserialize_error("file offset table too short"); + file_offsets = /** @type {Array} */ + JSON.parse(text_decoder.decode(file_offsets_buffer)); + files_start_offset = HEADER_BYTES + data_length + file_offsets_length; + } + const [data, meta] = devalue.parse(text_decoder.decode(data_buffer), { + File: ([name, type, size, last_modified, index]) => { + if (files_start_offset + file_offsets[index] + size > content_length) { + throw deserialize_error("file data overflow"); + } + return new Proxy( + new LazyFile( + name, + type, + size, + last_modified, + get_chunk, + files_start_offset + file_offsets[index] + ), + { + getPrototypeOf() { + return File.prototype; + } + } + ); + } + }); + void (async () => { + let has_more = true; + while (has_more) { + const chunk = await get_chunk(chunks.length); + has_more = !!chunk; + } + })(); + return { data, meta, form_data: null }; +} +function deserialize_error(message) { + return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`); +} +class LazyFile { + /** @type {(index: number) => Promise | undefined>} */ + #get_chunk; + /** @type {number} */ + #offset; + /** + * @param {string} name + * @param {string} type + * @param {number} size + * @param {number} last_modified + * @param {(index: number) => Promise | undefined>} get_chunk + * @param {number} offset + */ + constructor(name, type, size, last_modified, get_chunk, offset) { + this.name = name; + this.type = type; + this.size = size; + this.lastModified = last_modified; + this.webkitRelativePath = ""; + this.#get_chunk = get_chunk; + this.#offset = offset; + this.arrayBuffer = this.arrayBuffer.bind(this); + this.bytes = this.bytes.bind(this); + this.slice = this.slice.bind(this); + this.stream = this.stream.bind(this); + this.text = this.text.bind(this); + } + /** @type {ArrayBuffer | undefined} */ + #buffer; + async arrayBuffer() { + this.#buffer ??= await new Response(this.stream()).arrayBuffer(); + return this.#buffer; + } + async bytes() { + return new Uint8Array(await this.arrayBuffer()); + } + /** + * @param {number=} start + * @param {number=} end + * @param {string=} contentType + */ + slice(start = 0, end = this.size, contentType = this.type) { + if (start < 0) { + start = Math.max(this.size + start, 0); + } else { + start = Math.min(start, this.size); + } + if (end < 0) { + end = Math.max(this.size + end, 0); + } else { + end = Math.min(end, this.size); + } + const size = Math.max(end - start, 0); + const file = new LazyFile( + this.name, + contentType, + size, + this.lastModified, + this.#get_chunk, + this.#offset + start + ); + return file; + } + stream() { + let cursor = 0; + let chunk_index = 0; + return new ReadableStream({ + start: async (controller) => { + let chunk_start = 0; + let start_chunk = null; + for (chunk_index = 0; ; chunk_index++) { + const chunk = await this.#get_chunk(chunk_index); + if (!chunk) return null; + const chunk_end = chunk_start + chunk.byteLength; + if (this.#offset >= chunk_start && this.#offset < chunk_end) { + start_chunk = chunk; + break; + } + chunk_start = chunk_end; + } + if (this.#offset + this.size <= chunk_start + start_chunk.byteLength) { + controller.enqueue( + start_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start) + ); + controller.close(); + } else { + controller.enqueue(start_chunk.subarray(this.#offset - chunk_start)); + cursor = start_chunk.byteLength - this.#offset + chunk_start; + } + }, + pull: async (controller) => { + chunk_index++; + let chunk = await this.#get_chunk(chunk_index); + if (!chunk) { + controller.error("incomplete file data"); + controller.close(); + return; + } + if (chunk.byteLength > this.size - cursor) { + chunk = chunk.subarray(0, this.size - cursor); + } + controller.enqueue(chunk); + cursor += chunk.byteLength; + if (cursor >= this.size) { + controller.close(); + } + } + }); + } + async text() { + return text_decoder.decode(await this.arrayBuffer()); + } +} +const path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/; +function split_path(path) { + if (!path_regex.test(path)) { + throw new Error(`Invalid path ${path}`); + } + return path.split(/\.|\[|\]/).filter(Boolean); +} +function check_prototype_pollution(key) { + if (key === "__proto__" || key === "constructor" || key === "prototype") { + throw new Error( + `Invalid key "${key}"` + ); + } +} +function deep_set(object, keys, value) { + let current = object; + for (let i = 0; i < keys.length - 1; i += 1) { + const key = keys[i]; + check_prototype_pollution(key); + const is_array = /^\d+$/.test(keys[i + 1]); + const exists = Object.hasOwn(current, key); + const inner = current[key]; + if (exists && is_array !== Array.isArray(inner)) { + throw new Error(`Invalid array key ${keys[i + 1]}`); + } + if (!exists) { + current[key] = is_array ? [] : {}; + } + current = current[key]; + } + const final_key = keys[keys.length - 1]; + check_prototype_pollution(final_key); + current[final_key] = value; +} +function normalize_issue(issue, server = false) { + const normalized = { name: "", path: [], message: issue.message, server }; + if (issue.path !== void 0) { + let name = ""; + for (const segment of issue.path) { + const key = ( + /** @type {string | number} */ + typeof segment === "object" ? segment.key : segment + ); + normalized.path.push(key); + if (typeof key === "number") { + name += `[${key}]`; + } else if (typeof key === "string") { + name += name === "" ? key : "." + key; + } + } + normalized.name = name; + } + return normalized; +} +function flatten_issues(issues) { + const result = {}; + for (const issue of issues) { + (result.$ ??= []).push(issue); + let name = ""; + if (issue.path !== void 0) { + for (const key of issue.path) { + if (typeof key === "number") { + name += `[${key}]`; + } else if (typeof key === "string") { + name += name === "" ? key : "." + key; + } + (result[name] ??= []).push(issue); + } + } + } + return result; +} +function deep_get(object, path) { + let current = object; + for (const key of path) { + if (current == null || typeof current !== "object") { + return current; + } + current = current[key]; + } + return current; +} +function create_field_proxy(target, get_input, set_input, get_issues, path = []) { + const get_value = () => { + return deep_get(get_input(), path); + }; + return new Proxy(target, { + get(target2, prop) { + if (typeof prop === "symbol") return target2[prop]; + if (/^\d+$/.test(prop)) { + return create_field_proxy({}, get_input, set_input, get_issues, [ + ...path, + parseInt(prop, 10) + ]); + } + const key = build_path_string(path); + if (prop === "set") { + const set_func = function(newValue) { + set_input(path, newValue); + return newValue; + }; + return create_field_proxy(set_func, get_input, set_input, get_issues, [...path, prop]); + } + if (prop === "value") { + return create_field_proxy(get_value, get_input, set_input, get_issues, [...path, prop]); + } + if (prop === "issues" || prop === "allIssues") { + const issues_func = () => { + const all_issues = get_issues()[key === "" ? "$" : key]; + if (prop === "allIssues") { + return all_issues?.map((issue) => ({ + path: issue.path, + message: issue.message + })); + } + return all_issues?.filter((issue) => issue.name === key)?.map((issue) => ({ + path: issue.path, + message: issue.message + })); + }; + return create_field_proxy(issues_func, get_input, set_input, get_issues, [...path, prop]); + } + if (prop === "as") { + const as_func = (type, input_value) => { + const is_array = type === "file multiple" || type === "select multiple" || type === "checkbox" && typeof input_value === "string"; + const prefix = type === "number" || type === "range" ? "n:" : type === "checkbox" && !is_array ? "b:" : ""; + const base_props = { + name: prefix + key + (is_array ? "[]" : ""), + get "aria-invalid"() { + const issues = get_issues(); + return key in issues ? "true" : void 0; + } + }; + if (type !== "text" && type !== "select" && type !== "select multiple") { + base_props.type = type === "file multiple" ? "file" : type; + } + if (type === "submit" || type === "hidden") { + return Object.defineProperties(base_props, { + value: { value: input_value, enumerable: true } + }); + } + if (type === "select" || type === "select multiple") { + return Object.defineProperties(base_props, { + multiple: { value: is_array, enumerable: true }, + value: { + enumerable: true, + get() { + return get_value(); + } + } + }); + } + if (type === "checkbox" || type === "radio") { + return Object.defineProperties(base_props, { + value: { value: input_value ?? "on", enumerable: true }, + checked: { + enumerable: true, + get() { + const value = get_value(); + if (type === "radio") { + return value === input_value; + } + if (is_array) { + return (value ?? []).includes(input_value); + } + return value; + } + } + }); + } + if (type === "file" || type === "file multiple") { + return Object.defineProperties(base_props, { + multiple: { value: is_array, enumerable: true }, + files: { + enumerable: true, + get() { + const value = get_value(); + if (value instanceof File) { + if (typeof DataTransfer !== "undefined") { + const fileList = new DataTransfer(); + fileList.items.add(value); + return fileList.files; + } + return { 0: value, length: 1 }; + } + if (Array.isArray(value) && value.every((f) => f instanceof File)) { + if (typeof DataTransfer !== "undefined") { + const fileList = new DataTransfer(); + value.forEach((file) => fileList.items.add(file)); + return fileList.files; + } + const fileListLike = { length: value.length }; + value.forEach((file, index) => { + fileListLike[index] = file; + }); + return fileListLike; + } + return null; + } + } + }); + } + return Object.defineProperties(base_props, { + value: { + enumerable: true, + get() { + const value = get_value(); + return value != null ? String(value) : ""; + } + } + }); + }; + return create_field_proxy(as_func, get_input, set_input, get_issues, [...path, "as"]); + } + return create_field_proxy({}, get_input, set_input, get_issues, [...path, prop]); + } + }); +} +function build_path_string(path) { + let result = ""; + for (const segment of path) { + if (typeof segment === "number") { + result += `[${segment}]`; + } else { + result += result === "" ? segment : "." + segment; + } + } + return result; +} +const INVALIDATED_PARAM = "x-sveltekit-invalidated"; +const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash"; +function stringify(data, transport) { + const encoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.encode])); + return devalue.stringify(data, encoders); +} +function stringify_remote_arg(value, transport) { + if (value === void 0) return ""; + const json_string = stringify(value, transport); + const bytes = new TextEncoder().encode(json_string); + return base64_encode(bytes).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_"); +} +function parse_remote_arg(string, transport) { + if (!string) return void 0; + const json_string = text_decoder.decode( + // no need to add back `=` characters, atob can handle it + base64_decode(string.replaceAll("-", "+").replaceAll("_", "/")) + ); + const decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode])); + return devalue.parse(json_string, decoders); +} +function create_remote_key(id, payload) { + return id + "/" + payload; +} +export { + BINARY_FORM_CONTENT_TYPE as B, + INVALIDATED_PARAM as I, + TRAILING_SLASH_PARAM as T, + stringify_remote_arg as a, + create_field_proxy as b, + create_remote_key as c, + deserialize_binary_form as d, + set_nested_value as e, + flatten_issues as f, + deep_set as g, + normalize_issue as n, + parse_remote_arg as p, + stringify as s +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/state.svelte.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/state.svelte.js new file mode 100644 index 0000000..185e89f --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/state.svelte.js @@ -0,0 +1,16 @@ +import "clsx"; +import { n as noop } from "./utils2.js"; +import "@sveltejs/kit/internal/server"; +const is_legacy = noop.toString().includes("$$") || /function \w+\(\) \{\}/.test(noop.toString()); +if (is_legacy) { + ({ + data: {}, + form: null, + error: null, + params: {}, + route: { id: null }, + state: {}, + status: -1, + url: new URL("https://example.com") + }); +} diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils.js new file mode 100644 index 0000000..78e5bde --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils.js @@ -0,0 +1,43 @@ +const text_encoder = new TextEncoder(); +const text_decoder = new TextDecoder(); +function get_relative_path(from, to) { + const from_parts = from.split(/[/\\]/); + const to_parts = to.split(/[/\\]/); + from_parts.pop(); + while (from_parts[0] === to_parts[0]) { + from_parts.shift(); + to_parts.shift(); + } + let i = from_parts.length; + while (i--) from_parts[i] = ".."; + return from_parts.concat(to_parts).join("/"); +} +function base64_encode(bytes) { + if (globalThis.Buffer) { + return globalThis.Buffer.from(bytes).toString("base64"); + } + let binary = ""; + for (let i = 0; i < bytes.length; i++) { + binary += String.fromCharCode(bytes[i]); + } + return btoa(binary); +} +function base64_decode(encoded) { + if (globalThis.Buffer) { + const buffer = globalThis.Buffer.from(encoded, "base64"); + return new Uint8Array(buffer); + } + const binary = atob(encoded); + const bytes = new Uint8Array(binary.length); + for (let i = 0; i < binary.length; i++) { + bytes[i] = binary.charCodeAt(i); + } + return bytes; +} +export { + text_encoder as a, + base64_encode as b, + base64_decode as c, + get_relative_path as g, + text_decoder as t +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils2.js b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils2.js new file mode 100644 index 0000000..de14a79 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/chunks/utils2.js @@ -0,0 +1,39 @@ +var is_array = Array.isArray; +var index_of = Array.prototype.indexOf; +var array_from = Array.from; +var define_property = Object.defineProperty; +var get_descriptor = Object.getOwnPropertyDescriptor; +var object_prototype = Object.prototype; +var array_prototype = Array.prototype; +var get_prototype_of = Object.getPrototypeOf; +var is_extensible = Object.isExtensible; +const noop = () => { +}; +function run_all(arr) { + for (var i = 0; i < arr.length; i++) { + arr[i](); + } +} +function deferred() { + var resolve; + var reject; + var promise = new Promise((res, rej) => { + resolve = res; + reject = rej; + }); + return { promise, resolve, reject }; +} +export { + array_prototype as a, + get_prototype_of as b, + is_extensible as c, + deferred as d, + index_of as e, + define_property as f, + get_descriptor as g, + array_from as h, + is_array as i, + noop as n, + object_prototype as o, + run_all as r +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/entries/fallbacks/error.svelte.js b/ModeTemplate/frontend/.svelte-kit/output/server/entries/fallbacks/error.svelte.js new file mode 100644 index 0000000..96096f6 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/entries/fallbacks/error.svelte.js @@ -0,0 +1,44 @@ +import { g as getContext, e as escape_html } from "../../chunks/context.js"; +import "clsx"; +import "../../chunks/state.svelte.js"; +import "@sveltejs/kit/internal"; +import "../../chunks/exports.js"; +import "../../chunks/utils.js"; +import { w as writable } from "../../chunks/index.js"; +import "@sveltejs/kit/internal/server"; +function create_updated_store() { + const { set, subscribe } = writable(false); + { + return { + subscribe, + // eslint-disable-next-line @typescript-eslint/require-await + check: async () => false + }; + } +} +const stores = { + updated: /* @__PURE__ */ create_updated_store() +}; +({ + check: stores.updated.check +}); +function context() { + return getContext("__request__"); +} +const page$1 = { + get error() { + return context().page.error; + }, + get status() { + return context().page.status; + } +}; +const page = page$1; +function Error$1($$renderer, $$props) { + $$renderer.component(($$renderer2) => { + $$renderer2.push(`

${escape_html(page.status)}

${escape_html(page.error?.message)}

`); + }); +} +export { + Error$1 as default +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_layout.svelte.js b/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_layout.svelte.js new file mode 100644 index 0000000..45a30c3 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_layout.svelte.js @@ -0,0 +1,25 @@ +import { w as head } from "../../chunks/index2.js"; +import { a as auth } from "../../chunks/auth.svelte.js"; +import { e as escape_html } from "../../chunks/context.js"; +function _layout($$renderer, $$props) { + $$renderer.component(($$renderer2) => { + let { children } = $$props; + head("12qhfyh", $$renderer2, ($$renderer3) => { + $$renderer3.push(``); + }); + $$renderer2.push(`
`); + children($$renderer2); + $$renderer2.push(`
`); + }); +} +export { + _layout as default +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_page.svelte.js b/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_page.svelte.js new file mode 100644 index 0000000..8ee7555 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/_page.svelte.js @@ -0,0 +1,26 @@ +import { e as escape_html } from "../../chunks/context.js"; +import "clsx"; +import { a as auth } from "../../chunks/auth.svelte.js"; +function _page($$renderer, $$props) { + $$renderer.component(($$renderer2) => { + $$renderer2.push(`

Mode Template

`); + if (auth.loading) { + $$renderer2.push(""); + $$renderer2.push(`

Loading...

`); + } else { + $$renderer2.push(""); + if (auth.isAuthenticated) { + $$renderer2.push(""); + $$renderer2.push(`

Welcome, ${escape_html(auth.user?.displayName)}!

Email: ${escape_html(auth.user?.email)}

`); + } else { + $$renderer2.push(""); + $$renderer2.push(`

Please log in to continue.

`); + } + $$renderer2.push(``); + } + $$renderer2.push(``); + }); +} +export { + _page as default +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/callback/_page.svelte.js b/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/callback/_page.svelte.js new file mode 100644 index 0000000..0c129b2 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/entries/pages/callback/_page.svelte.js @@ -0,0 +1,19 @@ +import "clsx"; +import "@sveltejs/kit/internal"; +import "../../../chunks/exports.js"; +import "../../../chunks/utils.js"; +import "@sveltejs/kit/internal/server"; +import "../../../chunks/state.svelte.js"; +function _page($$renderer, $$props) { + $$renderer.component(($$renderer2) => { + $$renderer2.push(`

Authenticating...

`); + { + $$renderer2.push(""); + $$renderer2.push(`

Please wait...

`); + } + $$renderer2.push(``); + }); +} +export { + _page as default +}; diff --git a/ModeTemplate/frontend/.svelte-kit/output/server/index.js b/ModeTemplate/frontend/.svelte-kit/output/server/index.js new file mode 100644 index 0000000..6ed6366 --- /dev/null +++ b/ModeTemplate/frontend/.svelte-kit/output/server/index.js @@ -0,0 +1,3863 @@ +import { B as BROWSER, a as assets, b as base, c as app_dir, r as relative, o as override, d as reset } from "./chunks/environment.js"; +import { json, text, error } from "@sveltejs/kit"; +import { HttpError, SvelteKitError, Redirect, ActionFailure } from "@sveltejs/kit/internal"; +import { with_request_store, merge_tracing, try_get_request_store } from "@sveltejs/kit/internal/server"; +import { B as BINARY_FORM_CONTENT_TYPE, c as create_remote_key, p as parse_remote_arg, s as stringify, d as deserialize_binary_form, T as TRAILING_SLASH_PARAM, I as INVALIDATED_PARAM } from "./chunks/shared.js"; +import * as devalue from "devalue"; +import { m as make_trackable, d as disable_search, a as decode_params, S as SCHEME, v as validate_layout_server_exports, b as validate_layout_exports, c as validate_page_server_exports, e as validate_page_exports, n as normalize_path, r as resolve, f as decode_pathname, g as validate_server_exports } from "./chunks/exports.js"; +import { b as base64_encode, t as text_decoder, a as text_encoder, g as get_relative_path } from "./chunks/utils.js"; +import { r as readable, w as writable } from "./chunks/index.js"; +import { p as public_env, r as read_implementation, o as options, s as set_private_env, a as set_public_env, g as get_hooks, b as set_read_implementation } from "./chunks/internal.js"; +import { parse, serialize } from "cookie"; +import * as set_cookie_parser from "set-cookie-parser"; +function with_resolvers() { + let resolve2; + let reject; + const promise = new Promise((res, rej) => { + resolve2 = res; + reject = rej; + }); + return { promise, resolve: resolve2, reject }; +} +const NULL_BODY_STATUS = [101, 103, 204, 205, 304]; +const IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer; +const SVELTE_KIT_ASSETS = "/_svelte_kit_assets"; +const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]; +const PAGE_METHODS = ["GET", "POST", "HEAD"]; +function negotiate(accept, types) { + const parts = []; + accept.split(",").forEach((str, i) => { + const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str); + if (match) { + const [, type, subtype, q = "1"] = match; + parts.push({ type, subtype, q: +q, i }); + } + }); + parts.sort((a, b) => { + if (a.q !== b.q) { + return b.q - a.q; + } + if (a.subtype === "*" !== (b.subtype === "*")) { + return a.subtype === "*" ? 1 : -1; + } + if (a.type === "*" !== (b.type === "*")) { + return a.type === "*" ? 1 : -1; + } + return a.i - b.i; + }); + let accepted; + let min_priority = Infinity; + for (const mimetype of types) { + const [type, subtype] = mimetype.split("/"); + const priority = parts.findIndex( + (part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*") + ); + if (priority !== -1 && priority < min_priority) { + accepted = mimetype; + min_priority = priority; + } + } + return accepted; +} +function is_content_type(request, ...types) { + const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? ""; + return types.includes(type.toLowerCase()); +} +function is_form_content_type(request) { + return is_content_type( + request, + "application/x-www-form-urlencoded", + "multipart/form-data", + "text/plain", + BINARY_FORM_CONTENT_TYPE + ); +} +function coalesce_to_error(err) { + return err instanceof Error || err && /** @type {any} */ + err.name && /** @type {any} */ + err.message ? ( + /** @type {Error} */ + err + ) : new Error(JSON.stringify(err)); +} +function normalize_error(error2) { + return ( + /** @type {import('../exports/internal/index.js').Redirect | HttpError | SvelteKitError | Error} */ + error2 + ); +} +function get_status(error2) { + return error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500; +} +function get_message(error2) { + return error2 instanceof SvelteKitError ? error2.text : "Internal Error"; +} +const escape_html_attr_dict = { + "&": "&", + '"': """ + // Svelte also escapes < because the escape function could be called inside a `noscript` there + // https://github.com/sveltejs/svelte/security/advisories/GHSA-8266-84wp-wv5c + // However, that doesn't apply in SvelteKit +}; +const escape_html_dict = { + "&": "&", + "<": "<" +}; +const surrogates = ( + // high surrogate without paired low surrogate + "[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]" +); +const escape_html_attr_regex = new RegExp( + `[${Object.keys(escape_html_attr_dict).join("")}]|` + surrogates, + "g" +); +const escape_html_regex = new RegExp( + `[${Object.keys(escape_html_dict).join("")}]|` + surrogates, + "g" +); +function escape_html(str, is_attr) { + const dict = is_attr ? escape_html_attr_dict : escape_html_dict; + const escaped_str = str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => { + if (match.length === 2) { + return match; + } + return dict[match] ?? `&#${match.charCodeAt(0)};`; + }); + return escaped_str; +} +function method_not_allowed(mod, method) { + return text(`${method} method not allowed`, { + status: 405, + headers: { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: allowed_methods(mod).join(", ") + } + }); +} +function allowed_methods(mod) { + const allowed = ENDPOINT_METHODS.filter((method) => method in mod); + if ("GET" in mod && !("HEAD" in mod)) { + allowed.push("HEAD"); + } + return allowed; +} +function get_global_name(options2) { + return `__sveltekit_${options2.version_hash}`; +} +function static_error_page(options2, status, message) { + let page = options2.templates.error({ status, message: escape_html(message) }); + return text(page, { + headers: { "content-type": "text/html; charset=utf-8" }, + status + }); +} +async function handle_fatal_error(event, state, options2, error2) { + error2 = error2 instanceof HttpError ? error2 : coalesce_to_error(error2); + const status = get_status(error2); + const body2 = await handle_error_and_jsonify(event, state, options2, error2); + const type = negotiate(event.request.headers.get("accept") || "text/html", [ + "application/json", + "text/html" + ]); + if (event.isDataRequest || type === "application/json") { + return json(body2, { + status + }); + } + return static_error_page(options2, status, body2.message); +} +async function handle_error_and_jsonify(event, state, options2, error2) { + if (error2 instanceof HttpError) { + return { message: "Unknown Error", ...error2.body }; + } + const status = get_status(error2); + const message = get_message(error2); + return await with_request_store( + { event, state }, + () => options2.hooks.handleError({ error: error2, event, status, message }) + ) ?? { message }; +} +function redirect_response(status, location) { + const response = new Response(void 0, { + status, + headers: { location } + }); + return response; +} +function clarify_devalue_error(event, error2) { + if (error2.path) { + return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error2.message} (${error2.path}). If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`; + } + if (error2.path === "") { + return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`; + } + return error2.message; +} +function serialize_uses(node) { + const uses = {}; + if (node.uses && node.uses.dependencies.size > 0) { + uses.dependencies = Array.from(node.uses.dependencies); + } + if (node.uses && node.uses.search_params.size > 0) { + uses.search_params = Array.from(node.uses.search_params); + } + if (node.uses && node.uses.params.size > 0) { + uses.params = Array.from(node.uses.params); + } + if (node.uses?.parent) uses.parent = 1; + if (node.uses?.route) uses.route = 1; + if (node.uses?.url) uses.url = 1; + return uses; +} +function has_prerendered_path(manifest, pathname) { + return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1)); +} +function format_server_error(status, error2, event) { + const formatted_text = ` +\x1B[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1B[0m`; + if (status === 404) { + return formatted_text; + } + return `${formatted_text} +${error2.stack}`; +} +function get_node_type(node_id) { + const parts = node_id?.split("/"); + const filename = parts?.at(-1); + if (!filename) return "unknown"; + const dot_parts = filename.split("."); + return dot_parts.slice(0, -1).join("."); +} +async function render_endpoint(event, event_state, mod, state) { + const method = ( + /** @type {import('types').HttpMethod} */ + event.request.method + ); + let handler = mod[method] || mod.fallback; + if (method === "HEAD" && !mod.HEAD && mod.GET) { + handler = mod.GET; + } + if (!handler) { + return method_not_allowed(mod, method); + } + const prerender = mod.prerender ?? state.prerender_default; + if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) { + throw new Error("Cannot prerender endpoints that have mutative methods"); + } + if (state.prerendering && !state.prerendering.inside_reroute && !prerender) { + if (state.depth > 0) { + throw new Error(`${event.route.id} is not prerenderable`); + } else { + return new Response(void 0, { status: 204 }); + } + } + event_state.is_endpoint_request = true; + try { + const response = await with_request_store( + { event, state: event_state }, + () => handler( + /** @type {import('@sveltejs/kit').RequestEvent>} */ + event + ) + ); + if (!(response instanceof Response)) { + throw new Error( + `Invalid response from route ${event.url.pathname}: handler should return a Response object` + ); + } + if (state.prerendering && (!state.prerendering.inside_reroute || prerender)) { + const cloned = new Response(response.clone().body, { + status: response.status, + statusText: response.statusText, + headers: new Headers(response.headers) + }); + cloned.headers.set("x-sveltekit-prerender", String(prerender)); + if (state.prerendering.inside_reroute && prerender) { + cloned.headers.set( + "x-sveltekit-routeid", + encodeURI( + /** @type {string} */ + event.route.id + ) + ); + state.prerendering.dependencies.set(event.url.pathname, { response: cloned, body: null }); + } else { + return cloned; + } + } + return response; + } catch (e) { + if (e instanceof Redirect) { + return new Response(void 0, { + status: e.status, + headers: { location: e.location } + }); + } + throw e; + } +} +function is_endpoint_request(event) { + const { method, headers: headers2 } = event.request; + if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) { + return true; + } + if (method === "POST" && headers2.get("x-sveltekit-action") === "true") return false; + const accept = event.request.headers.get("accept") ?? "*/*"; + return negotiate(accept, ["*", "text/html"]) !== "text/html"; +} +function compact(arr) { + return arr.filter( + /** @returns {val is NonNullable} */ + (val) => val != null + ); +} +const DATA_SUFFIX = "/__data.json"; +const HTML_DATA_SUFFIX = ".html__data.json"; +function has_data_suffix(pathname) { + return pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX); +} +function add_data_suffix(pathname) { + if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_DATA_SUFFIX); + return pathname.replace(/\/$/, "") + DATA_SUFFIX; +} +function strip_data_suffix(pathname) { + if (pathname.endsWith(HTML_DATA_SUFFIX)) { + return pathname.slice(0, -HTML_DATA_SUFFIX.length) + ".html"; + } + return pathname.slice(0, -DATA_SUFFIX.length); +} +const ROUTE_SUFFIX = "/__route.js"; +function has_resolution_suffix(pathname) { + return pathname.endsWith(ROUTE_SUFFIX); +} +function add_resolution_suffix(pathname) { + return pathname.replace(/\/$/, "") + ROUTE_SUFFIX; +} +function strip_resolution_suffix(pathname) { + return pathname.slice(0, -ROUTE_SUFFIX.length); +} +const noop_span = { + spanContext() { + return noop_span_context; + }, + setAttribute() { + return this; + }, + setAttributes() { + return this; + }, + addEvent() { + return this; + }, + setStatus() { + return this; + }, + updateName() { + return this; + }, + end() { + return this; + }, + isRecording() { + return false; + }, + recordException() { + return this; + }, + addLink() { + return this; + }, + addLinks() { + return this; + } +}; +const noop_span_context = { + traceId: "", + spanId: "", + traceFlags: 0 +}; +async function record_span({ name, attributes, fn }) { + { + return fn(noop_span); + } +} +function is_action_json_request(event) { + const accept = negotiate(event.request.headers.get("accept") ?? "*/*", [ + "application/json", + "text/html" + ]); + return accept === "application/json" && event.request.method === "POST"; +} +async function handle_action_json_request(event, event_state, options2, server) { + const actions = server?.actions; + if (!actions) { + const no_actions_error = new SvelteKitError( + 405, + "Method Not Allowed", + `POST method not allowed. No form actions exist for ${"this page"}` + ); + return action_json( + { + type: "error", + error: await handle_error_and_jsonify(event, event_state, options2, no_actions_error) + }, + { + status: no_actions_error.status, + headers: { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: "GET" + } + } + ); + } + check_named_default_separate(actions); + try { + const data = await call_action(event, event_state, actions); + if (BROWSER) ; + if (data instanceof ActionFailure) { + return action_json({ + type: "failure", + status: data.status, + // @ts-expect-error we assign a string to what is supposed to be an object. That's ok + // because we don't use the object outside, and this way we have better code navigation + // through knowing where the related interface is used. + data: stringify_action_response( + data.data, + /** @type {string} */ + event.route.id, + options2.hooks.transport + ) + }); + } else { + return action_json({ + type: "success", + status: data ? 200 : 204, + // @ts-expect-error see comment above + data: stringify_action_response( + data, + /** @type {string} */ + event.route.id, + options2.hooks.transport + ) + }); + } + } catch (e) { + const err = normalize_error(e); + if (err instanceof Redirect) { + return action_json_redirect(err); + } + return action_json( + { + type: "error", + error: await handle_error_and_jsonify( + event, + event_state, + options2, + check_incorrect_fail_use(err) + ) + }, + { + status: get_status(err) + } + ); + } +} +function check_incorrect_fail_use(error2) { + return error2 instanceof ActionFailure ? new Error('Cannot "throw fail()". Use "return fail()"') : error2; +} +function action_json_redirect(redirect) { + return action_json({ + type: "redirect", + status: redirect.status, + location: redirect.location + }); +} +function action_json(data, init2) { + return json(data, init2); +} +function is_action_request(event) { + return event.request.method === "POST"; +} +async function handle_action_request(event, event_state, server) { + const actions = server?.actions; + if (!actions) { + event.setHeaders({ + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: "GET" + }); + return { + type: "error", + error: new SvelteKitError( + 405, + "Method Not Allowed", + `POST method not allowed. No form actions exist for ${"this page"}` + ) + }; + } + check_named_default_separate(actions); + try { + const data = await call_action(event, event_state, actions); + if (BROWSER) ; + if (data instanceof ActionFailure) { + return { + type: "failure", + status: data.status, + data: data.data + }; + } else { + return { + type: "success", + status: 200, + // @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission + data + }; + } + } catch (e) { + const err = normalize_error(e); + if (err instanceof Redirect) { + return { + type: "redirect", + status: err.status, + location: err.location + }; + } + return { + type: "error", + error: check_incorrect_fail_use(err) + }; + } +} +function check_named_default_separate(actions) { + if (actions.default && Object.keys(actions).length > 1) { + throw new Error( + "When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions" + ); + } +} +async function call_action(event, event_state, actions) { + const url = new URL(event.request.url); + let name = "default"; + for (const param of url.searchParams) { + if (param[0].startsWith("/")) { + name = param[0].slice(1); + if (name === "default") { + throw new Error('Cannot use reserved action name "default"'); + } + break; + } + } + const action = actions[name]; + if (!action) { + throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`); + } + if (!is_form_content_type(event.request)) { + throw new SvelteKitError( + 415, + "Unsupported Media Type", + `Form actions expect form-encoded data — received ${event.request.headers.get( + "content-type" + )}` + ); + } + return record_span({ + name: "sveltekit.form_action", + attributes: { + "http.route": event.route.id || "unknown" + }, + fn: async (current2) => { + const traced_event = merge_tracing(event, current2); + const result = await with_request_store( + { event: traced_event, state: event_state }, + () => action(traced_event) + ); + if (result instanceof ActionFailure) { + current2.setAttributes({ + "sveltekit.form_action.result.type": "failure", + "sveltekit.form_action.result.status": result.status + }); + } + return result; + } + }); +} +function validate_action_return(data) { + if (data instanceof Redirect) { + throw new Error("Cannot `return redirect(...)` — use `redirect(...)` instead"); + } + if (data instanceof HttpError) { + throw new Error("Cannot `return error(...)` — use `error(...)` or `return fail(...)` instead"); + } +} +function uneval_action_response(data, route_id, transport) { + const replacer = (thing) => { + for (const key2 in transport) { + const encoded = transport[key2].encode(thing); + if (encoded) { + return `app.decode('${key2}', ${devalue.uneval(encoded, replacer)})`; + } + } + }; + return try_serialize(data, (value) => devalue.uneval(value, replacer), route_id); +} +function stringify_action_response(data, route_id, transport) { + const encoders = Object.fromEntries( + Object.entries(transport).map(([key2, value]) => [key2, value.encode]) + ); + return try_serialize(data, (value) => devalue.stringify(value, encoders), route_id); +} +function try_serialize(data, fn, route_id) { + try { + return fn(data); + } catch (e) { + const error2 = ( + /** @type {any} */ + e + ); + if (data instanceof Response) { + throw new Error( + `Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });` + ); + } + if ("path" in error2) { + let message = `Data returned from action inside ${route_id} is not serializable: ${error2.message}`; + if (error2.path !== "") message += ` (data.${error2.path})`; + throw new Error(message); + } + throw error2; + } +} +function create_async_iterator() { + let resolved = -1; + let returned = -1; + const deferred = []; + return { + iterate: (transform = (x) => x) => { + return { + [Symbol.asyncIterator]() { + return { + next: async () => { + const next = deferred[++returned]; + if (!next) return { value: null, done: true }; + const value = await next.promise; + return { value: transform(value), done: false }; + } + }; + } + }; + }, + add: (promise) => { + deferred.push(with_resolvers()); + void promise.then((value) => { + deferred[++resolved].resolve(value); + }); + } + }; +} +function server_data_serializer(event, event_state, options2) { + let promise_id = 1; + let max_nodes = -1; + const iterator = create_async_iterator(); + const global = get_global_name(options2); + function get_replacer(index) { + return function replacer(thing) { + if (typeof thing?.then === "function") { + const id = promise_id++; + const promise = thing.then( + /** @param {any} data */ + (data) => ({ data }) + ).catch( + /** @param {any} error */ + async (error2) => ({ + error: await handle_error_and_jsonify(event, event_state, options2, error2) + }) + ).then( + /** + * @param {{data: any; error: any}} result + */ + async ({ data, error: error2 }) => { + let str; + try { + str = devalue.uneval(error2 ? [, error2] : [data], replacer); + } catch { + error2 = await handle_error_and_jsonify( + event, + event_state, + options2, + new Error(`Failed to serialize promise while rendering ${event.route.id}`) + ); + data = void 0; + str = devalue.uneval([, error2], replacer); + } + return { + index, + str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})` + }; + } + ); + iterator.add(promise); + return `${global}.defer(${id})`; + } else { + for (const key2 in options2.hooks.transport) { + const encoded = options2.hooks.transport[key2].encode(thing); + if (encoded) { + return `app.decode('${key2}', ${devalue.uneval(encoded, replacer)})`; + } + } + } + }; + } + const strings = ( + /** @type {string[]} */ + [] + ); + return { + set_max_nodes(i) { + max_nodes = i; + }, + add_node(i, node) { + try { + if (!node) { + strings[i] = "null"; + return; + } + const payload = { type: "data", data: node.data, uses: serialize_uses(node) }; + if (node.slash) payload.slash = node.slash; + strings[i] = devalue.uneval(payload, get_replacer(i)); + } catch (e) { + e.path = e.path.slice(1); + throw new Error(clarify_devalue_error( + event, + /** @type {any} */ + e + )); + } + }, + get_data(csp) { + const open = ``; + const close = `<\/script> +`; + return { + data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`, + chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => { + if (max_nodes > -1 && index >= max_nodes) { + return ""; + } + return open + str + close; + }) : null + }; + } + }; +} +function server_data_serializer_json(event, event_state, options2) { + let promise_id = 1; + const iterator = create_async_iterator(); + const reducers = { + ...Object.fromEntries( + Object.entries(options2.hooks.transport).map(([key2, value]) => [key2, value.encode]) + ), + /** @param {any} thing */ + Promise: (thing) => { + if (typeof thing?.then !== "function") { + return; + } + const id = promise_id++; + let key2 = "data"; + const promise = thing.catch( + /** @param {any} e */ + async (e) => { + key2 = "error"; + return handle_error_and_jsonify( + event, + event_state, + options2, + /** @type {any} */ + e + ); + } + ).then( + /** @param {any} value */ + async (value) => { + let str; + try { + str = devalue.stringify(value, reducers); + } catch { + const error2 = await handle_error_and_jsonify( + event, + event_state, + options2, + new Error(`Failed to serialize promise while rendering ${event.route.id}`) + ); + key2 = "error"; + str = devalue.stringify(error2, reducers); + } + return `{"type":"chunk","id":${id},"${key2}":${str}} +`; + } + ); + iterator.add(promise); + return id; + } + }; + const strings = ( + /** @type {string[]} */ + [] + ); + return { + add_node(i, node) { + try { + if (!node) { + strings[i] = "null"; + return; + } + if (node.type === "error" || node.type === "skip") { + strings[i] = JSON.stringify(node); + return; + } + strings[i] = `{"type":"data","data":${devalue.stringify(node.data, reducers)},"uses":${JSON.stringify( + serialize_uses(node) + )}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`; + } catch (e) { + e.path = "data" + e.path; + throw new Error(clarify_devalue_error( + event, + /** @type {any} */ + e + )); + } + }, + get_data() { + return { + data: `{"type":"data","nodes":[${strings.join(",")}]} +`, + chunks: promise_id > 1 ? iterator.iterate() : null + }; + } + }; +} +async function load_server_data({ event, event_state, state, node, parent }) { + if (!node?.server) return null; + let is_tracking = true; + const uses = { + dependencies: /* @__PURE__ */ new Set(), + params: /* @__PURE__ */ new Set(), + parent: false, + route: false, + url: false, + search_params: /* @__PURE__ */ new Set() + }; + const load = node.server.load; + const slash = node.server.trailingSlash; + if (!load) { + return { type: "data", data: null, uses, slash }; + } + const url = make_trackable( + event.url, + () => { + if (is_tracking) { + uses.url = true; + } + }, + (param) => { + if (is_tracking) { + uses.search_params.add(param); + } + } + ); + if (state.prerendering) { + disable_search(url); + } + const result = await record_span({ + name: "sveltekit.load", + attributes: { + "sveltekit.load.node_id": node.server_id || "unknown", + "sveltekit.load.node_type": get_node_type(node.server_id), + "http.route": event.route.id || "unknown" + }, + fn: async (current2) => { + const traced_event = merge_tracing(event, current2); + const result2 = await with_request_store( + { event: traced_event, state: event_state }, + () => load.call(null, { + ...traced_event, + fetch: (info, init2) => { + new URL(info instanceof Request ? info.url : info, event.url); + return event.fetch(info, init2); + }, + /** @param {string[]} deps */ + depends: (...deps) => { + for (const dep of deps) { + const { href } = new URL(dep, event.url); + uses.dependencies.add(href); + } + }, + params: new Proxy(event.params, { + get: (target, key2) => { + if (is_tracking) { + uses.params.add(key2); + } + return target[ + /** @type {string} */ + key2 + ]; + } + }), + parent: async () => { + if (is_tracking) { + uses.parent = true; + } + return parent(); + }, + route: new Proxy(event.route, { + get: (target, key2) => { + if (is_tracking) { + uses.route = true; + } + return target[ + /** @type {'id'} */ + key2 + ]; + } + }), + url, + untrack(fn) { + is_tracking = false; + try { + return fn(); + } finally { + is_tracking = true; + } + } + }) + ); + return result2; + } + }); + return { + type: "data", + data: result ?? null, + uses, + slash + }; +} +async function load_data({ + event, + event_state, + fetched, + node, + parent, + server_data_promise, + state, + resolve_opts, + csr +}) { + const server_data_node = await server_data_promise; + const load = node?.universal?.load; + if (!load) { + return server_data_node?.data ?? null; + } + const result = await record_span({ + name: "sveltekit.load", + attributes: { + "sveltekit.load.node_id": node.universal_id || "unknown", + "sveltekit.load.node_type": get_node_type(node.universal_id), + "http.route": event.route.id || "unknown" + }, + fn: async (current2) => { + const traced_event = merge_tracing(event, current2); + return await with_request_store( + { event: traced_event, state: event_state }, + () => load.call(null, { + url: event.url, + params: event.params, + data: server_data_node?.data ?? null, + route: event.route, + fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts), + setHeaders: event.setHeaders, + depends: () => { + }, + parent, + untrack: (fn) => fn(), + tracing: traced_event.tracing + }) + ); + } + }); + return result ?? null; +} +function create_universal_fetch(event, state, fetched, csr, resolve_opts) { + const universal_fetch = async (input, init2) => { + const cloned_body = input instanceof Request && input.body ? input.clone().body : null; + const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init2?.headers; + let response = await event.fetch(input, init2); + const url = new URL(input instanceof Request ? input.url : input, event.url); + const same_origin = url.origin === event.url.origin; + let dependency; + if (same_origin) { + if (state.prerendering) { + dependency = { response, body: null }; + state.prerendering.dependencies.set(url.pathname, dependency); + } + } else if (url.protocol === "https:" || url.protocol === "http:") { + const mode = input instanceof Request ? input.mode : init2?.mode ?? "cors"; + if (mode === "no-cors") { + response = new Response("", { + status: response.status, + statusText: response.statusText, + headers: response.headers + }); + } else { + const acao = response.headers.get("access-control-allow-origin"); + if (!acao || acao !== event.url.origin && acao !== "*") { + throw new Error( + `CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource` + ); + } + } + } + let teed_body; + const proxy = new Proxy(response, { + get(response2, key2, receiver) { + async function push_fetched(body2, is_b64) { + const status_number = Number(response2.status); + if (isNaN(status_number)) { + throw new Error( + `response.status is not a number. value: "${response2.status}" type: ${typeof response2.status}` + ); + } + fetched.push({ + url: same_origin ? url.href.slice(event.url.origin.length) : url.href, + method: event.request.method, + request_body: ( + /** @type {string | ArrayBufferView | undefined} */ + input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init2?.body + ), + request_headers: cloned_headers, + response_body: body2, + response: response2, + is_b64 + }); + } + if (key2 === "body") { + if (response2.body === null) { + return null; + } + if (teed_body) { + return teed_body; + } + const [a, b] = response2.body.tee(); + void (async () => { + let result = new Uint8Array(); + for await (const chunk of a) { + const combined = new Uint8Array(result.length + chunk.length); + combined.set(result, 0); + combined.set(chunk, result.length); + result = combined; + } + if (dependency) { + dependency.body = new Uint8Array(result); + } + void push_fetched(base64_encode(result), true); + })(); + return teed_body = b; + } + if (key2 === "arrayBuffer") { + return async () => { + const buffer = await response2.arrayBuffer(); + const bytes = new Uint8Array(buffer); + if (dependency) { + dependency.body = bytes; + } + if (buffer instanceof ArrayBuffer) { + await push_fetched(base64_encode(bytes), true); + } + return buffer; + }; + } + async function text2() { + const body2 = await response2.text(); + if (body2 === "" && NULL_BODY_STATUS.includes(response2.status)) { + await push_fetched(void 0, false); + return void 0; + } + if (!body2 || typeof body2 === "string") { + await push_fetched(body2, false); + } + if (dependency) { + dependency.body = body2; + } + return body2; + } + if (key2 === "text") { + return text2; + } + if (key2 === "json") { + return async () => { + const body2 = await text2(); + return body2 ? JSON.parse(body2) : void 0; + }; + } + const value = Reflect.get(response2, key2, response2); + if (value instanceof Function) { + return Object.defineProperties( + /** + * @this {any} + */ + function() { + return Reflect.apply(value, this === receiver ? response2 : this, arguments); + }, + { + name: { value: value.name }, + length: { value: value.length } + } + ); + } + return value; + } + }); + if (csr) { + const get = response.headers.get; + response.headers.get = (key2) => { + const lower = key2.toLowerCase(); + const value = get.call(response.headers, lower); + if (value && !lower.startsWith("x-sveltekit-")) { + const included = resolve_opts.filterSerializedResponseHeaders(lower, value); + if (!included) { + throw new Error( + `Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})` + ); + } + } + return value; + }; + } + return proxy; + }; + return (input, init2) => { + const response = universal_fetch(input, init2); + response.catch(() => { + }); + return response; + }; +} +async function stream_to_string(stream) { + let result = ""; + const reader = stream.getReader(); + while (true) { + const { done, value } = await reader.read(); + if (done) { + break; + } + result += text_decoder.decode(value); + } + return result; +} +function hash(...values) { + let hash2 = 5381; + for (const value of values) { + if (typeof value === "string") { + let i = value.length; + while (i) hash2 = hash2 * 33 ^ value.charCodeAt(--i); + } else if (ArrayBuffer.isView(value)) { + const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength); + let i = buffer.length; + while (i) hash2 = hash2 * 33 ^ buffer[--i]; + } else { + throw new TypeError("value must be a string or TypedArray"); + } + } + return (hash2 >>> 0).toString(36); +} +const replacements = { + "<": "\\u003C", + "\u2028": "\\u2028", + "\u2029": "\\u2029" +}; +const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g"); +function serialize_data(fetched, filter, prerendering = false) { + const headers2 = {}; + let cache_control = null; + let age = null; + let varyAny = false; + for (const [key2, value] of fetched.response.headers) { + if (filter(key2, value)) { + headers2[key2] = value; + } + if (key2 === "cache-control") cache_control = value; + else if (key2 === "age") age = value; + else if (key2 === "vary" && value.trim() === "*") varyAny = true; + } + const payload = { + status: fetched.response.status, + statusText: fetched.response.statusText, + headers: headers2, + body: fetched.response_body + }; + const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]); + const attrs = [ + 'type="application/json"', + "data-sveltekit-fetched", + `data-url="${escape_html(fetched.url, true)}"` + ]; + if (fetched.is_b64) { + attrs.push("data-b64"); + } + if (fetched.request_headers || fetched.request_body) { + const values = []; + if (fetched.request_headers) { + values.push([...new Headers(fetched.request_headers)].join(",")); + } + if (fetched.request_body) { + values.push(fetched.request_body); + } + attrs.push(`data-hash="${hash(...values)}"`); + } + if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) { + const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control); + if (match) { + const ttl = +match[1] - +(age ?? "0"); + attrs.push(`data-ttl="${ttl}"`); + } + } + return ` + + + diff --git a/ModeTemplate/frontend/bun.lock b/ModeTemplate/frontend/bun.lock new file mode 100644 index 0000000..6733358 --- /dev/null +++ b/ModeTemplate/frontend/bun.lock @@ -0,0 +1,210 @@ +{ + "lockfileVersion": 1, + "configVersion": 1, + "workspaces": { + "": { + "name": "mode-template-frontend", + "dependencies": { + "@sveltejs/kit": "^2.0.0", + "svelte": "^5.0.0", + }, + "devDependencies": { + "@sveltejs/adapter-static": "^3.0.0", + "@sveltejs/vite-plugin-svelte": "^4.0.0", + "typescript": "^5.0.0", + "vite": "^5.0.0", + }, + }, + }, + "packages": { + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.21.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="], + + "@esbuild/android-arm": ["@esbuild/android-arm@0.21.5", "", { "os": "android", "cpu": "arm" }, "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg=="], + + "@esbuild/android-arm64": ["@esbuild/android-arm64@0.21.5", "", { "os": "android", "cpu": "arm64" }, "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A=="], + + "@esbuild/android-x64": ["@esbuild/android-x64@0.21.5", "", { "os": "android", "cpu": "x64" }, "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA=="], + + "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.21.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ=="], + + "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.21.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw=="], + + "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.21.5", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g=="], + + "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.21.5", "", { "os": "freebsd", "cpu": "x64" }, "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ=="], + + "@esbuild/linux-arm": ["@esbuild/linux-arm@0.21.5", "", { "os": "linux", "cpu": "arm" }, "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA=="], + + "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.21.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q=="], + + "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.21.5", "", { "os": "linux", "cpu": "ia32" }, "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg=="], + + "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg=="], + + "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg=="], + + "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.21.5", "", { "os": "linux", "cpu": "ppc64" }, "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w=="], + + "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA=="], + + "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.21.5", "", { "os": "linux", "cpu": "s390x" }, "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A=="], + + "@esbuild/linux-x64": ["@esbuild/linux-x64@0.21.5", "", { "os": "linux", "cpu": "x64" }, "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ=="], + + "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.21.5", "", { "os": "none", "cpu": "x64" }, "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg=="], + + "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.21.5", "", { "os": "openbsd", "cpu": "x64" }, "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow=="], + + "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.21.5", "", { "os": "sunos", "cpu": "x64" }, "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg=="], + + "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.21.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A=="], + + "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.21.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA=="], + + "@esbuild/win32-x64": ["@esbuild/win32-x64@0.21.5", "", { "os": "win32", "cpu": "x64" }, "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw=="], + + "@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="], + + "@jridgewell/remapping": ["@jridgewell/remapping@2.3.5", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="], + + "@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="], + + "@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="], + + "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="], + + "@polka/url": ["@polka/url@1.0.0-next.29", "", {}, "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww=="], + + "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.55.2", "", { "os": "android", "cpu": "arm" }, "sha512-21J6xzayjy3O6NdnlO6aXi/urvSRjm6nCI6+nF6ra2YofKruGixN9kfT+dt55HVNwfDmpDHJcaS3JuP/boNnlA=="], + + "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.55.2", "", { "os": "android", "cpu": "arm64" }, "sha512-eXBg7ibkNUZ+sTwbFiDKou0BAckeV6kIigK7y5Ko4mB/5A1KLhuzEKovsmfvsL8mQorkoincMFGnQuIT92SKqA=="], + + "@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.55.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-UCbaTklREjrc5U47ypLulAgg4njaqfOVLU18VrCrI+6E5MQjuG0lSWaqLlAJwsD7NpFV249XgB0Bi37Zh5Sz4g=="], + + "@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.55.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-dP67MA0cCMHFT2g5XyjtpVOtp7y4UyUxN3dhLdt11at5cPKnSm4lY+EhwNvDXIMzAMIo2KU+mc9wxaAQJTn7sQ=="], + + "@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.55.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-WDUPLUwfYV9G1yxNRJdXcvISW15mpvod1Wv3ok+Ws93w1HjIVmCIFxsG2DquO+3usMNCpJQ0wqO+3GhFdl6Fow=="], + + "@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.55.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-Ng95wtHVEulRwn7R0tMrlUuiLVL/HXA8Lt/MYVpy88+s5ikpntzZba1qEulTuPnPIZuOPcW9wNEiqvZxZmgmqQ=="], + + "@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.55.2", "", { "os": "linux", "cpu": "arm" }, "sha512-AEXMESUDWWGqD6LwO/HkqCZgUE1VCJ1OhbvYGsfqX2Y6w5quSXuyoy/Fg3nRqiwro+cJYFxiw5v4kB2ZDLhxrw=="], + + "@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.55.2", "", { "os": "linux", "cpu": "arm" }, "sha512-ZV7EljjBDwBBBSv570VWj0hiNTdHt9uGznDtznBB4Caj3ch5rgD4I2K1GQrtbvJ/QiB+663lLgOdcADMNVC29Q=="], + + "@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.55.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-uvjwc8NtQVPAJtq4Tt7Q49FOodjfbf6NpqXyW/rjXoV+iZ3EJAHLNAnKT5UJBc6ffQVgmXTUL2ifYiLABlGFqA=="], + + "@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.55.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-s3KoWVNnye9mm/2WpOZ3JeUiediUVw6AvY/H7jNA6qgKA2V2aM25lMkVarTDfiicn/DLq3O0a81jncXszoyCFA=="], + + "@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.55.2", "", { "os": "linux", "cpu": "none" }, "sha512-gi21faacK+J8aVSyAUptML9VQN26JRxe484IbF+h3hpG+sNVoMXPduhREz2CcYr5my0NE3MjVvQ5bMKX71pfVA=="], + + "@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.55.2", "", { "os": "linux", "cpu": "none" }, "sha512-qSlWiXnVaS/ceqXNfnoFZh4IiCA0EwvCivivTGbEu1qv2o+WTHpn1zNmCTAoOG5QaVr2/yhCoLScQtc/7RxshA=="], + + "@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.55.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-rPyuLFNoF1B0+wolH277E780NUKf+KoEDb3OyoLbAO18BbeKi++YN6gC/zuJoPPDlQRL3fIxHxCxVEWiem2yXw=="], + + "@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.55.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-g+0ZLMook31iWV4PvqKU0i9E78gaZgYpSrYPed/4Bu+nGTgfOPtfs1h11tSSRPXSjC5EzLTjV/1A7L2Vr8pJoQ=="], + + "@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.55.2", "", { "os": "linux", "cpu": "none" }, "sha512-i+sGeRGsjKZcQRh3BRfpLsM3LX3bi4AoEVqmGDyc50L6KfYsN45wVCSz70iQMwPWr3E5opSiLOwsC9WB4/1pqg=="], + + "@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.55.2", "", { "os": "linux", "cpu": "none" }, "sha512-C1vLcKc4MfFV6I0aWsC7B2Y9QcsiEcvKkfxprwkPfLaN8hQf0/fKHwSF2lcYzA9g4imqnhic729VB9Fo70HO3Q=="], + + "@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.55.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-68gHUK/howpQjh7g7hlD9DvTTt4sNLp1Bb+Yzw2Ki0xvscm2cOdCLZNJNhd2jW8lsTPrHAHuF751BygifW4bkQ=="], + + "@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.55.2", "", { "os": "linux", "cpu": "x64" }, "sha512-1e30XAuaBP1MAizaOBApsgeGZge2/Byd6wV4a8oa6jPdHELbRHBiw7wvo4dp7Ie2PE8TZT4pj9RLGZv9N4qwlw=="], + + "@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.55.2", "", { "os": "linux", "cpu": "x64" }, "sha512-4BJucJBGbuGnH6q7kpPqGJGzZnYrpAzRd60HQSt3OpX/6/YVgSsJnNzR8Ot74io50SeVT4CtCWe/RYIAymFPwA=="], + + "@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.55.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-cT2MmXySMo58ENv8p6/O6wI/h/gLnD3D6JoajwXFZH6X9jz4hARqUhWpGuQhOgLNXscfZYRQMJvZDtWNzMAIDw=="], + + "@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.55.2", "", { "os": "none", "cpu": "arm64" }, "sha512-sZnyUgGkuzIXaK3jNMPmUIyJrxu/PjmATQrocpGA1WbCPX8H5tfGgRSuYtqBYAvLuIGp8SPRb1O4d1Fkb5fXaQ=="], + + "@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.55.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-sDpFbenhmWjNcEbBcoTV0PWvW5rPJFvu+P7XoTY0YLGRupgLbFY0XPfwIbJOObzO7QgkRDANh65RjhPmgSaAjQ=="], + + "@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.55.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-GvJ03TqqaweWCigtKQVBErw2bEhu1tyfNQbarwr94wCGnczA9HF8wqEe3U/Lfu6EdeNP0p6R+APeHVwEqVxpUQ=="], + + "@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.55.2", "", { "os": "win32", "cpu": "x64" }, "sha512-KvXsBvp13oZz9JGe5NYS7FNizLe99Ny+W8ETsuCyjXiKdiGrcz2/J/N8qxZ/RSwivqjQguug07NLHqrIHrqfYw=="], + + "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.55.2", "", { "os": "win32", "cpu": "x64" }, "sha512-xNO+fksQhsAckRtDSPWaMeT1uIM+JrDRXlerpnWNXhn1TdB3YZ6uKBMBTKP0eX9XtYEP978hHk1f8332i2AW8Q=="], + + "@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="], + + "@sveltejs/acorn-typescript": ["@sveltejs/acorn-typescript@1.0.8", "", { "peerDependencies": { "acorn": "^8.9.0" } }, "sha512-esgN+54+q0NjB0Y/4BomT9samII7jGwNy/2a3wNZbT2A2RpmXsXwUt24LvLhx6jUq2gVk4cWEvcRO6MFQbOfNA=="], + + "@sveltejs/adapter-static": ["@sveltejs/adapter-static@3.0.10", "", { "peerDependencies": { "@sveltejs/kit": "^2.0.0" } }, "sha512-7D9lYFWJmB7zxZyTE/qxjksvMqzMuYrrsyh1f4AlZqeZeACPRySjbC3aFiY55wb1tWUaKOQG9PVbm74JcN2Iew=="], + + "@sveltejs/kit": ["@sveltejs/kit@2.50.0", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@sveltejs/acorn-typescript": "^1.0.5", "@types/cookie": "^0.6.0", "acorn": "^8.14.1", "cookie": "^0.6.0", "devalue": "^5.6.2", "esm-env": "^1.2.2", "kleur": "^4.1.5", "magic-string": "^0.30.5", "mrmime": "^2.0.0", "sade": "^1.8.1", "set-cookie-parser": "^2.6.0", "sirv": "^3.0.0" }, "peerDependencies": { "@opentelemetry/api": "^1.0.0", "@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0", "svelte": "^4.0.0 || ^5.0.0-next.0", "typescript": "^5.3.3", "vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0" }, "optionalPeers": ["@opentelemetry/api", "typescript"], "bin": { "svelte-kit": "svelte-kit.js" } }, "sha512-Hj8sR8O27p2zshFEIJzsvfhLzxga/hWw6tRLnBjMYw70m1aS9BSYCqAUtzDBjRREtX1EvLMYgaC0mYE3Hz4KWA=="], + + "@sveltejs/vite-plugin-svelte": ["@sveltejs/vite-plugin-svelte@4.0.4", "", { "dependencies": { "@sveltejs/vite-plugin-svelte-inspector": "^3.0.0-next.0||^3.0.0", "debug": "^4.3.7", "deepmerge": "^4.3.1", "kleur": "^4.1.5", "magic-string": "^0.30.12", "vitefu": "^1.0.3" }, "peerDependencies": { "svelte": "^5.0.0-next.96 || ^5.0.0", "vite": "^5.0.0" } }, "sha512-0ba1RQ/PHen5FGpdSrW7Y3fAMQjrXantECALeOiOdBdzR5+5vPP6HVZRLmZaQL+W8m++o+haIAKq5qT+MiZ7VA=="], + + "@sveltejs/vite-plugin-svelte-inspector": ["@sveltejs/vite-plugin-svelte-inspector@3.0.1", "", { "dependencies": { "debug": "^4.3.7" }, "peerDependencies": { "@sveltejs/vite-plugin-svelte": "^4.0.0-next.0||^4.0.0", "svelte": "^5.0.0-next.96 || ^5.0.0", "vite": "^5.0.0" } }, "sha512-2CKypmj1sM4GE7HjllT7UKmo4Q6L5xFRd7VMGEWhYnZ+wc6AUVU01IBd7yUi6WnFndEwWoMNOd6e8UjoN0nbvQ=="], + + "@types/cookie": ["@types/cookie@0.6.0", "", {}, "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA=="], + + "@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="], + + "acorn": ["acorn@8.15.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg=="], + + "aria-query": ["aria-query@5.3.2", "", {}, "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw=="], + + "axobject-query": ["axobject-query@4.1.0", "", {}, "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ=="], + + "clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="], + + "cookie": ["cookie@0.6.0", "", {}, "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw=="], + + "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], + + "deepmerge": ["deepmerge@4.3.1", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="], + + "devalue": ["devalue@5.6.2", "", {}, "sha512-nPRkjWzzDQlsejL1WVifk5rvcFi/y1onBRxjaFMjZeR9mFpqu2gmAZ9xUB9/IEanEP/vBtGeGganC/GO1fmufg=="], + + "esbuild": ["esbuild@0.21.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="], + + "esm-env": ["esm-env@1.2.2", "", {}, "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA=="], + + "esrap": ["esrap@2.2.2", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" } }, "sha512-zA6497ha+qKvoWIK+WM9NAh5ni17sKZKhbS5B3PoYbBvaYHZWoS33zmFybmyqpn07RLUxSmn+RCls2/XF+d0oQ=="], + + "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], + + "is-reference": ["is-reference@3.0.3", "", { "dependencies": { "@types/estree": "^1.0.6" } }, "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw=="], + + "kleur": ["kleur@4.1.5", "", {}, "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ=="], + + "locate-character": ["locate-character@3.0.0", "", {}, "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA=="], + + "magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="], + + "mri": ["mri@1.2.0", "", {}, "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="], + + "mrmime": ["mrmime@2.0.1", "", {}, "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ=="], + + "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="], + + "nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="], + + "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="], + + "postcss": ["postcss@8.5.6", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg=="], + + "rollup": ["rollup@4.55.2", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.55.2", "@rollup/rollup-android-arm64": "4.55.2", "@rollup/rollup-darwin-arm64": "4.55.2", "@rollup/rollup-darwin-x64": "4.55.2", "@rollup/rollup-freebsd-arm64": "4.55.2", "@rollup/rollup-freebsd-x64": "4.55.2", "@rollup/rollup-linux-arm-gnueabihf": "4.55.2", "@rollup/rollup-linux-arm-musleabihf": "4.55.2", "@rollup/rollup-linux-arm64-gnu": "4.55.2", "@rollup/rollup-linux-arm64-musl": "4.55.2", "@rollup/rollup-linux-loong64-gnu": "4.55.2", "@rollup/rollup-linux-loong64-musl": "4.55.2", "@rollup/rollup-linux-ppc64-gnu": "4.55.2", "@rollup/rollup-linux-ppc64-musl": "4.55.2", "@rollup/rollup-linux-riscv64-gnu": "4.55.2", "@rollup/rollup-linux-riscv64-musl": "4.55.2", "@rollup/rollup-linux-s390x-gnu": "4.55.2", "@rollup/rollup-linux-x64-gnu": "4.55.2", "@rollup/rollup-linux-x64-musl": "4.55.2", "@rollup/rollup-openbsd-x64": "4.55.2", "@rollup/rollup-openharmony-arm64": "4.55.2", "@rollup/rollup-win32-arm64-msvc": "4.55.2", "@rollup/rollup-win32-ia32-msvc": "4.55.2", "@rollup/rollup-win32-x64-gnu": "4.55.2", "@rollup/rollup-win32-x64-msvc": "4.55.2", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-PggGy4dhwx5qaW+CKBilA/98Ql9keyfnb7lh4SR6shQ91QQQi1ORJ1v4UinkdP2i87OBs9AQFooQylcrrRfIcg=="], + + "sade": ["sade@1.8.1", "", { "dependencies": { "mri": "^1.1.0" } }, "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A=="], + + "set-cookie-parser": ["set-cookie-parser@2.7.2", "", {}, "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw=="], + + "sirv": ["sirv@3.0.2", "", { "dependencies": { "@polka/url": "^1.0.0-next.24", "mrmime": "^2.0.0", "totalist": "^3.0.0" } }, "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g=="], + + "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="], + + "svelte": ["svelte@5.47.1", "", { "dependencies": { "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0", "@sveltejs/acorn-typescript": "^1.0.5", "@types/estree": "^1.0.5", "acorn": "^8.12.1", "aria-query": "^5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", "devalue": "^5.6.2", "esm-env": "^1.2.1", "esrap": "^2.2.1", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", "zimmerframe": "^1.1.2" } }, "sha512-MhSWfWEpG5T57z0Oyfk9D1GhAz/KTZKZZlWtGEsy9zNk2fafpuU7sJQlXNSA8HtvwKxVC9XlDyl5YovXUXjjHA=="], + + "totalist": ["totalist@3.0.1", "", {}, "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ=="], + + "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + + "vite": ["vite@5.4.21", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["@types/node", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": { "vite": "bin/vite.js" } }, "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw=="], + + "vitefu": ["vitefu@1.1.1", "", { "peerDependencies": { "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0-beta.0" }, "optionalPeers": ["vite"] }, "sha512-B/Fegf3i8zh0yFbpzZ21amWzHmuNlLlmJT6n7bu5e+pCHUKQIfXSYokrqOBGEMMe9UG2sostKQF9mml/vYaWJQ=="], + + "zimmerframe": ["zimmerframe@1.1.4", "", {}, "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ=="], + } +} diff --git a/ModeTemplate/frontend/package.json b/ModeTemplate/frontend/package.json new file mode 100644 index 0000000..0ba9091 --- /dev/null +++ b/ModeTemplate/frontend/package.json @@ -0,0 +1,20 @@ +{ + "name": "mode-template-frontend", + "version": "1.0.0", + "type": "module", + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "@sveltejs/kit": "^2.0.0", + "svelte": "^5.0.0" + }, + "devDependencies": { + "@sveltejs/adapter-static": "^3.0.0", + "@sveltejs/vite-plugin-svelte": "^4.0.0", + "typescript": "^5.0.0", + "vite": "^5.0.0" + } +} diff --git a/ModeTemplate/frontend/src/app.html b/ModeTemplate/frontend/src/app.html new file mode 100644 index 0000000..248970b --- /dev/null +++ b/ModeTemplate/frontend/src/app.html @@ -0,0 +1,12 @@ + + + + + + Mode Template + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/ModeTemplate/frontend/src/lib/api.ts b/ModeTemplate/frontend/src/lib/api.ts new file mode 100644 index 0000000..790cf73 --- /dev/null +++ b/ModeTemplate/frontend/src/lib/api.ts @@ -0,0 +1,70 @@ +/** + * API Client Instance + * + * Pre-configured API client for this mode. + */ + +import { STORAGE_KEYS } from './stores/auth.svelte'; + +export interface ApiResponse { + ok: boolean; + status: number; + data?: T; + error?: string; +} + +async function request( + method: string, + path: string, + body?: unknown +): Promise> { + const token = localStorage.getItem(STORAGE_KEYS.PB_TOKEN); + + const headers: Record = { + 'Content-Type': 'application/json', + }; + + if (token) { + headers['Authorization'] = `Bearer ${token}`; + } + + try { + const response = await fetch(path, { + method, + headers, + body: body ? JSON.stringify(body) : undefined, + }); + + const data = response.headers.get('content-type')?.includes('application/json') + ? await response.json() + : await response.text(); + + if (!response.ok) { + return { + ok: false, + status: response.status, + error: typeof data === 'string' ? data : data.message || 'Request failed', + }; + } + + return { + ok: true, + status: response.status, + data: data as T, + }; + } catch (err) { + return { + ok: false, + status: 0, + error: err instanceof Error ? err.message : 'Network error', + }; + } +} + +export const api = { + get: (path: string) => request('GET', path), + post: (path: string, body?: unknown) => request('POST', path, body), + put: (path: string, body?: unknown) => request('PUT', path, body), + patch: (path: string, body?: unknown) => request('PATCH', path, body), + delete: (path: string) => request('DELETE', path), +}; diff --git a/ModeTemplate/frontend/src/lib/stores/auth.svelte.ts b/ModeTemplate/frontend/src/lib/stores/auth.svelte.ts new file mode 100644 index 0000000..bc48cae --- /dev/null +++ b/ModeTemplate/frontend/src/lib/stores/auth.svelte.ts @@ -0,0 +1,79 @@ +/** + * Auth Store (Svelte 5 Runes) + * + * Manages authentication state using Svelte 5 class-based store pattern. + */ + +export const STORAGE_KEYS = { + PB_TOKEN: 'pb_token', + SESSION: 'auth_session', +} as const; + +export interface AuthSession { + email: string; + displayName: string; + pbToken: string; +} + +class AuthStore { + private _session = $state(null); + private _loading = $state(true); + + // Derived state + isAuthenticated = $derived(this._session !== null); + + get session() { return this._session; } + get loading() { return this._loading; } + + user = $derived( + this._session + ? { email: this._session.email, displayName: this._session.displayName } + : null + ); + + constructor() { + // Defer initialization to hydrate() call from browser + } + + /** Call this in onMount to hydrate from localStorage */ + hydrate() { + if (typeof localStorage === 'undefined') return; + + const stored = localStorage.getItem(STORAGE_KEYS.SESSION); + if (stored) { + try { + this._session = JSON.parse(stored) as AuthSession; + } catch { + localStorage.removeItem(STORAGE_KEYS.SESSION); + localStorage.removeItem(STORAGE_KEYS.PB_TOKEN); + } + } + this._loading = false; + } + + login(session: AuthSession) { + if (typeof localStorage !== 'undefined') { + localStorage.setItem(STORAGE_KEYS.SESSION, JSON.stringify(session)); + localStorage.setItem(STORAGE_KEYS.PB_TOKEN, session.pbToken); + } + this._session = session; + this._loading = false; + } + + logout() { + if (typeof localStorage !== 'undefined') { + localStorage.removeItem(STORAGE_KEYS.SESSION); + localStorage.removeItem(STORAGE_KEYS.PB_TOKEN); + } + this._session = null; + } + + /** Redirect to backend auth login */ + redirectToLogin() { + if (typeof window !== 'undefined') { + window.location.href = '/auth/login'; + } + } +} + +export const auth = new AuthStore(); diff --git a/ModeTemplate/frontend/src/routes/+layout.svelte b/ModeTemplate/frontend/src/routes/+layout.svelte new file mode 100644 index 0000000..7c28442 --- /dev/null +++ b/ModeTemplate/frontend/src/routes/+layout.svelte @@ -0,0 +1,67 @@ + + + + + + +
+
+ +
+ +
+ {@render children()} +
+
+ + diff --git a/ModeTemplate/frontend/src/routes/+page.svelte b/ModeTemplate/frontend/src/routes/+page.svelte new file mode 100644 index 0000000..fbfdfc0 --- /dev/null +++ b/ModeTemplate/frontend/src/routes/+page.svelte @@ -0,0 +1,17 @@ + + +

Mode Template

+ +{#if auth.loading} +

Loading...

+{:else if auth.isAuthenticated} +

Welcome, {auth.user?.displayName}!

+

Email: {auth.user?.email}

+{:else} +

Please log in to continue.

+ +{/if} diff --git a/ModeTemplate/frontend/src/routes/callback/+page.svelte b/ModeTemplate/frontend/src/routes/callback/+page.svelte new file mode 100644 index 0000000..820dedb --- /dev/null +++ b/ModeTemplate/frontend/src/routes/callback/+page.svelte @@ -0,0 +1,38 @@ + + +

Authenticating...

+ +{#if error} +

{error}

+ Return home +{:else} +

Please wait...

+{/if} diff --git a/ModeTemplate/frontend/static/.gitkeep b/ModeTemplate/frontend/static/.gitkeep new file mode 100644 index 0000000..e12d700 --- /dev/null +++ b/ModeTemplate/frontend/static/.gitkeep @@ -0,0 +1 @@ +/* Empty file - SvelteKit requires this */ diff --git a/ModeTemplate/frontend/svelte.config.js b/ModeTemplate/frontend/svelte.config.js new file mode 100644 index 0000000..b4ba783 --- /dev/null +++ b/ModeTemplate/frontend/svelte.config.js @@ -0,0 +1,21 @@ +import adapter from '@sveltejs/adapter-static'; +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + preprocess: vitePreprocess(), + kit: { + adapter: adapter({ + pages: 'build', + assets: 'build', + fallback: 'index.html', + precompress: false, + }), + alias: { + '$lib': './src/lib', + '$types': '../types', + }, + }, +}; + +export default config; diff --git a/ModeTemplate/frontend/vite.config.ts b/ModeTemplate/frontend/vite.config.ts new file mode 100644 index 0000000..b8f3941 --- /dev/null +++ b/ModeTemplate/frontend/vite.config.ts @@ -0,0 +1,19 @@ +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [sveltekit()], + server: { + port: 5173, + proxy: { + '/api': { + target: 'http://localhost:3005', + changeOrigin: true, + }, + '/auth': { + target: 'http://localhost:3005', + changeOrigin: true, + }, + }, + }, +}); diff --git a/ModeTemplate/package.json b/ModeTemplate/package.json new file mode 100644 index 0000000..e2dfb84 --- /dev/null +++ b/ModeTemplate/package.json @@ -0,0 +1,17 @@ +{ + "name": "mode-template", + "version": "1.0.0", + "type": "module", + "scripts": { + "dev": "bun run backend/server.ts", + "dev:frontend": "cd frontend && bun run dev", + "dev:all": "bun run dev & bun run dev:frontend" + }, + "dependencies": { + "hono": "^4.0.0" + }, + "devDependencies": { + "bun-types": "latest", + "typescript": "^5.0.0" + } +} diff --git a/ModeTemplate/tsconfig.json b/ModeTemplate/tsconfig.json new file mode 100644 index 0000000..f7e3f22 --- /dev/null +++ b/ModeTemplate/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "types": ["bun-types"] + }, + "include": ["backend/**/*.ts", "types/**/*.ts"] +} diff --git a/ModeTemplate/types/README.md b/ModeTemplate/types/README.md new file mode 100644 index 0000000..304320e --- /dev/null +++ b/ModeTemplate/types/README.md @@ -0,0 +1,51 @@ +# Shared Types + +Common types used by both frontend and backend. Keeps API contracts in sync. + +## Usage + +```typescript +import type { User, ApiResult, PaginatedResponse } from './components/shared-types'; + +// Backend endpoint +app.get('/api/users', async (c): Promise>> => { + const users = await getUsers(); + return c.json({ success: true, data: users }); +}); + +// Frontend call +const result = await api.get>>('/users'); +if (result.ok && result.data?.success) { + const users = result.data.data.items; +} +``` + +## Types Included + +**User/Auth:** +- `User` - User record +- `AuthState` - Frontend auth state + +**API Responses:** +- `SuccessResponse` - `{ success: true, data: T }` +- `ErrorResponse` - `{ success: false, error: string }` +- `ApiResult` - Either success or error +- `PaginatedResponse` - List with pagination metadata + +**Request Params:** +- `PaginationParams` - `{ page?, perPage? }` +- `SortParams` - `{ sort?, order? }` +- `ListParams` - Combined pagination + sort + +**Utility Types:** +- `CreateInput` - Omits id and timestamps for creating +- `UpdateInput` - Partial without id/timestamps for updating + +## Copying to a Mode + +1. Copy `components/shared-types/` to your mode root as `types/` +2. Import from `./types` in both frontend and backend + +## Dependencies + +None - pure TypeScript types. diff --git a/ModeTemplate/types/index.ts b/ModeTemplate/types/index.ts new file mode 100644 index 0000000..d36d9f0 --- /dev/null +++ b/ModeTemplate/types/index.ts @@ -0,0 +1,15 @@ +export type { + User, + AuthState, + SuccessResponse, + ErrorResponse, + ApiResult, + PaginatedResponse, + PaginationParams, + SortParams, + ListParams, + PartialBy, + RequiredBy, + CreateInput, + UpdateInput, +} from './types'; diff --git a/ModeTemplate/types/types.ts b/ModeTemplate/types/types.ts new file mode 100644 index 0000000..7f345ed --- /dev/null +++ b/ModeTemplate/types/types.ts @@ -0,0 +1,87 @@ +/** + * Shared Types + * + * Common types used by both frontend and backend. + * Copy this to any Mode to ensure type consistency. + */ + +// ============================================ +// USER / AUTH +// ============================================ + +export interface User { + id: string; + email: string; + displayName: string; + role?: string; + createdAt?: string; + updatedAt?: string; +} + +export interface AuthState { + isAuthenticated: boolean; + user: User | null; + token: string | null; +} + +// ============================================ +// API RESPONSES +// ============================================ + +/** Standard success response */ +export interface SuccessResponse { + success: true; + data: T; +} + +/** Standard error response */ +export interface ErrorResponse { + success: false; + error: string; + code?: string; +} + +/** Combined response type */ +export type ApiResult = SuccessResponse | ErrorResponse; + +/** Paginated list response */ +export interface PaginatedResponse { + items: T[]; + page: number; + perPage: number; + totalItems: number; + totalPages: number; +} + +// ============================================ +// REQUEST TYPES +// ============================================ + +/** Standard pagination params */ +export interface PaginationParams { + page?: number; + perPage?: number; +} + +/** Standard sort params */ +export interface SortParams { + sort?: string; + order?: 'asc' | 'desc'; +} + +/** Combined list params */ +export type ListParams = PaginationParams & SortParams; + +// ============================================ +// UTILITY TYPES +// ============================================ + +/** Make specific properties optional */ +export type PartialBy = Omit & Partial>; + +/** Make specific properties required */ +export type RequiredBy = T & Required>; + +/** Create/Update types - id is optional for create */ +export type CreateInput = Omit; +export type UpdateInput = Partial>; diff --git a/components/api-client/README.md b/components/api-client/README.md new file mode 100644 index 0000000..bef303f --- /dev/null +++ b/components/api-client/README.md @@ -0,0 +1,59 @@ +# API Client Component + +Frontend helper for making authenticated requests to the backend. + +## Usage + +```typescript +import { createApiClient } from './components/api-client'; +import { STORAGE_KEYS } from './components/auth'; + +// Create client with token getter +const api = createApiClient({ + baseUrl: '/api', // or 'http://localhost:3005/api' + getToken: () => localStorage.getItem(STORAGE_KEYS.PB_TOKEN), +}); + +// Make requests +const result = await api.get('/users'); + +if (result.ok) { + console.log(result.data); // User[] +} else { + console.error(result.error); // Error message +} + +// POST with body +const created = await api.post('/jobs', { + title: 'New Job', + status: 'open', +}); +``` + +## Methods + +- `api.get(path)` - GET request +- `api.post(path, body?)` - POST request +- `api.put(path, body?)` - PUT request +- `api.patch(path, body?)` - PATCH request +- `api.delete(path)` - DELETE request + +## Response Type + +```typescript +interface ApiResponse { + ok: boolean; // true if status 2xx + status: number; // HTTP status code + data?: T; // Response data (if ok) + error?: string; // Error message (if not ok) +} +``` + +## Copying to a Mode + +1. Copy `components/api-client/` to your mode's `frontend/lib/api-client/` +2. Update imports + +## Dependencies + +None - fully self-contained. No package.json needed - inherits from consuming project. diff --git a/components/api-client/api-client.ts b/components/api-client/api-client.ts new file mode 100644 index 0000000..a71ce19 --- /dev/null +++ b/components/api-client/api-client.ts @@ -0,0 +1,97 @@ +/** + * API Client Component + * + * Frontend helper for making authenticated requests to the backend. + * Uses PocketBase token from auth session. + */ + +// Header constants (inline to avoid cross-component dependency) +const HEADERS = { + AUTH: 'Authorization', + CONTENT_TYPE: 'Content-Type', +} as const; + +const CONTENT_TYPES = { + JSON: 'application/json', +} as const; + +function authHeader(token: string): string { + return `Bearer ${token}`; +} + +export interface ApiResponse { + ok: boolean; + status: number; + data?: T; + error?: string; +} + +export interface ApiClientConfig { + baseUrl: string; + getToken: () => string | null; +} + +/** + * Create an API client instance + */ +export function createApiClient(config: ApiClientConfig) { + const { baseUrl, getToken } = config; + + async function request( + method: string, + path: string, + body?: unknown + ): Promise> { + const token = getToken(); + + const headers: Record = { + [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.JSON, + }; + + if (token) { + headers[HEADERS.AUTH] = authHeader(token); + } + + try { + const response = await fetch(`${baseUrl}${path}`, { + method, + headers, + body: body ? JSON.stringify(body) : undefined, + }); + + const data = response.headers.get('content-type')?.includes('application/json') + ? await response.json() + : await response.text(); + + if (!response.ok) { + return { + ok: false, + status: response.status, + error: typeof data === 'string' ? data : data.message || 'Request failed', + }; + } + + return { + ok: true, + status: response.status, + data: data as T, + }; + } catch (err) { + return { + ok: false, + status: 0, + error: err instanceof Error ? err.message : 'Network error', + }; + } + } + + return { + get: (path: string) => request('GET', path), + post: (path: string, body?: unknown) => request('POST', path, body), + put: (path: string, body?: unknown) => request('PUT', path, body), + patch: (path: string, body?: unknown) => request('PATCH', path, body), + delete: (path: string) => request('DELETE', path), + }; +} + +export type ApiClient = ReturnType; diff --git a/components/api-client/index.ts b/components/api-client/index.ts new file mode 100644 index 0000000..89b2712 --- /dev/null +++ b/components/api-client/index.ts @@ -0,0 +1,2 @@ +export { createApiClient } from './api-client'; +export type { ApiResponse, ApiClientConfig, ApiClient } from './api-client'; diff --git a/components/auth/README.md b/components/auth/README.md new file mode 100644 index 0000000..c5bcc14 --- /dev/null +++ b/components/auth/README.md @@ -0,0 +1,84 @@ +# Auth Component + +Microsoft OAuth authentication that returns user info and a PocketBase token. + +**Users must already exist in PocketBase - no user creation. Access denied if user not found.** + +## What it does + +1. Redirects user to Microsoft login +2. Exchanges auth code for access token +3. Gets user's email and display name from Microsoft Graph +4. Checks if user exists in PocketBase (denies access if not) +5. Returns PocketBase auth token + +## Environment Variables Used + +These variables exist in `/home/admin/secrets/.env`: + +``` +MICROSOFT_CLIENT_ID +MICROSOFT_CLIENT_SECRET +MICROSOFT_TENANT_ID +MICROSOFT_REDIRECT_URI +MICROSOFT_SCOPES +PB_URL +``` + +## Usage in Hono Backend + +```typescript +import { Hono } from 'hono'; +import { getAuthUrl, handleCallback, getConfigFromEnv } from './components/auth'; + +const app = new Hono(); +const config = getConfigFromEnv(); + +// Redirect to Microsoft login +app.get('/auth/login', (c) => { + return c.redirect(getAuthUrl(config)); +}); + +// Handle callback from Microsoft +app.get('/auth/callback', async (c) => { + const code = c.req.query('code'); + + if (!code) { + return c.json({ error: 'No authorization code' }, 400); + } + + try { + const result = await handleCallback(code, config); + + // result contains: + // - email: string + // - displayName: string + // - pocketbaseToken: string + + return c.json(result); + } catch (err) { + // User doesn't exist or auth failed + return c.json({ error: String(err) }, 403); + } +}); +``` + +## Copying to a Mode + +1. Copy the entire `components/auth/` folder to your mode's `backend/modules/auth/` +2. Update imports in your server +3. Environment variables are loaded from secrets at runtime + +## Dependencies + +None - uses native fetch API (Bun/Node 18+). No package.json needed - inherits from consuming project. + +## Returns + +```typescript +interface AuthResult { + email: string; // User's email from Microsoft + displayName: string; // User's display name from Microsoft + pocketbaseToken: string; // Auth token for PocketBase API calls +} +``` diff --git a/components/auth/index.ts b/components/auth/index.ts new file mode 100644 index 0000000..6857c77 --- /dev/null +++ b/components/auth/index.ts @@ -0,0 +1,28 @@ +export { + getAuthUrl, + handleCallback, + exchangeCodeForToken, + getMicrosoftUserInfo, + getPocketBaseToken, + getConfigFromEnv, +} from './microsoft-oauth'; + +export type { + AuthResult, + OAuthConfig +} from './microsoft-oauth'; + +export { + HEADERS, + CONTENT_TYPES, + STORAGE_KEYS, + pbAuthHeader, + pbHeaders, + isSessionExpired, +} from './types'; + +export type { + MicrosoftTokens, + PocketBaseTokens, + AuthSession, +} from './types'; diff --git a/components/auth/microsoft-oauth.ts b/components/auth/microsoft-oauth.ts new file mode 100644 index 0000000..9a6c3b2 --- /dev/null +++ b/components/auth/microsoft-oauth.ts @@ -0,0 +1,208 @@ +/** + * Microsoft OAuth Module + * + * Handles Microsoft OAuth flow to authenticate users and retrieve: + * - User's email + * - User's display name + * - PocketBase auth token (user must already exist) + * + * Environment Variables Used: + * - MICROSOFT_CLIENT_ID + * - MICROSOFT_CLIENT_SECRET + * - MICROSOFT_TENANT_ID + * - MICROSOFT_REDIRECT_URI + * - MICROSOFT_SCOPES + * - PB_URL + */ + +interface MicrosoftTokenResponse { + access_token: string; + token_type: string; + expires_in: number; + scope: string; + refresh_token?: string; +} + +interface MicrosoftUserInfo { + id: string; + displayName: string; + mail: string; + userPrincipalName: string; +} + +export interface AuthResult { + email: string; + displayName: string; + pocketbaseToken: string; +} + +export interface OAuthConfig { + clientId: string; + clientSecret: string; + tenantId: string; + redirectUri: string; + scopes: string; + pbUrl: string; +} + +/** + * Build config from process.env + */ +export function getConfigFromEnv(): OAuthConfig { + const clientId = process.env.MICROSOFT_CLIENT_ID; + const clientSecret = process.env.MICROSOFT_CLIENT_SECRET; + const tenantId = process.env.MICROSOFT_TENANT_ID; + const redirectUri = process.env.MICROSOFT_REDIRECT_URI; + const scopes = process.env.MICROSOFT_SCOPES; + const pbUrl = process.env.PB_URL; + + if (!clientId || !clientSecret || !tenantId || !redirectUri || !scopes || !pbUrl) { + throw new Error('Missing required OAuth environment variables'); + } + + return { clientId, clientSecret, tenantId, redirectUri, scopes, pbUrl }; +} + +/** + * Generate the Microsoft OAuth authorization URL + */ +export function getAuthUrl(config: OAuthConfig): string { + const params = new URLSearchParams({ + client_id: config.clientId, + response_type: 'code', + redirect_uri: config.redirectUri, + response_mode: 'query', + scope: config.scopes, + state: crypto.randomUUID(), + }); + + return `https://login.microsoftonline.com/${config.tenantId}/oauth2/v2.0/authorize?${params}`; +} + +/** + * Exchange authorization code for access token + */ +export async function exchangeCodeForToken( + code: string, + config: OAuthConfig +): Promise { + const response = await fetch( + `https://login.microsoftonline.com/${config.tenantId}/oauth2/v2.0/token`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: new URLSearchParams({ + client_id: config.clientId, + client_secret: config.clientSecret, + code, + redirect_uri: config.redirectUri, + grant_type: 'authorization_code', + scope: config.scopes, + }), + } + ); + + if (!response.ok) { + const error = await response.text(); + throw new Error(`Token exchange failed: ${error}`); + } + + return response.json(); +} + +/** + * Get user info from Microsoft Graph API + */ +export async function getMicrosoftUserInfo( + accessToken: string +): Promise { + const response = await fetch('https://graph.microsoft.com/v1.0/me', { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); + + if (!response.ok) { + const error = await response.text(); + throw new Error(`Failed to get user info: ${error}`); + } + + return response.json(); +} + +/** + * Authenticate existing user with PocketBase + * User MUST already exist - no user creation + */ +export async function getPocketBaseToken( + email: string, + pbUrl: string +): Promise { + // Look up user by email - user must exist + const searchResponse = await fetch( + `${pbUrl}/api/collections/users/records?filter=(email='${encodeURIComponent(email)}')`, + { + headers: { + 'Content-Type': 'application/json', + }, + } + ); + + if (!searchResponse.ok) { + throw new Error('Failed to query PocketBase'); + } + + const searchData = await searchResponse.json(); + + if (!searchData.items || searchData.items.length === 0) { + throw new Error('Access denied: User does not exist'); + } + + // User exists - authenticate via OAuth + const authResponse = await fetch(`${pbUrl}/api/collections/users/auth-with-oauth2`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + provider: 'microsoft', + }), + }); + + if (!authResponse.ok) { + const error = await authResponse.text(); + throw new Error(`PocketBase auth failed: ${error}`); + } + + const data = await authResponse.json(); + return data.token; +} + +/** + * Complete OAuth flow: code -> user info + PocketBase token + * Denies access if user doesn't exist in PocketBase + */ +export async function handleCallback( + code: string, + config: OAuthConfig +): Promise { + // 1. Exchange code for Microsoft access token + const tokenResponse = await exchangeCodeForToken(code, config); + + // 2. Get user info from Microsoft Graph + const userInfo = await getMicrosoftUserInfo(tokenResponse.access_token); + + const email = userInfo.mail || userInfo.userPrincipalName; + const displayName = userInfo.displayName; + + // 3. Get PocketBase auth token (user must exist) + const pocketbaseToken = await getPocketBaseToken(email, config.pbUrl); + + return { + email, + displayName, + pocketbaseToken, + }; +} diff --git a/components/auth/types.ts b/components/auth/types.ts new file mode 100644 index 0000000..9b32e5f --- /dev/null +++ b/components/auth/types.ts @@ -0,0 +1,99 @@ +/** + * Auth Constants & Types + * + * Standard naming conventions for auth-related values. + * Use these throughout all modes to maintain consistency. + */ + +// ============================================ +// TOKEN TYPES +// ============================================ + +/** Token received from Microsoft OAuth */ +export interface MicrosoftTokens { + accessToken: string; + refreshToken?: string; + expiresIn: number; +} + +/** Token received from PocketBase */ +export interface PocketBaseTokens { + token: string; + // PB tokens don't have separate refresh - they expire and re-auth is needed +} + +/** Combined auth state after successful login */ +export interface AuthSession { + email: string; + displayName: string; + pbToken: string; // PocketBase auth token + msAccessToken?: string; // Microsoft access token (if needed for Graph API calls) + expiresAt?: number; // Unix timestamp when session expires +} + +// ============================================ +// HEADER NAMES +// ============================================ + +export const HEADERS = { + /** Authorization header for PocketBase API calls */ + PB_AUTH: 'Authorization', + + /** Content type for JSON requests */ + CONTENT_TYPE: 'Content-Type', +} as const; + +// ============================================ +// HEADER VALUES +// ============================================ + +export const CONTENT_TYPES = { + JSON: 'application/json', + FORM: 'application/x-www-form-urlencoded', +} as const; + +// ============================================ +// COOKIE/STORAGE KEYS +// ============================================ + +export const STORAGE_KEYS = { + /** PocketBase token storage key */ + PB_TOKEN: 'pb_token', + + /** Session data storage key */ + SESSION: 'auth_session', +} as const; + +// ============================================ +// HELPER FUNCTIONS +// ============================================ + +/** + * Create Authorization header value for PocketBase + */ +export function pbAuthHeader(token: string): string { + return `Bearer ${token}`; +} + +/** + * Create headers object for PocketBase API calls + */ +export function pbHeaders(token?: string): Record { + const headers: Record = { + [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.JSON, + }; + + if (token) { + headers[HEADERS.PB_AUTH] = pbAuthHeader(token); + } + + return headers; +} + +/** + * Check if session is expired + */ +export function isSessionExpired(session: AuthSession): boolean { + if (!session.expiresAt) return false; + return Date.now() > session.expiresAt; +} diff --git a/components/shared-types/README.md b/components/shared-types/README.md new file mode 100644 index 0000000..304320e --- /dev/null +++ b/components/shared-types/README.md @@ -0,0 +1,51 @@ +# Shared Types + +Common types used by both frontend and backend. Keeps API contracts in sync. + +## Usage + +```typescript +import type { User, ApiResult, PaginatedResponse } from './components/shared-types'; + +// Backend endpoint +app.get('/api/users', async (c): Promise>> => { + const users = await getUsers(); + return c.json({ success: true, data: users }); +}); + +// Frontend call +const result = await api.get>>('/users'); +if (result.ok && result.data?.success) { + const users = result.data.data.items; +} +``` + +## Types Included + +**User/Auth:** +- `User` - User record +- `AuthState` - Frontend auth state + +**API Responses:** +- `SuccessResponse` - `{ success: true, data: T }` +- `ErrorResponse` - `{ success: false, error: string }` +- `ApiResult` - Either success or error +- `PaginatedResponse` - List with pagination metadata + +**Request Params:** +- `PaginationParams` - `{ page?, perPage? }` +- `SortParams` - `{ sort?, order? }` +- `ListParams` - Combined pagination + sort + +**Utility Types:** +- `CreateInput` - Omits id and timestamps for creating +- `UpdateInput` - Partial without id/timestamps for updating + +## Copying to a Mode + +1. Copy `components/shared-types/` to your mode root as `types/` +2. Import from `./types` in both frontend and backend + +## Dependencies + +None - pure TypeScript types. diff --git a/components/shared-types/index.ts b/components/shared-types/index.ts new file mode 100644 index 0000000..d36d9f0 --- /dev/null +++ b/components/shared-types/index.ts @@ -0,0 +1,15 @@ +export type { + User, + AuthState, + SuccessResponse, + ErrorResponse, + ApiResult, + PaginatedResponse, + PaginationParams, + SortParams, + ListParams, + PartialBy, + RequiredBy, + CreateInput, + UpdateInput, +} from './types'; diff --git a/components/shared-types/types.ts b/components/shared-types/types.ts new file mode 100644 index 0000000..7f345ed --- /dev/null +++ b/components/shared-types/types.ts @@ -0,0 +1,87 @@ +/** + * Shared Types + * + * Common types used by both frontend and backend. + * Copy this to any Mode to ensure type consistency. + */ + +// ============================================ +// USER / AUTH +// ============================================ + +export interface User { + id: string; + email: string; + displayName: string; + role?: string; + createdAt?: string; + updatedAt?: string; +} + +export interface AuthState { + isAuthenticated: boolean; + user: User | null; + token: string | null; +} + +// ============================================ +// API RESPONSES +// ============================================ + +/** Standard success response */ +export interface SuccessResponse { + success: true; + data: T; +} + +/** Standard error response */ +export interface ErrorResponse { + success: false; + error: string; + code?: string; +} + +/** Combined response type */ +export type ApiResult = SuccessResponse | ErrorResponse; + +/** Paginated list response */ +export interface PaginatedResponse { + items: T[]; + page: number; + perPage: number; + totalItems: number; + totalPages: number; +} + +// ============================================ +// REQUEST TYPES +// ============================================ + +/** Standard pagination params */ +export interface PaginationParams { + page?: number; + perPage?: number; +} + +/** Standard sort params */ +export interface SortParams { + sort?: string; + order?: 'asc' | 'desc'; +} + +/** Combined list params */ +export type ListParams = PaginationParams & SortParams; + +// ============================================ +// UTILITY TYPES +// ============================================ + +/** Make specific properties optional */ +export type PartialBy = Omit & Partial>; + +/** Make specific properties required */ +export type RequiredBy = T & Required>; + +/** Create/Update types - id is optional for create */ +export type CreateInput = Omit; +export type UpdateInput = Partial>;