import { type Readable, type Writable } from 'svelte/store'; /** Union type representing either a Readable or Writable Svelte store. */ export type ReadOrWritable = Readable | Writable; /** * Type guard that checks if a value is a Svelte Readable store. * * @template T - The type of the store's value. * @param value - The value to check. * @returns True if the value has a subscribe method. * @example * ```typescript * if (isReadable(maybeStore)) { * maybeStore.subscribe(value => console.log(value)) * } * ``` */ export declare const isReadable: (value: any) => value is Readable; /** * Type guard that checks if a value is a Svelte Writable store. * * @template T - The type of the store's value. * @param store - The value to check. * @returns True if the value has both update and set methods. * @example * ```typescript * if (isWritable(maybeStore)) { * maybeStore.set(newValue) * } * ``` */ export declare const isWritable: (store: any) => store is Writable; /** * Maps each key of T to a Writable store containing that key's value type. * @template T - The object type to map. */ export type WritableKeys = { [K in keyof T]: T[K] extends undefined ? Writable : Writable; }; /** * Maps each key of T to a Readable store containing that key's value type. * @template T - The object type to map. */ export type ReadableKeys = { [K in keyof T]: T[K] extends undefined ? Readable : Readable; }; /** * Maps each key of T to either a Readable or Writable store. * @template T - The object type to map. */ export type ReadOrWritableKeys = { [K in keyof T]: T[K] extends undefined ? ReadOrWritable : ReadOrWritable; }; /** A readable store that always contains undefined. */ export declare const Undefined: Readable; /** * Returns the Undefined store typed as a Readable of type T. * Useful for providing a default store value. * * @template T - The type to cast the undefined store to. * @returns A Readable store typed as Readable. */ export declare const UndefinedAs: () => Readable; /** * Options for toggle operations in set stores. */ export interface ToggleOptions { /** If true, removes all other items when toggling an item on. */ clearOthers?: boolean; } /** * Configuration options for creating an ArraySetStore. * @template T - The type of elements in the array. */ export interface ArraySetStoreOptions { /** Custom equality function for comparing items. Defaults to strict equality. */ isEqual?: (_a: T, _b: T) => boolean; } /** * A Svelte store that maintains a unique set of items as an array. * Extends Writable with set-like operations. * * @template T - The type of elements in the set. */ export interface ArraySetStore extends Writable { /** Toggles an item in the set (adds if absent, removes if present). */ toggle: (_item: T, _options?: ToggleOptions) => void; /** Adds an item to the set if not already present. */ add: (_item: T) => void; /** Removes an item from the set if present. */ remove: (_item: T) => void; /** Removes all items from the set. */ clear: () => void; } /** * Creates a Svelte store that maintains a unique set of items as an array. * Supports toggle, add, remove, and clear operations. * * @template T - The type of elements in the set. * @param initial - The initial array of items. * @param options - Configuration options including custom equality function. * @returns An ArraySetStore with set-like operations. * @example * ```typescript * const selectedIds = arraySetStore(['id1']) * selectedIds.toggle('id2') // Adds 'id2' * selectedIds.toggle('id1') // Removes 'id1' * ``` */ export declare const arraySetStore: (initial?: T[], { isEqual }?: ArraySetStoreOptions) => ArraySetStore; /** * A Svelte store that maintains a set using a Record with boolean values. * More efficient for string/number keys than ArraySetStore. * * @template T - The type of keys (must be string or number). */ export interface RecordSetStore extends Writable> { /** Toggles a key in the set (adds if absent, removes if present). */ toggle: (_item: T) => void; /** Adds a key to the set. */ add: (_item: T) => void; /** Adds multiple keys to the set. */ addAll: (_items: T[]) => void; /** Removes a key from the set. */ remove: (_item: T) => void; /** Removes multiple keys from the set. */ removeAll: (_items: T[]) => void; /** Removes all keys from the set. */ clear: () => void; } /** * Creates a Svelte store that maintains a set using a Record with boolean values. * False values are automatically removed to keep the record clean. * * @template T - The type of keys (must be string or number). * @param initial - The initial record of key-boolean pairs. * @returns A RecordSetStore with set-like operations. * @example * ```typescript * const expandedIds = recordSetStore({ row1: true }) * expandedIds.toggle('row2') // Adds 'row2' * expandedIds.toggle('row1') // Removes 'row1' * ``` */ export declare const recordSetStore: (initial?: Record) => RecordSetStore;