{"version":3,"file":"ngx-signal-plus.mjs","sources":["../../../projects/signal-plus/src/lib/utils/platform.ts","../../../projects/signal-plus/src/lib/core/signal-builder.ts","../../../projects/signal-plus/src/lib/utils/create.ts","../../../projects/signal-plus/src/lib/utils/enhance.ts","../../../projects/signal-plus/src/lib/utils/presets.ts","../../../projects/signal-plus/src/lib/core/signal-plus.service.ts","../../../projects/signal-plus/src/lib/core/signal-plus.component.ts","../../../projects/signal-plus/src/lib/core/index.ts","../../../projects/signal-plus/src/lib/operators/signal-operators.ts","../../../projects/signal-plus/src/lib/operators/index.ts","../../../projects/signal-plus/src/lib/managers/history-manager.ts","../../../projects/signal-plus/src/lib/managers/storage-manager.ts","../../../projects/signal-plus/src/lib/managers/index.ts","../../../projects/signal-plus/src/lib/utils/transactions.ts","../../../projects/signal-plus/src/lib/utils/index.ts","../../../projects/signal-plus/src/public-api.ts","../../../projects/signal-plus/src/ngx-signal-plus.ts"],"sourcesContent":["/**\r\n * @fileoverview Platform detection utilities for SSR compatibility\r\n * @description Provides utilities to check if code is running in a browser environment\r\n * \r\n * This is critical for Server-Side Rendering (SSR) compatibility with Angular Universal.\r\n * Browser APIs like window, localStorage, and document are not available during SSR.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { isBrowser } from './platform';\r\n * \r\n * if (isBrowser()) {\r\n *   localStorage.setItem('key', 'value');\r\n * }\r\n * ```\r\n */\r\n\r\n/**\r\n * Checks if the code is running in a browser environment\r\n * \r\n * @returns True if running in browser, false otherwise (e.g., Node.js/SSR)\r\n * \r\n * @remarks\r\n * This function checks for the existence of browser-specific global objects.\r\n * It's safe to call during SSR as it doesn't attempt to access these objects,\r\n * only checks for their existence.\r\n * \r\n * Use this before accessing any browser-specific APIs:\r\n * - window\r\n * - localStorage\r\n * - sessionStorage\r\n * - document\r\n * - navigator\r\n * \r\n * @example Basic Usage\r\n * ```typescript\r\n * if (isBrowser()) {\r\n *   const stored = localStorage.getItem('key');\r\n * }\r\n * ```\r\n * \r\n * @example With Angular Universal\r\n * ```typescript\r\n * // This code works in both SSR and browser\r\n * const value = isBrowser() \r\n *   ? localStorage.getItem('theme')\r\n *   : 'default';\r\n * ```\r\n */\r\nexport function isBrowser(): boolean {\r\n  return typeof window !== 'undefined' &&\r\n    typeof window.document !== 'undefined';\r\n}\r\n\r\n/**\r\n * Checks if localStorage is available\r\n * \r\n * @returns True if localStorage is available and working\r\n * \r\n * @remarks\r\n * This checks not only for browser environment but also:\r\n * - localStorage API existence\r\n * - localStorage is not disabled by user settings\r\n * - localStorage is not in private/incognito mode with quota exceeded\r\n * \r\n * @example Safe Storage Access\r\n * ```typescript\r\n * if (hasLocalStorage()) {\r\n *   localStorage.setItem('key', 'value');\r\n * } else {\r\n *   // Fallback to memory storage\r\n * }\r\n * ```\r\n */\r\nexport function hasLocalStorage(): boolean {\r\n  if (!isBrowser()) {\r\n    return false;\r\n  }\r\n\r\n  try {\r\n    const testKey = '__ngx_signal_plus_test__';\r\n    localStorage.setItem(testKey, 'test');\r\n    localStorage.removeItem(testKey);\r\n    return true;\r\n  } catch {\r\n    return false;\r\n  }\r\n}\r\n\r\n/**\r\n * Safely gets a value from localStorage\r\n * \r\n * @param key Storage key\r\n * @returns Stored value or null if not available/not in browser\r\n * \r\n * @remarks\r\n * This is a convenience wrapper that handles SSR gracefully.\r\n * Returns null when localStorage is not available instead of throwing.\r\n * \r\n * @example\r\n * ```typescript\r\n * const theme = safeLocalStorageGet('theme') ?? 'light';\r\n * ```\r\n */\r\nexport function safeLocalStorageGet(key: string): string | null {\r\n  if (!hasLocalStorage()) {\r\n    return null;\r\n  }\r\n\r\n  try {\r\n    return localStorage.getItem(key);\r\n  } catch {\r\n    return null;\r\n  }\r\n}\r\n\r\n/**\r\n * Safely sets a value in localStorage\r\n * \r\n * @param key Storage key\r\n * @param value Value to store\r\n * @returns True if successful, false otherwise\r\n * \r\n * @remarks\r\n * This is a convenience wrapper that handles SSR gracefully.\r\n * Returns false when localStorage is not available instead of throwing.\r\n * \r\n * **Error Handling:**\r\n * - Returns `false` for any error (QuotaExceededError, SecurityError, etc.)\r\n * - Silently handles failures without throwing\r\n * - Safe to call in SSR and browser environments\r\n * \r\n * **Common Failure Scenarios:**\r\n * - Storage quota exceeded (browser limit reached)\r\n * - Private/incognito mode with disabled storage\r\n * - SecurityError in cross-origin contexts\r\n * - SSR environment (no localStorage)\r\n * \r\n * @example\r\n * ```typescript\r\n * const success = safeLocalStorageSet('theme', 'dark');\r\n * if (!success) {\r\n *   console.warn('Could not persist theme');\r\n * }\r\n * ```\r\n * \r\n * @example Handling Quota Exceeded\r\n * ```typescript\r\n * const success = safeLocalStorageSet('large-data', JSON.stringify(data));\r\n * if (!success) {\r\n *   // Fallback: use memory storage or clear old data\r\n * }\r\n * ```\r\n */\r\nexport function safeLocalStorageSet(key: string, value: string): boolean {\r\n  if (!hasLocalStorage()) {\r\n    return false;\r\n  }\r\n\r\n  try {\r\n    localStorage.setItem(key, value);\r\n    return true;\r\n  } catch (error) {\r\n    // Silently handle all localStorage errors:\r\n    // - QuotaExceededError: Storage limit reached\r\n    // - SecurityError: Access denied\r\n    // - Other errors: Invalid state, etc.\r\n    return false;\r\n  }\r\n}\r\n\r\n/**\r\n * Safely removes a value from localStorage\r\n * \r\n * @param key Storage key to remove\r\n * @returns True if successful, false otherwise\r\n * \r\n * @example\r\n * ```typescript\r\n * safeLocalStorageRemove('temp-data');\r\n * ```\r\n */\r\nexport function safeLocalStorageRemove(key: string): boolean {\r\n  if (!hasLocalStorage()) {\r\n    return false;\r\n  }\r\n\r\n  try {\r\n    localStorage.removeItem(key);\r\n    return true;\r\n  } catch {\r\n    return false;\r\n  }\r\n}\r\n\r\n/**\r\n * Safe wrapper for setTimeout that works in SSR\r\n * \r\n * @param callback Function to execute\r\n * @param ms Delay in milliseconds\r\n * @returns Timeout ID (number in browser, undefined in SSR)\r\n * \r\n * @remarks\r\n * In SSR environment, returns undefined and doesn't execute callback.\r\n * This prevents errors during SSR while maintaining browser functionality.\r\n * \r\n * @example\r\n * ```typescript\r\n * const timeoutId = safeSetTimeout(() => {\r\n *   console.log('Executed in browser only');\r\n * }, 1000);\r\n * \r\n * if (timeoutId) {\r\n *   clearTimeout(timeoutId);\r\n * }\r\n * ```\r\n */\r\nexport function safeSetTimeout(callback: () => void, ms: number): number | undefined {\r\n  if (!isBrowser()) {\r\n    return undefined;\r\n  }\r\n\r\n  return window.setTimeout(callback, ms) as number;\r\n}\r\n\r\n/**\r\n * Safe wrapper for clearTimeout that works in SSR\r\n * \r\n * @param timeoutId Timeout ID to clear\r\n * \r\n * @example\r\n * ```typescript\r\n * const id = safeSetTimeout(() => {...}, 1000);\r\n * safeClearTimeout(id);\r\n * ```\r\n */\r\nexport function safeClearTimeout(timeoutId: number | undefined): void {\r\n  if (!isBrowser() || timeoutId === undefined) {\r\n    return;\r\n  }\r\n\r\n  window.clearTimeout(timeoutId);\r\n}\r\n\r\n/**\r\n * Safe wrapper for addEventListener that works in SSR\r\n * \r\n * @param event Event name\r\n * @param handler Event handler function\r\n * @returns Cleanup function, or no-op function in SSR\r\n * \r\n * @example\r\n * ```typescript\r\n * const cleanup = safeAddEventListener('storage', (event) => {\r\n *   console.log('Storage changed', event);\r\n * });\r\n * \r\n * // Later...\r\n * cleanup();\r\n * ```\r\n */\r\nexport function safeAddEventListener<K extends keyof WindowEventMap>(\r\n  event: K,\r\n  handler: (this: Window, ev: WindowEventMap[K]) => any\r\n): () => void {\r\n  if (!isBrowser()) {\r\n    return () => { }; // No-op cleanup function\r\n  }\r\n\r\n  window.addEventListener(event, handler);\r\n\r\n  return () => {\r\n    window.removeEventListener(event, handler);\r\n  };\r\n}\r\n\r\n","import { Signal, WritableSignal, computed, signal } from '@angular/core';\r\nimport { BuilderOptions, ErrorHandler, SignalPlus, Transform, Validator } from '../models/signal-plus.model';\r\nimport {\r\n    isBrowser,\r\n    safeAddEventListener,\r\n    safeClearTimeout,\r\n    safeLocalStorageGet,\r\n    safeLocalStorageSet,\r\n    safeSetTimeout\r\n} from '../utils/platform';\r\n\r\n/**\r\n * @fileoverview Builder class for creating enhanced Angular signals\r\n * Provides a fluent API for configuring signals with features like:\r\n * - Validation and transformation\r\n * - History tracking and persistence\r\n * - Error handling and cleanup\r\n * \r\n * @example\r\n * ```typescript\r\n * const signal = new SignalBuilder(0)\r\n *   .validate(x => x >= 0)\r\n *   .transform(Math.round)\r\n *   .build();\r\n * ```\r\n */\r\n\r\n/**\r\n * Builder class for creating enhanced Angular signals.\r\n * Uses a fluent API pattern for configuring signal features.\r\n * @template T The type of value managed by the signal\r\n */\r\nexport class SignalBuilder<T> {\r\n    private readonly options: BuilderOptions<T>;\r\n\r\n    /**\r\n     * Creates a new SignalBuilder instance\r\n     * @param initialValue Initial value for the signal\r\n     */\r\n    constructor(initialValue: T) {\r\n        this.options = {\r\n            initialValue,\r\n            defaultValue: initialValue,\r\n            validators: [],\r\n            transform: (value: T) => value,\r\n            distinctUntilChanged: false,\r\n            enableHistory: false,\r\n            persistHistory: false,\r\n            autoCleanup: true,\r\n            errorHandlers: []\r\n        };\r\n    }\r\n\r\n    /**\r\n     * Adds a validator function to the signal\r\n     * @param fn Function that validates the signal value\r\n     * @returns Builder instance for chaining\r\n     */\r\n    validate(fn: Validator<T>): SignalBuilder<T> {\r\n        if (!this.options.validators) {\r\n            this.options.validators = [];\r\n        }\r\n        this.options.validators.push(fn);\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * Enables skipping duplicate values\r\n     * @returns Builder instance for chaining\r\n     */\r\n    distinct(): SignalBuilder<T> {\r\n        this.options.distinctUntilChanged = true;\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * Enables history tracking for undo/redo operations\r\n     * @param sizeOrPersist Optional history size (number) or persist flag (boolean)\r\n     * @returns Builder instance for chaining\r\n     */\r\n    withHistory(sizeOrPersist?: number | boolean): SignalBuilder<T> {\r\n        this.options.enableHistory = true;\r\n\r\n        if (typeof sizeOrPersist === 'number') {\r\n            this.options.historySize = sizeOrPersist;\r\n        } else if (typeof sizeOrPersist === 'boolean') {\r\n            this.options.persistHistory = sizeOrPersist;\r\n        }\r\n\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * Enables value persistence with optional storage key\r\n     * @param key Optional storage key for persistence\r\n     * @returns Builder instance for chaining\r\n     */\r\n    persist(key?: string): SignalBuilder<T> {\r\n        this.options.storageKey = key;\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * Adds debounce time to value updates\r\n     * @param ms Debounce time in milliseconds\r\n     * @returns Builder instance for chaining\r\n     */\r\n    debounce(ms: number): SignalBuilder<T> {\r\n        this.options.debounceTime = ms;\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * Adds an error handler for signal operations\r\n     * @param handler Function to handle errors\r\n     * @returns Builder instance for chaining\r\n     */\r\n    onError(handler: ErrorHandler): SignalBuilder<T> {\r\n        if (!this.options.errorHandlers) {\r\n            this.options.errorHandlers = [];\r\n        }\r\n        this.options.errorHandlers.push(handler);\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * Transforms signal value to a different type\r\n     * @param fn Transform function from T to R\r\n     * @returns New builder instance with type R\r\n     * \r\n     * @remarks\r\n     * This method creates a new builder with the transformed type.\r\n     * Only type-agnostic options are copied (distinctUntilChanged, enableHistory,\r\n     * storageKey, debounceTime, etc.). Type-specific options like validators\r\n     * and transforms are NOT copied since they are incompatible with type R.\r\n     * \r\n     * @example\r\n     * ```typescript\r\n     * const numberSignal = new SignalBuilder(42)\r\n     *   .debounce(300)\r\n     *   .distinct();\r\n     * \r\n     * const stringSignal = numberSignal.map(n => n.toString());\r\n     * // stringSignal is SignalBuilder<string> with debounce and distinct preserved\r\n     * ```\r\n     */\r\n    map<R>(fn: (value: T) => R): SignalBuilder<R> {\r\n        const mappedValue = fn(this.options.initialValue);\r\n        const newBuilder = new SignalBuilder<R>(mappedValue);\r\n        newBuilder.options.distinctUntilChanged = this.options.distinctUntilChanged;\r\n        newBuilder.options.enableHistory = this.options.enableHistory;\r\n        newBuilder.options.historySize = this.options.historySize;\r\n        newBuilder.options.persistHistory = this.options.persistHistory;\r\n        newBuilder.options.storageKey = this.options.storageKey;\r\n        newBuilder.options.debounceTime = this.options.debounceTime;\r\n        newBuilder.options.autoCleanup = this.options.autoCleanup;\r\n\r\n        return newBuilder;\r\n    }\r\n\r\n    /**\r\n     * Filters signal updates using a predicate\r\n     * @param predicate Function that returns true to allow updates\r\n     * @returns Builder instance for chaining\r\n     */\r\n    filter(predicate: (value: T) => boolean): SignalBuilder<T> {\r\n        return this.transform((value: T) => {\r\n            if (predicate(value)) {\r\n                return value;\r\n            }\r\n            throw new Error('Filter failed');\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Adds a transform function to the signal.\r\n     * Transform functions are applied in the order they are added.\r\n     * @param fn The transform function to add\r\n     */\r\n    transform(fn: Transform<T>): SignalBuilder<T> {\r\n        // Initialize transforms array if needed\r\n        if (!this.options.transforms) {\r\n            this.options.transforms = [];\r\n        }\r\n\r\n        // Store the transform function\r\n        this.options.transforms.push(fn);\r\n\r\n        // Update the main transform function to apply all transforms in sequence\r\n        this.options.transform = (value: T) => {\r\n            // Apply each transform in sequence\r\n            return this.options.transforms!.reduce((result: T, transform: Transform<T>) => {\r\n                return transform(result);\r\n            }, value);\r\n        };\r\n\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * Creates a signal instance for testing\r\n     * @param options Configuration with initial value\r\n     * @returns SignalPlus instance for testing\r\n     */\r\n    static mock<T>(options: { initialValue: T }): SignalPlus<T> {\r\n        return new SignalBuilder<T>(options.initialValue).build();\r\n    }\r\n\r\n    /**\r\n     * Builds and returns the configured signal\r\n     * @returns Enhanced signal instance\r\n     */\r\n    build(): SignalPlus<T> {\r\n        // Get transform function\r\n        const transform: Transform<T> = this.options.transform || ((value: T) => value);\r\n\r\n        // Helper to conditionally clone only complex objects\r\n        const conditionalClone = (value: T): T => {\r\n            const type = typeof value;\r\n            if (type === 'string' || type === 'number' || type === 'boolean' || value === null || value === undefined) {\r\n                return value;\r\n            }\r\n            return structuredClone(value);\r\n        };\r\n\r\n        // Create signal with initial value (untransformed)\r\n        const writable: WritableSignal<T> = signal<T>(structuredClone(this.options.initialValue));\r\n        let previousValue: T = structuredClone(this.options.initialValue);\r\n        let initialValue: T = structuredClone(this.options.initialValue);\r\n        const history: WritableSignal<T[]> = signal([]);\r\n        let debounceTimeout: number | undefined | null = null;\r\n        let redoStack: T[] = [];\r\n        let pendingValue: T | null = null;\r\n        let isProcessingDebounce = false;\r\n        let isProcessingStorage = false;\r\n\r\n        /**\r\n         * Helper function to enforce history size limit\r\n         * @param histArray The history array to enforce size on\r\n         * @returns The history array with size limit applied\r\n         */\r\n        const enforceHistorySize = (histArray: T[]): T[] => {\r\n            if (this.options.historySize && histArray.length > this.options.historySize) {\r\n                return histArray.slice(-this.options.historySize);\r\n            }\r\n            return histArray;\r\n        };\r\n\r\n        const serializeWithCircularCheck = (data: any, fallbackData?: any): string => {\r\n            const safeStringify = (obj: any): string => {\r\n                const seen = new WeakSet();\r\n                return JSON.stringify(obj, (key, value) => {\r\n                    if (value !== null && typeof value === 'object') {\r\n                        if (seen.has(value)) {\r\n                            return '[Circular Reference]';\r\n                        }\r\n                        seen.add(value);\r\n                    }\r\n                    return value;\r\n                });\r\n            };\r\n\r\n            try {\r\n                return JSON.stringify(data);\r\n            } catch (error) {\r\n                if (error instanceof TypeError && error.message.includes('circular')) {\r\n                    return safeStringify(data);\r\n                }\r\n                \r\n                if (fallbackData !== undefined) {\r\n                    try {\r\n                        return JSON.stringify(fallbackData);\r\n                    } catch (fallbackError) {\r\n                        if (fallbackError instanceof TypeError && fallbackError.message.includes('circular')) {\r\n                            return safeStringify(fallbackData);\r\n                        }\r\n                        throw fallbackError;\r\n                    }\r\n                }\r\n                \r\n                throw error;\r\n            }\r\n        };\r\n\r\n        // Initialize history with initial value\r\n        if (this.options.enableHistory) {\r\n            history.set([conditionalClone(initialValue)]);\r\n        }\r\n\r\n        // Load initial value from storage if available\r\n        if (this.options.storageKey && isBrowser()) {\r\n            try {\r\n                const stored = safeLocalStorageGet(this.options.storageKey);\r\n                if (stored) {\r\n                    try {\r\n                        let parsedValue: T;\r\n                        let parsedHistory: T[] | undefined;\r\n\r\n                        const parsedData = JSON.parse(stored);\r\n                        if (parsedData && typeof parsedData === 'object' && 'value' in parsedData) {\r\n                            parsedValue = parsedData.value;\r\n                            parsedHistory = parsedData.history;\r\n                        } else {\r\n                            parsedValue = parsedData;\r\n                        }\r\n\r\n                        writable.set(parsedValue);\r\n                        previousValue = parsedValue;\r\n                        initialValue = parsedValue;\r\n\r\n                        if (this.options.enableHistory && parsedHistory) {\r\n                            history.set(enforceHistorySize(parsedHistory.map(v => conditionalClone(v))));\r\n                        } else if (this.options.enableHistory) {\r\n                            history.set([conditionalClone(parsedValue)]);\r\n                        }\r\n                    } catch (error) {\r\n                        this.handleError(error as Error);\r\n                    }\r\n                }\r\n            } catch (error) {\r\n                this.handleError(error as Error);\r\n            }\r\n        }\r\n\r\n        // Add storage event listener\r\n        const handleStorageEvent = (event: StorageEvent) => {\r\n            if (!isProcessingStorage && event.key === this.options.storageKey && event.newValue !== null) {\r\n                try {\r\n                    let parsedValue: T;\r\n                    let parsedHistory: T[] | undefined;\r\n\r\n                    const parsedData = JSON.parse(event.newValue);\r\n                    if (parsedData && typeof parsedData === 'object' && 'value' in parsedData) {\r\n                        parsedValue = parsedData.value;\r\n                        parsedHistory = parsedData.history;\r\n                    } else {\r\n                        parsedValue = parsedData;\r\n                    }\r\n\r\n                    if (!isProcessingDebounce) {\r\n                        writable.set(parsedValue);\r\n                        previousValue = parsedValue;\r\n\r\n                        if (this.options.enableHistory && parsedHistory) {\r\n                            history.set(enforceHistorySize(parsedHistory.map(v => conditionalClone(v))));\r\n                        }\r\n\r\n                        notifySubscribers(parsedValue);\r\n                    }\r\n                } catch (error) {\r\n                    this.handleError(error as Error);\r\n                }\r\n            }\r\n        };\r\n\r\n        // Store cleanup callback for storage listener\r\n        let storageListenerCleanup: (() => void) | undefined;\r\n\r\n        if (this.options.storageKey && isBrowser()) {\r\n            storageListenerCleanup = safeAddEventListener('storage', handleStorageEvent);\r\n        }\r\n\r\n        let nextSubId: number = 0;\r\n        const subscribers = new Map<number, (value: T) => void>();\r\n        let isCleanedUp = false;\r\n\r\n        const notifySubscribers: (value: T) => void = (value: T) => {\r\n            if (isCleanedUp) return;\r\n            subscribers.forEach((callback: (value: T) => void) => {\r\n                try {\r\n                    callback(value);\r\n                } catch (error) {\r\n                    this.handleError(error as Error);\r\n                }\r\n            });\r\n        };\r\n\r\n        const subscribe: (callback: (value: T) => void) => () => void = (callback: (value: T) => void): () => void => {\r\n            const subId: number = nextSubId++;\r\n            subscribers.set(subId, callback);\r\n\r\n            // Always notify with current value immediately\r\n            try {\r\n                callback(writable());\r\n            } catch (error) {\r\n                this.handleError(error as Error);\r\n            }\r\n\r\n            // Return cleanup function\r\n            return () => {\r\n                subscribers.delete(subId);\r\n                if (subscribers.size === 0) {\r\n                    // Cleanup storage event listener\r\n                    if (storageListenerCleanup) {\r\n                        storageListenerCleanup();\r\n                        storageListenerCleanup = undefined;\r\n                    }\r\n\r\n                    // Clear any pending debounce timeout\r\n                    if (debounceTimeout !== null) {\r\n                        safeClearTimeout(debounceTimeout);\r\n                        debounceTimeout = null;\r\n                    }\r\n\r\n                    // Clear pending value\r\n                    pendingValue = null;\r\n                }\r\n            };\r\n        };\r\n\r\n        const updateValue: (val: T, skipValidation?: boolean) => void = (val: T, skipValidation = false) => {\r\n            try {\r\n                // Apply transform first\r\n                let transformedValue: T = val;\r\n                if (transform) {\r\n                    try {\r\n                        transformedValue = transform(val);\r\n                    } catch (error) {\r\n                        this.handleError(error as Error);\r\n                        throw error;\r\n                    }\r\n                }\r\n\r\n                // Then validate the transformed value\r\n                if (!skipValidation) {\r\n                    const validators = this.options.validators as Validator<T>[];\r\n                    if (validators.length > 0) {\r\n                        // Check validators in sequence and stop on first failure\r\n                        for (const validator of validators) {\r\n                            try {\r\n                                const result = validator(transformedValue);\r\n                                if (!result) {\r\n                                    const error = new Error('Validation failed');\r\n                                    this.handleError(error);\r\n                                    throw error;\r\n                                }\r\n                            } catch (error) {\r\n                                this.handleError(error as Error);\r\n                                throw error;\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n\r\n                // Check if value is distinct\r\n                let hasChanged: boolean = true;\r\n                if (this.options.distinctUntilChanged) {\r\n                    try {\r\n                        const currentValueStr: string = JSON.stringify(writable());\r\n                        const newValueStr: string = JSON.stringify(transformedValue);\r\n                        hasChanged = currentValueStr !== newValueStr;\r\n                        \r\n                        if (!hasChanged) {\r\n                            return;\r\n                        }\r\n                    } catch (error) {\r\n                        hasChanged = true;\r\n                    }\r\n                }\r\n\r\n                // Only update if value has changed\r\n                if (hasChanged) {\r\n                    previousValue = conditionalClone(writable());\r\n                    writable.set(transformedValue);\r\n\r\n                    // Update history if enabled and value has changed\r\n                    if (this.options.enableHistory && !isProcessingDebounce) {\r\n                        // Clear redo stack when new value is set\r\n                        redoStack = [];\r\n                        const currentHistory: T[] = history();\r\n                        const newHistory = [...currentHistory, conditionalClone(transformedValue)];\r\n\r\n                        // Enforce history size limit using helper function\r\n                        history.set(enforceHistorySize(newHistory));\r\n                    }\r\n\r\n                    // Handle storage\r\n                    if (this.options.storageKey && isBrowser()) {\r\n                        try {\r\n                            isProcessingStorage = true;\r\n                            const shouldStoreHistory: boolean = Boolean(this.options.enableHistory && this.options.persistHistory);\r\n                            const dataToStore: T | { value: T; history: T[] } = shouldStoreHistory\r\n                                ? { value: transformedValue, history: history() }\r\n                                : transformedValue;\r\n                            \r\n                            const serialized = serializeWithCircularCheck(dataToStore, transformedValue);\r\n                            safeLocalStorageSet(this.options.storageKey, serialized);\r\n                        } catch (error) {\r\n                            this.handleError(error as Error);\r\n                        } finally {\r\n                            isProcessingStorage = false;\r\n                        }\r\n                    }\r\n\r\n                    // Only notify subscribers if not cleaned up\r\n                    if (!isCleanedUp) {\r\n                        notifySubscribers(transformedValue);\r\n                    }\r\n                }\r\n            } catch (error) {\r\n                this.handleError(error as Error);\r\n                throw error;\r\n            }\r\n        };\r\n\r\n        // Set initial value without applying transforms\r\n        writable.set(initialValue);\r\n\r\n        const processValue: (value: T) => void = (value: T) => {\r\n            // Prevent setValue after destroy\r\n            if (isCleanedUp) {\r\n                return;\r\n            }\r\n\r\n            // Clear existing debounce timeout\r\n            if (debounceTimeout !== null) {\r\n                safeClearTimeout(debounceTimeout);\r\n                debounceTimeout = null;\r\n            }\r\n\r\n            try {\r\n                // Handle debounce\r\n                if (this.options.debounceTime && this.options.debounceTime > 0) {\r\n                    isProcessingDebounce = true;\r\n                    pendingValue = value;\r\n                    debounceTimeout = safeSetTimeout(() => {\r\n                        try {\r\n                            const finalValue = pendingValue;\r\n                            pendingValue = null;\r\n                            isProcessingDebounce = false;\r\n\r\n                            if (finalValue !== null) {\r\n                                updateValue(finalValue);\r\n                            }\r\n                        } catch (error) {\r\n                            this.handleError(error as Error);\r\n                            throw error;\r\n                        } finally {\r\n                            debounceTimeout = null;\r\n                            isProcessingDebounce = false;\r\n                        }\r\n                    }, this.options.debounceTime);\r\n                } else {\r\n                    updateValue(value);\r\n                }\r\n            } catch (error) {\r\n                this.handleError(error as Error);\r\n                throw error;\r\n            }\r\n        };\r\n\r\n        const signalInstance: SignalPlus<T> = {\r\n            get value() { return writable(); },\r\n            get previousValue() { return previousValue; },\r\n            get initialValue() { return initialValue; },\r\n            signal: computed(() => writable()),\r\n            writable,\r\n            set: processValue,\r\n            setValue: processValue,\r\n            update: (fn: (current: T) => T) => {\r\n                try {\r\n                    const newValue: T = fn(writable());\r\n                    processValue(newValue);\r\n                } catch (error) {\r\n                    this.handleError(error as Error);\r\n                    throw error;\r\n                }\r\n            },\r\n            reset: () => {\r\n                try {\r\n                    // Clear any pending debounce timeout to prevent race conditions\r\n                    if (debounceTimeout !== null) {\r\n                        safeClearTimeout(debounceTimeout);\r\n                        debounceTimeout = null;\r\n                        pendingValue = null;\r\n                    }\r\n\r\n                    // Reset to initial untransformed value and apply transform\r\n                    const resetValue: T = this.options.defaultValue ?? this.options.initialValue;\r\n\r\n                    // Clear history and redo stack\r\n                    redoStack = [];\r\n                    if (this.options.enableHistory) {\r\n                        history.set([]);\r\n                    }\r\n\r\n                    // Process the reset value through normal update flow, but skip validation\r\n                    try {\r\n                        // Apply transform first\r\n                        let transformedValue: T = resetValue;\r\n                        if (transform) {\r\n                            transformedValue = transform(resetValue);\r\n                        }\r\n\r\n                        // Update signal state\r\n                        previousValue = conditionalClone(writable());\r\n                        writable.set(transformedValue);\r\n\r\n                        // Update history\r\n                        if (this.options.enableHistory) {\r\n                            history.set([conditionalClone(transformedValue)]);\r\n                        }\r\n\r\n                        // Handle storage\r\n                        if (this.options.storageKey && isBrowser()) {\r\n                            try {\r\n                                isProcessingStorage = true;\r\n                                const shouldStoreHistory: boolean = Boolean(this.options.enableHistory && this.options.persistHistory);\r\n                                const dataToStore: T | { value: T; history: T[] } = shouldStoreHistory\r\n                                    ? { value: transformedValue, history: [transformedValue] }\r\n                                    : transformedValue;\r\n                                \r\n                                const serialized = serializeWithCircularCheck(dataToStore, transformedValue);\r\n                                safeLocalStorageSet(this.options.storageKey, serialized);\r\n                            } catch (error) {\r\n                                this.handleError(error as Error);\r\n                            } finally {\r\n                                isProcessingStorage = false;\r\n                            }\r\n                        }\r\n\r\n                        // Notify subscribers\r\n                        notifySubscribers(transformedValue);\r\n                    } catch (error) {\r\n                        this.handleError(error as Error);\r\n                        throw error;\r\n                    }\r\n                } catch (error) {\r\n                    this.handleError(error as Error);\r\n                    throw error;\r\n                }\r\n            },\r\n            validate: () => {\r\n                try {\r\n                    const validators: Validator<T>[] = this.options.validators as Validator<T>[];\r\n                    return validators.every((validator: Validator<T>) => {\r\n                        try {\r\n                            return validator(writable());\r\n                        } catch (error) {\r\n                            this.handleError(error as Error);\r\n                            return false;\r\n                        }\r\n                    });\r\n                } catch (error) {\r\n                    this.handleError(error as Error);\r\n                    return false;\r\n                }\r\n            },\r\n            isValid: computed(() => {\r\n                try {\r\n                    const validators: Validator<T>[] = this.options.validators as Validator<T>[];\r\n                    return validators.every((validator: Validator<T>) => {\r\n                        try {\r\n                            return validator(writable());\r\n                        } catch (error) {\r\n                            this.handleError(error as Error);\r\n                            return false;\r\n                        }\r\n                    });\r\n                } catch (error) {\r\n                    this.handleError(error as Error);\r\n                    return false;\r\n                }\r\n            }),\r\n            isDirty: computed(() => {\r\n                try {\r\n                    return JSON.stringify(writable()) !== JSON.stringify(initialValue);\r\n                } catch (error) {\r\n                    return writable() !== initialValue;\r\n                }\r\n            }),\r\n            hasChanged: computed(() => {\r\n                try {\r\n                    const currentValue: string = JSON.stringify(writable());\r\n                    const prevValue: string = JSON.stringify(previousValue);\r\n                    return this.options.distinctUntilChanged ?\r\n                        currentValue !== prevValue && currentValue !== JSON.stringify(writable()) :\r\n                        currentValue !== prevValue;\r\n                } catch (error) {\r\n                    return writable() !== previousValue;\r\n                }\r\n            }),\r\n            history: computed(() => this.options.enableHistory ? history() : []),\r\n            undo: () => {\r\n                if (!this.options.enableHistory || history().length <= 1) return;\r\n\r\n                // Clear any pending debounce timeout to prevent race conditions\r\n                if (debounceTimeout !== null) {\r\n                    safeClearTimeout(debounceTimeout);\r\n                    debounceTimeout = null;\r\n                    pendingValue = null;\r\n                }\r\n\r\n                // Get current value\r\n                const currentValue: T = writable();\r\n\r\n                // Move current value to redo stack\r\n                redoStack.push(conditionalClone(currentValue));\r\n\r\n                // Get the previous value from history\r\n                const currentHistory: T[] = history();\r\n                const previousValue: T = currentHistory[currentHistory.length - 2];\r\n\r\n                // Update history and current value\r\n                history.set(currentHistory.slice(0, -1));\r\n                writable.set(conditionalClone(previousValue));\r\n\r\n                // Notify subscribers\r\n                notifySubscribers(previousValue);\r\n            },\r\n            redo: () => {\r\n                if (!this.options.enableHistory || redoStack.length === 0) return;\r\n\r\n                // Clear any pending debounce timeout to prevent race conditions\r\n                if (debounceTimeout !== null) {\r\n                    safeClearTimeout(debounceTimeout);\r\n                    debounceTimeout = null;\r\n                    pendingValue = null;\r\n                }\r\n\r\n                // Get the value to redo\r\n                const valueToRedo: T = redoStack.pop() as T;\r\n\r\n                // Add it to history\r\n                const currentHistory: T[] = history();\r\n                history.set([...currentHistory, conditionalClone(valueToRedo)]);\r\n\r\n                // Set the value\r\n                writable.set(conditionalClone(valueToRedo));\r\n\r\n                // Notify subscribers\r\n                notifySubscribers(valueToRedo);\r\n            },\r\n            subscribe,\r\n            pipe: <R>(...operators: any[]): SignalPlus<R> => {\r\n                // Create a computed signal that applies operators to the source signal\r\n                const computedSignal: Signal<R> = computed(() => {\r\n                    try {\r\n                        let value: any = writable();\r\n                        for (const op of operators) {\r\n                            const intermediateSignal: WritableSignal<any> = signal(value);\r\n                            value = op(intermediateSignal)();\r\n                        }\r\n                        return value as R;\r\n                    } catch (error) {\r\n                        this.handleError(error as Error);\r\n                        throw error;\r\n                    }\r\n                });\r\n\r\n                // Get transformed initial value\r\n                let transformedInitialValue: R;\r\n                try {\r\n                    transformedInitialValue = computedSignal();\r\n                } catch (error) {\r\n                    this.handleError(error as Error);\r\n                    throw error;\r\n                }\r\n\r\n                // Create a new builder with the transformed initial value\r\n                const resultBuilder = new SignalBuilder<R>(transformedInitialValue);\r\n\r\n                // Build the new signal\r\n                const result: SignalPlus<R> = resultBuilder.build();\r\n\r\n                // Subscribe to source changes\r\n                signalInstance.subscribe((value: T) => {\r\n                    try {\r\n                        result.setValue(computedSignal());\r\n                    } catch (error) {\r\n                        this.handleError(error as Error);\r\n                        throw error;\r\n                    }\r\n                });\r\n\r\n                return result;\r\n            },\r\n            destroy: () => {\r\n                const errors: Error[] = [];\r\n                \r\n                try {\r\n                    // Mark as cleaned up\r\n                    isCleanedUp = true;\r\n                } catch (error) {\r\n                    errors.push(new Error(`Failed to set cleanup flag: ${error}`));\r\n                }\r\n\r\n                try {\r\n                    // Clear all subscribers\r\n                    subscribers.clear();\r\n                } catch (error) {\r\n                    errors.push(new Error(`Failed to clear subscribers: ${error}`));\r\n                }\r\n\r\n                try {\r\n                    // Cleanup storage event listener\r\n                    if (storageListenerCleanup) {\r\n                        storageListenerCleanup();\r\n                        storageListenerCleanup = undefined;\r\n                    }\r\n                } catch (error) {\r\n                    errors.push(new Error(`Failed to cleanup storage listener: ${error}`));\r\n                }\r\n\r\n                try {\r\n                    // Clear any pending debounce timeout\r\n                    if (debounceTimeout !== null) {\r\n                        safeClearTimeout(debounceTimeout);\r\n                        debounceTimeout = null;\r\n                    }\r\n                } catch (error) {\r\n                    errors.push(new Error(`Failed to clear debounce timeout: ${error}`));\r\n                }\r\n\r\n                try {\r\n                    // Clear pending value\r\n                    pendingValue = null;\r\n                } catch (error) {\r\n                    errors.push(new Error(`Failed to clear pending value: ${error}`));\r\n                }\r\n\r\n                // If any errors occurred during cleanup, log them (don't throw to ensure all cleanup steps run)\r\n                if (errors.length > 0) {\r\n                    console.error(`Signal cleanup encountered ${errors.length} error(s):`, errors);\r\n                    // Call custom error handlers if available\r\n                    if (this.options.errorHandlers && this.options.errorHandlers.length > 0) {\r\n                        const cleanupError = new Error(`Cleanup failed with ${errors.length} error(s): ${errors.map(e => e.message).join(', ')}`);\r\n                        this.options.errorHandlers.forEach(handler => {\r\n                            try {\r\n                                handler(cleanupError);\r\n                            } catch (handlerError) {\r\n                                console.error('Error handler itself failed during cleanup:', handlerError);\r\n                            }\r\n                        });\r\n                    }\r\n                }\r\n            },\r\n            _clearPendingOperations: () => {\r\n                // Clear any pending debounce timeout without destroying the signal\r\n                if (debounceTimeout !== null) {\r\n                    safeClearTimeout(debounceTimeout);\r\n                    debounceTimeout = null;\r\n                }\r\n\r\n                // Clear pending value\r\n                pendingValue = null;\r\n            },\r\n            _setValueImmediate: (value: T) => {\r\n                // First clear any pending operations\r\n                if (debounceTimeout !== null) {\r\n                    safeClearTimeout(debounceTimeout);\r\n                    debounceTimeout = null;\r\n                }\r\n                pendingValue = null;\r\n\r\n                // Apply transformations\r\n                let transformedValue: T = value;\r\n                if (this.options.transform) {\r\n                    transformedValue = this.options.transform(value);\r\n                }\r\n\r\n                // Set the value immediately without going through processValue\r\n                // This bypasses debounce, validation, and subscribers\r\n                writable.set(transformedValue);\r\n\r\n                // Update history manually if enabled\r\n                if (this.options.enableHistory) {\r\n                    const currentHistory: readonly T[] = history();\r\n                    const newHistory: T[] = [...currentHistory, conditionalClone(transformedValue)];\r\n                    history.set(enforceHistorySize(newHistory));\r\n                    redoStack.length = 0; // Clear redo stack\r\n                }\r\n\r\n                // Update persistence if enabled\r\n                if (this.options.storageKey) {\r\n                    const storageValue: string = JSON.stringify(transformedValue);\r\n                    safeLocalStorageSet(this.options.storageKey, storageValue);\r\n                }\r\n\r\n                // Notify subscribers immediately\r\n                subscribers.forEach(callback => callback(transformedValue));\r\n            },\r\n            _setHistoryImmediate: (historyArray: T[]) => {\r\n                // Directly set the history without any side effects\r\n                // This is used primarily for transaction rollback\r\n                if (this.options.enableHistory) {\r\n                    history.set(enforceHistorySize([...historyArray]));\r\n                }\r\n            }\r\n        };\r\n\r\n        return signalInstance;\r\n    }\r\n\r\n    /**\r\n     * Internal method to handle errors through registered error handlers.\r\n     * @param error The error to handle\r\n     */\r\n    private handleError(error: Error): void {\r\n        if (this.options.errorHandlers) {\r\n            this.options.errorHandlers.forEach(handler => {\r\n                try {\r\n                    handler(error);\r\n                } catch (e) {\r\n                    console.error('Error in error handler:', e);\r\n                }\r\n            });\r\n        }\r\n    }\r\n} ","/**\r\n * @fileoverview Utility functions for creating enhanced signals\r\n * @description\r\n * Provides a collection of factory functions for creating common signal types.\r\n * Each function is designed for specific use cases with sensible defaults.\r\n * \r\n * Features:\r\n * - Type-safe signal creation\r\n * - Common preset configurations\r\n * - Automatic validation setup\r\n * - Built-in error handling\r\n * \r\n * @example Basic Usage\r\n * ```typescript\r\n * // Simple signal\r\n * const count = createSignal(0);\r\n * \r\n * // Validated counter\r\n * const counter = createCounter({ initial: 0, min: 0, max: 100 });\r\n * \r\n * // Form input with validation\r\n * const input = createForm({\r\n *   initial: '',\r\n *   validator: value => value.length > 0\r\n * });\r\n * ```\r\n */\r\n\r\nimport { SignalBuilder } from '../core/signal-builder';\r\nimport { FormNumberOptions, FormTextOptions } from '../models/form.model';\r\nimport { SignalPlus } from '../models/signal-plus.model';\r\nimport { safeLocalStorageSet } from './platform';\r\n\r\n/**\r\n * Creates a new SignalBuilder for configuring enhanced signals\r\n * \r\n * @typeParam T - The type of value to be stored in the signal\r\n * @param initialValue - The initial value for the signal. Cannot be undefined.\r\n * @returns A SignalBuilder instance for fluent configuration\r\n * @throws {Error} If initialValue is undefined\r\n * \r\n * @remarks\r\n * This is the primary entry point for creating enhanced signals with the builder pattern.\r\n * It provides a fluent API for configuring validation, persistence, history, and more.\r\n * \r\n * The builder must be finalized with `.build()` to create the actual signal.\r\n * \r\n * @example Basic Usage\r\n * ```typescript\r\n * const counter = sp(0).build();\r\n * counter.setValue(5);\r\n * ```\r\n * \r\n * @example With Validation\r\n * ```typescript\r\n * const age = sp(0)\r\n *   .validate(n => n >= 0)\r\n *   .validate(n => n <= 150)\r\n *   .build();\r\n * ```\r\n * \r\n * @example With Persistence and History\r\n * ```typescript\r\n * const username = sp('')\r\n *   .persist('username')\r\n *   .withHistory(10)\r\n *   .debounce(300)\r\n *   .build();\r\n * ```\r\n * \r\n * @example With Transformation\r\n * ```typescript\r\n * const rounded = sp(0)\r\n *   .transform(Math.round)\r\n *   .build();\r\n * ```\r\n */\r\nexport function sp<T>(initialValue: T): SignalBuilder<T> {\r\n    if (initialValue === undefined) {\r\n        throw new Error('Initial value cannot be undefined');\r\n    }\r\n    return new SignalBuilder<T>(initialValue);\r\n}\r\n\r\n/**\r\n * Creates a counter signal with automatic validation and history\r\n * \r\n * @param initial - The initial counter value. Defaults to 0.\r\n * @param options - Optional configuration for min/max bounds\r\n * @param options.min - Minimum allowed value (inclusive)\r\n * @param options.max - Maximum allowed value (inclusive)\r\n * @returns A SignalPlus instance configured as a counter\r\n * \r\n * @remarks\r\n * The counter signal automatically:\r\n * - Validates against min/max bounds if provided\r\n * - Tracks history for undo/redo operations\r\n * - Rejects invalid values that exceed bounds\r\n * \r\n * @example Basic Counter\r\n * ```typescript\r\n * const counter = spCounter();\r\n * counter.setValue(5);\r\n * counter.update(n => n + 1); // 6\r\n * ```\r\n * \r\n * @example Counter with Bounds\r\n * ```typescript\r\n * const percentage = spCounter(0, { min: 0, max: 100 });\r\n * percentage.setValue(150); // Validation fails\r\n * percentage.setValue(50);  // Success\r\n * ```\r\n * \r\n * @example With History\r\n * ```typescript\r\n * const counter = spCounter(10);\r\n * counter.setValue(20);\r\n * counter.setValue(30);\r\n * counter.undo(); // Back to 20\r\n * counter.redo(); // Forward to 30\r\n * ```\r\n */\r\nexport const spCounter = (initial = 0, options?: Partial<{ max: number, min: number }>) => {\r\n    // Validate input options\r\n    if (options?.min !== undefined && options?.max !== undefined && options.min > options.max) {\r\n        throw new RangeError(`spCounter: min (${options.min}) cannot be greater than max (${options.max})`);\r\n    }\r\n\r\n    return sp(initial)\r\n        .validate(n => options?.min === undefined || n >= options.min)\r\n        .validate(n => options?.max === undefined || n <= options.max)\r\n        .withHistory()\r\n        .build();\r\n};\r\n\r\n/**\r\n * Collection of form input signal presets with built-in validation\r\n * \r\n * @remarks\r\n * Provides ready-to-use form input signals for common scenarios:\r\n * - `text`: Plain text inputs with length validation\r\n * - `email`: Email inputs with format validation\r\n * - `number`: Numeric inputs with range validation\r\n * - `password`: Password inputs with strength requirements\r\n * - `url`: URL inputs with format validation\r\n * - `tel`: Phone number inputs with format validation\r\n * - `date`: Date inputs with validation\r\n * - `checkbox`: Boolean inputs\r\n * - `select`: Selection inputs with allowed values\r\n * \r\n * All form signals support:\r\n * - Automatic validation\r\n * - Debouncing for performance\r\n * - Optional persistence\r\n * - Type-safe values\r\n * \r\n * @example Text Input\r\n * ```typescript\r\n * const username = spForm.text('', {\r\n *   minLength: 3,\r\n *   maxLength: 20,\r\n *   debounce: 300\r\n * });\r\n * ```\r\n * \r\n * @example Email Input\r\n * ```typescript\r\n * const email = spForm.email('', { debounce: 500 });\r\n * console.log(email.isValid()); // false until valid email entered\r\n * ```\r\n * \r\n * @example Number Input\r\n * ```typescript\r\n * const age = spForm.number(0, {\r\n *   min: 0,\r\n *   max: 150,\r\n *   debounce: 200\r\n * });\r\n * ```\r\n */\r\nexport const spForm = {\r\n    text: (initial = '', options?: Partial<FormTextOptions>) => {\r\n        // Validate input options\r\n        if (options?.minLength !== undefined && options?.maxLength !== undefined && options.minLength > options.maxLength) {\r\n            throw new RangeError(`spForm.text: minLength (${options.minLength}) cannot be greater than maxLength (${options.maxLength})`);\r\n        }\r\n        if (options?.debounce !== undefined && options.debounce < 0) {\r\n            throw new RangeError(`spForm.text: debounce (${options.debounce}) cannot be negative`);\r\n        }\r\n\r\n        const signal = sp(initial);\r\n        signal.transform(v => v === undefined || v === null ? '' : String(v));\r\n\r\n        if (options?.minLength !== undefined || options?.maxLength !== undefined) {\r\n            signal.validate(v => {\r\n                if (options?.minLength && (v === '' || v.length < options.minLength)) return false;\r\n                if (options?.maxLength && v.length > options.maxLength) return false;\r\n                return true;\r\n            });\r\n        }\r\n\r\n        return options?.debounce !== undefined ? signal.debounce(options.debounce).build() : signal.build();\r\n    },\r\n\r\n    email: (initial = '', options?: Pick<FormTextOptions, 'debounce'>) => {\r\n        // Validate input options\r\n        if (options?.debounce !== undefined && options.debounce < 0) {\r\n            throw new RangeError(`spForm.email: debounce (${options.debounce}) cannot be negative`);\r\n        }\r\n\r\n        const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n        let lastValidValue = initial;\r\n\r\n        // Create signal with error handling\r\n        const signal = sp(initial)\r\n            .transform(v => {\r\n                if (v === undefined || v === null) return '';\r\n                const str = String(v);\r\n\r\n                if (str === '') return str;  // Always allow empty string for validation\r\n\r\n                // Validate email format\r\n                if (!emailRegex.test(str)) {\r\n                    if (options?.debounce) {\r\n                        return lastValidValue; // Silently revert to last valid value in debounced mode\r\n                    }\r\n                    throw new Error('Invalid email format'); // Throw in non-debounced mode\r\n                }\r\n\r\n                // Valid email - update lastValidValue and return\r\n                lastValidValue = str;\r\n                return str;\r\n            })\r\n            .validate(v => {\r\n                if (options?.debounce) {\r\n                    return v === '' || emailRegex.test(v);\r\n                }\r\n                return v !== '';\r\n            });\r\n\r\n        // Add debounce if specified\r\n        if (options?.debounce !== undefined) {\r\n            signal.debounce(options.debounce);\r\n        }\r\n\r\n        return signal.build();\r\n    },\r\n\r\n    number: (options?: Partial<FormNumberOptions>) => {\r\n        // Validate input options\r\n        if (options?.min !== undefined && options?.max !== undefined && options.min > options.max) {\r\n            throw new RangeError(`spForm.number: min (${options.min}) cannot be greater than max (${options.max})`);\r\n        }\r\n        if (options?.debounce !== undefined && options.debounce < 0) {\r\n            throw new RangeError(`spForm.number: debounce (${options.debounce}) cannot be negative`);\r\n        }\r\n\r\n        const effectiveMin = options?.min;\r\n        const effectiveMax = options?.max;\r\n        const init = options?.initial ?? 0;\r\n\r\n        const getValidValue = (value: number): number => {\r\n            if (effectiveMin !== undefined && value < effectiveMin) return effectiveMin;\r\n            if (effectiveMax !== undefined && value > effectiveMax) return effectiveMax;\r\n            return value;\r\n        };\r\n\r\n        if (options?.debounce !== undefined) {\r\n            // Debounced version starts with null\r\n            const signal = sp<number | null>(null);\r\n\r\n            signal.transform(n => {\r\n                if (n === null || n === undefined) return n;\r\n                const num = typeof n === 'boolean' ? (n ? 1 : 0) : Number(n);\r\n                if (isNaN(num)) return init;\r\n                const rounded = Math.round(num);\r\n                return getValidValue(rounded);\r\n            });\r\n\r\n            signal.validate(n => {\r\n                if (n === null) return true;\r\n                const value = getValidValue(n);\r\n                return value === n;\r\n            });\r\n\r\n            return signal.debounce(options.debounce).build();\r\n        } else {\r\n            // Non-debounced version starts with init\r\n            const signal = sp<number>(getValidValue(init));\r\n\r\n            signal.transform(n => {\r\n                const num = typeof n === 'boolean' ? (n ? 1 : 0) : Number(n);\r\n                if (isNaN(num)) return getValidValue(init);\r\n                const rounded = Math.round(num);\r\n                return getValidValue(rounded);\r\n            });\r\n\r\n            signal.validate(n => {\r\n                const value = getValidValue(n);\r\n                return value === n;\r\n            });\r\n\r\n            return signal.build();\r\n        }\r\n    }\r\n};\r\n\r\n/**\r\n * Creates a boolean toggle signal with history and optional persistence\r\n * \r\n * @param initial - The initial boolean value. Defaults to false.\r\n * @param key - Optional storage key for persistence in localStorage\r\n * @returns A SignalPlus instance configured for toggle operations\r\n * \r\n * @remarks\r\n * The toggle signal automatically:\r\n * - Tracks history for undo/redo operations\r\n * - Persists state in localStorage if key is provided\r\n * - Provides a convenient boolean state management\r\n * \r\n * Perfect for:\r\n * - UI toggles (dark mode, sidebar, etc.)\r\n * - Feature flags\r\n * - Boolean preferences\r\n * - Checkbox state\r\n * \r\n * @example Basic Toggle\r\n * ```typescript\r\n * const darkMode = spToggle(false);\r\n * darkMode.setValue(true);\r\n * console.log(darkMode.value); // true\r\n * ```\r\n * \r\n * @example Toggle with Persistence\r\n * ```typescript\r\n * const sidebarOpen = spToggle(false, 'sidebar-state');\r\n * sidebarOpen.setValue(true);\r\n * // State persists across page reloads\r\n * ```\r\n * \r\n * @example With History\r\n * ```typescript\r\n * const feature = spToggle(false);\r\n * feature.setValue(true);\r\n * feature.setValue(false);\r\n * feature.undo(); // Back to true\r\n * feature.redo(); // Forward to false\r\n * ```\r\n * \r\n * @example Update Pattern\r\n * ```typescript\r\n * const visible = spToggle(false);\r\n * visible.update(current => !current); // Toggle value\r\n * ```\r\n */\r\nexport const spToggle = (initial = false, key?: string) => {\r\n    const signal = sp(initial)\r\n        .withHistory(false);  // Enable history tracking but don't persist it\r\n\r\n    // Enable persistence if key is provided\r\n    if (key) {\r\n        signal.persist(key);\r\n        // Store initial value using SSR-safe wrapper\r\n        safeLocalStorageSet(key, JSON.stringify({ value: initial }));\r\n\r\n        // Override updateValue to store in correct format\r\n        const instance = signal.build();\r\n        const originalSetValue = instance.setValue;\r\n        instance.setValue = (value: boolean) => {\r\n            originalSetValue(value);\r\n            // Use SSR-safe wrapper for storage\r\n            safeLocalStorageSet(key, JSON.stringify({ value }));\r\n        };\r\n        return instance;\r\n    }\r\n\r\n    return signal.build();\r\n};\r\n\r\n/**\r\n * Creates a simple toggle signal with validation\r\n * \r\n * @typeParam T - The type of value (should be boolean)\r\n * @param initial - The initial value (must be boolean for spToggle)\r\n * @param key - Optional storage key for persistence\r\n * @returns A SignalPlus instance configured for toggle operations\r\n * @throws {TypeError} If initial value is not a boolean\r\n * \r\n * @remarks\r\n * This is a convenience wrapper for spToggle that validates the input type.\r\n * It ensures type safety by throwing an error if a non-boolean value is provided.\r\n * \r\n * @example Valid Usage\r\n * ```typescript\r\n * const darkMode = createSimple(true, 'dark-mode');\r\n * darkMode.setValue(false);\r\n * ```\r\n * \r\n * @example Invalid Usage (throws error)\r\n * ```typescript\r\n * const invalid = createSimple('not a boolean'); // ❌ Throws TypeError\r\n * ```\r\n */\r\nexport function createSimple<T>(initial: T, key?: string): SignalPlus<boolean> {\r\n    if (typeof initial !== 'boolean') {\r\n        throw new TypeError(`createSimple: initial value must be boolean, got ${typeof initial}`);\r\n    }\r\n    return spToggle(initial, key);\r\n} ","/**\r\n * @fileoverview Utility for enhancing Angular signals with additional features\r\n * @description\r\n * Provides a way to add advanced functionality to existing Angular signals\r\n * through a fluent builder API. This module bridges the gap between basic\r\n * Angular signals and the enhanced features of SignalPlus.\r\n * \r\n * Features that can be added:\r\n * - Persistent storage with automatic sync\r\n * - Validation rules and error handling\r\n * - Value transformation pipeline\r\n * - History tracking with undo/redo\r\n * - Time-based operations (debounce, throttle)\r\n * - Change detection optimization\r\n * \r\n * @example Basic Enhancement\r\n * ```typescript\r\n * // Add persistence to a signal\r\n * const name = signal('John');\r\n * const persistent = enhance(name)\r\n *   .persist('user-name')\r\n *   .build();\r\n * \r\n * // Add validation to a signal\r\n * const age = signal(25);\r\n * const validated = enhance(age)\r\n *   .validate(n => n >= 0)\r\n *   .build();\r\n * ```\r\n * \r\n * @example Advanced Usage\r\n * ```typescript\r\n * // Combine multiple features\r\n * const formInput = enhance(signal(''))\r\n *   .persist('form-field')\r\n *   .validate(value => value.length >= 3)\r\n *   .transform(value => value.trim())\r\n *   .debounce(300)\r\n *   .withHistory()\r\n *   .build();\r\n * \r\n * // Handle errors\r\n * const validated = enhance(signal(0))\r\n *   .validate(n => {\r\n *     if (n < 0) throw new Error('Must be positive');\r\n *     return true;\r\n *   })\r\n *   .onError(console.error)\r\n *   .build();\r\n * ```\r\n */\r\n\r\nimport { Signal } from '@angular/core';\r\nimport { SignalBuilder } from '../core/signal-builder';\r\n\r\n/**\r\n * Enhances an Angular signal with additional features\r\n * \r\n * @template T The type of value managed by the signal\r\n * @param signal The Angular signal to enhance\r\n * @returns A SignalBuilder instance for configuring enhancements\r\n * \r\n * @remarks\r\n * The enhance function is the entry point for adding SignalPlus features\r\n * to existing Angular signals. It creates a builder instance that allows\r\n * configuring various enhancements through a fluent API.\r\n * \r\n * Key Features:\r\n * - Persistence: Automatic localStorage integration\r\n * - Validation: Type-safe validation rules\r\n * - Transformation: Value processing pipeline\r\n * - History: Undo/redo capability\r\n * - Timing: Debounce and throttle\r\n * - Error Handling: Centralized error management\r\n * \r\n * The builder pattern ensures type safety and provides a clear API\r\n * for configuring exactly which features are needed.\r\n * \r\n * @example Persistence and Validation\r\n * ```typescript\r\n * const counter = enhance(signal(0))\r\n *   .persist('counter')\r\n *   .validate(n => n >= 0)\r\n *   .build();\r\n * \r\n * counter.value++; // Persisted and validated\r\n * ```\r\n * \r\n * @example Form Input Enhancement\r\n * ```typescript\r\n * const input = enhance(signal(''))\r\n *   .persist('user-input')\r\n *   .validate(value => value.length > 0)\r\n *   .transform(value => value.trim())\r\n *   .debounce(300)\r\n *   .withHistory()\r\n *   .onError(error => {\r\n *     console.error('Input error:', error);\r\n *     showErrorUI(error.message);\r\n *   })\r\n *   .build();\r\n * ```\r\n */\r\nexport function enhance<T>(signal: Signal<T>): SignalBuilder<T> {\r\n    return new SignalBuilder<T>(signal());\r\n} ","/**\r\n * @fileoverview Predefined signal configurations for common use cases\r\n * @description\r\n * This module provides a collection of ready-to-use signal patterns with\r\n * appropriate defaults and configurations. Each preset is optimized for\r\n * specific use cases and follows best practices for state management.\r\n * \r\n * Available Presets:\r\n * - counter: Numeric counter with validation and history\r\n * - toggle: Boolean state with history tracking\r\n * - formInput: Form field with validation and persistence\r\n * \r\n * Features included in presets:\r\n * - Type-safe configurations\r\n * - Validation rules\r\n * - History tracking\r\n * - Persistence options\r\n * - Performance optimizations\r\n * \r\n * @example Counter Usage\r\n * ```typescript\r\n * const counter = signalPlus.presets.counter({ \r\n *   initial: 0,\r\n *   min: 0,\r\n *   max: 100\r\n * });\r\n * counter.value++; // Validates and tracks history\r\n * counter.undo();  // Reverts to previous value\r\n * ```\r\n * \r\n * @example Form Input Usage\r\n * ```typescript\r\n * const username = signalPlus.presets.formInput({\r\n *   initial: '',\r\n *   key: 'username',\r\n *   validator: value => value.length >= 3,\r\n *   debounce: 300\r\n * });\r\n * \r\n * username.subscribe(value => {\r\n *   validateForm();\r\n *   saveProgress();\r\n * });\r\n * ```\r\n */\r\n\r\nimport { SignalBuilder } from '../core/signal-builder';\r\nimport { CounterConfig, FormConfig } from '../models/signal-plus.model';\r\n\r\n/**\r\n * Collection of predefined signal configurations\r\n * \r\n * @remarks\r\n * Each preset is carefully designed to handle specific use cases\r\n * with appropriate defaults and configurations. They encapsulate\r\n * common patterns and best practices for state management.\r\n * \r\n * Common features across presets:\r\n * - Type safety with generics\r\n * - Automatic cleanup\r\n * - Error handling\r\n * - Change detection optimization\r\n */\r\nexport const presets = {\r\n    /**\r\n     * Creates a number counter with validation and history\r\n     * \r\n     * @param config Configuration options for the counter\r\n     * @returns SignalBuilder configured for counter operations\r\n     * \r\n     * @remarks\r\n     * The counter preset provides:\r\n     * - Integer validation\r\n     * - Optional min/max bounds\r\n     * - History tracking\r\n     * - Type coercion\r\n     * \r\n     * Use this preset when you need:\r\n     * - Numeric value tracking\r\n     * - Increment/decrement operations\r\n     * - Range validation\r\n     * - Undo/redo support\r\n     * \r\n     * @example Basic Counter\r\n     * ```typescript\r\n     * const counter = signalPlus.presets.counter();\r\n     * counter.value++; // Validates and tracks\r\n     * counter.undo();  // Reverts increment\r\n     * ```\r\n     * \r\n     * @example Bounded Counter\r\n     * ```typescript\r\n     * const score = signalPlus.presets.counter({\r\n     *   initial: 0,\r\n     *   min: 0,\r\n     *   max: 100\r\n     * });\r\n     * \r\n     * score.update(v => v + 10); // Validates range\r\n     * ```\r\n     */\r\n    counter: (config?: CounterConfig): SignalBuilder<number> => {\r\n        const builder = new SignalBuilder(config?.initial ?? 0);\r\n        builder.validate(x => Number.isInteger(x));\r\n        if (typeof config?.min === 'number') {\r\n            builder.validate(x => x >= config.min!);\r\n        }\r\n        if (typeof config?.max === 'number') {\r\n            builder.validate(x => x <= config.max!);\r\n        }\r\n        return builder.withHistory();\r\n    },\r\n\r\n    /**\r\n     * Creates a boolean toggle with history tracking\r\n     * \r\n     * @param initial Initial toggle state\r\n     * @returns SignalBuilder configured for toggle operations\r\n     * \r\n     * @remarks\r\n     * The toggle preset provides:\r\n     * - Boolean state management\r\n     * - History tracking\r\n     * - Type safety\r\n     * - Easy toggling\r\n     * \r\n     * Use this preset when you need:\r\n     * - On/off states\r\n     * - Feature flags\r\n     * - UI toggles\r\n     * - Undo/redo support\r\n     * \r\n     * @example Basic Toggle\r\n     * ```typescript\r\n     * const darkMode = signalPlus.presets.toggle(false);\r\n     * darkMode.update(v => !v); // Toggles and tracks\r\n     * ```\r\n     * \r\n     * @example Persistent Toggle\r\n     * ```typescript\r\n     * const theme = signalPlus.presets.toggle(false)\r\n     *   .persist('theme-mode')\r\n     *   .build();\r\n     * \r\n     * theme.subscribe(dark => {\r\n     *   document.body.classList.toggle('dark', dark);\r\n     * });\r\n     * ```\r\n     */\r\n    toggle: (initial = false): SignalBuilder<boolean> => {\r\n        return new SignalBuilder(initial)\r\n            .withHistory();\r\n    },\r\n\r\n    /**\r\n     * Creates a form input with validation and features\r\n     * \r\n     * @template T Type of form value\r\n     * @param options Form input configuration\r\n     * @returns SignalBuilder configured for form handling\r\n     * \r\n     * @remarks\r\n     * The form input preset provides:\r\n     * - Value validation\r\n     * - Persistence\r\n     * - Debounced updates\r\n     * - History tracking\r\n     * - Error handling\r\n     * \r\n     * Use this preset when you need:\r\n     * - Form field state\r\n     * - Input validation\r\n     * - Auto-save\r\n     * - Undo/redo\r\n     * \r\n     * @example Text Input\r\n     * ```typescript\r\n     * const username = signalPlus.presets.formInput({\r\n     *   initial: '',\r\n     *   key: 'username',\r\n     *   validator: value => value.length >= 3,\r\n     *   debounce: 300\r\n     * });\r\n     * ```\r\n     * \r\n     * @example Number Input\r\n     * ```typescript\r\n     * const age = signalPlus.presets.formInput({\r\n     *   initial: 0,\r\n     *   validator: value => value >= 0 && value <= 120,\r\n     *   debounce: 500\r\n     * });\r\n     * \r\n     * age.subscribe(value => {\r\n     *   if (age.isValid()) {\r\n     *     updateProfile({ age: value });\r\n     *   }\r\n     * });\r\n     * ```\r\n     */\r\n    formInput: <T>(options: FormConfig<T>): SignalBuilder<T> => {\r\n        const builder = new SignalBuilder(options.initial);\r\n        if (options.validator) {\r\n            builder.validate(options.validator);\r\n        }\r\n        if (options.debounce) {\r\n            builder.debounce(options.debounce);\r\n        }\r\n        if (options.key) {\r\n            builder.persist(options.key);\r\n        }\r\n        return builder.withHistory();\r\n    },\r\n\r\n    /**\r\n     * Creates a search input with built-in debounce and duplicate filtering.\r\n     * Optimized for search field behavior with automatic performance tuning.\r\n     * \r\n     * @param initial - Initial search text (defaults to empty string)\r\n     * @returns SignalPlus<string> configured for search operations\r\n     * \r\n     * @example\r\n     * ```typescript\r\n     * const search = signalPlus.presets.searchField();\r\n     * search.subscribe(value => performSearch(value));\r\n     * ```\r\n     */\r\n    searchField: (initial = ''): SignalBuilder<string> => {\r\n        return new SignalBuilder(initial)\r\n            .debounce(300)\r\n            .distinct()\r\n            .withHistory();\r\n    },\r\n\r\n    /**\r\n     * Creates a persistent toggle with automatic storage and history.\r\n     * Perfect for app-wide settings that need to persist across sessions.\r\n     * \r\n     * @param initial - Initial toggle state (defaults to false)\r\n     * @param key - Storage key for persistence\r\n     * @returns SignalPlus<boolean> configured for persistent toggle operations\r\n     * \r\n     * @example\r\n     * ```typescript\r\n     * const theme = signalPlus.presets.persistentToggle(false, 'theme-mode');\r\n     * theme.subscribe(isDark => updateTheme(isDark));\r\n     * ```\r\n     */\r\n    persistentToggle: (initial = false, key: string): SignalBuilder<boolean> => {\r\n        return new SignalBuilder(initial)\r\n            .persist(key)\r\n            .withHistory();\r\n    }\r\n};\r\n\r\n/**\r\n * Collection of commonly used validation functions organized by data type.\r\n * These validators can be composed and reused across different signals.\r\n * \r\n * @example\r\n * ```typescript\r\n * const amount = signalPlus.create(0)\r\n *   .validate(validators.number.positive)\r\n *   .validate(validators.number.range(0, 100))\r\n *   .build();\r\n * ```\r\n */\r\nexport const validators = {\r\n    number: {\r\n        /** Ensures value is greater than or equal to zero */\r\n        positive: (x: number) => x >= 0,\r\n        /** Ensures value is an integer */\r\n        integer: (x: number) => Number.isInteger(x),\r\n        /** Creates a validator for checking if value is within specified range */\r\n        range: (min: number, max: number) => (x: number) => x >= min && x <= max\r\n    },\r\n    string: {\r\n        /** Ensures string is not empty */\r\n        notEmpty: (x: string) => x.length > 0,\r\n        /** Creates a validator for checking maximum string length */\r\n        maxLength: (max: number) => (x: string) => x.length <= max,\r\n        /** Creates a validator for matching string against a pattern */\r\n        pattern: (regex: RegExp) => (x: string) => regex.test(x)\r\n    },\r\n    array: {\r\n        /** Ensures array is not empty */\r\n        notEmpty: <T>(x: T[]) => x.length > 0,\r\n        /** Creates a validator for checking maximum array length */\r\n        maxLength: (max: number) => <T>(x: T[]) => x.length <= max\r\n    }\r\n};","/**\r\n * @fileoverview Core service for managing enhanced Angular signals\r\n * @description Provides a simplified API for creating and managing signals with additional features.\r\n * This service is the main entry point for creating and managing enhanced signals.\r\n * \r\n * The service provides three levels of API complexity:\r\n * 1. Presets for common use cases (counter, toggle, form)\r\n * 2. Simple creation with basic options (validation, storage)\r\n * 3. Builder pattern for advanced configuration (history, transforms)\r\n * \r\n * @example Basic Usage with Presets\r\n * ```typescript\r\n * const counter = signalPlus.presets.counter(0);\r\n * const toggle = signalPlus.presets.toggle(false);\r\n * ```\r\n * \r\n * @example Form Input with Validation\r\n * ```typescript\r\n * const name = signalPlus.presets.formInput({\r\n *   initial: '',\r\n *   key: 'user-name',\r\n *   validator: signalPlus.validators.string.notEmpty\r\n * });\r\n * ```\r\n * \r\n * @example Advanced Configuration\r\n * ```typescript\r\n * const advanced = signalPlus.create(0)\r\n *   .persist('counter')\r\n *   .validate(x => x >= 0)\r\n *   .transform(Math.round)\r\n *   .withHistory()\r\n *   .build();\r\n * ```\r\n */\r\n\r\nimport { Injectable, OnDestroy } from '@angular/core';\r\nimport { CounterConfig, FormConfig, SignalPlus, SimpleSignalOptions } from '../models/signal-plus.model';\r\nimport { validators } from '../utils/presets';\r\nimport { SignalBuilder } from './signal-builder';\r\n\r\n/**\r\n * Injectable service that provides the core functionality for creating and managing enhanced signals.\r\n * Implements OnDestroy for proper cleanup of resources.\r\n */\r\n@Injectable({\r\n  providedIn: 'root'\r\n})\r\nexport class SignalPlusService implements OnDestroy {\r\n  /** Internal set of cleanup functions to be executed on service destruction */\r\n  private readonly cleanup: Set<() => void> = new Set<() => void>();\r\n\r\n  /**\r\n   * Creates a new signal builder for advanced configuration.\r\n   * @param initialValue The initial value of the signal\r\n   * @returns A SignalBuilder instance for chaining configuration\r\n   * @throws {Error} If initialValue is undefined\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * const signal = signalPlus.create(0)\r\n   *   .persist('key')\r\n   *   .validate(x => x >= 0)\r\n   *   .build();\r\n   * ```\r\n   */\r\n  create<T>(initialValue: T): SignalBuilder<T> {\r\n    if (initialValue === undefined) {\r\n      throw new Error('Initial value cannot be undefined');\r\n    }\r\n    return new SignalBuilder<T>(initialValue);\r\n  }\r\n\r\n  /**\r\n   * Creates a signal with common options and error handling.\r\n   * @param initialValue The initial value of the signal\r\n   * @param options Configuration options for the signal\r\n   * @returns A SignalPlus instance with the specified configuration\r\n   * @throws {Error} If validation fails and no error handler is provided\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * const input = signalPlus.createSimple('', {\r\n   *   key: 'form-input',\r\n   *   validator: signalPlus.validators.string.notEmpty,\r\n   *   onError: console.error\r\n   * });\r\n   * ```\r\n   */\r\n  createSimple<T>(\r\n    initialValue: T,\r\n    options?: SimpleSignalOptions<T>\r\n  ): SignalPlus<T> {\r\n    try {\r\n      const builder: SignalBuilder<T> = this.create(initialValue);\r\n\r\n      if (options?.key) {\r\n        builder.persist(options.key);\r\n      }\r\n\r\n      if (options?.validator) {\r\n        builder.validate(options.validator);\r\n      }\r\n\r\n      if (options?.debounce) {\r\n        if (options.debounce < 0) {\r\n          throw new Error('Debounce time must be positive');\r\n        }\r\n        builder.debounce(options.debounce);\r\n      }\r\n\r\n      if (options?.history) {\r\n        builder.withHistory();\r\n      }\r\n\r\n      if (options?.onError) {\r\n        builder.onError(options.onError);\r\n      }\r\n\r\n      return builder.build();\r\n    } catch (error) {\r\n      if (options?.onError) {\r\n        options.onError(error as Error);\r\n      }\r\n      return SignalBuilder.mock({ initialValue });\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Collection of predefined validators for different data types.\r\n   * Includes validators for strings, numbers, arrays, and custom types.\r\n   * @see {@link validators} for available validation rules\r\n   */\r\n  readonly validators: typeof validators = validators;\r\n\r\n  /**\r\n   * Cleanup resources when service is destroyed.\r\n   * Executes all registered cleanup functions and clears the set.\r\n   * @internal\r\n   */\r\n  ngOnDestroy(): void {\r\n    this.cleanup.forEach(cleanup => cleanup());\r\n    this.cleanup.clear();\r\n  }\r\n\r\n  /**\r\n   * Static helper to create a new signal builder.\r\n   * Provides the same functionality as instance create() method.\r\n   * @param value The initial value of the signal\r\n   * @returns A SignalBuilder instance for chaining configuration\r\n   * @throws {Error} If value is undefined\r\n   */\r\n  static create<T>(value: T) {\r\n    return new SignalBuilder<T>(value);\r\n  }\r\n\r\n  /**\r\n   * Static helper to create a counter signal with validation.\r\n   * Configures bounds checking and history tracking.\r\n   * @param config Optional configuration for initial value and bounds\r\n   * @returns A SignalBuilder configured for counter behavior\r\n   */\r\n  static counter(config?: CounterConfig) {\r\n    return SignalPlusService.create(config?.initial ?? 0)\r\n      .validate(x => x >= (config?.min ?? 0))\r\n      .validate(x => x <= (config?.max ?? Infinity))\r\n      .withHistory();\r\n  }\r\n\r\n  /**\r\n   * Static helper to create a form input signal.\r\n   * Configures validation, debouncing, and persistence.\r\n   * @param config Form input configuration options\r\n   * @returns A SignalBuilder configured for form input behavior\r\n   */\r\n  static form<T>(config: FormConfig<T>) {\r\n    return SignalPlusService.create(config.initial)\r\n      .validate(config.validator || (() => true))\r\n      .debounce(config.debounce ?? 300)\r\n      .persist(config.key);\r\n  }\r\n}","/**\r\n * @fileoverview SignalPlus Demo Component\r\n * @description A standalone component that demonstrates the core features of the SignalPlus library.\r\n * This component serves as both documentation and a testing ground for the library's functionality.\r\n * \r\n * Features demonstrated:\r\n * - Basic signal presets (counter, toggle)\r\n * - Form input handling with validation\r\n * - Persistent storage integration\r\n * - History tracking and undo/redo\r\n * - Debounced search functionality\r\n * \r\n * @example\r\n * ```typescript\r\n * // Standalone component usage\r\n * @Component({\r\n *   imports: [SignalPlusComponent]\r\n * })\r\n * \r\n * // Or in NgModule\r\n * @NgModule({\r\n *   imports: [SignalPlusComponent]\r\n * })\r\n * ```\r\n */\r\n\r\nimport { CommonModule } from '@angular/common';\r\nimport { Component, inject } from '@angular/core';\r\nimport { SignalPlus } from '../models/signal-plus.model';\r\nimport { SignalPlusService } from './signal-plus.service';\r\nimport { sp, spCounter, spForm, spToggle } from '../utils/create';\r\nimport { SignalBuilder } from '../core/signal-builder';\r\n\r\n/**\r\n * Demo component showcasing SignalPlus features and usage patterns.\r\n * Provides interactive examples of different signal types and configurations.\r\n */\r\n@Component({\r\n  selector: 'lib-signal-plus',\r\n  standalone: true,\r\n  imports: [CommonModule],\r\n  template: `\r\n    <div class=\"signal-plus-demo\">\r\n      <h3>Signal Plus Demo</h3>\r\n      \r\n      <div class=\"counter\">\r\n        <h4>Basic Counter (Preset)</h4>\r\n        <p>Current value: {{ counter.value }}</p>\r\n        <p>Previous value: {{ counter.previousValue }}</p>\r\n        <p>Is valid: {{ counter.isValid() ? 'Yes' : 'No' }}</p>\r\n        \r\n        <button (click)=\"increment()\">Increment</button>\r\n        <button (click)=\"decrement()\">Decrement</button>\r\n        <button (click)=\"counter.reset()\">Reset</button>\r\n        <button (click)=\"counter.undo()\" [disabled]=\"!canUndo()\">Undo</button>\r\n      </div>\r\n\r\n      <div class=\"form\">\r\n        <h4>Text Input (Simple Creation)</h4>\r\n        <input [value]=\"input.value\" \r\n               (input)=\"handleInput($event)\"\r\n               placeholder=\"Type here...\">\r\n        <p class=\"hint\">Value updates after 300ms of inactivity</p>\r\n      </div>\r\n\r\n      <div class=\"amount\">\r\n        <h4>Amount Input (Builder Pattern)</h4>\r\n        <p>Value: {{ amount.value }}</p>\r\n        <input type=\"number\" \r\n               [value]=\"amount.value\"\r\n               [class.invalid]=\"!amount.isValid()\"\r\n               (input)=\"updateAmount($event)\">\r\n        @if (!amount.isValid()) {\r\n          <p class=\"error-message\">Value must be between 0 and 10</p>\r\n        }\r\n      </div>\r\n\r\n      <div class=\"toggle\">\r\n        <h4>Theme Toggle (Persistent)</h4>\r\n        <button (click)=\"onThemeChange()\">\r\n          {{ darkMode.value ? 'Dark' : 'Light' }} Mode\r\n        </button>\r\n      </div>\r\n\r\n      <div class=\"search\">\r\n        <h4>Search Input (Debounced)</h4>\r\n        <input [value]=\"search.value\"\r\n               (input)=\"onSearch($event)\"\r\n               placeholder=\"Search...\">\r\n        <p class=\"hint\">Last search: {{ search.value }}</p>\r\n      </div>\r\n    </div>\r\n  `,\r\n  styles: [`\r\n    .signal-plus-demo {\r\n      padding: 1rem;\r\n      border: 1px solid #ccc;\r\n      border-radius: 4px;\r\n    }\r\n    \r\n    .counter, .form, .amount {\r\n      margin-top: 1rem;\r\n      padding: 1rem;\r\n      background: #f5f5f5;\r\n      border-radius: 4px;\r\n    }\r\n    \r\n    input {\r\n      padding: 0.5rem;\r\n      border: 1px solid #ccc;\r\n      border-radius: 4px;\r\n      width: 100%;\r\n      max-width: 300px;\r\n    }\r\n\r\n    input:focus {\r\n      outline: none;\r\n      border-color: #007bff;\r\n    }\r\n\r\n    input.invalid {\r\n      border-color: #dc3545;\r\n    }\r\n    \r\n    button {\r\n      margin-right: 0.5rem;\r\n      padding: 0.5rem 1rem;\r\n      border: none;\r\n      border-radius: 4px;\r\n      background: #007bff;\r\n      color: white;\r\n      cursor: pointer;\r\n    }\r\n    \r\n    button:disabled {\r\n      background: #ccc;\r\n      cursor: not-allowed;\r\n    }\r\n\r\n    .error-message {\r\n      color: #dc3545;\r\n      font-size: 0.875rem;\r\n      margin-top: 0.25rem;\r\n    }\r\n  `]\r\n})\r\nexport class SignalPlusComponent {\r\n  /** Service instance for creating and managing signals */\r\n  private readonly signalPlus: SignalPlusService = inject(SignalPlusService);\r\n\r\n  /**\r\n   * Basic counter with integer validation and history tracking.\r\n   * Demonstrates the simplest usage pattern with presets.\r\n   * Features:\r\n   * - Integer validation\r\n   * - History tracking for undo\r\n   * - Reset capability\r\n   */\r\n  readonly counter = spCounter(0, { min: 0 });\r\n\r\n  /**\r\n   * Text input with debounce and persistence.\r\n   * Shows how to handle form inputs with automatic storage.\r\n   * Features:\r\n   * - Debounced updates (300ms)\r\n   * - Persistent storage\r\n   * - Automatic value sync\r\n   */\r\n  readonly input = spForm.text('', { \r\n    minLength: 3,\r\n    debounce: 300\r\n  });\r\n\r\n  /**\r\n   * Number input with range validation.\r\n   * Demonstrates validation and error handling.\r\n   * Features:\r\n   * - Range validation (0-10)\r\n   * - Error state handling\r\n   * - Visual feedback\r\n   */\r\n  readonly amount = new SignalBuilder(0)\r\n    .validate((value: number) => value >= 0 && value <= 10)\r\n    .onError((error: Error) => {\r\n        console.error(error);\r\n    })\r\n    .build();\r\n\r\n  /**\r\n   * Theme toggle with persistent storage.\r\n   * Shows how to maintain state across page reloads.\r\n   * Features:\r\n   * - Boolean state management\r\n   * - Local storage persistence\r\n   * - Immediate UI updates\r\n   */\r\n  readonly darkMode = spToggle(false, 'theme-mode');\r\n\r\n  /**\r\n   * Search field with debounce and distinct values.\r\n   * Demonstrates time-based operations and duplicate filtering.\r\n   * Features:\r\n   * - Debounced input\r\n   * - Distinct value filtering\r\n   * - Real-time updates\r\n   */\r\n  readonly search = spForm.text('', {\r\n    debounce: 300,\r\n    minLength: 2\r\n  });\r\n\r\n  /**\r\n   * Increments the counter value.\r\n   * Uses update pattern for atomic operations.\r\n   * Ensures thread-safe value updates.\r\n   */\r\n  increment(): void {\r\n    this.counter.update((value: number) => value + 1);\r\n  }\r\n\r\n  /**\r\n   * Decrements the counter value.\r\n   * Uses update pattern for atomic operations.\r\n   * Ensures thread-safe value updates.\r\n   */\r\n  decrement(): void {\r\n    this.counter.update((value: number) => value - 1);\r\n  }\r\n\r\n  /**\r\n   * Handles text input changes with type safety.\r\n   * @param event Input event from text field\r\n   * Automatically debounces updates and persists value.\r\n   */\r\n  handleInput(event: Event): void {\r\n    const target: HTMLInputElement = event.target as HTMLInputElement;\r\n    this.input.setValue(target.value);\r\n  }\r\n\r\n  /**\r\n   * Updates amount with validation.\r\n   * @param event Input event from number field\r\n   * Validates range and provides error feedback.\r\n   */\r\n  updateAmount(event: Event): void {\r\n    const target: HTMLInputElement = event.target as HTMLInputElement;\r\n    const value: number = +target.value;\r\n    try {\r\n        this.amount.setValue(value);\r\n    } catch (error) {\r\n        console.error(error);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Handles search input with debounce.\r\n   * @param event Input event from search field\r\n   * Provides real-time search functionality with performance optimization.\r\n   */\r\n  onSearch(event: Event): void {\r\n    const value: string = (event.target as HTMLInputElement).value;\r\n    this.search.setValue(value);\r\n  }\r\n\r\n  /**\r\n   * Toggles theme mode with persistence.\r\n   * Uses update pattern for boolean toggle.\r\n   * Automatically persists preference to localStorage.\r\n   */\r\n  onThemeChange(): void {\r\n    this.darkMode.update((value: boolean) => !value);\r\n  }\r\n\r\n  /**\r\n   * Checks if undo operation is available.\r\n   * @returns boolean indicating if undo is possible\r\n   * Ensures undo button is disabled when no history exists.\r\n   */\r\n  canUndo(): boolean {\r\n    return this.counter.history().length > 1;\r\n  }\r\n}","/**\r\n * @fileoverview Core functionality exports for ngx-signal-plus\r\n * @description Exports essential components and services for basic usage\r\n */\r\n\r\n// Core components and services\r\nexport { SignalBuilder as spSignalBuilder } from './signal-builder';\r\nexport { SignalPlusComponent as spSignalPlusComponent } from './signal-plus.component';\r\nexport { SignalPlusService as spSignalPlusService } from './signal-plus.service';","/**\r\n * @fileoverview Collection of operators for transforming and manipulating Angular signals\r\n * @module ngx-signal-plus/operators\r\n * \r\n * @description\r\n * This module provides a comprehensive set of operators for Angular signals, including:\r\n * - Value transformation (map, filter)\r\n * - Time-based operations (debounce, throttle, delay)\r\n * - State management (skip, take)\r\n * - Signal combination (merge, combineLatest)\r\n * \r\n * All operators are designed to be:\r\n * - Type-safe with full generic support\r\n * - Memory-efficient with proper cleanup\r\n * - Compatible with Angular's change detection\r\n * - Safe for server-side rendering\r\n * \r\n * @example Basic Usage\r\n * ```typescript\r\n * import { signal } from '@angular/core';\r\n * import { map, filter, debounceTime } from 'ngx-signal-plus/operators';\r\n * \r\n * const source = signal(0);\r\n * const result = source.pipe(\r\n *   filter(x => x > 0),\r\n *   map(x => x * 2),\r\n *   debounceTime(300)\r\n * );\r\n * ```\r\n * \r\n * @example Advanced Usage\r\n * ```typescript\r\n * // Combine multiple signals\r\n * const name = signal('John');\r\n * const age = signal(25);\r\n * const user = combineLatest([name, age]).pipe(\r\n *   map(([n, a]) => ({ name: n, age: a })),\r\n *   filter(u => u.age >= 18)\r\n * );\r\n * \r\n * // Time-based operations\r\n * const search = signal('');\r\n * const results = search.pipe(\r\n *   debounceTime(300),\r\n *   distinctUntilChanged(),\r\n *   filter(term => term.length >= 2)\r\n * );\r\n * ```\r\n */\r\n\r\nimport { computed, DestroyRef, effect, inject, Injector, runInInjectionContext, Signal, signal, WritableSignal } from '@angular/core';\r\n\r\n/**\r\n * Type definition for signal operators that can transform signal types\r\n * @template TInput The input signal type\r\n * @template TOutput The output signal type (defaults to TInput)\r\n * \r\n * @remarks\r\n * Operators are functions that take a signal and return a new signal.\r\n * They can transform both the value type and timing of updates.\r\n */\r\nexport interface SignalOperator<T, R = T> {\r\n  (signal: Signal<T>): Signal<R>;\r\n}\r\n\r\n/**\r\n * Combines multiple signals into a single signal of array values\r\n * @param signals Array of signals to combine\r\n * @returns Signal emitting array of latest values\r\n * \r\n * @remarks\r\n * - Updates when any input signal changes\r\n * - Output array maintains input signal order\r\n * - All signals must emit at least once\r\n * \r\n * @example\r\n * ```typescript\r\n * const first = signal('John');\r\n * const last = signal('Doe');\r\n * const fullName = combineLatest([first, last])\r\n *   .pipe(map(([f, l]) => `${f} ${l}`));\r\n * ```\r\n */\r\nexport function combineLatest<T>(signals: Signal<T>[]): Signal<T[]> {\r\n  return computed(() => signals.map(s => s()));\r\n}\r\n\r\n/**\r\n * Merges multiple signals into a single signal\r\n * @param signals Signals to merge\r\n * @returns Signal emitting values from all inputs\r\n * \r\n * @remarks\r\n * - Updates when any input signal changes\r\n * - Maintains value type consistency\r\n * - Order of emissions is preserved\r\n * \r\n * @example\r\n * ```typescript\r\n * const clicks = signal(0);\r\n * const updates = signal(0);\r\n * const all = merge(clicks, updates)\r\n *   .pipe(distinctUntilChanged());\r\n * ```\r\n */\r\nexport function merge<T>(...signals: Signal<T>[]): Signal<T> {\r\n  // Handle empty array case\r\n  if (signals.length === 0) {\r\n    return signal<T>(undefined as T);\r\n  }\r\n\r\n  const output: WritableSignal<T> = signal<T>(signals[0]());\r\n\r\n  if (typeof window !== 'undefined') {\r\n    const injector = inject(Injector);\r\n    runInInjectionContext(injector, () => {\r\n      signals.forEach(s => {\r\n        effect(() => output.set(s()));\r\n      });\r\n    });\r\n  }\r\n\r\n  return output;\r\n}\r\n\r\n/**\r\n * Delays signal emissions by specified time\r\n * @param time Delay duration in milliseconds\r\n * @returns Operator that delays emissions\r\n * \r\n * @remarks\r\n * - Uses setTimeout internally\r\n * - Maintains value order\r\n * - Cleans up pending timeouts\r\n * \r\n * @example\r\n * ```typescript\r\n * const delayed = source.pipe(\r\n *   delay(1000), // 1 second delay\r\n *   distinctUntilChanged()\r\n * );\r\n * ```\r\n */\r\nexport function delay<T>(time: number): SignalOperator<T, T> {\r\n  return (input: Signal<T>) => {\r\n    const output: WritableSignal<T> = signal<T>(input());\r\n    let timeoutId: ReturnType<typeof setTimeout> | null = null;\r\n\r\n    runInInjectionContext(inject(Injector), () => {\r\n      effect(() => {\r\n        const value: T = input();\r\n        \r\n        // Clear previous timeout to prevent memory leak\r\n        if (timeoutId !== null) {\r\n          clearTimeout(timeoutId);\r\n        }\r\n        \r\n        timeoutId = setTimeout(() => {\r\n          output.set(value);\r\n          timeoutId = null;\r\n        }, time);\r\n      });\r\n    });\r\n\r\n    return output;\r\n  };\r\n}\r\n\r\n/**\r\n * Limits signal emissions to specified time interval\r\n * @param time Minimum time between emissions\r\n * @returns Operator that throttles emissions\r\n * \r\n * @remarks\r\n * - Emits first value immediately (leading-only throttle)\r\n * - Ignores values during throttle period (no trailing emission)\r\n * - Resets timer on completion\r\n * - Includes DestroyRef cleanup\r\n * \r\n * @example\r\n * ```typescript\r\n * const throttled = scroll.pipe(\r\n *   throttleTime(100), // Max 10 updates per second\r\n *   map(e => e.scrollY)\r\n * );\r\n * ```\r\n */\r\nexport function throttleTime<T>(time: number): SignalOperator<T, T> {\r\n  return (input: Signal<T>) => {\r\n    const output: WritableSignal<T> = signal<T>(input());\r\n    let lastRun: number = 0;\r\n    const destroyRef: DestroyRef = inject(DestroyRef);\r\n\r\n    runInInjectionContext(inject(Injector), () => {\r\n      effect(() => {\r\n        const now: number = Date.now();\r\n        const value: T = input();\r\n\r\n        if (now - lastRun >= time) {\r\n          output.set(value);\r\n          lastRun = now;\r\n        }\r\n      });\r\n    });\r\n\r\n    // Cleanup on destroy (reset lastRun to prevent stale state)\r\n    destroyRef.onDestroy(() => {\r\n      lastRun = 0;\r\n    });\r\n\r\n    return output;\r\n  };\r\n}\r\n\r\n/**\r\n * Skips specified number of signal emissions\r\n * @param count Number of emissions to skip\r\n * @returns Operator that skips initial values\r\n * \r\n * @remarks\r\n * - Maintains internal counter\r\n * - Resets on signal completion\r\n * - Zero count skips nothing\r\n * \r\n * @example\r\n * ```typescript\r\n * const skipFirst = source.pipe(\r\n *   skip(1), // Skip first value\r\n *   filter(Boolean)\r\n * );\r\n * ```\r\n */\r\nexport function skip<T>(count: number): SignalOperator<T> {\r\n  return (source: Signal<T>) => {\r\n    const skipped: WritableSignal<T> = signal<T>(source());\r\n    let skipCount: number = -1; // Start at -1 to handle initial value\r\n\r\n    runInInjectionContext(inject(Injector), () => {\r\n      effect(() => {\r\n        const value: T = source();\r\n        skipCount++;\r\n        // Only emit after we've skipped enough values\r\n        if (skipCount >= count) {\r\n          skipped.set(value);\r\n        }\r\n      });\r\n    });\r\n\r\n    return skipped.asReadonly();\r\n  };\r\n}\r\n\r\n/**\r\n * Takes specified number of signal emissions\r\n * @param count Number of emissions to take\r\n * @returns Operator that limits emissions\r\n * \r\n * @remarks\r\n * - Maintains internal counter\r\n * - Completes after count reached\r\n * - Zero count takes nothing\r\n * \r\n * @example\r\n * ```typescript\r\n * const first3 = source.pipe(\r\n *   take(3), // Take first 3 values\r\n *   map(String)\r\n * );\r\n * ```\r\n */\r\nexport function take<T>(count: number): SignalOperator<T> {\r\n  return (source: Signal<T>) => {\r\n    const taken: WritableSignal<T> = signal<T>(source());\r\n    let emitCount: number = 0;\r\n\r\n    runInInjectionContext(inject(Injector), () => {\r\n      effect(() => {\r\n        const value: T = source();\r\n        // Always emit until count is reached\r\n        if (emitCount < count) {\r\n          taken.set(value);\r\n          emitCount++;\r\n        }\r\n      });\r\n    });\r\n\r\n    return taken.asReadonly();\r\n  };\r\n}\r\n\r\n/**\r\n * Debounces signal emissions by specified time\r\n * @param duration Debounce duration in milliseconds\r\n * @returns Operator that debounces emissions\r\n * \r\n * @remarks\r\n * - Waits for quiet period\r\n * - Cancels pending timeouts\r\n * - Ideal for input handling\r\n * \r\n * @example\r\n * ```typescript\r\n * const search = input.pipe(\r\n *   debounceTime(300), // Wait for typing to stop\r\n *   filter(term => term.length > 2)\r\n * );\r\n * ```\r\n */\r\nexport function debounceTime<T>(duration: number): SignalOperator<T> {\r\n  return (source: Signal<T>) => {\r\n    const output: WritableSignal<T> = signal<T>(source());\r\n    let timeoutId: ReturnType<typeof setTimeout> | null = null;\r\n    const injector: Injector = inject(Injector);\r\n    const destroyRef: DestroyRef = inject(DestroyRef);\r\n\r\n    runInInjectionContext(injector, () => {\r\n      let lastValue: T = source();\r\n      output.set(lastValue);\r\n\r\n      effect(() => {\r\n        const value: T = source();\r\n\r\n        // Skip if value hasn't changed\r\n        if (Object.is(value, lastValue)) {\r\n          return;\r\n        }\r\n\r\n        // Clear existing timeout\r\n        if (timeoutId !== null) {\r\n          clearTimeout(timeoutId);\r\n        }\r\n\r\n        // Schedule new update\r\n        timeoutId = setTimeout(() => {\r\n          runInInjectionContext(injector, () => {\r\n            output.set(value);\r\n            lastValue = value;\r\n          });\r\n          timeoutId = null; // Reset after firing\r\n        }, duration);\r\n      });\r\n\r\n      destroyRef.onDestroy(() => {\r\n        if (timeoutId !== null) {\r\n          clearTimeout(timeoutId);\r\n          timeoutId = null;\r\n        }\r\n      });\r\n    });\r\n\r\n    return output.asReadonly();\r\n  };\r\n}\r\n\r\n/**\r\n * Filters out consecutive duplicate values using deep comparison\r\n * @returns Operator that removes duplicates\r\n * \r\n * @remarks\r\n * - Uses deep value comparison (JSON serialization)\r\n * - Compares object/array contents, not just references\r\n * - Falls back to string comparison for non-serializable values\r\n * - Maintains previous value\r\n * - Memory efficient\r\n * \r\n * @example\r\n * ```typescript\r\n * const unique = source.pipe(\r\n *   distinctUntilChanged(),\r\n *   filter(Boolean)\r\n * );\r\n * \r\n * // Deep comparison for objects\r\n * signal.set({ a: 1 }); // Emits\r\n * signal.set({ a: 1 }); // Skipped (same value)\r\n * signal.set({ a: 2 }); // Emits (different value)\r\n * ```\r\n */\r\nexport function distinctUntilChanged<T>(): SignalOperator<T> {\r\n  return (source: Signal<T>) => {\r\n    // Helper function for deep value comparison\r\n    const serializeValue = (value: T): string => {\r\n      try {\r\n        return JSON.stringify(value);\r\n      } catch {\r\n        // Fallback for non-serializable values (functions, circular refs, etc.)\r\n        return String(value);\r\n      }\r\n    };\r\n    \r\n    let lastValue: T = source();\r\n    let lastSerialized: string = serializeValue(lastValue);\r\n\r\n    // Use computed for synchronous updates\r\n    return computed(() => {\r\n      const value: T = source();\r\n      const serialized: string = serializeValue(value);\r\n      \r\n      // Compare serialized values for deep equality\r\n      if (serialized !== lastSerialized) {\r\n        lastValue = value;\r\n        lastSerialized = serialized;\r\n      }\r\n      \r\n      return lastValue;\r\n    });\r\n  };\r\n}\r\n\r\n/**\r\n * Maps signal values through transform function\r\n * @param fn Transform function\r\n * @returns Operator that transforms values\r\n * \r\n * @remarks\r\n * - Type-safe transformation\r\n * - Synchronous operation\r\n * - No value caching\r\n * \r\n * @example\r\n * ```typescript\r\n * const doubled = numbers.pipe(\r\n *   map(n => n * 2),\r\n *   filter(n => n > 0)\r\n * );\r\n * ```\r\n */\r\nexport function map<T, R>(fn: (value: T) => R): SignalOperator<T, R> {\r\n  return (signal: Signal<T>) => computed(() => {\r\n    try {\r\n      return fn(signal());\r\n    } catch (error) {\r\n      console.error('Error in signal map operator:', error);\r\n      throw error;\r\n    }\r\n  });\r\n}\r\n\r\n/**\r\n * Filters signal values based on predicate\r\n * @param predicateFn Filter predicate function\r\n * @returns Operator that filters values\r\n * \r\n * @remarks\r\n * - Type-safe predicate\r\n * - Synchronous operation\r\n * - False values dropped\r\n * \r\n * @example\r\n * ```typescript\r\n * const positive = numbers.pipe(\r\n *   filter(n => n > 0),\r\n *   map(String)\r\n * );\r\n * ```\r\n */\r\nexport function filter<T>(predicateFn: (value: T) => boolean): SignalOperator<T> {\r\n  return (input: Signal<T>) => {\r\n    const initialValue: T = input();\r\n    let lastValidValue: T = initialValue;\r\n\r\n    // Check if initial value passes predicate\r\n    try {\r\n      if (predicateFn(initialValue)) {\r\n        lastValidValue = initialValue;\r\n      }\r\n    } catch (e) {\r\n      // Keep initial value on error\r\n    }\r\n\r\n    return computed(() => {\r\n      try {\r\n        const value: T = input();\r\n        if (predicateFn(value)) {\r\n          lastValidValue = value;\r\n          return value;\r\n        }\r\n        return lastValidValue;\r\n      } catch (e) {\r\n        return lastValidValue;\r\n      }\r\n    });\r\n  };\r\n} ","/**\r\n * @fileoverview Operator exports for ngx-signal-plus\r\n */\r\n\r\nexport {\r\n    map as spMap,\r\n    filter as spFilter,\r\n    debounceTime as spDebounceTime,\r\n    distinctUntilChanged as spDistinctUntilChanged,\r\n    delay as spDelay,\r\n    throttleTime as spThrottleTime,\r\n    skip as spSkip,\r\n    take as spTake,\r\n    merge as spMerge,\r\n    combineLatest as spCombineLatest\r\n} from './signal-operators'; ","/**\r\n * @fileoverview History management system for signal values\r\n * Provides undo/redo functionality with a fixed-size circular buffer.\r\n * \r\n * Features:\r\n * - Type-safe history tracking with generics\r\n * - Fixed-size buffer to prevent memory leaks\r\n * - Undo/redo operations with state tracking\r\n * - Current state access and validation\r\n * \r\n * @example Basic Usage\r\n * ```typescript\r\n * const history = new HistoryManager(0);\r\n * history.push(1);\r\n * history.push(2);\r\n * history.undo(); // Returns to 1\r\n * history.redo(); // Returns to 2\r\n * ```\r\n */\r\n\r\nimport { SignalHistory } from '../models/signal-plus.model';\r\n\r\n/**\r\n * Manages undo/redo history for signal values with a fixed-size buffer.\r\n * \r\n * @remarks\r\n * This class provides a robust history management system with:\r\n * - Fixed-size circular buffer to prevent memory leaks\r\n * - Type-safe operations with generics\r\n * - Undo/redo functionality with state validation\r\n * - Automatic cleanup of old entries\r\n * \r\n * @typeParam T - The type of value being tracked in history\r\n */\r\nexport class HistoryManager<T> {\r\n  /** Maximum number of history entries to maintain. Prevents unbounded memory growth */\r\n  private readonly maxHistory = 50;\r\n  \r\n  /** \r\n   * Internal history state tracking past, present, and future values.\r\n   * Past: Array of previous values for undo operations\r\n   * Present: Current active value\r\n   * Future: Array of undone values for redo operations\r\n   */\r\n  private history: SignalHistory<T>;\r\n\r\n  /**\r\n   * Creates a new history manager instance\r\n   * \r\n   * @param initialValue - The initial value to track\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * const manager = new HistoryManager(0);\r\n   * manager.push(1);  // History: [0] -> 1\r\n   * manager.push(2);  // History: [0, 1] -> 2\r\n   * manager.undo();   // History: [0] -> 1 [2]\r\n   * ```\r\n   */\r\n  constructor(initialValue: T) {\r\n    this.history = {\r\n      past: [],\r\n      present: initialValue,\r\n      future: []\r\n    };\r\n  }\r\n\r\n  /**\r\n   * Pushes a new value onto the history stack\r\n   * \r\n   * @param value - The new value to add to history\r\n   * @remarks\r\n   * - Clears the redo stack (future values)\r\n   * - Maintains the maximum history size by removing oldest entries\r\n   * - Updates the present value and moves current to past\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * manager.push(5);  // Adds 5 to history\r\n   * manager.push(10); // Adds 10 and moves 5 to past\r\n   * ```\r\n   */\r\n  push(value: T): void {\r\n    this.history.past.push(this.history.present);\r\n    this.history.present = value;\r\n    this.history.future = [];\r\n\r\n    if (this.history.past.length > this.maxHistory) {\r\n      this.history.past.shift();\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Reverts to the previous value in history\r\n   * \r\n   * @returns The previous value, or undefined if no history exists\r\n   * @remarks\r\n   * - Moves present value to future for redo\r\n   * - Updates present value to last past entry\r\n   * - Removes used past entry\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * manager.push(1);\r\n   * manager.push(2);\r\n   * const prev = manager.undo(); // prev = 1\r\n   * ```\r\n   */\r\n  undo(): T | undefined {\r\n    if (this.history.past.length === 0) return undefined;\r\n\r\n    const previous: T | undefined = this.history.past.pop();\r\n    this.history.future.unshift(this.history.present);\r\n    this.history.present = previous as T;\r\n    return previous;\r\n  }\r\n\r\n  /**\r\n   * Restores a previously undone value\r\n   * \r\n   * @returns The next value in the redo stack, or undefined if no redo history\r\n   * @remarks\r\n   * - Moves present value to past for undo\r\n   * - Updates present value to first future entry\r\n   * - Removes used future entry\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * manager.push(1);\r\n   * manager.undo();\r\n   * const next = manager.redo(); // next = 1\r\n   * ```\r\n   */\r\n  redo(): T | undefined {\r\n    if (this.history.future.length === 0) return undefined;\r\n\r\n    const next: T | undefined = this.history.future.shift();\r\n    this.history.past.push(this.history.present);\r\n    this.history.present = next as T;\r\n    return next;\r\n  }\r\n\r\n  /**\r\n   * Gets the current value in history\r\n   * \r\n   * @returns The present value\r\n   * @remarks\r\n   * Always returns the current value regardless of undo/redo state\r\n   */\r\n  get current(): T {\r\n    return this.history.present;\r\n  }\r\n\r\n  /**\r\n   * Checks if undo operation is available\r\n   * \r\n   * @returns True if there are past values to undo to\r\n   * @remarks\r\n   * Use this to validate before calling undo()\r\n   */\r\n  get canUndo(): boolean {\r\n    return this.history.past.length > 0;\r\n  }\r\n\r\n  /**\r\n   * Checks if redo operation is available\r\n   * \r\n   * @returns True if there are future values to redo to\r\n   * @remarks\r\n   * Use this to validate before calling redo()\r\n   */\r\n  get canRedo(): boolean {\r\n    return this.history.future.length > 0;\r\n  }\r\n} ","/**\r\n * @fileoverview Storage management system for persistent data\r\n * Provides a type-safe wrapper around localStorage with enhanced functionality.\r\n * \r\n * Features:\r\n * - Type-safe storage operations with generics\r\n * - Automatic namespacing to prevent key conflicts\r\n * - JSON serialization and deserialization\r\n * - Comprehensive error handling\r\n * - Storage availability checking\r\n * - SSR (Server-Side Rendering) compatible\r\n * \r\n * @example Basic Usage\r\n * ```typescript\r\n * // Save data with type safety\r\n * interface UserPrefs { theme: string; fontSize: number; }\r\n * StorageManager.save<UserPrefs>('prefs', { theme: 'dark', fontSize: 14 });\r\n * \r\n * // Load with type inference\r\n * const prefs = StorageManager.load<UserPrefs>('prefs');\r\n * console.log(prefs?.theme); // 'dark'\r\n * \r\n * // Safe removal\r\n * StorageManager.remove('prefs');\r\n * ```\r\n */\r\n\r\nimport { \r\n    hasLocalStorage, \r\n    safeLocalStorageGet, \r\n    safeLocalStorageSet, \r\n    safeLocalStorageRemove \r\n} from '../utils/platform';\r\n\r\n/**\r\n * Manages persistent storage operations with error handling and namespacing.\r\n * \r\n * @remarks\r\n * This class provides a wrapper around localStorage with:\r\n * - Automatic namespacing to prevent conflicts\r\n * - Type-safe operations with generics\r\n * - Built-in error handling and validation\r\n * - Storage availability detection\r\n * - Automatic JSON serialization/deserialization\r\n * \r\n * Storage keys are automatically prefixed to prevent conflicts\r\n * with other applications using localStorage.\r\n */\r\nexport class StorageManager {\r\n    /** \r\n     * Namespace prefix for all storage keys to prevent conflicts.\r\n     * All keys are prefixed with this value before storage.\r\n     */\r\n    private static readonly PREFIX: string = 'ngx-signal-plus:';\r\n    \r\n    /** \r\n     * Maximum allowed key length including prefix.\r\n     * Ensures compatibility across different browsers and platforms.\r\n     */\r\n    private static readonly MAX_KEY_LENGTH: number = 100;\r\n\r\n    /**\r\n     * Validates a storage key for correctness and length\r\n     * \r\n     * @param key - Storage key to validate\r\n     * @returns True if key is valid, false otherwise\r\n     * @remarks\r\n     * Validates that:\r\n     * - Key is a non-empty string\r\n     * - Key length (with prefix) doesn't exceed maximum\r\n     * - Key contains valid characters\r\n     */\r\n    private static validateKey(key: string): boolean {\r\n        if (!key || typeof key !== 'string' || key.trim().length === 0) {\r\n            console.warn('Invalid key: Key must be a non-empty string');\r\n            return false;\r\n        }\r\n\r\n        const fullKey = this.PREFIX + key;\r\n        if (fullKey.length > this.MAX_KEY_LENGTH) {\r\n            console.warn(`Invalid key: key length exceeds ${this.MAX_KEY_LENGTH} characters`);\r\n            return false;\r\n        }\r\n\r\n        return true;\r\n    }\r\n\r\n    /**\r\n     * Saves a value to localStorage with type safety\r\n     * \r\n     * @param key - Storage key (will be prefixed automatically)\r\n     * @param value - Value to store (will be JSON serialized)\r\n     * @throws {Error} If storage is not available\r\n     * @throws {Error} If serialization fails\r\n     * @remarks\r\n     * - Automatically handles JSON serialization\r\n     * - Validates key before storage\r\n     * - Handles storage errors\r\n     * \r\n     * @example\r\n     * ```typescript\r\n     * // Store a complex object\r\n     * StorageManager.save('user', {\r\n     *   id: 123,\r\n     *   preferences: { theme: 'dark' }\r\n     * });\r\n     * ```\r\n     */\r\n    static save<T>(key: string, value: T): void {\r\n        if (!this.validateKey(key)) return;\r\n        if (!hasLocalStorage()) {\r\n            console.warn('localStorage is not available (SSR or disabled)');\r\n            return;\r\n        }\r\n\r\n        try {\r\n            const storageKey: string = this.PREFIX + key;\r\n            const success = safeLocalStorageSet(storageKey, JSON.stringify(value));\r\n            if (!success) {\r\n                console.error('Failed to save to localStorage');\r\n            }\r\n        } catch (error) {\r\n            console.error(`Failed to save to localStorage: ${error}`);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Loads a value from localStorage with type safety\r\n     * \r\n     * @param key - Storage key (will be prefixed automatically)\r\n     * @returns The stored value or undefined if not found\r\n     * @throws {Error} If storage is not available\r\n     * @throws {Error} If deserialization fails\r\n     * @remarks\r\n     * - Automatically handles JSON deserialization\r\n     * - Returns undefined for missing keys\r\n     * - Type-safe return value\r\n     * \r\n     * @example\r\n     * ```typescript\r\n     * // Load with type checking\r\n     * interface UserData {\r\n     *   id: number;\r\n     *   preferences: { theme: string; }\r\n     * }\r\n     * const user = StorageManager.load<UserData>('user');\r\n     * ```\r\n     */\r\n    static load<T>(key: string): T | undefined {\r\n        if (!this.validateKey(key)) return undefined;\r\n        if (!hasLocalStorage()) {\r\n            return undefined;\r\n        }\r\n\r\n        try {\r\n            const storageKey: string = this.PREFIX + key;\r\n            const item: string | null = safeLocalStorageGet(storageKey);\r\n            return item ? JSON.parse(item) : undefined;\r\n        } catch (error) {\r\n            console.error(`Failed to load from localStorage: ${error}`);\r\n            return undefined;\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Removes a value from localStorage\r\n     * \r\n     * @param key - Storage key to remove (will be prefixed automatically)\r\n     * @throws {Error} If storage is not available\r\n     * @remarks\r\n     * - Silently ignores non-existent keys\r\n     * - Validates key before removal\r\n     * - Handles removal errors\r\n     * \r\n     * @example\r\n     * ```typescript\r\n     * // Remove stored data\r\n     * StorageManager.remove('user');\r\n     * ```\r\n     */\r\n    static remove(key: string): void {\r\n        if (!this.validateKey(key)) return;\r\n        if (!hasLocalStorage()) {\r\n            return;\r\n        }\r\n\r\n        try {\r\n            const storageKey: string = this.PREFIX + key;\r\n            safeLocalStorageRemove(storageKey);\r\n        } catch (error) {\r\n            console.error(`Failed to remove from localStorage: ${error}`);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Checks if localStorage is available and working\r\n     * \r\n     * @returns True if storage is available and working\r\n     * @remarks\r\n     * Tests storage by:\r\n     * - Checking if localStorage exists\r\n     * - Attempting a test write/read\r\n     * - Verifying storage quota\r\n     * \r\n     * @example\r\n     * ```typescript\r\n     * if (StorageManager.isAvailable()) {\r\n     *   StorageManager.save('key', data);\r\n     * } else {\r\n     *   console.warn('Local storage not available');\r\n     * }\r\n     * ```\r\n     */\r\n    static isAvailable(): boolean {\r\n        return hasLocalStorage();\r\n    }\r\n}","/**\r\n * @fileoverview Manager exports for ngx-signal-plus\r\n * @description Exports managers for handling storage and history\r\n */\r\n\r\nexport { HistoryManager } from './history-manager';\r\nexport { StorageManager } from './storage-manager';\r\n\r\n// Also export with sp prefix for consistency\r\nexport { HistoryManager as spHistoryManager } from './history-manager';\r\nexport { StorageManager as spStorageManager } from './storage-manager';","/**\r\n * @fileoverview Transaction and batching utilities for ngx-signal-plus\r\n * @description Provides functionality for atomic operations and batched updates\r\n * \r\n * Transactions: Allow multiple signal updates to be treated as a single atomic operation,\r\n * with automatic rollback on error.\r\n * \r\n * Batching: Allow multiple signal updates to be batched together without triggering\r\n * intermediate reactions or validations.\r\n * \r\n * @example\r\n * ```typescript\r\n * // Atomic transaction with rollback\r\n * spTransaction(() => {\r\n *   userProfile.setValue({...});\r\n *   userPreferences.setValue({...});\r\n * });\r\n * \r\n * // Simple batching without rollback\r\n * spBatch(() => {\r\n *   counter1.setValue(counter1.value() + 1);\r\n *   counter2.setValue(counter2.value() + 1);\r\n * });\r\n * ```\r\n */\r\n\r\nimport { SignalPlus } from '../models/signal-plus.model';\r\nimport { TransactionContext, BatchContext } from '../models/transactions.models';\r\n\r\n// Global state management for transactions and batching\r\nconst state = {\r\n  transaction: {\r\n    active: false,\r\n    originalValues: new Map<SignalPlus<any>, any>(),\r\n    originalHistories: new Map<SignalPlus<any>, any[]>(),\r\n    patchedSignals: new Map<SignalPlus<any>, (value: any) => void>(),\r\n    modifiedSignals: []\r\n  } as TransactionContext & { originalHistories: Map<SignalPlus<any>, any[]> },\r\n  \r\n  batch: {\r\n    active: false,\r\n    signals: new Set<SignalPlus<any>>()\r\n  } as BatchContext\r\n};\r\n\r\n/**\r\n * Patches a signal to intercept setValue calls during a transaction\r\n * @param signal The signal to patch\r\n */\r\nfunction patchSignal<T>(signal: SignalPlus<T>): void {\r\n  const txState = state.transaction;\r\n  \r\n  // Skip if already patched\r\n  if (txState.patchedSignals.has(signal)) {\r\n    return;\r\n  }\r\n  \r\n  // Store original setValue method\r\n  const originalSetValue = signal.setValue;\r\n  txState.patchedSignals.set(signal, originalSetValue);\r\n  \r\n  // Replace with transaction-aware version\r\n  signal.setValue = function(value: T): void {\r\n    // If in a transaction\r\n    if (txState.active) {\r\n      // Store original value if first time seeing this signal\r\n      if (!txState.originalValues.has(signal)) {\r\n        txState.originalValues.set(signal, signal.value);\r\n        \r\n        // Also store history state if signal has history\r\n        if (signal.history && typeof signal.history === 'function') {\r\n          const currentHistory = signal.history();\r\n          if (currentHistory && Array.isArray(currentHistory)) {\r\n            txState.originalHistories.set(signal, [...currentHistory]);\r\n          }\r\n        }\r\n        \r\n        // Add to the modified signals list to maintain order of modification\r\n        if (!txState.modifiedSignals.includes(signal)) {\r\n          txState.modifiedSignals.push(signal);\r\n        }\r\n      }\r\n    }\r\n    \r\n    // Delegate to the original implementation\r\n    return originalSetValue.call(this, value);\r\n  };\r\n}\r\n\r\n/**\r\n * Restores the original setValue method for all patched signals\r\n */\r\nfunction restoreOriginalMethods(): void {\r\n  const txState = state.transaction;\r\n  \r\n  for (const [signal, originalSetValue] of txState.patchedSignals.entries()) {\r\n    // Properly restore the original method\r\n    signal.setValue = originalSetValue;\r\n  }\r\n  \r\n  txState.patchedSignals.clear();\r\n}\r\n\r\n/**\r\n * Rolls back all changes made during a transaction\r\n */\r\nfunction rollbackChanges(): void {\r\n  const txState = state.transaction;\r\n  \r\n  // To avoid capturing rollback operations, temporarily disable transaction mode\r\n  const wasActive = txState.active;\r\n  txState.active = false;\r\n  \r\n  try {\r\n    // First, clear any pending debounced operations on all modified signals\r\n    for (const [signal] of txState.originalValues.entries()) {\r\n      try {\r\n        // Clear pending debounce operations if the method exists\r\n        if (signal._clearPendingOperations) {\r\n          signal._clearPendingOperations();\r\n        }\r\n      } catch (error) {\r\n        console.error('Error clearing pending operations during rollback:', error);\r\n        // Continue with other signals even if one fails\r\n      }\r\n    }\r\n    \r\n    // Restore original values using internal methods for fast rollback\r\n    for (const [signal, originalValue] of txState.originalValues.entries()) {\r\n      try {\r\n        // Use _setValueImmediate if available for fast rollback without debounce/validation\r\n        if (signal._setValueImmediate) {\r\n          signal._setValueImmediate(originalValue);\r\n        } else {\r\n          // Fallback to original setValue method\r\n          const originalSetValue = txState.patchedSignals.get(signal);\r\n          \r\n          if (originalSetValue) {\r\n            // Apply the original value using the original method\r\n            originalSetValue.call(signal, originalValue);\r\n          } else {\r\n            // Last resort fallback (shouldn't happen)\r\n            signal.setValue(originalValue);\r\n          }\r\n        }\r\n        \r\n        // Restore history state if it was captured\r\n        const originalHistory = txState.originalHistories.get(signal);\r\n        if (originalHistory && signal._setHistoryImmediate) {\r\n          signal._setHistoryImmediate(originalHistory);\r\n        }\r\n      } catch (error) {\r\n        console.error('Error during transaction rollback:', error);\r\n        // Continue with other rollbacks even if one fails\r\n      }\r\n    }\r\n  } finally {\r\n    // Restore transaction mode\r\n    txState.active = wasActive;\r\n    // Clear captured original values and histories\r\n    txState.originalValues.clear();\r\n    txState.originalHistories.clear();\r\n  }\r\n}\r\n\r\n/**\r\n * Execute a function as an atomic transaction with automatic rollback on error\r\n * @param fn Function containing signal operations\r\n * @returns Result of the function execution\r\n * @throws Will throw any error from the function and perform rollback\r\n * \r\n * @example\r\n * ```typescript\r\n * spTransaction(() => {\r\n *   userProfile.setValue({...});\r\n *   userPreferences.setValue({...});\r\n * });\r\n * ```\r\n */\r\nexport function spTransaction<T>(fn: () => T): T {\r\n  const txState = state.transaction;\r\n  \r\n  // Prevent nested transactions\r\n  if (txState.active) {\r\n    throw new Error('Nested transactions are not allowed');\r\n  }\r\n  \r\n  // Initialize transaction state\r\n  txState.active = true;\r\n  txState.originalValues.clear();\r\n  txState.modifiedSignals = [];\r\n  \r\n  try {\r\n    // Execute the transaction\r\n    const result = fn();\r\n    \r\n    // Transaction completed successfully\r\n    txState.active = false;\r\n    txState.originalValues.clear();\r\n    \r\n    return result;\r\n  } catch (error) {\r\n    // Error occurred, rollback all changes\r\n    rollbackChanges();\r\n    txState.active = false;\r\n    \r\n    // Re-throw the original error\r\n    throw error;\r\n  } finally {\r\n    // Clean up patched signals\r\n    restoreOriginalMethods();\r\n    txState.modifiedSignals = [];\r\n  }\r\n}\r\n\r\n/**\r\n * Execute multiple signal updates as a single batch\r\n * @param fn Function containing signal operations\r\n * @returns Result of the function execution\r\n * \r\n * @example\r\n * ```typescript\r\n * spBatch(() => {\r\n *   counter1.setValue(counter1.value + 1);\r\n *   counter2.setValue(counter2.value + 1);\r\n * });\r\n * ```\r\n */\r\nexport function spBatch<T>(fn: () => T): T {\r\n  const batchState = state.batch;\r\n  \r\n  // Mark batch as active\r\n  batchState.active = true;\r\n  batchState.signals.clear();\r\n  \r\n  try {\r\n    // Execute batch operations\r\n    return fn();\r\n  } finally {\r\n    // Clean up batch state\r\n    batchState.active = false;\r\n    batchState.signals.clear();\r\n  }\r\n}\r\n\r\n/**\r\n * Check if a transaction is currently active\r\n * @returns True if a transaction is active\r\n */\r\nexport function spIsTransactionActive(): boolean {\r\n  return state.transaction.active;\r\n}\r\n\r\n/**\r\n * Check if the signal is part of an active transaction\r\n * @param signal Signal to check\r\n * @returns True if a transaction is active\r\n */\r\nexport function spIsInTransaction<T>(signal: SignalPlus<T>): boolean {\r\n  if (state.transaction.active) {\r\n    // Ensure the signal is patched for transaction tracking\r\n    patchSignal(signal);\r\n    return true;\r\n  }\r\n  return false;\r\n}\r\n\r\n/**\r\n * Check if the signal is part of an active batch\r\n * @param signal Signal to check\r\n * @returns True if the signal is in an active batch\r\n */\r\nexport function spIsInBatch<T>(signal?: SignalPlus<T>): boolean {\r\n  if (state.batch.active) {\r\n    if (signal) {\r\n      state.batch.signals.add(signal);\r\n    }\r\n    return true;\r\n  }\r\n  return false;\r\n}\r\n\r\n/**\r\n * Get a list of signals that have been modified in the current transaction\r\n * @returns Array of modified signals, or empty array if no transaction is active\r\n */\r\nexport function spGetModifiedSignals(): SignalPlus<any>[] {\r\n  if (!state.transaction.active) {\r\n    return [];\r\n  }\r\n  \r\n  return [...state.transaction.modifiedSignals];\r\n}\r\n\r\n/**\r\n * Clear transaction state (for testing purposes)\r\n */\r\nexport function _resetTransactionState(): void {\r\n  const txState = state.transaction;\r\n  const batchState = state.batch;\r\n  \r\n  // Reset transaction state\r\n  txState.active = false;\r\n  txState.originalValues.clear();\r\n  txState.originalHistories.clear();\r\n  txState.modifiedSignals = [];\r\n  restoreOriginalMethods();\r\n  \r\n  // Reset batch state\r\n  batchState.active = false;\r\n  batchState.signals.clear();\r\n}\r\n\r\n/**\r\n * Patches all signals that haven't been patched yet\r\n * This ensures that all signals that are modified during a transaction are properly tracked\r\n * @internal Used for testing purposes only\r\n */\r\nexport function _patchAllSignalsInTest<T>(signal: SignalPlus<T>): void {\r\n  // This is a special helper for testing scenarios to make signals\r\n  // interact correctly with our transaction mechanism in test environments\r\n  \r\n  // For testing purposes, we need to make sure that setValue will work\r\n  // with our transaction tracking mechanism\r\n  patchSignal(signal);\r\n  \r\n  // Explicitly add this signal to the tracked list\r\n  if (state.transaction.active) {\r\n    spIsInTransaction(signal);\r\n  } else if (state.batch.active) {\r\n    spIsInBatch(signal);\r\n  }\r\n} ","/**\r\n * @fileoverview Utility exports for ngx-signal-plus\r\n */\r\n\r\n// Managers\r\nexport { HistoryManager as spHistoryManager, StorageManager as spStorageManager } from '../managers';\r\n\r\n// Utilities\r\nexport { enhance as spEnhance } from './enhance';\r\nexport { presets as spPresets, validators as spValidators } from './presets';\r\nexport { \r\n  spTransaction, \r\n  spBatch, \r\n  spIsInTransaction, \r\n  spIsInBatch,\r\n  spGetModifiedSignals,\r\n  spIsTransactionActive\r\n} from './transactions';\r\nexport {\r\n  isBrowser,\r\n  hasLocalStorage,\r\n  safeLocalStorageGet,\r\n  safeLocalStorageSet,\r\n  safeLocalStorageRemove,\r\n  safeSetTimeout,\r\n  safeClearTimeout,\r\n  safeAddEventListener\r\n} from './platform';","/**\r\n * Public API Surface of ngx-signal-plus\r\n * \r\n * This file exports all public functionality of the ngx-signal-plus library.\r\n * Everything exported here is considered stable and follows semantic versioning.\r\n */\r\n\r\n// Core Signal Creation\r\nexport {\r\n    sp,\r\n    spCounter,\r\n    spToggle,\r\n    spForm\r\n} from './lib/utils/create';\r\n\r\n// Signal Enhancement\r\nexport {\r\n    enhance\r\n} from './lib/utils/enhance';\r\n\r\n// Core Components and Services\r\nexport { \r\n    spSignalBuilder,\r\n    spSignalPlusService,\r\n    spSignalPlusComponent\r\n} from './lib/core';\r\n\r\n// Models and Types\r\nexport type {\r\n    // Core Types\r\n    SignalPlus,\r\n    SignalOptions,\r\n    BuilderOptions,\r\n    \r\n    // Form Types\r\n    FormTextOptions,\r\n    FormNumberOptions,\r\n    \r\n    // Function Types\r\n    Validator,\r\n    Transform,\r\n    ErrorHandler,\r\n    \r\n    // State Types\r\n    SignalHistory,\r\n    SignalState\r\n} from './lib/models';\r\n\r\n// Signal Operators\r\nexport {\r\n    spMap,\r\n    spFilter,\r\n    spDebounceTime,\r\n    spDistinctUntilChanged,\r\n    spDelay,\r\n    spThrottleTime,\r\n    spSkip,\r\n    spTake,\r\n    spMerge,\r\n    spCombineLatest\r\n} from './lib/operators';\r\n\r\n// Utilities and Presets\r\nexport {\r\n    spValidators,\r\n    spPresets\r\n} from './lib/utils';\r\n\r\n// State Management\r\nexport {\r\n    spHistoryManager,\r\n    spStorageManager\r\n} from './lib/managers';\r\n\r\n// Transactions and Batching\r\nexport {\r\n    spTransaction,\r\n    spBatch,\r\n    spIsInTransaction,\r\n    spIsInBatch,\r\n    spIsTransactionActive,\r\n    spGetModifiedSignals\r\n} from './lib/utils/transactions';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;AAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;SACa,SAAS,GAAA;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW;AAClC,QAAA,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;AAC1C;AAEA;;;;;;;;;;;;;;;;;;;AAmBG;SACa,eAAe,GAAA;AAC7B,IAAA,IAAI,CAAC,SAAS,EAAE,EAAE;AAChB,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI;QACF,MAAM,OAAO,GAAG,0BAA0B;AAC1C,QAAA,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC;AACrC,QAAA,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC;AAChC,QAAA,OAAO,IAAI;IACb;A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