"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeFlexListEager = exports.normalizeFlexListLazy = exports.markEager = exports.isLazy = void 0;
/** A symbol used to identify a `MarkedEager`. */
const flexListEager = Symbol("FlexList Eager");
/** Returns true iff the given item is a function and is not a `MarkedEager`. */
function isLazy(item) {
    return typeof item === "function" && item[flexListEager] !== true;
}
exports.isLazy = isLazy;
/**
 * Mark the given object as an eager item in a `FlexList`.
 * @remarks
 * This only has an effect on function objects that would otherwise be considered to be lazy items in a `FlexList`.
 * @param t - The object to mark as eager.
 * @returns `t`, marked as eager if applicable.
 */
function markEager(t) {
    return isLazy(t)
        ? Object.defineProperty(t, flexListEager, {
            value: true,
            configurable: true,
            enumerable: false,
            writable: false,
        })
        : t;
}
exports.markEager = markEager;
/**
 * Given a `FlexList` of eager and lazy items, return an equivalent list where all items are lazy.
 */
function normalizeFlexListLazy(t) {
    return t.map((value) => {
        if (isLazy(value)) {
            return value;
        }
        return () => value;
    });
}
exports.normalizeFlexListLazy = normalizeFlexListLazy;
/**
 * Given a `FlexList` of eager and lazy items, return an equivalent list where all items are eager.
 */
function normalizeFlexListEager(t) {
    const data = t.map((value) => {
        if (isLazy(value)) {
            return value();
        }
        return value;
    });
    return data;
}
exports.normalizeFlexListEager = normalizeFlexListEager;
//# sourceMappingURL=flexList.js.map