@mhmo91/schmancy 0.2.127 → 0.2.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/{context-object-CVqtbNDv.js → context-object-CD26Iary.js} +20 -17
- package/dist/context-object-CD26Iary.js.map +1 -0
- package/dist/context-object-D81PeS3j.cjs +2 -0
- package/dist/context-object-D81PeS3j.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +99 -86
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/selector-hook-9dSW11-1.js +274 -0
- package/dist/selector-hook-9dSW11-1.js.map +1 -0
- package/dist/selector-hook-CH-z8W2d.cjs +2 -0
- package/dist/selector-hook-CH-z8W2d.cjs.map +1 -0
- package/dist/store.cjs +1 -1
- package/dist/store.js +30 -17
- package/dist/teleport.cjs +1 -1
- package/dist/{teleport.component-B8yyRFCq.js → teleport.component-CBNKUZwe.js} +2 -2
- package/dist/{teleport.component-B8yyRFCq.js.map → teleport.component-CBNKUZwe.js.map} +1 -1
- package/dist/{teleport.component-AE9wd-Xe.cjs → teleport.component-CplIV2h1.cjs} +2 -2
- package/dist/{teleport.component-AE9wd-Xe.cjs.map → teleport.component-CplIV2h1.cjs.map} +1 -1
- package/dist/teleport.js +1 -1
- package/package.json +1 -1
- package/types/src/store/context-create.d.ts +15 -2
- package/types/src/store/filter-directive.d.ts +38 -11
- package/types/src/store/selector-hook.d.ts +27 -0
- package/types/src/store/selectors.d.ts +30 -1
- package/types/src/store/storage-manager.d.ts +6 -14
- package/types/src/store/types.d.ts +100 -45
- package/dist/context-object-CVqtbNDv.js.map +0 -1
- package/dist/context-object-CgZ6F8E9.cjs +0 -2
- package/dist/context-object-CgZ6F8E9.cjs.map +0 -1
- package/dist/selector-hook-B5oIBdcJ.cjs +0 -2
- package/dist/selector-hook-B5oIBdcJ.cjs.map +0 -1
- package/dist/selector-hook-BdsJkaE2.js +0 -185
- package/dist/selector-hook-BdsJkaE2.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selector-hook-BdsJkaE2.js","sources":["../src/store/context-create.ts","../src/store/filter-directive.ts","../src/store/selectors.ts","../src/store/selector-hook.ts"],"sourcesContent":["import { ICollectionStore, IStore, StorageType } from './types'\nimport { SchmancyStoreObject } from './context-object'\nimport SchmancyCollectionStore from './context-collection'\n\n/**\n * Checks if an object is empty\n */\nfunction isEmptyObject(obj: object): boolean {\n\tif (typeof obj !== 'object' || obj === null) {\n\t\treturn false\n\t}\n\treturn Object.keys(obj).length === 0\n}\n\n/**\n * Returns true if obj is an iterable collection\n */\nfunction isCollection(obj: any): obj is Iterable<any> {\n\t// Must be non-null and of type 'object'\n\tif (obj == null || typeof obj !== 'object') {\n\t\treturn false\n\t}\n\n\t// Exclude plain objects.\n\tconst proto = Object.getPrototypeOf(obj)\n\tif (proto === Object.prototype || proto === null) {\n\t\treturn false\n\t}\n\n\t// Check for Symbol.iterator method\n\treturn typeof obj[Symbol.iterator] === 'function'\n}\n\n/**\n * Creates a context for managing state with better type safety\n */\nexport function createContext<T extends Record<string, any>>(\n\tinitialData: T,\n\tstorage: StorageType,\n\tkey: string,\n): IStore<T> & SchmancyStoreObject<T>\n\nexport function createContext<V>(\n\tinitialData: Map<string, V>,\n\tstorage: StorageType,\n\tkey: string,\n): ICollectionStore<V> & SchmancyCollectionStore<V>\n\nexport function createContext<T extends Record<string, any> | Map<string, any>>(\n\tinitialData: T | Map<string, any>,\n\tstorage: StorageType,\n\tkey: string,\n): (IStore<T> & SchmancyStoreObject<T>) | (ICollectionStore<any> & SchmancyCollectionStore<any>) {\n\tif (isCollection(initialData)) {\n\t\t// Create a collection store\n\t\tconst store = SchmancyCollectionStore.getInstance(storage, key, initialData as Map<string, any>)\n\n\t\t// Initialize with provided data if store is empty\n\t\tif (!store.value.size) {\n\t\t\tstore.$.next(initialData as Map<string, any>)\n\t\t}\n\t\treturn store as ICollectionStore<any> & SchmancyCollectionStore<any>\n\t} else if (typeof initialData === 'object' && initialData !== null) {\n\t\t// Validate storage type for object stores\n\t\tif (storage === 'indexeddb') {\n\t\t\tthrow new Error('IndexedDB storage is not supported for plain objects.')\n\t\t}\n\n\t\t// Create an object store\n\t\tconst store = SchmancyStoreObject.getInstance<T>(storage, key, initialData as T)\n\n\t\t// Initialize with provided data if store is empty\n\t\tif (isEmptyObject(store.value)) {\n\t\t\tstore.$.next(initialData as T)\n\t\t}\n\t\treturn store as IStore<T> & SchmancyStoreObject<T>\n\t} else {\n\t\tthrow new Error('Initial data must be an object or a Map.')\n\t}\n}\n","/** Supported comparison operators. */\ntype ComparisonOperator =\n\t| '=='\n\t| '!='\n\t| '>'\n\t| '<'\n\t| '>='\n\t| '<='\n\t| 'includes'\n\t| 'notIncludes'\n\t| 'startsWith'\n\t| 'endsWith'\n\t| 'in'\n\t| 'notIn'\n\t| 'any' // fuzzy search operator\n\n/**\n * Query condition which can be either a tuple:\n * [field, operator, expected]\n * or an object:\n * { key, operator, value }\n */\nexport type QueryCondition =\n\t| [field: string, op: ComparisonOperator, expected: unknown, strict?: boolean]\n\t| { key: string; operator: ComparisonOperator; value: unknown; strict?: boolean }\n\n/**\n * Get a nested value from an object using a dot-separated path.\n * Checks explicitly for null/undefined so falsy values like 0 or false are preserved.\n */\nconst getFieldValue = (item: Record<string, any>, path: string): any =>\n\tpath.split('.').reduce((obj, key) => (obj == null ? undefined : obj[key]), item)\n\n/**\n * Compute the Levenshtein distance between two strings.\n */\nconst levenshtein = (a: string, b: string): number => {\n\tconst matrix: number[][] = []\n\n\t// initialize the first column\n\tfor (let i = 0; i <= b.length; i++) {\n\t\tmatrix[i] = [i]\n\t}\n\t// initialize the first row\n\tfor (let j = 0; j <= a.length; j++) {\n\t\tmatrix[0][j] = j\n\t}\n\n\tfor (let i = 1; i <= b.length; i++) {\n\t\tfor (let j = 1; j <= a.length; j++) {\n\t\t\tif (b.charAt(i - 1) === a.charAt(j - 1)) {\n\t\t\t\tmatrix[i][j] = matrix[i - 1][j - 1]\n\t\t\t} else {\n\t\t\t\tmatrix[i][j] = Math.min(\n\t\t\t\t\tmatrix[i - 1][j] + 1, // deletion\n\t\t\t\t\tmatrix[i][j - 1] + 1, // insertion\n\t\t\t\t\tmatrix[i - 1][j - 1] + 1, // substitution\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\treturn matrix[b.length][a.length]\n}\n\n/**\n * Check if string `sub` is a subsequence of string `str`.\n * All characters in `sub` must appear in order in `str` (they need not be contiguous).\n */\nconst isSubsequence = (sub: string, str: string): boolean => {\n\tlet i = 0,\n\t\tj = 0\n\twhile (i < sub.length && j < str.length) {\n\t\tif (sub[i] === str[j]) i++\n\t\tj++\n\t}\n\treturn i === sub.length\n}\n\n/**\n * Check if every character (with frequency) in the query exists in the target.\n * For example, \"aovc\" matches \"avocados\".\n */\nconst anagramMatch = (query: string, target: string): boolean => {\n\tconst countChars = (s: string): Record<string, number> =>\n\t\ts.split('').reduce((acc, char) => {\n\t\t\tacc[char] = (acc[char] || 0) + 1\n\t\t\treturn acc\n\t\t}, {} as Record<string, number>)\n\n\tconst queryCount = countChars(query)\n\tconst targetCount = countChars(target)\n\treturn Object.keys(queryCount).every(char => (targetCount[char] || 0) >= queryCount[char])\n}\n\n/**\n * Generate bigrams for a string.\n */\nconst getBigrams = (s: string): string[] => {\n\tconst bigrams = []\n\tfor (let i = 0; i < s.length - 1; i++) {\n\t\tbigrams.push(s.substring(i, i + 2))\n\t}\n\treturn bigrams\n}\n\n/**\n * Compute Dice's coefficient for two strings based on bigrams.\n * Returns a value between 0 (no similarity) and 1 (perfect match).\n */\nconst diceCoefficient = (s1: string, s2: string): number => {\n\tif (s1.length < 2 || s2.length < 2) return 0\n\tconst bigrams1 = getBigrams(s1)\n\tconst bigrams2 = getBigrams(s2)\n\tlet intersection = 0\n\tconst used = new Array(bigrams2.length).fill(false)\n\tfor (const bigram of bigrams1) {\n\t\tfor (let i = 0; i < bigrams2.length; i++) {\n\t\t\tif (!used[i] && bigrams2[i] === bigram) {\n\t\t\t\tintersection++\n\t\t\t\tused[i] = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn (2 * intersection) / (bigrams1.length + bigrams2.length)\n}\n\n/**\n * Compute a fuzzy similarity score between two strings.\n * The score is computed by taking the maximum of several methods:\n * - Direct substring match (score 1)\n * - Subsequence check (score 0.8)\n * - Anagram subset match (score 0.7)\n * - Dice coefficient\n * - Normalized Levenshtein similarity\n */\nconst computeFuzzyScore = (actual: string, expected: string): number => {\n\tconst a = actual.toLowerCase().trim()\n\tconst b = expected.toLowerCase().trim()\n\n\tconst substringScore = a.includes(b) ? 1 : 0\n\tconst subsequenceScore = isSubsequence(b, a) ? 0.8 : 0\n\tconst anagramScore = anagramMatch(b, a) ? 0.7 : 0\n\tconst diceScore = diceCoefficient(a, b)\n\tconst maxLen = Math.max(a.length, b.length)\n\tconst levenshteinScore = maxLen ? 1 - levenshtein(a, b) / maxLen : 1\n\n\treturn Math.max(substringScore, subsequenceScore, anagramScore, diceScore, levenshteinScore)\n}\n\n/**\n * Compare two values based on a simple operator.\n * For non-fuzzy operators, this returns a boolean.\n */\nconst compareValues = (op: ComparisonOperator, actual: any, expected: any): boolean => {\n\tswitch (op) {\n\t\tcase '==':\n\t\t\treturn actual === expected\n\t\tcase '!=':\n\t\t\treturn actual !== expected\n\t\tcase '>':\n\t\t\treturn actual > expected\n\t\tcase '<':\n\t\t\treturn actual < expected\n\t\tcase '>=':\n\t\t\treturn actual >= expected\n\t\tcase '<=':\n\t\t\treturn actual <= expected\n\t\tcase 'includes': {\n\t\t\tif (typeof actual === 'string') return actual.toLowerCase().includes(String(expected).toLowerCase())\n\t\t\telse if (Array.isArray(actual)) return actual.includes(expected)\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIncludes': {\n\t\t\tif (typeof actual === 'string') return !actual.toLowerCase().includes(String(expected).toLowerCase())\n\t\t\telse if (Array.isArray(actual)) return !actual.includes(expected)\n\t\t\treturn false\n\t\t}\n\t\tcase 'startsWith': {\n\t\t\tif (typeof actual === 'string') return actual.startsWith(String(expected))\n\t\t\treturn false\n\t\t}\n\t\tcase 'endsWith': {\n\t\t\tif (typeof actual === 'string') return actual.endsWith(String(expected))\n\t\t\treturn false\n\t\t}\n\t\tcase 'in': {\n\t\t\tif (Array.isArray(expected)) return expected.includes(actual)\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIn': {\n\t\t\tif (Array.isArray(expected)) return !expected.includes(actual)\n\t\t\treturn false\n\t\t}\n\t\tdefault: {\n\t\t\tconsole.warn(`Operator \"${op}\" is not supported in strict comparison.`)\n\t\t\treturn false\n\t\t}\n\t}\n}\n\n/**\n * Filter a Map of items given an array of query conditions.\n * For each query condition:\n * - If the expected value is empty/null/undefined, it is treated as a match.\n * - For non-fuzzy operators, the condition must strictly match.\n * - For the \"any\" operator, a fuzzy similarity score is computed.\n * Items with a fuzzy score below a given threshold (e.g., 0.3) are excluded.\n *\n * The overall item score is the average of the scores from all conditions.\n * The results are sorted in descending order of relevance.\n *\n * @param items - A Map containing items to filter.\n * @param queries - An array of query conditions to apply.\n * @returns An array of items that match all query conditions, sorted by relevance.\n */\nexport const filterMapItems = <T extends Record<string, any>>(\n\titems: Map<string, T>,\n\tqueries: QueryCondition[] = [],\n): T[] => {\n\t// Fuzzy threshold (adjust as needed)\n\tconst fuzzyThreshold = 0.3\n\n\t// Score and filter each item.\n\tconst scoredItems = Array.from(items.values())\n\t\t.map(item => {\n\t\t\tlet totalScore = 0\n\t\t\tlet count = 0\n\t\t\t// If any query fails, mark the item as invalid.\n\t\t\tlet valid = true\n\n\t\t\tfor (const query of queries) {\n\t\t\t\tlet field: string,\n\t\t\t\t\top: ComparisonOperator,\n\t\t\t\t\texpected: unknown,\n\t\t\t\t\tstrict = false\n\t\t\t\tif (Array.isArray(query)) {\n\t\t\t\t\t// Extract optional strict flag from tuple if provided.\n\t\t\t\t\t;[field, op, expected, strict = false] = query\n\t\t\t\t\tstrict = !!strict // default to false if undefined\n\t\t\t\t} else {\n\t\t\t\t\tfield = query.key\n\t\t\t\t\top = query.operator\n\t\t\t\t\texpected = query.value\n\t\t\t\t\tstrict = query.strict || false\n\t\t\t\t}\n\n\t\t\t\t// If the expected value is empty/null/undefined, or an empty array, skip filtering.\n\t\t\t\t// If the expected value is empty/null/undefined, or an empty array, and strict is false, skip filtering\n\t\t\t\tif (!strict && (expected === '' || expected == null || (Array.isArray(expected) && expected.length === 0))) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst actual = getFieldValue(item, field)\n\n\t\t\t\t// If strict mode is enabled, enforce exact equality.\n\t\t\t\tif (strict) {\n\t\t\t\t\tif (actual !== expected) {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\ttotalScore += 1 // exact match yields a perfect score\n\t\t\t\t\tcount++\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif (op === 'any') {\n\t\t\t\t\t// Fuzzy search requires both values to be strings.\n\t\t\t\t\tif (typeof actual !== 'string' || typeof expected !== 'string') {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tconst score = computeFuzzyScore(actual, expected)\n\t\t\t\t\tif (score < fuzzyThreshold) {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\ttotalScore += score\n\t\t\t\t\tcount++\n\t\t\t\t} else {\n\t\t\t\t\t// For non-fuzzy operators, if the condition fails, exclude the item.\n\t\t\t\t\tif (!compareValues(op, actual, expected)) {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\ttotalScore += 1 // strict match yields a perfect score.\n\t\t\t\t\tcount++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!valid) return null\n\n\t\t\t// Use the average score if at least one condition contributed.\n\t\t\tconst overallScore = count > 0 ? totalScore / count : 1\n\t\t\treturn { item, score: overallScore }\n\t\t})\n\t\t.filter(x => x !== null) as { item: T; score: number }[]\n\n\t// Sort by descending overall score.\n\tscoredItems.sort((a, b) => b.score - a.score)\n\treturn scoredItems.map(x => x.item)\n}\n\n// /**\n// * A typed directive function interface.\n// * Ensures that using the directive returns a filtered (and ranked) array of items.\n// */\n// export type FilterMapDirectiveFn = <T extends Record<string, any>>(\n// \titems: Map<string, T>,\n// \tqueries?: QueryCondition[],\n// ) => T[]\n\n// /**\n// * Lit directive to filter a Map based on an array of query conditions.\n// *\n// * Usage in your Lit template:\n// *\n// * ```ts\n// * html`\n// * <div .items=${filterMap(this.items, [\n// * { key: 'category', operator: '==', value: itemsFilterContext.value.category },\n// * ['name', 'any', 'avo'], // will match \"avocados\" even if typed as \"avo\" or \"aovc\"\n// * ])}></div>\n// * `\n// * ```\n// */\n// class FilterMapDirective extends Directive {\n// \tconstructor(partInfo: PartInfo) {\n// \t\tsuper(partInfo)\n// \t}\n\n// \trender<T extends Record<string, any>>(items: Map<string, T>, queries: QueryCondition[] = []): T[] {\n// \t\treturn filterMapItems(items, queries) as T[]\n// \t}\n// }\n\n// Cast the directive to our typed directive function interface.\nexport const filterMap = filterMapItems\n","// src/store/selectors.ts\nimport { Observable, combineLatest } from 'rxjs'\nimport { map, distinctUntilChanged, shareReplay } from 'rxjs/operators'\nimport { IStore, ICollectionStore } from './types'\n\n/**\n * Creates a selector that derives a value from store state\n *\n * @param store The store to observe\n * @param selectorFn Function that transforms the state\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createSelector<T, R>(store: IStore<T>, selectorFn: (state: T) => R): Observable<R> {\n\treturn store.$.pipe(\n\t\tmap(selectorFn),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\t// Compare the two objects deep to see if they are equal\n\t\t\t\tJSON.stringify(a) === JSON.stringify(b),\n\t\t),\n\t\tshareReplay(1),\n\t)\n}\n\n/**\n * Creates a selector for collection stores that derives a value from the collection\n *\n * @param store The collection store to observe\n * @param selectorFn Function that transforms the collection\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createCollectionSelector<T, R>(\n\tstore: ICollectionStore<T>,\n\tselectorFn: (state: Map<string, T>) => R,\n): Observable<R> {\n\treturn store.$.pipe(\n\t\tmap(selectorFn),\n\t\tdistinctUntilChanged((a, b) => {\n\t\t\tif (a instanceof Map && b instanceof Map) {\n\t\t\t\treturn JSON.stringify(Array.from(a.entries())) === JSON.stringify(Array.from(b.entries()))\n\t\t\t}\n\t\t\treturn JSON.stringify(a) === JSON.stringify(b)\n\t\t}),\n\t\tshareReplay(1),\n\t)\n}\n\n/**\n * Creates a selector that filters items from a collection\n *\n * @param store The collection store\n * @param filterFn Function that returns true for items to include\n * @returns An observable of filtered items as an array\n */\nexport function createFilterSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn: (item: T, key: string) => boolean,\n): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\tconst result: T[] = []\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) {\n\t\t\t\tresult.push(item)\n\t\t\t}\n\t\t})\n\t\treturn result\n\t})\n}\n\n/**\n * Creates a selector that retrieves a single item from a collection\n *\n * @param store The collection store\n * @param itemKey The key of the item to select\n * @returns An observable of the selected item that emits when the item changes\n */\nexport function createItemSelector<T>(store: ICollectionStore<T>, itemKey: string): Observable<T | undefined> {\n\treturn createCollectionSelector(store, collection => collection.get(itemKey))\n}\n\n/**\n * Creates a selector that counts items in a collection, optionally filtered\n *\n * @param store The collection store\n * @param filterFn Optional function to filter which items to count\n * @returns An observable of the count\n */\nexport function createCountSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn?: (item: T, key: string) => boolean,\n): Observable<number> {\n\treturn createCollectionSelector(store, collection => {\n\t\tif (!filterFn) return collection.size\n\n\t\tlet count = 0\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) count++\n\t\t})\n\t\treturn count\n\t})\n}\n\n/**\n * Creates a compound selector that depends on multiple other selectors\n *\n * @param selectors Array of source selectors\n * @param combinerFn Function that combines all selector results\n * @returns An observable of the combined result\n */\nexport function createCompoundSelector<R, T extends any[]>(\n\tselectors: Observable<any>[],\n\tcombinerFn: (...values: T) => R,\n): Observable<R> {\n\treturn combineLatest(selectors).pipe(\n\t\tmap(values => combinerFn(...(values as T))),\n\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\tshareReplay(1),\n\t)\n}\n","// src/store/selector-hook.ts\nimport { property as litProperty } from 'lit/decorators.js'\nimport { Subject, Subscription } from 'rxjs'\nimport { takeUntil } from 'rxjs/operators'\nimport { createCollectionSelector, createSelector } from './selectors'\nimport { ICollectionStore, IStore } from './types'\n\ninterface ComponentWithDisconnection {\n\tdisconnecting?: Subject<void>\n\trequestUpdate?: () => void\n\tisConnected: boolean\n\t__selectorProps?: Record<string, SelectorPropState<unknown>>\n\t[key: string]: any\n}\n\ninterface SelectorPropState<_T> {\n\tsubscription: Subscription | null\n\tinitialLoad: boolean\n}\n\ntype PropertyDescriptor<T> = {\n\tget?: () => T\n\tset?: (value: T) => void\n\tvalue?: T\n\tconfigurable?: boolean\n\tenumerable?: boolean\n\twritable?: boolean\n}\n\ninterface SelectOptions {\n\trequired?: boolean\n\tupdateOnly?: boolean\n}\n\nfunction isCollectionStore(store: any): store is ICollectionStore<unknown> {\n\treturn 'set' in store && typeof store.set === 'function' && store.value instanceof Map\n}\n\nexport function select<T, R>(\n\tstore: IStore<T> | ICollectionStore<T>,\n\tselectorFn: (state: any) => R = (state: R) => state,\n\toptions: SelectOptions = {},\n) {\n\treturn function (proto: Record<string, any>, propName: string, _descriptor?: PropertyDescriptor<R>) {\n\t\tlitProperty({ attribute: false, type: Object })(proto, propName)\n\n\t\tconst originalConnectedCallback = proto.connectedCallback\n\t\tconst originalDisconnectedCallback = proto.disconnectedCallback\n\n\t\tproto.connectedCallback = function (this: ComponentWithDisconnection) {\n\t\t\tconst instance = this\n\n\t\t\tif (!instance.__selectorProps) {\n\t\t\t\tinstance.__selectorProps = {}\n\t\t\t}\n\n\t\t\tif (!instance.__selectorProps[propName]) {\n\t\t\t\tinstance.__selectorProps[propName] = {\n\t\t\t\t\tsubscription: null,\n\t\t\t\t\tinitialLoad: false,\n\t\t\t\t} as SelectorPropState<R>\n\t\t\t}\n\n\t\t\tconst props = instance.__selectorProps[propName] as SelectorPropState<R>\n\n\t\t\t// Reset disconnecting Subject if it's closed or doesn't exist\n\t\t\tif (instance.disconnecting?.closed || !instance.disconnecting) {\n\t\t\t\tinstance.disconnecting = new Subject<void>()\n\t\t\t}\n\n\t\t\tconst selector = isCollectionStore(store)\n\t\t\t\t? createCollectionSelector(store, selectorFn)\n\t\t\t\t: createSelector(store as IStore<T>, selectorFn)\n\n\t\t\t// Call original connectedCallback immediately if not required\n\t\t\tif (!options.required && !props.initialLoad) {\n\t\t\t\toriginalConnectedCallback?.call(instance)\n\t\t\t\tprops.initialLoad = true\n\t\t\t}\n\n\t\t\tif (!props.subscription) {\n\t\t\t\tprops.subscription = selector.pipe(takeUntil(instance.disconnecting)).subscribe({\n\t\t\t\t\tnext: (value: R) => {\n\t\t\t\t\t\tconst newValue = structuredClone(value)\n\t\t\t\t\t\tinstance[propName] = newValue\n\t\t\t\t\t\tinstance.requestUpdate?.()\n\t\t\t\t\t\tif (options.required && !props.initialLoad && newValue) {\n\t\t\t\t\t\t\toriginalConnectedCallback?.call(instance)\n\t\t\t\t\t\t\tprops.initialLoad = true\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\terror: (err: Error) => {\n\t\t\t\t\t\tconsole.error(`Error in selector subscription for ${propName}:`, err)\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tproto.disconnectedCallback = function (this: ComponentWithDisconnection) {\n\t\t\toriginalDisconnectedCallback?.call(this)\n\n\t\t\tconst props = this.__selectorProps?.[propName] as SelectorPropState<R> | undefined\n\t\t\tif (props?.subscription) {\n\t\t\t\tprops.subscription.unsubscribe()\n\t\t\t\tprops.subscription = null\n\t\t\t}\n\n\t\t\tif (this.disconnecting) {\n\t\t\t\tthis.disconnecting.next()\n\t\t\t\tthis.disconnecting.complete()\n\t\t\t\t// Allow reinitialization by not deleting the disconnecting subject\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["createContext","initialData","storage","key","obj","proto","Object","getPrototypeOf","prototype","Symbol","iterator","store","SchmancyCollectionStore","getInstance","value","size","$","next","Error","SchmancyStoreObject","keys","length","getFieldValue","item","path","split","reduce","getBigrams","s","bigrams","i","push","substring","computeFuzzyScore","actual","expected","a","toLowerCase","trim","b","substringScore","includes","subsequenceScore","sub","str","j","anagramScore","query","target","countChars","acc","char","queryCount","targetCount","every","diceScore","s1","s2","bigrams1","bigrams2","intersection","used","Array","fill","bigram","maxLen","Math","max","levenshteinScore","matrix","charAt","min","compareValues","op","String","isArray","startsWith","endsWith","filterMapItems","items","queries","scoredItems","from","values","map","totalScore","count","valid","field","strict","operator","score","filter","x","sort","filterMap","createSelector","selectorFn","pipe","distinctUntilChanged","JSON","stringify","shareReplay","createCollectionSelector","Map","entries","createFilterSelector","filterFn","collection","result","forEach","createItemSelector","itemKey","get","createCountSelector","createCompoundSelector","selectors","combinerFn","combineLatest","select","state","options","propName","_descriptor","litProperty","attribute","type","originalConnectedCallback","connectedCallback","originalDisconnectedCallback","disconnectedCallback","instance","this","__selectorProps","subscription","initialLoad","props","disconnecting","closed","Subject","selector","set","required","call","takeUntil","subscribe","newValue","structuredClone","requestUpdate","error","err","unsubscribe","complete"],"mappings":";;;;AAgDgB,SAAAA,EACfC,GACAC,GACAC,GAEI;AAAA,MApCL,SAAsBC,GAAAA;AAErB,QAAIA,KAAO,QAAuB,OAARA,KAAQ,SAC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