/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Diagnostic } from "#log/Diagnostic.js";
import "#time/StandardTime.js";
import { Timestamp } from "#time/Timestamp.js";
/**
 * A "lifetime" represents the existence of an entity or ongoing task.
 *
 * This serves as a mechanism for tracking granular information about process state for diagnostic purposes.  A lifetime
 * is present in diagnostic reports until disposed.
 *
 * Lifetimes are hierarchical.  Create sublifetimes using join().
 */
export interface Lifetime extends Disposable, Diagnostic, Lifetime.Owner {
    /**
     * The name of the lifetime used for diagnostic presentation.
     *
     * Any diagnostic (so, any value) may serve as a name.
     */
    name: unknown;
    /**
     * The time at which the lifetime began.
     */
    readonly startedAt: Timestamp;
    /**
     * A "span" is a sub-lifetime created via {@link join}.
     */
    readonly spans: Set<Lifetime>;
    /**
     * Arbitrary details presented as a dictionary with {@link name}.
     */
    readonly details: Record<string, unknown>;
    /**
     * The inverse of {@link isClosing}.
     */
    readonly isOpen: boolean;
    /**
     * Set when the lifetime begins closing (via {@link closing}) or {@link isClosed} is true.
     */
    readonly isClosing: boolean;
    /**
     * Set when the lifetime has exited.
     */
    readonly isClosed: boolean;
    /**
     * The lifetime enclosing this lifetime.
     *
     * Only the process lifetime should have no owner.  This field is writable so you can move ownership of a lifetime.
     */
    owner?: Lifetime;
    /**
     * Mark this lifetime as closing.
     *
     * Creates a sublifetime specifically for closing this lifetime.  This supports the common pattern of tracking the
     * close process associated with an active lifetime.
     *
     * Calling repeatedly returns the same sublifetime.  Disposing the returned lifetime disposes this lifetime.
     */
    closing(): Lifetime;
}
export declare function Lifetime(...name: unknown[]): Lifetime;
export declare namespace Lifetime {
    /**
     * The lifetime of the system process.
     *
     * This is effectively a "global" lifetime.  It parents all other lifetimes.
     */
    const process: Lifetime.Owner;
    /**
     * Obtain a lifetime not attached to {@link process} for testing purposes.
     */
    const mock: Lifetime;
    /**
     * An object associated with a lifetime.
     */
    interface Owner {
        /**
         * Create or move a sublifetime.
         */
        join(...name: unknown[]): Lifetime;
    }
    /**
     * A lifetime subject that exists for a portion of a larger timespan.
     */
    interface Contributor {
        [owner]: Owner;
    }
    /**
     * Determine the lifetime of the owner of a component.
     */
    function of(subject?: {}): Owner;
    const owner: unique symbol;
}
//# sourceMappingURL=Lifetime.d.ts.map