{"version":3,"file":"findMixin.mjs","sources":["../../../../src/scene/container/container-mixins/findMixin.ts"],"sourcesContent":["import { deprecation, v8_0_0 } from '../../../utils/logging/deprecation';\n\nimport type { Container } from '../Container';\n\n/** @ignore */\nexport interface FindMixinConstructor\n{\n    /**\n     * The instance label of the object.\n     * @default null\n     */\n    label?: string;\n}\n\n/**\n * The FindMixin interface provides methods for finding children within a container by their label.\n * It allows for searching for a single child or multiple children with a specific label,\n * either directly or recursively through the container's hierarchy.\n * @category scene\n * @advanced\n */\nexport interface FindMixin extends Required<FindMixinConstructor>\n{\n    /**\n     * The instance name of the object.\n     * @deprecated since 8.0.0\n     * @see Container#label\n     * @default null\n     */\n    name: string;\n    /**\n     * @deprecated since 8.0.0\n     * @param {string} label - Instance name.\n     * @param {boolean}[deep=false] - Whether to search recursively\n     * @returns {Container} The child with the specified name.\n     * @see Container#getChildByLabel\n     */\n    getChildByName(label: RegExp | string, deep?: boolean): Container | null;\n    /**\n     * Returns the first child in the container with the specified label.\n     * Recursive searches are done in a pre-order traversal.\n     * @example\n     * ```ts\n     * // Basic label search\n     * const child = container.getChildByLabel('player');\n     *\n     * // Search with regular expression\n     * const enemy = container.getChildByLabel(/enemy-\\d+/);\n     *\n     * // Deep search through children\n     * const deepChild = container.getChildByLabel('powerup', true);\n     * ```\n     * @param {RegExp|string} label - Instance label to search for\n     * @param {boolean} deep - Whether to search recursively through children\n     * @returns The first child with the specified label, or null if none found\n     * @see {@link Container#getChildrenByLabel} For finding all matches\n     * @see {@link Container#label} For setting labels\n     */\n    getChildByLabel(label: RegExp | string, deep?: boolean): Container | null;\n    /**\n     * Returns all children in the container with the specified label.\n     * Recursive searches are done in a pre-order traversal.\n     * @example\n     * ```ts\n     * // Basic label search\n     * const enemies = container.getChildrenByLabel('enemy');\n     * // Search with regular expression\n     * const powerups = container.getChildrenByLabel(/powerup-\\d+/);\n     * // Deep search with collection\n     * const buttons = [];\n     * container.getChildrenByLabel('button', true, buttons);\n     * ```\n     * @param {string|RegExp} label  - Instance label to search for\n     * @param {boolean}[deep=false] - Whether to search recursively through children\n     * @param {Container[]} [out=[]]  - Optional array to store matching children in\n     * @returns An array of children with the specified label\n     * @see {@link Container#getChildByLabel} For finding first match\n     * @see {@link Container#label} For setting labels\n     */\n    getChildrenByLabel(label: RegExp | string, deep?: boolean, out?: Container[]): Container[];\n}\n\n/** @internal */\nexport const findMixin: Partial<Container> = {\n    label: null,\n\n    get name(): string\n    {\n        // #if _DEBUG\n        deprecation(v8_0_0, 'Container.name property has been removed, use Container.label instead');\n        // #endif\n\n        return this.label;\n    },\n    set name(value: string)\n    {\n        // #if _DEBUG\n        deprecation(v8_0_0, 'Container.name property has been removed, use Container.label instead');\n        // #endif\n\n        this.label = value;\n    },\n\n    getChildByName(name: string, deep = false): Container | null\n    {\n        return this.getChildByLabel(name, deep);\n    },\n\n    getChildByLabel(label: string | RegExp, deep = false): Container | null\n    {\n        const children = this.children;\n\n        for (let i = 0; i < children.length; i++)\n        {\n            const child = children[i];\n\n            if (child.label === label || (label instanceof RegExp && label.test(child.label))) return child;\n        }\n\n        if (deep)\n        {\n            for (let i = 0; i < children.length; i++)\n            {\n                const child = children[i];\n                const found = child.getChildByLabel(label, true);\n\n                if (found)\n                {\n                    return found;\n                }\n            }\n        }\n\n        return null;\n    },\n\n    getChildrenByLabel(label: string | RegExp, deep = false, out = []): Container[]\n    {\n        const children = this.children;\n\n        for (let i = 0; i < children.length; i++)\n        {\n            const child = children[i];\n\n            if (child.label === label || (label instanceof RegExp && label.test(child.label)))\n            {\n                out.push(child);\n            }\n        }\n\n        if (deep)\n        {\n            for (let i = 0; i < children.length; i++)\n            {\n                children[i].getChildrenByLabel(label, true, out);\n            }\n        }\n\n        return out;\n    },\n} as Container;\n"],"names":[],"mappings":";;;AAmFO,MAAM,SAAA,GAAgC;AAAA,EACzC,KAAA,EAAO,IAAA;AAAA,EAEP,IAAI,IAAA,GACJ;AAEI,IAAA,WAAA,CAAY,QAAQ,uEAAuE,CAAA;A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