import { HsonQuery } from "../../../types/livetree.types.js"; import { LiveTree } from "../livetree.js"; import { TreeSelector } from "../creation/tree-selector.js"; import { FindWithById } from "../../../types/livetree.types.js"; export type FindQuery = HsonQuery | string; export type FindQueryMany = FindQuery | readonly FindQuery[]; type FindManyHelpers = { /** Existing helper: accepts one id or many ids. */ id: (ids: string | readonly string[]) => TreeSelector; /** CHANGED: explicit collection aliases. */ byId: (id: string) => TreeSelector; byIds: (...ids: string[]) => TreeSelector; byAttribute: (attr: string, value: string) => TreeSelector; byAttr: (attr: string, value: string) => TreeSelector; byAttrs: (attr: string, value: string) => TreeSelector; byFlag: (flag: string) => TreeSelector; byFlags: (flag: string) => TreeSelector; byTag: (tag: string) => TreeSelector; byClass: (className: string) => TreeSelector; byData: (key: string, value: string) => TreeSelector; }; export type FindManyMust = ((q: FindQueryMany, label?: string) => TreeSelector) & FindManyHelpers; export type FindMany = ((q: FindQueryMany) => TreeSelector) & FindManyHelpers & { must: FindManyMust; }; /** * Find *all* matching nodes under a `LiveTree` and return them as a `TreeSelector`. * * Semantics: * - Rooted search: delegates to `search_nodes([tree.node], query, { findFirst: false })`, * so the traversal is confined to this tree’s subtree. * - For each matching `HsonNode`, constructs a child `LiveTree` via * `wrap_in_tree`, preserving the original host root. * - Packs the resulting `LiveTree[]` into a `TreeSelector` via * `make_tree_selector`, giving the caller broadcast helpers * (`setAttrs`, `style`, `listen`, etc.). * * Selector handling: * - If `q` is a string, it is parsed via `parse_selector` into `HsonQuery`. * - If `q` is already an `HsonQuery`, it is used as-is. * * Return value: * - Always returns a `TreeSelector` (possibly empty). All mutation * helpers on the selector are no-ops when the selection is empty. * * @param tree - The `LiveTree` whose subtree will be searched. * @param q - A selector string or `HsonQuery` describing matches. * @returns A `TreeSelector` containing all matching nodes. */ export declare function find_all_in_tree(tree: LiveTree, q: HsonQuery | string): TreeSelector; /** * Find *all* matching nodes for one or many queries and union the results. * * @param tree - The `LiveTree` whose subtree will be searched. * @param q - A selector/query or list of queries to match (OR semantics). * @returns A `TreeSelector` containing all matches across all queries. */ export declare function find_all_in_tree_many(tree: LiveTree, q: FindQueryMany): TreeSelector; /** * Build a single-result finder bound to a `LiveTree` subtree. * * The returned function searches only within `tree.node` and exposes helper * lookups for common cases: * - `byId(id)` * - `byAttrs(attr, value)` * - `byFlags(flag)` * - `byTag(tag)` * - `byQuid(quid)` * * A matching `.must(...)` surface is also provided and throws when no match * exists. * * @param tree - The `LiveTree` whose subtree will be searched. * @returns A `find` helper bound to that subtree. */ export declare function make_find_for(tree: LiveTree): FindWithById; /** * Build a multi-result finder (`findAll`) bound to a `LiveTree` subtree. * * The returned function accepts a single query or list of queries and * exposes helper shortcuts (`id`, `byAttribute`, `byFlag`, `byTag`) plus * a `.must(...)` variant that throws when empty. * * @param tree - The `LiveTree` whose subtree will be searched. * @returns A `FindMany` helper bound to that tree. */ export declare function make_find_all_for(tree: LiveTree): FindMany; export {}; //# sourceMappingURL=find.d.ts.map