/**
 * @typedef {import('ol/Collection').default<import('gmf/datasource/OGC').default>} DataSources
 */
/**
 * @typedef {Object<(number|string), ManagerTreeCtrlCacheItem>} ManagerTreeCtrlCache
 */
/**
 * @typedef {Object} ManagerTreeCtrlCacheItem
 * @property {Function} filterRulesWatcherUnregister
 * @property {Function} stateWatcherUnregister
 * @property {Function} [timeLowerValueWatcherUnregister]
 * @property {Function} [timeUpperValueWatcherUnregister]
 * @property {import('ngeo/layertree/Controller').LayertreeController} treeCtrl
 * @property {import('ol/layer/Image').default<import('ol/source/Image').default>} [wmsLayer]
 */
/**
 * The GeoMapFish DataSources Manager is responsible of listening to the
 * c2cgeoportal's themes to create instances of `ngeo.datasource.DataSource`
 * objects with the layer definitions found and push them in the
 * `DataSources` collection. The Manager must be initialized
 * with the app's map using the `setDatasourceMap()` method.
 *
 * When changing theme, these data sources are cleared then re-created.
 *
 * Used metadata:
 *
 *  - `identifierAttributeField`: The field used in the 'display query window' as feature title.
 *      For WMS layers.
 */
export class DatasourceManager {
    /**
     * @param {angular.IQService} $q Angular q service
     * @param {angular.IScope} $rootScope Angular rootScope.
     * @param {angular.ITimeoutService} $timeout Angular timeout service.
     * @param {angular.IInjectorService} $injector Main injector.
     * @param {import('gmf/theme/Themes').ThemesService} gmfThemes The gmf Themes service.
     * @param {import('gmf/layertree/TreeManager').LayertreeTreeManager} gmfTreeManager The gmf TreeManager
     *    service.
     * @param {import('ngeo/map/BackgroundLayerMgr').MapBackgroundLayerManager} ngeoBackgroundLayerMgr
     *    Background layer manager.
     * @param {import('ngeo/datasource/DataSources').DataSource} ngeoDataSources Ngeo data sources service.
     *     data sources service.
     * @param {import('ngeo/map/LayerHelper').LayerHelper} ngeoLayerHelper Ngeo Layer Helper.
     * @param {import('ngeo/filter/RuleHelper').RuleHelper} ngeoRuleHelper Ngeo rule helper service.
     * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime wms time service.
     * @param {import('gmf/datasource/WFSAliases').DatasourceWFSAlias} gmfWFSAliases Gmf WFS aliases
     *    service.
     * @ngdoc service
     * @ngname gmfDataSourcesManager
     */
    constructor($q: angular.IQService, $rootScope: angular.IScope, $timeout: angular.ITimeoutService, $injector: angular.IInjectorService, gmfThemes: import("gmf/theme/Themes").ThemesService, gmfTreeManager: import("gmf/layertree/TreeManager").LayertreeTreeManager, ngeoBackgroundLayerMgr: import("ngeo/map/BackgroundLayerMgr").MapBackgroundLayerManager, ngeoDataSources: import("ngeo/datasource/DataSources").DataSource, ngeoLayerHelper: import("ngeo/map/LayerHelper").LayerHelper, ngeoRuleHelper: import("ngeo/filter/RuleHelper").RuleHelper, ngeoWMSTime: import("ngeo/misc/WMSTime").WMSTime, gmfWFSAliases: import("gmf/datasource/WFSAliases").DatasourceWFSAlias);
    /**
     * @type {angular.IQService}
     * @private
     */
    private q_;
    /**
     * @type {angular.IScope}
     * @private
     */
    private rootScope_;
    /**
     * @type {angular.ITimeoutService}
     * @private
     */
    private timeout_;
    /**
     * @type {import('gmf/theme/Themes').ThemesService}
     * @private
     */
    private gmfThemes_;
    /**
     * @type {import('gmf/layertree/TreeManager').LayertreeTreeManager}
     * @private
     */
    private gmfTreeManager_;
    /**
     * @type {import('ngeo/map/BackgroundLayerMgr').MapBackgroundLayerManager}
     * @private
     */
    private ngeoBackgroundLayerMgr_;
    /**
     * @type {import('ngeo/datasource/DataSources').DataSource}
     * @private
     */
    private ngeoDataSources_;
    /**
     * The collection of DataSources from ngeo, which gets updated by this
     * service. When the theme changes, first we remove all data sources, then
     * the 'active' data source are added here.
     *
     * @type {import('ngeo/datasource/DataSource').DataSources}
     * @private
     */
    private dataSources_;
    /**
     * @type {import('ngeo/map/LayerHelper').LayerHelper}
     * @private
     */
    private ngeoLayerHelper_;
    /**
     * @type {import('ngeo/filter/RuleHelper').RuleHelper}
     * @private
     */
    private ngeoRuleHelper_;
    /**
     * @type {import('ngeo/misc/WMSTime').WMSTime}
     * @private
     */
    private ngeoWMSTime_;
    /**
     * @type {import('gmf/datasource/WFSAliases').DatasourceWFSAlias}
     * @private
     */
    private gmfWFSAliases_;
    /**
     * While loading a new theme, this is where all of the created data sources
     * are put using the id as key for easier find in the future.
     *
     * @type {Object<string, import('gmf/datasource/OGC').default>}
     * @private
     */
    private dataSourcesCache_;
    /**
     * A reference to the dimensions object.
     *
     * @type {import('ngeo/datasource/OGC').Dimensions|undefined}
     * @private
     */
    private dimensions_;
    /**
     * The function to call to unregister the `watch` event on the dimensions
     * object properties.
     *
     * @type {?Function}
     * @private
     */
    private dimensionsWatcherUnregister;
    /**
     * The cache of layertree leaf controller, i.e. those that are added to
     * the tree manager. When treeCtrl is added in this cache, it's given
     * a reference to its according data source.
     *
     * @type {ManagerTreeCtrlCache}
     * @private
     */
    private treeCtrlCache_;
    /**
     * The function to call to unregister the `watchCollection` event on
     * the root layer tree controller children.
     *
     * @type {?Function}
     * @private
     */
    private treeCtrlsUnregister_;
    /**
     * @type {{import('gmf/options').gmfDatasourceOptions}
     */
    gmfDatasourceOptions: {
        import(: any): any;
    };
    /**
     * Set the map to use with your datasources.
     *
     * @param {import('ol/Map').default} map The map to use.
     * @hidden
     */
    setDatasourceMap(map: import("ol/Map").default): void;
    /**
     * Get a datasource by its id.
     *
     * @param {string} id The id of the datasource.
     * @returns {GmfDatasourceOGC}
     * @hidden
     */
    getDatasource(id: string): GmfDatasourceOGC;
    /**
     * @param {import('ngeo/datasource/OGC').Dimensions} dimensions A reference to the dimensions
     *     object to keep a reference of in this service.
     * @hidden
     */
    setDimensions(dimensions: import("ngeo/datasource/OGC").Dimensions): void;
    /**
     * Called when the dimensions change. Update all affected layer's filters.
     *
     * @private
     * @hidden
     */
    private handleDimensionsChange_;
    /**
     * Called when the themes change. Remove any existing data sources first,
     * then create and add data sources from the loaded themes.
     *
     * @private
     * @hidden
     */
    private handleThemesChange_;
    /**
     * Called when the list of tree controllers within the tree manager
     * root controller changes. In other words, this method is called
     * after nodes are being added added or removed from the tree,
     * i.e. from the child nodes collection.
     *
     * A timeout is required  because the collection event is fired before
     * the leaf nodes are created and they are the ones we're looking for here.
     *
     * This method handles the registration/unregistration of tree nodes that
     * are added or removed, pushing it to the cache or removing it from the
     * cache.
     *
     * @param {import('ngeo/layertree/Controller').LayertreeController[] | undefined} value List of tree
     *     controllers.
     * @private
     * @hidden
     */
    private handleTreeManagerRootChildrenChange_;
    /**
     * Remove the data sources from the ngeo collection that are in the cache,
     * i.e. those created by this service, then clear the cache.
     *
     * @private
     * @hidden
     */
    private clearDataSources_;
    /**
     * Create a data source using the information on the node, group node
     * and OGC servers. If the node has children, then we loop in those to get
     * leaf nodes. Only leaf nodes end up creating a data source. If a data
     * source with the same id already exists, then the node is skipped.
     *
     * Once a data source is created, it is added to the data sources cache.
     *
     * @param {?import('gmf/themes').GmfGroup} firstLevelGroup The first level group node.
     * @param {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} node The node, which
     *     may have children or not.
     * @param {import('gmf/themes').GmfOgcServers} ogcServers OGC servers.
     * @private
     * @hidden
     */
    private createDataSource_;
    /**
     * If the given Layertree controller is a 'leaf', add it to the cache.
     * Also, set its according data source. Finally, add the data source to
     * the ngeo collection.
     *
     * @param {import('ngeo/layertree/Controller').LayertreeController} treeCtrl Layertree controller to add
     * @private
     * @hidden
     */
    private addTreeCtrlToCache_;
    /**
     * Remove a treeCtrl cache item. Unregister event listeners and remove the
     * data source from the ngeo collection.
     *
     * @param {ManagerTreeCtrlCacheItem} item Layertree controller cache item
     * @private
     * @hidden
     */
    private removeTreeCtrlCacheItem_;
    /**
     * Clears the layer tree controller cache. At the same time, each item gets
     * its data source reference unset and state watcher unregistered.
     *
     * The data source gets also removed from the ngeo data sources collection.
     *
     * @private
     * @hidden
     */
    private clearTreeCtrlCache_;
    /**
     * Called when the state of a 'leaf' layertree controller changes.
     * Update the `visible` property of the data source according to the
     * state of the layertree controller.
     *
     * Note: The possible states can only be 'on' or 'off', because the
     * layertree controller being a 'leaf'.
     *
     * @param {import('ngeo/layertree/Controller').LayertreeController} treeCtrl The layer tree controller
     * @param {string|undefined} newVal New state value
     * @private
     * @hidden
     */
    private handleTreeCtrlStateChange_;
    /**
     * Returns a layertree controller cache item, if it exists.
     *
     * @param {import('ngeo/layertree/Controller').LayertreeController} treeCtrl The layer tree controller
     * @returns {ManagerTreeCtrlCacheItem} Cache item
     * @private
     * @hidden
     */
    private getTreeCtrlCacheItem_;
    /**
     * Return the layer corresponding to the data source.
     *
     * @param {import('ngeo/datasource/DataSource').default} dataSource The data source.
     * @returns {import('ol/layer/Base').default|undefined} The layer.
     * @private
     * @hidden
     */
    private getDataSourceLayer_;
    /**
     * Update layer filter parameter according to data sources filter rules
     * and dimensions filters.
     *
     * @param {import('ol/layer/Base').default} layer The layer to update.
     * @private
     * @hidden
     */
    private updateLayerFilter_;
    /**
     * Called when both the 'visible' and 'filterRules' properties of a data
     * source change.
     *
     * If the data source is filtrable, then make sure that when it gets rules
     * set to apply them as OGC filters to the OpenLayers layer, more precisely
     * as a `FILTER` parameter in the layer's source parameters.
     *
     * @param {import('gmf/datasource/OGC').default} dataSource Data source.
     * @private
     * @hidden
     */
    private handleDataSourceFilterRulesChange_;
    /**
     * Called when either the `timeLowerValue` or `timeUpperValue` property of a
     * data source changes.
     *
     * Get the range value from the data source, then update the WMS layer
     * thereafter.
     *
     * @param {import('gmf/datasource/OGC').default} dataSource Data source.
     * @private
     * @hidden
     */
    private handleDataSourceTimeValueChange_;
    /**
     * Called when the background layer changes. Add/Remove the according data
     * sources to/from the ngeo data sources collection. Update the data source
     * `visible` property as well.
     *
     * The `querySourceIds` property in the layer is used to determine the
     * data sources that are bound to the layer.
     *
     * @param {Event|import('ol/events/Event').default} evt Event.
     * @private
     * @hidden
     */
    private handleNgeoBackgroundLayerChange_;
}
export namespace DatasourceManager {
    let $inject: string[];
}
export default myModule;
export type DataSources = import("ol/Collection").default<import("gmf/datasource/OGC").default>;
export type ManagerTreeCtrlCache = any;
export type ManagerTreeCtrlCacheItem = {
    filterRulesWatcherUnregister: Function;
    stateWatcherUnregister: Function;
    timeLowerValueWatcherUnregister?: Function;
    timeUpperValueWatcherUnregister?: Function;
    treeCtrl: import("ngeo/layertree/Controller").LayertreeController;
    wmsLayer?: import("ol/layer/Image").default<import("ol/source/Image").default>;
};
import GmfDatasourceOGC from 'gmf/datasource/OGC';
import angular from 'angular';
/**
 * @type {angular.IModule}
 * @hidden
 */
declare const myModule: angular.IModule;
