import { UMB_TEMPLATE_ENTITY_TYPE } from '../../entity.js';
import { UmbManagementApiTemplateItemDataRequestManager } from './template-item.server.request-manager.js';
import { UmbItemServerDataSourceBase } from '../../../../core/repository/index.js';
/**
 * A server data source for Template items
 * @class UmbTemplateItemServerDataSource
 * @implements {DocumentTreeDataSource}
 */
export class UmbTemplateItemServerDataSource extends UmbItemServerDataSourceBase {
    #itemRequestManager = new UmbManagementApiTemplateItemDataRequestManager(this);
    /**
     * Creates an instance of UmbTemplateItemServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbTemplateItemServerDataSource
     */
    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_TEMPLATE_ENTITY_TYPE,
        unique: item.id,
        name: item.name,
        alias: item.alias,
    };
};
