import { UmbDocumentTypeTreeRepository } from '../../../document-type-tree.repository.js';
import { UmbRepositoryBase } from '../../../../../../core/repository/index.js';
import { UMB_ENTITY_CONTEXT } from '../../../../../../core/entity/index.js';
export class UmbDocumentTypeTreeItemChildrenCollectionRepository extends UmbRepositoryBase {
    #treeRepository = new UmbDocumentTypeTreeRepository(this);
    async requestCollection(filter) {
        // TODO: get parent from args
        const entityContext = await this.getContext(UMB_ENTITY_CONTEXT);
        if (!entityContext)
            throw new Error('Entity context not found');
        const entityType = entityContext.getEntityType();
        const unique = entityContext.getUnique();
        if (!entityType)
            throw new Error('Entity type not found');
        if (unique === undefined)
            throw new Error('Unique not found');
        const parent = { entityType, unique };
        if (parent.unique === null) {
            return this.#treeRepository.requestTreeRootItems({ skip: filter.skip, take: filter.take });
        }
        else {
            return this.#treeRepository.requestTreeItemsOf({ parent, skip: filter.skip, take: filter.take });
        }
    }
}
export { UmbDocumentTypeTreeItemChildrenCollectionRepository as api };
