From 9e3cfa5142ac04ca310c0c683b5b7a0895478522 Mon Sep 17 00:00:00 2001 From: BCsabaEngine Date: Sun, 15 Mar 2026 22:43:23 +0100 Subject: [PATCH 1/4] fix: security issues --- src/plugins/analytics.ts | 8 +++++++- src/plugins/autosave.ts | 3 ++- src/plugins/devtools.ts | 5 ++++- src/plugins/history.ts | 7 ++++++- src/plugins/persist.ts | 32 +++++++++++++++++++++++++++----- src/plugins/sync.ts | 26 +++++++++++++++++++++----- src/plugins/undo-redo.ts | 14 ++++++++++++-- src/state.svelte.ts | 13 ++++++++++--- 8 files changed, 89 insertions(+), 19 deletions(-) diff --git a/src/plugins/analytics.ts b/src/plugins/analytics.ts index 8c5a92c..2c95f97 100644 --- a/src/plugins/analytics.ts +++ b/src/plugins/analytics.ts @@ -11,6 +11,7 @@ export type AnalyticsOptions = { batchSize?: number; flushInterval?: number; include?: AnalyticsEvent['type'][]; + redact?: string[]; }; export function analyticsPlugin>( @@ -45,7 +46,12 @@ export function analyticsPlugin>( }, onChange(event) { - addEvent('change', { property: event.property, currentValue: event.currentValue, oldValue: event.oldValue }); + const isRedacted = options.redact?.includes(event.property); + addEvent('change', { + property: event.property, + currentValue: isRedacted ? '[redacted]' : event.currentValue, + oldValue: isRedacted ? '[redacted]' : event.oldValue + }); }, onValidation(errors) { diff --git a/src/plugins/autosave.ts b/src/plugins/autosave.ts index d10e975..9532666 100644 --- a/src/plugins/autosave.ts +++ b/src/plugins/autosave.ts @@ -83,7 +83,8 @@ export function autosavePlugin>( const shouldSave = !onlyWhenDirty || get(context.state.isDirty); if (shouldSave) try { - options.save(context.data); + const result = options.save(context.data); + if (result instanceof Promise) result.catch((error: unknown) => options.onError?.(error)); } catch (error) { options.onError?.(error); } diff --git a/src/plugins/devtools.ts b/src/plugins/devtools.ts index ede281a..1cb48c4 100644 --- a/src/plugins/devtools.ts +++ b/src/plugins/devtools.ts @@ -5,6 +5,7 @@ export type DevtoolsOptions = { collapsed?: boolean; logValidation?: boolean; enabled?: boolean; + logValues?: boolean; }; const isProduction = (): boolean => { @@ -19,6 +20,7 @@ export function devtoolsPlugin>(options?: Devt const name = options?.name ?? 'svstate'; const collapsed = options?.collapsed ?? true; const logValidation = options?.logValidation ?? false; + const logValues = options?.logValues ?? false; const enabled = options?.enabled ?? !isProduction(); const log = (label: string, ...arguments_: unknown[]) => { @@ -34,7 +36,8 @@ export function devtoolsPlugin>(options?: Devt name: 'devtools', onChange(event) { - log('change', { property: event.property, from: event.oldValue, to: event.currentValue }); + if (logValues) log('change', { property: event.property, from: event.oldValue, to: event.currentValue }); + else log('change', { property: event.property }); }, onValidation(errors) { diff --git a/src/plugins/history.ts b/src/plugins/history.ts index 3f95f71..40da89a 100644 --- a/src/plugins/history.ts +++ b/src/plugins/history.ts @@ -1,5 +1,7 @@ import type { PluginContext, SvStatePlugin } from '../plugin'; +const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']); + export type HistoryOptions = { fields: Record; mode?: 'push' | 'replace'; @@ -29,10 +31,12 @@ const setValueAtPath = (target: Record, path: string, value: un let current: Record = target; for (let index = 0; index < parts.length - 1; index++) { const part = parts[index]!; + if (DANGEROUS_KEYS.has(part)) return; if (current[part] === undefined || current[part] === null) current[part] = {}; current = current[part] as Record; } - current[parts.at(-1)!] = value; + const lastPart = parts.at(-1)!; + if (!DANGEROUS_KEYS.has(lastPart)) current[lastPart] = value; }; export function historyPlugin>(options: HistoryOptions): HistoryPluginInstance { @@ -47,6 +51,7 @@ export function historyPlugin>(options: Histor if (!context || typeof window === 'undefined') return; const parameters = new URLSearchParams(window.location.search); for (const [stateField, urlParameter] of Object.entries(options.fields)) { + if (stateField.split('.').some((part) => DANGEROUS_KEYS.has(part))) continue; const parameterValue = parameters.get(urlParameter); if (parameterValue !== null) { const value = deserialize(parameterValue, stateField); diff --git a/src/plugins/persist.ts b/src/plugins/persist.ts index 27295b6..429dc13 100644 --- a/src/plugins/persist.ts +++ b/src/plugins/persist.ts @@ -1,5 +1,19 @@ import type { SvStatePlugin } from '../plugin'; +const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']); + +const isPlainObject = (value: unknown): value is Record => + value !== null && typeof value === 'object' && !Array.isArray(value); + +const isValidStorageFormat = (value: unknown): value is StorageFormat => + isPlainObject(value) && + typeof (value as StorageFormat).version === 'number' && + isPlainObject((value as StorageFormat).data); + +const safeMerge = (target: Record, source: Record): void => { + for (const key of Object.keys(source)) if (!DANGEROUS_KEYS.has(key)) target[key] = source[key]; +}; + export type PersistOptions = { key: string; storage?: { @@ -34,10 +48,12 @@ const setValueAtPath = (target: Record, path: string, value: un let current: Record = target; for (let index = 0; index < parts.length - 1; index++) { const part = parts[index]!; + if (DANGEROUS_KEYS.has(part)) return; if (current[part] === undefined || current[part] === null) current[part] = {}; current = current[part] as Record; } - current[parts.at(-1)!] = value; + const lastPart = parts.at(-1)!; + if (!DANGEROUS_KEYS.has(lastPart)) current[lastPart] = value; }; const filterData = (data: Record, include?: string[], exclude?: string[]): Record => { @@ -109,11 +125,17 @@ export function persistPlugin>( if (!raw) return; try { - let parsed = JSON.parse(raw) as StorageFormat; - if (options.migrate && parsed.version !== version) - parsed = { version, data: options.migrate(parsed.data, parsed.version) as Record }; + const rawParsed: unknown = JSON.parse(raw); + if (!isValidStorageFormat(rawParsed)) return; + + let parsed: StorageFormat = rawParsed; + if (options.migrate && parsed.version !== version) { + const migrated = options.migrate(parsed.data, parsed.version); + if (!isPlainObject(migrated)) return; + parsed = { version, data: migrated }; + } - Object.assign(context.data, parsed.data); + safeMerge(context.data as unknown as Record, parsed.data); restored = true; } catch { // Invalid stored data — ignore diff --git a/src/plugins/sync.ts b/src/plugins/sync.ts index 678d8b9..0c45a84 100644 --- a/src/plugins/sync.ts +++ b/src/plugins/sync.ts @@ -1,5 +1,14 @@ import type { PluginContext, SvStatePlugin } from '../plugin'; +const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']); + +const isPlainObject = (value: unknown): value is Record => + value !== null && typeof value === 'object' && !Array.isArray(value); + +const safeMerge = (target: Record, source: Record): void => { + for (const key of Object.keys(source)) if (!DANGEROUS_KEYS.has(key)) target[key] = source[key]; +}; + export type SyncOptions = { key: string; throttle?: number; @@ -18,6 +27,7 @@ export function syncPlugin>(options: SyncOptio let context: PluginContext | undefined; let isReceiving = false; let pendingTimeout: ReturnType | undefined; + let lastReceivedAt = 0; const broadcast = () => { if (!channel || !context) return; @@ -50,11 +60,17 @@ export function syncPlugin>(options: SyncOptio channel = new BroadcastChannel(options.key); channel.addEventListener('message', (event: MessageEvent) => { if (!context || merge === 'ignore') return; - if (event.data?.type === 'sync') { - isReceiving = true; - Object.assign(context.data, event.data.data); - isReceiving = false; - } + if (event.data?.type !== 'sync') return; + + const now = Date.now(); + if (now - lastReceivedAt < throttleMs) return; + lastReceivedAt = now; + + if (!isPlainObject(event.data.data)) return; + + isReceiving = true; + safeMerge(context.data as unknown as Record, event.data.data); + isReceiving = false; }); }, diff --git a/src/plugins/undo-redo.ts b/src/plugins/undo-redo.ts index 5df2d06..52a762c 100644 --- a/src/plugins/undo-redo.ts +++ b/src/plugins/undo-redo.ts @@ -3,13 +3,19 @@ import { get, type Readable, writable } from 'svelte/store'; import type { PluginContext, SvStatePlugin } from '../plugin'; import type { Snapshot } from '../state.svelte'; +export type UndoRedoOptions = { + maxRedoStack?: number; +}; + export type UndoRedoPluginInstance> = SvStatePlugin & { redo(): void; canRedo(): boolean; redoStack: Readable[]>; }; -export function undoRedoPlugin>(): UndoRedoPluginInstance { +export function undoRedoPlugin>( + options?: UndoRedoOptions +): UndoRedoPluginInstance { const redoStore = writable[]>([]); let cachedSnapshots: Snapshot[] = []; let context: PluginContext | undefined; @@ -77,7 +83,11 @@ export function undoRedoPlugin>(): UndoRedoPlu // With the refactored approach, previousTipSnapshot is set by the subscription // before cachedSnapshots is updated. We push that to the redo stack. if (previousTipSnapshot) { - redoStore.update((stack) => [...stack, previousTipSnapshot!]); + redoStore.update((stack) => { + const updated = [...stack, previousTipSnapshot!]; + const max = options?.maxRedoStack; + return max && max > 0 ? updated.slice(-max) : updated; + }); previousTipSnapshot = undefined; } }, diff --git a/src/state.svelte.ts b/src/state.svelte.ts index 8f8602b..2a5808f 100644 --- a/src/state.svelte.ts +++ b/src/state.svelte.ts @@ -65,12 +65,15 @@ const checkHasErrors = (validator: Validator): boolean => Object.values(validator).some((item) => (typeof item === 'string' ? !!item : checkHasErrors(item))); const hasAnyErrors = ($errors: Validator | undefined): boolean => !!$errors && checkHasErrors($errors); +const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']); + const deepClone = (object: T): T => { if (object === null || typeof object !== 'object') return object; if (object instanceof Date) return new Date(object) as T; if (Array.isArray(object)) return object.map((item) => deepClone(item)) as T; const cloned = Object.create(Object.getPrototypeOf(object)) as T; - for (const key of Object.keys(object)) cloned[key as keyof T] = deepClone(object[key as keyof T]); + for (const key of Object.keys(object)) + if (!DANGEROUS_KEYS.has(key)) cloned[key as keyof T] = deepClone(object[key as keyof T]); return cloned; }; @@ -306,8 +309,12 @@ export function createSvState, V extends Valid [path]: error })); } catch (error) { - // Ignore abort errors, re-throw others - if (error instanceof Error && error.name !== 'AbortError') throw error; + if (error instanceof Error && error.name === 'AbortError') return; + // Store unexpected validator errors rather than re-throwing + if (!controller.signal.aborted) { + const message = error instanceof Error ? error.message : 'Async validation error'; + asyncErrorsStore.update(($asyncErrors) => ({ ...$asyncErrors, [path]: message })); + } } finally { asyncValidationTrackers.delete(path); asyncValidatingSet.update(($set) => { From c6e606b6643e61a1466ae7380071a65ff06951e9 Mon Sep 17 00:00:00 2001 From: BCsabaEngine Date: Sun, 15 Mar 2026 22:43:29 +0100 Subject: [PATCH 2/4] chore: demo deps --- demo/package-lock.json | 269 ++++++++++++++++++++--------------------- demo/package.json | 2 +- 2 files changed, 130 insertions(+), 141 deletions(-) diff --git a/demo/package-lock.json b/demo/package-lock.json index 1e118bd..23f3eea 100644 --- a/demo/package-lock.json +++ b/demo/package-lock.json @@ -8,7 +8,7 @@ "name": "svstate-demo", "version": "1.0.0", "dependencies": { - "svelte": "^5.53.9", + "svelte": "^5.53.12", "zod": "^4.3.6" }, "devDependencies": { @@ -63,9 +63,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz", - "integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", + "integrity": "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q==", "cpu": [ "ppc64" ], @@ -80,9 +80,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz", - "integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.4.tgz", + "integrity": "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ==", "cpu": [ "arm" ], @@ -97,9 +97,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz", - "integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.4.tgz", + "integrity": "sha512-gdLscB7v75wRfu7QSm/zg6Rx29VLdy9eTr2t44sfTW7CxwAtQghZ4ZnqHk3/ogz7xao0QAgrkradbBzcqFPasw==", "cpu": [ "arm64" ], @@ -114,9 +114,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz", - "integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.4.tgz", + "integrity": "sha512-PzPFnBNVF292sfpfhiyiXCGSn9HZg5BcAz+ivBuSsl6Rk4ga1oEXAamhOXRFyMcjwr2DVtm40G65N3GLeH1Lvw==", "cpu": [ "x64" ], @@ -131,9 +131,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz", - "integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.4.tgz", + "integrity": "sha512-b7xaGIwdJlht8ZFCvMkpDN6uiSmnxxK56N2GDTMYPr2/gzvfdQN8rTfBsvVKmIVY/X7EM+/hJKEIbbHs9oA4tQ==", "cpu": [ "arm64" ], @@ -148,9 +148,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz", - "integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.4.tgz", + "integrity": "sha512-sR+OiKLwd15nmCdqpXMnuJ9W2kpy0KigzqScqHI3Hqwr7IXxBp3Yva+yJwoqh7rE8V77tdoheRYataNKL4QrPw==", "cpu": [ "x64" ], @@ -165,9 +165,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz", - "integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.4.tgz", + "integrity": "sha512-jnfpKe+p79tCnm4GVav68A7tUFeKQwQyLgESwEAUzyxk/TJr4QdGog9sqWNcUbr/bZt/O/HXouspuQDd9JxFSw==", "cpu": [ "arm64" ], @@ -182,9 +182,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz", - "integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.4.tgz", + "integrity": "sha512-2kb4ceA/CpfUrIcTUl1wrP/9ad9Atrp5J94Lq69w7UwOMolPIGrfLSvAKJp0RTvkPPyn6CIWrNy13kyLikZRZQ==", "cpu": [ "x64" ], @@ -199,9 +199,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz", - "integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.4.tgz", + "integrity": "sha512-aBYgcIxX/wd5n2ys0yESGeYMGF+pv6g0DhZr3G1ZG4jMfruU9Tl1i2Z+Wnj9/KjGz1lTLCcorqE2viePZqj4Eg==", "cpu": [ "arm" ], @@ -216,9 +216,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz", - "integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.4.tgz", + "integrity": "sha512-7nQOttdzVGth1iz57kxg9uCz57dxQLHWxopL6mYuYthohPKEK0vU0C3O21CcBK6KDlkYVcnDXY099HcCDXd9dA==", "cpu": [ "arm64" ], @@ -233,9 +233,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz", - "integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.4.tgz", + "integrity": "sha512-oPtixtAIzgvzYcKBQM/qZ3R+9TEUd1aNJQu0HhGyqtx6oS7qTpvjheIWBbes4+qu1bNlo2V4cbkISr8q6gRBFA==", "cpu": [ "ia32" ], @@ -250,9 +250,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz", - "integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.4.tgz", + "integrity": "sha512-8mL/vh8qeCoRcFH2nM8wm5uJP+ZcVYGGayMavi8GmRJjuI3g1v6Z7Ni0JJKAJW+m0EtUuARb6Lmp4hMjzCBWzA==", "cpu": [ "loong64" ], @@ -267,9 +267,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz", - "integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.4.tgz", + "integrity": "sha512-1RdrWFFiiLIW7LQq9Q2NES+HiD4NyT8Itj9AUeCl0IVCA459WnPhREKgwrpaIfTOe+/2rdntisegiPWn/r/aAw==", "cpu": [ "mips64el" ], @@ -284,9 +284,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz", - "integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.4.tgz", + "integrity": "sha512-tLCwNG47l3sd9lpfyx9LAGEGItCUeRCWeAx6x2Jmbav65nAwoPXfewtAdtbtit/pJFLUWOhpv0FpS6GQAmPrHA==", "cpu": [ "ppc64" ], @@ -301,9 +301,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz", - "integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.4.tgz", + "integrity": "sha512-BnASypppbUWyqjd1KIpU4AUBiIhVr6YlHx/cnPgqEkNoVOhHg+YiSVxM1RLfiy4t9cAulbRGTNCKOcqHrEQLIw==", "cpu": [ "riscv64" ], @@ -318,9 +318,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz", - "integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.4.tgz", + "integrity": "sha512-+eUqgb/Z7vxVLezG8bVB9SfBie89gMueS+I0xYh2tJdw3vqA/0ImZJ2ROeWwVJN59ihBeZ7Tu92dF/5dy5FttA==", "cpu": [ "s390x" ], @@ -335,9 +335,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz", - "integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.4.tgz", + "integrity": "sha512-S5qOXrKV8BQEzJPVxAwnryi2+Iq5pB40gTEIT69BQONqR7JH1EPIcQ/Uiv9mCnn05jff9umq/5nqzxlqTOg9NA==", "cpu": [ "x64" ], @@ -352,9 +352,9 @@ } }, "node_modules/@esbuild/netbsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz", - "integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.4.tgz", + "integrity": "sha512-xHT8X4sb0GS8qTqiwzHqpY00C95DPAq7nAwX35Ie/s+LO9830hrMd3oX0ZMKLvy7vsonee73x0lmcdOVXFzd6Q==", "cpu": [ "arm64" ], @@ -369,9 +369,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz", - "integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.4.tgz", + "integrity": "sha512-RugOvOdXfdyi5Tyv40kgQnI0byv66BFgAqjdgtAKqHoZTbTF2QqfQrFwa7cHEORJf6X2ht+l9ABLMP0dnKYsgg==", "cpu": [ "x64" ], @@ -386,9 +386,9 @@ } }, "node_modules/@esbuild/openbsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz", - "integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.4.tgz", + "integrity": "sha512-2MyL3IAaTX+1/qP0O1SwskwcwCoOI4kV2IBX1xYnDDqthmq5ArrW94qSIKCAuRraMgPOmG0RDTA74mzYNQA9ow==", "cpu": [ "arm64" ], @@ -403,9 +403,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz", - "integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.4.tgz", + "integrity": "sha512-u8fg/jQ5aQDfsnIV6+KwLOf1CmJnfu1ShpwqdwC0uA7ZPwFws55Ngc12vBdeUdnuWoQYx/SOQLGDcdlfXhYmXQ==", "cpu": [ "x64" ], @@ -420,9 +420,9 @@ } }, "node_modules/@esbuild/openharmony-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz", - "integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.4.tgz", + "integrity": "sha512-JkTZrl6VbyO8lDQO3yv26nNr2RM2yZzNrNHEsj9bm6dOwwu9OYN28CjzZkH57bh4w0I2F7IodpQvUAEd1mbWXg==", "cpu": [ "arm64" ], @@ -437,9 +437,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz", - "integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.4.tgz", + "integrity": "sha512-/gOzgaewZJfeJTlsWhvUEmUG4tWEY2Spp5M20INYRg2ZKl9QPO3QEEgPeRtLjEWSW8FilRNacPOg8R1uaYkA6g==", "cpu": [ "x64" ], @@ -454,9 +454,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz", - "integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.4.tgz", + "integrity": "sha512-Z9SExBg2y32smoDQdf1HRwHRt6vAHLXcxD2uGgO/v2jK7Y718Ix4ndsbNMU/+1Qiem9OiOdaqitioZwxivhXYg==", "cpu": [ "arm64" ], @@ -471,9 +471,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz", - "integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.4.tgz", + "integrity": "sha512-DAyGLS0Jz5G5iixEbMHi5KdiApqHBWMGzTtMiJ72ZOLhbu/bzxgAe8Ue8CTS3n3HbIUHQz/L51yMdGMeoxXNJw==", "cpu": [ "ia32" ], @@ -488,9 +488,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz", - "integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.4.tgz", + "integrity": "sha512-+knoa0BDoeXgkNvvV1vvbZX4+hizelrkwmGJBdT17t8FNPwG2lKemmuMZlmaNQ3ws3DKKCxpb4zRZEIp3UxFCg==", "cpu": [ "x64" ], @@ -1060,7 +1060,6 @@ "integrity": "sha512-ou/d51QSdTyN26D7h6dSpusAKaZkAiGM55/AKYi+9AGZw7q85hElbjK3kEyzXHhLSnRISHOYzVge6x0jRZ7DXA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@sveltejs/vite-plugin-svelte-inspector": "^5.0.0", "deepmerge": "^4.3.1", @@ -1448,7 +1447,6 @@ "integrity": "sha512-XZzOmihLIr8AD1b9hL9ccNMzEMWt/dE2u7NyTY9jJG6YNiNthaD5XtUHVF2uCXZ15ng+z2hT3MVuxnUYhq6k1g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.57.0", "@typescript-eslint/types": "8.57.0", @@ -1554,7 +1552,6 @@ "version": "8.57.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.57.0.tgz", "integrity": "sha512-dTLI8PEXhjUC7B9Kre+u0XznO696BhXcTlOn0/6kf1fHaQW8+VjJAVHJ3eTI14ZapTxdkOmc80HblPQLaEeJdg==", - "dev": true, "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1652,7 +1649,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1716,9 +1712,9 @@ } }, "node_modules/baseline-browser-mapping": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.0.tgz", - "integrity": "sha512-lIyg0szRfYbiy67j9KN8IyeD7q7hcmqnJ1ddWmNt19ItGpNN64mnllmxUNFIOdOm6by97jlL6wfpTTJrmnjWAA==", + "version": "2.10.8", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.8.tgz", + "integrity": "sha512-PCLz/LXGBsNTErbtB6i5u4eLpHeMfi93aUv5duMmj6caNu6IphS4q6UevDnL36sZQv9lrP11dbPKGMaXPwMKfQ==", "dev": true, "license": "Apache-2.0", "bin": { @@ -1761,7 +1757,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -1790,9 +1785,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001777", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001777.tgz", - "integrity": "sha512-tmN+fJxroPndC74efCdp12j+0rk0RHwV5Jwa1zWaFVyw2ZxAuPeG8ZgWC3Wz7uSjT3qMRQ5XHZ4COgQmsCMJAQ==", + "version": "1.0.30001779", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001779.tgz", + "integrity": "sha512-U5og2PN7V4DMgF50YPNtnZJGWVLFjjsN3zb6uMT5VGYIewieDj1upwfuVNXf4Kor+89c3iCRJnSzMD5LmTvsfA==", "dev": true, "funding": [ { @@ -1969,15 +1964,15 @@ } }, "node_modules/devalue": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.3.tgz", - "integrity": "sha512-nc7XjUU/2Lb+SvEFVGcWLiKkzfw8+qHI7zn8WYXKkLMgfGSHbgCEaR6bJpev8Cm6Rmrb19Gfd/tZvGqx9is3wg==", + "version": "5.6.4", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.4.tgz", + "integrity": "sha512-Gp6rDldRsFh/7XuouDbxMH3Mx8GMCcgzIb1pDTvNyn8pZGQ22u+Wa+lGV9dQCltFQ7uVw0MhRyb8XDskNFOReA==", "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.307", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.307.tgz", - "integrity": "sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg==", + "version": "1.5.313", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.313.tgz", + "integrity": "sha512-QBMrTWEf00GXZmJyx2lbYD45jpI3TUFnNIzJ5BBc8piGUDwMPa1GV6HJWTZVvY/eiN3fSopl7NRbgGp9sZ9LTA==", "dev": true, "license": "ISC" }, @@ -1996,9 +1991,9 @@ } }, "node_modules/esbuild": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz", - "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.4.tgz", + "integrity": "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -2009,32 +2004,32 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.27.3", - "@esbuild/android-arm": "0.27.3", - "@esbuild/android-arm64": "0.27.3", - "@esbuild/android-x64": "0.27.3", - "@esbuild/darwin-arm64": "0.27.3", - "@esbuild/darwin-x64": "0.27.3", - "@esbuild/freebsd-arm64": "0.27.3", - "@esbuild/freebsd-x64": "0.27.3", - "@esbuild/linux-arm": "0.27.3", - "@esbuild/linux-arm64": "0.27.3", - "@esbuild/linux-ia32": "0.27.3", - "@esbuild/linux-loong64": "0.27.3", - "@esbuild/linux-mips64el": "0.27.3", - "@esbuild/linux-ppc64": "0.27.3", - "@esbuild/linux-riscv64": "0.27.3", - "@esbuild/linux-s390x": "0.27.3", - "@esbuild/linux-x64": "0.27.3", - "@esbuild/netbsd-arm64": "0.27.3", - "@esbuild/netbsd-x64": "0.27.3", - "@esbuild/openbsd-arm64": "0.27.3", - "@esbuild/openbsd-x64": "0.27.3", - "@esbuild/openharmony-arm64": "0.27.3", - "@esbuild/sunos-x64": "0.27.3", - "@esbuild/win32-arm64": "0.27.3", - "@esbuild/win32-ia32": "0.27.3", - "@esbuild/win32-x64": "0.27.3" + "@esbuild/aix-ppc64": "0.27.4", + "@esbuild/android-arm": "0.27.4", + "@esbuild/android-arm64": "0.27.4", + "@esbuild/android-x64": "0.27.4", + "@esbuild/darwin-arm64": "0.27.4", + "@esbuild/darwin-x64": "0.27.4", + "@esbuild/freebsd-arm64": "0.27.4", + "@esbuild/freebsd-x64": "0.27.4", + "@esbuild/linux-arm": "0.27.4", + "@esbuild/linux-arm64": "0.27.4", + "@esbuild/linux-ia32": "0.27.4", + "@esbuild/linux-loong64": "0.27.4", + "@esbuild/linux-mips64el": "0.27.4", + "@esbuild/linux-ppc64": "0.27.4", + "@esbuild/linux-riscv64": "0.27.4", + "@esbuild/linux-s390x": "0.27.4", + "@esbuild/linux-x64": "0.27.4", + "@esbuild/netbsd-arm64": "0.27.4", + "@esbuild/netbsd-x64": "0.27.4", + "@esbuild/openbsd-arm64": "0.27.4", + "@esbuild/openbsd-x64": "0.27.4", + "@esbuild/openharmony-arm64": "0.27.4", + "@esbuild/sunos-x64": "0.27.4", + "@esbuild/win32-arm64": "0.27.4", + "@esbuild/win32-ia32": "0.27.4", + "@esbuild/win32-x64": "0.27.4" } }, "node_modules/escalade": { @@ -2066,7 +2061,6 @@ "integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -2317,12 +2311,13 @@ } }, "node_modules/esrap": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.3.tgz", - "integrity": "sha512-8fOS+GIGCQZl/ZIlhl59htOlms6U8NvX6ZYgYHpRU/b6tVSh3uHkOHZikl3D4cMbYM0JlpBe+p/BkZEi8J9XIQ==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.4.tgz", + "integrity": "sha512-suICpxAmZ9A8bzJjEl/+rLJiDKC0X4gYWUxT6URAWBLvlXmtbZd5ySMu/N2ZGEtMCAmflUDPSehrP9BQcsGcSg==", "license": "MIT", "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.15" + "@jridgewell/sourcemap-codec": "^1.4.15", + "@typescript-eslint/types": "^8.2.0" } }, "node_modules/esrecurse": { @@ -3134,7 +3129,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -3172,7 +3166,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -3306,7 +3299,6 @@ "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -3493,11 +3485,10 @@ } }, "node_modules/svelte": { - "version": "5.53.9", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.53.9.tgz", - "integrity": "sha512-MwDfWsN8qZzeP0jlQsWF4k/4B3csb3IbzCRggF+L/QqY7T8bbKvnChEo1cPZztF51HJQhilDbevWYl2LvXbquA==", + "version": "5.53.12", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.53.12.tgz", + "integrity": "sha512-4x/uk4rQe/d7RhfvS8wemTfNjQ0bJbKvamIzRBfTe2eHHjzBZ7PZicUQrC2ryj83xxEacfA1zHKd1ephD1tAxA==", "license": "MIT", - "peer": true, "dependencies": { "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0", @@ -3508,7 +3499,7 @@ "aria-query": "5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", - "devalue": "^5.6.3", + "devalue": "^5.6.4", "esm-env": "^1.2.1", "esrap": "^2.2.2", "is-reference": "^3.0.3", @@ -3756,7 +3747,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -3819,7 +3809,6 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", diff --git a/demo/package.json b/demo/package.json index 2fbc4be..7ea9655 100644 --- a/demo/package.json +++ b/demo/package.json @@ -42,7 +42,7 @@ "vite": "^7.3.1" }, "dependencies": { - "svelte": "^5.53.9", + "svelte": "^5.53.12", "zod": "^4.3.6" } } From d960f872a515a566360b47f66f559861ce08532a Mon Sep 17 00:00:00 2001 From: BCsabaEngine Date: Sun, 15 Mar 2026 22:44:55 +0100 Subject: [PATCH 3/4] chore: deps --- package-lock.json | 441 +++++++++++++++++++++++----------------------- package.json | 8 +- 2 files changed, 225 insertions(+), 224 deletions(-) diff --git a/package-lock.json b/package-lock.json index f8111b1..44ef971 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,21 +12,21 @@ "@eslint/eslintrc": "^3.3.5", "@eslint/js": "^10.0.1", "@sveltejs/vite-plugin-svelte": "^6.2.4", - "@types/node": "^25.4.0", + "@types/node": "^25.5.0", "@typescript-eslint/eslint-plugin": "^8.57.0", "@typescript-eslint/parser": "^8.57.0", - "@vitest/coverage-v8": "^4.0.18", + "@vitest/coverage-v8": "^4.1.0", "eslint": "^10.0.3", "eslint-config-prettier": "^10.1.8", "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-unicorn": "^63.0.0", "nodemon": "^3.1.14", "prettier": "^3.8.1", - "svelte": "^5.53.9", + "svelte": "^5.53.12", "ts-node": "^10.9.2", "tsx": "^4.21.0", "typescript": "^5.9.3", - "vitest": "^4.0.18" + "vitest": "^4.1.0" }, "engines": { "node": ">=20", @@ -121,9 +121,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz", - "integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", + "integrity": "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q==", "cpu": [ "ppc64" ], @@ -138,9 +138,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz", - "integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.4.tgz", + "integrity": "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ==", "cpu": [ "arm" ], @@ -155,9 +155,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz", - "integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.4.tgz", + "integrity": "sha512-gdLscB7v75wRfu7QSm/zg6Rx29VLdy9eTr2t44sfTW7CxwAtQghZ4ZnqHk3/ogz7xao0QAgrkradbBzcqFPasw==", "cpu": [ "arm64" ], @@ -172,9 +172,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz", - "integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.4.tgz", + "integrity": "sha512-PzPFnBNVF292sfpfhiyiXCGSn9HZg5BcAz+ivBuSsl6Rk4ga1oEXAamhOXRFyMcjwr2DVtm40G65N3GLeH1Lvw==", "cpu": [ "x64" ], @@ -189,9 +189,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz", - "integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.4.tgz", + "integrity": "sha512-b7xaGIwdJlht8ZFCvMkpDN6uiSmnxxK56N2GDTMYPr2/gzvfdQN8rTfBsvVKmIVY/X7EM+/hJKEIbbHs9oA4tQ==", "cpu": [ "arm64" ], @@ -206,9 +206,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz", - "integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.4.tgz", + "integrity": "sha512-sR+OiKLwd15nmCdqpXMnuJ9W2kpy0KigzqScqHI3Hqwr7IXxBp3Yva+yJwoqh7rE8V77tdoheRYataNKL4QrPw==", "cpu": [ "x64" ], @@ -223,9 +223,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz", - "integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.4.tgz", + "integrity": "sha512-jnfpKe+p79tCnm4GVav68A7tUFeKQwQyLgESwEAUzyxk/TJr4QdGog9sqWNcUbr/bZt/O/HXouspuQDd9JxFSw==", "cpu": [ "arm64" ], @@ -240,9 +240,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz", - "integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.4.tgz", + "integrity": "sha512-2kb4ceA/CpfUrIcTUl1wrP/9ad9Atrp5J94Lq69w7UwOMolPIGrfLSvAKJp0RTvkPPyn6CIWrNy13kyLikZRZQ==", "cpu": [ "x64" ], @@ -257,9 +257,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz", - "integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.4.tgz", + "integrity": "sha512-aBYgcIxX/wd5n2ys0yESGeYMGF+pv6g0DhZr3G1ZG4jMfruU9Tl1i2Z+Wnj9/KjGz1lTLCcorqE2viePZqj4Eg==", "cpu": [ "arm" ], @@ -274,9 +274,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz", - "integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.4.tgz", + "integrity": "sha512-7nQOttdzVGth1iz57kxg9uCz57dxQLHWxopL6mYuYthohPKEK0vU0C3O21CcBK6KDlkYVcnDXY099HcCDXd9dA==", "cpu": [ "arm64" ], @@ -291,9 +291,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz", - "integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.4.tgz", + "integrity": "sha512-oPtixtAIzgvzYcKBQM/qZ3R+9TEUd1aNJQu0HhGyqtx6oS7qTpvjheIWBbes4+qu1bNlo2V4cbkISr8q6gRBFA==", "cpu": [ "ia32" ], @@ -308,9 +308,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz", - "integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.4.tgz", + "integrity": "sha512-8mL/vh8qeCoRcFH2nM8wm5uJP+ZcVYGGayMavi8GmRJjuI3g1v6Z7Ni0JJKAJW+m0EtUuARb6Lmp4hMjzCBWzA==", "cpu": [ "loong64" ], @@ -325,9 +325,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz", - "integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.4.tgz", + "integrity": "sha512-1RdrWFFiiLIW7LQq9Q2NES+HiD4NyT8Itj9AUeCl0IVCA459WnPhREKgwrpaIfTOe+/2rdntisegiPWn/r/aAw==", "cpu": [ "mips64el" ], @@ -342,9 +342,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz", - "integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.4.tgz", + "integrity": "sha512-tLCwNG47l3sd9lpfyx9LAGEGItCUeRCWeAx6x2Jmbav65nAwoPXfewtAdtbtit/pJFLUWOhpv0FpS6GQAmPrHA==", "cpu": [ "ppc64" ], @@ -359,9 +359,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz", - "integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.4.tgz", + "integrity": "sha512-BnASypppbUWyqjd1KIpU4AUBiIhVr6YlHx/cnPgqEkNoVOhHg+YiSVxM1RLfiy4t9cAulbRGTNCKOcqHrEQLIw==", "cpu": [ "riscv64" ], @@ -376,9 +376,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz", - "integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.4.tgz", + "integrity": "sha512-+eUqgb/Z7vxVLezG8bVB9SfBie89gMueS+I0xYh2tJdw3vqA/0ImZJ2ROeWwVJN59ihBeZ7Tu92dF/5dy5FttA==", "cpu": [ "s390x" ], @@ -393,9 +393,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz", - "integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.4.tgz", + "integrity": "sha512-S5qOXrKV8BQEzJPVxAwnryi2+Iq5pB40gTEIT69BQONqR7JH1EPIcQ/Uiv9mCnn05jff9umq/5nqzxlqTOg9NA==", "cpu": [ "x64" ], @@ -410,9 +410,9 @@ } }, "node_modules/@esbuild/netbsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz", - "integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.4.tgz", + "integrity": "sha512-xHT8X4sb0GS8qTqiwzHqpY00C95DPAq7nAwX35Ie/s+LO9830hrMd3oX0ZMKLvy7vsonee73x0lmcdOVXFzd6Q==", "cpu": [ "arm64" ], @@ -427,9 +427,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz", - "integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.4.tgz", + "integrity": "sha512-RugOvOdXfdyi5Tyv40kgQnI0byv66BFgAqjdgtAKqHoZTbTF2QqfQrFwa7cHEORJf6X2ht+l9ABLMP0dnKYsgg==", "cpu": [ "x64" ], @@ -444,9 +444,9 @@ } }, "node_modules/@esbuild/openbsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz", - "integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.4.tgz", + "integrity": "sha512-2MyL3IAaTX+1/qP0O1SwskwcwCoOI4kV2IBX1xYnDDqthmq5ArrW94qSIKCAuRraMgPOmG0RDTA74mzYNQA9ow==", "cpu": [ "arm64" ], @@ -461,9 +461,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz", - "integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.4.tgz", + "integrity": "sha512-u8fg/jQ5aQDfsnIV6+KwLOf1CmJnfu1ShpwqdwC0uA7ZPwFws55Ngc12vBdeUdnuWoQYx/SOQLGDcdlfXhYmXQ==", "cpu": [ "x64" ], @@ -478,9 +478,9 @@ } }, "node_modules/@esbuild/openharmony-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz", - "integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.4.tgz", + "integrity": "sha512-JkTZrl6VbyO8lDQO3yv26nNr2RM2yZzNrNHEsj9bm6dOwwu9OYN28CjzZkH57bh4w0I2F7IodpQvUAEd1mbWXg==", "cpu": [ "arm64" ], @@ -495,9 +495,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz", - "integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.4.tgz", + "integrity": "sha512-/gOzgaewZJfeJTlsWhvUEmUG4tWEY2Spp5M20INYRg2ZKl9QPO3QEEgPeRtLjEWSW8FilRNacPOg8R1uaYkA6g==", "cpu": [ "x64" ], @@ -512,9 +512,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz", - "integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.4.tgz", + "integrity": "sha512-Z9SExBg2y32smoDQdf1HRwHRt6vAHLXcxD2uGgO/v2jK7Y718Ix4ndsbNMU/+1Qiem9OiOdaqitioZwxivhXYg==", "cpu": [ "arm64" ], @@ -529,9 +529,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz", - "integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.4.tgz", + "integrity": "sha512-DAyGLS0Jz5G5iixEbMHi5KdiApqHBWMGzTtMiJ72ZOLhbu/bzxgAe8Ue8CTS3n3HbIUHQz/L51yMdGMeoxXNJw==", "cpu": [ "ia32" ], @@ -546,9 +546,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz", - "integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.4.tgz", + "integrity": "sha512-+knoa0BDoeXgkNvvV1vvbZX4+hizelrkwmGJBdT17t8FNPwG2lKemmuMZlmaNQ3ws3DKKCxpb4zRZEIp3UxFCg==", "cpu": [ "x64" ], @@ -1215,7 +1215,6 @@ "integrity": "sha512-ou/d51QSdTyN26D7h6dSpusAKaZkAiGM55/AKYi+9AGZw7q85hElbjK3kEyzXHhLSnRISHOYzVge6x0jRZ7DXA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@sveltejs/vite-plugin-svelte-inspector": "^5.0.0", "deepmerge": "^4.3.1", @@ -1317,12 +1316,11 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.4.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.4.0.tgz", - "integrity": "sha512-9wLpoeWuBlcbBpOY3XmzSTG3oscB6xjBEEtn+pYXTfhyXhIxC5FsBer2KTopBlvKEiW9l13po9fq+SJY/5lkhw==", + "version": "25.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.0.tgz", + "integrity": "sha512-jp2P3tQMSxWugkCUKLRPVUpGaL5MVFwF8RDuSRztfwgN1wmqJeMSbKlnEtQqU8UrhTmzEmZdu2I6v2dpp7XIxw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.18.0" } @@ -1379,7 +1377,6 @@ "integrity": "sha512-XZzOmihLIr8AD1b9hL9ccNMzEMWt/dE2u7NyTY9jJG6YNiNthaD5XtUHVF2uCXZ15ng+z2hT3MVuxnUYhq6k1g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.57.0", "@typescript-eslint/types": "8.57.0", @@ -1618,29 +1615,29 @@ } }, "node_modules/@vitest/coverage-v8": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.0.18.tgz", - "integrity": "sha512-7i+N2i0+ME+2JFZhfuz7Tg/FqKtilHjGyGvoHYQ6iLV0zahbsJ9sljC9OcFcPDbhYKCet+sG8SsVqlyGvPflZg==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.0.tgz", + "integrity": "sha512-nDWulKeik2bL2Va/Wl4x7DLuTKAXa906iRFooIRPR+huHkcvp9QDkPQ2RJdmjOFrqOqvNfoSQLF68deE3xC3CQ==", "dev": true, "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/utils": "4.0.18", - "ast-v8-to-istanbul": "^0.3.10", + "@vitest/utils": "4.1.0", + "ast-v8-to-istanbul": "^1.0.0", "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", "istanbul-reports": "^3.2.0", - "magicast": "^0.5.1", + "magicast": "^0.5.2", "obug": "^2.1.1", - "std-env": "^3.10.0", + "std-env": "^4.0.0-rc.1", "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "4.0.18", - "vitest": "4.0.18" + "@vitest/browser": "4.1.0", + "vitest": "4.1.0" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -1649,17 +1646,17 @@ } }, "node_modules/@vitest/expect": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.18.tgz", - "integrity": "sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.0.tgz", + "integrity": "sha512-EIxG7k4wlWweuCLG9Y5InKFwpMEOyrMb6ZJ1ihYu02LVj/bzUwn2VMU+13PinsjRW75XnITeFrQBMH5+dLvCDA==", "dev": true, "license": "MIT", "dependencies": { - "@standard-schema/spec": "^1.0.0", + "@standard-schema/spec": "^1.1.0", "@types/chai": "^5.2.2", - "@vitest/spy": "4.0.18", - "@vitest/utils": "4.0.18", - "chai": "^6.2.1", + "@vitest/spy": "4.1.0", + "@vitest/utils": "4.1.0", + "chai": "^6.2.2", "tinyrainbow": "^3.0.3" }, "funding": { @@ -1667,13 +1664,13 @@ } }, "node_modules/@vitest/mocker": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.18.tgz", - "integrity": "sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.0.tgz", + "integrity": "sha512-evxREh+Hork43+Y4IOhTo+h5lGmVRyjqI739Rz4RlUPqwrkFFDF6EMvOOYjTx4E8Tl6gyCLRL8Mu7Ry12a13Tw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "4.0.18", + "@vitest/spy": "4.1.0", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, @@ -1682,7 +1679,7 @@ }, "peerDependencies": { "msw": "^2.4.9", - "vite": "^6.0.0 || ^7.0.0-0" + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0-0" }, "peerDependenciesMeta": { "msw": { @@ -1694,9 +1691,9 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.18.tgz", - "integrity": "sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.0.tgz", + "integrity": "sha512-3RZLZlh88Ib0J7NQTRATfc/3ZPOnSUn2uDBUoGNn5T36+bALixmzphN26OUD3LRXWkJu4H0s5vvUeqBiw+kS0A==", "dev": true, "license": "MIT", "dependencies": { @@ -1707,13 +1704,13 @@ } }, "node_modules/@vitest/runner": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.18.tgz", - "integrity": "sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.0.tgz", + "integrity": "sha512-Duvx2OzQ7d6OjchL+trw+aSrb9idh7pnNfxrklo14p3zmNL4qPCDeIJAK+eBKYjkIwG96Bc6vYuxhqDXQOWpoQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "4.0.18", + "@vitest/utils": "4.1.0", "pathe": "^2.0.3" }, "funding": { @@ -1721,13 +1718,14 @@ } }, "node_modules/@vitest/snapshot": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.18.tgz", - "integrity": "sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.0.tgz", + "integrity": "sha512-0Vy9euT1kgsnj1CHttwi9i9o+4rRLEaPRSOJ5gyv579GJkNpgJK+B4HSv/rAWixx2wdAFci1X4CEPjiu2bXIMg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.0.18", + "@vitest/pretty-format": "4.1.0", + "@vitest/utils": "4.1.0", "magic-string": "^0.30.21", "pathe": "^2.0.3" }, @@ -1736,9 +1734,9 @@ } }, "node_modules/@vitest/spy": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.18.tgz", - "integrity": "sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.0.tgz", + "integrity": "sha512-pz77k+PgNpyMDv2FV6qmk5ZVau6c3R8HC8v342T2xlFxQKTrSeYw9waIJG8KgV9fFwAtTu4ceRzMivPTH6wSxw==", "dev": true, "license": "MIT", "funding": { @@ -1746,13 +1744,14 @@ } }, "node_modules/@vitest/utils": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.18.tgz", - "integrity": "sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.0.tgz", + "integrity": "sha512-XfPXT6a8TZY3dcGY8EdwsBulFCIw+BeeX0RZn2x/BtiY/75YGh8FeWGG8QISN/WhaqSrE2OrlDgtF8q5uhOTmw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.0.18", + "@vitest/pretty-format": "4.1.0", + "convert-source-map": "^2.0.0", "tinyrainbow": "^3.0.3" }, "funding": { @@ -1765,7 +1764,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1862,9 +1860,9 @@ } }, "node_modules/ast-v8-to-istanbul": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-0.3.12.tgz", - "integrity": "sha512-BRRC8VRZY2R4Z4lFIL35MwNXmwVqBityvOIwETtsCSwvjl0IdgFsy9NhdaA6j74nUdtJJlIypeRhpDam19Wq3g==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.0.tgz", + "integrity": "sha512-1fSfIwuDICFA4LKkCzRPO7F0hzFf0B7+Xqrl27ynQaa+Rh0e1Es0v6kWHPott3lU10AyAr7oKHa65OppjLn3Rg==", "dev": true, "license": "MIT", "dependencies": { @@ -1891,9 +1889,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.0.tgz", - "integrity": "sha512-lIyg0szRfYbiy67j9KN8IyeD7q7hcmqnJ1ddWmNt19ItGpNN64mnllmxUNFIOdOm6by97jlL6wfpTTJrmnjWAA==", + "version": "2.10.8", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.8.tgz", + "integrity": "sha512-PCLz/LXGBsNTErbtB6i5u4eLpHeMfi93aUv5duMmj6caNu6IphS4q6UevDnL36sZQv9lrP11dbPKGMaXPwMKfQ==", "dev": true, "license": "Apache-2.0", "bin": { @@ -1960,7 +1958,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -1999,9 +1996,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001777", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001777.tgz", - "integrity": "sha512-tmN+fJxroPndC74efCdp12j+0rk0RHwV5Jwa1zWaFVyw2ZxAuPeG8ZgWC3Wz7uSjT3qMRQ5XHZ4COgQmsCMJAQ==", + "version": "1.0.30001779", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001779.tgz", + "integrity": "sha512-U5og2PN7V4DMgF50YPNtnZJGWVLFjjsN3zb6uMT5VGYIewieDj1upwfuVNXf4Kor+89c3iCRJnSzMD5LmTvsfA==", "dev": true, "funding": [ { @@ -2130,6 +2127,13 @@ "dev": true, "license": "MIT" }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, "node_modules/core-js-compat": { "version": "3.48.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.48.0.tgz", @@ -2202,9 +2206,9 @@ } }, "node_modules/devalue": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.3.tgz", - "integrity": "sha512-nc7XjUU/2Lb+SvEFVGcWLiKkzfw8+qHI7zn8WYXKkLMgfGSHbgCEaR6bJpev8Cm6Rmrb19Gfd/tZvGqx9is3wg==", + "version": "5.6.4", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.4.tgz", + "integrity": "sha512-Gp6rDldRsFh/7XuouDbxMH3Mx8GMCcgzIb1pDTvNyn8pZGQ22u+Wa+lGV9dQCltFQ7uVw0MhRyb8XDskNFOReA==", "dev": true, "license": "MIT" }, @@ -2219,23 +2223,23 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.307", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.307.tgz", - "integrity": "sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg==", + "version": "1.5.313", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.313.tgz", + "integrity": "sha512-QBMrTWEf00GXZmJyx2lbYD45jpI3TUFnNIzJ5BBc8piGUDwMPa1GV6HJWTZVvY/eiN3fSopl7NRbgGp9sZ9LTA==", "dev": true, "license": "ISC" }, "node_modules/es-module-lexer": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", - "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.0.0.tgz", + "integrity": "sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==", "dev": true, "license": "MIT" }, "node_modules/esbuild": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz", - "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.4.tgz", + "integrity": "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -2246,32 +2250,32 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.27.3", - "@esbuild/android-arm": "0.27.3", - "@esbuild/android-arm64": "0.27.3", - "@esbuild/android-x64": "0.27.3", - "@esbuild/darwin-arm64": "0.27.3", - "@esbuild/darwin-x64": "0.27.3", - "@esbuild/freebsd-arm64": "0.27.3", - "@esbuild/freebsd-x64": "0.27.3", - "@esbuild/linux-arm": "0.27.3", - "@esbuild/linux-arm64": "0.27.3", - "@esbuild/linux-ia32": "0.27.3", - "@esbuild/linux-loong64": "0.27.3", - "@esbuild/linux-mips64el": "0.27.3", - "@esbuild/linux-ppc64": "0.27.3", - "@esbuild/linux-riscv64": "0.27.3", - "@esbuild/linux-s390x": "0.27.3", - "@esbuild/linux-x64": "0.27.3", - "@esbuild/netbsd-arm64": "0.27.3", - "@esbuild/netbsd-x64": "0.27.3", - "@esbuild/openbsd-arm64": "0.27.3", - "@esbuild/openbsd-x64": "0.27.3", - "@esbuild/openharmony-arm64": "0.27.3", - "@esbuild/sunos-x64": "0.27.3", - "@esbuild/win32-arm64": "0.27.3", - "@esbuild/win32-ia32": "0.27.3", - "@esbuild/win32-x64": "0.27.3" + "@esbuild/aix-ppc64": "0.27.4", + "@esbuild/android-arm": "0.27.4", + "@esbuild/android-arm64": "0.27.4", + "@esbuild/android-x64": "0.27.4", + "@esbuild/darwin-arm64": "0.27.4", + "@esbuild/darwin-x64": "0.27.4", + "@esbuild/freebsd-arm64": "0.27.4", + "@esbuild/freebsd-x64": "0.27.4", + "@esbuild/linux-arm": "0.27.4", + "@esbuild/linux-arm64": "0.27.4", + "@esbuild/linux-ia32": "0.27.4", + "@esbuild/linux-loong64": "0.27.4", + "@esbuild/linux-mips64el": "0.27.4", + "@esbuild/linux-ppc64": "0.27.4", + "@esbuild/linux-riscv64": "0.27.4", + "@esbuild/linux-s390x": "0.27.4", + "@esbuild/linux-x64": "0.27.4", + "@esbuild/netbsd-arm64": "0.27.4", + "@esbuild/netbsd-x64": "0.27.4", + "@esbuild/openbsd-arm64": "0.27.4", + "@esbuild/openbsd-x64": "0.27.4", + "@esbuild/openharmony-arm64": "0.27.4", + "@esbuild/sunos-x64": "0.27.4", + "@esbuild/win32-arm64": "0.27.4", + "@esbuild/win32-ia32": "0.27.4", + "@esbuild/win32-x64": "0.27.4" } }, "node_modules/escalade": { @@ -2303,7 +2307,6 @@ "integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -2581,13 +2584,14 @@ } }, "node_modules/esrap": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.3.tgz", - "integrity": "sha512-8fOS+GIGCQZl/ZIlhl59htOlms6U8NvX6ZYgYHpRU/b6tVSh3uHkOHZikl3D4cMbYM0JlpBe+p/BkZEi8J9XIQ==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.4.tgz", + "integrity": "sha512-suICpxAmZ9A8bzJjEl/+rLJiDKC0X4gYWUxT6URAWBLvlXmtbZd5ySMu/N2ZGEtMCAmflUDPSehrP9BQcsGcSg==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.15" + "@jridgewell/sourcemap-codec": "^1.4.15", + "@typescript-eslint/types": "^8.2.0" } }, "node_modules/esrecurse": { @@ -3665,9 +3669,9 @@ "license": "MIT" }, "node_modules/std-env": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", - "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.0.0.tgz", + "integrity": "sha512-zUMPtQ/HBY3/50VbpkupYHbRroTRZJPRLvreamgErJVys0ceuzMkD44J/QjqhHjOzK42GQ3QZIeFG1OYfOtKqQ==", "dev": true, "license": "MIT" }, @@ -3711,12 +3715,11 @@ } }, "node_modules/svelte": { - "version": "5.53.9", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.53.9.tgz", - "integrity": "sha512-MwDfWsN8qZzeP0jlQsWF4k/4B3csb3IbzCRggF+L/QqY7T8bbKvnChEo1cPZztF51HJQhilDbevWYl2LvXbquA==", + "version": "5.53.12", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.53.12.tgz", + "integrity": "sha512-4x/uk4rQe/d7RhfvS8wemTfNjQ0bJbKvamIzRBfTe2eHHjzBZ7PZicUQrC2ryj83xxEacfA1zHKd1ephD1tAxA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0", @@ -3727,7 +3730,7 @@ "aria-query": "5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", - "devalue": "^5.6.3", + "devalue": "^5.6.4", "esm-env": "^1.2.1", "esrap": "^2.2.2", "is-reference": "^3.0.3", @@ -3747,9 +3750,9 @@ "license": "MIT" }, "node_modules/tinyexec": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", - "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.4.tgz", + "integrity": "sha512-u9r3uZC0bdpGOXtlxUIdwf9pkmvhqJdrVCH9fapQtgy/OeTTMZ1nqH7agtvEfmGui6e1XxjcdrlxvxJvc3sMqw==", "dev": true, "license": "MIT", "engines": { @@ -3797,7 +3800,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -3806,9 +3808,9 @@ } }, "node_modules/tinyrainbow": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", - "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz", + "integrity": "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==", "dev": true, "license": "MIT", "engines": { @@ -3901,7 +3903,6 @@ "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" @@ -3935,7 +3936,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -4012,7 +4012,6 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -4106,7 +4105,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -4135,32 +4133,31 @@ } }, "node_modules/vitest": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.18.tgz", - "integrity": "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.0.tgz", + "integrity": "sha512-YbDrMF9jM2Lqc++2530UourxZHmkKLxrs4+mYhEwqWS97WJ7wOYEkcr+QfRgJ3PW9wz3odRijLZjHEaRLTNbqw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@vitest/expect": "4.0.18", - "@vitest/mocker": "4.0.18", - "@vitest/pretty-format": "4.0.18", - "@vitest/runner": "4.0.18", - "@vitest/snapshot": "4.0.18", - "@vitest/spy": "4.0.18", - "@vitest/utils": "4.0.18", - "es-module-lexer": "^1.7.0", - "expect-type": "^1.2.2", + "@vitest/expect": "4.1.0", + "@vitest/mocker": "4.1.0", + "@vitest/pretty-format": "4.1.0", + "@vitest/runner": "4.1.0", + "@vitest/snapshot": "4.1.0", + "@vitest/spy": "4.1.0", + "@vitest/utils": "4.1.0", + "es-module-lexer": "^2.0.0", + "expect-type": "^1.3.0", "magic-string": "^0.30.21", "obug": "^2.1.1", "pathe": "^2.0.3", "picomatch": "^4.0.3", - "std-env": "^3.10.0", + "std-env": "^4.0.0-rc.1", "tinybench": "^2.9.0", "tinyexec": "^1.0.2", "tinyglobby": "^0.2.15", "tinyrainbow": "^3.0.3", - "vite": "^6.0.0 || ^7.0.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0-0", "why-is-node-running": "^2.3.0" }, "bin": { @@ -4176,12 +4173,13 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.0.18", - "@vitest/browser-preview": "4.0.18", - "@vitest/browser-webdriverio": "4.0.18", - "@vitest/ui": "4.0.18", + "@vitest/browser-playwright": "4.1.0", + "@vitest/browser-preview": "4.1.0", + "@vitest/browser-webdriverio": "4.1.0", + "@vitest/ui": "4.1.0", "happy-dom": "*", - "jsdom": "*" + "jsdom": "*", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0-0" }, "peerDependenciesMeta": { "@edge-runtime/vm": { @@ -4210,6 +4208,9 @@ }, "jsdom": { "optional": true + }, + "vite": { + "optional": false } } }, diff --git a/package.json b/package.json index 0f0c72a..6bf7a3a 100644 --- a/package.json +++ b/package.json @@ -56,21 +56,21 @@ "@eslint/eslintrc": "^3.3.5", "@eslint/js": "^10.0.1", "@sveltejs/vite-plugin-svelte": "^6.2.4", - "@types/node": "^25.4.0", + "@types/node": "^25.5.0", "@typescript-eslint/eslint-plugin": "^8.57.0", "@typescript-eslint/parser": "^8.57.0", - "@vitest/coverage-v8": "^4.0.18", + "@vitest/coverage-v8": "^4.1.0", "eslint": "^10.0.3", "eslint-config-prettier": "^10.1.8", "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-unicorn": "^63.0.0", "nodemon": "^3.1.14", "prettier": "^3.8.1", - "svelte": "^5.53.9", + "svelte": "^5.53.12", "ts-node": "^10.9.2", "tsx": "^4.21.0", "typescript": "^5.9.3", - "vitest": "^4.0.18" + "vitest": "^4.1.0" }, "peerDependencies": { "svelte": "^5.0.0" From 8f1fc48ff32d46d0d65f0ca309dcad39d94d031c Mon Sep 17 00:00:00 2001 From: BCsabaEngine Date: Sun, 15 Mar 2026 22:47:26 +0100 Subject: [PATCH 4/4] release: 1.5.1 --- CHANGELOG.md | 18 ++ CLAUDE.md | 6 +- README.md | 10 +- docs/assets/index-BvwiQ3S5.js | 511 ---------------------------------- docs/assets/index-DyhFc29r.js | 511 ++++++++++++++++++++++++++++++++++ docs/index.html | 2 +- package-lock.json | 4 +- package.json | 2 +- 8 files changed, 543 insertions(+), 521 deletions(-) delete mode 100644 docs/assets/index-BvwiQ3S5.js create mode 100644 docs/assets/index-DyhFc29r.js diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f58b7..84a2c83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.5.1] - 2026-03-15 + +### Fixed + +- **Prototype pollution** — `persistPlugin` and `syncPlugin` no longer propagate `__proto__`, `constructor`, or `prototype` keys when merging external data into state +- **Prototype pollution via path traversal** — `setValueAtPath` in `persistPlugin` and `historyPlugin` now rejects path segments matching `__proto__`, `constructor`, or `prototype` +- **Prototype pollution via snapshot restore** — `deepClone` in `createSvState` now skips dangerous keys, preventing polluted data from being re-applied through `rollback()`, `rollbackTo()`, or `reset()` +- **Unvalidated localStorage data** — `persistPlugin` now validates that parsed JSON has a numeric `version` and a plain-object `data` field before applying it; invalid payloads are silently discarded +- **Silent async validator crashes** — uncaught errors from async validators are now stored in `asyncErrors` under the relevant path instead of being re-thrown silently +- **`saveOnDestroy` with async save functions** — `autosavePlugin` now attaches `.catch(onError)` to the save promise returned during `destroy()`, preventing unhandled rejections + +### Added + +- **`devtoolsPlugin`** — new `logValues` option (default: `false`) to opt into logging raw state values in the console; omitting values by default prevents passwords and tokens from appearing in devtools +- **`undoRedoPlugin`** — new `maxRedoStack` option to cap the redo stack size (mirrors the main `maxSnapshots` limit) +- **`analyticsPlugin`** — new `redact` option accepting an array of property paths whose `currentValue`/`oldValue` are replaced with `'[redacted]'` in flushed events +- **`syncPlugin`** — incoming `BroadcastChannel` messages are now validated as plain objects and rate-limited to one per `throttle` ms interval, preventing message-flooding attacks + ## [1.5.0] - 2026-02-26 ### Added diff --git a/CLAUDE.md b/CLAUDE.md index 51a5fdf..3aead64 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -224,11 +224,11 @@ Plugins extend `createSvState` via lifecycle hooks. They are registered via `opt | ----------------- | -------------- | -------------------------------------------- | ------------------------------------------------------------------------ | | `persistPlugin` | `persist.ts` | Persist state to localStorage/custom storage | `key`, `storage`, `throttle`, `version`, `migrate`, `include`, `exclude` | | `autosavePlugin` | `autosave.ts` | Auto-save after idle/interval | `save` (required), `idle`, `interval`, `saveOnDestroy`, `onlyWhenDirty` | -| `devtoolsPlugin` | `devtools.ts` | Console logging of all events | `name`, `collapsed`, `logValidation`, `enabled` | +| `devtoolsPlugin` | `devtools.ts` | Console logging of all events | `name`, `collapsed`, `logValidation`, `enabled`, `logValues` | | `historyPlugin` | `history.ts` | Sync state fields to URL params | `fields` (required), `mode`, `serialize`, `deserialize` | | `syncPlugin` | `sync.ts` | Cross-tab sync via BroadcastChannel | `key` (required), `throttle`, `merge` | -| `undoRedoPlugin` | `undo-redo.ts` | Redo stack on top of built-in rollback | No required options; exposes `redo()`, `canRedo()`, `redoStack` | -| `analyticsPlugin` | `analytics.ts` | Batch event buffering for analytics | `onFlush` (required), `batchSize`, `flushInterval`, `include` | +| `undoRedoPlugin` | `undo-redo.ts` | Redo stack on top of built-in rollback | `maxRedoStack`; exposes `redo()`, `canRedo()`, `redoStack` | +| `analyticsPlugin` | `analytics.ts` | Batch event buffering for analytics | `onFlush` (required), `batchSize`, `flushInterval`, `include`, `redact` | ### Deep Clone System (src/state.svelte.ts) diff --git a/README.md b/README.md index 5799061..f8da312 100644 --- a/README.md +++ b/README.md @@ -564,7 +564,8 @@ devtoolsPlugin({ name: 'MyForm', // Log prefix (default: 'svstate') collapsed: true, // Use groupCollapsed (default: true) logValidation: false, // Log validation results (default: false) - enabled: true // Auto-disabled in production + enabled: true, // Auto-disabled in production + logValues: false // Log raw state values in change events (default: false — avoids leaking passwords/tokens) }); ``` @@ -604,7 +605,9 @@ sync.disconnect(); // Close the channel ```typescript import { undoRedoPlugin } from 'svstate'; -const undoRedo = undoRedoPlugin(); +const undoRedo = undoRedoPlugin({ + maxRedoStack: 50 // Cap redo stack size (default: unlimited) +}); // Extra methods and stores: undoRedo.redo(); // Re-apply last undone change @@ -621,7 +624,8 @@ analyticsPlugin({ onFlush: (events) => sendToAnalytics(events), // Required batchSize: 20, // Flush at N events (default: 20) flushInterval: 5000, // Periodic flush ms (default: 5000) - include: ['change', 'action'] // Filter event types + include: ['change', 'action'], // Filter event types + redact: ['password', 'creditCard'] // Replace values for these paths with '[redacted]' }); ``` diff --git a/docs/assets/index-BvwiQ3S5.js b/docs/assets/index-BvwiQ3S5.js deleted file mode 100644 index 7834dd0..0000000 --- a/docs/assets/index-BvwiQ3S5.js +++ /dev/null @@ -1,511 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(o){if(o.ep)return;o.ep=!0;const a=r(o);fetch(o.href,a)}})();const ds=!1;var Pn=Array.isArray,fs=Array.prototype.indexOf,dr=Array.prototype.includes,cn=Array.from,Fo=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,Mo=Object.getOwnPropertyDescriptors,ps=Object.prototype,vs=Array.prototype,Cn=Object.getPrototypeOf,ro=Object.isExtensible;const St=()=>{};function ms(e){return e()}function en(e){for(var t=0;t{e=n,t=o});return{promise:r,resolve:e,reject:t}}const Ie=2,fr=4,Fr=8,qo=1<<24,Zt=16,ht=32,Ht=64,_n=128,ct=512,Ne=1024,Fe=2048,gt=4096,ot=8192,ut=16384,er=32768,no=1<<25,Kt=65536,oo=1<<17,hs=1<<18,gr=1<<19,Uo=1<<20,bt=1<<25,Gt=65536,yn=1<<21,On=1<<22,Ct=1<<23,Ot=Symbol("$state"),gs=Symbol("legacy props"),bs=Symbol(""),Et=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function _s(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function ys(e,t,r){throw new Error("https://svelte.dev/e/each_key_duplicate")}function xs(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function ws(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function $s(e){throw new Error("https://svelte.dev/e/effect_orphan")}function Es(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Ss(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function ks(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function zs(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Ds(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function As(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Ps=1,Cs=2,Bo=4,Os=8,Ns=16,Ts=1,Is=2,Zs=4,Rs=8,Ls=16,js=1,Fs=2,Le=Symbol(),Jo="http://www.w3.org/1999/xhtml";function Ms(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function Vs(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Wo(e){return e===this.v}function Ho(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Ko(e){return!Ho(e,this.v)}let Mr=!1,qs=!1;function Us(){Mr=!0}let Te=null;function pr(e){Te=e}function Ce(e,t=!1,r){Te={p:Te,i:!1,c:null,e:null,s:e,x:null,r:ge,l:Mr&&!t?{s:null,u:null,$:[]}:null}}function Oe(e){var t=Te,r=t.e;if(r!==null){t.e=null;for(var n of r)pa(n)}return t.i=!0,Te=t.p,{}}function br(){return!Mr||Te!==null&&Te.l===null}let Ft=[];function Go(){var e=Ft;Ft=[],en(e)}function Vt(e){if(Ft.length===0&&!Dr){var t=Ft;queueMicrotask(()=>{t===Ft&&Go()})}Ft.push(e)}function Bs(){for(;Ft.length>0;)Go()}function Yo(e){var t=ge;if(t===null)return ve.f|=Ct,e;if((t.f&er)===0&&(t.f&fr)===0)throw e;Pt(e,t)}function Pt(e,t){for(;t!==null;){if((t.f&_n)!==0){if((t.f&er)===0)throw e;try{t.b.error(e);return}catch(r){e=r}}t=t.parent}throw e}const Js=-7169;function ke(e,t){e.f=e.f&Js|t}function Nn(e){(e.f&ct)!==0||e.deps===null?ke(e,Ne):ke(e,gt)}function Xo(e){if(e!==null)for(const t of e)(t.f&Ie)===0||(t.f&Gt)===0||(t.f^=Gt,Xo(t.deps))}function Qo(e,t,r){(e.f&Fe)!==0?t.add(e):(e.f>)!==0&&r.add(e),Xo(e.deps),ke(e,Ne)}function Tn(e,t,r){if(e==null)return t(void 0),r&&r(void 0),St;const n=tr(()=>e.subscribe(t,r));return n.unsubscribe?()=>n.unsubscribe():n}const or=[];function Ws(e,t){return{subscribe:wt(e,t).subscribe}}function wt(e,t=St){let r=null;const n=new Set;function o(i){if(Ho(e,i)&&(e=i,r)){const c=!or.length;for(const l of n)l[1](),or.push(l,e);if(c){for(let l=0;l{n.delete(l),n.size===0&&r&&(r(),r=null)}}return{set:o,update:a,subscribe:s}}function wr(e,t,r){const n=!Array.isArray(e),o=n?[e]:e;if(!o.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const a=t.length<2;return Ws(r,(s,i)=>{let c=!1;const l=[];let u=0,m=St;const p=()=>{if(u)return;m();const g=t(n?l[0]:l,s,i);a?s(g):m=typeof g=="function"?g:St},h=o.map((g,_)=>Tn(g,b=>{l[_]=b,u&=~(1<<_),c&&p()},()=>{u|=1<<_}));return c=!0,p(),function(){en(h),m(),c=!1}})}function Ye(e){let t;return Tn(e,r=>t=r)(),t}let Jr=!1,xn=Symbol();function ee(e,t,r){const n=r[t]??={store:null,source:Rn(void 0),unsubscribe:St};if(n.store!==e&&!(xn in r))if(n.unsubscribe(),n.store=e??null,e==null)n.source.v=void 0,n.unsubscribe=St;else{var o=!0;n.unsubscribe=Tn(e,a=>{o?n.source.v=a:he(n.source,a)}),o=!1}return e&&xn in r?Ye(e):v(n.source)}function Ue(){const e={};function t(){Mn(()=>{for(var r in e)e[r].unsubscribe();Fo(e,xn,{enumerable:!1,value:!0})})}return[e,t]}function Hs(e){var t=Jr;try{return Jr=!1,[e(),Jr]}finally{Jr=t}}const $r=new Set;let me=null,vt=null,wn=null,Dr=!1,vn=!1,ar=null,Xr=null;var ao=0;let Ks=1;class Tt{id=Ks++;current=new Map;previous=new Map;#e=new Set;#l=new Set;#t=0;#i=0;#r=null;#n=[];#o=new Set;#a=new Set;#s=new Map;is_fork=!1;#c=!1;#u(){return this.is_fork||this.#i>0}skip_effect(t){this.#s.has(t)||this.#s.set(t,{d:[],m:[]})}unskip_effect(t){var r=this.#s.get(t);if(r){this.#s.delete(t);for(var n of r.d)ke(n,Fe),this.schedule(n);for(n of r.m)ke(n,gt),this.schedule(n)}}#f(){ao++>1e3&&Ys();const t=this.#n;this.#n=[],this.apply();var r=ar=[],n=[],o=Xr=[];for(const i of t)this.#p(i,r,n);if(me=null,o.length>0){var a=Tt.ensure();for(const i of o)a.schedule(i)}if(ar=null,Xr=null,this.#u()){this.#v(n),this.#v(r);for(const[i,c]of this.#s)ra(i,c)}else{this.#o.clear(),this.#a.clear();for(const i of this.#e)i(this);this.#e.clear(),so(n),so(r),this.#t===0&&this.#d(),this.#r?.resolve()}var s=me;s!==null&&($r.add(s),s.#f())}#p(t,r,n){t.f^=Ne;for(var o=t.first;o!==null;){var a=o.f,s=(a&(ht|Ht))!==0,i=s&&(a&Ne)!==0,c=i||(a&ot)!==0||this.#s.has(o);if(!c&&o.fn!==null){s?o.f^=Ne:(a&fr)!==0?r.push(o):Br(o)&&((a&Zt)!==0&&this.#a.add(o),mr(o));var l=o.first;if(l!==null){o=l;continue}}for(;o!==null;){var u=o.next;if(u!==null){o=u;break}o=o.parent}}}#v(t){for(var r=0;r1){this.previous.clear();var t=me,r=vt,n=!0;for(const o of $r){if(o===this){n=!1;continue}const a=[];for(const[i,c]of this.current){if(o.current.has(i))if(n&&c!==o.current.get(i))o.current.set(i,c);else continue;a.push(i)}if(a.length===0)continue;const s=[...o.current.keys()].filter(i=>!this.current.has(i));if(s.length>0){o.activate();const i=new Set,c=new Map;for(const l of a)ea(l,s,i,c);if(o.#n.length>0){o.apply();for(const l of o.#n)o.#p(l,[],[])}o.deactivate()}}me=t,vt=r}this.#s.clear(),$r.delete(this)}increment(t){this.#t+=1,t&&(this.#i+=1)}decrement(t,r){this.#t-=1,t&&(this.#i-=1),!(this.#c||r)&&(this.#c=!0,Vt(()=>{this.#c=!1,this.flush()}))}oncommit(t){this.#e.add(t)}ondiscard(t){this.#l.add(t)}settled(){return(this.#r??=Vo()).promise}static ensure(){if(me===null){const t=me=new Tt;vn||($r.add(me),Dr||Vt(()=>{me===t&&t.flush()}))}return me}apply(){}schedule(t){if(wn=t,t.b?.is_pending&&(t.f&(fr|Fr|qo))!==0&&(t.f&er)===0){t.b.defer_effect(t);return}for(var r=t;r.parent!==null;){r=r.parent;var n=r.f;if(ar!==null&&r===ge&&(ve===null||(ve.f&Ie)===0))return;if((n&(Ht|ht))!==0){if((n&Ne)===0)return;r.f^=Ne}}this.#n.push(r)}}function Gs(e){var t=Dr;Dr=!0;try{for(var r;;){if(Bs(),me===null)return r;me.flush()}}finally{Dr=t}}function Ys(){try{Es()}catch(e){Pt(e,wn)}}let $t=null;function so(e){var t=e.length;if(t!==0){for(var r=0;r0)){Nt.clear();for(const o of $t){if((o.f&(ut|ot))!==0)continue;const a=[o];let s=o.parent;for(;s!==null;)$t.has(s)&&($t.delete(s),a.push(s)),s=s.parent;for(let i=a.length-1;i>=0;i--){const c=a[i];(c.f&(ut|ot))===0&&mr(c)}}$t.clear()}}$t=null}}function ea(e,t,r,n){if(!r.has(e)&&(r.add(e),e.reactions!==null))for(const o of e.reactions){const a=o.f;(a&Ie)!==0?ea(o,t,r,n):(a&(On|Zt))!==0&&(a&Fe)===0&&ta(o,t,n)&&(ke(o,Fe),In(o))}}function ta(e,t,r){const n=r.get(e);if(n!==void 0)return n;if(e.deps!==null)for(const o of e.deps){if(dr.call(t,o))return!0;if((o.f&Ie)!==0&&ta(o,t,r))return r.set(o,!0),!0}return r.set(e,!1),!1}function In(e){me.schedule(e)}function ra(e,t){if(!((e.f&ht)!==0&&(e.f&Ne)!==0)){(e.f&Fe)!==0?t.d.push(e):(e.f>)!==0&&t.m.push(e),ke(e,Ne);for(var r=e.first;r!==null;)ra(r,t),r=r.next}}function Xs(e){let t=0,r=Yt(0),n;return()=>{Fn()&&(v(r),Vn(()=>(t===0&&(n=tr(()=>e(()=>Ar(r)))),t+=1,()=>{Vt(()=>{t-=1,t===0&&(n?.(),n=void 0,Ar(r))})})))}}var Qs=Kt|gr;function ei(e,t,r,n){new ti(e,t,r,n)}class ti{parent;is_pending=!1;transform_error;#e;#l=null;#t;#i;#r;#n=null;#o=null;#a=null;#s=null;#c=0;#u=0;#f=!1;#p=new Set;#v=new Set;#d=null;#_=Xs(()=>(this.#d=Yt(this.#c),()=>{this.#d=null}));constructor(t,r,n,o){this.#e=t,this.#t=r,this.#i=a=>{var s=ge;s.b=this,s.f|=_n,n(a)},this.parent=ge.b,this.transform_error=o??this.parent?.transform_error??(a=>a),this.#r=Ur(()=>{this.#g()},Qs)}#y(){try{this.#n=st(()=>this.#i(this.#e))}catch(t){this.error(t)}}#x(t){const r=this.#t.failed;r&&(this.#a=st(()=>{r(this.#e,()=>t,()=>()=>{})}))}#w(){const t=this.#t.pending;if(t){this.is_pending=!0,this.#o=st(()=>t(this.#e));var r=me;Vt(()=>{var n=this.#s=document.createDocumentFragment(),o=kt();n.append(o),this.#n=this.#h(()=>st(()=>this.#i(o))),this.#u===0&&(this.#e.before(n),this.#s=null,qt(this.#o,()=>{this.#o=null}),this.#m(r))})}}#g(){var t=me;try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#c=0,this.#n=st(()=>{this.#i(this.#e)}),this.#u>0){var r=this.#s=document.createDocumentFragment();Bn(this.#n,r);const n=this.#t.pending;this.#o=st(()=>n(this.#e))}else this.#m(t)}catch(n){this.error(n)}}#m(t){this.is_pending=!1;for(const r of this.#p)ke(r,Fe),t.schedule(r);for(const r of this.#v)ke(r,gt),t.schedule(r);this.#p.clear(),this.#v.clear()}defer_effect(t){Qo(t,this.#p,this.#v)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#t.pending}#h(t){var r=ge,n=ve,o=Te;_t(this.#r),ft(this.#r),pr(this.#r.ctx);try{return Tt.ensure(),t()}catch(a){return Yo(a),null}finally{_t(r),ft(n),pr(o)}}#b(t,r){if(!this.has_pending_snippet()){this.parent&&this.parent.#b(t,r);return}this.#u+=t,this.#u===0&&(this.#m(r),this.#o&&qt(this.#o,()=>{this.#o=null}),this.#s&&(this.#e.before(this.#s),this.#s=null))}update_pending_count(t,r){this.#b(t,r),this.#c+=t,!(!this.#d||this.#f)&&(this.#f=!0,Vt(()=>{this.#f=!1,this.#d&&vr(this.#d,this.#c)}))}get_effect_pending(){return this.#_(),v(this.#d)}error(t){var r=this.#t.onerror;let n=this.#t.failed;if(!r&&!n)throw t;this.#n&&(et(this.#n),this.#n=null),this.#o&&(et(this.#o),this.#o=null),this.#a&&(et(this.#a),this.#a=null);var o=!1,a=!1;const s=()=>{if(o){Vs();return}o=!0,a&&As(),this.#a!==null&&qt(this.#a,()=>{this.#a=null}),this.#h(()=>{this.#g()})},i=c=>{try{a=!0,r?.(c,s),a=!1}catch(l){Pt(l,this.#r&&this.#r.parent)}n&&(this.#a=this.#h(()=>{try{return st(()=>{var l=ge;l.b=this,l.f|=_n,n(this.#e,()=>c,()=>s)})}catch(l){return Pt(l,this.#r.parent),null}}))};Vt(()=>{var c;try{c=this.transform_error(t)}catch(l){Pt(l,this.#r&&this.#r.parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(i,l=>Pt(l,this.#r&&this.#r.parent)):i(c)})}}function ri(e,t,r,n){const o=br()?Vr:cr;var a=e.filter(p=>!p.settled);if(r.length===0&&a.length===0){n(t.map(o));return}var s=ge,i=ni(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(p=>p.promise)):null;function l(p){i();try{n(p)}catch(h){(s.f&ut)===0&&Pt(h,s)}tn()}if(r.length===0){c.then(()=>l(t.map(o)));return}var u=na();function m(){Promise.all(r.map(p=>oi(p))).then(p=>l([...t.map(o),...p])).catch(p=>Pt(p,s)).finally(()=>u())}c?c.then(()=>{i(),m(),tn()}):m()}function ni(){var e=ge,t=ve,r=Te,n=me;return function(a=!0){_t(e),ft(t),pr(r),a&&(e.f&ut)===0&&(n?.activate(),n?.apply())}}function tn(e=!0){_t(null),ft(null),pr(null),e&&me?.deactivate()}function na(){var e=ge.b,t=me,r=e.is_rendered();return e.update_pending_count(1,t),t.increment(r),(n=!1)=>{e.update_pending_count(-1,t),t.decrement(r,n)}}function Vr(e){var t=Ie|Fe,r=ve!==null&&(ve.f&Ie)!==0?ve:null;return ge!==null&&(ge.f|=gr),{ctx:Te,deps:null,effects:null,equals:Wo,f:t,fn:e,reactions:null,rv:0,v:Le,wv:0,parent:r??ge,ac:null}}function oi(e,t,r){let n=ge;n===null&&_s();var o=void 0,a=Yt(Le),s=!ve,i=new Map;return _i(()=>{var c=ge,l=Vo();o=l.promise;try{Promise.resolve(e()).then(l.resolve,l.reject).finally(tn)}catch(h){l.reject(h),tn()}var u=me;if(s){if((c.f&er)!==0)var m=na();if(n.b.is_rendered())i.get(u)?.reject(Et),i.delete(u);else{for(const h of i.values())h.reject(Et);i.clear()}i.set(u,l)}const p=(h,g=void 0)=>{if(m){var _=g===Et;m(_)}if(!(g===Et||(c.f&ut)!==0)){if(u.activate(),g)a.f|=Ct,vr(a,g);else{(a.f&Ct)!==0&&(a.f^=Ct),vr(a,h);for(const[b,x]of i){if(i.delete(b),b===u)break;x.reject(Et)}}u.deactivate()}};l.promise.then(p,h=>p(null,h||"unknown"))}),Mn(()=>{for(const c of i.values())c.reject(Et)}),new Promise(c=>{function l(u){function m(){u===o?c(a):l(o)}u.then(m,m)}l(o)})}function te(e){const t=Vr(e);return ba(t),t}function cr(e){const t=Vr(e);return t.equals=Ko,t}function ai(e){var t=e.effects;if(t!==null){e.effects=null;for(var r=0;rv(e))),t}function he(e,t,r=!1){ve!==null&&(!mt||(ve.f&oo)!==0)&&br()&&(ve.f&(Ie|Zt|On|oo))!==0&&(dt===null||!dr.call(dt,e))&&Ds();let n=r?it(t):t;return vr(e,n,Xr)}function vr(e,t,r=null){if(!e.equals(t)){var n=e.v;It?Nt.set(e,t):Nt.set(e,n),e.v=t;var o=Tt.ensure();if(o.capture(e,n),(e.f&Ie)!==0){const a=e;(e.f&Fe)!==0&&Zn(a),Nn(a)}e.wv=ya(),ia(e,Fe,r),br()&&ge!==null&&(ge.f&Ne)!==0&&(ge.f&(ht|Ht))===0&&(at===null?wi([e]):at.push(e)),!o.is_fork&&$n.size>0&&!sa&&li()}return t}function li(){sa=!1;for(const e of $n)(e.f&Ne)!==0&&ke(e,gt),Br(e)&&mr(e);$n.clear()}function ci(e,t=1){var r=v(e),n=t===1?r++:r--;return he(e,r),n}function Ar(e){he(e,e.v+1)}function ia(e,t,r){var n=e.reactions;if(n!==null)for(var o=br(),a=n.length,s=0;s{if(Ut===a)return i();var c=ve,l=Ut;ft(null),fo(a);var u=i();return ft(c),fo(l),u};return n&&r.set("length",we(e.length)),new Proxy(e,{defineProperty(i,c,l){(!("value"in l)||l.configurable===!1||l.enumerable===!1||l.writable===!1)&&ks();var u=r.get(c);return u===void 0?s(()=>{var m=we(l.value);return r.set(c,m),m}):he(u,l.value,!0),!0},deleteProperty(i,c){var l=r.get(c);if(l===void 0){if(c in i){const u=s(()=>we(Le));r.set(c,u),Ar(o)}}else he(l,Le),Ar(o);return!0},get(i,c,l){if(c===Ot)return e;var u=r.get(c),m=c in i;if(u===void 0&&(!m||lr(i,c)?.writable)&&(u=s(()=>{var h=it(m?i[c]:Le),g=we(h);return g}),r.set(c,u)),u!==void 0){var p=v(u);return p===Le?void 0:p}return Reflect.get(i,c,l)},getOwnPropertyDescriptor(i,c){var l=Reflect.getOwnPropertyDescriptor(i,c);if(l&&"value"in l){var u=r.get(c);u&&(l.value=v(u))}else if(l===void 0){var m=r.get(c),p=m?.v;if(m!==void 0&&p!==Le)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return l},has(i,c){if(c===Ot)return!0;var l=r.get(c),u=l!==void 0&&l.v!==Le||Reflect.has(i,c);if(l!==void 0||ge!==null&&(!u||lr(i,c)?.writable)){l===void 0&&(l=s(()=>{var p=u?it(i[c]):Le,h=we(p);return h}),r.set(c,l));var m=v(l);if(m===Le)return!1}return u},set(i,c,l,u){var m=r.get(c),p=c in i;if(n&&c==="length")for(var h=l;hwe(Le)),r.set(h+"",g))}if(m===void 0)(!p||lr(i,c)?.writable)&&(m=s(()=>we(void 0)),he(m,it(l)),r.set(c,m));else{p=m.v!==Le;var _=s(()=>it(l));he(m,_)}var b=Reflect.getOwnPropertyDescriptor(i,c);if(b?.set&&b.set.call(u,l),!p){if(n&&typeof c=="string"){var x=r.get("length"),J=Number(c);Number.isInteger(J)&&J>=x.v&&he(x,J+1)}Ar(o)}return!0},ownKeys(i){v(o);var c=Reflect.ownKeys(i).filter(m=>{var p=r.get(m);return p===void 0||p.v!==Le});for(var[l,u]of r)u.v!==Le&&!(l in i)&&c.push(l);return c},setPrototypeOf(){zs()}})}function io(e){try{if(e!==null&&typeof e=="object"&&Ot in e)return e[Ot]}catch{}return e}function ui(e,t){return Object.is(io(e),io(t))}var lo,la,ca,ua;function di(){if(lo===void 0){lo=window,la=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,r=Text.prototype;ca=lr(t,"firstChild").get,ua=lr(t,"nextSibling").get,ro(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),ro(r)&&(r.__t=void 0)}}function kt(e=""){return document.createTextNode(e)}function rn(e){return ca.call(e)}function qr(e){return ua.call(e)}function f(e,t){return rn(e)}function ue(e,t=!1){{var r=rn(e);return r instanceof Comment&&r.data===""?qr(r):r}}function d(e,t=1,r=!1){let n=e;for(;t--;)n=qr(n);return n}function fi(e){e.textContent=""}function da(){return!1}function pi(e,t,r){return document.createElementNS(Jo,e,void 0)}let co=!1;function vi(){co||(co=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(const t of e.target.elements)t.__on_r?.()})},{capture:!0}))}function Ln(e){var t=ve,r=ge;ft(null),_t(null);try{return e()}finally{ft(t),_t(r)}}function jn(e,t,r,n=r){e.addEventListener(t,()=>Ln(r));const o=e.__on_r;o?e.__on_r=()=>{o(),n(!0)}:e.__on_r=()=>n(!0),vi()}function fa(e){ge===null&&(ve===null&&$s(),ws()),It&&xs()}function mi(e,t){var r=t.last;r===null?t.last=t.first=e:(r.next=e,e.prev=r,t.last=e)}function yt(e,t){var r=ge;r!==null&&(r.f&ot)!==0&&(e|=ot);var n={ctx:Te,deps:null,nodes:null,f:e|Fe|ct,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null},o=n;if((e&fr)!==0)ar!==null?ar.push(n):Tt.ensure().schedule(n);else if(t!==null){try{mr(n)}catch(s){throw et(n),s}o.deps===null&&o.teardown===null&&o.nodes===null&&o.first===o.last&&(o.f&gr)===0&&(o=o.first,(e&Zt)!==0&&(e&Kt)!==0&&o!==null&&(o.f|=Kt))}if(o!==null&&(o.parent=r,r!==null&&mi(o,r),ve!==null&&(ve.f&Ie)!==0&&(e&Ht)===0)){var a=ve;(a.effects??=[]).push(o)}return n}function Fn(){return ve!==null&&!mt}function Mn(e){const t=yt(Fr,null);return ke(t,Ne),t.teardown=e,t}function Nr(e){fa();var t=ge.f,r=!ve&&(t&ht)!==0&&(t&er)===0;if(r){var n=Te;(n.e??=[]).push(e)}else return pa(e)}function pa(e){return yt(fr|Uo,e)}function hi(e){return fa(),yt(Fr|Uo,e)}function gi(e){Tt.ensure();const t=yt(Ht|gr,e);return(r={})=>new Promise(n=>{r.outro?qt(t,()=>{et(t),n(void 0)}):(et(t),n(void 0))})}function bi(e){return yt(fr,e)}function _i(e){return yt(On|gr,e)}function Vn(e,t=0){return yt(Fr|t,e)}function ae(e,t=[],r=[],n=[]){ri(n,t,r,o=>{yt(Fr,()=>e(...o.map(v)))})}function Ur(e,t=0){var r=yt(Zt|t,e);return r}function st(e){return yt(ht|gr,e)}function va(e){var t=e.teardown;if(t!==null){const r=It,n=ve;uo(!0),ft(null);try{t.call(null)}finally{uo(r),ft(n)}}}function qn(e,t=!1){var r=e.first;for(e.first=e.last=null;r!==null;){const o=r.ac;o!==null&&Ln(()=>{o.abort(Et)});var n=r.next;(r.f&Ht)!==0?r.parent=null:et(r,t),r=n}}function yi(e){for(var t=e.first;t!==null;){var r=t.next;(t.f&ht)===0&&et(t),t=r}}function et(e,t=!0){var r=!1;(t||(e.f&hs)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(xi(e.nodes.start,e.nodes.end),r=!0),ke(e,no),qn(e,t&&!r),Tr(e,0);var n=e.nodes&&e.nodes.t;if(n!==null)for(const a of n)a.stop();va(e),e.f^=no,e.f|=ut;var o=e.parent;o!==null&&o.first!==null&&ma(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function xi(e,t){for(;e!==null;){var r=e===t?null:qr(e);e.remove(),e=r}}function ma(e){var t=e.parent,r=e.prev,n=e.next;r!==null&&(r.next=n),n!==null&&(n.prev=r),t!==null&&(t.first===e&&(t.first=n),t.last===e&&(t.last=r))}function qt(e,t,r=!0){var n=[];ha(e,n,!0);var o=()=>{r&&et(e),t&&t()},a=n.length;if(a>0){var s=()=>--a||o();for(var i of n)i.out(s)}else o()}function ha(e,t,r){if((e.f&ot)===0){e.f^=ot;var n=e.nodes&&e.nodes.t;if(n!==null)for(const i of n)(i.is_global||r)&&t.push(i);for(var o=e.first;o!==null;){var a=o.next,s=(o.f&Kt)!==0||(o.f&ht)!==0&&(e.f&Zt)!==0;ha(o,t,s?r:!1),o=a}}}function Un(e){ga(e,!0)}function ga(e,t){if((e.f&ot)!==0){e.f^=ot,(e.f&Ne)===0&&(ke(e,Fe),Tt.ensure().schedule(e));for(var r=e.first;r!==null;){var n=r.next,o=(r.f&Kt)!==0||(r.f&ht)!==0;ga(r,o?t:!1),r=n}var a=e.nodes&&e.nodes.t;if(a!==null)for(const s of a)(s.is_global||t)&&s.in()}}function Bn(e,t){if(e.nodes)for(var r=e.nodes.start,n=e.nodes.end;r!==null;){var o=r===n?null:qr(r);t.append(r),r=o}}let Qr=!1,It=!1;function uo(e){It=e}let ve=null,mt=!1;function ft(e){ve=e}let ge=null;function _t(e){ge=e}let dt=null;function ba(e){ve!==null&&(dt===null?dt=[e]:dt.push(e))}let Xe=null,nt=0,at=null;function wi(e){at=e}let _a=1,Mt=0,Ut=Mt;function fo(e){Ut=e}function ya(){return++_a}function Br(e){var t=e.f;if((t&Fe)!==0)return!0;if(t&Ie&&(e.f&=~Gt),(t>)!==0){for(var r=e.deps,n=r.length,o=0;oe.wv)return!0}(t&ct)!==0&&vt===null&&ke(e,Ne)}return!1}function xa(e,t,r=!0){var n=e.reactions;if(n!==null&&!(dt!==null&&dr.call(dt,e)))for(var o=0;o{e.ac.abort(Et)}),e.ac=null);try{e.f|=yn;var u=e.fn,m=u();e.f|=er;var p=e.deps,h=me?.is_fork;if(Xe!==null){var g;if(h||Tr(e,nt),p!==null&&nt>0)for(p.length=nt+Xe.length,g=0;g{throw b});throw p}}finally{e[Sr]=t,delete e.currentTarget,ft(u),_t(m)}}}const Di=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Ai(e){return Di?.createHTML(e)??e}function Pi(e){var t=pi("template");return t.innerHTML=Ai(e.replaceAll("","")),t.content}function nn(e,t){var r=ge;r.nodes===null&&(r.nodes={start:e,end:t,a:null,t:null})}function k(e,t){var r=(t&js)!==0,n=(t&Fs)!==0,o,a=!e.startsWith("");return()=>{o===void 0&&(o=Pi(a?e:""+e),r||(o=rn(o)));var s=n||la?document.importNode(o,!0):o.cloneNode(!0);if(r){var i=rn(s),c=s.lastChild;nn(i,c)}else nn(s,s);return s}}function Jn(e=""){{var t=kt(e+"");return nn(t,t),t}}function Bt(){var e=document.createDocumentFragment(),t=document.createComment(""),r=kt();return e.append(t,r),nn(t,r),e}function $(e,t){e!==null&&e.before(t)}function G(e,t){var r=t==null?"":typeof t=="object"?`${t}`:t;r!==(e.__t??=e.nodeValue)&&(e.__t=r,e.nodeValue=`${r}`)}function Ci(e,t){return Oi(e,t)}const Wr=new Map;function Oi(e,{target:t,anchor:r,props:n={},events:o,context:a,intro:s=!0,transformError:i}){di();var c=void 0,l=gi(()=>{var u=r??t.appendChild(kt());ei(u,{pending:()=>{}},h=>{Ce({});var g=Te;a&&(g.c=a),o&&(n.$$events=o),c=e(h,n)||{},Oe()},i);var m=new Set,p=h=>{for(var g=0;g{for(var h of m)for(const b of[t,document]){var g=Wr.get(b),_=g.get(h);--_==0?(b.removeEventListener(h,vo),g.delete(h),g.size===0&&Wr.delete(b)):g.set(h,_)}Sn.delete(p),u!==r&&u.parentNode?.removeChild(u)}});return Ni.set(c,l),c}let Ni=new WeakMap;class Wn{anchor;#e=new Map;#l=new Map;#t=new Map;#i=new Set;#r=!0;constructor(t,r=!0){this.anchor=t,this.#r=r}#n=t=>{if(this.#e.has(t)){var r=this.#e.get(t),n=this.#l.get(r);if(n)Un(n),this.#i.delete(r);else{var o=this.#t.get(r);o&&(this.#l.set(r,o.effect),this.#t.delete(r),o.fragment.lastChild.remove(),this.anchor.before(o.fragment),n=o.effect)}for(const[a,s]of this.#e){if(this.#e.delete(a),a===t)break;const i=this.#t.get(s);i&&(et(i.effect),this.#t.delete(s))}for(const[a,s]of this.#l){if(a===r||this.#i.has(a))continue;const i=()=>{if(Array.from(this.#e.values()).includes(a)){var l=document.createDocumentFragment();Bn(s,l),l.append(kt()),this.#t.set(a,{effect:s,fragment:l})}else et(s);this.#i.delete(a),this.#l.delete(a)};this.#r||!n?(this.#i.add(a),qt(s,i,!1)):i()}}};#o=t=>{this.#e.delete(t);const r=Array.from(this.#e.values());for(const[n,o]of this.#t)r.includes(n)||(et(o.effect),this.#t.delete(n))};ensure(t,r){var n=me,o=da();if(r&&!this.#l.has(t)&&!this.#t.has(t))if(o){var a=document.createDocumentFragment(),s=kt();a.append(s),this.#t.set(t,{effect:st(()=>r(s)),fragment:a})}else this.#l.set(t,st(()=>r(this.anchor)));if(this.#e.set(n,t),o){for(const[i,c]of this.#l)i===t?n.unskip_effect(c):n.skip_effect(c);for(const[i,c]of this.#t)i===t?n.unskip_effect(c.effect):n.skip_effect(c.effect);n.oncommit(this.#n),n.ondiscard(this.#o)}else this.#n(n)}}function se(e,t,r=!1){var n=new Wn(e),o=r?Kt:0;function a(s,i){n.ensure(s,i)}Ur(()=>{var s=!1;t((i,c=0)=>{s=!0,a(c,i)}),s||a(-1,null)},o)}const Ti=Symbol("NaN");function Ii(e,t,r){var n=new Wn(e),o=!br();Ur(()=>{var a=t();a!==a&&(a=Ti),o&&a!==null&&typeof a=="object"&&(a={}),n.ensure(a,r)})}function Ir(e,t){return t}function Zi(e,t,r){for(var n=[],o=t.length,a,s=t.length,i=0;i{if(a){if(a.pending.delete(m),a.done.add(m),a.pending.size===0){var p=e.outrogroups;kn(e,cn(a.done)),p.delete(a),p.size===0&&(e.outrogroups=null)}}else s-=1},!1)}if(s===0){var c=n.length===0&&r!==null;if(c){var l=r,u=l.parentNode;fi(u),u.append(l),e.items.clear()}kn(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function kn(e,t,r=!0){var n;if(e.pending.size>0){n=new Set;for(const s of e.pending.values())for(const i of s)n.add(e.items.get(i).e)}for(var o=0;o{var A=r();return Pn(A)?A:A==null?[]:cn(A)}),p,h=new Map,g=!0;function _(A){(J.effect.f&ut)===0&&(J.pending.delete(A),J.fallback=u,Ri(J,p,s,t,n),u!==null&&(p.length===0?(u.f&bt)===0?Un(u):(u.f^=bt,kr(u,null,s)):qt(u,()=>{u=null})))}function b(A){J.pending.delete(A)}var x=Ur(()=>{p=v(m);for(var A=p.length,D=new Set,R=me,K=da(),T=0;Ta(s)):(u=st(()=>a(mo??=kt())),u.f|=bt)),A>D.size&&ys(),!g)if(h.set(R,D),K){for(const[F,q]of i)D.has(F)||R.skip_effect(q.e);R.oncommit(_),R.ondiscard(b)}else _(R);v(m)}),J={effect:x,items:i,pending:h,outrogroups:null,fallback:u};g=!1}function Er(e){for(;e!==null&&(e.f&ht)===0;)e=e.next;return e}function Ri(e,t,r,n,o){var a=(n&Os)!==0,s=t.length,i=e.items,c=Er(e.effect.first),l,u=null,m,p=[],h=[],g,_,b,x;if(a)for(x=0;x0){var j=(n&Bo)!==0&&s===0?r:null;if(a){for(x=0;x{if(m!==void 0)for(b of m)b.nodes?.a?.apply()})}function Li(e,t,r,n,o,a,s,i){var c=(s&Ps)!==0?(s&Ns)===0?Rn(r,!1,!1):Yt(r):null,l=(s&Cs)!==0?Yt(o):null;return{v:c,i:l,e:st(()=>(a(t,c??r,l??o,i),()=>{e.delete(n)}))}}function kr(e,t,r){if(e.nodes)for(var n=e.nodes.start,o=e.nodes.end,a=t&&(t.f&bt)===0?t.nodes.start:r;n!==null;){var s=qr(n);if(a.before(n),n===o)return;n=s}}function At(e,t,r){t===null?e.effect.first=r:t.next=r,r===null?e.effect.last=t:r.prev=t}function Jt(e,t,...r){var n=new Wn(e);Ur(()=>{const o=t()??null;n.ensure(o,o&&(a=>o(a,...r)))},Kt)}function ji(e,t,r){var n=e==null?"":""+e;return n===""?null:n}function qe(e,t,r,n,o,a){var s=e.__className;if(s!==r||s===void 0){var i=ji(r);i==null?e.removeAttribute("class"):t?e.className=i:e.setAttribute("class",i),e.__className=r}return a}function ka(e,t,r=!1){if(e.multiple){if(t==null)return;if(!Pn(t))return Ms();for(var n of e.options)n.selected=t.includes(Pr(n));return}for(n of e.options){var o=Pr(n);if(ui(o,t)){n.selected=!0;return}}(!r||t!==void 0)&&(e.selectedIndex=-1)}function Fi(e){var t=new MutationObserver(()=>{ka(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Mn(()=>{t.disconnect()})}function un(e,t,r=t){var n=new WeakSet,o=!0;jn(e,"change",a=>{var s=a?"[selected]":":checked",i;if(e.multiple)i=[].map.call(e.querySelectorAll(s),Pr);else{var c=e.querySelector(s)??e.querySelector("option:not([disabled])");i=c&&Pr(c)}r(i),me!==null&&n.add(me)}),bi(()=>{var a=t();if(e===document.activeElement){var s=me;if(n.has(s))return}if(ka(e,a,o),o&&a===void 0){var i=e.querySelector(":checked");i!==null&&(a=Pr(i),r(a))}e.__value=a,o=!1}),Fi(e)}function Pr(e){return"__value"in e?e.__value:e.value}const Mi=Symbol("is custom element"),Vi=Symbol("is html");function je(e,t,r,n){var o=qi(e);o[t]!==(o[t]=r)&&(t==="loading"&&(e[bs]=r),r==null?e.removeAttribute(t):typeof r!="string"&&Ui(e).includes(t)?e[t]=r:e.setAttribute(t,r))}function qi(e){return e.__attributes??={[Mi]:e.nodeName.includes("-"),[Vi]:e.namespaceURI===Jo}}var ho=new Map;function Ui(e){var t=e.getAttribute("is")||e.nodeName,r=ho.get(t);if(r)return r;ho.set(t,r=[]);for(var n,o=e,a=Element.prototype;a!==o;){n=Mo(o);for(var s in n)n[s].set&&r.push(s);o=Cn(o)}return r}function Zr(e,t,r=t){var n=new WeakSet;jn(e,"input",async o=>{var a=o?e.defaultValue:e.value;if(a=mn(e)?hn(a):a,r(a),me!==null&&n.add(me),await Ei(),a!==(a=t())){var s=e.selectionStart,i=e.selectionEnd,c=e.value.length;if(e.value=a??"",i!==null){var l=e.value.length;s===i&&i===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=s,e.selectionEnd=Math.min(i,l))}}}),tr(t)==null&&e.value&&(r(mn(e)?hn(e.value):e.value),me!==null&&n.add(me)),Vn(()=>{var o=t();if(e===document.activeElement){var a=me;if(n.has(a))return}mn(e)&&o===hn(e.value)||e.type==="date"&&!o&&!e.value||o!==e.value&&(e.value=o??"")})}function Cr(e,t,r=t){jn(e,"change",n=>{var o=n?e.defaultChecked:e.checked;r(o)}),tr(t)==null&&r(e.checked),Vn(()=>{var n=t();e.checked=!!n})}function mn(e){var t=e.type;return t==="number"||t==="range"}function hn(e){return e===""?null:+e}function Bi(e=!1){const t=Te,r=t.l.u;if(!r)return;let n=()=>Si(t.s);if(e){let o=0,a={};const s=Vr(()=>{let i=!1;const c=t.s;for(const l in c)c[l]!==a[l]&&(a[l]=c[l],i=!0);return i&&o++,o});n=()=>v(s)}r.b.length&&hi(()=>{go(t,n),en(r.b)}),Nr(()=>{const o=tr(()=>r.m.map(ms));return()=>{for(const a of o)typeof a=="function"&&a()}}),r.a.length&&Nr(()=>{go(t,n),en(r.a)})}function go(e,t){if(e.l.s)for(const r of e.l.s)v(r);t()}function Qe(e,t,r,n){var o=!Mr||(r&Is)!==0,a=(r&Rs)!==0,s=(r&Ls)!==0,i=n,c=!0,l=()=>(c&&(c=!1,i=s?tr(n):n),i);let u;if(a){var m=Ot in e||gs in e;u=lr(e,t)?.set??(m&&t in e?A=>e[t]=A:void 0)}var p,h=!1;a?[p,h]=Hs(()=>e[t]):p=e[t],p===void 0&&n!==void 0&&(p=l(),u&&(o&&Ss(),u(p)));var g;if(o?g=()=>{var A=e[t];return A===void 0?l():(c=!0,A)}:g=()=>{var A=e[t];return A!==void 0&&(i=void 0),A===void 0?i:A},o&&(r&Zs)===0)return g;if(u){var _=e.$$legacy;return(function(A,D){return arguments.length>0?((!o||!D||_||h)&&u(D?g():A),A):g()})}var b=!1,x=((r&Ts)!==0?Vr:cr)(()=>(b=!1,g()));a&&v(x);var J=ge;return(function(A,D){if(arguments.length>0){const R=D?v(x):o&&a?it(A):A;return he(x,R),b=!0,i!==void 0&&(i=R),A}return It&&b||(J.f&ut)!==0?x.v:v(x)})}const Ji="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(Ji);function Wi(e){const t=e.batchSize,r=e.flushInterval,n=e.include,o=[];let a;const s=u=>!n||n.includes(u),i=(u,m)=>{s(u)&&(o.push({type:u,timestamp:Date.now(),detail:m}),o.length>=t&&c())},c=()=>{if(o.length===0)return;const u=o.splice(0);e.onFlush(u)};return{name:"analytics",onInit(){a=setInterval(c,r)},onChange(u){i("change",{property:u.property,currentValue:u.currentValue,oldValue:u.oldValue})},onValidation(u){i("validation",{hasErrors:u!==void 0})},onSnapshot(u){i("snapshot",{title:u.title})},onAction(u){i("action",{phase:u.phase,error:u.error?.message})},onRollback(u){i("rollback",{title:u.title})},onReset(){i("reset",{})},destroy(){a!==void 0&&clearInterval(a),c()},flush(){c()},eventCount(){return o.length}}}function Hi(e){const t=e.idle??1e3,r=e.interval??0,n=e.saveOnDestroy??!0,o=e.onlyWhenDirty??!0;let a,s,i,c=!1,l=!1;const u=async()=>{if(a&&!(o&&!Ye(a.state.isDirty))&&!c){c=!0;try{await e.save(a.data)}catch(g){e.onError?.(g)}finally{c=!1}}},m=()=>{clearTimeout(s),s=setTimeout(u,t)},p=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};return{name:"autosave",onInit(g){a=g,r>0&&(i=setInterval(u,r)),e.onVisibilityHidden&&typeof document<"u"&&document.addEventListener("visibilitychange",p)},onChange(){m()},onAction(g){g.phase==="after"&&!g.error&&clearTimeout(s)},destroy(){if(l=!0,clearTimeout(s),i!==void 0&&clearInterval(i),typeof document<"u"&&document.removeEventListener("visibilitychange",p),n&&a&&(c=!1,!o||Ye(a.state.isDirty)))try{e.save(a.data)}catch(_){e.onError?.(_)}},async saveNow(){l||(clearTimeout(s),c=!1,await u())},isSaving(){return c}}}function Ki(e){const t=e?.name,r=e?.collapsed??!0,n=(o,...a)=>{const s=new Date().toISOString().slice(11,23);(r?console.groupCollapsed:console.group)(`[${t}] ${o} (${s})`);for(const c of a)console.log(c);console.groupEnd()};return{name:"devtools",onChange(o){n("change",{property:o.property,from:o.oldValue,to:o.currentValue})},onValidation(o){n("validation",o)},onSnapshot(o){n("snapshot",{title:o.title})},onAction(o){o.error?n(`action:${o.phase}`,{params:o.params,error:o.error.message}):n(`action:${o.phase}`,{params:o.params})},onRollback(o){n("rollback",{title:o.title})},onReset(){n("reset")}}}const Gi=(e,t)=>{const r=t.split(".");let n=e;for(const o of r){if(n==null)return;n=n[o]}return n},Yi=(e,t,r)=>{const n=t.split(".");let o=e;for(let a=0;a{if(t){const n={};for(const o of t){const a=Gi(e,o);a!==void 0&&Yi(n,o,a)}return n}if(r){const n={...e};for(const o of r){const a=o.split(".");if(a.length===1)delete n[o];else{let s=n;for(let i=0;i"u"?void 0:localStorage),r=e.throttle??300,n=e.version??1;let o=!1,a,s;const i=()=>{if(!t||!s)return;const u=Xi(s,e.include,e.exclude),m={version:n,data:u};t.setItem(e.key,JSON.stringify(m))},c=()=>{clearTimeout(a),a=setTimeout(i,r)};return{name:"persist",onInit(u){if(s=u.data,!t)return;const m=t.getItem(e.key);if(m)try{let p=JSON.parse(m);e.migrate&&p.version!==n&&(p={version:n,data:e.migrate(p.data,p.version)}),Object.assign(u.data,p.data),o=!0}catch{}},onChange(){c()},onReset(){i()},destroy(){a!==void 0&&(clearTimeout(a),i())},clearPersistedState(){t?.removeItem(e.key)},isRestored(){return o}}}function el(e){const t=e.throttle,r=e.merge??"overwrite";let n,o,a=!1,s;const i=()=>{if(!n||!o)return;const u=JSON.parse(JSON.stringify(o.data));n.postMessage({type:"sync",data:u})},c=()=>{clearTimeout(s),s=setTimeout(i,t)},l=()=>{clearTimeout(s),n&&(n.close(),n=void 0)};return{name:"sync",onInit(u){o=u,!(typeof BroadcastChannel>"u")&&(n=new BroadcastChannel(e.key),n.addEventListener("message",m=>{!o||r==="ignore"||m.data?.type==="sync"&&(a=!0,Object.assign(o.data,m.data.data),a=!1)}))},onChange(){a||c()},destroy(){l()},disconnect(){l()}}}function tl(){const e=wt([]);let t=[],r,n;const o=i=>{if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return i.map(l=>o(l));const c=Object.create(Object.getPrototypeOf(i));for(const l of Object.keys(i))c[l]=o(i[l]);return c},a={name:"undo-redo",redoStack:{subscribe:e.subscribe},onInit(i){r=i,n=i.state.snapshots.subscribe(c=>{t=c})},onRollback(){s&&(e.update(i=>[...i,s]),s=void 0)},onChange(){e.set([])},onReset(){e.set([])},redo(){if(!r)return;const i=Ye(e);if(i.length===0)return;const c=i.at(-1);e.set(i.slice(0,-1)),r.snapshot("Undo"),Object.assign(r.data,o(c.data))},canRedo(){return Ye(e).length>0},destroy(){n?.()}};let s;return a.onInit,a.onInit=i=>{r=i,n=i.state.snapshots.subscribe(c=>{c.length0&&(s=t.at(-1)),t=c})},a}const rl=e=>typeof e=="object"&&e!==null&&!(e instanceof Date)&&!(e instanceof Map)&&!(e instanceof Set)&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Promise),nl=(e,t)=>{const r=(o,a)=>new Proxy(o,{get(s,i){const c=s[i];if(rl(c)){const l=Number.isInteger(Number(i))?"":String(i),u=l?a?`${a}.${l}`:l:a;return r(c,u)}return c},set(s,i,c){const l=s[i];if(l!==c){s[i]=c;const u=Number.isInteger(Number(i))?"":String(i),m=u?a?`${a}.${u}`:u:a;t(n,m,c,l)}return!0}}),n=r(e,"");return n},za=e=>Object.values(e).some(t=>typeof t=="string"?!!t:za(t)),ol=e=>!!e&&za(e),sr=e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return e.map(r=>sr(r));const t=Object.create(Object.getPrototypeOf(e));for(const r of Object.keys(e))t[r]=sr(e[r]);return t},al=(e,t)=>{const r=t.split(".");let n=e;for(const o of r){if(n==null)return;n=n[o]}return n},sl=(e,t)=>{if(!e)return"";const r=t.split(".");let n=e;for(const o of r){if(typeof n=="string"||n[o]===void 0)return"";n=n[o]}return typeof n=="string"?n:""},il=(e,t)=>{const r=[];for(const n of Object.keys(e))(n===t||n.startsWith(t+".")||t.startsWith(n+"."))&&r.push(n);return r},ll={resetDirtyOnAction:!0,debounceValidation:0,allowConcurrentActions:!1,persistActionError:!1,debounceAsyncValidation:300,runAsyncValidationOnInit:!1,clearAsyncErrorsOnChange:!0,maxConcurrentAsyncValidations:4,maxSnapshots:50,plugins:[]};function Be(e,t,r){const n={...ll,...r},{validator:o,effect:a,asyncValidator:s}=t??{},i=wt(),c=wr(i,ol),l=wt({}),u=wr(l,y=>Object.keys(y).length>0),m=wt(!1),p=wt(),h=wt([{title:"Initial",data:sr(e)}]),g=wt({}),_=wt(new Set),b=wr(_,y=>[...y]),x=wr(g,y=>Object.values(y).some(S=>!!S)),J=wr([c,x],([y,S])=>y||S),A=new Map,D=[],R=y=>{l.update(S=>{const C={...S,[y]:!0},ne=y.split(".");for(let de=1;de{for(const C of T){const ne=C[y];typeof ne=="function"&&ne.call(C,...S)}},j=()=>{if(!o)return;const y=o(B);i.set(y),P("onValidation",y)},z=(y,S=!0)=>{const C=Ye(h),ne={title:y,data:sr(K)},de=C.at(-1);let pe=S&&de&&de.title===y?[...C.slice(0,-1),ne]:[...C,ne];if(n.maxSnapshots>0&&pe.length>n.maxSnapshots){const Ze=pe.length-n.maxSnapshots;pe=[pe[0],...pe.slice(1+Ze)]}h.set(pe),P("onSnapshot",ne)};let F=!1,q;const I=()=>{if(o)if(n.debounceValidation>0)clearTimeout(q),q=setTimeout(()=>{j()},n.debounceValidation);else{if(F)return;F=!0,queueMicrotask(()=>{j(),F=!1})}},N=y=>{const S=D.indexOf(y);S!==-1&&D.splice(S,1)},M=y=>{N(y);const S=A.get(y);S&&(clearTimeout(S.timeoutId),S.controller.abort(),A.delete(y),_.update(C=>(C.delete(y),new Set(C))))},L=()=>{D.length=0;for(const y of A.keys())M(y);g.set({})},W=async(y,S)=>{if(!s){S();return}const C=s[y];if(!C){S();return}if(sl(Ye(i),y)){S();return}const de=new AbortController;A.set(y,{controller:de,timeoutId:0}),_.update(pe=>new Set([...pe,y]));try{const pe=al(B,y),Ze=await C(pe,B,de.signal);de.signal.aborted||g.update(Se=>({...Se,[y]:Ze}))}catch(pe){if(pe instanceof Error&&pe.name!=="AbortError")throw pe}finally{A.delete(y),_.update(pe=>(pe.delete(y),new Set(pe))),S()}},H=()=>{for(;D.length>0&&!(Ye(_).size>=n.maxConcurrentAsyncValidations);){const S=D.shift();S&&W(S,H)}},V=y=>{if(!s||!s[y])return;M(y),n.clearAsyncErrorsOnChange&&g.update(ne=>{const de={...ne};return delete de[y],de});const S=new AbortController,C=setTimeout(()=>{A.delete(y),Ye(_).size{if(!s)return;const S=il(s,y);for(const C of S)V(C)},B=nl(K,(y,S,C,ne)=>{if(n.persistActionError||p.set(void 0),R(S),a?.({snapshot:z,target:y,property:S,currentValue:C,oldValue:ne})instanceof Promise)throw new Error("svstate: effect callback must be synchronous. Use action for async operations.");P("onChange",{target:y,property:S,currentValue:C,oldValue:ne}),I(),w(S)});if(j(),s&&n.runAsyncValidationOnInit)for(const y of Object.keys(s))V(y);const Y=async y=>{if(!(!n.allowConcurrentActions&&Ye(m))){P("onAction",{phase:"before",params:y}),p.set(void 0),m.set(!0);try{await t?.action?.(y),n.resetDirtyOnAction&&l.set({}),h.set([{title:"Initial",data:sr(K)}]),await t?.actionCompleted?.(),P("onAction",{phase:"after",params:y})}catch(S){await t?.actionCompleted?.(S);const C=S instanceof Error?S:void 0;p.set(C),P("onAction",{phase:"after",params:y,error:C})}finally{m.set(!1)}}},X=(y,S)=>{const C=S[y];if(C)return L(),l.set({}),Object.assign(K,sr(C.data)),h.set(S.slice(0,y+1)),j(),C},Q=(y=1)=>{const S=Ye(h);if(S.length<=1)return;const C=Math.max(0,S.length-1-y),ne=X(C,S);ne&&P("onRollback",ne)},U=y=>{const S=Ye(h);if(S.length<=1)return!1;for(let C=S.length-1;C>=0;C--)if(S[C].title===y){const ne=X(C,S);return ne&&P("onRollback",ne),!0}return!1},Z=()=>{const y=Ye(h);y[0]&&(X(0,y),P("onReset"))},O={errors:i,hasErrors:c,isDirty:u,isDirtyByField:l,actionInProgress:m,actionError:p,snapshots:h,asyncErrors:g,hasAsyncErrors:x,asyncValidating:b,hasCombinedErrors:J},re=()=>{for(let y=T.length-1;y>=0;y--)T[y]?.destroy?.()};return P("onInit",{data:B,state:O,options:n,snapshot:z}),{data:B,execute:Y,state:O,rollback:Q,rollbackTo:U,reset:Z,destroy:re}}const cl={trim:e=>e.trim(),normalize:e=>e.replaceAll(/\s{2,}/g," "),upper:e=>e.toUpperCase(),lower:e=>e.toLowerCase(),localeUpper:e=>e.toLocaleUpperCase(),localeLower:e=>e.toLocaleLowerCase()};function ie(e){let t="";const r=e==null;let n=e??"";const o=s=>{t||(t=s)},a={prepare(...s){return n=s.reduce((i,c)=>cl[c](i),n),a},required(){return!t&&(r||!n)&&o("Required"),a},requiredIf(s){return s&&!t&&(r||!n)&&o("Required"),a},noSpace(){return r||!t&&n.includes(" ")&&o("No space allowed"),a},notBlank(){return r||!t&&n.length>0&&n.trim().length===0&&o("Must not be blank"),a},minLength(s){return r||!t&&n.lengths&&o(`Max length ${s}`),a},uppercase(){return r||!t&&n!==n.toUpperCase()&&o("Uppercase only"),a},lowercase(){return r||!t&&n!==n.toLowerCase()&&o("Lowercase only"),a},startsWith(s){if(t)return a;const i=Array.isArray(s)?s:[s];return n&&!i.some(c=>n.startsWith(c))&&o(`Must start with ${i.join(", ")}`),a},regexp(s,i){return!t&&n&&!s.test(n)&&o(i??"Not allowed chars"),a},in(s){if(t)return a;const i=Array.isArray(s)?s:Object.keys(s);return n&&!i.includes(n)&&o(`Must be one of: ${i.join(", ")}`),a},notIn(s){if(t)return a;const i=Array.isArray(s)?s:Object.keys(s);return n&&i.includes(n)&&o(`Must not be one of: ${i.join(", ")}`),a},email(){return!t&&n&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)&&o("Invalid email format"),a},website(s="optional"){if(t||!n||s==="optional")return a;const i=/^https?:\/\//.test(n);return s==="required"&&!i?o("Must start with http:// or https://"):s==="forbidden"&&i&&o("Must not start with http:// or https://"),a},endsWith(s){if(t||!n)return a;const i=Array.isArray(s)?s:[s];return i.some(c=>n.endsWith(c))||o(`Must end with ${i.join(", ")}`),a},contains(s){return!t&&n&&!n.includes(s)&&o(`Must contain "${s}"`),a},alphanumeric(){return!t&&n&&!/^[\dA-Za-z]+$/.test(n)&&o("Only letters and numbers allowed"),a},numeric(){return!t&&n&&!/^\d+$/.test(n)&&o("Only numbers allowed"),a},slug(){return!t&&n&&!/^[\da-z-]+$/.test(n)&&o("Invalid slug format"),a},identifier(){return!t&&n&&!/^[A-Z_a-z]\w*$/.test(n)&&o("Invalid identifier format"),a},getError(){return t}};return a}function Rr(e){let t="";const r=e==null,n=a=>{t||(t=a)},o={required(){return!t&&(r||Number.isNaN(e))&&n("Required"),o},requiredIf(a){return a&&!t&&(r||Number.isNaN(e))&&n("Required"),o},min(a){return r||!t&&ea&&n(`Maximum ${a}`),o},between(a,s){return r||!t&&(es)&&n(`Must be between ${a} and ${s}`),o},integer(){return r||!t&&!Number.isInteger(e)&&n("Must be an integer"),o},positive(){return r||!t&&e<=0&&n("Must be positive"),o},negative(){return r||!t&&e>=0&&n("Must be negative"),o},nonNegative(){return r||!t&&e<0&&n("Must be non-negative"),o},notZero(){return r||!t&&e===0&&n("Must not be zero"),o},multipleOf(a){return r||!t&&e%a!==0&&n(`Must be a multiple of ${a}`),o},step(a){return r||!t&&e%a!==0&&n(`Must be a multiple of ${a}`),o},decimal(a){return r||t||Number.isNaN(e)||(String(e).split(".")[1]?.length??0)>a&&n(`Maximum ${a} decimal places`),o},percentage(){return r||!t&&(e<0||e>100)&&n("Must be between 0 and 100"),o},getError(){return t}};return o}function ul(e){let t="";const r=e==null,n=e??[],o=s=>{t||(t=s)},a={required(){return!t&&(r||n.length===0)&&o("Required"),a},requiredIf(s){return s&&!t&&(r||n.length===0)&&o("Required"),a},minLength(s){return r||!t&&n.lengths&&o(`Maximum ${s} items`),a},unique(){if(r||t)return a;const s=new Set;for(const i of n){const c=typeof i=="object"?JSON.stringify(i):String(i);if(s.has(c)){o("Items must be unique");break}s.add(c)}return a},ofLength(s){return r||!t&&n.length!==s&&o(`Must have exactly ${s} items`),a},includes(s){if(r||t)return a;const i=typeof s=="object"?JSON.stringify(s):String(s);return n.some(l=>(typeof l=="object"?JSON.stringify(l):String(l))===i)||o(`Must include ${i}`),a},includesAny(s){if(r||t)return a;const i=s.map(l=>typeof l=="object"?JSON.stringify(l):String(l));return n.some(l=>{const u=typeof l=="object"?JSON.stringify(l):String(l);return i.includes(u)})||o(`Must include at least one of: ${i.join(", ")}`),a},includesAll(s){if(r||t)return a;const i=new Set(n.map(l=>typeof l=="object"?JSON.stringify(l):String(l))),c=s.filter(l=>{const u=typeof l=="object"?JSON.stringify(l):String(l);return!i.has(u)});if(c.length>0){const l=c.map(u=>typeof u=="object"?JSON.stringify(u):String(u));o(`Missing required items: ${l.join(", ")}`)}return a},getError(){return t}};return a}var dl=k('
'),fl=k('
 
');function fe(e,t){var r=fl(),n=f(r);{var o=i=>{var c=dl(),l=f(c);ae(()=>G(l,t.title)),$(i,c)};se(n,i=>{t.title&&i(o)})}var a=d(n,2),s=f(a);ae(()=>G(s,t.code)),$(e,r)}var pl=k('
Dirty Fields
 
'),vl=k('
State Object
 
State Info
isDirty:
hasErrors:
Errors
 
');function Je(e,t){Ce(t,!0);let r=Qe(t,"width",3,"xl:w-80");var n=vl(),o=f(n),a=d(f(o),2),s=f(a),i=d(o,2),c=d(f(i),2),l=f(c),u=d(f(l)),m=d(l,2),p=d(f(m)),h=d(i,2);{var g=A=>{var D=pl(),R=d(f(D),2),K=f(R);ae(T=>G(K,T),[()=>JSON.stringify(t.isDirtyByField,Object.keys(t.isDirtyByField).toSorted(),2)]),$(A,D)};se(h,A=>{t.isDirtyByField&&A(g)})}var _=d(h,2),b=d(f(_),2),x=f(b),J=d(_,2);ae((A,D)=>{qe(n,1,`w-full ${r()??""} flex-shrink-0 space-y-4`),G(s,A),G(u,` ${t.isDirty??""}`),G(p,` ${t.hasErrors??""}`),G(x,D)},[()=>JSON.stringify(t.data,void 0,2),()=>JSON.stringify(t.errors,void 0,2)]),ye("click",J,function(...A){t.onFill?.apply(this,A)}),$(e,n),Oe()}tt(["click"]);var ml=k('

');function Or(e,t){var r=Bt(),n=ue(r);{var o=a=>{var s=ml(),i=f(s);ae(()=>G(i,t.error)),$(a,s)};se(n,a=>{t.error&&a(o)})}$(e,r)}var hl=k(''),gl=k("
");function le(e,t){Ce(t,!0);let r=Qe(t,"type",3,"text"),n=Qe(t,"placeholder",3,""),o=Qe(t,"value",15),a=Qe(t,"error",3,""),s=Qe(t,"required",3,!0),i=Qe(t,"disabled",3,!1),c=Qe(t,"variant",3,"default");const l=te(()=>c()==="nested"?"bg-white":"bg-gray-50");var u=gl(),m=f(u),p=f(m),h=d(p);{var g=x=>{var J=hl();$(x,J)};se(h,x=>{t.isDirty&&x(g)})}var _=d(m,2),b=d(_,2);{let x=te(()=>a()??"");Or(b,{get error(){return v(x)}})}ae(()=>{qe(m,1,`mb-2 block text-sm text-gray-900 ${s()?"font-bold":""}`),je(m,"for",t.id),G(p,`${t.label??""} `),je(_,"id",t.id),qe(_,1,`block w-full rounded-lg border p-2.5 text-sm ${a()?"border-red-500 bg-red-50 text-red-900 placeholder-red-400 focus:border-red-500 focus:ring-red-500":`border-gray-300 ${v(l)} text-gray-900 focus:border-blue-500 focus:ring-blue-500`} ${i()?"cursor-not-allowed opacity-50":""}`),_.disabled=i(),je(_,"max",t.max),je(_,"min",t.min),je(_,"placeholder",n()),je(_,"step",t.step),je(_,"type",r())}),Zr(_,o),$(e,u),Oe()}var bl=k('

'),_l=k('
'),yl=k('
',1);function We(e,t){var r=yl(),n=ue(r),o=f(n),a=f(o),s=f(a),i=d(a,2);{var c=g=>{var _=bl(),b=f(_);ae(()=>G(b,t.description)),$(g,_)},l=g=>{var _=_l();$(g,_)};se(i,g=>{t.description?g(c):g(l,-1)})}var u=d(i,2);Jt(u,()=>t.main);var m=d(o,2);Jt(m,()=>t.sidebar);var p=d(n,2);{var h=g=>{var _=Bt(),b=ue(_);Jt(b,()=>t.sourceCode),$(g,_)};se(p,g=>{t.sourceCode&&g(h)})}ae(()=>G(s,t.title)),$(e,r)}var xl=k('
'),wl=k('
');function He(e,t){let r=we(!1);var n=wl(),o=f(n),a=d(f(o),2),s=d(o,2);{var i=c=>{var l=xl(),u=f(l);Jt(u,()=>t.children),$(c,l)};se(s,c=>{v(r)&&c(i)})}ae(()=>{qe(o,1,`flex w-full cursor-pointer items-center justify-between px-4 py-3 text-left text-sm font-medium text-gray-900 hover:bg-gray-50 ${v(r)?"border-b border-gray-200":""}`),qe(a,0,`h-5 w-5 transform transition-transform ${v(r)?"rotate-180":""}`)}),ye("click",o,()=>he(r,!v(r))),$(e,n)}tt(["click"]);var $l=k('
');function Ke(e,t){var r=$l(),n=f(r),o=f(n),a=d(n,2),s=f(a);ae(()=>{qe(n,1,`rounded px-2.5 py-0.5 text-xs font-medium ${t.hasErrors?"bg-red-100 text-red-800":"bg-green-100 text-green-800"}`),G(o,t.hasErrors?"Has Errors":"Valid"),qe(a,1,`rounded px-2.5 py-0.5 text-xs font-medium ${t.isDirty?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800"}`),G(s,t.isDirty?"Modified":"Clean")}),$(e,r)}const ce=()=>Math.random().toString(36).slice(2,8),lt=(e,t)=>Math.floor(Math.random()*(t-e+1))+e;var El=k('
'),Sl=k('
'),kl=k(' Submitting...'),zl=k('
',1),Dl=k('
Action State
actionInProgress:
actionError:
'),Al=k(" ",1);function Pl(e,t){Ce(t,!0);const r=()=>ee(_,"$hasErrors",i),n=()=>ee(b,"$isDirty",i),o=()=>ee(x,"$actionInProgress",i),a=()=>ee(g,"$errors",i),s=()=>ee(J,"$actionError",i),[i,c]=Ue(),l={title:`Task ${ce()}`,description:`This is a sample task description with ID ${ce()}`};let u=we(!1),m=we(void 0);const{data:p,execute:h,state:{errors:g,hasErrors:_,isDirty:b,actionInProgress:x,actionError:J}}=Be(l,{validator:P=>({title:ie(P.title).prepare("trim").required().minLength(3).maxLength(50).getError(),description:ie(P.description).prepare("trim").required().minLength(10).maxLength(200).getError()}),action:async()=>{const P=lt(100,1e3);if(await new Promise(j=>setTimeout(j,P)),v(u))throw new Error(`Simulated server error after ${P}ms`);he(m,`Submitted successfully in ${P}ms!`)},actionCompleted:P=>{P&&he(m,void 0)}}),A=()=>{p.title=`Task ${ce()}`,p.description=`This is a sample task description with ID ${ce()}`},D=()=>{he(m,void 0),h()},R=`const { data, execute, state: { errors, hasErrors, isDirty, actionInProgress, actionError } } = - createSvState(sourceData, { - validator: (source) => ({ - title: stringValidator(source.title).prepare('trim').required().minLength(3).maxLength(50).getError(), - description: stringValidator(source.description).prepare('trim').required().minLength(10).getError() - }), - action: async () => { - // Simulate API call with 100-1000ms delay - const delay = randomInt(100, 1000); - await new Promise((resolve) => setTimeout(resolve, delay)); - - if (shouldFail) { - throw new Error('Simulated server error'); - } - }, - actionCompleted: (error) => { - // Called after action completes (success or failure) - console.log(error ? 'Action failed' : 'Action succeeded'); - } - });`,K=`// Execute the action - - -// With parameters (if action accepts them) -execute({ userId: 123 });`,T=`// Display action error -{#if $actionError} -
- {$actionError.message} -
-{/if} - -// Check if action is in progress -{#if $actionInProgress} -
Submitting...
-{/if}`;We(e,{description:"Demonstrates async action execution with loading states and error handling.",title:"Action Demo",main:F=>{var q=zl(),I=ue(q);Ke(I,{get hasErrors(){return r()},get isDirty(){return n()}});var N=d(I,2),M=f(N),L=f(M),W=d(N,2),H=f(W);{let C=te(()=>a()?.title);le(H,{id:"title",get disabled(){return o()},get error(){return v(C)},label:"Title",placeholder:"Enter task title",get value(){return p.title},set value(ne){p.title=ne}})}var V=d(H,2);{let C=te(()=>a()?.description);le(V,{id:"description",get disabled(){return o()},get error(){return v(C)},label:"Description",placeholder:"Enter task description (min 10 characters)",get value(){return p.description},set value(ne){p.description=ne}})}var w=d(V,2),B=f(w),Y=d(W,2);{var X=C=>{var ne=El(),de=f(ne),pe=d(f(de),2),Ze=f(pe);ae(()=>G(Ze,s().message)),$(C,ne)};se(Y,C=>{s()&&C(X)})}var Q=d(Y,2);{var U=C=>{var ne=Sl(),de=f(ne),pe=d(f(de),2),Ze=f(pe);ae(()=>G(Ze,v(m))),$(C,ne)};se(Q,C=>{v(m)&&C(U)})}var Z=d(Q,2),O=f(Z),re=f(O);{var y=C=>{var ne=kl();$(C,ne)},S=C=>{var ne=Jn("Submit");$(C,ne)};se(re,C=>{o()?C(y):C(S,-1)})}ae(()=>{qe(M,1,`rounded px-2.5 py-0.5 text-xs font-medium ${o()?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`),G(L,o()?"In Progress":"Idle"),B.disabled=o(),O.disabled=r()||o()}),Cr(B,()=>v(u),C=>he(u,C)),ye("click",O,D),$(F,q)},sidebar:F=>{var q=Dl(),I=f(q);Je(I,{get data(){return p},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:A});var N=d(I,2),M=d(f(N),2),L=f(M),W=d(f(L)),H=d(L,2),V=d(f(H));ae(()=>{G(W,` ${o()??""}`),G(V,` ${s()?.message??"none"??""}`)}),$(F,q)},sourceCode:F=>{He(F,{children:(q,I)=>{var N=Al(),M=ue(N);fe(M,{code:R,title:"State Setup with Action"});var L=d(M,2);fe(L,{code:K,title:"Execute Action"});var W=d(L,2);fe(W,{code:T,title:"Error & Loading States"}),$(q,N)}})}}),Oe(),c()}tt(["click"]);var Cl=k('
');function Ol(e,t){let r=Qe(t,"label",3,"Item");var n=Cl(),o=f(n),a=f(o),s=f(a),i=d(a,2),c=d(o,2);Jt(c,()=>t.children),ae(()=>G(s,`${r()??""} #${t.index+1}`)),ye("click",i,function(...l){t.onRemove?.apply(this,l)}),$(e,n)}tt(["click"]);var Nl=k('

');function Tl(e,t){var r=Nl(),n=f(r),o=f(n);ae(()=>G(o,t.message)),$(e,r)}var Il=k('
'),Zl=k('
'),Rl=k('
'),Ll=k('
Contacts
',1),jl=k(" ",1);function Fl(e,t){Ce(t,!0);const r=()=>ee(u,"$hasErrors",a),n=()=>ee(m,"$isDirty",a),o=()=>ee(l,"$errors",a),[a,s]=Ue(),i={listName:"",items:[]},{data:c,state:{errors:l,hasErrors:u,isDirty:m}}=Be(i,{validator:x=>({listName:ie(x.listName).prepare("trim").required().minLength(2).getError(),items:ul(x.items).required().minLength(1).getError(),...Object.fromEntries(x.items.map((J,A)=>[`item_${A}`,{name:ie(J.name).prepare("trim").required().minLength(2).getError(),email:ie(J.email).prepare("trim").required().email().getError()}]))})}),p=()=>{c.items=[...c.items,{name:"",email:""}]},h=x=>{c.items=c.items.filter((J,A)=>A!==x)},g=()=>{c.listName=`Contact List ${ce()}`,c.items=[{name:"John Doe",email:"john@example.com"},{name:"Jane Smith",email:"jane@example.com"},{name:"Bob Wilson",email:"bob@example.com"}]},_=`const sourceData = { - listName: '', - items: [] as { name: string; email: string }[] -}; - -const { data, state: { errors, hasErrors, isDirty } } = createSvState(sourceData, { - validator: (source) => ({ - listName: stringValidator(source.listName).prepare('trim').required().minLength(2).getError(), - items: arrayValidator(source.items).required().minLength(1).getError(), - // Per-item validation using indexed keys - ...Object.fromEntries( - source.items.map((item, index) => [ - \`item_\${index}\`, - { - name: stringValidator(item.name).prepare('trim').required().minLength(2).getError(), - email: stringValidator(item.email).prepare('trim').required().email().getError() - } - ]) - ) - }) -});`,b=`// Define type for item errors -type ItemErrors = Record; - -{#each data.items as item, index} - - - - - -{/each}`;We(e,{description:"Shows how to validate dynamic arrays with per-item validation using indexed error keys.",title:"Array Property Demo",main:D=>{var R=Ll(),K=ue(R);Ke(K,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(K,2),P=f(T);{let w=te(()=>o()?.listName);le(P,{id:"listName",get error(){return v(w)},label:"List Name",placeholder:"Enter list name",get value(){return c.listName},set value(B){c.listName=B}})}var j=d(P,2),z=f(j),F=f(z),q=d(f(F)),I=f(q),N=d(F,2),M=d(z,2);{var L=w=>{var B=Il(),Y=f(B);Or(Y,{get error(){return o().items}}),$(w,B)};se(M,w=>{o()?.items&&w(L)})}var W=d(M,2);{var H=w=>{Tl(w,{message:'No contacts yet. Click "Add Contact" to get started.'})},V=w=>{var B=Rl();zt(B,21,()=>c.items,Ir,(Y,X,Q)=>{Ol(Y,{index:Q,label:"Contact",onRemove:()=>h(Q),children:(U,Z)=>{var O=Zl(),re=f(O),y=f(re);je(y,"for",`item-name-${Q}`);var S=d(y,2);je(S,"id",`item-name-${Q}`);var C=d(S,2);{let Se=te(()=>o()?.[`item_${Q}`]?.name??"");Or(C,{get error(){return v(Se)}})}var ne=d(re,2),de=f(ne);je(de,"for",`item-email-${Q}`);var pe=d(de,2);je(pe,"id",`item-email-${Q}`);var Ze=d(pe,2);{let Se=te(()=>o()?.[`item_${Q}`]?.email??"");Or(Ze,{get error(){return v(Se)}})}ae(()=>{qe(S,1,`block w-full rounded-lg border p-2 text-sm ${o()?.[`item_${Q}`]?.name?"border-red-500 bg-red-50 text-red-900 placeholder-red-400":"border-gray-300 bg-white text-gray-900"}`),qe(pe,1,`block w-full rounded-lg border p-2 text-sm ${o()?.[`item_${Q}`]?.email?"border-red-500 bg-red-50 text-red-900 placeholder-red-400":"border-gray-300 bg-white text-gray-900"}`)}),Zr(S,()=>v(X).name,Se=>v(X).name=Se),Zr(pe,()=>v(X).email,Se=>v(X).email=Se),$(U,O)},$$slots:{default:!0}})}),$(w,B)};se(W,w=>{c.items.length===0?w(H):w(V,-1)})}ae(()=>G(I,`${c.items.length??""} items`)),ye("click",N,p),$(D,R)},sidebar:D=>{Je(D,{get data(){return c},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:g,width:"xl:w-96"})},sourceCode:D=>{He(D,{children:(R,K)=>{var T=jl(),P=ue(T);fe(P,{code:_,title:"State Setup with Array Item Validation"});var j=d(P,2);fe(j,{code:b,title:"Array Form Binding Examples"}),$(R,T)}})}}),Oe(),s()}tt(["click"]);Us();var Ml=k('
'),Vl=k('
'),ql=k('
'),Ul=k(' Validating...'),Bl=k('
Taken usernames:
Taken emails:
Taken slugs:
Concurrency limit: maxConcurrentAsyncValidations = 2
Only 2 async validations run simultaneously. Try filling all 3 fields at once to see queuing in action.
',1),Jl=k('
Quick Fill
Async Validation State
asyncValidating:
hasAsyncErrors:
hasCombinedErrors:
Async Errors
 
'),Wl=k(" ",1);function Hl(e,t){Ce(t,!1);const r=()=>ee(J,"$hasErrors",l),n=()=>ee(A,"$isDirty",l),o=()=>ee(R,"$hasAsyncErrors",l),a=()=>ee(T,"$hasCombinedErrors",l),s=()=>ee(x,"$errors",l),i=()=>ee(D,"$asyncErrors",l),c=()=>ee(K,"$asyncValidating",l),[l,u]=Ue(),m=["admin","user","test","demo","root"],p=["admin@example.com","test@example.com","user@example.com"],h=["admin","about","contact","help","support"],_=Be({username:"",email:"",slug:""},{validator:I=>({username:ie(I.username).prepare("trim").required().minLength(3).maxLength(20).noSpace().getError(),email:ie(I.email).prepare("trim").required().email().getError(),slug:ie(I.slug).prepare("trim").required().minLength(2).slug().getError()}),asyncValidator:{username:async(I,N,M)=>{await new Promise((W,H)=>{const V=setTimeout(W,500);M.addEventListener("abort",()=>{clearTimeout(V),H(new DOMException("Aborted","AbortError"))})});const L=String(I).toLowerCase();return m.includes(L)?"Username is already taken":""},email:async(I,N,M)=>{await new Promise((W,H)=>{const V=setTimeout(W,400);M.addEventListener("abort",()=>{clearTimeout(V),H(new DOMException("Aborted","AbortError"))})});const L=String(I).toLowerCase();return p.includes(L)?"Email is already registered":""},slug:async(I,N,M)=>{await new Promise((W,H)=>{const V=setTimeout(W,600);M.addEventListener("abort",()=>{clearTimeout(V),H(new DOMException("Aborted","AbortError"))})});const L=String(I).toLowerCase();return h.includes(L)?"URL slug is already in use":""}}},{maxConcurrentAsyncValidations:2}),b=Rn(_.data),x=_.state.errors,J=_.state.hasErrors,A=_.state.isDirty,D=_.state.asyncErrors,R=_.state.hasAsyncErrors,K=_.state.asyncValidating,T=_.state.hasCombinedErrors,P=()=>{xt(b,v(b).username=`newuser${ce()}`),xt(b,v(b).email=`${ce()}@example.com`),xt(b,v(b).slug=`my-page-${ce()}`)},j=()=>{xt(b,v(b).username="admin"),xt(b,v(b).email="admin@example.com"),xt(b,v(b).slug="about")},z=`const { data, state: { errors, asyncErrors, asyncValidating, hasCombinedErrors } } = - createSvState(sourceData, { - validator: (source) => ({ - username: stringValidator(source.username).required().minLength(3).noSpace().getError(), - email: stringValidator(source.email).required().email().getError(), - slug: stringValidator(source.slug).required().minLength(2).slug().getError() - }), - asyncValidator: { - username: async (value, source, signal) => { - const res = await fetch(\`/api/check-username?u=\${value}\`, { signal }); - return (await res.json()).available ? '' : 'Username already taken'; - }, - email: async (value, source, signal) => { - const res = await fetch(\`/api/check-email?e=\${value}\`, { signal }); - return (await res.json()).available ? '' : 'Email already registered'; - }, - slug: async (value, source, signal) => { - const res = await fetch(\`/api/check-slug?s=\${value}\`, { signal }); - return (await res.json()).available ? '' : 'URL slug already in use'; - } - } - }, - { maxConcurrentAsyncValidations: 2 } // Only 2 async validations run at a time -);`,F=` -{#if $asyncValidating.includes('username')} - ... -{/if} - - -{#if $asyncErrors.username} - {$asyncErrors.username} -{/if} - - -`,q=`// Available stores for async validation: -$errors // Sync validation errors (nested object) -$hasErrors // true if any sync errors - -$asyncErrors // Async validation errors (flat map by path) -$hasAsyncErrors // true if any async errors - -$asyncValidating // Array of paths currently being validated -$hasCombinedErrors // hasErrors || hasAsyncErrors`;Bi(),We(e,{description:"Demonstrates async validation with simulated API calls for username and email uniqueness checks.",title:"Async Validation Demo",main:L=>{var W=Bl(),H=ue(W);Ke(H,{get hasErrors(){return r()},get isDirty(){return n()}});var V=d(H,2),w=f(V),B=f(w),Y=d(w,2),X=f(Y),Q=d(V,2),U=f(Q),Z=f(U);{let xe=cr(()=>s()?.username||i().username);le(Z,{id:"username",get error(){return v(xe)},label:"Username",placeholder:"Enter username (try 'admin', 'user', 'test')",get value(){return v(b).username},set value(Re){xt(b,v(b).username=Re)},$$legacy:!0})}var O=d(Z,2);{var re=xe=>{var Re=Ml();$(xe,Re)},y=te(()=>c().includes("username"));se(O,xe=>{v(y)&&xe(re)})}var S=d(U,2),C=f(S);{let xe=cr(()=>s()?.email||i().email);le(C,{id:"email",get error(){return v(xe)},label:"Email",placeholder:"Enter email (try 'admin@example.com')",type:"email",get value(){return v(b).email},set value(Re){xt(b,v(b).email=Re)},$$legacy:!0})}var ne=d(C,2);{var de=xe=>{var Re=Vl();$(xe,Re)},pe=te(()=>c().includes("email"));se(ne,xe=>{v(pe)&&xe(de)})}var Ze=d(S,2),Se=f(Ze);{let xe=cr(()=>s()?.slug||i().slug);le(Se,{id:"slug",get error(){return v(xe)},label:"URL Slug",placeholder:"Enter slug (try 'admin', 'about', 'contact')",get value(){return v(b).slug},set value(Re){xt(b,v(b).slug=Re)},$$legacy:!0})}var Ae=d(Se,2);{var Ge=xe=>{var Re=ql();$(xe,Re)},yr=te(()=>c().includes("slug"));se(Ae,xe=>{v(yr)&&xe(Ge)})}var be=d(Q,2),Pe=f(be),jt=d(f(Pe)),Dt=d(Pe,2),xr=d(f(Dt)),os=d(Dt,2),as=d(f(os)),ss=d(be,4),to=f(ss),is=f(to);{var ls=xe=>{var Re=Ul();$(xe,Re)},cs=xe=>{var Re=Jn("Submit");$(xe,Re)};se(is,xe=>{c().length>0?xe(ls):xe(cs,-1)})}ae((xe,Re,us)=>{qe(w,1,`rounded px-2.5 py-0.5 text-xs font-medium ${o()?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`),G(B,`Async Errors: ${o()?"Yes":"No"}`),qe(Y,1,`rounded px-2.5 py-0.5 text-xs font-medium ${a()?"bg-red-100 text-red-800":"bg-green-100 text-green-800"}`),G(X,`Combined: ${a()?"Has Errors":"Valid"}`),G(jt,` ${xe??""}`),G(xr,` ${Re??""}`),G(as,` ${us??""}`),to.disabled=a()||c().length>0},[()=>m.join(", "),()=>p.join(", "),()=>h.join(", ")]),$(L,W)},sidebar:L=>{var W=Jl(),H=f(W);Je(H,{get data(){return v(b)},get errors(){return s()},get hasErrors(){return r()},get isDirty(){return n()},onFill:P});var V=d(H,2),w=d(f(V),2),B=d(V,2),Y=d(f(B),2),X=f(Y),Q=d(f(X)),U=d(X,2),Z=d(f(U)),O=d(U,2),re=d(f(O)),y=d(B,2),S=d(f(y),2),C=f(S);ae((ne,de)=>{G(Q,` [${ne??""}]`),G(Z,` ${o()??""}`),G(re,` ${a()??""}`),G(C,de)},[()=>c().join(", "),()=>JSON.stringify(i(),void 0,2)]),ye("click",w,j),$(L,W)},sourceCode:L=>{He(L,{children:(W,H)=>{var V=Wl(),w=ue(V);fe(w,{code:z,title:"State Setup with Async Validators"});var B=d(w,2);fe(B,{code:F,title:"Template Usage"});var Y=d(B,2);fe(Y,{code:q,title:"Available Stores"}),$(W,V)}})}}),Oe(),u()}tt(["click"]);var Kl=k(''),Gl=k("
");function rr(e,t){Ce(t,!0);let r=Qe(t,"placeholder",3,""),n=Qe(t,"value",15),o=Qe(t,"error",3,""),a=Qe(t,"required",3,!1),s=Qe(t,"rows",3,3);var i=Gl(),c=f(i),l=f(c),u=d(l);{var m=g=>{var _=Kl();$(g,_)};se(u,g=>{t.isDirty&&g(m)})}var p=d(c,2),h=d(p,2);{let g=te(()=>o()??"");Or(h,{get error(){return v(g)}})}ae(()=>{qe(c,1,`mb-2 block text-sm text-gray-900 ${a()?"font-bold":""}`),je(c,"for",t.id),G(l,`${t.label??""} `),je(p,"id",t.id),qe(p,1,`block w-full rounded-lg border p-2.5 text-sm ${o()?"border-red-500 bg-red-50 text-red-900 placeholder-red-400 focus:border-red-500 focus:ring-red-500":"border-gray-300 bg-gray-50 text-gray-900 focus:border-blue-500 focus:ring-blue-500"}`),je(p,"placeholder",r()),je(p,"rows",s())}),Zr(p,n),$(e,i),Oe()}var Yl=k('
',1),Xl=k(" ",1);function Ql(e,t){Ce(t,!0);const r=()=>ee(m,"$hasErrors",s),n=()=>ee(p,"$isDirty",s),o=()=>ee(u,"$errors",s),a=()=>ee(h,"$isDirtyByField",s),[s,i]=Ue(),c={username:"",email:"",age:0,bio:"",website:""},{data:l,state:{errors:u,hasErrors:m,isDirty:p,isDirtyByField:h}}=Be(c,{validator:x=>({username:ie(x.username).prepare("trim").required().minLength(3).maxLength(20).noSpace().getError(),email:ie(x.email).prepare("trim").required().email().getError(),age:Rr(x.age).required().min(18).max(120).integer().getError(),bio:ie(x.bio).maxLength(200).getError(),website:ie(x.website).prepare("trim").website("required").getError()})}),g=()=>{l.username=`user${ce()}`,l.email=`${ce()}@example.com`,l.age=lt(18,65),l.bio="Hello, I am a demo user!",l.website=`https://${ce()}.com`},_=`const sourceData = { - username: '', - email: '', - age: 0, - bio: '', - website: '' -}; - -const { data, state: { errors, hasErrors, isDirty, isDirtyByField } } = createSvState(sourceData, { - validator: (source) => ({ - username: stringValidator(source.username).prepare('trim').required().minLength(3).maxLength(20).noSpace().getError(), - email: stringValidator(source.email).prepare('trim').required().email().getError(), - age: numberValidator(source.age).required().min(18).max(120).integer().getError(), - bio: stringValidator(source.bio).maxLength(200).getError(), - website: stringValidator(source.website).prepare('trim').website('required').getError() - }) -});`,b=` -`;We(e,{description:"Demonstrates form validation with string, number, and email validators using the fluent API.",title:"Basic Validation Demo",main:D=>{var R=Yl(),K=ue(R);Ke(K,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(K,2),P=f(T);{let I=te(()=>o()?.username);le(P,{id:"username",get error(){return v(I)},get isDirty(){return a().username},label:"Username",placeholder:"Enter username",get value(){return l.username},set value(N){l.username=N}})}var j=d(P,2);{let I=te(()=>o()?.email);le(j,{id:"email",get error(){return v(I)},get isDirty(){return a().email},label:"Email",placeholder:"Enter email",type:"email",get value(){return l.email},set value(N){l.email=N}})}var z=d(j,2);{let I=te(()=>o()?.age);le(z,{id:"age",get error(){return v(I)},get isDirty(){return a().age},label:"Age",placeholder:"Enter age",type:"number",get value(){return l.age},set value(N){l.age=N}})}var F=d(z,2);{let I=te(()=>o()?.bio);rr(F,{id:"bio",get error(){return v(I)},get isDirty(){return a().bio},label:"Bio",placeholder:"Tell us about yourself",get value(){return l.bio},set value(N){l.bio=N}})}var q=d(F,2);{let I=te(()=>o()?.website);le(q,{id:"website",get error(){return v(I)},get isDirty(){return a().website},label:"Website",placeholder:"https://example.com",required:!1,get value(){return l.website},set value(N){l.website=N}})}$(D,R)},sidebar:D=>{Je(D,{get data(){return l},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},get isDirtyByField(){return a()},onFill:g})},sourceCode:D=>{He(D,{children:(R,K)=>{var T=Xl(),P=ue(T);fe(P,{code:_,title:"State Setup"});var j=d(P,2);fe(j,{code:b,title:"Form Binding Example"}),$(R,T)}})}}),Oe(),i()}var ec=k(' '),tc=k('
');function Wt(e,t){var r=tc(),n=f(r),o=d(n);{var a=c=>{var l=ec(),u=f(l);ae(()=>G(u,`(${t.subtitle??""})`)),$(c,l)};se(o,c=>{t.subtitle&&c(a)})}var s=d(o,2);{var i=c=>{var l=Bt(),u=ue(l);Jt(u,()=>t.children),$(c,l)};se(s,c=>{t.children&&c(i)})}ae(()=>G(n,`${t.title??""} `)),$(e,r)}var rc=k('
Subtotal:
Tax (8%):
Total:

Values formatted using methods on state: data.formatCurrency() and data.formatTotal()

',1),nc=k(" ",1);function oc(e,t){Ce(t,!0);const r=()=>ee(m,"$hasErrors",a),n=()=>ee(p,"$isDirty",a),o=()=>ee(u,"$errors",a),[a,s]=Ue(),i=.08,c=()=>({productName:`Widget ${ce()}`,item:{unitPrice:0,quantity:1},subtotal:0,tax:0,total:0,formatTotal(){return`$${this.total.toFixed(2)}`},formatCurrency(x){return`$${x.toFixed(2)}`},calculateTotals(x=i){this.subtotal=this.item.unitPrice*this.item.quantity,this.tax=this.subtotal*x,this.total=this.subtotal+this.tax}}),{data:l,state:{errors:u,hasErrors:m,isDirty:p}}=Be(c(),{validator:x=>({productName:ie(x.productName).prepare("trim").required().minLength(2).getError(),item:{unitPrice:Rr(x.item.unitPrice).required().positive().getError(),quantity:Rr(x.item.quantity).required().integer().min(1).max(100).getError()}}),effect:({property:x})=>{(x==="item.unitPrice"||x==="item.quantity")&&l.calculateTotals()}}),h=()=>{l.productName=`Widget ${ce()}`,l.item.unitPrice=lt(10,100),l.item.quantity=lt(1,10)},g=`// Define state type with methods -type SourceData = { - productName: string; - item: { unitPrice: number; quantity: number }; - subtotal: number; - tax: number; - total: number; - formatTotal: () => string; - formatCurrency: (value: number) => string; - calculateTotals: (taxRate?: number) => void; -}; - -// Create initial state as object with methods -const createSourceData = (): SourceData => ({ - productName: '', - item: { unitPrice: 0, quantity: 1 }, - subtotal: 0, - tax: 0, - total: 0, - formatTotal() { - return \`$\${this.total.toFixed(2)}\`; - }, - formatCurrency(value: number) { - return \`$\${value.toFixed(2)}\`; - }, - calculateTotals(taxRate: number = 0.08) { - this.subtotal = this.item.unitPrice * this.item.quantity; - this.tax = this.subtotal * taxRate; - this.total = this.subtotal + this.tax; - } -});`,_=`const { data, state: { errors, hasErrors, isDirty } } = createSvState(createSourceData(), { - validator: (source) => ({ - productName: stringValidator(source.productName).prepare('trim').required().minLength(2).getError(), - item: { - unitPrice: numberValidator(source.item.unitPrice).required().positive().getError(), - quantity: numberValidator(source.item.quantity).required().integer().min(1).max(100).getError() - } - }), - effect: ({ property }) => { - if (property === 'item.unitPrice' || property === 'item.quantity') { - data.calculateTotals(); // Call method on state object! - } - } -});`,b=` -{data.formatCurrency(data.subtotal)} -{data.formatTotal()}`;We(e,{description:"Demonstrates using objects with methods as state. The effect callback can call methods directly on the state object.",title:"State with Methods Demo",main:D=>{var R=rc(),K=ue(R);Ke(K,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(K,2),P=f(T);{let O=te(()=>o()?.productName);le(P,{id:"productName",get error(){return v(O)},label:"Product Name",placeholder:"Enter product name",get value(){return l.productName},set value(re){l.productName=re}})}var j=d(P,2),z=f(j);Wt(z,{subtitle:"nested object",title:"Item Details"});var F=d(z,2),q=f(F);{let O=te(()=>o()?.item?.unitPrice);le(q,{id:"unitPrice",get error(){return v(O)},label:"Unit Price ($)",min:0,placeholder:"0.00",step:.01,type:"number",get value(){return l.item.unitPrice},set value(re){l.item.unitPrice=re}})}var I=d(q,2);{let O=te(()=>o()?.item?.quantity);le(I,{id:"quantity",get error(){return v(O)},label:"Quantity",max:100,min:1,placeholder:"1",type:"number",get value(){return l.item.quantity},set value(re){l.item.quantity=re}})}var N=d(j,2),M=f(N);Wt(M,{subtitle:"computed by method",title:"Calculated Totals"});var L=d(M,2),W=f(L),H=f(W),V=d(f(H),2),w=f(V),B=d(H,2),Y=d(f(B),2),X=f(Y),Q=d(B,2),U=d(f(Q),2),Z=f(U);ae((O,re,y)=>{G(w,O),G(X,re),G(Z,y)},[()=>l.formatCurrency(l.subtotal),()=>l.formatCurrency(l.tax),()=>l.formatTotal()]),$(D,R)},sidebar:D=>{Je(D,{get data(){return l},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:h})},sourceCode:D=>{He(D,{children:(R,K)=>{var T=nc(),P=ue(T);fe(P,{code:g,title:"Class Definition"});var j=d(P,2);fe(j,{code:_,title:"State Setup with Class Instance"});var z=d(j,2);fe(z,{code:b,title:"Template Usage"}),$(R,T)}})}}),Oe(),s()}var ac=k('
Subtotal:
Tax (8%):
Total:
',1),sc=k(" ",1);function ic(e,t){Ce(t,!0);const r=()=>ee(m,"$hasErrors",a),n=()=>ee(p,"$isDirty",a),o=()=>ee(u,"$errors",a),[a,s]=Ue(),i=.08,c={productName:`Widget ${ce()}`,item:{unitPrice:0,quantity:1},subtotal:0,tax:0,total:0},{data:l,state:{errors:u,hasErrors:m,isDirty:p}}=Be(c,{validator:x=>({productName:ie(x.productName).prepare("trim").required().minLength(2).getError(),item:{unitPrice:Rr(x.item.unitPrice).required().positive().getError(),quantity:Rr(x.item.quantity).required().integer().min(1).max(100).getError()}}),effect:({property:x})=>{(x==="item.unitPrice"||x==="item.quantity")&&(l.subtotal=l.item.unitPrice*l.item.quantity,l.tax=l.subtotal*i,l.total=l.subtotal+l.tax)}}),h=()=>{l.productName=`Widget ${ce()}`,l.item.unitPrice=lt(10,100),l.item.quantity=lt(1,10)},g=x=>`$${x.toFixed(2)}`,_=`const sourceData = { - productName: '', - item: { unitPrice: 0, quantity: 1 }, - subtotal: 0, tax: 0, total: 0 // Calculated fields (set by effect) -}; - -const TAX_RATE = 0.08; - -const { data, state: { errors, hasErrors, isDirty } } = createSvState(sourceData, { - validator: (source) => ({ - productName: stringValidator(source.productName).prepare('trim').required().minLength(2).getError(), - item: { - unitPrice: numberValidator(source.item.unitPrice).required().positive().getError(), - quantity: numberValidator(source.item.quantity).required().integer().min(1).max(100).getError() - } - }), - effect: ({ property }) => { - if (property === 'item.unitPrice' || property === 'item.quantity') { - data.subtotal = data.item.unitPrice * data.item.quantity; - data.tax = data.subtotal * TAX_RATE; - data.total = data.subtotal + data.tax; - } - } -});`,b=`effect: ({ property }) => { - if (property === 'item.unitPrice' || property === 'item.quantity') { - data.subtotal = data.item.unitPrice * data.item.quantity; - data.tax = data.subtotal * TAX_RATE; - data.total = data.subtotal + data.tax; - } -}`;We(e,{description:"Uses the effect callback to automatically compute derived values like subtotals, taxes, and totals.",title:"Calculated Fields Demo",main:D=>{var R=ac(),K=ue(R);Ke(K,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(K,2),P=f(T);{let O=te(()=>o()?.productName);le(P,{id:"productName",get error(){return v(O)},label:"Product Name",placeholder:"Enter product name",get value(){return l.productName},set value(re){l.productName=re}})}var j=d(P,2),z=f(j);Wt(z,{subtitle:"nested object",title:"Item Details"});var F=d(z,2),q=f(F);{let O=te(()=>o()?.item?.unitPrice);le(q,{id:"unitPrice",get error(){return v(O)},label:"Unit Price ($)",min:0,placeholder:"0.00",step:.01,type:"number",get value(){return l.item.unitPrice},set value(re){l.item.unitPrice=re}})}var I=d(q,2);{let O=te(()=>o()?.item?.quantity);le(I,{id:"quantity",get error(){return v(O)},label:"Quantity",max:100,min:1,placeholder:"1",type:"number",get value(){return l.item.quantity},set value(re){l.item.quantity=re}})}var N=d(j,2),M=f(N);Wt(M,{subtitle:"computed by effect",title:"Calculated Totals"});var L=d(M,2),W=f(L),H=f(W),V=d(f(H),2),w=f(V),B=d(H,2),Y=d(f(B),2),X=f(Y),Q=d(B,2),U=d(f(Q),2),Z=f(U);ae((O,re,y)=>{G(w,O),G(X,re),G(Z,y)},[()=>g(l.subtotal),()=>g(l.tax),()=>g(l.total)]),$(D,R)},sidebar:D=>{Je(D,{get data(){return l},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:h})},sourceCode:D=>{He(D,{children:(R,K)=>{var T=sc(),P=ue(T);fe(P,{code:_,title:"State Setup with Effect"});var j=d(P,2);fe(j,{code:b,title:"Effect Function"}),$(R,T)}})}}),Oe(),s()}var lc=k(' '),cc=k(''),uc=k('
');function dc(e,t){var r=uc(),n=f(r),o=f(n),a=d(o);{var s=u=>{var m=lc(),p=f(m);ae(()=>G(p,`(${t.subtitle??""})`)),$(u,m)};se(a,u=>{t.subtitle&&u(s)})}var i=d(a,2);{var c=u=>{var m=cc();$(u,m)};se(i,u=>{t.isDirty&&u(c)})}var l=d(n,2);Jt(l,()=>t.children),ae(()=>G(o,`${t.title??""} `)),$(e,r)}var fc=k(''),pc=k(''),vc=k(''),mc=k('
'),hc=k('
',1),gc=k(" ",1);function bc(e,t){Ce(t,!0);const r=()=>ee(m,"$hasErrors",s),n=()=>ee(p,"$isDirty",s),o=()=>ee(h,"$isDirtyByField",s),a=()=>ee(u,"$errors",s),[s,i]=Ue(),c={name:"",address:{street:"",city:"",zip:""},company:{name:"",department:"",contact:{phone:"",email:""}}},{data:l,state:{errors:u,hasErrors:m,isDirty:p,isDirtyByField:h}}=Be(c,{validator:x=>({name:ie(x.name).prepare("trim").required().minLength(2).maxLength(50).getError(),address:{street:ie(x.address.street).prepare("trim").required().minLength(5).getError(),city:ie(x.address.city).prepare("trim").required().minLength(2).getError(),zip:ie(x.address.zip).prepare("trim").required().minLength(5).maxLength(10).getError()},company:{name:ie(x.company.name).prepare("trim").required().minLength(2).getError(),department:ie(x.company.department).prepare("trim").maxLength(50).getError(),contact:{phone:ie(x.company.contact.phone).prepare("trim").required().minLength(10).getError(),email:ie(x.company.contact.email).prepare("trim").required().email().getError()}}})}),g=()=>{l.name=`John ${ce()}`,l.address.street=`${lt(100,9999)} Main Street`,l.address.city="New York",l.address.zip=`${lt(1e4,99999)}`,l.company.name=`Acme ${ce()} Inc`,l.company.department="Engineering",l.company.contact.phone=`555-${lt(100,999)}-${lt(1e3,9999)}`,l.company.contact.email=`contact@${ce()}.com`},_=`const sourceData = { - name: '', - address: { street: '', city: '', zip: '' }, // 2-level nested - company: { // 3-level nested - name: '', - department: '', - contact: { phone: '', email: '' } - } -}; - -const { data, state: { errors, hasErrors, isDirty, isDirtyByField } } = createSvState(sourceData, { - validator: (source) => ({ - name: stringValidator(source.name).prepare('trim').required().minLength(2).maxLength(50).getError(), - address: { - street: stringValidator(source.address.street).prepare('trim').required().minLength(5).getError(), - city: stringValidator(source.address.city).prepare('trim').required().minLength(2).getError(), - zip: stringValidator(source.address.zip).prepare('trim').required().minLength(5).maxLength(10).getError() - }, - company: { - name: stringValidator(source.company.name).prepare('trim').required().minLength(2).getError(), - department: stringValidator(source.company.department).prepare('trim').maxLength(50).getError(), - contact: { - phone: stringValidator(source.company.contact.phone).prepare('trim').required().minLength(10).getError(), - email: stringValidator(source.company.contact.email).prepare('trim').required().email().getError() - } - } - }) -});`,b=` - - - - - -`;We(e,{description:"Illustrates validating deeply nested object structures with multi-level property paths.",title:"Nested Objects Demo",main:D=>{var R=hc(),K=ue(R);Ke(K,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(K,2),P=f(T),j=f(P);Wt(j,{title:"Personal Info",children:(U,Z)=>{var O=Bt(),re=ue(O);{var y=S=>{var C=fc();$(S,C)};se(re,S=>{o().name&&S(y)})}$(U,O)}});var z=d(j,2);{let U=te(()=>a()?.name);le(z,{id:"name",get error(){return v(U)},label:"Full Name",placeholder:"Enter your full name",get value(){return l.name},set value(Z){l.name=Z}})}var F=d(P,2),q=f(F);Wt(q,{subtitle:"2-level nested",title:"Address",children:(U,Z)=>{var O=Bt(),re=ue(O);{var y=S=>{var C=pc();$(S,C)};se(re,S=>{o().address&&S(y)})}$(U,O)}});var I=d(q,2),N=f(I);{let U=te(()=>a()?.address?.street);le(N,{id:"street",get error(){return v(U)},label:"Street",placeholder:"Enter street address",get value(){return l.address.street},set value(Z){l.address.street=Z}})}var M=d(N,2),L=f(M);{let U=te(()=>a()?.address?.city);le(L,{id:"city",get error(){return v(U)},label:"City",placeholder:"Enter city",get value(){return l.address.city},set value(Z){l.address.city=Z}})}var W=d(L,2);{let U=te(()=>a()?.address?.zip);le(W,{id:"zip",get error(){return v(U)},label:"ZIP Code",placeholder:"Enter ZIP",get value(){return l.address.zip},set value(Z){l.address.zip=Z}})}var H=d(F,2),V=f(H);Wt(V,{subtitle:"3-level nested",title:"Company",children:(U,Z)=>{var O=Bt(),re=ue(O);{var y=S=>{var C=vc();$(S,C)};se(re,S=>{o().company&&S(y)})}$(U,O)}});var w=d(V,2),B=f(w),Y=f(B);{let U=te(()=>a()?.company?.name);le(Y,{id:"company-name",get error(){return v(U)},label:"Company Name",placeholder:"Enter company name",get value(){return l.company.name},set value(Z){l.company.name=Z}})}var X=d(Y,2);{let U=te(()=>a()?.company?.department);le(X,{id:"department",get error(){return v(U)},label:"Department",placeholder:"Enter department",required:!1,get value(){return l.company.department},set value(Z){l.company.department=Z}})}var Q=d(B,2);dc(Q,{get isDirty(){return o()["company.contact"]},subtitle:"3rd level",title:"Contact Info",children:(U,Z)=>{var O=mc(),re=f(O);{let S=te(()=>a()?.company?.contact?.phone);le(re,{id:"contact-phone",get error(){return v(S)},label:"Phone",placeholder:"Enter phone number",variant:"nested",get value(){return l.company.contact.phone},set value(C){l.company.contact.phone=C}})}var y=d(re,2);{let S=te(()=>a()?.company?.contact?.email);le(y,{id:"contact-email",get error(){return v(S)},label:"Email",placeholder:"Enter email address",type:"email",variant:"nested",get value(){return l.company.contact.email},set value(C){l.company.contact.email=C}})}$(U,O)}}),$(D,R)},sidebar:D=>{Je(D,{get data(){return l},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},get isDirtyByField(){return o()},onFill:g,width:"xl:w-96"})},sourceCode:D=>{He(D,{children:(R,K)=>{var T=gc(),P=ue(T);fe(P,{code:_,title:"State Setup with Nested Validation"});var j=d(P,2);fe(j,{code:b,title:"Nested Form Binding Examples"}),$(R,T)}})}}),Oe(),i()}var _c=k('
Effect triggered:
'),yc=k('
'),xc=k('
'),wc=k(' Submitting...'),$c=k('
',1),Ec=k('
Options

Reset isDirty after successful action

Try 500ms and type quickly

Keep errors until next action

Current Options
'),Sc=k(" ",1);function kc(e,t){Ce(t,!0);const r=()=>ee(v(R),"$hasErrors",i),n=()=>ee(v(K),"$isDirty",i),o=()=>ee(v(T),"$actionInProgress",i),a=()=>ee(v(D),"$errors",i),s=()=>ee(v(P),"$actionError",i),[i,c]=Ue();let l=we(!0),u=we(0),m=we(!1),p=we(0),h=we(!1),g=we(void 0),_=we(void 0);const b=()=>({name:`User ${ce()}`,email:`${ce()}@example.com`}),x=M=>Be(b(),{validator:L=>({name:ie(L.name).prepare("trim").required().minLength(2).maxLength(50).getError(),email:ie(L.email).prepare("trim").required().email().getError()}),effect:({property:L})=>{he(_,L,!0)},action:async()=>{const L=lt(100,800);if(await new Promise(W=>setTimeout(W,L)),v(h))throw new Error(`Simulated error after ${L}ms`);he(g,`Submitted successfully in ${L}ms!`)},actionCompleted:L=>{L&&he(g,void 0)}},M);let J=we(it(x({resetDirtyOnAction:!0,debounceValidation:0,persistActionError:!1})));const A=()=>{he(_,void 0),he(g,void 0),he(J,x({resetDirtyOnAction:v(l),debounceValidation:v(u),persistActionError:v(m)}),!0),ci(p)},D=te(()=>v(J).state.errors),R=te(()=>v(J).state.hasErrors),K=te(()=>v(J).state.isDirty),T=te(()=>v(J).state.actionInProgress),P=te(()=>v(J).state.actionError),j=()=>{v(J).data.name=`User ${ce()}`,v(J).data.email=`${ce()}@example.com`},z=()=>{he(g,void 0),v(J).execute()},F=`const { data, execute, state } = createSvState( - sourceData, - { validator, effect, action }, - { - // Reset isDirty to false after successful action - resetDirtyOnAction: true, // default: true - - // Debounce validation by N milliseconds - debounceValidation: 0, // default: 0 (uses queueMicrotask) - - // Keep action errors until next action (not cleared on data change) - persistActionError: false // default: false - } -);`,q=`// With resetDirtyOnAction: true (default) -await execute(); -// isDirty is now false - -// With resetDirtyOnAction: false -await execute(); -// isDirty remains true`,I=`// With debounceValidation: 0 (default) -// Validation runs via queueMicrotask after each change - -// With debounceValidation: 500 -// Validation runs 500ms after the last change -// Useful for expensive validators or rapid typing`,N=`// With persistActionError: false (default) -data.name = 'new value'; -// actionError is cleared immediately - -// With persistActionError: true -data.name = 'new value'; -// actionError remains until next execute() call`;We(e,{description:"Interactive playground for configuring createSvState options like debouncing and error persistence.",title:"Options Demo",main:H=>{var V=Bt(),w=ue(V);Ii(w,()=>v(p),B=>{var Y=$c(),X=ue(Y);Ke(X,{get hasErrors(){return r()},get isDirty(){return n()}});var Q=d(X,2);{var U=be=>{var Pe=_c(),jt=f(Pe),Dt=d(f(jt));ae(()=>G(Dt,` property "${v(_)??""}" changed`)),$(be,Pe)};se(Q,be=>{v(_)&&be(U)})}var Z=d(Q,2),O=f(Z);{let be=te(()=>a()?.name);le(O,{id:"name",get disabled(){return o()},get error(){return v(be)},label:"Name",placeholder:"Enter name",get value(){return v(J).data.name},set value(Pe){v(J).data.name=Pe}})}var re=d(O,2);{let be=te(()=>a()?.email);le(re,{id:"email",get disabled(){return o()},get error(){return v(be)},label:"Email",placeholder:"Enter email",type:"email",get value(){return v(J).data.email},set value(Pe){v(J).data.email=Pe}})}var y=d(re,2),S=f(y),C=d(Z,2);{var ne=be=>{var Pe=yc(),jt=f(Pe),Dt=d(f(jt),2),xr=f(Dt);ae(()=>G(xr,s().message)),$(be,Pe)};se(C,be=>{s()&&be(ne)})}var de=d(C,2);{var pe=be=>{var Pe=xc(),jt=f(Pe),Dt=d(f(jt),2),xr=f(Dt);ae(()=>G(xr,v(g))),$(be,Pe)};se(de,be=>{v(g)&&be(pe)})}var Ze=d(de,2),Se=f(Ze),Ae=f(Se);{var Ge=be=>{var Pe=wc();$(be,Pe)},yr=be=>{var Pe=Jn("Submit");$(be,Pe)};se(Ae,be=>{o()?be(Ge):be(yr,-1)})}ae(()=>{S.disabled=o(),Se.disabled=r()||o()}),Cr(S,()=>v(h),be=>he(h,be)),ye("click",Se,z),$(B,Y)}),$(H,V)},sidebar:H=>{var V=Ec(),w=f(V);Je(w,{get data(){return v(J).data},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:j});var B=d(w,2),Y=d(f(B),2),X=f(Y),Q=f(X),U=f(Q),Z=d(X,2),O=d(f(Z),2),re=d(Z,2),y=f(re),S=f(y),C=d(re,2),ne=d(B,2),de=d(f(ne),2),pe=f(de),Ze=f(pe),Se=d(pe,2),Ae=f(Se),Ge=d(Se,2),yr=f(Ge);ae(()=>{G(Ze,`resetDirtyOnAction: ${v(l)??""}`),G(Ae,`debounceValidation: ${v(u)??""}`),G(yr,`persistActionError: ${v(m)??""}`)}),Cr(U,()=>v(l),be=>he(l,be)),Zr(O,()=>v(u),be=>he(u,be)),Cr(S,()=>v(m),be=>he(m,be)),ye("click",C,A),$(H,V)},sourceCode:H=>{He(H,{children:(V,w)=>{var B=Sc(),Y=ue(B);fe(Y,{code:F,title:"Options Overview"});var X=d(Y,2);fe(X,{code:q,title:"resetDirtyOnAction"});var Q=d(X,2);fe(Q,{code:I,title:"debounceValidation"});var U=d(Q,2);fe(U,{code:N,title:"persistActionError"}),$(V,B)}})}}),Oe(),c()}tt(["click"]);var zc=k('Saving...'),Dc=k(''),Ac=k(`
Auto-save triggers 2 seconds after the last change. Analytics events buffer and flush at 10 events or every 10 - seconds.
`,1),Pc=k('

No saves yet — edit the form and wait 2s

'),Cc=k('
  • save
  • '),Oc=k('
      '),Nc=k('

      No flushes yet

      '),Tc=k('
    • flush
    • '),Ic=k('
        '),Zc=k('
        Autosave Log
        Analytics Buffer
        Buffered:
        Batch size: 10
        Flush interval: 10s
        Tracked: change, action, snapshot
        Flush History
        '),Rc=k(" ",1);function Lc(e,t){Ce(t,!0);const r=()=>ee(x,"$hasErrors",s),n=()=>ee(J,"$isDirty",s),o=()=>ee(b,"$errors",s),a=()=>ee(A,"$actionInProgress",s),[s,i]=Ue();let c=we(it([])),l=we(it([])),u=we(0);const m=Hi({save:async T=>{await new Promise(j=>setTimeout(j,300));const P=new Date().toISOString().slice(11,23);he(c,[...v(c),{id:ce(),timestamp:P,data:`${T.title} (${T.category})`}],!0)},idle:2e3,onlyWhenDirty:!0}),p=Wi({onFlush:T=>{const P=new Date().toISOString().slice(11,23),j={};for(const F of T)j[F.type]=(j[F.type]??0)+1;const z=Object.entries(j).map(([F,q])=>`${F}:${q}`).join(", ");he(l,[...v(l),{id:ce(),timestamp:P,eventCount:T.length,types:z}],!0)},batchSize:10,flushInterval:1e4,include:["change","action","snapshot"]}),{data:h,execute:g,reset:_,state:{errors:b,hasErrors:x,isDirty:J,actionInProgress:A}}=Be({title:"",category:"general",notes:""},{validator:T=>({title:ie(T.title).prepare("trim").required().minLength(2).maxLength(100).getError(),category:"",notes:ie(T.notes).maxLength(500).getError()}),effect:({snapshot:T,property:P})=>{const j=P.charAt(0).toUpperCase()+P.slice(1);T(`Changed ${j}`)},action:async()=>{await new Promise(T=>setTimeout(T,500))}},{plugins:[m,p]}),D=()=>{h.title=`Article ${ce()}`,h.category="tech",h.notes="Some interesting notes about the topic that should pass validation."};Nr(()=>{const T=setInterval(()=>{he(u,p.eventCount(),!0)},500);return()=>clearInterval(T)});const R=`import { createSvState, autosavePlugin, analyticsPlugin } from 'svstate'; - -const autosave = autosavePlugin({ - save: async (data) => { - await fetch('/api/save', { - method: 'POST', - body: JSON.stringify(data) - }); - }, - idle: 2000, // Save 2s after last change - onlyWhenDirty: true // Skip save if nothing changed -}); - -const analytics = analyticsPlugin({ - onFlush: (events) => { - sendToAnalytics(events); // Your analytics endpoint - }, - batchSize: 10, // Flush after 10 events - flushInterval: 10000, // Or every 10 seconds - include: ['change', 'action', 'snapshot'] // Filter event types -}); - -const { data, execute, state } = createSvState( - initialData, actuators, - { plugins: [autosave, analytics] } -);`,K=`// autosavePlugin API -autosave.saveNow(); // Force immediate save -autosave.isSaving(); // Check if currently saving - -// analyticsPlugin API -analytics.flush(); // Force flush buffered events -analytics.eventCount(); // Number of buffered events`;We(e,{description:"Auto-save with idle timer (autosavePlugin) and batched event analytics (analyticsPlugin).",title:"Plugin: Autosave & Analytics",main:z=>{var F=Ac(),q=ue(F);Ke(q,{get hasErrors(){return r()},get isDirty(){return n()}});var I=d(q,2),N=f(I),M=f(N),L=d(N,2),W=f(L),H=d(L,2);{var V=Ae=>{var Ge=zc();$(Ae,Ge)},w=te(()=>m.isSaving());se(H,Ae=>{v(w)&&Ae(V)})}var B=d(I,4),Y=f(B);{let Ae=te(()=>o()?.title);le(Y,{id:"title",get error(){return v(Ae)},label:"Title",placeholder:"Enter article title",get value(){return h.title},set value(Ge){h.title=Ge}})}var X=d(Y,2),Q=d(f(X),2),U=f(Q);U.value=U.__value="general";var Z=d(U);Z.value=Z.__value="tech";var O=d(Z);O.value=O.__value="science";var re=d(O);re.value=re.__value="culture";var y=d(X,2);{let Ae=te(()=>o()?.notes);rr(y,{id:"notes",get error(){return v(Ae)},label:"Notes",placeholder:"Write your notes (max 500 chars)",rows:4,get value(){return h.notes},set value(Ge){h.notes=Ge}})}var S=d(B,2),C=f(S),ne=f(C),de=d(C,2),pe=d(de,2),Ze=d(pe,2);{var Se=Ae=>{var Ge=Dc();ye("click",Ge,_),$(Ae,Ge)};se(Ze,Ae=>{n()&&Ae(Se)})}ae(()=>{G(M,`${v(c).length??""} Save${v(c).length===1?"":"s"}`),G(W,`${v(u)??""} Buffered Event${v(u)===1?"":"s"}`),C.disabled=r()||a(),G(ne,a()?"Submitting...":"Submit")}),un(Q,()=>h.category,Ae=>h.category=Ae),ye("click",C,()=>g()),ye("click",de,()=>m.saveNow()),ye("click",pe,()=>p.flush()),$(z,F)},sidebar:z=>{var F=Zc(),q=f(F);Je(q,{get data(){return h},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:D,width:"xl:w-96"});var I=d(q,2),N=d(f(I),2);{var M=U=>{var Z=Pc();$(U,Z)},L=U=>{var Z=Oc();zt(Z,21,()=>v(c),O=>O.id,(O,re)=>{var y=Cc(),S=d(f(y),2),C=f(S),ne=d(S,2),de=f(ne);ae(()=>{G(C,v(re).data),G(de,v(re).timestamp)}),$(O,y)}),$(U,Z)};se(N,U=>{v(c).length===0?U(M):U(L,-1)})}var W=d(I,2),H=d(f(W),2),V=f(H),w=d(f(V)),B=d(W,2),Y=d(f(B),2);{var X=U=>{var Z=Nc();$(U,Z)},Q=U=>{var Z=Ic();zt(Z,21,()=>v(l),O=>O.id,(O,re)=>{var y=Tc(),S=d(f(y),2),C=f(S),ne=d(S,2),de=f(ne);ae(()=>{G(C,`${v(re).eventCount??""} event${v(re).eventCount===1?"":"s"} (${v(re).types??""})`),G(de,v(re).timestamp)}),$(O,y)}),$(U,Z)};se(Y,U=>{v(l).length===0?U(X):U(Q,-1)})}ae(()=>G(w,` ${v(u)??""} event${v(u)===1?"":"s"}`)),$(z,F)},sourceCode:z=>{He(z,{children:(F,q)=>{var I=Rc(),N=ue(I);fe(N,{code:R,title:"autosavePlugin + analyticsPlugin Setup"});var M=d(N,2);fe(M,{code:K,title:"Plugin API"}),$(F,I)}})}}),Oe(),i()}tt(["click"]);var jc=k(''),Fc=k('
        ',1),Mc=k('

        No events yet — interact with the form

        '),Vc=k('
      • '),qc=k('
          '),Uc=k('
          Event Log
          '),Bc=k(" ",1);function Jc(e,t){Ce(t,!0);const r=()=>ee(x,"$hasErrors",i),n=()=>ee(J,"$isDirty",i),o=()=>ee(b,"$errors",i),a=()=>ee(D,"$actionInProgress",i),s=()=>ee(A,"$snapshots",i),[i,c]=Ue();let l=we(it([]));const u=(z,F)=>{const q=new Date().toISOString().slice(11,23);he(l,[...v(l),{id:ce(),type:z,message:F,timestamp:q}],!0)},m={name:"log-mirror",onChange(z){u("change",`${z.property}: "${z.oldValue}" → "${z.currentValue}"`)},onValidation(z){u("validation",z?"Has errors":"Valid")},onSnapshot(z){u("snapshot",z.title)},onAction(z){z.phase==="before"?u("action","Action started"):u("action",z.error?`Action failed: ${z.error.message}`:"Action completed")},onRollback(z){u("rollback",`Rolled back to: ${z.title}`)},onReset(){u("reset","State reset to initial")}},{data:p,execute:h,reset:g,rollback:_,state:{errors:b,hasErrors:x,isDirty:J,snapshots:A,actionInProgress:D}}=Be({name:"",email:"",message:""},{validator:z=>({name:ie(z.name).prepare("trim").required().minLength(2).maxLength(50).getError(),email:ie(z.email).prepare("trim").required().email().getError(),message:ie(z.message).prepare("trim").required().minLength(5).getError()}),effect:({snapshot:z,property:F})=>{const q=F.charAt(0).toUpperCase()+F.slice(1);z(`Changed ${q}`)},action:async()=>{await new Promise(z=>setTimeout(z,500))}},{plugins:[Ki({name:"demo-devtools"}),m]}),R=()=>{p.name=`John Doe ${ce()}`,p.email=`john.${ce()}@example.com`,p.message="Hello, this is a test message for the devtools demo."},K=()=>{he(l,[],!0)},T={change:"bg-blue-100 text-blue-800",validation:"bg-yellow-100 text-yellow-800",snapshot:"bg-purple-100 text-purple-800",action:"bg-green-100 text-green-800",rollback:"bg-amber-100 text-amber-800",reset:"bg-red-100 text-red-800"},P=`import { createSvState, devtoolsPlugin } from 'svstate'; - -const { data, execute, reset, rollback, state } = createSvState( - { name: '', email: '', message: '' }, - { - validator: (source) => ({ /* ... */ }), - effect: ({ snapshot, property }) => { - snapshot(\`Changed \${property}\`); - }, - action: async () => { await saveToServer(); } - }, - { - plugins: [ - devtoolsPlugin({ - name: 'my-form', // Label in console - enabled: true, // Auto-disabled in production - collapsed: true, // Console groups collapsed - logValidation: true // Also log validation events - }) - ] - } -);`,j=`// devtoolsPlugin logs these events to the console: -// - onChange: property changes with old/new values -// - onValidation: validation results (if logValidation: true) -// - onSnapshot: snapshot creation with title -// - onAction: action start/complete/error -// - onRollback: rollback with target snapshot title -// - onReset: state reset events`;We(e,{description:"Shows devtoolsPlugin console logging and a custom log-mirror plugin that captures all events in-page.",title:"Plugin: Devtools",main:I=>{var N=Fc(),M=ue(N);Ke(M,{get hasErrors(){return r()},get isDirty(){return n()}});var L=d(M,2),W=f(L);{let Z=te(()=>o()?.name);le(W,{id:"name",get error(){return v(Z)},label:"Name",placeholder:"Enter your name",get value(){return p.name},set value(O){p.name=O}})}var H=d(W,2);{let Z=te(()=>o()?.email);le(H,{id:"email",get error(){return v(Z)},label:"Email",placeholder:"Enter your email",type:"email",get value(){return p.email},set value(O){p.email=O}})}var V=d(H,2);{let Z=te(()=>o()?.message);rr(V,{id:"message",get error(){return v(Z)},label:"Message",placeholder:"Enter a message (min 5 chars)",required:!0,get value(){return p.message},set value(O){p.message=O}})}var w=d(L,2),B=f(w),Y=f(B),X=d(B,2),Q=d(X,2);{var U=Z=>{var O=jc();ye("click",O,g),$(Z,O)};se(Q,Z=>{n()&&Z(U)})}ae(()=>{B.disabled=r()||a(),G(Y,a()?"Submitting...":"Submit"),X.disabled=s().length<=1}),ye("click",B,()=>h()),ye("click",X,()=>_()),$(I,N)},sidebar:I=>{var N=Uc(),M=f(N);Je(M,{get data(){return p},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:R,width:"xl:w-96"});var L=d(M,2),W=f(L),H=d(f(W),2),V=d(W,2);{var w=Y=>{var X=Mc();$(Y,X)},B=Y=>{var X=qc();zt(X,21,()=>v(l),Q=>Q.id,(Q,U)=>{var Z=Vc(),O=f(Z),re=f(O),y=d(O,2),S=f(y),C=d(y,2),ne=f(C);ae(()=>{qe(O,1,`mt-0.5 flex-shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium ${T[v(U).type]??""}`),G(re,v(U).type),G(S,v(U).message),G(ne,v(U).timestamp)}),$(Q,Z)}),$(Y,X)};se(V,Y=>{v(l).length===0?Y(w):Y(B,-1)})}ye("click",H,K),$(I,N)},sourceCode:I=>{He(I,{children:(N,M)=>{var L=Bc(),W=ue(L);fe(W,{code:P,title:"devtoolsPlugin Setup"});var H=d(W,2);fe(H,{code:j,title:"What Gets Logged"}),$(N,L)}})}}),Oe(),c()}tt(["click"]);var Wc=k('Restored from storage'),Hc=k('Fresh state'),Kc=k(''),Gc=k('
          Try: Reload the page to see persistence. Open this page in another tab to see cross-tab sync.
          ',1),Yc=k('
          Persistence Info
          Restored:
          Key: svstate-demo-settings
          Excluded: notifications
          Raw localStorage
           
          Sync Info
          Channel: svstate-demo-sync
          Throttle: 200ms
          Merge: overwrite (default)
          '),Xc=k(" ",1);function Qc(e,t){Ce(t,!0);const r=()=>ee(p,"$hasErrors",a),n=()=>ee(h,"$isDirty",a),o=()=>ee(m,"$errors",a),[a,s]=Ue(),i=Qi({key:"svstate-demo-settings",throttle:300,exclude:["notifications"]}),c=el({key:"svstate-demo-sync",throttle:200}),{data:l,reset:u,state:{errors:m,hasErrors:p,isDirty:h}}=Be({username:"",theme:"light",fontSize:14,notifications:!0},{validator:D=>({username:ie(D.username).prepare("trim").required().minLength(2).maxLength(30).getError(),theme:"",fontSize:"",notifications:""})},{plugins:[i,c]}),g=i.isRestored(),_=()=>{i.clearPersistedState(),u()},b=()=>{l.username="demo_user",l.theme="dark",l.fontSize=16,l.notifications=!1};let x=we("");Nr(()=>{l.username,l.theme,l.fontSize,l.notifications;const D=setTimeout(()=>{he(x,localStorage.getItem("svstate-demo-settings")??"(empty)",!0)},500);return()=>clearTimeout(D)});const J=`import { createSvState, persistPlugin, syncPlugin } from 'svstate'; - -const persist = persistPlugin({ - key: 'svstate-demo-settings', - throttle: 300, - exclude: ['notifications'] // Don't persist this field -}); - -const sync = syncPlugin({ - key: 'svstate-demo-sync', - throttle: 200 -}); - -const { data, reset, state } = createSvState( - { username: '', theme: 'light', fontSize: 14, notifications: true }, - { validator: (source) => ({ /* ... */ }) }, - { plugins: [persist, sync] } -);`,A=`// persistPlugin API -persist.isRestored(); // true if data was loaded from storage -persist.clearPersistedState(); // Remove stored data - -// syncPlugin: automatic cross-tab sync via BroadcastChannel -// Changes in one tab appear in all other tabs with same key`;We(e,{description:"Settings form with persistPlugin (localStorage) and syncPlugin (cross-tab sync via BroadcastChannel).",title:"Plugin: Persist & Sync",main:T=>{var P=Gc(),j=ue(P);Ke(j,{get hasErrors(){return r()},get isDirty(){return n()}});var z=d(j,2),F=f(z);{var q=y=>{var S=Wc();$(y,S)},I=y=>{var S=Hc();$(y,S)};se(F,y=>{g?y(q):y(I,-1)})}var N=d(z,4),M=f(N);{let y=te(()=>o()?.username);le(M,{id:"username",get error(){return v(y)},label:"Username",placeholder:"Enter username",get value(){return l.username},set value(S){l.username=S}})}var L=d(M,2),W=d(f(L),2),H=f(W);H.value=H.__value="light";var V=d(H);V.value=V.__value="dark";var w=d(V);w.value=w.__value="system";var B=d(L,2);le(B,{id:"fontSize",label:"Font Size",max:32,min:8,step:1,type:"number",get value(){return l.fontSize},set value(y){l.fontSize=y}});var Y=d(B,2),X=f(Y),Q=f(X),U=d(N,2),Z=f(U),O=d(Z,2);{var re=y=>{var S=Kc();ye("click",S,u),$(y,S)};se(O,y=>{n()&&y(re)})}un(W,()=>l.theme,y=>l.theme=y),Cr(Q,()=>l.notifications,y=>l.notifications=y),ye("click",Z,_),$(T,P)},sidebar:T=>{var P=Yc(),j=f(P);Je(j,{get data(){return l},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:b,width:"xl:w-96"});var z=d(j,2),F=d(f(z),2),q=f(F),I=d(f(q)),N=d(z,2),M=d(f(N),2),L=f(M);ae(()=>{G(I,` ${g??""}`),G(L,v(x))}),$(T,P)},sourceCode:T=>{He(T,{children:(P,j)=>{var z=Xc(),F=ue(z);fe(F,{code:J,title:"persistPlugin + syncPlugin Setup"});var q=d(F,2);fe(q,{code:A,title:"Plugin API"}),$(P,z)}})}}),Oe(),s()}tt(["click"]);var eu=k(''),tu=k('
          Max: 10
          ',1),ru=k('

          No snapshots yet

          '),nu=k('
        • '),ou=k('
            '),au=k('

            No redo entries — undo something first

            '),su=k('
          • '),iu=k('
              '),lu=k('
              Snapshot History
              Redo Stack
              '),cu=k(" ",1);function uu(e,t){Ce(t,!0);const r=()=>ee(g,"$hasErrors",s),n=()=>ee(_,"$isDirty",s),o=()=>ee(b,"$snapshots",s),a=()=>ee(h,"$errors",s),[s,i]=Ue(),c=tl(),l=R=>R.charAt(0).toUpperCase()+R.slice(1).replaceAll(/([A-Z])/g," $1"),{data:u,reset:m,rollback:p,state:{errors:h,hasErrors:g,isDirty:_,snapshots:b}}=Be({title:"My Document",content:"",priority:"medium"},{validator:R=>({title:ie(R.title).prepare("trim").required().minLength(2).maxLength(100).getError(),content:ie(R.content).prepare("trim").required().minLength(10).getError(),priority:""}),effect:({snapshot:R,property:K})=>{R(`Changed ${l(K)}`)}},{maxSnapshots:10,plugins:[c]}),x=()=>{u.title=`Project Report ${ce()}`,u.content="This is a detailed document with enough content to pass validation requirements.",u.priority="high"};let J=we(it(Ye(c.redoStack)));Nr(()=>c.redoStack.subscribe(K=>{he(J,K,!0)}));const A=`import { createSvState, undoRedoPlugin } from 'svstate'; - -const undoRedo = undoRedoPlugin(); - -const { data, reset, rollback, state } = createSvState( - { title: 'My Document', content: '', priority: 'medium' }, - { - validator: (source) => ({ /* ... */ }), - effect: ({ snapshot, property }) => { - snapshot(\`Changed \${property}\`); - } - }, - { maxSnapshots: 10, plugins: [undoRedo] } -);`,D=`// Undo (built-in rollback) -rollback(); - -// Redo (from undoRedoPlugin) -undoRedo.redo(); - -// Check if redo is available -undoRedo.canRedo(); // boolean - -// Subscribe to redo stack -undoRedo.redoStack; // Readable`;We(e,{description:"Combines the built-in snapshot/rollback system with the undoRedoPlugin for full undo/redo support.",title:"Plugin: Undo/Redo",main:P=>{var j=tu(),z=ue(j);Ke(z,{get hasErrors(){return r()},get isDirty(){return n()}});var F=d(z,2),q=f(F),I=f(q),N=d(q,2),M=f(N),L=d(F,2),W=f(L);{let S=te(()=>a()?.title);le(W,{id:"title",get error(){return v(S)},label:"Title",placeholder:"Enter document title",get value(){return u.title},set value(C){u.title=C}})}var H=d(W,2);{let S=te(()=>a()?.content);rr(H,{id:"content",get error(){return v(S)},label:"Content",placeholder:"Write your document content (min 10 chars)",required:!0,rows:4,get value(){return u.content},set value(C){u.content=C}})}var V=d(H,2),w=d(f(V),2),B=f(w);B.value=B.__value="low";var Y=d(B);Y.value=Y.__value="medium";var X=d(Y);X.value=X.__value="high";var Q=d(X);Q.value=Q.__value="critical";var U=d(L,2),Z=f(U),O=d(Z,2),re=d(O,2);{var y=S=>{var C=eu();ye("click",C,m),$(S,C)};se(re,S=>{n()&&S(y)})}ae(()=>{G(I,`${o().length??""} Snapshot${o().length===1?"":"s"}`),G(M,`${v(J).length??""} Redo${v(J).length===1?"":"s"}`),Z.disabled=o().length<=1,O.disabled=v(J).length===0}),un(w,()=>u.priority,S=>u.priority=S),ye("click",Z,()=>p()),ye("click",O,()=>c.redo()),$(P,j)},sidebar:P=>{var j=lu(),z=f(j);Je(z,{get data(){return u},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:x,width:"xl:w-96"});var F=d(z,2),q=d(f(F),2);{var I=V=>{var w=ru();$(V,w)},N=V=>{var w=ou();zt(w,5,o,Ir,(B,Y,X)=>{var Q=nu(),U=f(Q);U.textContent=X+1;var Z=d(U,2),O=f(Z);ae(()=>G(O,v(Y).title)),$(B,Q)}),$(V,w)};se(q,V=>{o().length===0?V(I):V(N,-1)})}var M=d(F,2),L=d(f(M),2);{var W=V=>{var w=au();$(V,w)},H=V=>{var w=iu();zt(w,21,()=>v(J),Ir,(B,Y,X)=>{var Q=su(),U=f(Q);U.textContent=X+1;var Z=d(U,2),O=f(Z);ae(()=>G(O,v(Y).title)),$(B,Q)}),$(V,w)};se(L,V=>{v(J).length===0?V(W):V(H,-1)})}$(P,j)},sourceCode:P=>{He(P,{children:(j,z)=>{var F=cu(),q=ue(F);fe(q,{code:A,title:"Setup with undoRedoPlugin"});var I=d(q,2);fe(I,{code:D,title:"Undo/Redo Usage"}),$(j,F)}})}}),Oe(),i()}tt(["click"]);var du=k('
              '),fu=k('
              ',1),pu=k(" ",1);function vu(e,t){Ce(t,!0);const r=()=>ee(m,"$hasErrors",a),n=()=>ee(p,"$isDirty",a),o=()=>ee(u,"$errors",a),[a,s]=Ue(),i={firstName:"Alice",lastName:"Smith",email:"alice.smith@example.com",phone:"",bio:""},{data:c,reset:l,state:{errors:u,hasErrors:m,isDirty:p}}=Be(i,{validator:b=>({firstName:ie(b.firstName).prepare("trim").required().minLength(2).maxLength(30).getError(),lastName:ie(b.lastName).prepare("trim").required().minLength(2).maxLength(30).getError(),email:ie(b.email).prepare("trim").required().email().getError(),phone:ie(b.phone).prepare("trim").required().minLength(10).getError(),bio:ie(b.bio).maxLength(200).getError()})}),h=()=>{c.firstName="John",c.lastName=`Doe${ce()}`,c.email=`john.doe.${ce()}@example.com`,c.phone=`555-${ce().slice(0,3)}-${ce().slice(0,4)}`,c.bio="Software developer with a passion for clean code."},g=`const sourceData = { - firstName: 'Alice', - lastName: 'Smith', - email: 'alice.smith@example.com', - phone: '', - bio: '' -}; - -const { data, reset, state: { errors, hasErrors, isDirty } } = createSvState(sourceData, { - validator: (source) => ({ - firstName: stringValidator(source.firstName).prepare('trim').required().minLength(2).maxLength(30).getError(), - lastName: stringValidator(source.lastName).prepare('trim').required().minLength(2).maxLength(30).getError(), - email: stringValidator(source.email).prepare('trim').required().email().getError(), - phone: stringValidator(source.phone).prepare('trim').required().minLength(10).getError(), - bio: stringValidator(source.bio).maxLength(200).getError() - }) -});`,_=` -{#if $isDirty} - -{/if} - - -`;We(e,{description:"Demonstrates the reset() function to restore state back to its initial values.",title:"Reset Demo",main:A=>{var D=fu(),R=ue(D);Ke(R,{get hasErrors(){return r()},get isDirty(){return n()}});var K=d(R,2),T=f(K);{let N=te(()=>o()?.firstName);le(T,{id:"firstName",get error(){return v(N)},label:"First Name",placeholder:"Enter first name",get value(){return c.firstName},set value(M){c.firstName=M}})}var P=d(T,2);{let N=te(()=>o()?.lastName);le(P,{id:"lastName",get error(){return v(N)},label:"Last Name",placeholder:"Enter last name",get value(){return c.lastName},set value(M){c.lastName=M}})}var j=d(P,2);{let N=te(()=>o()?.email);le(j,{id:"email",get error(){return v(N)},label:"Email",placeholder:"Enter email",type:"email",get value(){return c.email},set value(M){c.email=M}})}var z=d(j,2);{let N=te(()=>o()?.phone);le(z,{id:"phone",get error(){return v(N)},label:"Phone",placeholder:"555-123-4567",get value(){return c.phone},set value(M){c.phone=M}})}var F=d(z,2);{let N=te(()=>o()?.bio);rr(F,{id:"bio",get error(){return v(N)},label:"Bio",placeholder:"Tell us about yourself",required:!1,get value(){return c.bio},set value(M){c.bio=M}})}var q=d(K,2);{var I=N=>{var M=du(),L=f(M);ye("click",L,l),$(N,M)};se(q,N=>{n()&&N(I)})}$(A,D)},sidebar:A=>{Je(A,{get data(){return c},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:h})},sourceCode:A=>{He(A,{children:(D,R)=>{var K=pu(),T=ue(K);fe(T,{code:g,title:"State Setup with Reset"});var P=d(T,2);fe(P,{code:_,title:"Conditional Reset Button"}),$(D,K)}})}}),Oe(),s()}tt(["click"]);var mu=k(''),hu=k('
              Max: 5
              ',1),gu=k('

              No snapshots yet

              '),bu=k('
            • '),_u=k('
                '),yu=k('
                Snapshot History
                '),xu=k(" ",1);function wu(e,t){Ce(t,!0);const r=()=>ee(_,"$hasErrors",s),n=()=>ee(b,"$isDirty",s),o=()=>ee(x,"$snapshots",s),a=()=>ee(g,"$errors",s),[s,i]=Ue(),c={firstName:"Alice",lastName:"Smith",email:"alice.smith@example.com",phone:"",bio:""},l=K=>K.charAt(0).toUpperCase()+K.slice(1).replaceAll(/([A-Z])/g," $1"),{data:u,reset:m,rollback:p,rollbackTo:h,state:{errors:g,hasErrors:_,isDirty:b,snapshots:x}}=Be(c,{validator:K=>({firstName:ie(K.firstName).prepare("trim").required().minLength(2).maxLength(30).getError(),lastName:ie(K.lastName).prepare("trim").required().minLength(2).maxLength(30).getError(),email:ie(K.email).prepare("trim").required().email().getError(),phone:ie(K.phone).prepare("trim").required().minLength(10).getError(),bio:ie(K.bio).maxLength(200).getError()}),effect:({snapshot:K,property:T})=>{K(`Changed ${l(T)}`)}},{maxSnapshots:5}),J=()=>{u.firstName="John",u.lastName=`Doe${ce()}`,u.email=`john.doe.${ce()}@example.com`,u.phone=`555-${ce().slice(0,3)}-${ce().slice(0,4)}`,u.bio="Software developer with a passion for clean code."},A=`const sourceData = { - firstName: 'Alice', lastName: 'Smith', email: 'alice.smith@example.com', phone: '', bio: '' -}; - -const { data, reset, rollback, rollbackTo, state: { errors, hasErrors, isDirty, snapshots } } = - createSvState(sourceData, { - validator: (source) => ({ /* validation rules */ }), - effect: ({ snapshot, property }) => { - snapshot(\`Changed \${formatFieldName(property)}\`); - } - }, { maxSnapshots: 5 });`,D=`// Effect callback creates snapshots on each change -effect: ({ snapshot, property }) => { - snapshot(\`Changed \${property}\`); // Creates undo point - // If same title, replaces last snapshot (debouncing) - // Use snapshot(title, false) to always create new -}`,R=`// Undo last change -rollback(); - -// Undo 3 changes at once -rollback(3); - -// Roll back to a named snapshot (returns true if found) -rollbackTo('Changed First Name'); - -// Roll back to initial state -rollbackTo('Initial'); - -// Reset to initial state (clears all snapshots) -reset();`;We(e,{description:"Shows snapshot creation for undo functionality with rollback(), rollbackTo(), and maxSnapshots support.",title:"Snapshot & Rollback Demo",main:j=>{var z=hu(),F=ue(z);Ke(F,{get hasErrors(){return r()},get isDirty(){return n()}});var q=d(F,2),I=f(q),N=f(I),M=d(q,2),L=f(M);{let Z=te(()=>a()?.firstName);le(L,{id:"firstName",get error(){return v(Z)},label:"First Name",placeholder:"Enter first name",get value(){return u.firstName},set value(O){u.firstName=O}})}var W=d(L,2);{let Z=te(()=>a()?.lastName);le(W,{id:"lastName",get error(){return v(Z)},label:"Last Name",placeholder:"Enter last name",get value(){return u.lastName},set value(O){u.lastName=O}})}var H=d(W,2);{let Z=te(()=>a()?.email);le(H,{id:"email",get error(){return v(Z)},label:"Email",placeholder:"Enter email",type:"email",get value(){return u.email},set value(O){u.email=O}})}var V=d(H,2);{let Z=te(()=>a()?.phone);le(V,{id:"phone",get error(){return v(Z)},label:"Phone",placeholder:"555-123-4567",get value(){return u.phone},set value(O){u.phone=O}})}var w=d(V,2);{let Z=te(()=>a()?.bio);rr(w,{id:"bio",get error(){return v(Z)},label:"Bio",placeholder:"Tell us about yourself",required:!1,get value(){return u.bio},set value(O){u.bio=O}})}var B=d(M,2),Y=f(B),X=d(Y,2),Q=d(X,2);{var U=Z=>{var O=mu();ye("click",O,m),$(Z,O)};se(Q,Z=>{n()&&Z(U)})}ae(()=>{G(N,`${o().length??""} Snapshot${o().length===1?"":"s"}`),Y.disabled=o().length<=1,X.disabled=o().length<=1}),ye("click",Y,()=>p()),ye("click",X,()=>h("Initial")),$(j,z)},sidebar:j=>{var z=yu(),F=f(z);Je(F,{get data(){return u},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:J,width:"xl:w-96"});var q=d(F,2),I=d(f(q),2);{var N=L=>{var W=gu();$(L,W)},M=L=>{var W=_u();zt(W,5,o,Ir,(H,V,w)=>{var B=bu(),Y=f(B);Y.textContent=w+1;var X=d(Y,2),Q=f(X);ae(()=>{X.disabled=o().length<=1,G(Q,v(V).title)}),ye("click",X,()=>h(v(V).title)),$(H,B)}),$(L,W)};se(I,L=>{o().length===0?L(N):L(M,-1)})}$(j,z)},sourceCode:j=>{He(j,{children:(z,F)=>{var q=xu(),I=ue(q);fe(I,{code:A,title:"State Setup with Snapshots & maxSnapshots"});var N=d(I,2);fe(N,{code:D,title:"Effect with Snapshot Creation"});var M=d(N,2);fe(M,{code:R,title:"Rollback, RollbackTo & Reset Usage"}),$(z,q)}})}}),Oe(),i()}tt(["click"]);function E(e,t,r){function n(i,c){if(i._zod||Object.defineProperty(i,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),i._zod.traits.has(e))return;i._zod.traits.add(e),t(i,c);const l=s.prototype,u=Object.keys(l);for(let m=0;mr?.Parent&&i instanceof r.Parent?!0:i?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Da extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Aa={};function Xt(e){return Aa}function Pa(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function zn(e,t){return typeof t=="bigint"?t.toString():t}function Hn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Kn(e){return e==null}function Gn(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function $u(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const c=n.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const a=r>o?r:o,s=Number.parseInt(e.toFixed(a).replace(".","")),i=Number.parseInt(t.toFixed(a).replace(".",""));return s%i/10**a}const bo=Symbol("evaluating");function _e(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==bo)return n===void 0&&(n=bo,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function nr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Rt(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function _o(e){return JSON.stringify(e)}function Eu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ca="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function on(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Su=Hn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Lr(e){if(on(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(on(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Oa(e){return Lr(e)?{...e}:Array.isArray(e)?[...e]:e}const ku=new Set(["string","number","symbol"]);function hr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lt(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function oe(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function zu(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Du={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Au(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=Rt(e._zod.def,{get shape(){const s={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(s[i]=r.shape[i])}return nr(this,"shape",s),s},checks:[]});return Lt(e,a)}function Pu(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=Rt(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete s[i]}return nr(this,"shape",s),s},checks:[]});return Lt(e,a)}function Cu(e,t){if(!Lr(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const a=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(a,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=Rt(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return nr(this,"shape",a),a}});return Lt(e,o)}function Ou(e,t){if(!Lr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=Rt(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return nr(this,"shape",n),n}});return Lt(e,r)}function Nu(e,t){const r=Rt(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return nr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return Lt(e,r)}function Tu(e,t,r){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=Rt(t._zod.def,{get shape(){const i=t._zod.def.shape,c={...i};if(r)for(const l in r){if(!(l in i))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=e?new e({type:"optional",innerType:i[l]}):i[l])}else for(const l in i)c[l]=e?new e({type:"optional",innerType:i[l]}):i[l];return nr(this,"shape",c),c},checks:[]});return Lt(t,s)}function Iu(e,t,r){const n=Rt(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(r)for(const s in r){if(!(s in a))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(a[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)a[s]=new e({type:"nonoptional",innerType:o[s]});return nr(this,"shape",a),a}});return Lt(t,n)}function ir(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Hr(e){return typeof e=="string"?e:e?.message}function Qt(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const o=Hr(e.inst?._zod.def?.error?.(e))??Hr(t?.error?.(e))??Hr(r.customError?.(e))??Hr(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Yn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function jr(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Ta=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,zn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ia=E("$ZodError",Ta),Za=E("$ZodError",Ta,{Parent:Error});function Zu(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ru(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>n({issues:s}));else if(a.code==="invalid_key")n({issues:a.issues});else if(a.code==="invalid_element")n({issues:a.issues});else if(a.path.length===0)r._errors.push(t(a));else{let s=r,i=0;for(;i(t,r,n,o)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},a);if(s instanceof Promise)throw new ur;if(s.issues.length){const i=new(o?.Err??e)(s.issues.map(c=>Qt(c,a,Xt())));throw Ca(i,o?.callee),i}return s.value},Qn=e=>async(t,r,n,o)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){const i=new(o?.Err??e)(s.issues.map(c=>Qt(c,a,Xt())));throw Ca(i,o?.callee),i}return s.value},dn=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new ur;return a.issues.length?{success:!1,error:new(e??Ia)(a.issues.map(s=>Qt(s,o,Xt())))}:{success:!0,data:a.value}},Lu=dn(Za),fn=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},o);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(s=>Qt(s,o,Xt())))}:{success:!0,data:a.value}},ju=fn(Za),Fu=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Xn(e)(t,r,o)},Mu=e=>(t,r,n)=>Xn(e)(t,r,n),Vu=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Qn(e)(t,r,o)},qu=e=>async(t,r,n)=>Qn(e)(t,r,n),Uu=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return dn(e)(t,r,o)},Bu=e=>(t,r,n)=>dn(e)(t,r,n),Ju=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return fn(e)(t,r,o)},Wu=e=>async(t,r,n)=>fn(e)(t,r,n),Hu=/^[cC][^\s-]{8,}$/,Ku=/^[0-9a-z]+$/,Gu=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yu=/^[0-9a-vA-V]{20}$/,Xu=/^[A-Za-z0-9]{27}$/,Qu=/^[a-zA-Z0-9_-]{21}$/,ed=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,td=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,yo=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,rd=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function od(){return new RegExp(nd,"u")}const ad=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,id=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ld=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,cd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ra=/^[A-Za-z0-9_-]*$/,ud=/^\+[1-9]\d{6,14}$/,La="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",dd=new RegExp(`^${La}$`);function ja(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function fd(e){return new RegExp(`^${ja(e)}$`)}function pd(e){const t=ja({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${La}T(?:${n})$`)}const vd=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},md=/^-?\d+$/,hd=/^-?\d+(?:\.\d+)?$/,gd=/^[^A-Z]*$/,bd=/^[^a-z]*$/,rt=E("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Fa={number:"number",bigint:"bigint",object:"date"},Ma=E("$ZodCheckLessThan",(e,t)=>{rt.init(e,t);const r=Fa[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,a=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{rt.init(e,t);const r=Fa[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,a=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_d=E("$ZodCheckMultipleOf",(e,t)=>{rt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):$u(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),yd=E("$ZodCheckNumberFormat",(e,t)=>{rt.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,a]=Du[t.format];e._zod.onattach.push(s=>{const i=s._zod.bag;i.format=t.format,i.minimum=o,i.maximum=a,r&&(i.pattern=md)}),e._zod.check=s=>{const i=s.value;if(r){if(!Number.isInteger(i)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});return}if(!Number.isSafeInteger(i)){i>0?s.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}ia&&s.issues.push({origin:"number",input:i,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),xd=E("$ZodCheckMaxLength",(e,t)=>{var r;rt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Kn(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum{const o=n.value;if(o.length<=t.maximum)return;const s=Yn(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),wd=E("$ZodCheckMinLength",(e,t)=>{var r;rt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Kn(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const s=Yn(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$d=E("$ZodCheckLengthEquals",(e,t)=>{var r;rt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Kn(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,a=o.length;if(a===t.length)return;const s=Yn(o),i=a>t.length;n.issues.push({origin:s,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),pn=E("$ZodCheckStringFormat",(e,t)=>{var r,n;rt.init(e,t),e._zod.onattach.push(o=>{const a=o._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ed=E("$ZodCheckRegex",(e,t)=>{pn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Sd=E("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=gd),pn.init(e,t)}),kd=E("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=bd),pn.init(e,t)}),zd=E("$ZodCheckIncludes",(e,t)=>{rt.init(e,t);const r=hr(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Dd=E("$ZodCheckStartsWith",(e,t)=>{rt.init(e,t);const r=new RegExp(`^${hr(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ad=E("$ZodCheckEndsWith",(e,t)=>{rt.init(e,t);const r=new RegExp(`.*${hr(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Pd=E("$ZodCheckOverwrite",(e,t)=>{rt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Cd{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(` -`).filter(s=>s),o=Math.min(...n.map(s=>s.length-s.trimStart().length)),a=n.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of a)this.content.push(s)}compile(){const t=Function,r=this?.args,o=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...r,o.join(` -`))}}const Od={major:4,minor:3,patch:6},ze=E("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Od;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const a of o._zod.onattach)a(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,i,c)=>{let l=ir(s),u;for(const m of i){if(m._zod.def.when){if(!m._zod.def.when(s))continue}else if(l)continue;const p=s.issues.length,h=m._zod.check(s);if(h instanceof Promise&&c?.async===!1)throw new ur;if(u||h instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await h,s.issues.length!==p&&(l||(l=ir(s,p)))});else{if(s.issues.length===p)continue;l||(l=ir(s,p))}}return u?u.then(()=>s):s},a=(s,i,c)=>{if(ir(s))return s.aborted=!0,s;const l=o(i,n,c);if(l instanceof Promise){if(c.async===!1)throw new ur;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(s,i)=>{if(i.skipChecks)return e._zod.parse(s,i);if(i.direction==="backward"){const l=e._zod.parse({value:s.value,issues:[]},{...i,skipChecks:!0});return l instanceof Promise?l.then(u=>a(u,s,i)):a(l,s,i)}const c=e._zod.parse(s,i);if(c instanceof Promise){if(i.async===!1)throw new ur;return c.then(l=>o(l,n,i))}return o(c,n,i)}}_e(e,"~standard",()=>({validate:o=>{try{const a=Lu(e,o);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return ju(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),eo=E("$ZodString",(e,t)=>{ze.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??vd(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),$e=E("$ZodStringFormat",(e,t)=>{pn.init(e,t),eo.init(e,t)}),Nd=E("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=td),$e.init(e,t)}),Td=E("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=yo(n))}else t.pattern??(t.pattern=yo());$e.init(e,t)}),Id=E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=rd),$e.init(e,t)}),Zd=E("$ZodURL",(e,t)=>{$e.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Rd=E("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=od()),$e.init(e,t)}),Ld=E("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Qu),$e.init(e,t)}),jd=E("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Hu),$e.init(e,t)}),Fd=E("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ku),$e.init(e,t)}),Md=E("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Gu),$e.init(e,t)}),Vd=E("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yu),$e.init(e,t)}),qd=E("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Xu),$e.init(e,t)}),Ud=E("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=pd(t)),$e.init(e,t)}),Bd=E("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=dd),$e.init(e,t)}),Jd=E("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=fd(t)),$e.init(e,t)}),Wd=E("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ed),$e.init(e,t)}),Hd=E("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ad),$e.init(e,t),e._zod.bag.format="ipv4"}),Kd=E("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sd),$e.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Gd=E("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=id),$e.init(e,t)}),Yd=E("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ld),$e.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,a]=n;if(!a)throw new Error;const s=Number(a);if(`${s}`!==a)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function qa(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Xd=E("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=cd),$e.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{qa(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Qd(e){if(!Ra.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qa(r)}const ef=E("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ra),$e.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Qd(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),tf=E("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ud),$e.init(e,t)});function rf(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const nf=E("$ZodJWT",(e,t)=>{$e.init(e,t),e._zod.check=r=>{rf(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ua=E("$ZodNumber",(e,t)=>{ze.init(e,t),e._zod.pattern=e._zod.bag.pattern??hd,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const a=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...a?{received:a}:{}}),r}}),of=E("$ZodNumberFormat",(e,t)=>{yd.init(e,t),Ua.init(e,t)}),af=E("$ZodUnknown",(e,t)=>{ze.init(e,t),e._zod.parse=r=>r}),sf=E("$ZodNever",(e,t)=>{ze.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function xo(e,t,r){e.issues.length&&t.issues.push(...Na(r,e.issues)),t.value[r]=e.value}const lf=E("$ZodArray",(e,t)=>{ze.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const a=[];for(let s=0;sxo(l,r,s))):xo(c,r,s)}return a.length?Promise.all(a).then(()=>r):r}});function an(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...Na(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Ba(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=zu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Ja(e,t,r,n,o,a){const s=[],i=o.keySet,c=o.catchall._zod,l=c.def.type,u=c.optout==="optional";for(const m in t){if(i.has(m))continue;if(l==="never"){s.push(m);continue}const p=c.run({value:t[m],issues:[]},n);p instanceof Promise?e.push(p.then(h=>an(h,r,m,t,u))):an(p,r,m,t,u)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}const cf=E("$ZodObject",(e,t)=>{if(ze.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const i=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...i};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=Hn(()=>Ba(t));_e(e._zod,"propValues",()=>{const i=t.shape,c={};for(const l in i){const u=i[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(const m of u.values)c[l].add(m)}}return c});const o=on,a=t.catchall;let s;e._zod.parse=(i,c)=>{s??(s=n.value);const l=i.value;if(!o(l))return i.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),i;i.value={};const u=[],m=s.shape;for(const p of s.keys){const h=m[p],g=h._zod.optout==="optional",_=h._zod.run({value:l[p],issues:[]},c);_ instanceof Promise?u.push(_.then(b=>an(b,i,p,l,g))):an(_,i,p,l,g)}return a?Ja(u,l,i,c,n.value,e):u.length?Promise.all(u).then(()=>i):i}}),uf=E("$ZodObjectJIT",(e,t)=>{cf.init(e,t);const r=e._zod.parse,n=Hn(()=>Ba(t)),o=p=>{const h=new Cd(["shape","payload","ctx"]),g=n.value,_=A=>{const D=_o(A);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};h.write("const input = payload.value;");const b=Object.create(null);let x=0;for(const A of g.keys)b[A]=`key_${x++}`;h.write("const newResult = {};");for(const A of g.keys){const D=b[A],R=_o(A),T=p[A]?._zod?.optout==="optional";h.write(`const ${D} = ${_(A)};`),T?h.write(` - if (${D}.issues.length) { - if (${R} in input) { - payload.issues = payload.issues.concat(${D}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${R}, ...iss.path] : [${R}] - }))); - } - } - - if (${D}.value === undefined) { - if (${R} in input) { - newResult[${R}] = undefined; - } - } else { - newResult[${R}] = ${D}.value; - } - - `):h.write(` - if (${D}.issues.length) { - payload.issues = payload.issues.concat(${D}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${R}, ...iss.path] : [${R}] - }))); - } - - if (${D}.value === undefined) { - if (${R} in input) { - newResult[${R}] = undefined; - } - } else { - newResult[${R}] = ${D}.value; - } - - `)}h.write("payload.value = newResult;"),h.write("return payload;");const J=h.compile();return(A,D)=>J(p,A,D)};let a;const s=on,i=!Aa.jitless,l=i&&Su.value,u=t.catchall;let m;e._zod.parse=(p,h)=>{m??(m=n.value);const g=p.value;return s(g)?i&&l&&h?.async===!1&&h.jitless!==!0?(a||(a=o(t.shape)),p=a(p,h),u?Ja([],g,p,h,m,e):p):r(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});function wo(e,t,r,n){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const o=e.filter(a=>!ir(a));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(s=>Qt(s,n,Xt())))}),t)}const df=E("$ZodUnion",(e,t)=>{ze.init(e,t),_e(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),_e(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_e(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),_e(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${o.map(a=>Gn(a.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,a)=>{if(r)return n(o,a);let s=!1;const i=[];for(const c of t.options){const l=c._zod.run({value:o.value,issues:[]},a);if(l instanceof Promise)i.push(l),s=!0;else{if(l.issues.length===0)return l;i.push(l)}}return s?Promise.all(i).then(c=>wo(c,o,e,a)):wo(i,o,e,a)}}),ff=E("$ZodIntersection",(e,t)=>{ze.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,a=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);return a instanceof Promise||s instanceof Promise?Promise.all([a,s]).then(([c,l])=>$o(r,c,l)):$o(r,a,s)}});function Dn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Lr(e)&&Lr(t)){const r=Object.keys(t),n=Object.keys(e).filter(a=>r.indexOf(a)!==-1),o={...e,...t};for(const a of n){const s=Dn(e[a],t[a]);if(!s.valid)return{valid:!1,mergeErrorPath:[a,...s.mergeErrorPath]};o[a]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;ni.l&&i.r).map(([i])=>i);if(a.length&&o&&e.issues.push({...o,keys:a}),ir(e))return e;const s=Dn(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const pf=E("$ZodEnum",(e,t)=>{ze.init(e,t);const r=Pa(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>ku.has(typeof o)).map(o=>typeof o=="string"?hr(o):o.toString()).join("|")})$`),e._zod.parse=(o,a)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}}),vf=E("$ZodLiteral",(e,t)=>{if(ze.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?hr(n):n?hr(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{const a=n.value;return r.has(a)||n.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),n}}),mf=E("$ZodTransform",(e,t)=>{ze.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Da(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(r.value=s,r));if(o instanceof Promise)throw new ur;return r.value=o,r}});function Eo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Wa=E("$ZodOptional",(e,t)=>{ze.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_e(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Gn(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>Eo(a,r.value)):Eo(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),hf=E("$ZodExactOptional",(e,t)=>{Wa.init(e,t),_e(e._zod,"values",()=>t.innerType._zod.values),_e(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),gf=E("$ZodNullable",(e,t)=>{ze.init(e,t),_e(e._zod,"optin",()=>t.innerType._zod.optin),_e(e._zod,"optout",()=>t.innerType._zod.optout),_e(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Gn(r.source)}|null)$`):void 0}),_e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),bf=E("$ZodDefault",(e,t)=>{ze.init(e,t),e._zod.optin="optional",_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>So(a,t)):So(o,t)}});function So(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const _f=E("$ZodPrefault",(e,t)=>{ze.init(e,t),e._zod.optin="optional",_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),yf=E("$ZodNonOptional",(e,t)=>{ze.init(e,t),_e(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>ko(a,e)):ko(o,e)}});function ko(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const xf=E("$ZodCatch",(e,t)=>{ze.init(e,t),_e(e._zod,"optin",()=>t.innerType._zod.optin),_e(e._zod,"optout",()=>t.innerType._zod.optout),_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(s=>Qt(s,n,Xt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>Qt(a,n,Xt()))},input:r.value}),r.issues=[]),r)}}),wf=E("$ZodPipe",(e,t)=>{ze.init(e,t),_e(e._zod,"values",()=>t.in._zod.values),_e(e._zod,"optin",()=>t.in._zod.optin),_e(e._zod,"optout",()=>t.out._zod.optout),_e(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const a=t.out._zod.run(r,n);return a instanceof Promise?a.then(s=>Kr(s,t.in,n)):Kr(a,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(a=>Kr(a,t.out,n)):Kr(o,t.out,n)}});function Kr(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const $f=E("$ZodReadonly",(e,t)=>{ze.init(e,t),_e(e._zod,"propValues",()=>t.innerType._zod.propValues),_e(e._zod,"values",()=>t.innerType._zod.values),_e(e._zod,"optin",()=>t.innerType?._zod?.optin),_e(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(zo):zo(o)}});function zo(e){return e.value=Object.freeze(e.value),e}const Ef=E("$ZodCustom",(e,t)=>{rt.init(e,t),ze.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(a=>Do(a,r,n,e));Do(o,r,n,e)}});function Do(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(jr(o))}}var Ao;class Sf{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function kf(){return new Sf}(Ao=globalThis).__zod_globalRegistry??(Ao.__zod_globalRegistry=kf());const zr=globalThis.__zod_globalRegistry;function zf(e,t){return new e({type:"string",...oe(t)})}function Df(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...oe(t)})}function Po(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...oe(t)})}function Af(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...oe(t)})}function Pf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...oe(t)})}function Cf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...oe(t)})}function Of(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...oe(t)})}function Nf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...oe(t)})}function Tf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...oe(t)})}function If(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...oe(t)})}function Zf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...oe(t)})}function Rf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...oe(t)})}function Lf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...oe(t)})}function jf(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...oe(t)})}function Ff(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...oe(t)})}function Mf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...oe(t)})}function Vf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...oe(t)})}function qf(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...oe(t)})}function Uf(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...oe(t)})}function Bf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...oe(t)})}function Jf(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...oe(t)})}function Wf(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...oe(t)})}function Hf(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...oe(t)})}function Kf(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...oe(t)})}function Gf(e,t){return new e({type:"string",format:"date",check:"string_format",...oe(t)})}function Yf(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...oe(t)})}function Xf(e,t){return new e({type:"string",format:"duration",check:"string_format",...oe(t)})}function Qf(e,t){return new e({type:"number",checks:[],...oe(t)})}function ep(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...oe(t)})}function tp(e){return new e({type:"unknown"})}function rp(e,t){return new e({type:"never",...oe(t)})}function Co(e,t){return new Ma({check:"less_than",...oe(t),value:e,inclusive:!1})}function gn(e,t){return new Ma({check:"less_than",...oe(t),value:e,inclusive:!0})}function Oo(e,t){return new Va({check:"greater_than",...oe(t),value:e,inclusive:!1})}function bn(e,t){return new Va({check:"greater_than",...oe(t),value:e,inclusive:!0})}function No(e,t){return new _d({check:"multiple_of",...oe(t),value:e})}function Ha(e,t){return new xd({check:"max_length",...oe(t),maximum:e})}function sn(e,t){return new wd({check:"min_length",...oe(t),minimum:e})}function Ka(e,t){return new $d({check:"length_equals",...oe(t),length:e})}function np(e,t){return new Ed({check:"string_format",format:"regex",...oe(t),pattern:e})}function op(e){return new Sd({check:"string_format",format:"lowercase",...oe(e)})}function ap(e){return new kd({check:"string_format",format:"uppercase",...oe(e)})}function sp(e,t){return new zd({check:"string_format",format:"includes",...oe(t),includes:e})}function ip(e,t){return new Dd({check:"string_format",format:"starts_with",...oe(t),prefix:e})}function lp(e,t){return new Ad({check:"string_format",format:"ends_with",...oe(t),suffix:e})}function _r(e){return new Pd({check:"overwrite",tx:e})}function cp(e){return _r(t=>t.normalize(e))}function up(){return _r(e=>e.trim())}function dp(){return _r(e=>e.toLowerCase())}function fp(){return _r(e=>e.toUpperCase())}function pp(){return _r(e=>Eu(e))}function vp(e,t,r){return new e({type:"array",element:t,...oe(r)})}function mp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...oe(r)})}function hp(e){const t=gp(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(jr(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(jr(o))}},e(r.value,r)));return t}function gp(e,t){const r=new rt({check:"custom",...oe(t)});return r._zod.check=e,r}function Ga(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??zr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Me(e,t,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;const s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);const i=e._zod.toJSONSchema?.();if(i)s.schema=i;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const p=s.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,p,u)}const m=e._zod.parent;m&&(s.ref||(s.ref=m),Me(m,t,u),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&Ve(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Ya(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const s of e.seen.entries()){const i=e.metadataRegistry.get(s[0])?.id;if(i){const c=n.get(i);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${i}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(i,s[0])}}const o=s=>{const i=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const m=e.external.registry.get(s[0])?.id,p=e.external.uri??(g=>g);if(m)return{ref:p(m)};const h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${p("__shared")}#/${i}/${h}`}}if(s[1]===r)return{ref:"#"};const l=`#/${i}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},a=s=>{if(s[1].schema.$ref)return;const i=s[1],{ref:c,defId:l}=o(s);i.def={...i.schema},l&&(i.defId=l);const u=i.schema;for(const m in u)delete u[m];u.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const i=s[1];if(i.cycle)throw new Error(`Cycle detected: #/${i.cycle?.join("/")}/ - -Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const i=s[1];if(t===s[0]){a(s);continue}if(e.external){const l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){a(s);continue}}if(e.metadataRegistry.get(s[0])?.id){a(s);continue}if(i.cycle){a(s);continue}if(i.count>1&&e.reused==="ref"){a(s);continue}}}function Xa(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=s=>{const i=e.seen.get(s);if(i.ref===null)return;const c=i.def??i.schema,l={...c},u=i.ref;if(i.ref=null,u){n(u);const p=e.seen.get(u),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Object.assign(c,h),Object.assign(c,l),s._zod.parent===u)for(const _ in c)_==="$ref"||_==="allOf"||_ in l||delete c[_];if(h.$ref&&p.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(c[_])===JSON.stringify(p.def[_])&&delete c[_]}const m=s._zod.parent;if(m&&m!==u){n(m);const p=e.seen.get(m);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(const h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}e.override({zodSchema:s,jsonSchema:c,path:i.path??[]})};for(const s of[...e.seen.entries()].reverse())n(s[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,r.def??r.schema);const a=e.external?.defs??{};for(const s of e.seen.entries()){const i=s[1];i.def&&i.defId&&(a[i.defId]=i.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:ln(t,"input",e.processors),output:ln(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Ve(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ve(n.element,r);if(n.type==="set")return Ve(n.valueType,r);if(n.type==="lazy")return Ve(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ve(n.innerType,r);if(n.type==="intersection")return Ve(n.left,r)||Ve(n.right,r);if(n.type==="record"||n.type==="map")return Ve(n.keyType,r)||Ve(n.valueType,r);if(n.type==="pipe")return Ve(n.in,r)||Ve(n.out,r);if(n.type==="object"){for(const o in n.shape)if(Ve(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(Ve(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(Ve(o,r))return!0;return!!(n.rest&&Ve(n.rest,r))}return!1}const bp=(e,t={})=>r=>{const n=Ga({...r,processors:t});return Me(e,n),Ya(n,e),Xa(n,e)},ln=(e,t,r={})=>n=>{const{libraryOptions:o,target:a}=n??{},s=Ga({...o??{},target:a,io:t,processors:r});return Me(e,s),Ya(s,e),Xa(s,e)},_p={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},yp=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:a,maximum:s,format:i,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a=="number"&&(o.minLength=a),typeof s=="number"&&(o.maxLength=s),i&&(o.format=_p[i]??i,o.format===""&&delete o.format,i==="time"&&delete o.format),l&&(o.contentEncoding=l),c&&c.size>0){const u=[...c];u.length===1?o.pattern=u[0].source:u.length>1&&(o.allOf=[...u.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},xp=(e,t,r,n)=>{const o=r,{minimum:a,maximum:s,format:i,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof i=="string"&&i.includes("int")?o.type="integer":o.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u),typeof a=="number"&&(o.minimum=a,typeof u=="number"&&t.target!=="draft-04"&&(u>=a?delete o.minimum:delete o.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l),typeof s=="number"&&(o.maximum=s,typeof l=="number"&&t.target!=="draft-04"&&(l<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},wp=(e,t,r,n)=>{r.not={}},$p=(e,t,r,n)=>{},Ep=(e,t,r,n)=>{const o=e._zod.def,a=Pa(o.entries);a.every(s=>typeof s=="number")&&(r.type="number"),a.every(s=>typeof s=="string")&&(r.type="string"),r.enum=a},Sp=(e,t,r,n)=>{const o=e._zod.def,a=[];for(const s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(s))}else a.push(s);if(a.length!==0)if(a.length===1){const s=a[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else a.every(s=>typeof s=="number")&&(r.type="number"),a.every(s=>typeof s=="string")&&(r.type="string"),a.every(s=>typeof s=="boolean")&&(r.type="boolean"),a.every(s=>s===null)&&(r.type="null"),r.enum=a},kp=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},zp=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Dp=(e,t,r,n)=>{const o=r,a=e._zod.def,{minimum:s,maximum:i}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof i=="number"&&(o.maxItems=i),o.type="array",o.items=Me(a.element,t,{...n,path:[...n.path,"items"]})},Ap=(e,t,r,n)=>{const o=r,a=e._zod.def;o.type="object",o.properties={};const s=a.shape;for(const l in s)o.properties[l]=Me(s[l],t,{...n,path:[...n.path,"properties",l]});const i=new Set(Object.keys(s)),c=new Set([...i].filter(l=>{const u=a.shape[l]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(o.required=Array.from(c)),a.catchall?._zod.def.type==="never"?o.additionalProperties=!1:a.catchall?a.catchall&&(o.additionalProperties=Me(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Pp=(e,t,r,n)=>{const o=e._zod.def,a=o.inclusive===!1,s=o.options.map((i,c)=>Me(i,t,{...n,path:[...n.path,a?"oneOf":"anyOf",c]}));a?r.oneOf=s:r.anyOf=s},Cp=(e,t,r,n)=>{const o=e._zod.def,a=Me(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=Me(o.right,t,{...n,path:[...n.path,"allOf",1]}),i=l=>"allOf"in l&&Object.keys(l).length===1,c=[...i(a)?a.allOf:[a],...i(s)?s.allOf:[s]];r.allOf=c},Op=(e,t,r,n)=>{const o=e._zod.def,a=Me(o.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},Np=(e,t,r,n)=>{const o=e._zod.def;Me(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType},Tp=(e,t,r,n)=>{const o=e._zod.def;Me(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Ip=(e,t,r,n)=>{const o=e._zod.def;Me(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Zp=(e,t,r,n)=>{const o=e._zod.def;Me(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Rp=(e,t,r,n)=>{const o=e._zod.def,a=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Me(a,t,n);const s=t.seen.get(e);s.ref=a},Lp=(e,t,r,n)=>{const o=e._zod.def;Me(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType,r.readOnly=!0},Qa=(e,t,r,n)=>{const o=e._zod.def;Me(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType},jp=E("ZodISODateTime",(e,t)=>{Ud.init(e,t),Ee.init(e,t)});function Fp(e){return Kf(jp,e)}const Mp=E("ZodISODate",(e,t)=>{Bd.init(e,t),Ee.init(e,t)});function Vp(e){return Gf(Mp,e)}const qp=E("ZodISOTime",(e,t)=>{Jd.init(e,t),Ee.init(e,t)});function Up(e){return Yf(qp,e)}const Bp=E("ZodISODuration",(e,t)=>{Wd.init(e,t),Ee.init(e,t)});function Jp(e){return Xf(Bp,e)}const Wp=(e,t)=>{Ia.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Ru(e,r)},flatten:{value:r=>Zu(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,zn,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,zn,2)}},isEmpty:{get(){return e.issues.length===0}}})},pt=E("ZodError",Wp,{Parent:Error}),Hp=Xn(pt),Kp=Qn(pt),Gp=dn(pt),Yp=fn(pt),Xp=Fu(pt),Qp=Mu(pt),ev=Vu(pt),tv=qu(pt),rv=Uu(pt),nv=Bu(pt),ov=Ju(pt),av=Wu(pt),De=E("ZodType",(e,t)=>(ze.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ln(e,"input"),output:ln(e,"output")}}),e.toJSONSchema=bp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(Rt(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>Lt(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>Hp(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Gp(e,r,n),e.parseAsync=async(r,n)=>Kp(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Yp(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Xp(e,r,n),e.decode=(r,n)=>Qp(e,r,n),e.encodeAsync=async(r,n)=>ev(e,r,n),e.decodeAsync=async(r,n)=>tv(e,r,n),e.safeEncode=(r,n)=>rv(e,r,n),e.safeDecode=(r,n)=>nv(e,r,n),e.safeEncodeAsync=async(r,n)=>ov(e,r,n),e.safeDecodeAsync=async(r,n)=>av(e,r,n),e.refine=(r,n)=>e.check(rm(r,n)),e.superRefine=r=>e.check(nm(r)),e.overwrite=r=>e.check(_r(r)),e.optional=()=>Ro(e),e.exactOptional=()=>qv(e),e.nullable=()=>Lo(e),e.nullish=()=>Ro(Lo(e)),e.nonoptional=r=>Kv(e,r),e.array=()=>Pv(e),e.or=r=>Tv([e,r]),e.and=r=>Zv(e,r),e.transform=r=>jo(e,Mv(r)),e.default=r=>Jv(e,r),e.prefault=r=>Hv(e,r),e.catch=r=>Yv(e,r),e.pipe=r=>jo(e,r),e.readonly=()=>em(e),e.describe=r=>{const n=e.clone();return zr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return zr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return zr.get(e);const n=e.clone();return zr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),es=E("_ZodString",(e,t)=>{eo.init(e,t),De.init(e,t),e._zod.processJSONSchema=(n,o,a)=>yp(e,n,o);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(np(...n)),e.includes=(...n)=>e.check(sp(...n)),e.startsWith=(...n)=>e.check(ip(...n)),e.endsWith=(...n)=>e.check(lp(...n)),e.min=(...n)=>e.check(sn(...n)),e.max=(...n)=>e.check(Ha(...n)),e.length=(...n)=>e.check(Ka(...n)),e.nonempty=(...n)=>e.check(sn(1,...n)),e.lowercase=n=>e.check(op(n)),e.uppercase=n=>e.check(ap(n)),e.trim=()=>e.check(up()),e.normalize=(...n)=>e.check(cp(...n)),e.toLowerCase=()=>e.check(dp()),e.toUpperCase=()=>e.check(fp()),e.slugify=()=>e.check(pp())}),sv=E("ZodString",(e,t)=>{eo.init(e,t),es.init(e,t),e.email=r=>e.check(Df(iv,r)),e.url=r=>e.check(Nf(lv,r)),e.jwt=r=>e.check(Hf($v,r)),e.emoji=r=>e.check(Tf(cv,r)),e.guid=r=>e.check(Po(To,r)),e.uuid=r=>e.check(Af(Yr,r)),e.uuidv4=r=>e.check(Pf(Yr,r)),e.uuidv6=r=>e.check(Cf(Yr,r)),e.uuidv7=r=>e.check(Of(Yr,r)),e.nanoid=r=>e.check(If(uv,r)),e.guid=r=>e.check(Po(To,r)),e.cuid=r=>e.check(Zf(dv,r)),e.cuid2=r=>e.check(Rf(fv,r)),e.ulid=r=>e.check(Lf(pv,r)),e.base64=r=>e.check(Bf(yv,r)),e.base64url=r=>e.check(Jf(xv,r)),e.xid=r=>e.check(jf(vv,r)),e.ksuid=r=>e.check(Ff(mv,r)),e.ipv4=r=>e.check(Mf(hv,r)),e.ipv6=r=>e.check(Vf(gv,r)),e.cidrv4=r=>e.check(qf(bv,r)),e.cidrv6=r=>e.check(Uf(_v,r)),e.e164=r=>e.check(Wf(wv,r)),e.datetime=r=>e.check(Fp(r)),e.date=r=>e.check(Vp(r)),e.time=r=>e.check(Up(r)),e.duration=r=>e.check(Jp(r))});function Gr(e){return zf(sv,e)}const Ee=E("ZodStringFormat",(e,t)=>{$e.init(e,t),es.init(e,t)}),iv=E("ZodEmail",(e,t)=>{Id.init(e,t),Ee.init(e,t)}),To=E("ZodGUID",(e,t)=>{Nd.init(e,t),Ee.init(e,t)}),Yr=E("ZodUUID",(e,t)=>{Td.init(e,t),Ee.init(e,t)}),lv=E("ZodURL",(e,t)=>{Zd.init(e,t),Ee.init(e,t)}),cv=E("ZodEmoji",(e,t)=>{Rd.init(e,t),Ee.init(e,t)}),uv=E("ZodNanoID",(e,t)=>{Ld.init(e,t),Ee.init(e,t)}),dv=E("ZodCUID",(e,t)=>{jd.init(e,t),Ee.init(e,t)}),fv=E("ZodCUID2",(e,t)=>{Fd.init(e,t),Ee.init(e,t)}),pv=E("ZodULID",(e,t)=>{Md.init(e,t),Ee.init(e,t)}),vv=E("ZodXID",(e,t)=>{Vd.init(e,t),Ee.init(e,t)}),mv=E("ZodKSUID",(e,t)=>{qd.init(e,t),Ee.init(e,t)}),hv=E("ZodIPv4",(e,t)=>{Hd.init(e,t),Ee.init(e,t)}),gv=E("ZodIPv6",(e,t)=>{Kd.init(e,t),Ee.init(e,t)}),bv=E("ZodCIDRv4",(e,t)=>{Gd.init(e,t),Ee.init(e,t)}),_v=E("ZodCIDRv6",(e,t)=>{Yd.init(e,t),Ee.init(e,t)}),yv=E("ZodBase64",(e,t)=>{Xd.init(e,t),Ee.init(e,t)}),xv=E("ZodBase64URL",(e,t)=>{ef.init(e,t),Ee.init(e,t)}),wv=E("ZodE164",(e,t)=>{tf.init(e,t),Ee.init(e,t)}),$v=E("ZodJWT",(e,t)=>{nf.init(e,t),Ee.init(e,t)}),ts=E("ZodNumber",(e,t)=>{Ua.init(e,t),De.init(e,t),e._zod.processJSONSchema=(n,o,a)=>xp(e,n,o),e.gt=(n,o)=>e.check(Oo(n,o)),e.gte=(n,o)=>e.check(bn(n,o)),e.min=(n,o)=>e.check(bn(n,o)),e.lt=(n,o)=>e.check(Co(n,o)),e.lte=(n,o)=>e.check(gn(n,o)),e.max=(n,o)=>e.check(gn(n,o)),e.int=n=>e.check(Io(n)),e.safe=n=>e.check(Io(n)),e.positive=n=>e.check(Oo(0,n)),e.nonnegative=n=>e.check(bn(0,n)),e.negative=n=>e.check(Co(0,n)),e.nonpositive=n=>e.check(gn(0,n)),e.multipleOf=(n,o)=>e.check(No(n,o)),e.step=(n,o)=>e.check(No(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Ev(e){return Qf(ts,e)}const Sv=E("ZodNumberFormat",(e,t)=>{of.init(e,t),ts.init(e,t)});function Io(e){return ep(Sv,e)}const kv=E("ZodUnknown",(e,t)=>{af.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$p()});function Zo(){return tp(kv)}const zv=E("ZodNever",(e,t)=>{sf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wp(e,r,n)});function Dv(e){return rp(zv,e)}const Av=E("ZodArray",(e,t)=>{lf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dp(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(sn(r,n)),e.nonempty=r=>e.check(sn(1,r)),e.max=(r,n)=>e.check(Ha(r,n)),e.length=(r,n)=>e.check(Ka(r,n)),e.unwrap=()=>e.element});function Pv(e,t){return vp(Av,e,t)}const Cv=E("ZodObject",(e,t)=>{uf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ap(e,r,n,o),_e(e,"shape",()=>t.shape),e.keyof=()=>Rv(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Zo()}),e.loose=()=>e.clone({...e._zod.def,catchall:Zo()}),e.strict=()=>e.clone({...e._zod.def,catchall:Dv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Cu(e,r),e.safeExtend=r=>Ou(e,r),e.merge=r=>Nu(e,r),e.pick=r=>Au(e,r),e.omit=r=>Pu(e,r),e.partial=(...r)=>Tu(rs,e,r[0]),e.required=(...r)=>Iu(ns,e,r[0])});function Ov(e,t){const r={type:"object",shape:e??{},...oe(t)};return new Cv(r)}const Nv=E("ZodUnion",(e,t)=>{df.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pp(e,r,n,o),e.options=t.options});function Tv(e,t){return new Nv({type:"union",options:e,...oe(t)})}const Iv=E("ZodIntersection",(e,t)=>{ff.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Cp(e,r,n,o)});function Zv(e,t){return new Iv({type:"intersection",left:e,right:t})}const An=E("ZodEnum",(e,t)=>{pf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(n,o,a)=>Ep(e,n,o),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const a={};for(const s of n)if(r.has(s))a[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new An({...t,checks:[],...oe(o),entries:a})},e.exclude=(n,o)=>{const a={...t.entries};for(const s of n)if(r.has(s))delete a[s];else throw new Error(`Key ${s} not found in enum`);return new An({...t,checks:[],...oe(o),entries:a})}});function Rv(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new An({type:"enum",entries:r,...oe(t)})}const Lv=E("ZodLiteral",(e,t)=>{vf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sp(e,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function jv(e,t){return new Lv({type:"literal",values:Array.isArray(e)?e:[e],...oe(t)})}const Fv=E("ZodTransform",(e,t)=>{mf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zp(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Da(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(jr(a,r.value,t));else{const s=a;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(jr(s))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(a=>(r.value=a,r)):(r.value=o,r)}});function Mv(e){return new Fv({type:"transform",transform:e})}const rs=E("ZodOptional",(e,t)=>{Wa.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ro(e){return new rs({type:"optional",innerType:e})}const Vv=E("ZodExactOptional",(e,t)=>{hf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function qv(e){return new Vv({type:"optional",innerType:e})}const Uv=E("ZodNullable",(e,t)=>{gf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Op(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Lo(e){return new Uv({type:"nullable",innerType:e})}const Bv=E("ZodDefault",(e,t)=>{bf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Jv(e,t){return new Bv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Oa(t)}})}const Wv=E("ZodPrefault",(e,t)=>{_f.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ip(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Hv(e,t){return new Wv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Oa(t)}})}const ns=E("ZodNonOptional",(e,t)=>{yf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Np(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Kv(e,t){return new ns({type:"nonoptional",innerType:e,...oe(t)})}const Gv=E("ZodCatch",(e,t)=>{xf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Yv(e,t){return new Gv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Xv=E("ZodPipe",(e,t)=>{wf.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rp(e,r,n,o),e.in=t.in,e.out=t.out});function jo(e,t){return new Xv({type:"pipe",in:e,out:t})}const Qv=E("ZodReadonly",(e,t)=>{$f.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Lp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function em(e){return new Qv({type:"readonly",innerType:e})}const tm=E("ZodCustom",(e,t)=>{Ef.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kp(e,r)});function rm(e,t={}){return mp(tm,e,t)}function nm(e){return hp(e)}var om=k('
                ',1),am=k(" ",1);function sm(e,t){Ce(t,!0);const r=()=>ee(x,"$hasErrors",s),n=()=>ee(J,"$isDirty",s),o=()=>ee(b,"$errors",s),a=()=>ee(A,"$isDirtyByField",s),[s,i]=Ue(),c=Ov({username:Gr().min(3).max(20).regex(/^\S+$/,"Must not contain spaces"),email:Gr().min(1,"Required").email(),age:Ev().int().min(18).max(120),website:Gr().url().optional().or(jv("")),bio:Gr().max(200).optional()});function l(P,j,z){const F=P.safeParse(j);if(F.success)return Object.fromEntries(z.map(I=>[I,""]));const q={};for(const I of F.error.issues){const N=String(I.path[0]);q[N]||(q[N]=I.message)}return Object.fromEntries(z.map(I=>[I,q[I]??""]))}const u=c.pick({username:!0,email:!0,age:!0,website:!0}),m=Object.keys(u.shape),p=[...m,"bio"],h={username:{label:"Username",placeholder:"Enter username",type:"text"},email:{label:"Email",placeholder:"Enter email",type:"email"},age:{label:"Age",placeholder:"Enter age",type:"number"},website:{label:"Website",placeholder:"https://example.com",type:"text"}},g={username:"",email:"",age:0,website:"",bio:""},{data:_,state:{errors:b,hasErrors:x,isDirty:J,isDirtyByField:A}}=Be(g,{validator:P=>l(c,P,p)}),D=()=>{_.username=`user${ce()}`,_.email=`${ce()}@example.com`,_.age=lt(18,65),_.bio="Hello, I am a demo user!",_.website=`https://${ce()}.com`},R=String.raw`import { z } from 'zod'; - -const userSchema = z.object({ - username: z.string().min(3).max(20).regex(/^\S+$/, 'Must not contain spaces'), - email: z.string().min(1, 'Required').email(), - age: z.number().int().min(18).max(120), - website: z.string().url().optional().or(z.literal('')), - bio: z.string().max(200).optional() -});`,K=`function zodToSvstateErrors(schema, source, fields) { - const result = schema.safeParse(source); - if (result.success) - return Object.fromEntries(fields.map(f => [f, ''])); - - const errorMap = {}; - for (const issue of result.error.issues) { - const key = String(issue.path[0]); - if (!errorMap[key]) errorMap[key] = issue.message; - } - return Object.fromEntries( - fields.map(f => [f, errorMap[f] ?? '']) - ); -} - -const { data, state: { errors, hasErrors } } = createSvState(sourceData, { - validator: (source) => zodToSvstateErrors(userSchema, source, allFields) -});`,T=`// Pick a subset of fields for dynamic rendering -const pickedSchema = userSchema.pick({ username: true, email: true, age: true, website: true }); -const dynamicFields = Object.keys(pickedSchema.shape); - -const fieldMeta = { - username: { label: 'Username', placeholder: 'Enter username', type: 'text' }, - email: { label: 'Email', placeholder: 'Enter email', type: 'email' }, - age: { label: 'Age', placeholder: 'Enter age', type: 'number' }, - website: { label: 'Website', placeholder: 'https://...', type: 'text' }, -}; - -// In template: -{#each dynamicFields as field} - -{/each} - - -`;We(e,{description:"Demonstrates using Zod schemas for validation with svstate, including dynamic form rendering via z.pick() shape keys.",title:"Zod Integration Demo",main:F=>{var q=om(),I=ue(q);Ke(I,{get hasErrors(){return r()},get isDirty(){return n()}});var N=d(I,2),M=f(N);zt(M,16,()=>m,W=>W,(W,H)=>{const V=te(()=>h[H]);{let w=te(()=>o()?.[H]),B=te(()=>H!=="website");le(W,{get id(){return H},get error(){return v(w)},get isDirty(){return a()[H]},get label(){return v(V).label},get placeholder(){return v(V).placeholder},get required(){return v(B)},get type(){return v(V).type},get value(){return _[H]},set value(Y){_[H]=Y}})}});var L=d(M,2);{let W=te(()=>o()?.bio);rr(L,{id:"bio",get error(){return v(W)},get isDirty(){return a().bio},label:"Bio",placeholder:"Tell us about yourself (not in pick subset)",get value(){return _.bio},set value(H){_.bio=H}})}$(F,q)},sidebar:F=>{Je(F,{get data(){return _},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},get isDirtyByField(){return a()},onFill:D})},sourceCode:F=>{He(F,{children:(q,I)=>{var N=am(),M=ue(N);fe(M,{get code(){return R},title:"Zod Schema Definition"});var L=d(M,2);fe(L,{code:K,title:"Bridge Function (Zod → svstate)"});var W=d(L,2);fe(W,{code:T,title:"Dynamic Rendering via z.pick()"}),$(q,N)}})}}),Oe(),i()}var im=k(""),lm=k(`
                svstate logo

                svstate

                A Svelte 5 library that provides a supercharged $state() with deep reactive proxies, validation, snapshot/undo, - and side effects — built for complex, real-world applications.

                $ npm i svstate
                `);function cm(e){const t=[{value:"basic-validation",name:"Basic Validation"},{value:"nested-objects",name:"Nested Objects"},{value:"array-property",name:"Array Property"},{value:"calculated-fields",name:"Calculated Fields"},{value:"calculated-class",name:"State with Methods"},{value:"reset-demo",name:"Reset"},{value:"snapshot-demo",name:"Snapshot & Rollback"},{value:"action-demo",name:"Action & Error"},{value:"async-validation",name:"Async Validation"},{value:"options-demo",name:"Options"},{value:"zod-validation",name:"Zod Integration"},{value:"plugin-devtools",name:"Plugin: Devtools"},{value:"plugin-persist-sync",name:"Plugin: Persist & Sync"},{value:"plugin-undo-redo",name:"Plugin: Undo/Redo"},{value:"plugin-autosave-analytics",name:"Plugin: Autosave & Analytics"}];let r=we("basic-validation");const n="1.5.0",o="/svstate";var a=lm(),s=f(a),i=f(s),c=d(i,2),l=f(c),u=d(f(l),2),m=f(u),p=d(l,4),h=d(f(p),4),g=d(p,2),_=d(s,2),b=f(_),x=f(b),J=d(f(x),2);zt(J,21,()=>t,Ir,(w,B)=>{var Y=im(),X=f(Y),Q={};ae(()=>{G(X,v(B).name),Q!==(Q=v(B).value)&&(Y.value=(Y.__value=v(B).value)??"")}),$(w,Y)});var A=d(b,2),D=f(A);{var R=w=>{Ql(w,{})},K=w=>{bc(w,{})},T=w=>{Fl(w,{})},P=w=>{ic(w,{})},j=w=>{oc(w,{})},z=w=>{vu(w,{})},F=w=>{wu(w,{})},q=w=>{Pl(w,{})},I=w=>{Hl(w,{})},N=w=>{kc(w,{})},M=w=>{sm(w,{})},L=w=>{Jc(w,{})},W=w=>{Qc(w,{})},H=w=>{uu(w,{})},V=w=>{Lc(w,{})};se(D,w=>{v(r)==="basic-validation"?w(R):v(r)==="nested-objects"?w(K,1):v(r)==="array-property"?w(T,2):v(r)==="calculated-fields"?w(P,3):v(r)==="calculated-class"?w(j,4):v(r)==="reset-demo"?w(z,5):v(r)==="snapshot-demo"?w(F,6):v(r)==="action-demo"?w(q,7):v(r)==="async-validation"?w(I,8):v(r)==="options-demo"?w(N,9):v(r)==="zod-validation"?w(M,10):v(r)==="plugin-devtools"?w(L,11):v(r)==="plugin-persist-sync"?w(W,12):v(r)==="plugin-undo-redo"?w(H,13):v(r)==="plugin-autosave-analytics"&&w(V,14)})}ae(()=>{je(i,"src",`${o}/favicon.png`),G(m,`v${n}`),je(g,"href",`${o}/llms.txt`)}),ye("click",h,()=>navigator.clipboard.writeText(`npm i svstate@${n}`)),un(J,()=>v(r),w=>he(r,w)),$(e,a)}tt(["click"]);Ci(cm,{target:document.querySelector("#app")}); diff --git a/docs/assets/index-DyhFc29r.js b/docs/assets/index-DyhFc29r.js new file mode 100644 index 0000000..d15fb73 --- /dev/null +++ b/docs/assets/index-DyhFc29r.js @@ -0,0 +1,511 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(o){if(o.ep)return;o.ep=!0;const a=r(o);fetch(o.href,a)}})();const vs=!1;var On=Array.isArray,ms=Array.prototype.indexOf,fr=Array.prototype.includes,cn=Array.from,Vo=Object.defineProperty,cr=Object.getOwnPropertyDescriptor,qo=Object.getOwnPropertyDescriptors,hs=Object.prototype,gs=Array.prototype,Nn=Object.getPrototypeOf,oo=Object.isExtensible;const St=()=>{};function bs(e){return e()}function en(e){for(var t=0;t{e=n,t=o});return{promise:r,resolve:e,reject:t}}const Ze=2,pr=4,Fr=8,Bo=1<<24,Zt=16,ht=32,Kt=64,_n=128,ct=512,Oe=1024,Me=2048,bt=4096,ot=8192,ut=16384,er=32768,ao=1<<25,Ht=65536,so=1<<17,_s=1<<18,br=1<<19,Jo=1<<20,gt=1<<25,Gt=65536,yn=1<<21,Tn=1<<22,Ct=1<<23,Ot=Symbol("$state"),ys=Symbol("legacy props"),xs=Symbol(""),Et=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function ws(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function $s(e,t,r){throw new Error("https://svelte.dev/e/each_key_duplicate")}function Es(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Ss(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function ks(e){throw new Error("https://svelte.dev/e/effect_orphan")}function zs(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Ds(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function As(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Ps(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Cs(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Os(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Ns=1,Ts=2,Wo=4,Is=8,Zs=16,Rs=1,js=2,Ls=4,Fs=8,Ms=16,Vs=1,qs=2,je=Symbol(),Ko="http://www.w3.org/1999/xhtml";function Us(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function Bs(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Ho(e){return e===this.v}function Go(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Yo(e){return!Go(e,this.v)}let Mr=!1,Js=!1;function Ws(){Mr=!0}let Ie=null;function vr(e){Ie=e}function Ne(e,t=!1,r){Ie={p:Ie,i:!1,c:null,e:null,s:e,x:null,r:ge,l:Mr&&!t?{s:null,u:null,$:[]}:null}}function Te(e){var t=Ie,r=t.e;if(r!==null){t.e=null;for(var n of r)ha(n)}return t.i=!0,Ie=t.p,{}}function _r(){return!Mr||Ie!==null&&Ie.l===null}let Ft=[];function Xo(){var e=Ft;Ft=[],en(e)}function Vt(e){if(Ft.length===0&&!Dr){var t=Ft;queueMicrotask(()=>{t===Ft&&Xo()})}Ft.push(e)}function Ks(){for(;Ft.length>0;)Xo()}function Qo(e){var t=ge;if(t===null)return ve.f|=Ct,e;if((t.f&er)===0&&(t.f&pr)===0)throw e;Pt(e,t)}function Pt(e,t){for(;t!==null;){if((t.f&_n)!==0){if((t.f&er)===0)throw e;try{t.b.error(e);return}catch(r){e=r}}t=t.parent}throw e}const Hs=-7169;function De(e,t){e.f=e.f&Hs|t}function In(e){(e.f&ct)!==0||e.deps===null?De(e,Oe):De(e,bt)}function ea(e){if(e!==null)for(const t of e)(t.f&Ze)===0||(t.f&Gt)===0||(t.f^=Gt,ea(t.deps))}function ta(e,t,r){(e.f&Me)!==0?t.add(e):(e.f&bt)!==0&&r.add(e),ea(e.deps),De(e,Oe)}function Zn(e,t,r){if(e==null)return t(void 0),r&&r(void 0),St;const n=tr(()=>e.subscribe(t,r));return n.unsubscribe?()=>n.unsubscribe():n}const or=[];function Gs(e,t){return{subscribe:wt(e,t).subscribe}}function wt(e,t=St){let r=null;const n=new Set;function o(i){if(Go(e,i)&&(e=i,r)){const l=!or.length;for(const c of n)c[1](),or.push(c,e);if(l){for(let c=0;c{n.delete(c),n.size===0&&r&&(r(),r=null)}}return{set:o,update:a,subscribe:s}}function $r(e,t,r){const n=!Array.isArray(e),o=n?[e]:e;if(!o.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const a=t.length<2;return Gs(r,(s,i)=>{let l=!1;const c=[];let u=0,m=St;const p=()=>{if(u)return;m();const g=t(n?c[0]:c,s,i);a?s(g):m=typeof g=="function"?g:St},h=o.map((g,_)=>Zn(g,b=>{c[_]=b,u&=~(1<<_),l&&p()},()=>{u|=1<<_}));return l=!0,p(),function(){en(h),m(),l=!1}})}function Ye(e){let t;return Zn(e,r=>t=r)(),t}let Jr=!1,xn=Symbol();function ee(e,t,r){const n=r[t]??={store:null,source:Ln(void 0),unsubscribe:St};if(n.store!==e&&!(xn in r))if(n.unsubscribe(),n.store=e??null,e==null)n.source.v=void 0,n.unsubscribe=St;else{var o=!0;n.unsubscribe=Zn(e,a=>{o?n.source.v=a:me(n.source,a)}),o=!1}return e&&xn in r?Ye(e):v(n.source)}function Ue(){const e={};function t(){qn(()=>{for(var r in e)e[r].unsubscribe();Vo(e,xn,{enumerable:!1,value:!0})})}return[e,t]}function Ys(e){var t=Jr;try{return Jr=!1,[e(),Jr]}finally{Jr=t}}const ar=new Set;let he=null,vt=null,wn=null,Dr=!1,vn=!1,sr=null,Xr=null;var io=0;let Xs=1;class Tt{id=Xs++;current=new Map;previous=new Map;#e=new Set;#l=new Set;#t=0;#s=0;#n=null;#r=[];#o=new Set;#a=new Set;#i=new Map;is_fork=!1;#c=!1;#u(){return this.is_fork||this.#s>0}skip_effect(t){this.#i.has(t)||this.#i.set(t,{d:[],m:[]})}unskip_effect(t){var r=this.#i.get(t);if(r){this.#i.delete(t);for(var n of r.d)De(n,Me),this.schedule(n);for(n of r.m)De(n,bt),this.schedule(n)}}#f(){if(io++>1e3&&(ar.delete(this),ei()),!this.#u()){for(const i of this.#o)this.#a.delete(i),De(i,Me),this.schedule(i);for(const i of this.#a)De(i,bt),this.schedule(i)}const t=this.#r;this.#r=[],this.apply();var r=sr=[],n=[],o=Xr=[];for(const i of t)try{this.#p(i,r,n)}catch(l){throw aa(i),l}if(he=null,o.length>0){var a=Tt.ensure();for(const i of o)a.schedule(i)}if(sr=null,Xr=null,this.#u()){this.#v(n),this.#v(r);for(const[i,l]of this.#i)oa(i,l)}else{this.#t===0&&ar.delete(this),this.#o.clear(),this.#a.clear();for(const i of this.#e)i(this);this.#e.clear(),lo(n),lo(r),this.#n?.resolve()}var s=he;if(this.#r.length>0){const i=s??=this;i.#r.push(...this.#r.filter(l=>!i.#r.includes(l)))}s!==null&&(ar.add(s),s.#f()),ar.has(this)||this.#d()}#p(t,r,n){t.f^=Oe;for(var o=t.first;o!==null;){var a=o.f,s=(a&(ht|Kt))!==0,i=s&&(a&Oe)!==0,l=i||(a&ot)!==0||this.#i.has(o);if(!l&&o.fn!==null){s?o.f^=Oe:(a&pr)!==0?r.push(o):Br(o)&&((a&Zt)!==0&&this.#a.add(o),hr(o));var c=o.first;if(c!==null){o=c;continue}}for(;o!==null;){var u=o.next;if(u!==null){o=u;break}o=o.parent}}}#v(t){for(var r=0;r!this.current.has(c));if(n.length>0){l.activate();var o=new Set,a=new Map;for(var s of r)ra(s,n,o,a);if(l.#r.length>0){l.apply();for(var i of l.#r)l.#p(i,[],[]);l.#r=[]}l.deactivate()}}}}increment(t){this.#t+=1,t&&(this.#s+=1)}decrement(t,r){this.#t-=1,t&&(this.#s-=1),!(this.#c||r)&&(this.#c=!0,Vt(()=>{this.#c=!1,this.flush()}))}transfer_effects(t,r){for(const n of t)this.#o.add(n);for(const n of r)this.#a.add(n);t.clear(),r.clear()}oncommit(t){this.#e.add(t)}ondiscard(t){this.#l.add(t)}settled(){return(this.#n??=Uo()).promise}static ensure(){if(he===null){const t=he=new Tt;vn||(ar.add(he),Dr||Vt(()=>{he===t&&t.flush()}))}return he}apply(){{vt=null;return}}schedule(t){if(wn=t,t.b?.is_pending&&(t.f&(pr|Fr|Bo))!==0&&(t.f&er)===0){t.b.defer_effect(t);return}for(var r=t;r.parent!==null;){r=r.parent;var n=r.f;if(sr!==null&&r===ge&&(ve===null||(ve.f&Ze)===0))return;if((n&(Kt|ht))!==0){if((n&Oe)===0)return;r.f^=Oe}}this.#r.push(r)}}function Qs(e){var t=Dr;Dr=!0;try{for(var r;;){if(Ks(),he===null)return r;he.flush()}}finally{Dr=t}}function ei(){try{zs()}catch(e){Pt(e,wn)}}let $t=null;function lo(e){var t=e.length;if(t!==0){for(var r=0;r0)){Nt.clear();for(const o of $t){if((o.f&(ut|ot))!==0)continue;const a=[o];let s=o.parent;for(;s!==null;)$t.has(s)&&($t.delete(s),a.push(s)),s=s.parent;for(let i=a.length-1;i>=0;i--){const l=a[i];(l.f&(ut|ot))===0&&hr(l)}}$t.clear()}}$t=null}}function ra(e,t,r,n){if(!r.has(e)&&(r.add(e),e.reactions!==null))for(const o of e.reactions){const a=o.f;(a&Ze)!==0?ra(o,t,r,n):(a&(Tn|Zt))!==0&&(a&Me)===0&&na(o,t,n)&&(De(o,Me),Rn(o))}}function na(e,t,r){const n=r.get(e);if(n!==void 0)return n;if(e.deps!==null)for(const o of e.deps){if(fr.call(t,o))return!0;if((o.f&Ze)!==0&&na(o,t,r))return r.set(o,!0),!0}return r.set(e,!1),!1}function Rn(e){he.schedule(e)}function oa(e,t){if(!((e.f&ht)!==0&&(e.f&Oe)!==0)){(e.f&Me)!==0?t.d.push(e):(e.f&bt)!==0&&t.m.push(e),De(e,Oe);for(var r=e.first;r!==null;)oa(r,t),r=r.next}}function aa(e){De(e,Oe);for(var t=e.first;t!==null;)aa(t),t=t.next}function ti(e){let t=0,r=Yt(0),n;return()=>{Vn()&&(v(r),Un(()=>(t===0&&(n=tr(()=>e(()=>Ar(r)))),t+=1,()=>{Vt(()=>{t-=1,t===0&&(n?.(),n=void 0,Ar(r))})})))}}var ri=Ht|br;function ni(e,t,r,n){new oi(e,t,r,n)}class oi{parent;is_pending=!1;transform_error;#e;#l=null;#t;#s;#n;#r=null;#o=null;#a=null;#i=null;#c=0;#u=0;#f=!1;#p=new Set;#v=new Set;#d=null;#_=ti(()=>(this.#d=Yt(this.#c),()=>{this.#d=null}));constructor(t,r,n,o){this.#e=t,this.#t=r,this.#s=a=>{var s=ge;s.b=this,s.f|=_n,n(a)},this.parent=ge.b,this.transform_error=o??this.parent?.transform_error??(a=>a),this.#n=Ur(()=>{this.#g()},ri)}#y(){try{this.#r=st(()=>this.#s(this.#e))}catch(t){this.error(t)}}#x(t){const r=this.#t.failed;r&&(this.#a=st(()=>{r(this.#e,()=>t,()=>()=>{})}))}#w(){const t=this.#t.pending;t&&(this.is_pending=!0,this.#o=st(()=>t(this.#e)),Vt(()=>{var r=this.#i=document.createDocumentFragment(),n=kt();r.append(n),this.#r=this.#h(()=>st(()=>this.#s(n))),this.#u===0&&(this.#e.before(r),this.#i=null,qt(this.#o,()=>{this.#o=null}),this.#m(he))}))}#g(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#c=0,this.#r=st(()=>{this.#s(this.#e)}),this.#u>0){var t=this.#i=document.createDocumentFragment();Wn(this.#r,t);const r=this.#t.pending;this.#o=st(()=>r(this.#e))}else this.#m(he)}catch(r){this.error(r)}}#m(t){this.is_pending=!1,t.transfer_effects(this.#p,this.#v)}defer_effect(t){ta(t,this.#p,this.#v)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#t.pending}#h(t){var r=ge,n=ve,o=Ie;_t(this.#n),ft(this.#n),vr(this.#n.ctx);try{return Tt.ensure(),t()}catch(a){return Qo(a),null}finally{_t(r),ft(n),vr(o)}}#b(t,r){if(!this.has_pending_snippet()){this.parent&&this.parent.#b(t,r);return}this.#u+=t,this.#u===0&&(this.#m(r),this.#o&&qt(this.#o,()=>{this.#o=null}),this.#i&&(this.#e.before(this.#i),this.#i=null))}update_pending_count(t,r){this.#b(t,r),this.#c+=t,!(!this.#d||this.#f)&&(this.#f=!0,Vt(()=>{this.#f=!1,this.#d&&mr(this.#d,this.#c)}))}get_effect_pending(){return this.#_(),v(this.#d)}error(t){var r=this.#t.onerror;let n=this.#t.failed;if(!r&&!n)throw t;this.#r&&(et(this.#r),this.#r=null),this.#o&&(et(this.#o),this.#o=null),this.#a&&(et(this.#a),this.#a=null);var o=!1,a=!1;const s=()=>{if(o){Bs();return}o=!0,a&&Os(),this.#a!==null&&qt(this.#a,()=>{this.#a=null}),this.#h(()=>{this.#g()})},i=l=>{try{a=!0,r?.(l,s),a=!1}catch(c){Pt(c,this.#n&&this.#n.parent)}n&&(this.#a=this.#h(()=>{try{return st(()=>{var c=ge;c.b=this,c.f|=_n,n(this.#e,()=>l,()=>s)})}catch(c){return Pt(c,this.#n.parent),null}}))};Vt(()=>{var l;try{l=this.transform_error(t)}catch(c){Pt(c,this.#n&&this.#n.parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(i,c=>Pt(c,this.#n&&this.#n.parent)):i(l)})}}function ai(e,t,r,n){const o=_r()?Vr:ur;var a=e.filter(p=>!p.settled);if(r.length===0&&a.length===0){n(t.map(o));return}var s=ge,i=si(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(p=>p.promise)):null;function c(p){i();try{n(p)}catch(h){(s.f&ut)===0&&Pt(h,s)}tn()}if(r.length===0){l.then(()=>c(t.map(o)));return}var u=sa();function m(){Promise.all(r.map(p=>ii(p))).then(p=>c([...t.map(o),...p])).catch(p=>Pt(p,s)).finally(()=>u())}l?l.then(()=>{i(),m(),tn()}):m()}function si(){var e=ge,t=ve,r=Ie,n=he;return function(a=!0){_t(e),ft(t),vr(r),a&&(e.f&ut)===0&&(n?.activate(),n?.apply())}}function tn(e=!0){_t(null),ft(null),vr(null),e&&he?.deactivate()}function sa(){var e=ge.b,t=he,r=e.is_rendered();return e.update_pending_count(1,t),t.increment(r),(n=!1)=>{e.update_pending_count(-1,t),t.decrement(r,n)}}function Vr(e){var t=Ze|Me,r=ve!==null&&(ve.f&Ze)!==0?ve:null;return ge!==null&&(ge.f|=br),{ctx:Ie,deps:null,effects:null,equals:Ho,f:t,fn:e,reactions:null,rv:0,v:je,wv:0,parent:r??ge,ac:null}}function ii(e,t,r){let n=ge;n===null&&ws();var o=void 0,a=Yt(je),s=!ve,i=new Map;return wi(()=>{var l=ge,c=Uo();o=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(tn)}catch(h){c.reject(h),tn()}var u=he;if(s){if((l.f&er)!==0)var m=sa();if(n.b.is_rendered())i.get(u)?.reject(Et),i.delete(u);else{for(const h of i.values())h.reject(Et);i.clear()}i.set(u,c)}const p=(h,g=void 0)=>{if(m){var _=g===Et;m(_)}if(!(g===Et||(l.f&ut)!==0)){if(u.activate(),g)a.f|=Ct,mr(a,g);else{(a.f&Ct)!==0&&(a.f^=Ct),mr(a,h);for(const[b,x]of i){if(i.delete(b),b===u)break;x.reject(Et)}}u.deactivate()}};c.promise.then(p,h=>p(null,h||"unknown"))}),qn(()=>{for(const l of i.values())l.reject(Et)}),new Promise(l=>{function c(u){function m(){u===o?l(a):c(o)}u.then(m,m)}c(o)})}function te(e){const t=Vr(e);return xa(t),t}function ur(e){const t=Vr(e);return t.equals=Yo,t}function li(e){var t=e.effects;if(t!==null){e.effects=null;for(var r=0;rv(e))),t}function me(e,t,r=!1){ve!==null&&(!mt||(ve.f&so)!==0)&&_r()&&(ve.f&(Ze|Zt|Tn|so))!==0&&(dt===null||!fr.call(dt,e))&&Cs();let n=r?it(t):t;return mr(e,n,Xr)}function mr(e,t,r=null){if(!e.equals(t)){var n=e.v;It?Nt.set(e,t):Nt.set(e,n),e.v=t;var o=Tt.ensure();if(o.capture(e,n),(e.f&Ze)!==0){const a=e;(e.f&Me)!==0&&jn(a),vt===null&&In(a)}e.wv=$a(),ua(e,Me,r),_r()&&ge!==null&&(ge.f&Oe)!==0&&(ge.f&(ht|Kt))===0&&(at===null?Si([e]):at.push(e)),!o.is_fork&&$n.size>0&&!ca&&di()}return t}function di(){ca=!1;for(const e of $n)(e.f&Oe)!==0&&De(e,bt),Br(e)&&hr(e);$n.clear()}function fi(e,t=1){var r=v(e),n=t===1?r++:r--;return me(e,r),n}function Ar(e){me(e,e.v+1)}function ua(e,t,r){var n=e.reactions;if(n!==null)for(var o=_r(),a=n.length,s=0;s{if(Ut===a)return i();var l=ve,c=Ut;ft(null),vo(a);var u=i();return ft(l),vo(c),u};return n&&r.set("length",we(e.length)),new Proxy(e,{defineProperty(i,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&As();var u=r.get(l);return u===void 0?s(()=>{var m=we(c.value);return r.set(l,m),m}):me(u,c.value,!0),!0},deleteProperty(i,l){var c=r.get(l);if(c===void 0){if(l in i){const u=s(()=>we(je));r.set(l,u),Ar(o)}}else me(c,je),Ar(o);return!0},get(i,l,c){if(l===Ot)return e;var u=r.get(l),m=l in i;if(u===void 0&&(!m||cr(i,l)?.writable)&&(u=s(()=>{var h=it(m?i[l]:je),g=we(h);return g}),r.set(l,u)),u!==void 0){var p=v(u);return p===je?void 0:p}return Reflect.get(i,l,c)},getOwnPropertyDescriptor(i,l){var c=Reflect.getOwnPropertyDescriptor(i,l);if(c&&"value"in c){var u=r.get(l);u&&(c.value=v(u))}else if(c===void 0){var m=r.get(l),p=m?.v;if(m!==void 0&&p!==je)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return c},has(i,l){if(l===Ot)return!0;var c=r.get(l),u=c!==void 0&&c.v!==je||Reflect.has(i,l);if(c!==void 0||ge!==null&&(!u||cr(i,l)?.writable)){c===void 0&&(c=s(()=>{var p=u?it(i[l]):je,h=we(p);return h}),r.set(l,c));var m=v(c);if(m===je)return!1}return u},set(i,l,c,u){var m=r.get(l),p=l in i;if(n&&l==="length")for(var h=c;hwe(je)),r.set(h+"",g))}if(m===void 0)(!p||cr(i,l)?.writable)&&(m=s(()=>we(void 0)),me(m,it(c)),r.set(l,m));else{p=m.v!==je;var _=s(()=>it(c));me(m,_)}var b=Reflect.getOwnPropertyDescriptor(i,l);if(b?.set&&b.set.call(u,c),!p){if(n&&typeof l=="string"){var x=r.get("length"),J=Number(l);Number.isInteger(J)&&J>=x.v&&me(x,J+1)}Ar(o)}return!0},ownKeys(i){v(o);var l=Reflect.ownKeys(i).filter(m=>{var p=r.get(m);return p===void 0||p.v!==je});for(var[c,u]of r)u.v!==je&&!(c in i)&&l.push(c);return l},setPrototypeOf(){Ps()}})}function co(e){try{if(e!==null&&typeof e=="object"&&Ot in e)return e[Ot]}catch{}return e}function pi(e,t){return Object.is(co(e),co(t))}var uo,da,fa,pa;function vi(){if(uo===void 0){uo=window,da=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,r=Text.prototype;fa=cr(t,"firstChild").get,pa=cr(t,"nextSibling").get,oo(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),oo(r)&&(r.__t=void 0)}}function kt(e=""){return document.createTextNode(e)}function rn(e){return fa.call(e)}function qr(e){return pa.call(e)}function f(e,t){return rn(e)}function de(e,t=!1){{var r=rn(e);return r instanceof Comment&&r.data===""?qr(r):r}}function d(e,t=1,r=!1){let n=e;for(;t--;)n=qr(n);return n}function mi(e){e.textContent=""}function va(){return!1}function hi(e,t,r){return document.createElementNS(Ko,e,void 0)}let fo=!1;function gi(){fo||(fo=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(const t of e.target.elements)t.__on_r?.()})},{capture:!0}))}function Fn(e){var t=ve,r=ge;ft(null),_t(null);try{return e()}finally{ft(t),_t(r)}}function Mn(e,t,r,n=r){e.addEventListener(t,()=>Fn(r));const o=e.__on_r;o?e.__on_r=()=>{o(),n(!0)}:e.__on_r=()=>n(!0),gi()}function ma(e){ge===null&&(ve===null&&ks(),Ss()),It&&Es()}function bi(e,t){var r=t.last;r===null?t.last=t.first=e:(r.next=e,e.prev=r,t.last=e)}function yt(e,t){var r=ge;r!==null&&(r.f&ot)!==0&&(e|=ot);var n={ctx:Ie,deps:null,nodes:null,f:e|Me|ct,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null},o=n;if((e&pr)!==0)sr!==null?sr.push(n):Tt.ensure().schedule(n);else if(t!==null){try{hr(n)}catch(s){throw et(n),s}o.deps===null&&o.teardown===null&&o.nodes===null&&o.first===o.last&&(o.f&br)===0&&(o=o.first,(e&Zt)!==0&&(e&Ht)!==0&&o!==null&&(o.f|=Ht))}if(o!==null&&(o.parent=r,r!==null&&bi(o,r),ve!==null&&(ve.f&Ze)!==0&&(e&Kt)===0)){var a=ve;(a.effects??=[]).push(o)}return n}function Vn(){return ve!==null&&!mt}function qn(e){const t=yt(Fr,null);return De(t,Oe),t.teardown=e,t}function Nr(e){ma();var t=ge.f,r=!ve&&(t&ht)!==0&&(t&er)===0;if(r){var n=Ie;(n.e??=[]).push(e)}else return ha(e)}function ha(e){return yt(pr|Jo,e)}function _i(e){return ma(),yt(Fr|Jo,e)}function yi(e){Tt.ensure();const t=yt(Kt|br,e);return(r={})=>new Promise(n=>{r.outro?qt(t,()=>{et(t),n(void 0)}):(et(t),n(void 0))})}function xi(e){return yt(pr,e)}function wi(e){return yt(Tn|br,e)}function Un(e,t=0){return yt(Fr|t,e)}function ae(e,t=[],r=[],n=[]){ai(n,t,r,o=>{yt(Fr,()=>e(...o.map(v)))})}function Ur(e,t=0){var r=yt(Zt|t,e);return r}function st(e){return yt(ht|br,e)}function ga(e){var t=e.teardown;if(t!==null){const r=It,n=ve;po(!0),ft(null);try{t.call(null)}finally{po(r),ft(n)}}}function Bn(e,t=!1){var r=e.first;for(e.first=e.last=null;r!==null;){const o=r.ac;o!==null&&Fn(()=>{o.abort(Et)});var n=r.next;(r.f&Kt)!==0?r.parent=null:et(r,t),r=n}}function $i(e){for(var t=e.first;t!==null;){var r=t.next;(t.f&ht)===0&&et(t),t=r}}function et(e,t=!0){var r=!1;(t||(e.f&_s)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Ei(e.nodes.start,e.nodes.end),r=!0),De(e,ao),Bn(e,t&&!r),Tr(e,0);var n=e.nodes&&e.nodes.t;if(n!==null)for(const a of n)a.stop();ga(e),e.f^=ao,e.f|=ut;var o=e.parent;o!==null&&o.first!==null&&ba(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Ei(e,t){for(;e!==null;){var r=e===t?null:qr(e);e.remove(),e=r}}function ba(e){var t=e.parent,r=e.prev,n=e.next;r!==null&&(r.next=n),n!==null&&(n.prev=r),t!==null&&(t.first===e&&(t.first=n),t.last===e&&(t.last=r))}function qt(e,t,r=!0){var n=[];_a(e,n,!0);var o=()=>{r&&et(e),t&&t()},a=n.length;if(a>0){var s=()=>--a||o();for(var i of n)i.out(s)}else o()}function _a(e,t,r){if((e.f&ot)===0){e.f^=ot;var n=e.nodes&&e.nodes.t;if(n!==null)for(const i of n)(i.is_global||r)&&t.push(i);for(var o=e.first;o!==null;){var a=o.next,s=(o.f&Ht)!==0||(o.f&ht)!==0&&(e.f&Zt)!==0;_a(o,t,s?r:!1),o=a}}}function Jn(e){ya(e,!0)}function ya(e,t){if((e.f&ot)!==0){e.f^=ot,(e.f&Oe)===0&&(De(e,Me),Tt.ensure().schedule(e));for(var r=e.first;r!==null;){var n=r.next,o=(r.f&Ht)!==0||(r.f&ht)!==0;ya(r,o?t:!1),r=n}var a=e.nodes&&e.nodes.t;if(a!==null)for(const s of a)(s.is_global||t)&&s.in()}}function Wn(e,t){if(e.nodes)for(var r=e.nodes.start,n=e.nodes.end;r!==null;){var o=r===n?null:qr(r);t.append(r),r=o}}let Qr=!1,It=!1;function po(e){It=e}let ve=null,mt=!1;function ft(e){ve=e}let ge=null;function _t(e){ge=e}let dt=null;function xa(e){ve!==null&&(dt===null?dt=[e]:dt.push(e))}let Xe=null,nt=0,at=null;function Si(e){at=e}let wa=1,Mt=0,Ut=Mt;function vo(e){Ut=e}function $a(){return++wa}function Br(e){var t=e.f;if((t&Me)!==0)return!0;if(t&Ze&&(e.f&=~Gt),(t&bt)!==0){for(var r=e.deps,n=r.length,o=0;oe.wv)return!0}(t&ct)!==0&&vt===null&&De(e,Oe)}return!1}function Ea(e,t,r=!0){var n=e.reactions;if(n!==null&&!(dt!==null&&fr.call(dt,e)))for(var o=0;o{e.ac.abort(Et)}),e.ac=null);try{e.f|=yn;var u=e.fn,m=u();e.f|=er;var p=e.deps,h=he?.is_fork;if(Xe!==null){var g;if(h||Tr(e,nt),p!==null&&nt>0)for(p.length=nt+Xe.length,g=0;g{throw b});throw p}}finally{e[Sr]=t,delete e.currentTarget,ft(u),_t(m)}}}const Ci=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Oi(e){return Ci?.createHTML(e)??e}function Ni(e){var t=hi("template");return t.innerHTML=Oi(e.replaceAll("","")),t.content}function nn(e,t){var r=ge;r.nodes===null&&(r.nodes={start:e,end:t,a:null,t:null})}function k(e,t){var r=(t&Vs)!==0,n=(t&qs)!==0,o,a=!e.startsWith("");return()=>{o===void 0&&(o=Ni(a?e:""+e),r||(o=rn(o)));var s=n||da?document.importNode(o,!0):o.cloneNode(!0);if(r){var i=rn(s),l=s.lastChild;nn(i,l)}else nn(s,s);return s}}function Kn(e=""){{var t=kt(e+"");return nn(t,t),t}}function Bt(){var e=document.createDocumentFragment(),t=document.createComment(""),r=kt();return e.append(t,r),nn(t,r),e}function $(e,t){e!==null&&e.before(t)}function G(e,t){var r=t==null?"":typeof t=="object"?`${t}`:t;r!==(e.__t??=e.nodeValue)&&(e.__t=r,e.nodeValue=`${r}`)}function Ti(e,t){return Ii(e,t)}const Wr=new Map;function Ii(e,{target:t,anchor:r,props:n={},events:o,context:a,intro:s=!0,transformError:i}){vi();var l=void 0,c=yi(()=>{var u=r??t.appendChild(kt());ni(u,{pending:()=>{}},h=>{Ne({});var g=Ie;a&&(g.c=a),o&&(n.$$events=o),l=e(h,n)||{},Te()},i);var m=new Set,p=h=>{for(var g=0;g{for(var h of m)for(const b of[t,document]){var g=Wr.get(b),_=g.get(h);--_==0?(b.removeEventListener(h,ho),g.delete(h),g.size===0&&Wr.delete(b)):g.set(h,_)}Sn.delete(p),u!==r&&u.parentNode?.removeChild(u)}});return Zi.set(l,c),l}let Zi=new WeakMap;class Hn{anchor;#e=new Map;#l=new Map;#t=new Map;#s=new Set;#n=!0;constructor(t,r=!0){this.anchor=t,this.#n=r}#r=t=>{if(this.#e.has(t)){var r=this.#e.get(t),n=this.#l.get(r);if(n)Jn(n),this.#s.delete(r);else{var o=this.#t.get(r);o&&(this.#l.set(r,o.effect),this.#t.delete(r),o.fragment.lastChild.remove(),this.anchor.before(o.fragment),n=o.effect)}for(const[a,s]of this.#e){if(this.#e.delete(a),a===t)break;const i=this.#t.get(s);i&&(et(i.effect),this.#t.delete(s))}for(const[a,s]of this.#l){if(a===r||this.#s.has(a))continue;const i=()=>{if(Array.from(this.#e.values()).includes(a)){var c=document.createDocumentFragment();Wn(s,c),c.append(kt()),this.#t.set(a,{effect:s,fragment:c})}else et(s);this.#s.delete(a),this.#l.delete(a)};this.#n||!n?(this.#s.add(a),qt(s,i,!1)):i()}}};#o=t=>{this.#e.delete(t);const r=Array.from(this.#e.values());for(const[n,o]of this.#t)r.includes(n)||(et(o.effect),this.#t.delete(n))};ensure(t,r){var n=he,o=va();if(r&&!this.#l.has(t)&&!this.#t.has(t))if(o){var a=document.createDocumentFragment(),s=kt();a.append(s),this.#t.set(t,{effect:st(()=>r(s)),fragment:a})}else this.#l.set(t,st(()=>r(this.anchor)));if(this.#e.set(n,t),o){for(const[i,l]of this.#l)i===t?n.unskip_effect(l):n.skip_effect(l);for(const[i,l]of this.#t)i===t?n.unskip_effect(l.effect):n.skip_effect(l.effect);n.oncommit(this.#r),n.ondiscard(this.#o)}else this.#r(n)}}function se(e,t,r=!1){var n=new Hn(e),o=r?Ht:0;function a(s,i){n.ensure(s,i)}Ur(()=>{var s=!1;t((i,l=0)=>{s=!0,a(l,i)}),s||a(-1,null)},o)}const Ri=Symbol("NaN");function ji(e,t,r){var n=new Hn(e),o=!_r();Ur(()=>{var a=t();a!==a&&(a=Ri),o&&a!==null&&typeof a=="object"&&(a={}),n.ensure(a,r)})}function Ir(e,t){return t}function Li(e,t,r){for(var n=[],o=t.length,a,s=t.length,i=0;i{if(a){if(a.pending.delete(m),a.done.add(m),a.pending.size===0){var p=e.outrogroups;kn(e,cn(a.done)),p.delete(a),p.size===0&&(e.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=n.length===0&&r!==null;if(l){var c=r,u=c.parentNode;mi(u),u.append(c),e.items.clear()}kn(e,t,!l)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function kn(e,t,r=!0){var n;if(e.pending.size>0){n=new Set;for(const s of e.pending.values())for(const i of s)n.add(e.items.get(i).e)}for(var o=0;o{var A=r();return On(A)?A:A==null?[]:cn(A)}),p,h=new Map,g=!0;function _(A){(J.effect.f&ut)===0&&(J.pending.delete(A),J.fallback=u,Fi(J,p,s,t,n),u!==null&&(p.length===0?(u.f>)===0?Jn(u):(u.f^=gt,kr(u,null,s)):qt(u,()=>{u=null})))}function b(A){J.pending.delete(A)}var x=Ur(()=>{p=v(m);for(var A=p.length,D=new Set,R=he,H=va(),T=0;Ta(s)):(u=st(()=>a(go??=kt())),u.f|=gt)),A>D.size&&$s(),!g)if(h.set(R,D),H){for(const[F,q]of i)D.has(F)||R.skip_effect(q.e);R.oncommit(_),R.ondiscard(b)}else _(R);v(m)}),J={effect:x,items:i,pending:h,outrogroups:null,fallback:u};g=!1}function Er(e){for(;e!==null&&(e.f&ht)===0;)e=e.next;return e}function Fi(e,t,r,n,o){var a=(n&Is)!==0,s=t.length,i=e.items,l=Er(e.effect.first),c,u=null,m,p=[],h=[],g,_,b,x;if(a)for(x=0;x0){var L=(n&Wo)!==0&&s===0?r:null;if(a){for(x=0;x{if(m!==void 0)for(b of m)b.nodes?.a?.apply()})}function Mi(e,t,r,n,o,a,s,i){var l=(s&Ns)!==0?(s&Zs)===0?Ln(r,!1,!1):Yt(r):null,c=(s&Ts)!==0?Yt(o):null;return{v:l,i:c,e:st(()=>(a(t,l??r,c??o,i),()=>{e.delete(n)}))}}function kr(e,t,r){if(e.nodes)for(var n=e.nodes.start,o=e.nodes.end,a=t&&(t.f>)===0?t.nodes.start:r;n!==null;){var s=qr(n);if(a.before(n),n===o)return;n=s}}function At(e,t,r){t===null?e.effect.first=r:t.next=r,r===null?e.effect.last=t:r.prev=t}function Jt(e,t,...r){var n=new Hn(e);Ur(()=>{const o=t()??null;n.ensure(o,o&&(a=>o(a,...r)))},Ht)}function Vi(e,t,r){var n=e==null?"":""+e;return n===""?null:n}function qe(e,t,r,n,o,a){var s=e.__className;if(s!==r||s===void 0){var i=Vi(r);i==null?e.removeAttribute("class"):t?e.className=i:e.setAttribute("class",i),e.__className=r}return a}function Aa(e,t,r=!1){if(e.multiple){if(t==null)return;if(!On(t))return Us();for(var n of e.options)n.selected=t.includes(Pr(n));return}for(n of e.options){var o=Pr(n);if(pi(o,t)){n.selected=!0;return}}(!r||t!==void 0)&&(e.selectedIndex=-1)}function qi(e){var t=new MutationObserver(()=>{Aa(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),qn(()=>{t.disconnect()})}function un(e,t,r=t){var n=new WeakSet,o=!0;Mn(e,"change",a=>{var s=a?"[selected]":":checked",i;if(e.multiple)i=[].map.call(e.querySelectorAll(s),Pr);else{var l=e.querySelector(s)??e.querySelector("option:not([disabled])");i=l&&Pr(l)}r(i),e.__value=i,he!==null&&n.add(he)}),xi(()=>{var a=t();if(e===document.activeElement){var s=he;if(n.has(s))return}if(Aa(e,a,o),o&&a===void 0){var i=e.querySelector(":checked");i!==null&&(a=Pr(i),r(a))}e.__value=a,o=!1}),qi(e)}function Pr(e){return"__value"in e?e.__value:e.value}const Ui=Symbol("is custom element"),Bi=Symbol("is html");function Le(e,t,r,n){var o=Ji(e);o[t]!==(o[t]=r)&&(t==="loading"&&(e[xs]=r),r==null?e.removeAttribute(t):typeof r!="string"&&Wi(e).includes(t)?e[t]=r:e.setAttribute(t,r))}function Ji(e){return e.__attributes??={[Ui]:e.nodeName.includes("-"),[Bi]:e.namespaceURI===Ko}}var bo=new Map;function Wi(e){var t=e.getAttribute("is")||e.nodeName,r=bo.get(t);if(r)return r;bo.set(t,r=[]);for(var n,o=e,a=Element.prototype;a!==o;){n=qo(o);for(var s in n)n[s].set&&r.push(s);o=Nn(o)}return r}function Zr(e,t,r=t){var n=new WeakSet;Mn(e,"input",async o=>{var a=o?e.defaultValue:e.value;if(a=mn(e)?hn(a):a,r(a),he!==null&&n.add(he),await zi(),a!==(a=t())){var s=e.selectionStart,i=e.selectionEnd,l=e.value.length;if(e.value=a??"",i!==null){var c=e.value.length;s===i&&i===l&&c>l?(e.selectionStart=c,e.selectionEnd=c):(e.selectionStart=s,e.selectionEnd=Math.min(i,c))}}}),tr(t)==null&&e.value&&(r(mn(e)?hn(e.value):e.value),he!==null&&n.add(he)),Un(()=>{var o=t();if(e===document.activeElement){var a=he;if(n.has(a))return}mn(e)&&o===hn(e.value)||e.type==="date"&&!o&&!e.value||o!==e.value&&(e.value=o??"")})}function Cr(e,t,r=t){Mn(e,"change",n=>{var o=n?e.defaultChecked:e.checked;r(o)}),tr(t)==null&&r(e.checked),Un(()=>{var n=t();e.checked=!!n})}function mn(e){var t=e.type;return t==="number"||t==="range"}function hn(e){return e===""?null:+e}function Ki(e=!1){const t=Ie,r=t.l.u;if(!r)return;let n=()=>Di(t.s);if(e){let o=0,a={};const s=Vr(()=>{let i=!1;const l=t.s;for(const c in l)l[c]!==a[c]&&(a[c]=l[c],i=!0);return i&&o++,o});n=()=>v(s)}r.b.length&&_i(()=>{_o(t,n),en(r.b)}),Nr(()=>{const o=tr(()=>r.m.map(bs));return()=>{for(const a of o)typeof a=="function"&&a()}}),r.a.length&&Nr(()=>{_o(t,n),en(r.a)})}function _o(e,t){if(e.l.s)for(const r of e.l.s)v(r);t()}function Qe(e,t,r,n){var o=!Mr||(r&js)!==0,a=(r&Fs)!==0,s=(r&Ms)!==0,i=n,l=!0,c=()=>(l&&(l=!1,i=s?tr(n):n),i);let u;if(a){var m=Ot in e||ys in e;u=cr(e,t)?.set??(m&&t in e?A=>e[t]=A:void 0)}var p,h=!1;a?[p,h]=Ys(()=>e[t]):p=e[t],p===void 0&&n!==void 0&&(p=c(),u&&(o&&Ds(),u(p)));var g;if(o?g=()=>{var A=e[t];return A===void 0?c():(l=!0,A)}:g=()=>{var A=e[t];return A!==void 0&&(i=void 0),A===void 0?i:A},o&&(r&Ls)===0)return g;if(u){var _=e.$$legacy;return(function(A,D){return arguments.length>0?((!o||!D||_||h)&&u(D?g():A),A):g()})}var b=!1,x=((r&Rs)!==0?Vr:ur)(()=>(b=!1,g()));a&&v(x);var J=ge;return(function(A,D){if(arguments.length>0){const R=D?v(x):o&&a?it(A):A;return me(x,R),b=!0,i!==void 0&&(i=R),A}return It&&b||(J.f&ut)!==0?x.v:v(x)})}const Hi="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(Hi);function Gi(e){const t=e.batchSize,r=e.flushInterval,n=e.include,o=[];let a;const s=u=>!n||n.includes(u),i=(u,m)=>{s(u)&&(o.push({type:u,timestamp:Date.now(),detail:m}),o.length>=t&&l())},l=()=>{if(o.length===0)return;const u=o.splice(0);e.onFlush(u)};return{name:"analytics",onInit(){a=setInterval(l,r)},onChange(u){const m=e.redact?.includes(u.property);i("change",{property:u.property,currentValue:m?"[redacted]":u.currentValue,oldValue:m?"[redacted]":u.oldValue})},onValidation(u){i("validation",{hasErrors:u!==void 0})},onSnapshot(u){i("snapshot",{title:u.title})},onAction(u){i("action",{phase:u.phase,error:u.error?.message})},onRollback(u){i("rollback",{title:u.title})},onReset(){i("reset",{})},destroy(){a!==void 0&&clearInterval(a),l()},flush(){l()},eventCount(){return o.length}}}function Yi(e){const t=e.idle??1e3,r=e.interval??0,n=e.saveOnDestroy??!0,o=e.onlyWhenDirty??!0;let a,s,i,l=!1,c=!1;const u=async()=>{if(a&&!(o&&!Ye(a.state.isDirty))&&!l){l=!0;try{await e.save(a.data)}catch(g){e.onError?.(g)}finally{l=!1}}},m=()=>{clearTimeout(s),s=setTimeout(u,t)},p=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};return{name:"autosave",onInit(g){a=g,r>0&&(i=setInterval(u,r)),e.onVisibilityHidden&&typeof document<"u"&&document.addEventListener("visibilitychange",p)},onChange(){m()},onAction(g){g.phase==="after"&&!g.error&&clearTimeout(s)},destroy(){if(c=!0,clearTimeout(s),i!==void 0&&clearInterval(i),typeof document<"u"&&document.removeEventListener("visibilitychange",p),n&&a&&(l=!1,!o||Ye(a.state.isDirty)))try{const _=e.save(a.data);_ instanceof Promise&&_.catch(b=>e.onError?.(b))}catch(_){e.onError?.(_)}},async saveNow(){c||(clearTimeout(s),l=!1,await u())},isSaving(){return l}}}function Xi(e){const t=e?.name,r=e?.collapsed??!0,n=e?.logValues??!1,o=(a,...s)=>{const i=new Date().toISOString().slice(11,23);(r?console.groupCollapsed:console.group)(`[${t}] ${a} (${i})`);for(const c of s)console.log(c);console.groupEnd()};return{name:"devtools",onChange(a){n?o("change",{property:a.property,from:a.oldValue,to:a.currentValue}):o("change",{property:a.property})},onValidation(a){o("validation",a)},onSnapshot(a){o("snapshot",{title:a.title})},onAction(a){a.error?o(`action:${a.phase}`,{params:a.params,error:a.error.message}):o(`action:${a.phase}`,{params:a.params})},onRollback(a){o("rollback",{title:a.title})},onReset(){o("reset")}}}const zn=new Set(["__proto__","constructor","prototype"]),Dn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Qi=e=>Dn(e)&&typeof e.version=="number"&&Dn(e.data),el=(e,t)=>{for(const r of Object.keys(t))zn.has(r)||(e[r]=t[r])},tl=(e,t)=>{const r=t.split(".");let n=e;for(const o of r){if(n==null)return;n=n[o]}return n},rl=(e,t,r)=>{const n=t.split(".");let o=e;for(let s=0;s{if(t){const n={};for(const o of t){const a=tl(e,o);a!==void 0&&rl(n,o,a)}return n}if(r){const n={...e};for(const o of r){const a=o.split(".");if(a.length===1)delete n[o];else{let s=n;for(let i=0;i"u"?void 0:localStorage),r=e.throttle??300,n=e.version??1;let o=!1,a,s;const i=()=>{if(!t||!s)return;const u=nl(s,e.include,e.exclude),m={version:n,data:u};t.setItem(e.key,JSON.stringify(m))},l=()=>{clearTimeout(a),a=setTimeout(i,r)};return{name:"persist",onInit(u){if(s=u.data,!t)return;const m=t.getItem(e.key);if(m)try{const p=JSON.parse(m);if(!Qi(p))return;let h=p;if(e.migrate&&h.version!==n){const g=e.migrate(h.data,h.version);if(!Dn(g))return;h={version:n,data:g}}el(u.data,h.data),o=!0}catch{}},onChange(){l()},onReset(){i()},destroy(){a!==void 0&&(clearTimeout(a),i())},clearPersistedState(){t?.removeItem(e.key)},isRestored(){return o}}}const al=new Set(["__proto__","constructor","prototype"]),sl=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),il=(e,t)=>{for(const r of Object.keys(t))al.has(r)||(e[r]=t[r])};function ll(e){const t=e.throttle,r=e.merge??"overwrite";let n,o,a=!1,s,i=0;const l=()=>{if(!n||!o)return;const m=JSON.parse(JSON.stringify(o.data));n.postMessage({type:"sync",data:m})},c=()=>{clearTimeout(s),s=setTimeout(l,t)},u=()=>{clearTimeout(s),n&&(n.close(),n=void 0)};return{name:"sync",onInit(m){o=m,!(typeof BroadcastChannel>"u")&&(n=new BroadcastChannel(e.key),n.addEventListener("message",p=>{if(!o||r==="ignore"||p.data?.type!=="sync")return;const h=Date.now();h-i{if(l===null||typeof l!="object")return l;if(l instanceof Date)return new Date(l);if(Array.isArray(l))return l.map(u=>a(u));const c=Object.create(Object.getPrototypeOf(l));for(const u of Object.keys(l))c[u]=a(l[u]);return c},s={name:"undo-redo",redoStack:{subscribe:t.subscribe},onInit(l){n=l,o=l.state.snapshots.subscribe(c=>{r=c})},onRollback(){i&&(t.update(l=>{const c=[...l,i],u=e?.maxRedoStack;return u&&u>0?c.slice(-u):c}),i=void 0)},onChange(){t.set([])},onReset(){t.set([])},redo(){if(!n)return;const l=Ye(t);if(l.length===0)return;const c=l.at(-1);t.set(l.slice(0,-1)),n.snapshot("Undo"),Object.assign(n.data,a(c.data))},canRedo(){return Ye(t).length>0},destroy(){o?.()}};let i;return s.onInit,s.onInit=l=>{n=l,o=l.state.snapshots.subscribe(c=>{c.length0&&(i=r.at(-1)),r=c})},s}const ul=e=>typeof e=="object"&&e!==null&&!(e instanceof Date)&&!(e instanceof Map)&&!(e instanceof Set)&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Promise),dl=(e,t)=>{const r=(o,a)=>new Proxy(o,{get(s,i){const l=s[i];if(ul(l)){const c=Number.isInteger(Number(i))?"":String(i),u=c?a?`${a}.${c}`:c:a;return r(l,u)}return l},set(s,i,l){const c=s[i];if(c!==l){s[i]=l;const u=Number.isInteger(Number(i))?"":String(i),m=u?a?`${a}.${u}`:u:a;t(n,m,l,c)}return!0}}),n=r(e,"");return n},Pa=e=>Object.values(e).some(t=>typeof t=="string"?!!t:Pa(t)),fl=e=>!!e&&Pa(e),pl=new Set(["__proto__","constructor","prototype"]),ir=e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return e.map(r=>ir(r));const t=Object.create(Object.getPrototypeOf(e));for(const r of Object.keys(e))pl.has(r)||(t[r]=ir(e[r]));return t},vl=(e,t)=>{const r=t.split(".");let n=e;for(const o of r){if(n==null)return;n=n[o]}return n},ml=(e,t)=>{if(!e)return"";const r=t.split(".");let n=e;for(const o of r){if(typeof n=="string"||n[o]===void 0)return"";n=n[o]}return typeof n=="string"?n:""},hl=(e,t)=>{const r=[];for(const n of Object.keys(e))(n===t||n.startsWith(t+".")||t.startsWith(n+"."))&&r.push(n);return r},gl={resetDirtyOnAction:!0,debounceValidation:0,allowConcurrentActions:!1,persistActionError:!1,debounceAsyncValidation:300,runAsyncValidationOnInit:!1,clearAsyncErrorsOnChange:!0,maxConcurrentAsyncValidations:4,maxSnapshots:50,plugins:[]};function Be(e,t,r){const n={...gl,...r},{validator:o,effect:a,asyncValidator:s}=t??{},i=wt(),l=$r(i,fl),c=wt({}),u=$r(c,y=>Object.keys(y).length>0),m=wt(!1),p=wt(),h=wt([{title:"Initial",data:ir(e)}]),g=wt({}),_=wt(new Set),b=$r(_,y=>[...y]),x=$r(g,y=>Object.values(y).some(S=>!!S)),J=$r([l,x],([y,S])=>y||S),A=new Map,D=[],R=y=>{c.update(S=>{const C={...S,[y]:!0},ne=y.split(".");for(let ue=1;ue{for(const C of T){const ne=C[y];typeof ne=="function"&&ne.call(C,...S)}},L=()=>{if(!o)return;const y=o(B);i.set(y),P("onValidation",y)},z=(y,S=!0)=>{const C=Ye(h),ne={title:y,data:ir(H)},ue=C.at(-1);let fe=S&&ue&&ue.title===y?[...C.slice(0,-1),ne]:[...C,ne];if(n.maxSnapshots>0&&fe.length>n.maxSnapshots){const Ae=fe.length-n.maxSnapshots;fe=[fe[0],...fe.slice(1+Ae)]}h.set(fe),P("onSnapshot",ne)};let F=!1,q;const I=()=>{if(o)if(n.debounceValidation>0)clearTimeout(q),q=setTimeout(()=>{L()},n.debounceValidation);else{if(F)return;F=!0,queueMicrotask(()=>{L(),F=!1})}},N=y=>{const S=D.indexOf(y);S!==-1&&D.splice(S,1)},M=y=>{N(y);const S=A.get(y);S&&(clearTimeout(S.timeoutId),S.controller.abort(),A.delete(y),_.update(C=>(C.delete(y),new Set(C))))},j=()=>{D.length=0;for(const y of A.keys())M(y);g.set({})},W=async(y,S)=>{if(!s){S();return}const C=s[y];if(!C){S();return}if(ml(Ye(i),y)){S();return}const ue=new AbortController;A.set(y,{controller:ue,timeoutId:0}),_.update(fe=>new Set([...fe,y]));try{const fe=vl(B,y),Ae=await C(fe,B,ue.signal);ue.signal.aborted||g.update(Ee=>({...Ee,[y]:Ae}))}catch(fe){if(fe instanceof Error&&fe.name==="AbortError")return;if(!ue.signal.aborted){const Ae=fe instanceof Error?fe.message:"Async validation error";g.update(Ee=>({...Ee,[y]:Ae}))}}finally{A.delete(y),_.update(fe=>(fe.delete(y),new Set(fe))),S()}},K=()=>{for(;D.length>0&&!(Ye(_).size>=n.maxConcurrentAsyncValidations);){const S=D.shift();S&&W(S,K)}},V=y=>{if(!s||!s[y])return;M(y),n.clearAsyncErrorsOnChange&&g.update(ne=>{const ue={...ne};return delete ue[y],ue});const S=new AbortController,C=setTimeout(()=>{A.delete(y),Ye(_).size{if(!s)return;const S=hl(s,y);for(const C of S)V(C)},B=dl(H,(y,S,C,ne)=>{if(n.persistActionError||p.set(void 0),R(S),a?.({snapshot:z,target:y,property:S,currentValue:C,oldValue:ne})instanceof Promise)throw new Error("svstate: effect callback must be synchronous. Use action for async operations.");P("onChange",{target:y,property:S,currentValue:C,oldValue:ne}),I(),w(S)});if(L(),s&&n.runAsyncValidationOnInit)for(const y of Object.keys(s))V(y);const Y=async y=>{if(!(!n.allowConcurrentActions&&Ye(m))){P("onAction",{phase:"before",params:y}),p.set(void 0),m.set(!0);try{await t?.action?.(y),n.resetDirtyOnAction&&c.set({}),h.set([{title:"Initial",data:ir(H)}]),await t?.actionCompleted?.(),P("onAction",{phase:"after",params:y})}catch(S){await t?.actionCompleted?.(S);const C=S instanceof Error?S:void 0;p.set(C),P("onAction",{phase:"after",params:y,error:C})}finally{m.set(!1)}}},X=(y,S)=>{const C=S[y];if(C)return j(),c.set({}),Object.assign(H,ir(C.data)),h.set(S.slice(0,y+1)),L(),C},Q=(y=1)=>{const S=Ye(h);if(S.length<=1)return;const C=Math.max(0,S.length-1-y),ne=X(C,S);ne&&P("onRollback",ne)},U=y=>{const S=Ye(h);if(S.length<=1)return!1;for(let C=S.length-1;C>=0;C--)if(S[C].title===y){const ne=X(C,S);return ne&&P("onRollback",ne),!0}return!1},Z=()=>{const y=Ye(h);y[0]&&(X(0,y),P("onReset"))},O={errors:i,hasErrors:l,isDirty:u,isDirtyByField:c,actionInProgress:m,actionError:p,snapshots:h,asyncErrors:g,hasAsyncErrors:x,asyncValidating:b,hasCombinedErrors:J},re=()=>{for(let y=T.length-1;y>=0;y--)T[y]?.destroy?.()};return P("onInit",{data:B,state:O,options:n,snapshot:z}),{data:B,execute:Y,state:O,rollback:Q,rollbackTo:U,reset:Z,destroy:re}}const bl={trim:e=>e.trim(),normalize:e=>e.replaceAll(/\s{2,}/g," "),upper:e=>e.toUpperCase(),lower:e=>e.toLowerCase(),localeUpper:e=>e.toLocaleUpperCase(),localeLower:e=>e.toLocaleLowerCase()};function ie(e){let t="";const r=e==null;let n=e??"";const o=s=>{t||(t=s)},a={prepare(...s){return n=s.reduce((i,l)=>bl[l](i),n),a},required(){return!t&&(r||!n)&&o("Required"),a},requiredIf(s){return s&&!t&&(r||!n)&&o("Required"),a},noSpace(){return r||!t&&n.includes(" ")&&o("No space allowed"),a},notBlank(){return r||!t&&n.length>0&&n.trim().length===0&&o("Must not be blank"),a},minLength(s){return r||!t&&n.lengths&&o(`Max length ${s}`),a},uppercase(){return r||!t&&n!==n.toUpperCase()&&o("Uppercase only"),a},lowercase(){return r||!t&&n!==n.toLowerCase()&&o("Lowercase only"),a},startsWith(s){if(t)return a;const i=Array.isArray(s)?s:[s];return n&&!i.some(l=>n.startsWith(l))&&o(`Must start with ${i.join(", ")}`),a},regexp(s,i){return!t&&n&&!s.test(n)&&o(i??"Not allowed chars"),a},in(s){if(t)return a;const i=Array.isArray(s)?s:Object.keys(s);return n&&!i.includes(n)&&o(`Must be one of: ${i.join(", ")}`),a},notIn(s){if(t)return a;const i=Array.isArray(s)?s:Object.keys(s);return n&&i.includes(n)&&o(`Must not be one of: ${i.join(", ")}`),a},email(){return!t&&n&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)&&o("Invalid email format"),a},website(s="optional"){if(t||!n||s==="optional")return a;const i=/^https?:\/\//.test(n);return s==="required"&&!i?o("Must start with http:// or https://"):s==="forbidden"&&i&&o("Must not start with http:// or https://"),a},endsWith(s){if(t||!n)return a;const i=Array.isArray(s)?s:[s];return i.some(l=>n.endsWith(l))||o(`Must end with ${i.join(", ")}`),a},contains(s){return!t&&n&&!n.includes(s)&&o(`Must contain "${s}"`),a},alphanumeric(){return!t&&n&&!/^[\dA-Za-z]+$/.test(n)&&o("Only letters and numbers allowed"),a},numeric(){return!t&&n&&!/^\d+$/.test(n)&&o("Only numbers allowed"),a},slug(){return!t&&n&&!/^[\da-z-]+$/.test(n)&&o("Invalid slug format"),a},identifier(){return!t&&n&&!/^[A-Z_a-z]\w*$/.test(n)&&o("Invalid identifier format"),a},getError(){return t}};return a}function Rr(e){let t="";const r=e==null,n=a=>{t||(t=a)},o={required(){return!t&&(r||Number.isNaN(e))&&n("Required"),o},requiredIf(a){return a&&!t&&(r||Number.isNaN(e))&&n("Required"),o},min(a){return r||!t&&ea&&n(`Maximum ${a}`),o},between(a,s){return r||!t&&(es)&&n(`Must be between ${a} and ${s}`),o},integer(){return r||!t&&!Number.isInteger(e)&&n("Must be an integer"),o},positive(){return r||!t&&e<=0&&n("Must be positive"),o},negative(){return r||!t&&e>=0&&n("Must be negative"),o},nonNegative(){return r||!t&&e<0&&n("Must be non-negative"),o},notZero(){return r||!t&&e===0&&n("Must not be zero"),o},multipleOf(a){return r||!t&&e%a!==0&&n(`Must be a multiple of ${a}`),o},step(a){return r||!t&&e%a!==0&&n(`Must be a multiple of ${a}`),o},decimal(a){return r||t||Number.isNaN(e)||(String(e).split(".")[1]?.length??0)>a&&n(`Maximum ${a} decimal places`),o},percentage(){return r||!t&&(e<0||e>100)&&n("Must be between 0 and 100"),o},getError(){return t}};return o}function _l(e){let t="";const r=e==null,n=e??[],o=s=>{t||(t=s)},a={required(){return!t&&(r||n.length===0)&&o("Required"),a},requiredIf(s){return s&&!t&&(r||n.length===0)&&o("Required"),a},minLength(s){return r||!t&&n.lengths&&o(`Maximum ${s} items`),a},unique(){if(r||t)return a;const s=new Set;for(const i of n){const l=typeof i=="object"?JSON.stringify(i):String(i);if(s.has(l)){o("Items must be unique");break}s.add(l)}return a},ofLength(s){return r||!t&&n.length!==s&&o(`Must have exactly ${s} items`),a},includes(s){if(r||t)return a;const i=typeof s=="object"?JSON.stringify(s):String(s);return n.some(c=>(typeof c=="object"?JSON.stringify(c):String(c))===i)||o(`Must include ${i}`),a},includesAny(s){if(r||t)return a;const i=s.map(c=>typeof c=="object"?JSON.stringify(c):String(c));return n.some(c=>{const u=typeof c=="object"?JSON.stringify(c):String(c);return i.includes(u)})||o(`Must include at least one of: ${i.join(", ")}`),a},includesAll(s){if(r||t)return a;const i=new Set(n.map(c=>typeof c=="object"?JSON.stringify(c):String(c))),l=s.filter(c=>{const u=typeof c=="object"?JSON.stringify(c):String(c);return!i.has(u)});if(l.length>0){const c=l.map(u=>typeof u=="object"?JSON.stringify(u):String(u));o(`Missing required items: ${c.join(", ")}`)}return a},getError(){return t}};return a}var yl=k('
                '),xl=k('
                 
                ');function pe(e,t){var r=xl(),n=f(r);{var o=i=>{var l=yl(),c=f(l);ae(()=>G(c,t.title)),$(i,l)};se(n,i=>{t.title&&i(o)})}var a=d(n,2),s=f(a);ae(()=>G(s,t.code)),$(e,r)}var wl=k('
                Dirty Fields
                 
                '),$l=k('
                State Object
                 
                State Info
                isDirty:
                hasErrors:
                Errors
                 
                ');function Je(e,t){Ne(t,!0);let r=Qe(t,"width",3,"xl:w-80");var n=$l(),o=f(n),a=d(f(o),2),s=f(a),i=d(o,2),l=d(f(i),2),c=f(l),u=d(f(c)),m=d(c,2),p=d(f(m)),h=d(i,2);{var g=A=>{var D=wl(),R=d(f(D),2),H=f(R);ae(T=>G(H,T),[()=>JSON.stringify(t.isDirtyByField,Object.keys(t.isDirtyByField).toSorted(),2)]),$(A,D)};se(h,A=>{t.isDirtyByField&&A(g)})}var _=d(h,2),b=d(f(_),2),x=f(b),J=d(_,2);ae((A,D)=>{qe(n,1,`w-full ${r()??""} flex-shrink-0 space-y-4`),G(s,A),G(u,` ${t.isDirty??""}`),G(p,` ${t.hasErrors??""}`),G(x,D)},[()=>JSON.stringify(t.data,void 0,2),()=>JSON.stringify(t.errors,void 0,2)]),ye("click",J,function(...A){t.onFill?.apply(this,A)}),$(e,n),Te()}tt(["click"]);var El=k('

                ');function Or(e,t){var r=Bt(),n=de(r);{var o=a=>{var s=El(),i=f(s);ae(()=>G(i,t.error)),$(a,s)};se(n,a=>{t.error&&a(o)})}$(e,r)}var Sl=k(''),kl=k("
                ");function le(e,t){Ne(t,!0);let r=Qe(t,"type",3,"text"),n=Qe(t,"placeholder",3,""),o=Qe(t,"value",15),a=Qe(t,"error",3,""),s=Qe(t,"required",3,!0),i=Qe(t,"disabled",3,!1),l=Qe(t,"variant",3,"default");const c=te(()=>l()==="nested"?"bg-white":"bg-gray-50");var u=kl(),m=f(u),p=f(m),h=d(p);{var g=x=>{var J=Sl();$(x,J)};se(h,x=>{t.isDirty&&x(g)})}var _=d(m,2),b=d(_,2);{let x=te(()=>a()??"");Or(b,{get error(){return v(x)}})}ae(()=>{qe(m,1,`mb-2 block text-sm text-gray-900 ${s()?"font-bold":""}`),Le(m,"for",t.id),G(p,`${t.label??""} `),Le(_,"id",t.id),qe(_,1,`block w-full rounded-lg border p-2.5 text-sm ${a()?"border-red-500 bg-red-50 text-red-900 placeholder-red-400 focus:border-red-500 focus:ring-red-500":`border-gray-300 ${v(c)} text-gray-900 focus:border-blue-500 focus:ring-blue-500`} ${i()?"cursor-not-allowed opacity-50":""}`),_.disabled=i(),Le(_,"max",t.max),Le(_,"min",t.min),Le(_,"placeholder",n()),Le(_,"step",t.step),Le(_,"type",r())}),Zr(_,o),$(e,u),Te()}var zl=k('

                '),Dl=k('
                '),Al=k('
                ',1);function We(e,t){var r=Al(),n=de(r),o=f(n),a=f(o),s=f(a),i=d(a,2);{var l=g=>{var _=zl(),b=f(_);ae(()=>G(b,t.description)),$(g,_)},c=g=>{var _=Dl();$(g,_)};se(i,g=>{t.description?g(l):g(c,-1)})}var u=d(i,2);Jt(u,()=>t.main);var m=d(o,2);Jt(m,()=>t.sidebar);var p=d(n,2);{var h=g=>{var _=Bt(),b=de(_);Jt(b,()=>t.sourceCode),$(g,_)};se(p,g=>{t.sourceCode&&g(h)})}ae(()=>G(s,t.title)),$(e,r)}var Pl=k('
                '),Cl=k('
                ');function Ke(e,t){let r=we(!1);var n=Cl(),o=f(n),a=d(f(o),2),s=d(o,2);{var i=l=>{var c=Pl(),u=f(c);Jt(u,()=>t.children),$(l,c)};se(s,l=>{v(r)&&l(i)})}ae(()=>{qe(o,1,`flex w-full cursor-pointer items-center justify-between px-4 py-3 text-left text-sm font-medium text-gray-900 hover:bg-gray-50 ${v(r)?"border-b border-gray-200":""}`),qe(a,0,`h-5 w-5 transform transition-transform ${v(r)?"rotate-180":""}`)}),ye("click",o,()=>me(r,!v(r))),$(e,n)}tt(["click"]);var Ol=k('
                ');function He(e,t){var r=Ol(),n=f(r),o=f(n),a=d(n,2),s=f(a);ae(()=>{qe(n,1,`rounded px-2.5 py-0.5 text-xs font-medium ${t.hasErrors?"bg-red-100 text-red-800":"bg-green-100 text-green-800"}`),G(o,t.hasErrors?"Has Errors":"Valid"),qe(a,1,`rounded px-2.5 py-0.5 text-xs font-medium ${t.isDirty?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800"}`),G(s,t.isDirty?"Modified":"Clean")}),$(e,r)}const ce=()=>Math.random().toString(36).slice(2,8),lt=(e,t)=>Math.floor(Math.random()*(t-e+1))+e;var Nl=k('
                '),Tl=k('
                '),Il=k(' Submitting...'),Zl=k('
                ',1),Rl=k('
                Action State
                actionInProgress:
                actionError:
                '),jl=k(" ",1);function Ll(e,t){Ne(t,!0);const r=()=>ee(_,"$hasErrors",i),n=()=>ee(b,"$isDirty",i),o=()=>ee(x,"$actionInProgress",i),a=()=>ee(g,"$errors",i),s=()=>ee(J,"$actionError",i),[i,l]=Ue(),c={title:`Task ${ce()}`,description:`This is a sample task description with ID ${ce()}`};let u=we(!1),m=we(void 0);const{data:p,execute:h,state:{errors:g,hasErrors:_,isDirty:b,actionInProgress:x,actionError:J}}=Be(c,{validator:P=>({title:ie(P.title).prepare("trim").required().minLength(3).maxLength(50).getError(),description:ie(P.description).prepare("trim").required().minLength(10).maxLength(200).getError()}),action:async()=>{const P=lt(100,1e3);if(await new Promise(L=>setTimeout(L,P)),v(u))throw new Error(`Simulated server error after ${P}ms`);me(m,`Submitted successfully in ${P}ms!`)},actionCompleted:P=>{P&&me(m,void 0)}}),A=()=>{p.title=`Task ${ce()}`,p.description=`This is a sample task description with ID ${ce()}`},D=()=>{me(m,void 0),h()},R=`const { data, execute, state: { errors, hasErrors, isDirty, actionInProgress, actionError } } = + createSvState(sourceData, { + validator: (source) => ({ + title: stringValidator(source.title).prepare('trim').required().minLength(3).maxLength(50).getError(), + description: stringValidator(source.description).prepare('trim').required().minLength(10).getError() + }), + action: async () => { + // Simulate API call with 100-1000ms delay + const delay = randomInt(100, 1000); + await new Promise((resolve) => setTimeout(resolve, delay)); + + if (shouldFail) { + throw new Error('Simulated server error'); + } + }, + actionCompleted: (error) => { + // Called after action completes (success or failure) + console.log(error ? 'Action failed' : 'Action succeeded'); + } + });`,H=`// Execute the action + + +// With parameters (if action accepts them) +execute({ userId: 123 });`,T=`// Display action error +{#if $actionError} +
                + {$actionError.message} +
                +{/if} + +// Check if action is in progress +{#if $actionInProgress} +
                Submitting...
                +{/if}`;We(e,{description:"Demonstrates async action execution with loading states and error handling.",title:"Action Demo",main:F=>{var q=Zl(),I=de(q);He(I,{get hasErrors(){return r()},get isDirty(){return n()}});var N=d(I,2),M=f(N),j=f(M),W=d(N,2),K=f(W);{let C=te(()=>a()?.title);le(K,{id:"title",get disabled(){return o()},get error(){return v(C)},label:"Title",placeholder:"Enter task title",get value(){return p.title},set value(ne){p.title=ne}})}var V=d(K,2);{let C=te(()=>a()?.description);le(V,{id:"description",get disabled(){return o()},get error(){return v(C)},label:"Description",placeholder:"Enter task description (min 10 characters)",get value(){return p.description},set value(ne){p.description=ne}})}var w=d(V,2),B=f(w),Y=d(W,2);{var X=C=>{var ne=Nl(),ue=f(ne),fe=d(f(ue),2),Ae=f(fe);ae(()=>G(Ae,s().message)),$(C,ne)};se(Y,C=>{s()&&C(X)})}var Q=d(Y,2);{var U=C=>{var ne=Tl(),ue=f(ne),fe=d(f(ue),2),Ae=f(fe);ae(()=>G(Ae,v(m))),$(C,ne)};se(Q,C=>{v(m)&&C(U)})}var Z=d(Q,2),O=f(Z),re=f(O);{var y=C=>{var ne=Il();$(C,ne)},S=C=>{var ne=Kn("Submit");$(C,ne)};se(re,C=>{o()?C(y):C(S,-1)})}ae(()=>{qe(M,1,`rounded px-2.5 py-0.5 text-xs font-medium ${o()?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`),G(j,o()?"In Progress":"Idle"),B.disabled=o(),O.disabled=r()||o()}),Cr(B,()=>v(u),C=>me(u,C)),ye("click",O,D),$(F,q)},sidebar:F=>{var q=Rl(),I=f(q);Je(I,{get data(){return p},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:A});var N=d(I,2),M=d(f(N),2),j=f(M),W=d(f(j)),K=d(j,2),V=d(f(K));ae(()=>{G(W,` ${o()??""}`),G(V,` ${s()?.message??"none"??""}`)}),$(F,q)},sourceCode:F=>{Ke(F,{children:(q,I)=>{var N=jl(),M=de(N);pe(M,{code:R,title:"State Setup with Action"});var j=d(M,2);pe(j,{code:H,title:"Execute Action"});var W=d(j,2);pe(W,{code:T,title:"Error & Loading States"}),$(q,N)}})}}),Te(),l()}tt(["click"]);var Fl=k('
                ');function Ml(e,t){let r=Qe(t,"label",3,"Item");var n=Fl(),o=f(n),a=f(o),s=f(a),i=d(a,2),l=d(o,2);Jt(l,()=>t.children),ae(()=>G(s,`${r()??""} #${t.index+1}`)),ye("click",i,function(...c){t.onRemove?.apply(this,c)}),$(e,n)}tt(["click"]);var Vl=k('

                ');function ql(e,t){var r=Vl(),n=f(r),o=f(n);ae(()=>G(o,t.message)),$(e,r)}var Ul=k('
                '),Bl=k('
                '),Jl=k('
                '),Wl=k('
                Contacts
                ',1),Kl=k(" ",1);function Hl(e,t){Ne(t,!0);const r=()=>ee(u,"$hasErrors",a),n=()=>ee(m,"$isDirty",a),o=()=>ee(c,"$errors",a),[a,s]=Ue(),i={listName:"",items:[]},{data:l,state:{errors:c,hasErrors:u,isDirty:m}}=Be(i,{validator:x=>({listName:ie(x.listName).prepare("trim").required().minLength(2).getError(),items:_l(x.items).required().minLength(1).getError(),...Object.fromEntries(x.items.map((J,A)=>[`item_${A}`,{name:ie(J.name).prepare("trim").required().minLength(2).getError(),email:ie(J.email).prepare("trim").required().email().getError()}]))})}),p=()=>{l.items=[...l.items,{name:"",email:""}]},h=x=>{l.items=l.items.filter((J,A)=>A!==x)},g=()=>{l.listName=`Contact List ${ce()}`,l.items=[{name:"John Doe",email:"john@example.com"},{name:"Jane Smith",email:"jane@example.com"},{name:"Bob Wilson",email:"bob@example.com"}]},_=`const sourceData = { + listName: '', + items: [] as { name: string; email: string }[] +}; + +const { data, state: { errors, hasErrors, isDirty } } = createSvState(sourceData, { + validator: (source) => ({ + listName: stringValidator(source.listName).prepare('trim').required().minLength(2).getError(), + items: arrayValidator(source.items).required().minLength(1).getError(), + // Per-item validation using indexed keys + ...Object.fromEntries( + source.items.map((item, index) => [ + \`item_\${index}\`, + { + name: stringValidator(item.name).prepare('trim').required().minLength(2).getError(), + email: stringValidator(item.email).prepare('trim').required().email().getError() + } + ]) + ) + }) +});`,b=`// Define type for item errors +type ItemErrors = Record; + +{#each data.items as item, index} + + + + + +{/each}`;We(e,{description:"Shows how to validate dynamic arrays with per-item validation using indexed error keys.",title:"Array Property Demo",main:D=>{var R=Wl(),H=de(R);He(H,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(H,2),P=f(T);{let w=te(()=>o()?.listName);le(P,{id:"listName",get error(){return v(w)},label:"List Name",placeholder:"Enter list name",get value(){return l.listName},set value(B){l.listName=B}})}var L=d(P,2),z=f(L),F=f(z),q=d(f(F)),I=f(q),N=d(F,2),M=d(z,2);{var j=w=>{var B=Ul(),Y=f(B);Or(Y,{get error(){return o().items}}),$(w,B)};se(M,w=>{o()?.items&&w(j)})}var W=d(M,2);{var K=w=>{ql(w,{message:'No contacts yet. Click "Add Contact" to get started.'})},V=w=>{var B=Jl();zt(B,21,()=>l.items,Ir,(Y,X,Q)=>{Ml(Y,{index:Q,label:"Contact",onRemove:()=>h(Q),children:(U,Z)=>{var O=Bl(),re=f(O),y=f(re);Le(y,"for",`item-name-${Q}`);var S=d(y,2);Le(S,"id",`item-name-${Q}`);var C=d(S,2);{let Ee=te(()=>o()?.[`item_${Q}`]?.name??"");Or(C,{get error(){return v(Ee)}})}var ne=d(re,2),ue=f(ne);Le(ue,"for",`item-email-${Q}`);var fe=d(ue,2);Le(fe,"id",`item-email-${Q}`);var Ae=d(fe,2);{let Ee=te(()=>o()?.[`item_${Q}`]?.email??"");Or(Ae,{get error(){return v(Ee)}})}ae(()=>{qe(S,1,`block w-full rounded-lg border p-2 text-sm ${o()?.[`item_${Q}`]?.name?"border-red-500 bg-red-50 text-red-900 placeholder-red-400":"border-gray-300 bg-white text-gray-900"}`),qe(fe,1,`block w-full rounded-lg border p-2 text-sm ${o()?.[`item_${Q}`]?.email?"border-red-500 bg-red-50 text-red-900 placeholder-red-400":"border-gray-300 bg-white text-gray-900"}`)}),Zr(S,()=>v(X).name,Ee=>v(X).name=Ee),Zr(fe,()=>v(X).email,Ee=>v(X).email=Ee),$(U,O)},$$slots:{default:!0}})}),$(w,B)};se(W,w=>{l.items.length===0?w(K):w(V,-1)})}ae(()=>G(I,`${l.items.length??""} items`)),ye("click",N,p),$(D,R)},sidebar:D=>{Je(D,{get data(){return l},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:g,width:"xl:w-96"})},sourceCode:D=>{Ke(D,{children:(R,H)=>{var T=Kl(),P=de(T);pe(P,{code:_,title:"State Setup with Array Item Validation"});var L=d(P,2);pe(L,{code:b,title:"Array Form Binding Examples"}),$(R,T)}})}}),Te(),s()}tt(["click"]);Ws();var Gl=k('
                '),Yl=k('
                '),Xl=k('
                '),Ql=k(' Validating...'),ec=k('
                Taken usernames:
                Taken emails:
                Taken slugs:
                Concurrency limit: maxConcurrentAsyncValidations = 2
                Only 2 async validations run simultaneously. Try filling all 3 fields at once to see queuing in action.
                ',1),tc=k('
                Quick Fill
                Async Validation State
                asyncValidating:
                hasAsyncErrors:
                hasCombinedErrors:
                Async Errors
                 
                '),rc=k(" ",1);function nc(e,t){Ne(t,!1);const r=()=>ee(J,"$hasErrors",c),n=()=>ee(A,"$isDirty",c),o=()=>ee(R,"$hasAsyncErrors",c),a=()=>ee(T,"$hasCombinedErrors",c),s=()=>ee(x,"$errors",c),i=()=>ee(D,"$asyncErrors",c),l=()=>ee(H,"$asyncValidating",c),[c,u]=Ue(),m=["admin","user","test","demo","root"],p=["admin@example.com","test@example.com","user@example.com"],h=["admin","about","contact","help","support"],_=Be({username:"",email:"",slug:""},{validator:I=>({username:ie(I.username).prepare("trim").required().minLength(3).maxLength(20).noSpace().getError(),email:ie(I.email).prepare("trim").required().email().getError(),slug:ie(I.slug).prepare("trim").required().minLength(2).slug().getError()}),asyncValidator:{username:async(I,N,M)=>{await new Promise((W,K)=>{const V=setTimeout(W,500);M.addEventListener("abort",()=>{clearTimeout(V),K(new DOMException("Aborted","AbortError"))})});const j=String(I).toLowerCase();return m.includes(j)?"Username is already taken":""},email:async(I,N,M)=>{await new Promise((W,K)=>{const V=setTimeout(W,400);M.addEventListener("abort",()=>{clearTimeout(V),K(new DOMException("Aborted","AbortError"))})});const j=String(I).toLowerCase();return p.includes(j)?"Email is already registered":""},slug:async(I,N,M)=>{await new Promise((W,K)=>{const V=setTimeout(W,600);M.addEventListener("abort",()=>{clearTimeout(V),K(new DOMException("Aborted","AbortError"))})});const j=String(I).toLowerCase();return h.includes(j)?"URL slug is already in use":""}}},{maxConcurrentAsyncValidations:2}),b=Ln(_.data),x=_.state.errors,J=_.state.hasErrors,A=_.state.isDirty,D=_.state.asyncErrors,R=_.state.hasAsyncErrors,H=_.state.asyncValidating,T=_.state.hasCombinedErrors,P=()=>{xt(b,v(b).username=`newuser${ce()}`),xt(b,v(b).email=`${ce()}@example.com`),xt(b,v(b).slug=`my-page-${ce()}`)},L=()=>{xt(b,v(b).username="admin"),xt(b,v(b).email="admin@example.com"),xt(b,v(b).slug="about")},z=`const { data, state: { errors, asyncErrors, asyncValidating, hasCombinedErrors } } = + createSvState(sourceData, { + validator: (source) => ({ + username: stringValidator(source.username).required().minLength(3).noSpace().getError(), + email: stringValidator(source.email).required().email().getError(), + slug: stringValidator(source.slug).required().minLength(2).slug().getError() + }), + asyncValidator: { + username: async (value, source, signal) => { + const res = await fetch(\`/api/check-username?u=\${value}\`, { signal }); + return (await res.json()).available ? '' : 'Username already taken'; + }, + email: async (value, source, signal) => { + const res = await fetch(\`/api/check-email?e=\${value}\`, { signal }); + return (await res.json()).available ? '' : 'Email already registered'; + }, + slug: async (value, source, signal) => { + const res = await fetch(\`/api/check-slug?s=\${value}\`, { signal }); + return (await res.json()).available ? '' : 'URL slug already in use'; + } + } + }, + { maxConcurrentAsyncValidations: 2 } // Only 2 async validations run at a time +);`,F=` +{#if $asyncValidating.includes('username')} + ... +{/if} + + +{#if $asyncErrors.username} + {$asyncErrors.username} +{/if} + + +`,q=`// Available stores for async validation: +$errors // Sync validation errors (nested object) +$hasErrors // true if any sync errors + +$asyncErrors // Async validation errors (flat map by path) +$hasAsyncErrors // true if any async errors + +$asyncValidating // Array of paths currently being validated +$hasCombinedErrors // hasErrors || hasAsyncErrors`;Ki(),We(e,{description:"Demonstrates async validation with simulated API calls for username and email uniqueness checks.",title:"Async Validation Demo",main:j=>{var W=ec(),K=de(W);He(K,{get hasErrors(){return r()},get isDirty(){return n()}});var V=d(K,2),w=f(V),B=f(w),Y=d(w,2),X=f(Y),Q=d(V,2),U=f(Q),Z=f(U);{let xe=ur(()=>s()?.username||i().username);le(Z,{id:"username",get error(){return v(xe)},label:"Username",placeholder:"Enter username (try 'admin', 'user', 'test')",get value(){return v(b).username},set value(Re){xt(b,v(b).username=Re)},$$legacy:!0})}var O=d(Z,2);{var re=xe=>{var Re=Gl();$(xe,Re)},y=te(()=>l().includes("username"));se(O,xe=>{v(y)&&xe(re)})}var S=d(U,2),C=f(S);{let xe=ur(()=>s()?.email||i().email);le(C,{id:"email",get error(){return v(xe)},label:"Email",placeholder:"Enter email (try 'admin@example.com')",type:"email",get value(){return v(b).email},set value(Re){xt(b,v(b).email=Re)},$$legacy:!0})}var ne=d(C,2);{var ue=xe=>{var Re=Yl();$(xe,Re)},fe=te(()=>l().includes("email"));se(ne,xe=>{v(fe)&&xe(ue)})}var Ae=d(S,2),Ee=f(Ae);{let xe=ur(()=>s()?.slug||i().slug);le(Ee,{id:"slug",get error(){return v(xe)},label:"URL Slug",placeholder:"Enter slug (try 'admin', 'about', 'contact')",get value(){return v(b).slug},set value(Re){xt(b,v(b).slug=Re)},$$legacy:!0})}var Pe=d(Ee,2);{var Ge=xe=>{var Re=Xl();$(xe,Re)},xr=te(()=>l().includes("slug"));se(Pe,xe=>{v(xr)&&xe(Ge)})}var be=d(Q,2),Ce=f(be),Lt=d(f(Ce)),Dt=d(Ce,2),wr=d(f(Dt)),is=d(Dt,2),ls=d(f(is)),cs=d(be,4),no=f(cs),us=f(no);{var ds=xe=>{var Re=Ql();$(xe,Re)},fs=xe=>{var Re=Kn("Submit");$(xe,Re)};se(us,xe=>{l().length>0?xe(ds):xe(fs,-1)})}ae((xe,Re,ps)=>{qe(w,1,`rounded px-2.5 py-0.5 text-xs font-medium ${o()?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`),G(B,`Async Errors: ${o()?"Yes":"No"}`),qe(Y,1,`rounded px-2.5 py-0.5 text-xs font-medium ${a()?"bg-red-100 text-red-800":"bg-green-100 text-green-800"}`),G(X,`Combined: ${a()?"Has Errors":"Valid"}`),G(Lt,` ${xe??""}`),G(wr,` ${Re??""}`),G(ls,` ${ps??""}`),no.disabled=a()||l().length>0},[()=>m.join(", "),()=>p.join(", "),()=>h.join(", ")]),$(j,W)},sidebar:j=>{var W=tc(),K=f(W);Je(K,{get data(){return v(b)},get errors(){return s()},get hasErrors(){return r()},get isDirty(){return n()},onFill:P});var V=d(K,2),w=d(f(V),2),B=d(V,2),Y=d(f(B),2),X=f(Y),Q=d(f(X)),U=d(X,2),Z=d(f(U)),O=d(U,2),re=d(f(O)),y=d(B,2),S=d(f(y),2),C=f(S);ae((ne,ue)=>{G(Q,` [${ne??""}]`),G(Z,` ${o()??""}`),G(re,` ${a()??""}`),G(C,ue)},[()=>l().join(", "),()=>JSON.stringify(i(),void 0,2)]),ye("click",w,L),$(j,W)},sourceCode:j=>{Ke(j,{children:(W,K)=>{var V=rc(),w=de(V);pe(w,{code:z,title:"State Setup with Async Validators"});var B=d(w,2);pe(B,{code:F,title:"Template Usage"});var Y=d(B,2);pe(Y,{code:q,title:"Available Stores"}),$(W,V)}})}}),Te(),u()}tt(["click"]);var oc=k(''),ac=k("
                ");function rr(e,t){Ne(t,!0);let r=Qe(t,"placeholder",3,""),n=Qe(t,"value",15),o=Qe(t,"error",3,""),a=Qe(t,"required",3,!1),s=Qe(t,"rows",3,3);var i=ac(),l=f(i),c=f(l),u=d(c);{var m=g=>{var _=oc();$(g,_)};se(u,g=>{t.isDirty&&g(m)})}var p=d(l,2),h=d(p,2);{let g=te(()=>o()??"");Or(h,{get error(){return v(g)}})}ae(()=>{qe(l,1,`mb-2 block text-sm text-gray-900 ${a()?"font-bold":""}`),Le(l,"for",t.id),G(c,`${t.label??""} `),Le(p,"id",t.id),qe(p,1,`block w-full rounded-lg border p-2.5 text-sm ${o()?"border-red-500 bg-red-50 text-red-900 placeholder-red-400 focus:border-red-500 focus:ring-red-500":"border-gray-300 bg-gray-50 text-gray-900 focus:border-blue-500 focus:ring-blue-500"}`),Le(p,"placeholder",r()),Le(p,"rows",s())}),Zr(p,n),$(e,i),Te()}var sc=k('
                ',1),ic=k(" ",1);function lc(e,t){Ne(t,!0);const r=()=>ee(m,"$hasErrors",s),n=()=>ee(p,"$isDirty",s),o=()=>ee(u,"$errors",s),a=()=>ee(h,"$isDirtyByField",s),[s,i]=Ue(),l={username:"",email:"",age:0,bio:"",website:""},{data:c,state:{errors:u,hasErrors:m,isDirty:p,isDirtyByField:h}}=Be(l,{validator:x=>({username:ie(x.username).prepare("trim").required().minLength(3).maxLength(20).noSpace().getError(),email:ie(x.email).prepare("trim").required().email().getError(),age:Rr(x.age).required().min(18).max(120).integer().getError(),bio:ie(x.bio).maxLength(200).getError(),website:ie(x.website).prepare("trim").website("required").getError()})}),g=()=>{c.username=`user${ce()}`,c.email=`${ce()}@example.com`,c.age=lt(18,65),c.bio="Hello, I am a demo user!",c.website=`https://${ce()}.com`},_=`const sourceData = { + username: '', + email: '', + age: 0, + bio: '', + website: '' +}; + +const { data, state: { errors, hasErrors, isDirty, isDirtyByField } } = createSvState(sourceData, { + validator: (source) => ({ + username: stringValidator(source.username).prepare('trim').required().minLength(3).maxLength(20).noSpace().getError(), + email: stringValidator(source.email).prepare('trim').required().email().getError(), + age: numberValidator(source.age).required().min(18).max(120).integer().getError(), + bio: stringValidator(source.bio).maxLength(200).getError(), + website: stringValidator(source.website).prepare('trim').website('required').getError() + }) +});`,b=` +`;We(e,{description:"Demonstrates form validation with string, number, and email validators using the fluent API.",title:"Basic Validation Demo",main:D=>{var R=sc(),H=de(R);He(H,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(H,2),P=f(T);{let I=te(()=>o()?.username);le(P,{id:"username",get error(){return v(I)},get isDirty(){return a().username},label:"Username",placeholder:"Enter username",get value(){return c.username},set value(N){c.username=N}})}var L=d(P,2);{let I=te(()=>o()?.email);le(L,{id:"email",get error(){return v(I)},get isDirty(){return a().email},label:"Email",placeholder:"Enter email",type:"email",get value(){return c.email},set value(N){c.email=N}})}var z=d(L,2);{let I=te(()=>o()?.age);le(z,{id:"age",get error(){return v(I)},get isDirty(){return a().age},label:"Age",placeholder:"Enter age",type:"number",get value(){return c.age},set value(N){c.age=N}})}var F=d(z,2);{let I=te(()=>o()?.bio);rr(F,{id:"bio",get error(){return v(I)},get isDirty(){return a().bio},label:"Bio",placeholder:"Tell us about yourself",get value(){return c.bio},set value(N){c.bio=N}})}var q=d(F,2);{let I=te(()=>o()?.website);le(q,{id:"website",get error(){return v(I)},get isDirty(){return a().website},label:"Website",placeholder:"https://example.com",required:!1,get value(){return c.website},set value(N){c.website=N}})}$(D,R)},sidebar:D=>{Je(D,{get data(){return c},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},get isDirtyByField(){return a()},onFill:g})},sourceCode:D=>{Ke(D,{children:(R,H)=>{var T=ic(),P=de(T);pe(P,{code:_,title:"State Setup"});var L=d(P,2);pe(L,{code:b,title:"Form Binding Example"}),$(R,T)}})}}),Te(),i()}var cc=k(' '),uc=k('
                ');function Wt(e,t){var r=uc(),n=f(r),o=d(n);{var a=l=>{var c=cc(),u=f(c);ae(()=>G(u,`(${t.subtitle??""})`)),$(l,c)};se(o,l=>{t.subtitle&&l(a)})}var s=d(o,2);{var i=l=>{var c=Bt(),u=de(c);Jt(u,()=>t.children),$(l,c)};se(s,l=>{t.children&&l(i)})}ae(()=>G(n,`${t.title??""} `)),$(e,r)}var dc=k('
                Subtotal:
                Tax (8%):
                Total:

                Values formatted using methods on state: data.formatCurrency() and data.formatTotal()

                ',1),fc=k(" ",1);function pc(e,t){Ne(t,!0);const r=()=>ee(m,"$hasErrors",a),n=()=>ee(p,"$isDirty",a),o=()=>ee(u,"$errors",a),[a,s]=Ue(),i=.08,l=()=>({productName:`Widget ${ce()}`,item:{unitPrice:0,quantity:1},subtotal:0,tax:0,total:0,formatTotal(){return`$${this.total.toFixed(2)}`},formatCurrency(x){return`$${x.toFixed(2)}`},calculateTotals(x=i){this.subtotal=this.item.unitPrice*this.item.quantity,this.tax=this.subtotal*x,this.total=this.subtotal+this.tax}}),{data:c,state:{errors:u,hasErrors:m,isDirty:p}}=Be(l(),{validator:x=>({productName:ie(x.productName).prepare("trim").required().minLength(2).getError(),item:{unitPrice:Rr(x.item.unitPrice).required().positive().getError(),quantity:Rr(x.item.quantity).required().integer().min(1).max(100).getError()}}),effect:({property:x})=>{(x==="item.unitPrice"||x==="item.quantity")&&c.calculateTotals()}}),h=()=>{c.productName=`Widget ${ce()}`,c.item.unitPrice=lt(10,100),c.item.quantity=lt(1,10)},g=`// Define state type with methods +type SourceData = { + productName: string; + item: { unitPrice: number; quantity: number }; + subtotal: number; + tax: number; + total: number; + formatTotal: () => string; + formatCurrency: (value: number) => string; + calculateTotals: (taxRate?: number) => void; +}; + +// Create initial state as object with methods +const createSourceData = (): SourceData => ({ + productName: '', + item: { unitPrice: 0, quantity: 1 }, + subtotal: 0, + tax: 0, + total: 0, + formatTotal() { + return \`$\${this.total.toFixed(2)}\`; + }, + formatCurrency(value: number) { + return \`$\${value.toFixed(2)}\`; + }, + calculateTotals(taxRate: number = 0.08) { + this.subtotal = this.item.unitPrice * this.item.quantity; + this.tax = this.subtotal * taxRate; + this.total = this.subtotal + this.tax; + } +});`,_=`const { data, state: { errors, hasErrors, isDirty } } = createSvState(createSourceData(), { + validator: (source) => ({ + productName: stringValidator(source.productName).prepare('trim').required().minLength(2).getError(), + item: { + unitPrice: numberValidator(source.item.unitPrice).required().positive().getError(), + quantity: numberValidator(source.item.quantity).required().integer().min(1).max(100).getError() + } + }), + effect: ({ property }) => { + if (property === 'item.unitPrice' || property === 'item.quantity') { + data.calculateTotals(); // Call method on state object! + } + } +});`,b=` +{data.formatCurrency(data.subtotal)} +{data.formatTotal()}`;We(e,{description:"Demonstrates using objects with methods as state. The effect callback can call methods directly on the state object.",title:"State with Methods Demo",main:D=>{var R=dc(),H=de(R);He(H,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(H,2),P=f(T);{let O=te(()=>o()?.productName);le(P,{id:"productName",get error(){return v(O)},label:"Product Name",placeholder:"Enter product name",get value(){return c.productName},set value(re){c.productName=re}})}var L=d(P,2),z=f(L);Wt(z,{subtitle:"nested object",title:"Item Details"});var F=d(z,2),q=f(F);{let O=te(()=>o()?.item?.unitPrice);le(q,{id:"unitPrice",get error(){return v(O)},label:"Unit Price ($)",min:0,placeholder:"0.00",step:.01,type:"number",get value(){return c.item.unitPrice},set value(re){c.item.unitPrice=re}})}var I=d(q,2);{let O=te(()=>o()?.item?.quantity);le(I,{id:"quantity",get error(){return v(O)},label:"Quantity",max:100,min:1,placeholder:"1",type:"number",get value(){return c.item.quantity},set value(re){c.item.quantity=re}})}var N=d(L,2),M=f(N);Wt(M,{subtitle:"computed by method",title:"Calculated Totals"});var j=d(M,2),W=f(j),K=f(W),V=d(f(K),2),w=f(V),B=d(K,2),Y=d(f(B),2),X=f(Y),Q=d(B,2),U=d(f(Q),2),Z=f(U);ae((O,re,y)=>{G(w,O),G(X,re),G(Z,y)},[()=>c.formatCurrency(c.subtotal),()=>c.formatCurrency(c.tax),()=>c.formatTotal()]),$(D,R)},sidebar:D=>{Je(D,{get data(){return c},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:h})},sourceCode:D=>{Ke(D,{children:(R,H)=>{var T=fc(),P=de(T);pe(P,{code:g,title:"Class Definition"});var L=d(P,2);pe(L,{code:_,title:"State Setup with Class Instance"});var z=d(L,2);pe(z,{code:b,title:"Template Usage"}),$(R,T)}})}}),Te(),s()}var vc=k('
                Subtotal:
                Tax (8%):
                Total:
                ',1),mc=k(" ",1);function hc(e,t){Ne(t,!0);const r=()=>ee(m,"$hasErrors",a),n=()=>ee(p,"$isDirty",a),o=()=>ee(u,"$errors",a),[a,s]=Ue(),i=.08,l={productName:`Widget ${ce()}`,item:{unitPrice:0,quantity:1},subtotal:0,tax:0,total:0},{data:c,state:{errors:u,hasErrors:m,isDirty:p}}=Be(l,{validator:x=>({productName:ie(x.productName).prepare("trim").required().minLength(2).getError(),item:{unitPrice:Rr(x.item.unitPrice).required().positive().getError(),quantity:Rr(x.item.quantity).required().integer().min(1).max(100).getError()}}),effect:({property:x})=>{(x==="item.unitPrice"||x==="item.quantity")&&(c.subtotal=c.item.unitPrice*c.item.quantity,c.tax=c.subtotal*i,c.total=c.subtotal+c.tax)}}),h=()=>{c.productName=`Widget ${ce()}`,c.item.unitPrice=lt(10,100),c.item.quantity=lt(1,10)},g=x=>`$${x.toFixed(2)}`,_=`const sourceData = { + productName: '', + item: { unitPrice: 0, quantity: 1 }, + subtotal: 0, tax: 0, total: 0 // Calculated fields (set by effect) +}; + +const TAX_RATE = 0.08; + +const { data, state: { errors, hasErrors, isDirty } } = createSvState(sourceData, { + validator: (source) => ({ + productName: stringValidator(source.productName).prepare('trim').required().minLength(2).getError(), + item: { + unitPrice: numberValidator(source.item.unitPrice).required().positive().getError(), + quantity: numberValidator(source.item.quantity).required().integer().min(1).max(100).getError() + } + }), + effect: ({ property }) => { + if (property === 'item.unitPrice' || property === 'item.quantity') { + data.subtotal = data.item.unitPrice * data.item.quantity; + data.tax = data.subtotal * TAX_RATE; + data.total = data.subtotal + data.tax; + } + } +});`,b=`effect: ({ property }) => { + if (property === 'item.unitPrice' || property === 'item.quantity') { + data.subtotal = data.item.unitPrice * data.item.quantity; + data.tax = data.subtotal * TAX_RATE; + data.total = data.subtotal + data.tax; + } +}`;We(e,{description:"Uses the effect callback to automatically compute derived values like subtotals, taxes, and totals.",title:"Calculated Fields Demo",main:D=>{var R=vc(),H=de(R);He(H,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(H,2),P=f(T);{let O=te(()=>o()?.productName);le(P,{id:"productName",get error(){return v(O)},label:"Product Name",placeholder:"Enter product name",get value(){return c.productName},set value(re){c.productName=re}})}var L=d(P,2),z=f(L);Wt(z,{subtitle:"nested object",title:"Item Details"});var F=d(z,2),q=f(F);{let O=te(()=>o()?.item?.unitPrice);le(q,{id:"unitPrice",get error(){return v(O)},label:"Unit Price ($)",min:0,placeholder:"0.00",step:.01,type:"number",get value(){return c.item.unitPrice},set value(re){c.item.unitPrice=re}})}var I=d(q,2);{let O=te(()=>o()?.item?.quantity);le(I,{id:"quantity",get error(){return v(O)},label:"Quantity",max:100,min:1,placeholder:"1",type:"number",get value(){return c.item.quantity},set value(re){c.item.quantity=re}})}var N=d(L,2),M=f(N);Wt(M,{subtitle:"computed by effect",title:"Calculated Totals"});var j=d(M,2),W=f(j),K=f(W),V=d(f(K),2),w=f(V),B=d(K,2),Y=d(f(B),2),X=f(Y),Q=d(B,2),U=d(f(Q),2),Z=f(U);ae((O,re,y)=>{G(w,O),G(X,re),G(Z,y)},[()=>g(c.subtotal),()=>g(c.tax),()=>g(c.total)]),$(D,R)},sidebar:D=>{Je(D,{get data(){return c},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:h})},sourceCode:D=>{Ke(D,{children:(R,H)=>{var T=mc(),P=de(T);pe(P,{code:_,title:"State Setup with Effect"});var L=d(P,2);pe(L,{code:b,title:"Effect Function"}),$(R,T)}})}}),Te(),s()}var gc=k(' '),bc=k(''),_c=k('
                ');function yc(e,t){var r=_c(),n=f(r),o=f(n),a=d(o);{var s=u=>{var m=gc(),p=f(m);ae(()=>G(p,`(${t.subtitle??""})`)),$(u,m)};se(a,u=>{t.subtitle&&u(s)})}var i=d(a,2);{var l=u=>{var m=bc();$(u,m)};se(i,u=>{t.isDirty&&u(l)})}var c=d(n,2);Jt(c,()=>t.children),ae(()=>G(o,`${t.title??""} `)),$(e,r)}var xc=k(''),wc=k(''),$c=k(''),Ec=k('
                '),Sc=k('
                ',1),kc=k(" ",1);function zc(e,t){Ne(t,!0);const r=()=>ee(m,"$hasErrors",s),n=()=>ee(p,"$isDirty",s),o=()=>ee(h,"$isDirtyByField",s),a=()=>ee(u,"$errors",s),[s,i]=Ue(),l={name:"",address:{street:"",city:"",zip:""},company:{name:"",department:"",contact:{phone:"",email:""}}},{data:c,state:{errors:u,hasErrors:m,isDirty:p,isDirtyByField:h}}=Be(l,{validator:x=>({name:ie(x.name).prepare("trim").required().minLength(2).maxLength(50).getError(),address:{street:ie(x.address.street).prepare("trim").required().minLength(5).getError(),city:ie(x.address.city).prepare("trim").required().minLength(2).getError(),zip:ie(x.address.zip).prepare("trim").required().minLength(5).maxLength(10).getError()},company:{name:ie(x.company.name).prepare("trim").required().minLength(2).getError(),department:ie(x.company.department).prepare("trim").maxLength(50).getError(),contact:{phone:ie(x.company.contact.phone).prepare("trim").required().minLength(10).getError(),email:ie(x.company.contact.email).prepare("trim").required().email().getError()}}})}),g=()=>{c.name=`John ${ce()}`,c.address.street=`${lt(100,9999)} Main Street`,c.address.city="New York",c.address.zip=`${lt(1e4,99999)}`,c.company.name=`Acme ${ce()} Inc`,c.company.department="Engineering",c.company.contact.phone=`555-${lt(100,999)}-${lt(1e3,9999)}`,c.company.contact.email=`contact@${ce()}.com`},_=`const sourceData = { + name: '', + address: { street: '', city: '', zip: '' }, // 2-level nested + company: { // 3-level nested + name: '', + department: '', + contact: { phone: '', email: '' } + } +}; + +const { data, state: { errors, hasErrors, isDirty, isDirtyByField } } = createSvState(sourceData, { + validator: (source) => ({ + name: stringValidator(source.name).prepare('trim').required().minLength(2).maxLength(50).getError(), + address: { + street: stringValidator(source.address.street).prepare('trim').required().minLength(5).getError(), + city: stringValidator(source.address.city).prepare('trim').required().minLength(2).getError(), + zip: stringValidator(source.address.zip).prepare('trim').required().minLength(5).maxLength(10).getError() + }, + company: { + name: stringValidator(source.company.name).prepare('trim').required().minLength(2).getError(), + department: stringValidator(source.company.department).prepare('trim').maxLength(50).getError(), + contact: { + phone: stringValidator(source.company.contact.phone).prepare('trim').required().minLength(10).getError(), + email: stringValidator(source.company.contact.email).prepare('trim').required().email().getError() + } + } + }) +});`,b=` + + + + + +`;We(e,{description:"Illustrates validating deeply nested object structures with multi-level property paths.",title:"Nested Objects Demo",main:D=>{var R=Sc(),H=de(R);He(H,{get hasErrors(){return r()},get isDirty(){return n()}});var T=d(H,2),P=f(T),L=f(P);Wt(L,{title:"Personal Info",children:(U,Z)=>{var O=Bt(),re=de(O);{var y=S=>{var C=xc();$(S,C)};se(re,S=>{o().name&&S(y)})}$(U,O)}});var z=d(L,2);{let U=te(()=>a()?.name);le(z,{id:"name",get error(){return v(U)},label:"Full Name",placeholder:"Enter your full name",get value(){return c.name},set value(Z){c.name=Z}})}var F=d(P,2),q=f(F);Wt(q,{subtitle:"2-level nested",title:"Address",children:(U,Z)=>{var O=Bt(),re=de(O);{var y=S=>{var C=wc();$(S,C)};se(re,S=>{o().address&&S(y)})}$(U,O)}});var I=d(q,2),N=f(I);{let U=te(()=>a()?.address?.street);le(N,{id:"street",get error(){return v(U)},label:"Street",placeholder:"Enter street address",get value(){return c.address.street},set value(Z){c.address.street=Z}})}var M=d(N,2),j=f(M);{let U=te(()=>a()?.address?.city);le(j,{id:"city",get error(){return v(U)},label:"City",placeholder:"Enter city",get value(){return c.address.city},set value(Z){c.address.city=Z}})}var W=d(j,2);{let U=te(()=>a()?.address?.zip);le(W,{id:"zip",get error(){return v(U)},label:"ZIP Code",placeholder:"Enter ZIP",get value(){return c.address.zip},set value(Z){c.address.zip=Z}})}var K=d(F,2),V=f(K);Wt(V,{subtitle:"3-level nested",title:"Company",children:(U,Z)=>{var O=Bt(),re=de(O);{var y=S=>{var C=$c();$(S,C)};se(re,S=>{o().company&&S(y)})}$(U,O)}});var w=d(V,2),B=f(w),Y=f(B);{let U=te(()=>a()?.company?.name);le(Y,{id:"company-name",get error(){return v(U)},label:"Company Name",placeholder:"Enter company name",get value(){return c.company.name},set value(Z){c.company.name=Z}})}var X=d(Y,2);{let U=te(()=>a()?.company?.department);le(X,{id:"department",get error(){return v(U)},label:"Department",placeholder:"Enter department",required:!1,get value(){return c.company.department},set value(Z){c.company.department=Z}})}var Q=d(B,2);yc(Q,{get isDirty(){return o()["company.contact"]},subtitle:"3rd level",title:"Contact Info",children:(U,Z)=>{var O=Ec(),re=f(O);{let S=te(()=>a()?.company?.contact?.phone);le(re,{id:"contact-phone",get error(){return v(S)},label:"Phone",placeholder:"Enter phone number",variant:"nested",get value(){return c.company.contact.phone},set value(C){c.company.contact.phone=C}})}var y=d(re,2);{let S=te(()=>a()?.company?.contact?.email);le(y,{id:"contact-email",get error(){return v(S)},label:"Email",placeholder:"Enter email address",type:"email",variant:"nested",get value(){return c.company.contact.email},set value(C){c.company.contact.email=C}})}$(U,O)}}),$(D,R)},sidebar:D=>{Je(D,{get data(){return c},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},get isDirtyByField(){return o()},onFill:g,width:"xl:w-96"})},sourceCode:D=>{Ke(D,{children:(R,H)=>{var T=kc(),P=de(T);pe(P,{code:_,title:"State Setup with Nested Validation"});var L=d(P,2);pe(L,{code:b,title:"Nested Form Binding Examples"}),$(R,T)}})}}),Te(),i()}var Dc=k('
                Effect triggered:
                '),Ac=k('
                '),Pc=k('
                '),Cc=k(' Submitting...'),Oc=k('
                ',1),Nc=k('
                Options

                Reset isDirty after successful action

                Try 500ms and type quickly

                Keep errors until next action

                Current Options
                '),Tc=k(" ",1);function Ic(e,t){Ne(t,!0);const r=()=>ee(v(R),"$hasErrors",i),n=()=>ee(v(H),"$isDirty",i),o=()=>ee(v(T),"$actionInProgress",i),a=()=>ee(v(D),"$errors",i),s=()=>ee(v(P),"$actionError",i),[i,l]=Ue();let c=we(!0),u=we(0),m=we(!1),p=we(0),h=we(!1),g=we(void 0),_=we(void 0);const b=()=>({name:`User ${ce()}`,email:`${ce()}@example.com`}),x=M=>Be(b(),{validator:j=>({name:ie(j.name).prepare("trim").required().minLength(2).maxLength(50).getError(),email:ie(j.email).prepare("trim").required().email().getError()}),effect:({property:j})=>{me(_,j,!0)},action:async()=>{const j=lt(100,800);if(await new Promise(W=>setTimeout(W,j)),v(h))throw new Error(`Simulated error after ${j}ms`);me(g,`Submitted successfully in ${j}ms!`)},actionCompleted:j=>{j&&me(g,void 0)}},M);let J=we(it(x({resetDirtyOnAction:!0,debounceValidation:0,persistActionError:!1})));const A=()=>{me(_,void 0),me(g,void 0),me(J,x({resetDirtyOnAction:v(c),debounceValidation:v(u),persistActionError:v(m)}),!0),fi(p)},D=te(()=>v(J).state.errors),R=te(()=>v(J).state.hasErrors),H=te(()=>v(J).state.isDirty),T=te(()=>v(J).state.actionInProgress),P=te(()=>v(J).state.actionError),L=()=>{v(J).data.name=`User ${ce()}`,v(J).data.email=`${ce()}@example.com`},z=()=>{me(g,void 0),v(J).execute()},F=`const { data, execute, state } = createSvState( + sourceData, + { validator, effect, action }, + { + // Reset isDirty to false after successful action + resetDirtyOnAction: true, // default: true + + // Debounce validation by N milliseconds + debounceValidation: 0, // default: 0 (uses queueMicrotask) + + // Keep action errors until next action (not cleared on data change) + persistActionError: false // default: false + } +);`,q=`// With resetDirtyOnAction: true (default) +await execute(); +// isDirty is now false + +// With resetDirtyOnAction: false +await execute(); +// isDirty remains true`,I=`// With debounceValidation: 0 (default) +// Validation runs via queueMicrotask after each change + +// With debounceValidation: 500 +// Validation runs 500ms after the last change +// Useful for expensive validators or rapid typing`,N=`// With persistActionError: false (default) +data.name = 'new value'; +// actionError is cleared immediately + +// With persistActionError: true +data.name = 'new value'; +// actionError remains until next execute() call`;We(e,{description:"Interactive playground for configuring createSvState options like debouncing and error persistence.",title:"Options Demo",main:K=>{var V=Bt(),w=de(V);ji(w,()=>v(p),B=>{var Y=Oc(),X=de(Y);He(X,{get hasErrors(){return r()},get isDirty(){return n()}});var Q=d(X,2);{var U=be=>{var Ce=Dc(),Lt=f(Ce),Dt=d(f(Lt));ae(()=>G(Dt,` property "${v(_)??""}" changed`)),$(be,Ce)};se(Q,be=>{v(_)&&be(U)})}var Z=d(Q,2),O=f(Z);{let be=te(()=>a()?.name);le(O,{id:"name",get disabled(){return o()},get error(){return v(be)},label:"Name",placeholder:"Enter name",get value(){return v(J).data.name},set value(Ce){v(J).data.name=Ce}})}var re=d(O,2);{let be=te(()=>a()?.email);le(re,{id:"email",get disabled(){return o()},get error(){return v(be)},label:"Email",placeholder:"Enter email",type:"email",get value(){return v(J).data.email},set value(Ce){v(J).data.email=Ce}})}var y=d(re,2),S=f(y),C=d(Z,2);{var ne=be=>{var Ce=Ac(),Lt=f(Ce),Dt=d(f(Lt),2),wr=f(Dt);ae(()=>G(wr,s().message)),$(be,Ce)};se(C,be=>{s()&&be(ne)})}var ue=d(C,2);{var fe=be=>{var Ce=Pc(),Lt=f(Ce),Dt=d(f(Lt),2),wr=f(Dt);ae(()=>G(wr,v(g))),$(be,Ce)};se(ue,be=>{v(g)&&be(fe)})}var Ae=d(ue,2),Ee=f(Ae),Pe=f(Ee);{var Ge=be=>{var Ce=Cc();$(be,Ce)},xr=be=>{var Ce=Kn("Submit");$(be,Ce)};se(Pe,be=>{o()?be(Ge):be(xr,-1)})}ae(()=>{S.disabled=o(),Ee.disabled=r()||o()}),Cr(S,()=>v(h),be=>me(h,be)),ye("click",Ee,z),$(B,Y)}),$(K,V)},sidebar:K=>{var V=Nc(),w=f(V);Je(w,{get data(){return v(J).data},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:L});var B=d(w,2),Y=d(f(B),2),X=f(Y),Q=f(X),U=f(Q),Z=d(X,2),O=d(f(Z),2),re=d(Z,2),y=f(re),S=f(y),C=d(re,2),ne=d(B,2),ue=d(f(ne),2),fe=f(ue),Ae=f(fe),Ee=d(fe,2),Pe=f(Ee),Ge=d(Ee,2),xr=f(Ge);ae(()=>{G(Ae,`resetDirtyOnAction: ${v(c)??""}`),G(Pe,`debounceValidation: ${v(u)??""}`),G(xr,`persistActionError: ${v(m)??""}`)}),Cr(U,()=>v(c),be=>me(c,be)),Zr(O,()=>v(u),be=>me(u,be)),Cr(S,()=>v(m),be=>me(m,be)),ye("click",C,A),$(K,V)},sourceCode:K=>{Ke(K,{children:(V,w)=>{var B=Tc(),Y=de(B);pe(Y,{code:F,title:"Options Overview"});var X=d(Y,2);pe(X,{code:q,title:"resetDirtyOnAction"});var Q=d(X,2);pe(Q,{code:I,title:"debounceValidation"});var U=d(Q,2);pe(U,{code:N,title:"persistActionError"}),$(V,B)}})}}),Te(),l()}tt(["click"]);var Zc=k('Saving...'),Rc=k(''),jc=k(`
                Auto-save triggers 2 seconds after the last change. Analytics events buffer and flush at 10 events or every 10 + seconds.
                `,1),Lc=k('

                No saves yet — edit the form and wait 2s

                '),Fc=k('
              • save
              • '),Mc=k('
                  '),Vc=k('

                  No flushes yet

                  '),qc=k('
                • flush
                • '),Uc=k('
                    '),Bc=k('
                    Autosave Log
                    Analytics Buffer
                    Buffered:
                    Batch size: 10
                    Flush interval: 10s
                    Tracked: change, action, snapshot
                    Flush History
                    '),Jc=k(" ",1);function Wc(e,t){Ne(t,!0);const r=()=>ee(x,"$hasErrors",s),n=()=>ee(J,"$isDirty",s),o=()=>ee(b,"$errors",s),a=()=>ee(A,"$actionInProgress",s),[s,i]=Ue();let l=we(it([])),c=we(it([])),u=we(0);const m=Yi({save:async T=>{await new Promise(L=>setTimeout(L,300));const P=new Date().toISOString().slice(11,23);me(l,[...v(l),{id:ce(),timestamp:P,data:`${T.title} (${T.category})`}],!0)},idle:2e3,onlyWhenDirty:!0}),p=Gi({onFlush:T=>{const P=new Date().toISOString().slice(11,23),L={};for(const F of T)L[F.type]=(L[F.type]??0)+1;const z=Object.entries(L).map(([F,q])=>`${F}:${q}`).join(", ");me(c,[...v(c),{id:ce(),timestamp:P,eventCount:T.length,types:z}],!0)},batchSize:10,flushInterval:1e4,include:["change","action","snapshot"]}),{data:h,execute:g,reset:_,state:{errors:b,hasErrors:x,isDirty:J,actionInProgress:A}}=Be({title:"",category:"general",notes:""},{validator:T=>({title:ie(T.title).prepare("trim").required().minLength(2).maxLength(100).getError(),category:"",notes:ie(T.notes).maxLength(500).getError()}),effect:({snapshot:T,property:P})=>{const L=P.charAt(0).toUpperCase()+P.slice(1);T(`Changed ${L}`)},action:async()=>{await new Promise(T=>setTimeout(T,500))}},{plugins:[m,p]}),D=()=>{h.title=`Article ${ce()}`,h.category="tech",h.notes="Some interesting notes about the topic that should pass validation."};Nr(()=>{const T=setInterval(()=>{me(u,p.eventCount(),!0)},500);return()=>clearInterval(T)});const R=`import { createSvState, autosavePlugin, analyticsPlugin } from 'svstate'; + +const autosave = autosavePlugin({ + save: async (data) => { + await fetch('/api/save', { + method: 'POST', + body: JSON.stringify(data) + }); + }, + idle: 2000, // Save 2s after last change + onlyWhenDirty: true // Skip save if nothing changed +}); + +const analytics = analyticsPlugin({ + onFlush: (events) => { + sendToAnalytics(events); // Your analytics endpoint + }, + batchSize: 10, // Flush after 10 events + flushInterval: 10000, // Or every 10 seconds + include: ['change', 'action', 'snapshot'] // Filter event types +}); + +const { data, execute, state } = createSvState( + initialData, actuators, + { plugins: [autosave, analytics] } +);`,H=`// autosavePlugin API +autosave.saveNow(); // Force immediate save +autosave.isSaving(); // Check if currently saving + +// analyticsPlugin API +analytics.flush(); // Force flush buffered events +analytics.eventCount(); // Number of buffered events`;We(e,{description:"Auto-save with idle timer (autosavePlugin) and batched event analytics (analyticsPlugin).",title:"Plugin: Autosave & Analytics",main:z=>{var F=jc(),q=de(F);He(q,{get hasErrors(){return r()},get isDirty(){return n()}});var I=d(q,2),N=f(I),M=f(N),j=d(N,2),W=f(j),K=d(j,2);{var V=Pe=>{var Ge=Zc();$(Pe,Ge)},w=te(()=>m.isSaving());se(K,Pe=>{v(w)&&Pe(V)})}var B=d(I,4),Y=f(B);{let Pe=te(()=>o()?.title);le(Y,{id:"title",get error(){return v(Pe)},label:"Title",placeholder:"Enter article title",get value(){return h.title},set value(Ge){h.title=Ge}})}var X=d(Y,2),Q=d(f(X),2),U=f(Q);U.value=U.__value="general";var Z=d(U);Z.value=Z.__value="tech";var O=d(Z);O.value=O.__value="science";var re=d(O);re.value=re.__value="culture";var y=d(X,2);{let Pe=te(()=>o()?.notes);rr(y,{id:"notes",get error(){return v(Pe)},label:"Notes",placeholder:"Write your notes (max 500 chars)",rows:4,get value(){return h.notes},set value(Ge){h.notes=Ge}})}var S=d(B,2),C=f(S),ne=f(C),ue=d(C,2),fe=d(ue,2),Ae=d(fe,2);{var Ee=Pe=>{var Ge=Rc();ye("click",Ge,_),$(Pe,Ge)};se(Ae,Pe=>{n()&&Pe(Ee)})}ae(()=>{G(M,`${v(l).length??""} Save${v(l).length===1?"":"s"}`),G(W,`${v(u)??""} Buffered Event${v(u)===1?"":"s"}`),C.disabled=r()||a(),G(ne,a()?"Submitting...":"Submit")}),un(Q,()=>h.category,Pe=>h.category=Pe),ye("click",C,()=>g()),ye("click",ue,()=>m.saveNow()),ye("click",fe,()=>p.flush()),$(z,F)},sidebar:z=>{var F=Bc(),q=f(F);Je(q,{get data(){return h},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:D,width:"xl:w-96"});var I=d(q,2),N=d(f(I),2);{var M=U=>{var Z=Lc();$(U,Z)},j=U=>{var Z=Mc();zt(Z,21,()=>v(l),O=>O.id,(O,re)=>{var y=Fc(),S=d(f(y),2),C=f(S),ne=d(S,2),ue=f(ne);ae(()=>{G(C,v(re).data),G(ue,v(re).timestamp)}),$(O,y)}),$(U,Z)};se(N,U=>{v(l).length===0?U(M):U(j,-1)})}var W=d(I,2),K=d(f(W),2),V=f(K),w=d(f(V)),B=d(W,2),Y=d(f(B),2);{var X=U=>{var Z=Vc();$(U,Z)},Q=U=>{var Z=Uc();zt(Z,21,()=>v(c),O=>O.id,(O,re)=>{var y=qc(),S=d(f(y),2),C=f(S),ne=d(S,2),ue=f(ne);ae(()=>{G(C,`${v(re).eventCount??""} event${v(re).eventCount===1?"":"s"} (${v(re).types??""})`),G(ue,v(re).timestamp)}),$(O,y)}),$(U,Z)};se(Y,U=>{v(c).length===0?U(X):U(Q,-1)})}ae(()=>G(w,` ${v(u)??""} event${v(u)===1?"":"s"}`)),$(z,F)},sourceCode:z=>{Ke(z,{children:(F,q)=>{var I=Jc(),N=de(I);pe(N,{code:R,title:"autosavePlugin + analyticsPlugin Setup"});var M=d(N,2);pe(M,{code:H,title:"Plugin API"}),$(F,I)}})}}),Te(),i()}tt(["click"]);var Kc=k(''),Hc=k('
                    ',1),Gc=k('

                    No events yet — interact with the form

                    '),Yc=k('
                  • '),Xc=k('
                      '),Qc=k('
                      Event Log
                      '),eu=k(" ",1);function tu(e,t){Ne(t,!0);const r=()=>ee(x,"$hasErrors",i),n=()=>ee(J,"$isDirty",i),o=()=>ee(b,"$errors",i),a=()=>ee(D,"$actionInProgress",i),s=()=>ee(A,"$snapshots",i),[i,l]=Ue();let c=we(it([]));const u=(z,F)=>{const q=new Date().toISOString().slice(11,23);me(c,[...v(c),{id:ce(),type:z,message:F,timestamp:q}],!0)},m={name:"log-mirror",onChange(z){u("change",`${z.property}: "${z.oldValue}" → "${z.currentValue}"`)},onValidation(z){u("validation",z?"Has errors":"Valid")},onSnapshot(z){u("snapshot",z.title)},onAction(z){z.phase==="before"?u("action","Action started"):u("action",z.error?`Action failed: ${z.error.message}`:"Action completed")},onRollback(z){u("rollback",`Rolled back to: ${z.title}`)},onReset(){u("reset","State reset to initial")}},{data:p,execute:h,reset:g,rollback:_,state:{errors:b,hasErrors:x,isDirty:J,snapshots:A,actionInProgress:D}}=Be({name:"",email:"",message:""},{validator:z=>({name:ie(z.name).prepare("trim").required().minLength(2).maxLength(50).getError(),email:ie(z.email).prepare("trim").required().email().getError(),message:ie(z.message).prepare("trim").required().minLength(5).getError()}),effect:({snapshot:z,property:F})=>{const q=F.charAt(0).toUpperCase()+F.slice(1);z(`Changed ${q}`)},action:async()=>{await new Promise(z=>setTimeout(z,500))}},{plugins:[Xi({name:"demo-devtools"}),m]}),R=()=>{p.name=`John Doe ${ce()}`,p.email=`john.${ce()}@example.com`,p.message="Hello, this is a test message for the devtools demo."},H=()=>{me(c,[],!0)},T={change:"bg-blue-100 text-blue-800",validation:"bg-yellow-100 text-yellow-800",snapshot:"bg-purple-100 text-purple-800",action:"bg-green-100 text-green-800",rollback:"bg-amber-100 text-amber-800",reset:"bg-red-100 text-red-800"},P=`import { createSvState, devtoolsPlugin } from 'svstate'; + +const { data, execute, reset, rollback, state } = createSvState( + { name: '', email: '', message: '' }, + { + validator: (source) => ({ /* ... */ }), + effect: ({ snapshot, property }) => { + snapshot(\`Changed \${property}\`); + }, + action: async () => { await saveToServer(); } + }, + { + plugins: [ + devtoolsPlugin({ + name: 'my-form', // Label in console + enabled: true, // Auto-disabled in production + collapsed: true, // Console groups collapsed + logValidation: true // Also log validation events + }) + ] + } +);`,L=`// devtoolsPlugin logs these events to the console: +// - onChange: property changes with old/new values +// - onValidation: validation results (if logValidation: true) +// - onSnapshot: snapshot creation with title +// - onAction: action start/complete/error +// - onRollback: rollback with target snapshot title +// - onReset: state reset events`;We(e,{description:"Shows devtoolsPlugin console logging and a custom log-mirror plugin that captures all events in-page.",title:"Plugin: Devtools",main:I=>{var N=Hc(),M=de(N);He(M,{get hasErrors(){return r()},get isDirty(){return n()}});var j=d(M,2),W=f(j);{let Z=te(()=>o()?.name);le(W,{id:"name",get error(){return v(Z)},label:"Name",placeholder:"Enter your name",get value(){return p.name},set value(O){p.name=O}})}var K=d(W,2);{let Z=te(()=>o()?.email);le(K,{id:"email",get error(){return v(Z)},label:"Email",placeholder:"Enter your email",type:"email",get value(){return p.email},set value(O){p.email=O}})}var V=d(K,2);{let Z=te(()=>o()?.message);rr(V,{id:"message",get error(){return v(Z)},label:"Message",placeholder:"Enter a message (min 5 chars)",required:!0,get value(){return p.message},set value(O){p.message=O}})}var w=d(j,2),B=f(w),Y=f(B),X=d(B,2),Q=d(X,2);{var U=Z=>{var O=Kc();ye("click",O,g),$(Z,O)};se(Q,Z=>{n()&&Z(U)})}ae(()=>{B.disabled=r()||a(),G(Y,a()?"Submitting...":"Submit"),X.disabled=s().length<=1}),ye("click",B,()=>h()),ye("click",X,()=>_()),$(I,N)},sidebar:I=>{var N=Qc(),M=f(N);Je(M,{get data(){return p},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:R,width:"xl:w-96"});var j=d(M,2),W=f(j),K=d(f(W),2),V=d(W,2);{var w=Y=>{var X=Gc();$(Y,X)},B=Y=>{var X=Xc();zt(X,21,()=>v(c),Q=>Q.id,(Q,U)=>{var Z=Yc(),O=f(Z),re=f(O),y=d(O,2),S=f(y),C=d(y,2),ne=f(C);ae(()=>{qe(O,1,`mt-0.5 flex-shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium ${T[v(U).type]??""}`),G(re,v(U).type),G(S,v(U).message),G(ne,v(U).timestamp)}),$(Q,Z)}),$(Y,X)};se(V,Y=>{v(c).length===0?Y(w):Y(B,-1)})}ye("click",K,H),$(I,N)},sourceCode:I=>{Ke(I,{children:(N,M)=>{var j=eu(),W=de(j);pe(W,{code:P,title:"devtoolsPlugin Setup"});var K=d(W,2);pe(K,{code:L,title:"What Gets Logged"}),$(N,j)}})}}),Te(),l()}tt(["click"]);var ru=k('Restored from storage'),nu=k('Fresh state'),ou=k(''),au=k('
                      Try: Reload the page to see persistence. Open this page in another tab to see cross-tab sync.
                      ',1),su=k('
                      Persistence Info
                      Restored:
                      Key: svstate-demo-settings
                      Excluded: notifications
                      Raw localStorage
                       
                      Sync Info
                      Channel: svstate-demo-sync
                      Throttle: 200ms
                      Merge: overwrite (default)
                      '),iu=k(" ",1);function lu(e,t){Ne(t,!0);const r=()=>ee(p,"$hasErrors",a),n=()=>ee(h,"$isDirty",a),o=()=>ee(m,"$errors",a),[a,s]=Ue(),i=ol({key:"svstate-demo-settings",throttle:300,exclude:["notifications"]}),l=ll({key:"svstate-demo-sync",throttle:200}),{data:c,reset:u,state:{errors:m,hasErrors:p,isDirty:h}}=Be({username:"",theme:"light",fontSize:14,notifications:!0},{validator:D=>({username:ie(D.username).prepare("trim").required().minLength(2).maxLength(30).getError(),theme:"",fontSize:"",notifications:""})},{plugins:[i,l]}),g=i.isRestored(),_=()=>{i.clearPersistedState(),u()},b=()=>{c.username="demo_user",c.theme="dark",c.fontSize=16,c.notifications=!1};let x=we("");Nr(()=>{c.username,c.theme,c.fontSize,c.notifications;const D=setTimeout(()=>{me(x,localStorage.getItem("svstate-demo-settings")??"(empty)",!0)},500);return()=>clearTimeout(D)});const J=`import { createSvState, persistPlugin, syncPlugin } from 'svstate'; + +const persist = persistPlugin({ + key: 'svstate-demo-settings', + throttle: 300, + exclude: ['notifications'] // Don't persist this field +}); + +const sync = syncPlugin({ + key: 'svstate-demo-sync', + throttle: 200 +}); + +const { data, reset, state } = createSvState( + { username: '', theme: 'light', fontSize: 14, notifications: true }, + { validator: (source) => ({ /* ... */ }) }, + { plugins: [persist, sync] } +);`,A=`// persistPlugin API +persist.isRestored(); // true if data was loaded from storage +persist.clearPersistedState(); // Remove stored data + +// syncPlugin: automatic cross-tab sync via BroadcastChannel +// Changes in one tab appear in all other tabs with same key`;We(e,{description:"Settings form with persistPlugin (localStorage) and syncPlugin (cross-tab sync via BroadcastChannel).",title:"Plugin: Persist & Sync",main:T=>{var P=au(),L=de(P);He(L,{get hasErrors(){return r()},get isDirty(){return n()}});var z=d(L,2),F=f(z);{var q=y=>{var S=ru();$(y,S)},I=y=>{var S=nu();$(y,S)};se(F,y=>{g?y(q):y(I,-1)})}var N=d(z,4),M=f(N);{let y=te(()=>o()?.username);le(M,{id:"username",get error(){return v(y)},label:"Username",placeholder:"Enter username",get value(){return c.username},set value(S){c.username=S}})}var j=d(M,2),W=d(f(j),2),K=f(W);K.value=K.__value="light";var V=d(K);V.value=V.__value="dark";var w=d(V);w.value=w.__value="system";var B=d(j,2);le(B,{id:"fontSize",label:"Font Size",max:32,min:8,step:1,type:"number",get value(){return c.fontSize},set value(y){c.fontSize=y}});var Y=d(B,2),X=f(Y),Q=f(X),U=d(N,2),Z=f(U),O=d(Z,2);{var re=y=>{var S=ou();ye("click",S,u),$(y,S)};se(O,y=>{n()&&y(re)})}un(W,()=>c.theme,y=>c.theme=y),Cr(Q,()=>c.notifications,y=>c.notifications=y),ye("click",Z,_),$(T,P)},sidebar:T=>{var P=su(),L=f(P);Je(L,{get data(){return c},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:b,width:"xl:w-96"});var z=d(L,2),F=d(f(z),2),q=f(F),I=d(f(q)),N=d(z,2),M=d(f(N),2),j=f(M);ae(()=>{G(I,` ${g??""}`),G(j,v(x))}),$(T,P)},sourceCode:T=>{Ke(T,{children:(P,L)=>{var z=iu(),F=de(z);pe(F,{code:J,title:"persistPlugin + syncPlugin Setup"});var q=d(F,2);pe(q,{code:A,title:"Plugin API"}),$(P,z)}})}}),Te(),s()}tt(["click"]);var cu=k(''),uu=k('
                      Max: 10
                      ',1),du=k('

                      No snapshots yet

                      '),fu=k('
                    • '),pu=k('
                        '),vu=k('

                        No redo entries — undo something first

                        '),mu=k('
                      • '),hu=k('
                          '),gu=k('
                          Snapshot History
                          Redo Stack
                          '),bu=k(" ",1);function _u(e,t){Ne(t,!0);const r=()=>ee(g,"$hasErrors",s),n=()=>ee(_,"$isDirty",s),o=()=>ee(b,"$snapshots",s),a=()=>ee(h,"$errors",s),[s,i]=Ue(),l=cl(),c=R=>R.charAt(0).toUpperCase()+R.slice(1).replaceAll(/([A-Z])/g," $1"),{data:u,reset:m,rollback:p,state:{errors:h,hasErrors:g,isDirty:_,snapshots:b}}=Be({title:"My Document",content:"",priority:"medium"},{validator:R=>({title:ie(R.title).prepare("trim").required().minLength(2).maxLength(100).getError(),content:ie(R.content).prepare("trim").required().minLength(10).getError(),priority:""}),effect:({snapshot:R,property:H})=>{R(`Changed ${c(H)}`)}},{maxSnapshots:10,plugins:[l]}),x=()=>{u.title=`Project Report ${ce()}`,u.content="This is a detailed document with enough content to pass validation requirements.",u.priority="high"};let J=we(it(Ye(l.redoStack)));Nr(()=>l.redoStack.subscribe(H=>{me(J,H,!0)}));const A=`import { createSvState, undoRedoPlugin } from 'svstate'; + +const undoRedo = undoRedoPlugin(); + +const { data, reset, rollback, state } = createSvState( + { title: 'My Document', content: '', priority: 'medium' }, + { + validator: (source) => ({ /* ... */ }), + effect: ({ snapshot, property }) => { + snapshot(\`Changed \${property}\`); + } + }, + { maxSnapshots: 10, plugins: [undoRedo] } +);`,D=`// Undo (built-in rollback) +rollback(); + +// Redo (from undoRedoPlugin) +undoRedo.redo(); + +// Check if redo is available +undoRedo.canRedo(); // boolean + +// Subscribe to redo stack +undoRedo.redoStack; // Readable`;We(e,{description:"Combines the built-in snapshot/rollback system with the undoRedoPlugin for full undo/redo support.",title:"Plugin: Undo/Redo",main:P=>{var L=uu(),z=de(L);He(z,{get hasErrors(){return r()},get isDirty(){return n()}});var F=d(z,2),q=f(F),I=f(q),N=d(q,2),M=f(N),j=d(F,2),W=f(j);{let S=te(()=>a()?.title);le(W,{id:"title",get error(){return v(S)},label:"Title",placeholder:"Enter document title",get value(){return u.title},set value(C){u.title=C}})}var K=d(W,2);{let S=te(()=>a()?.content);rr(K,{id:"content",get error(){return v(S)},label:"Content",placeholder:"Write your document content (min 10 chars)",required:!0,rows:4,get value(){return u.content},set value(C){u.content=C}})}var V=d(K,2),w=d(f(V),2),B=f(w);B.value=B.__value="low";var Y=d(B);Y.value=Y.__value="medium";var X=d(Y);X.value=X.__value="high";var Q=d(X);Q.value=Q.__value="critical";var U=d(j,2),Z=f(U),O=d(Z,2),re=d(O,2);{var y=S=>{var C=cu();ye("click",C,m),$(S,C)};se(re,S=>{n()&&S(y)})}ae(()=>{G(I,`${o().length??""} Snapshot${o().length===1?"":"s"}`),G(M,`${v(J).length??""} Redo${v(J).length===1?"":"s"}`),Z.disabled=o().length<=1,O.disabled=v(J).length===0}),un(w,()=>u.priority,S=>u.priority=S),ye("click",Z,()=>p()),ye("click",O,()=>l.redo()),$(P,L)},sidebar:P=>{var L=gu(),z=f(L);Je(z,{get data(){return u},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:x,width:"xl:w-96"});var F=d(z,2),q=d(f(F),2);{var I=V=>{var w=du();$(V,w)},N=V=>{var w=pu();zt(w,5,o,Ir,(B,Y,X)=>{var Q=fu(),U=f(Q);U.textContent=X+1;var Z=d(U,2),O=f(Z);ae(()=>G(O,v(Y).title)),$(B,Q)}),$(V,w)};se(q,V=>{o().length===0?V(I):V(N,-1)})}var M=d(F,2),j=d(f(M),2);{var W=V=>{var w=vu();$(V,w)},K=V=>{var w=hu();zt(w,21,()=>v(J),Ir,(B,Y,X)=>{var Q=mu(),U=f(Q);U.textContent=X+1;var Z=d(U,2),O=f(Z);ae(()=>G(O,v(Y).title)),$(B,Q)}),$(V,w)};se(j,V=>{v(J).length===0?V(W):V(K,-1)})}$(P,L)},sourceCode:P=>{Ke(P,{children:(L,z)=>{var F=bu(),q=de(F);pe(q,{code:A,title:"Setup with undoRedoPlugin"});var I=d(q,2);pe(I,{code:D,title:"Undo/Redo Usage"}),$(L,F)}})}}),Te(),i()}tt(["click"]);var yu=k('
                          '),xu=k('
                          ',1),wu=k(" ",1);function $u(e,t){Ne(t,!0);const r=()=>ee(m,"$hasErrors",a),n=()=>ee(p,"$isDirty",a),o=()=>ee(u,"$errors",a),[a,s]=Ue(),i={firstName:"Alice",lastName:"Smith",email:"alice.smith@example.com",phone:"",bio:""},{data:l,reset:c,state:{errors:u,hasErrors:m,isDirty:p}}=Be(i,{validator:b=>({firstName:ie(b.firstName).prepare("trim").required().minLength(2).maxLength(30).getError(),lastName:ie(b.lastName).prepare("trim").required().minLength(2).maxLength(30).getError(),email:ie(b.email).prepare("trim").required().email().getError(),phone:ie(b.phone).prepare("trim").required().minLength(10).getError(),bio:ie(b.bio).maxLength(200).getError()})}),h=()=>{l.firstName="John",l.lastName=`Doe${ce()}`,l.email=`john.doe.${ce()}@example.com`,l.phone=`555-${ce().slice(0,3)}-${ce().slice(0,4)}`,l.bio="Software developer with a passion for clean code."},g=`const sourceData = { + firstName: 'Alice', + lastName: 'Smith', + email: 'alice.smith@example.com', + phone: '', + bio: '' +}; + +const { data, reset, state: { errors, hasErrors, isDirty } } = createSvState(sourceData, { + validator: (source) => ({ + firstName: stringValidator(source.firstName).prepare('trim').required().minLength(2).maxLength(30).getError(), + lastName: stringValidator(source.lastName).prepare('trim').required().minLength(2).maxLength(30).getError(), + email: stringValidator(source.email).prepare('trim').required().email().getError(), + phone: stringValidator(source.phone).prepare('trim').required().minLength(10).getError(), + bio: stringValidator(source.bio).maxLength(200).getError() + }) +});`,_=` +{#if $isDirty} + +{/if} + + +`;We(e,{description:"Demonstrates the reset() function to restore state back to its initial values.",title:"Reset Demo",main:A=>{var D=xu(),R=de(D);He(R,{get hasErrors(){return r()},get isDirty(){return n()}});var H=d(R,2),T=f(H);{let N=te(()=>o()?.firstName);le(T,{id:"firstName",get error(){return v(N)},label:"First Name",placeholder:"Enter first name",get value(){return l.firstName},set value(M){l.firstName=M}})}var P=d(T,2);{let N=te(()=>o()?.lastName);le(P,{id:"lastName",get error(){return v(N)},label:"Last Name",placeholder:"Enter last name",get value(){return l.lastName},set value(M){l.lastName=M}})}var L=d(P,2);{let N=te(()=>o()?.email);le(L,{id:"email",get error(){return v(N)},label:"Email",placeholder:"Enter email",type:"email",get value(){return l.email},set value(M){l.email=M}})}var z=d(L,2);{let N=te(()=>o()?.phone);le(z,{id:"phone",get error(){return v(N)},label:"Phone",placeholder:"555-123-4567",get value(){return l.phone},set value(M){l.phone=M}})}var F=d(z,2);{let N=te(()=>o()?.bio);rr(F,{id:"bio",get error(){return v(N)},label:"Bio",placeholder:"Tell us about yourself",required:!1,get value(){return l.bio},set value(M){l.bio=M}})}var q=d(H,2);{var I=N=>{var M=yu(),j=f(M);ye("click",j,c),$(N,M)};se(q,N=>{n()&&N(I)})}$(A,D)},sidebar:A=>{Je(A,{get data(){return l},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},onFill:h})},sourceCode:A=>{Ke(A,{children:(D,R)=>{var H=wu(),T=de(H);pe(T,{code:g,title:"State Setup with Reset"});var P=d(T,2);pe(P,{code:_,title:"Conditional Reset Button"}),$(D,H)}})}}),Te(),s()}tt(["click"]);var Eu=k(''),Su=k('
                          Max: 5
                          ',1),ku=k('

                          No snapshots yet

                          '),zu=k('
                        • '),Du=k('
                            '),Au=k('
                            Snapshot History
                            '),Pu=k(" ",1);function Cu(e,t){Ne(t,!0);const r=()=>ee(_,"$hasErrors",s),n=()=>ee(b,"$isDirty",s),o=()=>ee(x,"$snapshots",s),a=()=>ee(g,"$errors",s),[s,i]=Ue(),l={firstName:"Alice",lastName:"Smith",email:"alice.smith@example.com",phone:"",bio:""},c=H=>H.charAt(0).toUpperCase()+H.slice(1).replaceAll(/([A-Z])/g," $1"),{data:u,reset:m,rollback:p,rollbackTo:h,state:{errors:g,hasErrors:_,isDirty:b,snapshots:x}}=Be(l,{validator:H=>({firstName:ie(H.firstName).prepare("trim").required().minLength(2).maxLength(30).getError(),lastName:ie(H.lastName).prepare("trim").required().minLength(2).maxLength(30).getError(),email:ie(H.email).prepare("trim").required().email().getError(),phone:ie(H.phone).prepare("trim").required().minLength(10).getError(),bio:ie(H.bio).maxLength(200).getError()}),effect:({snapshot:H,property:T})=>{H(`Changed ${c(T)}`)}},{maxSnapshots:5}),J=()=>{u.firstName="John",u.lastName=`Doe${ce()}`,u.email=`john.doe.${ce()}@example.com`,u.phone=`555-${ce().slice(0,3)}-${ce().slice(0,4)}`,u.bio="Software developer with a passion for clean code."},A=`const sourceData = { + firstName: 'Alice', lastName: 'Smith', email: 'alice.smith@example.com', phone: '', bio: '' +}; + +const { data, reset, rollback, rollbackTo, state: { errors, hasErrors, isDirty, snapshots } } = + createSvState(sourceData, { + validator: (source) => ({ /* validation rules */ }), + effect: ({ snapshot, property }) => { + snapshot(\`Changed \${formatFieldName(property)}\`); + } + }, { maxSnapshots: 5 });`,D=`// Effect callback creates snapshots on each change +effect: ({ snapshot, property }) => { + snapshot(\`Changed \${property}\`); // Creates undo point + // If same title, replaces last snapshot (debouncing) + // Use snapshot(title, false) to always create new +}`,R=`// Undo last change +rollback(); + +// Undo 3 changes at once +rollback(3); + +// Roll back to a named snapshot (returns true if found) +rollbackTo('Changed First Name'); + +// Roll back to initial state +rollbackTo('Initial'); + +// Reset to initial state (clears all snapshots) +reset();`;We(e,{description:"Shows snapshot creation for undo functionality with rollback(), rollbackTo(), and maxSnapshots support.",title:"Snapshot & Rollback Demo",main:L=>{var z=Su(),F=de(z);He(F,{get hasErrors(){return r()},get isDirty(){return n()}});var q=d(F,2),I=f(q),N=f(I),M=d(q,2),j=f(M);{let Z=te(()=>a()?.firstName);le(j,{id:"firstName",get error(){return v(Z)},label:"First Name",placeholder:"Enter first name",get value(){return u.firstName},set value(O){u.firstName=O}})}var W=d(j,2);{let Z=te(()=>a()?.lastName);le(W,{id:"lastName",get error(){return v(Z)},label:"Last Name",placeholder:"Enter last name",get value(){return u.lastName},set value(O){u.lastName=O}})}var K=d(W,2);{let Z=te(()=>a()?.email);le(K,{id:"email",get error(){return v(Z)},label:"Email",placeholder:"Enter email",type:"email",get value(){return u.email},set value(O){u.email=O}})}var V=d(K,2);{let Z=te(()=>a()?.phone);le(V,{id:"phone",get error(){return v(Z)},label:"Phone",placeholder:"555-123-4567",get value(){return u.phone},set value(O){u.phone=O}})}var w=d(V,2);{let Z=te(()=>a()?.bio);rr(w,{id:"bio",get error(){return v(Z)},label:"Bio",placeholder:"Tell us about yourself",required:!1,get value(){return u.bio},set value(O){u.bio=O}})}var B=d(M,2),Y=f(B),X=d(Y,2),Q=d(X,2);{var U=Z=>{var O=Eu();ye("click",O,m),$(Z,O)};se(Q,Z=>{n()&&Z(U)})}ae(()=>{G(N,`${o().length??""} Snapshot${o().length===1?"":"s"}`),Y.disabled=o().length<=1,X.disabled=o().length<=1}),ye("click",Y,()=>p()),ye("click",X,()=>h("Initial")),$(L,z)},sidebar:L=>{var z=Au(),F=f(z);Je(F,{get data(){return u},get errors(){return a()},get hasErrors(){return r()},get isDirty(){return n()},onFill:J,width:"xl:w-96"});var q=d(F,2),I=d(f(q),2);{var N=j=>{var W=ku();$(j,W)},M=j=>{var W=Du();zt(W,5,o,Ir,(K,V,w)=>{var B=zu(),Y=f(B);Y.textContent=w+1;var X=d(Y,2),Q=f(X);ae(()=>{X.disabled=o().length<=1,G(Q,v(V).title)}),ye("click",X,()=>h(v(V).title)),$(K,B)}),$(j,W)};se(I,j=>{o().length===0?j(N):j(M,-1)})}$(L,z)},sourceCode:L=>{Ke(L,{children:(z,F)=>{var q=Pu(),I=de(q);pe(I,{code:A,title:"State Setup with Snapshots & maxSnapshots"});var N=d(I,2);pe(N,{code:D,title:"Effect with Snapshot Creation"});var M=d(N,2);pe(M,{code:R,title:"Rollback, RollbackTo & Reset Usage"}),$(z,q)}})}}),Te(),i()}tt(["click"]);function E(e,t,r){function n(i,l){if(i._zod||Object.defineProperty(i,"_zod",{value:{def:l,constr:s,traits:new Set},enumerable:!1}),i._zod.traits.has(e))return;i._zod.traits.add(e),t(i,l);const c=s.prototype,u=Object.keys(c);for(let m=0;mr?.Parent&&i instanceof r.Parent?!0:i?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class dr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ca extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Oa={};function Xt(e){return Oa}function Na(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function An(e,t){return typeof t=="bigint"?t.toString():t}function Gn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Yn(e){return e==null}function Xn(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ou(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(o=Number.parseInt(l[1]))}const a=r>o?r:o,s=Number.parseInt(e.toFixed(a).replace(".","")),i=Number.parseInt(t.toFixed(a).replace(".",""));return s%i/10**a}const yo=Symbol("evaluating");function _e(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==yo)return n===void 0&&(n=yo,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function nr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Rt(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function xo(e){return JSON.stringify(e)}function Nu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ta="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function on(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Tu=Gn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function jr(e){if(on(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(on(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ia(e){return jr(e)?{...e}:Array.isArray(e)?[...e]:e}const Iu=new Set(["string","number","symbol"]);function gr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jt(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function oe(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Zu(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Ru={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ju(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=Rt(e._zod.def,{get shape(){const s={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(s[i]=r.shape[i])}return nr(this,"shape",s),s},checks:[]});return jt(e,a)}function Lu(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=Rt(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete s[i]}return nr(this,"shape",s),s},checks:[]});return jt(e,a)}function Fu(e,t){if(!jr(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const a=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(a,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=Rt(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return nr(this,"shape",a),a}});return jt(e,o)}function Mu(e,t){if(!jr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=Rt(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return nr(this,"shape",n),n}});return jt(e,r)}function Vu(e,t){const r=Rt(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return nr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return jt(e,r)}function qu(e,t,r){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=Rt(t._zod.def,{get shape(){const i=t._zod.def.shape,l={...i};if(r)for(const c in r){if(!(c in i))throw new Error(`Unrecognized key: "${c}"`);r[c]&&(l[c]=e?new e({type:"optional",innerType:i[c]}):i[c])}else for(const c in i)l[c]=e?new e({type:"optional",innerType:i[c]}):i[c];return nr(this,"shape",l),l},checks:[]});return jt(t,s)}function Uu(e,t,r){const n=Rt(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(r)for(const s in r){if(!(s in a))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(a[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)a[s]=new e({type:"nonoptional",innerType:o[s]});return nr(this,"shape",a),a}});return jt(t,n)}function lr(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Kr(e){return typeof e=="string"?e:e?.message}function Qt(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const o=Kr(e.inst?._zod.def?.error?.(e))??Kr(t?.error?.(e))??Kr(r.customError?.(e))??Kr(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Qn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Lr(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Ra=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,An,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ja=E("$ZodError",Ra),La=E("$ZodError",Ra,{Parent:Error});function Bu(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ju(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>n({issues:s}));else if(a.code==="invalid_key")n({issues:a.issues});else if(a.code==="invalid_element")n({issues:a.issues});else if(a.path.length===0)r._errors.push(t(a));else{let s=r,i=0;for(;i(t,r,n,o)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},a);if(s instanceof Promise)throw new dr;if(s.issues.length){const i=new(o?.Err??e)(s.issues.map(l=>Qt(l,a,Xt())));throw Ta(i,o?.callee),i}return s.value},to=e=>async(t,r,n,o)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){const i=new(o?.Err??e)(s.issues.map(l=>Qt(l,a,Xt())));throw Ta(i,o?.callee),i}return s.value},dn=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new dr;return a.issues.length?{success:!1,error:new(e??ja)(a.issues.map(s=>Qt(s,o,Xt())))}:{success:!0,data:a.value}},Wu=dn(La),fn=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},o);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(s=>Qt(s,o,Xt())))}:{success:!0,data:a.value}},Ku=fn(La),Hu=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return eo(e)(t,r,o)},Gu=e=>(t,r,n)=>eo(e)(t,r,n),Yu=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return to(e)(t,r,o)},Xu=e=>async(t,r,n)=>to(e)(t,r,n),Qu=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return dn(e)(t,r,o)},ed=e=>(t,r,n)=>dn(e)(t,r,n),td=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return fn(e)(t,r,o)},rd=e=>async(t,r,n)=>fn(e)(t,r,n),nd=/^[cC][^\s-]{8,}$/,od=/^[0-9a-z]+$/,ad=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,sd=/^[0-9a-vA-V]{20}$/,id=/^[A-Za-z0-9]{27}$/,ld=/^[a-zA-Z0-9_-]{21}$/,cd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ud=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wo=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,dd=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function pd(){return new RegExp(fd,"u")}const vd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,md=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,hd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,gd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Fa=/^[A-Za-z0-9_-]*$/,_d=/^\+[1-9]\d{6,14}$/,Ma="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",yd=new RegExp(`^${Ma}$`);function Va(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function xd(e){return new RegExp(`^${Va(e)}$`)}function wd(e){const t=Va({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Ma}T(?:${n})$`)}const $d=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ed=/^-?\d+$/,Sd=/^-?\d+(?:\.\d+)?$/,kd=/^[^A-Z]*$/,zd=/^[^a-z]*$/,rt=E("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),qa={number:"number",bigint:"bigint",object:"date"},Ua=E("$ZodCheckLessThan",(e,t)=>{rt.init(e,t);const r=qa[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,a=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{rt.init(e,t);const r=qa[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,a=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dd=E("$ZodCheckMultipleOf",(e,t)=>{rt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Ou(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ad=E("$ZodCheckNumberFormat",(e,t)=>{rt.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,a]=Ru[t.format];e._zod.onattach.push(s=>{const i=s._zod.bag;i.format=t.format,i.minimum=o,i.maximum=a,r&&(i.pattern=Ed)}),e._zod.check=s=>{const i=s.value;if(r){if(!Number.isInteger(i)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});return}if(!Number.isSafeInteger(i)){i>0?s.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}ia&&s.issues.push({origin:"number",input:i,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Pd=E("$ZodCheckMaxLength",(e,t)=>{var r;rt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Yn(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum{const o=n.value;if(o.length<=t.maximum)return;const s=Qn(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Cd=E("$ZodCheckMinLength",(e,t)=>{var r;rt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Yn(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const s=Qn(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Od=E("$ZodCheckLengthEquals",(e,t)=>{var r;rt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Yn(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,a=o.length;if(a===t.length)return;const s=Qn(o),i=a>t.length;n.issues.push({origin:s,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),pn=E("$ZodCheckStringFormat",(e,t)=>{var r,n;rt.init(e,t),e._zod.onattach.push(o=>{const a=o._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Nd=E("$ZodCheckRegex",(e,t)=>{pn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Td=E("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kd),pn.init(e,t)}),Id=E("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zd),pn.init(e,t)}),Zd=E("$ZodCheckIncludes",(e,t)=>{rt.init(e,t);const r=gr(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Rd=E("$ZodCheckStartsWith",(e,t)=>{rt.init(e,t);const r=new RegExp(`^${gr(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),jd=E("$ZodCheckEndsWith",(e,t)=>{rt.init(e,t);const r=new RegExp(`.*${gr(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ld=E("$ZodCheckOverwrite",(e,t)=>{rt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Fd{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(` +`).filter(s=>s),o=Math.min(...n.map(s=>s.length-s.trimStart().length)),a=n.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of a)this.content.push(s)}compile(){const t=Function,r=this?.args,o=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...r,o.join(` +`))}}const Md={major:4,minor:3,patch:6},ke=E("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Md;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const a of o._zod.onattach)a(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,i,l)=>{let c=lr(s),u;for(const m of i){if(m._zod.def.when){if(!m._zod.def.when(s))continue}else if(c)continue;const p=s.issues.length,h=m._zod.check(s);if(h instanceof Promise&&l?.async===!1)throw new dr;if(u||h instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await h,s.issues.length!==p&&(c||(c=lr(s,p)))});else{if(s.issues.length===p)continue;c||(c=lr(s,p))}}return u?u.then(()=>s):s},a=(s,i,l)=>{if(lr(s))return s.aborted=!0,s;const c=o(i,n,l);if(c instanceof Promise){if(l.async===!1)throw new dr;return c.then(u=>e._zod.parse(u,l))}return e._zod.parse(c,l)};e._zod.run=(s,i)=>{if(i.skipChecks)return e._zod.parse(s,i);if(i.direction==="backward"){const c=e._zod.parse({value:s.value,issues:[]},{...i,skipChecks:!0});return c instanceof Promise?c.then(u=>a(u,s,i)):a(c,s,i)}const l=e._zod.parse(s,i);if(l instanceof Promise){if(i.async===!1)throw new dr;return l.then(c=>o(c,n,i))}return o(l,n,i)}}_e(e,"~standard",()=>({validate:o=>{try{const a=Wu(e,o);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return Ku(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),ro=E("$ZodString",(e,t)=>{ke.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$d(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),$e=E("$ZodStringFormat",(e,t)=>{pn.init(e,t),ro.init(e,t)}),Vd=E("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ud),$e.init(e,t)}),qd=E("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=wo(n))}else t.pattern??(t.pattern=wo());$e.init(e,t)}),Ud=E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dd),$e.init(e,t)}),Bd=E("$ZodURL",(e,t)=>{$e.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Jd=E("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=pd()),$e.init(e,t)}),Wd=E("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ld),$e.init(e,t)}),Kd=E("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nd),$e.init(e,t)}),Hd=E("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=od),$e.init(e,t)}),Gd=E("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ad),$e.init(e,t)}),Yd=E("$ZodXID",(e,t)=>{t.pattern??(t.pattern=sd),$e.init(e,t)}),Xd=E("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=id),$e.init(e,t)}),Qd=E("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=wd(t)),$e.init(e,t)}),ef=E("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=yd),$e.init(e,t)}),tf=E("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xd(t)),$e.init(e,t)}),rf=E("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=cd),$e.init(e,t)}),nf=E("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=vd),$e.init(e,t),e._zod.bag.format="ipv4"}),of=E("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=md),$e.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),af=E("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=hd),$e.init(e,t)}),sf=E("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=gd),$e.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,a]=n;if(!a)throw new Error;const s=Number(a);if(`${s}`!==a)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Ja(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const lf=E("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bd),$e.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Ja(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function cf(e){if(!Fa.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ja(r)}const uf=E("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Fa),$e.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{cf(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),df=E("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_d),$e.init(e,t)});function ff(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const pf=E("$ZodJWT",(e,t)=>{$e.init(e,t),e._zod.check=r=>{ff(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Wa=E("$ZodNumber",(e,t)=>{ke.init(e,t),e._zod.pattern=e._zod.bag.pattern??Sd,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const a=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...a?{received:a}:{}}),r}}),vf=E("$ZodNumberFormat",(e,t)=>{Ad.init(e,t),Wa.init(e,t)}),mf=E("$ZodUnknown",(e,t)=>{ke.init(e,t),e._zod.parse=r=>r}),hf=E("$ZodNever",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function $o(e,t,r){e.issues.length&&t.issues.push(...Za(r,e.issues)),t.value[r]=e.value}const gf=E("$ZodArray",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const a=[];for(let s=0;s$o(c,r,s))):$o(l,r,s)}return a.length?Promise.all(a).then(()=>r):r}});function an(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...Za(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Ka(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Zu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Ha(e,t,r,n,o,a){const s=[],i=o.keySet,l=o.catchall._zod,c=l.def.type,u=l.optout==="optional";for(const m in t){if(i.has(m))continue;if(c==="never"){s.push(m);continue}const p=l.run({value:t[m],issues:[]},n);p instanceof Promise?e.push(p.then(h=>an(h,r,m,t,u))):an(p,r,m,t,u)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}const bf=E("$ZodObject",(e,t)=>{if(ke.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const i=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...i};return Object.defineProperty(t,"shape",{value:l}),l}})}const n=Gn(()=>Ka(t));_e(e._zod,"propValues",()=>{const i=t.shape,l={};for(const c in i){const u=i[c]._zod;if(u.values){l[c]??(l[c]=new Set);for(const m of u.values)l[c].add(m)}}return l});const o=on,a=t.catchall;let s;e._zod.parse=(i,l)=>{s??(s=n.value);const c=i.value;if(!o(c))return i.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),i;i.value={};const u=[],m=s.shape;for(const p of s.keys){const h=m[p],g=h._zod.optout==="optional",_=h._zod.run({value:c[p],issues:[]},l);_ instanceof Promise?u.push(_.then(b=>an(b,i,p,c,g))):an(_,i,p,c,g)}return a?Ha(u,c,i,l,n.value,e):u.length?Promise.all(u).then(()=>i):i}}),_f=E("$ZodObjectJIT",(e,t)=>{bf.init(e,t);const r=e._zod.parse,n=Gn(()=>Ka(t)),o=p=>{const h=new Fd(["shape","payload","ctx"]),g=n.value,_=A=>{const D=xo(A);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};h.write("const input = payload.value;");const b=Object.create(null);let x=0;for(const A of g.keys)b[A]=`key_${x++}`;h.write("const newResult = {};");for(const A of g.keys){const D=b[A],R=xo(A),T=p[A]?._zod?.optout==="optional";h.write(`const ${D} = ${_(A)};`),T?h.write(` + if (${D}.issues.length) { + if (${R} in input) { + payload.issues = payload.issues.concat(${D}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${R}, ...iss.path] : [${R}] + }))); + } + } + + if (${D}.value === undefined) { + if (${R} in input) { + newResult[${R}] = undefined; + } + } else { + newResult[${R}] = ${D}.value; + } + + `):h.write(` + if (${D}.issues.length) { + payload.issues = payload.issues.concat(${D}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${R}, ...iss.path] : [${R}] + }))); + } + + if (${D}.value === undefined) { + if (${R} in input) { + newResult[${R}] = undefined; + } + } else { + newResult[${R}] = ${D}.value; + } + + `)}h.write("payload.value = newResult;"),h.write("return payload;");const J=h.compile();return(A,D)=>J(p,A,D)};let a;const s=on,i=!Oa.jitless,c=i&&Tu.value,u=t.catchall;let m;e._zod.parse=(p,h)=>{m??(m=n.value);const g=p.value;return s(g)?i&&c&&h?.async===!1&&h.jitless!==!0?(a||(a=o(t.shape)),p=a(p,h),u?Ha([],g,p,h,m,e):p):r(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});function Eo(e,t,r,n){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const o=e.filter(a=>!lr(a));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(s=>Qt(s,n,Xt())))}),t)}const yf=E("$ZodUnion",(e,t)=>{ke.init(e,t),_e(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),_e(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_e(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),_e(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${o.map(a=>Xn(a.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,a)=>{if(r)return n(o,a);let s=!1;const i=[];for(const l of t.options){const c=l._zod.run({value:o.value,issues:[]},a);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(l=>Eo(l,o,e,a)):Eo(i,o,e,a)}}),xf=E("$ZodIntersection",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,a=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);return a instanceof Promise||s instanceof Promise?Promise.all([a,s]).then(([l,c])=>So(r,l,c)):So(r,a,s)}});function Pn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(jr(e)&&jr(t)){const r=Object.keys(t),n=Object.keys(e).filter(a=>r.indexOf(a)!==-1),o={...e,...t};for(const a of n){const s=Pn(e[a],t[a]);if(!s.valid)return{valid:!1,mergeErrorPath:[a,...s.mergeErrorPath]};o[a]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;ni.l&&i.r).map(([i])=>i);if(a.length&&o&&e.issues.push({...o,keys:a}),lr(e))return e;const s=Pn(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const wf=E("$ZodEnum",(e,t)=>{ke.init(e,t);const r=Na(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Iu.has(typeof o)).map(o=>typeof o=="string"?gr(o):o.toString()).join("|")})$`),e._zod.parse=(o,a)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}}),$f=E("$ZodLiteral",(e,t)=>{if(ke.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?gr(n):n?gr(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{const a=n.value;return r.has(a)||n.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),n}}),Ef=E("$ZodTransform",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ca(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(r.value=s,r));if(o instanceof Promise)throw new dr;return r.value=o,r}});function ko(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Ga=E("$ZodOptional",(e,t)=>{ke.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_e(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xn(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>ko(a,r.value)):ko(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Sf=E("$ZodExactOptional",(e,t)=>{Ga.init(e,t),_e(e._zod,"values",()=>t.innerType._zod.values),_e(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),kf=E("$ZodNullable",(e,t)=>{ke.init(e,t),_e(e._zod,"optin",()=>t.innerType._zod.optin),_e(e._zod,"optout",()=>t.innerType._zod.optout),_e(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xn(r.source)}|null)$`):void 0}),_e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),zf=E("$ZodDefault",(e,t)=>{ke.init(e,t),e._zod.optin="optional",_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>zo(a,t)):zo(o,t)}});function zo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Df=E("$ZodPrefault",(e,t)=>{ke.init(e,t),e._zod.optin="optional",_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Af=E("$ZodNonOptional",(e,t)=>{ke.init(e,t),_e(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>Do(a,e)):Do(o,e)}});function Do(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Pf=E("$ZodCatch",(e,t)=>{ke.init(e,t),_e(e._zod,"optin",()=>t.innerType._zod.optin),_e(e._zod,"optout",()=>t.innerType._zod.optout),_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(s=>Qt(s,n,Xt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>Qt(a,n,Xt()))},input:r.value}),r.issues=[]),r)}}),Cf=E("$ZodPipe",(e,t)=>{ke.init(e,t),_e(e._zod,"values",()=>t.in._zod.values),_e(e._zod,"optin",()=>t.in._zod.optin),_e(e._zod,"optout",()=>t.out._zod.optout),_e(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const a=t.out._zod.run(r,n);return a instanceof Promise?a.then(s=>Hr(s,t.in,n)):Hr(a,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(a=>Hr(a,t.out,n)):Hr(o,t.out,n)}});function Hr(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Of=E("$ZodReadonly",(e,t)=>{ke.init(e,t),_e(e._zod,"propValues",()=>t.innerType._zod.propValues),_e(e._zod,"values",()=>t.innerType._zod.values),_e(e._zod,"optin",()=>t.innerType?._zod?.optin),_e(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Ao):Ao(o)}});function Ao(e){return e.value=Object.freeze(e.value),e}const Nf=E("$ZodCustom",(e,t)=>{rt.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(a=>Po(a,r,n,e));Po(o,r,n,e)}});function Po(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Lr(o))}}var Co;class Tf{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function If(){return new Tf}(Co=globalThis).__zod_globalRegistry??(Co.__zod_globalRegistry=If());const zr=globalThis.__zod_globalRegistry;function Zf(e,t){return new e({type:"string",...oe(t)})}function Rf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...oe(t)})}function Oo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...oe(t)})}function jf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...oe(t)})}function Lf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...oe(t)})}function Ff(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...oe(t)})}function Mf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...oe(t)})}function Vf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...oe(t)})}function qf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...oe(t)})}function Uf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...oe(t)})}function Bf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...oe(t)})}function Jf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...oe(t)})}function Wf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...oe(t)})}function Kf(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...oe(t)})}function Hf(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...oe(t)})}function Gf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...oe(t)})}function Yf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...oe(t)})}function Xf(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...oe(t)})}function Qf(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...oe(t)})}function ep(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...oe(t)})}function tp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...oe(t)})}function rp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...oe(t)})}function np(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...oe(t)})}function op(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...oe(t)})}function ap(e,t){return new e({type:"string",format:"date",check:"string_format",...oe(t)})}function sp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...oe(t)})}function ip(e,t){return new e({type:"string",format:"duration",check:"string_format",...oe(t)})}function lp(e,t){return new e({type:"number",checks:[],...oe(t)})}function cp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...oe(t)})}function up(e){return new e({type:"unknown"})}function dp(e,t){return new e({type:"never",...oe(t)})}function No(e,t){return new Ua({check:"less_than",...oe(t),value:e,inclusive:!1})}function gn(e,t){return new Ua({check:"less_than",...oe(t),value:e,inclusive:!0})}function To(e,t){return new Ba({check:"greater_than",...oe(t),value:e,inclusive:!1})}function bn(e,t){return new Ba({check:"greater_than",...oe(t),value:e,inclusive:!0})}function Io(e,t){return new Dd({check:"multiple_of",...oe(t),value:e})}function Ya(e,t){return new Pd({check:"max_length",...oe(t),maximum:e})}function sn(e,t){return new Cd({check:"min_length",...oe(t),minimum:e})}function Xa(e,t){return new Od({check:"length_equals",...oe(t),length:e})}function fp(e,t){return new Nd({check:"string_format",format:"regex",...oe(t),pattern:e})}function pp(e){return new Td({check:"string_format",format:"lowercase",...oe(e)})}function vp(e){return new Id({check:"string_format",format:"uppercase",...oe(e)})}function mp(e,t){return new Zd({check:"string_format",format:"includes",...oe(t),includes:e})}function hp(e,t){return new Rd({check:"string_format",format:"starts_with",...oe(t),prefix:e})}function gp(e,t){return new jd({check:"string_format",format:"ends_with",...oe(t),suffix:e})}function yr(e){return new Ld({check:"overwrite",tx:e})}function bp(e){return yr(t=>t.normalize(e))}function _p(){return yr(e=>e.trim())}function yp(){return yr(e=>e.toLowerCase())}function xp(){return yr(e=>e.toUpperCase())}function wp(){return yr(e=>Nu(e))}function $p(e,t,r){return new e({type:"array",element:t,...oe(r)})}function Ep(e,t,r){return new e({type:"custom",check:"custom",fn:t,...oe(r)})}function Sp(e){const t=kp(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Lr(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(Lr(o))}},e(r.value,r)));return t}function kp(e,t){const r=new rt({check:"custom",...oe(t)});return r._zod.check=e,r}function Qa(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??zr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Fe(e,t,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;const s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);const i=e._zod.toJSONSchema?.();if(i)s.schema=i;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const p=s.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,p,u)}const m=e._zod.parent;m&&(s.ref||(s.ref=m),Fe(m,t,u),t.seen.get(m).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),t.io==="input"&&Ve(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function es(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const s of e.seen.entries()){const i=e.metadataRegistry.get(s[0])?.id;if(i){const l=n.get(i);if(l&&l!==s[0])throw new Error(`Duplicate schema id "${i}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(i,s[0])}}const o=s=>{const i=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const m=e.external.registry.get(s[0])?.id,p=e.external.uri??(g=>g);if(m)return{ref:p(m)};const h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${p("__shared")}#/${i}/${h}`}}if(s[1]===r)return{ref:"#"};const c=`#/${i}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},a=s=>{if(s[1].schema.$ref)return;const i=s[1],{ref:l,defId:c}=o(s);i.def={...i.schema},c&&(i.defId=c);const u=i.schema;for(const m in u)delete u[m];u.$ref=l};if(e.cycles==="throw")for(const s of e.seen.entries()){const i=s[1];if(i.cycle)throw new Error(`Cycle detected: #/${i.cycle?.join("/")}/ + +Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const i=s[1];if(t===s[0]){a(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){a(s);continue}}if(e.metadataRegistry.get(s[0])?.id){a(s);continue}if(i.cycle){a(s);continue}if(i.count>1&&e.reused==="ref"){a(s);continue}}}function ts(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=s=>{const i=e.seen.get(s);if(i.ref===null)return;const l=i.def??i.schema,c={...l},u=i.ref;if(i.ref=null,u){n(u);const p=e.seen.get(u),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(h)):Object.assign(l,h),Object.assign(l,c),s._zod.parent===u)for(const _ in l)_==="$ref"||_==="allOf"||_ in c||delete l[_];if(h.$ref&&p.def)for(const _ in l)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(l[_])===JSON.stringify(p.def[_])&&delete l[_]}const m=s._zod.parent;if(m&&m!==u){n(m);const p=e.seen.get(m);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(const h in l)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(l[h])===JSON.stringify(p.def[h])&&delete l[h]}e.override({zodSchema:s,jsonSchema:l,path:i.path??[]})};for(const s of[...e.seen.entries()].reverse())n(s[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,r.def??r.schema);const a=e.external?.defs??{};for(const s of e.seen.entries()){const i=s[1];i.def&&i.defId&&(a[i.defId]=i.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:ln(t,"input",e.processors),output:ln(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Ve(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ve(n.element,r);if(n.type==="set")return Ve(n.valueType,r);if(n.type==="lazy")return Ve(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ve(n.innerType,r);if(n.type==="intersection")return Ve(n.left,r)||Ve(n.right,r);if(n.type==="record"||n.type==="map")return Ve(n.keyType,r)||Ve(n.valueType,r);if(n.type==="pipe")return Ve(n.in,r)||Ve(n.out,r);if(n.type==="object"){for(const o in n.shape)if(Ve(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(Ve(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(Ve(o,r))return!0;return!!(n.rest&&Ve(n.rest,r))}return!1}const zp=(e,t={})=>r=>{const n=Qa({...r,processors:t});return Fe(e,n),es(n,e),ts(n,e)},ln=(e,t,r={})=>n=>{const{libraryOptions:o,target:a}=n??{},s=Qa({...o??{},target:a,io:t,processors:r});return Fe(e,s),es(s,e),ts(s,e)},Dp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ap=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:a,maximum:s,format:i,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof a=="number"&&(o.minLength=a),typeof s=="number"&&(o.maxLength=s),i&&(o.format=Dp[i]??i,o.format===""&&delete o.format,i==="time"&&delete o.format),c&&(o.contentEncoding=c),l&&l.size>0){const u=[...l];u.length===1?o.pattern=u[0].source:u.length>1&&(o.allOf=[...u.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Pp=(e,t,r,n)=>{const o=r,{minimum:a,maximum:s,format:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;typeof i=="string"&&i.includes("int")?o.type="integer":o.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u),typeof a=="number"&&(o.minimum=a,typeof u=="number"&&t.target!=="draft-04"&&(u>=a?delete o.minimum:delete o.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c),typeof s=="number"&&(o.maximum=s,typeof c=="number"&&t.target!=="draft-04"&&(c<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof l=="number"&&(o.multipleOf=l)},Cp=(e,t,r,n)=>{r.not={}},Op=(e,t,r,n)=>{},Np=(e,t,r,n)=>{const o=e._zod.def,a=Na(o.entries);a.every(s=>typeof s=="number")&&(r.type="number"),a.every(s=>typeof s=="string")&&(r.type="string"),r.enum=a},Tp=(e,t,r,n)=>{const o=e._zod.def,a=[];for(const s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(s))}else a.push(s);if(a.length!==0)if(a.length===1){const s=a[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else a.every(s=>typeof s=="number")&&(r.type="number"),a.every(s=>typeof s=="string")&&(r.type="string"),a.every(s=>typeof s=="boolean")&&(r.type="boolean"),a.every(s=>s===null)&&(r.type="null"),r.enum=a},Ip=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Zp=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Rp=(e,t,r,n)=>{const o=r,a=e._zod.def,{minimum:s,maximum:i}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof i=="number"&&(o.maxItems=i),o.type="array",o.items=Fe(a.element,t,{...n,path:[...n.path,"items"]})},jp=(e,t,r,n)=>{const o=r,a=e._zod.def;o.type="object",o.properties={};const s=a.shape;for(const c in s)o.properties[c]=Fe(s[c],t,{...n,path:[...n.path,"properties",c]});const i=new Set(Object.keys(s)),l=new Set([...i].filter(c=>{const u=a.shape[c]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));l.size>0&&(o.required=Array.from(l)),a.catchall?._zod.def.type==="never"?o.additionalProperties=!1:a.catchall?a.catchall&&(o.additionalProperties=Fe(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Lp=(e,t,r,n)=>{const o=e._zod.def,a=o.inclusive===!1,s=o.options.map((i,l)=>Fe(i,t,{...n,path:[...n.path,a?"oneOf":"anyOf",l]}));a?r.oneOf=s:r.anyOf=s},Fp=(e,t,r,n)=>{const o=e._zod.def,a=Fe(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=Fe(o.right,t,{...n,path:[...n.path,"allOf",1]}),i=c=>"allOf"in c&&Object.keys(c).length===1,l=[...i(a)?a.allOf:[a],...i(s)?s.allOf:[s]];r.allOf=l},Mp=(e,t,r,n)=>{const o=e._zod.def,a=Fe(o.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},Vp=(e,t,r,n)=>{const o=e._zod.def;Fe(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType},qp=(e,t,r,n)=>{const o=e._zod.def;Fe(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Up=(e,t,r,n)=>{const o=e._zod.def;Fe(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Bp=(e,t,r,n)=>{const o=e._zod.def;Fe(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Jp=(e,t,r,n)=>{const o=e._zod.def,a=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Fe(a,t,n);const s=t.seen.get(e);s.ref=a},Wp=(e,t,r,n)=>{const o=e._zod.def;Fe(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType,r.readOnly=!0},rs=(e,t,r,n)=>{const o=e._zod.def;Fe(o.innerType,t,n);const a=t.seen.get(e);a.ref=o.innerType},Kp=E("ZodISODateTime",(e,t)=>{Qd.init(e,t),Se.init(e,t)});function Hp(e){return op(Kp,e)}const Gp=E("ZodISODate",(e,t)=>{ef.init(e,t),Se.init(e,t)});function Yp(e){return ap(Gp,e)}const Xp=E("ZodISOTime",(e,t)=>{tf.init(e,t),Se.init(e,t)});function Qp(e){return sp(Xp,e)}const ev=E("ZodISODuration",(e,t)=>{rf.init(e,t),Se.init(e,t)});function tv(e){return ip(ev,e)}const rv=(e,t)=>{ja.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Ju(e,r)},flatten:{value:r=>Bu(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,An,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,An,2)}},isEmpty:{get(){return e.issues.length===0}}})},pt=E("ZodError",rv,{Parent:Error}),nv=eo(pt),ov=to(pt),av=dn(pt),sv=fn(pt),iv=Hu(pt),lv=Gu(pt),cv=Yu(pt),uv=Xu(pt),dv=Qu(pt),fv=ed(pt),pv=td(pt),vv=rd(pt),ze=E("ZodType",(e,t)=>(ke.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ln(e,"input"),output:ln(e,"output")}}),e.toJSONSchema=zp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(Rt(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>jt(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>nv(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>av(e,r,n),e.parseAsync=async(r,n)=>ov(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>sv(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>iv(e,r,n),e.decode=(r,n)=>lv(e,r,n),e.encodeAsync=async(r,n)=>cv(e,r,n),e.decodeAsync=async(r,n)=>uv(e,r,n),e.safeEncode=(r,n)=>dv(e,r,n),e.safeDecode=(r,n)=>fv(e,r,n),e.safeEncodeAsync=async(r,n)=>pv(e,r,n),e.safeDecodeAsync=async(r,n)=>vv(e,r,n),e.refine=(r,n)=>e.check(dm(r,n)),e.superRefine=r=>e.check(fm(r)),e.overwrite=r=>e.check(yr(r)),e.optional=()=>Lo(e),e.exactOptional=()=>Xv(e),e.nullable=()=>Fo(e),e.nullish=()=>Lo(Fo(e)),e.nonoptional=r=>om(e,r),e.array=()=>Lv(e),e.or=r=>qv([e,r]),e.and=r=>Bv(e,r),e.transform=r=>Mo(e,Gv(r)),e.default=r=>tm(e,r),e.prefault=r=>nm(e,r),e.catch=r=>sm(e,r),e.pipe=r=>Mo(e,r),e.readonly=()=>cm(e),e.describe=r=>{const n=e.clone();return zr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return zr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return zr.get(e);const n=e.clone();return zr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),ns=E("_ZodString",(e,t)=>{ro.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,o,a)=>Ap(e,n,o);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(fp(...n)),e.includes=(...n)=>e.check(mp(...n)),e.startsWith=(...n)=>e.check(hp(...n)),e.endsWith=(...n)=>e.check(gp(...n)),e.min=(...n)=>e.check(sn(...n)),e.max=(...n)=>e.check(Ya(...n)),e.length=(...n)=>e.check(Xa(...n)),e.nonempty=(...n)=>e.check(sn(1,...n)),e.lowercase=n=>e.check(pp(n)),e.uppercase=n=>e.check(vp(n)),e.trim=()=>e.check(_p()),e.normalize=(...n)=>e.check(bp(...n)),e.toLowerCase=()=>e.check(yp()),e.toUpperCase=()=>e.check(xp()),e.slugify=()=>e.check(wp())}),mv=E("ZodString",(e,t)=>{ro.init(e,t),ns.init(e,t),e.email=r=>e.check(Rf(hv,r)),e.url=r=>e.check(Vf(gv,r)),e.jwt=r=>e.check(np(Ov,r)),e.emoji=r=>e.check(qf(bv,r)),e.guid=r=>e.check(Oo(Zo,r)),e.uuid=r=>e.check(jf(Yr,r)),e.uuidv4=r=>e.check(Lf(Yr,r)),e.uuidv6=r=>e.check(Ff(Yr,r)),e.uuidv7=r=>e.check(Mf(Yr,r)),e.nanoid=r=>e.check(Uf(_v,r)),e.guid=r=>e.check(Oo(Zo,r)),e.cuid=r=>e.check(Bf(yv,r)),e.cuid2=r=>e.check(Jf(xv,r)),e.ulid=r=>e.check(Wf(wv,r)),e.base64=r=>e.check(ep(Av,r)),e.base64url=r=>e.check(tp(Pv,r)),e.xid=r=>e.check(Kf($v,r)),e.ksuid=r=>e.check(Hf(Ev,r)),e.ipv4=r=>e.check(Gf(Sv,r)),e.ipv6=r=>e.check(Yf(kv,r)),e.cidrv4=r=>e.check(Xf(zv,r)),e.cidrv6=r=>e.check(Qf(Dv,r)),e.e164=r=>e.check(rp(Cv,r)),e.datetime=r=>e.check(Hp(r)),e.date=r=>e.check(Yp(r)),e.time=r=>e.check(Qp(r)),e.duration=r=>e.check(tv(r))});function Gr(e){return Zf(mv,e)}const Se=E("ZodStringFormat",(e,t)=>{$e.init(e,t),ns.init(e,t)}),hv=E("ZodEmail",(e,t)=>{Ud.init(e,t),Se.init(e,t)}),Zo=E("ZodGUID",(e,t)=>{Vd.init(e,t),Se.init(e,t)}),Yr=E("ZodUUID",(e,t)=>{qd.init(e,t),Se.init(e,t)}),gv=E("ZodURL",(e,t)=>{Bd.init(e,t),Se.init(e,t)}),bv=E("ZodEmoji",(e,t)=>{Jd.init(e,t),Se.init(e,t)}),_v=E("ZodNanoID",(e,t)=>{Wd.init(e,t),Se.init(e,t)}),yv=E("ZodCUID",(e,t)=>{Kd.init(e,t),Se.init(e,t)}),xv=E("ZodCUID2",(e,t)=>{Hd.init(e,t),Se.init(e,t)}),wv=E("ZodULID",(e,t)=>{Gd.init(e,t),Se.init(e,t)}),$v=E("ZodXID",(e,t)=>{Yd.init(e,t),Se.init(e,t)}),Ev=E("ZodKSUID",(e,t)=>{Xd.init(e,t),Se.init(e,t)}),Sv=E("ZodIPv4",(e,t)=>{nf.init(e,t),Se.init(e,t)}),kv=E("ZodIPv6",(e,t)=>{of.init(e,t),Se.init(e,t)}),zv=E("ZodCIDRv4",(e,t)=>{af.init(e,t),Se.init(e,t)}),Dv=E("ZodCIDRv6",(e,t)=>{sf.init(e,t),Se.init(e,t)}),Av=E("ZodBase64",(e,t)=>{lf.init(e,t),Se.init(e,t)}),Pv=E("ZodBase64URL",(e,t)=>{uf.init(e,t),Se.init(e,t)}),Cv=E("ZodE164",(e,t)=>{df.init(e,t),Se.init(e,t)}),Ov=E("ZodJWT",(e,t)=>{pf.init(e,t),Se.init(e,t)}),os=E("ZodNumber",(e,t)=>{Wa.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,o,a)=>Pp(e,n,o),e.gt=(n,o)=>e.check(To(n,o)),e.gte=(n,o)=>e.check(bn(n,o)),e.min=(n,o)=>e.check(bn(n,o)),e.lt=(n,o)=>e.check(No(n,o)),e.lte=(n,o)=>e.check(gn(n,o)),e.max=(n,o)=>e.check(gn(n,o)),e.int=n=>e.check(Ro(n)),e.safe=n=>e.check(Ro(n)),e.positive=n=>e.check(To(0,n)),e.nonnegative=n=>e.check(bn(0,n)),e.negative=n=>e.check(No(0,n)),e.nonpositive=n=>e.check(gn(0,n)),e.multipleOf=(n,o)=>e.check(Io(n,o)),e.step=(n,o)=>e.check(Io(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Nv(e){return lp(os,e)}const Tv=E("ZodNumberFormat",(e,t)=>{vf.init(e,t),os.init(e,t)});function Ro(e){return cp(Tv,e)}const Iv=E("ZodUnknown",(e,t)=>{mf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Op()});function jo(){return up(Iv)}const Zv=E("ZodNever",(e,t)=>{hf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Cp(e,r,n)});function Rv(e){return dp(Zv,e)}const jv=E("ZodArray",(e,t)=>{gf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rp(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(sn(r,n)),e.nonempty=r=>e.check(sn(1,r)),e.max=(r,n)=>e.check(Ya(r,n)),e.length=(r,n)=>e.check(Xa(r,n)),e.unwrap=()=>e.element});function Lv(e,t){return $p(jv,e,t)}const Fv=E("ZodObject",(e,t)=>{_f.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>jp(e,r,n,o),_e(e,"shape",()=>t.shape),e.keyof=()=>Jv(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:jo()}),e.loose=()=>e.clone({...e._zod.def,catchall:jo()}),e.strict=()=>e.clone({...e._zod.def,catchall:Rv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Fu(e,r),e.safeExtend=r=>Mu(e,r),e.merge=r=>Vu(e,r),e.pick=r=>ju(e,r),e.omit=r=>Lu(e,r),e.partial=(...r)=>qu(as,e,r[0]),e.required=(...r)=>Uu(ss,e,r[0])});function Mv(e,t){const r={type:"object",shape:e??{},...oe(t)};return new Fv(r)}const Vv=E("ZodUnion",(e,t)=>{yf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Lp(e,r,n,o),e.options=t.options});function qv(e,t){return new Vv({type:"union",options:e,...oe(t)})}const Uv=E("ZodIntersection",(e,t)=>{xf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fp(e,r,n,o)});function Bv(e,t){return new Uv({type:"intersection",left:e,right:t})}const Cn=E("ZodEnum",(e,t)=>{wf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,o,a)=>Np(e,n,o),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const a={};for(const s of n)if(r.has(s))a[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Cn({...t,checks:[],...oe(o),entries:a})},e.exclude=(n,o)=>{const a={...t.entries};for(const s of n)if(r.has(s))delete a[s];else throw new Error(`Key ${s} not found in enum`);return new Cn({...t,checks:[],...oe(o),entries:a})}});function Jv(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Cn({type:"enum",entries:r,...oe(t)})}const Wv=E("ZodLiteral",(e,t)=>{$f.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tp(e,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Kv(e,t){return new Wv({type:"literal",values:Array.isArray(e)?e:[e],...oe(t)})}const Hv=E("ZodTransform",(e,t)=>{Ef.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zp(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ca(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(Lr(a,r.value,t));else{const s=a;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(Lr(s))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(a=>(r.value=a,r)):(r.value=o,r)}});function Gv(e){return new Hv({type:"transform",transform:e})}const as=E("ZodOptional",(e,t)=>{Ga.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Lo(e){return new as({type:"optional",innerType:e})}const Yv=E("ZodExactOptional",(e,t)=>{Sf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Xv(e){return new Yv({type:"optional",innerType:e})}const Qv=E("ZodNullable",(e,t)=>{kf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Fo(e){return new Qv({type:"nullable",innerType:e})}const em=E("ZodDefault",(e,t)=>{zf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tm(e,t){return new em({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ia(t)}})}const rm=E("ZodPrefault",(e,t)=>{Df.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Up(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nm(e,t){return new rm({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ia(t)}})}const ss=E("ZodNonOptional",(e,t)=>{Af.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function om(e,t){return new ss({type:"nonoptional",innerType:e,...oe(t)})}const am=E("ZodCatch",(e,t)=>{Pf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sm(e,t){return new am({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const im=E("ZodPipe",(e,t)=>{Cf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jp(e,r,n,o),e.in=t.in,e.out=t.out});function Mo(e,t){return new im({type:"pipe",in:e,out:t})}const lm=E("ZodReadonly",(e,t)=>{Of.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function cm(e){return new lm({type:"readonly",innerType:e})}const um=E("ZodCustom",(e,t)=>{Nf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ip(e,r)});function dm(e,t={}){return Ep(um,e,t)}function fm(e){return Sp(e)}var pm=k('
                            ',1),vm=k(" ",1);function mm(e,t){Ne(t,!0);const r=()=>ee(x,"$hasErrors",s),n=()=>ee(J,"$isDirty",s),o=()=>ee(b,"$errors",s),a=()=>ee(A,"$isDirtyByField",s),[s,i]=Ue(),l=Mv({username:Gr().min(3).max(20).regex(/^\S+$/,"Must not contain spaces"),email:Gr().min(1,"Required").email(),age:Nv().int().min(18).max(120),website:Gr().url().optional().or(Kv("")),bio:Gr().max(200).optional()});function c(P,L,z){const F=P.safeParse(L);if(F.success)return Object.fromEntries(z.map(I=>[I,""]));const q={};for(const I of F.error.issues){const N=String(I.path[0]);q[N]||(q[N]=I.message)}return Object.fromEntries(z.map(I=>[I,q[I]??""]))}const u=l.pick({username:!0,email:!0,age:!0,website:!0}),m=Object.keys(u.shape),p=[...m,"bio"],h={username:{label:"Username",placeholder:"Enter username",type:"text"},email:{label:"Email",placeholder:"Enter email",type:"email"},age:{label:"Age",placeholder:"Enter age",type:"number"},website:{label:"Website",placeholder:"https://example.com",type:"text"}},g={username:"",email:"",age:0,website:"",bio:""},{data:_,state:{errors:b,hasErrors:x,isDirty:J,isDirtyByField:A}}=Be(g,{validator:P=>c(l,P,p)}),D=()=>{_.username=`user${ce()}`,_.email=`${ce()}@example.com`,_.age=lt(18,65),_.bio="Hello, I am a demo user!",_.website=`https://${ce()}.com`},R=String.raw`import { z } from 'zod'; + +const userSchema = z.object({ + username: z.string().min(3).max(20).regex(/^\S+$/, 'Must not contain spaces'), + email: z.string().min(1, 'Required').email(), + age: z.number().int().min(18).max(120), + website: z.string().url().optional().or(z.literal('')), + bio: z.string().max(200).optional() +});`,H=`function zodToSvstateErrors(schema, source, fields) { + const result = schema.safeParse(source); + if (result.success) + return Object.fromEntries(fields.map(f => [f, ''])); + + const errorMap = {}; + for (const issue of result.error.issues) { + const key = String(issue.path[0]); + if (!errorMap[key]) errorMap[key] = issue.message; + } + return Object.fromEntries( + fields.map(f => [f, errorMap[f] ?? '']) + ); +} + +const { data, state: { errors, hasErrors } } = createSvState(sourceData, { + validator: (source) => zodToSvstateErrors(userSchema, source, allFields) +});`,T=`// Pick a subset of fields for dynamic rendering +const pickedSchema = userSchema.pick({ username: true, email: true, age: true, website: true }); +const dynamicFields = Object.keys(pickedSchema.shape); + +const fieldMeta = { + username: { label: 'Username', placeholder: 'Enter username', type: 'text' }, + email: { label: 'Email', placeholder: 'Enter email', type: 'email' }, + age: { label: 'Age', placeholder: 'Enter age', type: 'number' }, + website: { label: 'Website', placeholder: 'https://...', type: 'text' }, +}; + +// In template: +{#each dynamicFields as field} + +{/each} + + +`;We(e,{description:"Demonstrates using Zod schemas for validation with svstate, including dynamic form rendering via z.pick() shape keys.",title:"Zod Integration Demo",main:F=>{var q=pm(),I=de(q);He(I,{get hasErrors(){return r()},get isDirty(){return n()}});var N=d(I,2),M=f(N);zt(M,16,()=>m,W=>W,(W,K)=>{const V=te(()=>h[K]);{let w=te(()=>o()?.[K]),B=te(()=>K!=="website");le(W,{get id(){return K},get error(){return v(w)},get isDirty(){return a()[K]},get label(){return v(V).label},get placeholder(){return v(V).placeholder},get required(){return v(B)},get type(){return v(V).type},get value(){return _[K]},set value(Y){_[K]=Y}})}});var j=d(M,2);{let W=te(()=>o()?.bio);rr(j,{id:"bio",get error(){return v(W)},get isDirty(){return a().bio},label:"Bio",placeholder:"Tell us about yourself (not in pick subset)",get value(){return _.bio},set value(K){_.bio=K}})}$(F,q)},sidebar:F=>{Je(F,{get data(){return _},get errors(){return o()},get hasErrors(){return r()},get isDirty(){return n()},get isDirtyByField(){return a()},onFill:D})},sourceCode:F=>{Ke(F,{children:(q,I)=>{var N=vm(),M=de(N);pe(M,{get code(){return R},title:"Zod Schema Definition"});var j=d(M,2);pe(j,{code:H,title:"Bridge Function (Zod → svstate)"});var W=d(j,2);pe(W,{code:T,title:"Dynamic Rendering via z.pick()"}),$(q,N)}})}}),Te(),i()}var hm=k(""),gm=k(`
                            svstate logo

                            svstate

                            A Svelte 5 library that provides a supercharged $state() with deep reactive proxies, validation, snapshot/undo, + and side effects — built for complex, real-world applications.

                            $ npm i svstate
                            `);function bm(e){const t=[{value:"basic-validation",name:"Basic Validation"},{value:"nested-objects",name:"Nested Objects"},{value:"array-property",name:"Array Property"},{value:"calculated-fields",name:"Calculated Fields"},{value:"calculated-class",name:"State with Methods"},{value:"reset-demo",name:"Reset"},{value:"snapshot-demo",name:"Snapshot & Rollback"},{value:"action-demo",name:"Action & Error"},{value:"async-validation",name:"Async Validation"},{value:"options-demo",name:"Options"},{value:"zod-validation",name:"Zod Integration"},{value:"plugin-devtools",name:"Plugin: Devtools"},{value:"plugin-persist-sync",name:"Plugin: Persist & Sync"},{value:"plugin-undo-redo",name:"Plugin: Undo/Redo"},{value:"plugin-autosave-analytics",name:"Plugin: Autosave & Analytics"}];let r=we("basic-validation");const n="1.5.1",o="/svstate";var a=gm(),s=f(a),i=f(s),l=d(i,2),c=f(l),u=d(f(c),2),m=f(u),p=d(c,4),h=d(f(p),4),g=d(p,2),_=d(s,2),b=f(_),x=f(b),J=d(f(x),2);zt(J,21,()=>t,Ir,(w,B)=>{var Y=hm(),X=f(Y),Q={};ae(()=>{G(X,v(B).name),Q!==(Q=v(B).value)&&(Y.value=(Y.__value=v(B).value)??"")}),$(w,Y)});var A=d(b,2),D=f(A);{var R=w=>{lc(w,{})},H=w=>{zc(w,{})},T=w=>{Hl(w,{})},P=w=>{hc(w,{})},L=w=>{pc(w,{})},z=w=>{$u(w,{})},F=w=>{Cu(w,{})},q=w=>{Ll(w,{})},I=w=>{nc(w,{})},N=w=>{Ic(w,{})},M=w=>{mm(w,{})},j=w=>{tu(w,{})},W=w=>{lu(w,{})},K=w=>{_u(w,{})},V=w=>{Wc(w,{})};se(D,w=>{v(r)==="basic-validation"?w(R):v(r)==="nested-objects"?w(H,1):v(r)==="array-property"?w(T,2):v(r)==="calculated-fields"?w(P,3):v(r)==="calculated-class"?w(L,4):v(r)==="reset-demo"?w(z,5):v(r)==="snapshot-demo"?w(F,6):v(r)==="action-demo"?w(q,7):v(r)==="async-validation"?w(I,8):v(r)==="options-demo"?w(N,9):v(r)==="zod-validation"?w(M,10):v(r)==="plugin-devtools"?w(j,11):v(r)==="plugin-persist-sync"?w(W,12):v(r)==="plugin-undo-redo"?w(K,13):v(r)==="plugin-autosave-analytics"&&w(V,14)})}ae(()=>{Le(i,"src",`${o}/favicon.png`),G(m,`v${n}`),Le(g,"href",`${o}/llms.txt`)}),ye("click",h,()=>navigator.clipboard.writeText(`npm i svstate@${n}`)),un(J,()=>v(r),w=>me(r,w)),$(e,a)}tt(["click"]);Ti(bm,{target:document.querySelector("#app")}); diff --git a/docs/index.html b/docs/index.html index 8536d0f..6fea746 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ svstate demo - + diff --git a/package-lock.json b/package-lock.json index 44ef971..8ec9e2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "svstate", - "version": "1.5.0", + "version": "1.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "svstate", - "version": "1.5.0", + "version": "1.5.1", "license": "ISC", "devDependencies": { "@eslint/eslintrc": "^3.3.5", diff --git a/package.json b/package.json index 6bf7a3a..fd9a9c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svstate", - "version": "1.5.0", + "version": "1.5.1", "description": "Supercharged $state() for Svelte 5: deep reactive proxy with validation, cross-field rules, computed & side-effects", "author": "BCsabaEngine", "license": "ISC",