"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Views
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TiledGraphicsProvider = void 0;
/** @public */
var TiledGraphicsProvider;
(function (TiledGraphicsProvider) {
    /** @internal because TypeDoc can't disambiguate with the interface method by same name. */
    function addToScene(provider, context) {
        if (provider.addToScene)
            provider.addToScene(context);
        else
            provider.forEachTileTreeRef(context.viewport, (ref) => ref.addToScene(context));
    }
    TiledGraphicsProvider.addToScene = addToScene;
    /** @internal because TypeDoc can't disambiguate with the interface method by same name. */
    function isLoadingComplete(provider, viewport) {
        if (provider.isLoadingComplete && !provider.isLoadingComplete(viewport))
            return false;
        let allLoaded = true;
        provider.forEachTileTreeRef(viewport, (ref) => {
            allLoaded &&= ref.isLoadingComplete;
        });
        return allLoaded;
    }
    TiledGraphicsProvider.isLoadingComplete = isLoadingComplete;
    /** Obtain an iterator over all of the [[TileTreeReference]]s belonging to this provider that should be drawn in the specified [[Viewport]].
     * This function invokes [[TiledGraphicsProvider.getReferences]] if implemented by `provider`; otherwise, it populates an iterable from the references
     * provided by [[TiledGraphicsProvider.forEachTileTreeRef]], which is less efficient.
     */
    function getTileTreeRefs(provider, viewport) {
        if (provider.getReferences) {
            return provider.getReferences(viewport);
        }
        const refs = [];
        provider.forEachTileTreeRef(viewport, (ref) => {
            refs.push(ref);
        });
        return refs;
    }
    TiledGraphicsProvider.getTileTreeRefs = getTileTreeRefs;
})(TiledGraphicsProvider || (exports.TiledGraphicsProvider = TiledGraphicsProvider = {}));
//# sourceMappingURL=TiledGraphicsProvider.js.map