import { UMB_DICTIONARY_ENTITY_TYPE } from '../../entity.js';
import { UmbManagementApiDictionaryItemDataRequestManager } from './dictionary-item.server.request-manager.js';
import { UmbItemServerDataSourceBase } from '../../../core/repository/index.js';
/**
 * A server data source for Dictionary items
 * @class UmbDictionaryItemServerDataSource
 * @implements {DocumentTreeDataSource}
 */
export class UmbDictionaryItemServerDataSource extends UmbItemServerDataSourceBase {
    #itemRequestManager = new UmbManagementApiDictionaryItemDataRequestManager(this);
    /**
     * Creates an instance of UmbDictionaryItemServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbDictionaryItemServerDataSource
     */
    constructor(host) {
        super(host, {
            mapper,
        });
    }
    async getItems(uniques) {
        if (!uniques)
            throw new Error('Uniques are missing');
        const { data, error } = await this.#itemRequestManager.getItems(uniques);
        return { data: this._getMappedItems(data), error };
    }
}
const mapper = (item) => {
    return {
        entityType: UMB_DICTIONARY_ENTITY_TYPE,
        unique: item.id,
        name: item.name,
    };
};
