/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ServiceProvider } from "#environment/ServiceProvider.js";
import { SharedEnvironmentServices } from "#environment/SharedEnvironmentServices.js";
import { Lifetime } from "#util/Lifetime.js";
import { MaybePromise } from "#util/Promises.js";
import "../polyfills/disposable.js";
import { Observable } from "../util/Observable.js";
import { Environmental } from "./Environmental.js";
import { RuntimeService } from "./RuntimeService.js";
import { VariableService } from "./VariableService.js";
/**
 * Access to general platform-dependent features.
 *
 * The following variables are defined by this class:
 * * `log.level` - Log level to use {@link Logger.LEVEL}
 * * `log.format` - Log format to use {@link Logger.FORMAT}
 * * `log.stack.limit` - Stack trace limit, see https://nodejs.org/api/errors.html#errorstacktracelimit
 * * `mdns.networkInterface` - Network interface to use for MDNS broadcasts and scanning, default are all available interfaces
 * * `mdns.ipv4` - Also announce/scan on IPv4 interfaces
 * * `network.interface` - Map of interface names to types, expected to be defined as object with name as key and of `{type: string|number}` objects with types: 1=Wifi, 2=Ethernet, 3=Cellular, 4=Thread (strings or numbers can be used). Can also be provided via env or cli like `MATTER_NETWORK_INTERFACE_ETH0_TYPE=Ethernet`
 *
 * The environment supports reference-counted service sharing through shared service instances. Create
 * a shared instance using {@link asDependent} to access services with automatic lifecycle tracking at
 * the root environment. Shared services enable safe sharing across multiple consumers - services are
 * protected from premature closure and only cleaned up when all consumers have released them.
 *
 * Services can be accessed directly via {@link get} for immediate use, or through {@link SharedEnvironmentServices}
 * for tracked access at the root level. Direct access means services close immediately when requested.
 * Shared access means services are registered at root and only close when all consumers have released them.
 *
 * When services are deleted or closed without shared tracking, the service is blocked locally and does
 * not inherit from parent environments. When accessed through shared instances, the service is managed
 * at the root environment and protected as long as any consumer is using it.
 *
 * TODO - could remove global singletons by moving here
 */
export declare class Environment implements ServiceProvider, Lifetime.Owner {
    #private;
    constructor(name: string, parent?: Environment);
    join(...name: unknown[]): Lifetime;
    /**
     * Create a shared service instance for reference-counted service access at root.
     *
     * Shared instances track which services they use and enable safe sharing across multiple
     * consumers. Services are automatically protected from premature closure and only
     * cleaned up when all consumers have released them, e.g. by calling close().
     *
     * All shared instances operate at the root environment for centralized lifecycle
     * management, regardless of which environment in the hierarchy creates them.
     *
     * @returns A new shared service instance for accessing services with lifecycle tracking
     */
    asDependent(): SharedEnvironmentServices;
    /**
     * Determine if an environmental service is available.
     */
    has(type: Environmental.ServiceType): boolean;
    /**
     * Determine if an environmental services is owned by this environment (not an ancestor).
     */
    owns(type: Environmental.ServiceType): boolean;
    /**
     * Access an environmental service.
     */
    get<T extends object>(type: Environmental.ServiceType<T>): T;
    /**
     * Access an environmental service that may not exist.
     */
    maybeGet<T extends object>(type: Environmental.ServiceType<T>): T | undefined;
    /**
     * Remove an environmental service and block further inheritance.
     *
     * If any consumer is currently using the service, deletion is deferred until all
     * consumers have released it. Services accessed via {@link SharedEnvironmentServices}
     * are protected from premature removal.
     */
    delete(type: Environmental.ServiceType, instance?: any): void;
    /**
     * Remove and close an environmental service.
     *
     * Calls the service's close method if present, then removes it from the environment.
     * If any consumer is currently using the service, closure is deferred until all
     * consumers have released it.
     */
    close<T extends object>(type: Environmental.ServiceType<T>): T extends {
        close: () => MaybePromise<void>;
    } ? MaybePromise<void> : void;
    /**
     * Access an environmental service, waiting for any async initialization to complete.
     */
    load<T extends Environmental.Service>(type: Environmental.Factory<T>): Promise<T>;
    /**
     * Install a preinitialized version of an environmental service.
     */
    set<T extends {}>(type: Environmental.ServiceType<T>, instance: T): void;
    /**
     * Name of the environment.
     */
    get name(): string;
    /**
     * Get the root environment in the hierarchy.
     *
     * Recursively traverses parent links to find the topmost environment with no parent.
     * Used internally to ensure certain services (like DependentsManager) are installed
     * at a single, consistent location for the entire environment tree.
     */
    get root(): Environment;
    /**
     * Emits on service add.
     *
     * Currently only emits for services owned directly by this environment.
     */
    get added(): Observable<[type: Environmental.ServiceType<object>, instance: {}], void>;
    /**
     * Emits on service delete.
     *
     * Currently only emits for services owned directly by this environment.
     */
    get deleted(): Observable<[type: Environmental.ServiceType<object>, instance: {}], void>;
    /**
     * Obtain an object with events that trigger when a specific service is added or deleted.
     *
     * This is a more convenient way to observe a specific service than {@link added} and {@link deleted}.
     */
    eventsFor<T extends Environmental.ServiceType>(type: T): Environmental.ServiceEvents<T>;
    /**
     * Apply functions to a specific service type automatically.
     *
     * The environment invokes {@link added} immediately if the service is currently present.  It then invokes
     * {@link added} in the future if the service is added or replaced and/or {@link deleted} if the service is replaced
     * or deleted.
     */
    applyTo<T extends object>(type: Environmental.ServiceType<T>, added?: (env: Environment, service: T) => MaybePromise<void>, deleted?: (env: Environment, service: T) => MaybePromise<void>): void;
    /**
     * The default environment.
     *
     * Currently only emits for services owned directly by this environment.
     */
    static get default(): Environment;
    /**
     * Set the default environment.
     */
    static set default(env: Environment);
    /**
     * Shortcut for accessing {@link VariableService.vars}.
     */
    get vars(): VariableService;
    /**
     * Shortcut for accessing {@link RuntimeService}.
     */
    get runtime(): RuntimeService;
    /**
     * Display tasks that supply diagnostics.
     */
    diagnose(): void;
    protected loadVariables(): Record<string, any>;
    [Symbol.dispose](): void;
}
//# sourceMappingURL=Environment.d.ts.map