import { UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_SEARCH_PROVIDER_ALIAS } from '../../constants.js';
import { UMB_DOCUMENT_TYPE_PICKER_MODAL } from '../../modals/index.js';
import { UmbPickerInputContext } from '../../../../core/picker-input/index.js';
export class UmbDocumentTypePickerInputContext extends UmbPickerInputContext {
    constructor(host) {
        super(host, UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_PICKER_MODAL);
    }
    async openPicker(pickerData, args) {
        if (args?.documentTypesOnly && args?.elementTypesOnly) {
            throw new Error('You cannot set both documentTypesOnly and elementTypesOnly to true.');
        }
        const isElementType = args?.elementTypesOnly ?? (args?.documentTypesOnly === true ? false : undefined);
        const combinedPickerData = {
            ...pickerData,
        };
        if (!pickerData?.search) {
            combinedPickerData.search = {
                providerAlias: UMB_DOCUMENT_TYPE_SEARCH_PROVIDER_ALIAS,
                ...pickerData?.search,
            };
        }
        combinedPickerData.search.queryParams = {
            isElementType,
            ...pickerData?.search?.queryParams,
        };
        await super.openPicker(combinedPickerData);
    }
}
