export function lazyAgentMap(build) {
    let cache = null;
    const ensure = () => {
        if (!cache)
            cache = build();
        return cache;
    };
    return new Proxy({}, {
        get(_t, prop) { return ensure()[prop]; },
        has(_t, prop) { return prop in ensure(); },
        ownKeys() { return Reflect.ownKeys(ensure()); },
        getOwnPropertyDescriptor(_t, prop) {
            const m = ensure();
            if (prop in m)
                return { configurable: true, enumerable: true, value: m[prop] };
            return undefined;
        },
    });
}
