import React from 'react';
import { observer } from 'mobx-react-lite';
import { useMultiCollectionSupportContext } from '../MultiCollectionSupportProvider';
import { TextButton } from '@wix/design-system';
import { Revert } from '@wix/wix-ui-icons-common';
import { useWixPatternsContainer, useCollectionContext, } from '@wix/bex-core/react';
import { EmptyStateBase } from './EmptyStateBase';
import { MagnifyingGlassArt } from '../MagnifyingGlassArt';
function _CollectionNoResultsState(props) {
    const state = useMultiCollectionSupportContext();
    const { translate: t } = useWixPatternsContainer();
    const { title, subtitle, cta } = getNoResultsStateTexts(state, t);
    return (React.createElement(EmptyStateBase, { dataHook: "collection-empty-state", title: title, subtitle: subtitle, ...props, cta: cta, image: React.createElement(MagnifyingGlassArt, { "data-hook": "empty-state-glass-illustration" }) }));
}
function ResetFiltersButton(props) {
    const state = useCollectionContext();
    return (React.createElement(TextButton, { ...props, prefixIcon: React.createElement(Revert, null), dataHook: "empty-state-clear-filters-button", onClick: () => {
            state.emitter.emit('beforeClearFilters', { origin: 'empty-state' });
            state.resetFiltersAndRefresh();
            state.searchInputRef?.focus();
        } }));
}
const getNoResultsStateTexts = (state, t) => {
    const { hasAvailableItems, hasNonPersistentCustomFilters, resultOriginQuerySearch: search, resultOriginQueryRawSearch: rawSearch, } = state;
    // has search no filter
    if (hasAvailableItems && search && !hasNonPersistentCustomFilters) {
        return {
            title: t('cairo.search.nothingMatches.title', {
                term: rawSearch,
            }),
            subtitle: t('cairo.search.nothingMatches.text'),
            cta: (React.createElement(ResetFiltersButton, null, t('cairo.emptyState.reset.button'))),
        };
    }
    // has filter no search
    if (hasAvailableItems && !search && hasNonPersistentCustomFilters) {
        return {
            title: t('cairo.search.noresults.title'),
            subtitle: t('cairo.emptyState.subtitle.noFilterResults'),
            cta: (React.createElement(ResetFiltersButton, null, t('cairo.emptyState.filters.nothingFound.clearFilters.CTA'))),
        };
    }
    // has filter and search
    return {
        title: t('cairo.search.nothingMatches.title', {
            term: rawSearch,
        }),
        subtitle: t('cairo.search.filter.nothingMatches.text'),
        cta: (React.createElement(ResetFiltersButton, null, t('cairo.emptyState.reset.button'))),
    };
};
export const CollectionNoResultsState = observer(_CollectionNoResultsState);
//# sourceMappingURL=CollectionNoResultsState.js.map