/*!
 * Custom elements for Nanopore-Digital Web applications
 */
import { proxyCustomElement, HTMLElement, createEvent, Build, Host } from '@stencil/core/internal/client';
import { t as transformTag, h } from './renderer.js';
import { a as addGlobalStylesheetToShadow } from './style.js';
import { d as defineCustomElement$2 } from './algolia.js';
import { d as defineCustomElement$1 } from './spinner.js';

let searchInsights;
const searchInsight = {
    /**
     * Initialise algolia search insights.
     * Will asynchronously import the search-insight library
     * @param appId
     * @param apiKey
     */
    init: async (appId, apiKey) => {
        if (searchInsights)
            return;
        searchInsights = (await import('./index-browser.js')).default;
        searchInsights('init', {
            appId,
            apiKey,
        });
    },
    /**
     * Sends a `clickedObjectIDsAfterSearch` event to algolia search-insights.
     * `init(...)` Must have been called first.
     * @param params
     */
    sendClick: (params) => {
        if (!searchInsights) {
            console.error('You must call `init()` first');
            return;
        }
        searchInsights('clickedObjectIDsAfterSearch', { ...params }).catch((e) => {
            console.error('Error sending click event', e);
        });
    },
    /**
     * Associates algolia analytics with a user id
     * @param userToken
     */
    setUser: (userToken) => {
        if (!searchInsights) {
            console.error('You must call `init()` first');
            return;
        }
        searchInsights('setUserToken', userToken);
    },
};

const globalSearchResultsCss = ":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{display:block;flex:1 1 100%}.main-search{display:flex;background:var(--nano-color-base-0);font-size:14px;min-block-size:calc(100vh - 63px);justify-content:space-between;max-inline-size:1266px;margin:auto}.main-search__wrap{display:contents;block-size:100%}.main-search ul{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:var(--nano-spacing-xl)}.main-search li{margin:0;padding:0}.main-search button:not(.result__tags-tag){appearance:none;border:none;background:none;position:relative;cursor:pointer}.main-search button:not(.result__tags-tag):focus-visible{outline:var(--nano-focus-ring);outline-offset:var(--nano-focus-ring-offset)}.main-search a:focus-visible{outline:var(--nano-focus-ring);outline-offset:var(--nano-focus-ring-offset)}.main-search .icon-button{color:inherit;align-self:normal;padding:9px 7px;cursor:pointer;display:flex;align-items:center}.main-search div[slot=start-output]{border-block-end:1px solid var(--nano-color-neutral-300);margin-block-end:var(--nano-spacing-md)}.main-search__topbar{display:flex;align-items:center;flex-wrap:wrap;margin-block-end:1em}.main-search__applied-filters{display:flex;flex-wrap:wrap;gap:var(--nano-spacing-sm);margin-block-end:var(--nano-spacing-md)}.main-search .topbar__bkbtn{position:relative;inset-inline-start:-7px}:host(.small) .main-search .topbar__query{display:none}.main-search .topbar__filtering{display:flex;align-items:center;margin-block:0;margin-inline:1em 0;flex:1}.main-search .topbar__order{min-inline-size:175px;max-inline-size:200px;margin-inline-start:auto}:host(.small) .main-search .topbar__order{max-inline-size:300px}.main-search .topbar .nano-select{opacity:1;transition:0.1s ease opacity}.main-search .topbar .nano-select:not(.hydrated){opacity:0}.main-search .topbar__show-filters{margin-inline-start:0.5em;text-transform:uppercase;display:none;flex-direction:column;align-items:center}.main-search .topbar__show-filters .nano-icon{font-size:20px}:host(.small) .main-search .topbar__show-filters{display:flex}.main-search .topbar__filter-count{inline-size:12px;block-size:12px;box-shadow:inset 0 3px 4px 0 rgba(0, 0, 0, 0.2);border:solid 1px #005c76;background-color:#005c76;color:white;font-size:7px;border-radius:50%;display:flex;align-items:center;justify-content:center;line-height:1;margin-block-end:3px}.main-search__results{font-size:14px;padding:var(--nano-spacing-md) var(--nano-spacing-l1-default);color:var(--nano-color-neutral-1400);inline-size:70%;block-size:100%}:host(.small) .main-search__results{inline-size:100%}.main-search__filters{outline:none;padding-inline:0 var(--nano-spacing-l1-default);padding-block:var(--nano-spacing-l) var(--nano-spacing-md);flex:1 1 30%;box-sizing:border-box}:host(:not(.small)) .main-search__filters{max-inline-size:350px;min-inline-size:220px}.filters{color:var(--nano-color-neutral-1400);font-size:var(--nano-font-size-xs)}:host(.small) .filters{position:fixed;inline-size:0;block-size:0;z-index:var(--nano-z-index-modal);inset-block-start:0;inset-inline-end:0;transition:all 0s ease 0.5s;background:none}:host(.small) .filters.show{block-size:100vh;inline-size:100vw;transition:all 0s ease 0s}:host(.small) .filters.show::after{opacity:1}:host(.small) .filters::after{content:\"\";background:rgba(0, 0, 0, 0.5);position:absolute;inset:0;z-index:-1;opacity:0;transition:0.1s ease opacity}.filters__close-filters{display:none !important;font-size:1.4em}:host(.small) .filters__close-filters{display:inline-block !important;margin-inline:auto 0;margin-block:0}.filters__old-posts{margin-inline-start:1rem}:host(.small) .filters-wrap{position:absolute;inset-block-start:0;inset-inline-end:0;transform:translateX(120%);inline-size:300px;min-inline-size:200px;max-inline-size:80vw;transition:transform 0.3s ease;padding:var(--nano-spacing-md);overflow:auto;block-size:100vh;background-color:var(--nano-color-surface-200);box-shadow:var(--nano-shadow-l2)}:host(.small) .filters.show .filters-wrap{transform:translateX(0%);box-shadow:-3px -3px 7px rgba(0, 0, 0, 0.1)}.filters ul{margin:0;padding:0;list-style:none;gap:var(--nano-spacing-sm);display:flex;flex-direction:column}.filters li{margin:0;padding:0}.filters li:last-child .filter-label{margin-block-end:0}.filters .filter-label{display:grid;place-items:center center;grid-template-columns:1.125em 1fr;gap:var(--nano-spacing-sm);cursor:pointer}.filters .filter-label>*{justify-self:start;font-size:var(--nano-font-size-2xs)}.filters .filter-label::before{content:\"\";grid-column:1;grid-row:1;border-radius:1px;block-size:1.125em;inline-size:1.125em;border:1px solid var(--nano-color-primary-1000);font-size:1rem}.filters .filter-label::after{content:\"\";grid-column:1;grid-row:1;border:solid var(--nano-color-basic-white);border-width:0 0.125em 0.125em 0;opacity:1;transition:scale var(--nano-transition-x-fast) ease-out;transform-origin:center;rotate:45deg;scale:0;inline-size:0.325em;block-size:0.5625em;margin-block-start:-0.1875em;font-size:1rem}.filters .filter-cb{clip-path:inset(50%);block-size:1px;overflow:hidden;position:absolute;white-space:nowrap;inline-size:1px}.filters .filter-cb:checked~.filter-label::before{background-color:var(--nano-color-primary-1000)}.filters .filter-cb:checked~.filter-label::after{scale:1}.filters .filter-cb:focus-visible:focus~.filter-label::before{outline:var(--nano-focus-ring);outline-offset:1px}.filters-header{display:flex;align-items:center;border-block-end:1px solid var(--nano-color-neutral-300);padding-block-end:var(--nano-spacing-md);margin-block-end:var(--nano-spacing-md)}.filters-reset{color:var(--nano-color-primary-1000);font-size:var(--nano-font-size-xs);text-decoration:underline;margin-inline:auto 0;margin-block:0;appearance:none;background:none;border:none}:host(.small) .filters-reset{margin:0}.filters-title{margin:0;text-transform:uppercase;color:rgba(69, 85, 86, 0.85);font-weight:bold;font-size:var(--nano-font-size-xs)}:host(.small) .filters-title{display:none}.filters-list{display:flex;flex-direction:column;gap:var(--nano-spacing-md)}.result{text-decoration:none;display:flex;flex-flow:row wrap;gap:var(--nano-spacing-sm);color:var(--nano-color-neutral-1400)}.result *{word-wrap:break-word;overflow-wrap:break-word}.result__title{inline-size:70%;display:flex}.result__title a{font-size:var(--nano-font-size-sm);line-height:var(--nano-line-height-normal);font-weight:var(--nano-font-weight-bold);text-decoration:none;color:var(--nano-color-neutral-1400)}.result__title .nano-icon{margin-inline:0 0.5em;margin-block:0;min-inline-size:20px;min-block-size:20px;opacity:0.8}@media (max-width: 992px){.result__title{inline-size:100%}}.result__body{font-size:var(--nano-font-size-xs);inline-size:70%;text-decoration:none;color:var(--nano-color-neutral-1400)}@media (max-width: 992px){.result__body{inline-size:100%}}.result__pdf{display:inline-block;margin-inline-start:0.5rem;color:var(--nano-color-neutral-300)}.result__meta{display:flex;flex-flow:row wrap;font-size:var(--nano-font-size-2xs);line-height:13px;inline-size:100%;align-items:center}.result__meta>*:not(:last-child){padding-inline-end:0}.result__meta>*:not(:last-child)::after{content:\"\";block-size:1rem;inline-size:1px;background:var(--nano-color-neutral-300);display:inline-block;margin-inline:0.7rem}@media (max-width: 576px){.result__meta>*:not(:last-child)::after{display:none}}@media (max-width: 576px){.result__meta{flex-flow:column;align-items:flex-start}}.result__tags{display:flex;flex-flow:row wrap;gap:var(--nano-spacing-sm)}@media (max-width: 576px){.result__tags{padding-inline-start:0}}.result__type{text-transform:capitalize;white-space:nowrap;display:flex;align-items:center}.result__date{display:flex;align-items:center}.result__source{padding-inline-end:0.75rem}.result__authors{font-size:var(--nano-font-size-2xs);margin-block-end:var(--nano-spacing-xs);text-decoration:none;inline-size:70%;color:var(--nano-color-neutral-1400)}.result__buttons{inline-size:70%;margin-block-end:0.5rem}.result__promo{inline-size:70%;margin-block-end:0.5rem;text-decoration:none;color:var(--nano-color-neutral-1400)}.result__promo-box{inline-size:300px;background-color:#e3eef1;padding:12px 12px 8px 4px;display:flex;flex-flow:row nowrap;margin-block-start:1rem}.result__promo-bigdate{flex:0 1 60px;text-align:center;font-weight:600;color:var(--nano-color-primary-1000);text-transform:uppercase;line-height:1;letter-spacing:1.5px}@media (max-width: 992px){.result__promo-bigdate{inline-size:100%}}.result__promo-bigdate span{color:var(--nano-color-neutral-1400);display:block}.result__promo-bigdate~div{padding-inline-start:1rem;border-inline-start:1px solid var(--nano-color-neutral-300)}.result__promo-date{font-size:var(--nano-font-size-2xs)}.result__promo-venue{font-size:var(--nano-font-size-2xs)}.result__promo .nano-icon{color:var(--nano-color-primary-1000);position:relative;inset-block-start:1px;padding-inline-end:2px}.result__image{display:block;background-size:cover;background-repeat:no-repeat;background-position:center;border-radius:4px;position:relative;inline-size:100%;block-size:150px;margin-block-end:var(--nano-spacing-xs)}@media (min-width: 576px){.result__image{inline-size:142px;block-size:80px}}.result__image .nano-icon{position:absolute;inset-block-start:calc(50% - 0.75rem);inset-inline-start:calc(50% - 0.75rem);font-size:var(--nano-pictogram-size-small);color:var(--nano-color-primary-1000);--primary-color:var(--nano-color-base-0);--secondary-color:var(--nano-color-primary-1000);--primary-opacity:1}@media (max-width: 576px){.result__image .nano-icon{font-size:3rem;inset-block-start:calc(50% - 1.5rem);inset-inline-start:calc(50% - 1.5rem)}}.result__video-body{inline-size:70%;text-decoration:none;display:flex;flex-flow:row wrap}@media (max-width: 992px){.result__video-body{inline-size:100%}}@media (max-width: 576px){.result__video-body{flex-flow:column}}.result__video-body .result__body{padding-inline-start:var(--nano-spacing-md);display:flex;flex-direction:column;margin-block-end:0;flex:1}@media (max-width: 576px){.result__video-body .result__body{padding-inline-start:0}}.result__video-body .result__body p{display:inline;margin:0}.result__video-body .result__body u,.result__video-body .result__body li,.result__video-body .result__body a{text-decoration:none}.result__video-body .result__body .result__meta{margin-block-start:0.5rem}.result__video-body .result__body .result__description{flex:1 0 auto}.search-empty{padding:var(--nano-spacing-xl) 0;text-align:center;border-block-start:1px solid var(--nano-color-neutral-300)}.search-empty h2{font-weight:var(--nano-font-weight-normal);font-size:var(--nano-font-size-xl);line-height:var(--nano-line-height-denser);text-wrap:balance}.search-empty-icon{font-size:7rem;--icon-color:#e4e6e8;margin-block-end:2rem}.search__highlight{background:var(--nano-color-highlight);font-style:normal}";

const filterOldPosts = 'created > ' + Math.floor((Date.now() - 63115200000) / 1000);
let searchResultIds = 0;
const GlobalSearchResults = /*@__PURE__*/ proxyCustomElement(class GlobalSearchResults extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.nanoSearchGoBack = createEvent(this, "nanoSearchGoBack", 7);
    }
    algoliaResultsEle;
    filtersDiv;
    openFilterBtn;
    ro;
    searchResultId = searchResultIds++;
    queryId = this.searchResultId > 0 ? `searchq-${this.searchResultId}` : 'searchq';
    globalNav;
    algoliaResults;
    algoliaEle;
    currentWidth;
    apiKey;
    appId;
    index;
    get el() { return this; }
    /**
     * Fired when the user clicks the 'back' button / closes the search panel
     * Calling `event.preventDefault()` will prevent it from being closed.
     */
    nanoSearchGoBack;
    handleAlgoliaCredsChange() {
        if (!this.apiKey || !this.appId || !this.algoliaEle)
            return;
        this.algoliaEle.apiKey = this.apiKey;
        this.algoliaEle.appId = this.appId;
    }
    handleAlgoliaIndexChange() {
        if (!this.index || !this.algoliaEle)
            return;
        this.algoliaEle.searchIndex = this.index;
    }
    handleAlgoliaEleChange() {
        if (!this.algoliaEle || !this.algoliaResults)
            return;
        if (this.algoliaResults.indexName === 'Community') {
            this.algoliaEle.filters = [filterOldPosts]; // only get last 2 years
        }
    }
    handleGlobalNavReset = () => {
        this.algoliaResultsEle = null;
        this.goback();
    };
    handleGlobalNavSearch = (e) => {
        const { detail: { meta, client }, } = e;
        this.apiKey = client.apiKey;
        this.appId = client.appId;
        this.index = {
            name: meta.indexTitle,
            index: meta.index,
            domain: meta.domain,
            filters: meta.filters,
            replicas: meta.replicas,
        };
        this.algoliaEle.query = meta.query;
    };
    handleNanoFilterChanged() {
        if (!this.algoliaEle.showResults ||
            !this.algoliaResultsEle?.querySelector('.topbar'))
            return;
        const topBar = this.algoliaResultsEle.querySelector('.topbar');
        if (topBar.scrollIntoViewIfNeeded) {
            // @ts-expect-error - scrollIntoViewIfNeeded is not standard
            topBar.scrollIntoViewIfNeeded();
        }
        else {
            topBar.scrollIntoView({ behavior: 'smooth', block: 'start' });
        }
    }
    handleReorder(e) {
        if (e
            .composedPath()
            .find((ele) => ele.classList && ele.classList.contains('indexchange')) &&
            !!this.algoliaResultsEle) {
            this.changeOrder(e);
        }
    }
    attachListeners(e) {
        searchInsight.init(e.detail.client.appId, e.detail.client.apiKey);
        if (!e
            .composedPath()
            .find((ele) => ele.id && ele.id === 'main-search'))
            return;
        this.algoliaResultsEle = this.algoliaEle.querySelector('#main-search-results');
        this.algoliaResults = e.detail.meta;
        // add results listeners
        this.attachResultListeners();
        this.algoliaEle.querySelectorAll('.filters-reset').forEach((item) => {
            item.addEventListener('click', () => {
                this.removeAllFilters();
            });
        });
        this.algoliaEle.querySelectorAll('.close-filters').forEach((item) => {
            item.addEventListener('click', () => {
                this.closefilters();
            });
        });
        const filterWrap = this.algoliaEle.querySelector('.filters-wrap');
        if (filterWrap) {
            filterWrap.addEventListener('click', (e) => {
                e.stopPropagation();
            });
        }
        this.filtersDiv = this.algoliaEle.querySelector('#main-search-filters');
        const oldResults = this.algoliaEle.querySelector('.old-posts');
        if (oldResults) {
            oldResults.addEventListener('nanoChange', (e) => {
                this.toggleOldResults(e.target.checked);
            });
        }
    }
    attachResultListeners(e) {
        if (e && e.composedPath()?.find((el) => el === this.algoliaEle)) {
            this.algoliaResultsEle = this.algoliaEle.querySelector('nano-algolia-results');
        }
        if (!this.algoliaResultsEle)
            return;
        const resultEle = this.algoliaResultsEle;
        // wire up hit event listener for analytics
        this.algoliaResultsEle.removeEventListener('click', this.resultClick);
        this.algoliaResultsEle.addEventListener('click', this.resultClick);
        // wire up remove filter event listener
        resultEle.querySelectorAll('.remove-filter').forEach((item) => {
            item.removeEventListener('nanoClose', this.removeFilterClick);
            item.addEventListener('nanoClose', this.removeFilterClick);
        });
        // wire up the back button event listener
        resultEle.querySelectorAll('.back-btn').forEach((item) => {
            item.removeEventListener('click', this.goback);
            item.addEventListener('click', this.goback);
        });
        // wire up mobile filter list panel event listener
        resultEle.querySelectorAll('.topbar__show-filters').forEach((item) => {
            this.openFilterBtn = item;
            item.removeEventListener('click', this.showFiltersClick);
            item.addEventListener('click', this.showFiltersClick);
        });
        // wire up tags event listeners
        const tags = Array.from(resultEle.querySelectorAll('.result__tags-tag'));
        tags.forEach((tag) => {
            tag.removeEventListener('click', this.tagClick);
            tag.addEventListener('click', this.tagClick);
        });
    }
    onDocNanoSearchResult(e) {
        if (!this.globalNav)
            return;
        if (e.target !== this.globalNav)
            return;
        this.handleGlobalNavSearch(e);
    }
    onDocNanoSearchReset(e) {
        if (!this.globalNav)
            return;
        if (e.target !== this.globalNav)
            return;
        this.handleGlobalNavReset();
    }
    /** Manually close the search panel */
    async closeSearch(clearHistory = false) {
        if (clearHistory) {
            this.goback();
            return;
        }
        this.algoliaEle.showResults = false;
    }
    resultClick = (e) => {
        const hit = e.target.closest('.result');
        if (e.target.tagName === 'A' && hit) {
            searchInsight.sendClick({
                index: this.algoliaResults.index,
                eventName: 'Global nav full search - search result clicked',
                queryID: this.algoliaResults.queryID,
                objectIDs: [hit.dataset.hitId],
                positions: [Number(hit.dataset.hitCount) + 1],
            });
            this.closeSearch();
        }
    };
    showFiltersClick = () => {
        this.filtersDiv.tabIndex = -1;
        this.filtersDiv.classList.add('show');
        this.filtersDiv.setAttribute('aria-expanded', 'true');
        document.body.style.overflow = 'hidden';
        setTimeout(() => this.filtersDiv.focus(), 20);
    };
    removeFilterClick = (e) => {
        const target = e.target.closest('[data-filter-val]');
        this.removeFilter(target?.dataset.filter, target?.dataset.filterVal);
    };
    tagClick = (e) => {
        e.preventDefault();
        let tagVal = e.target.dataset.value;
        tagVal = tagVal === 'publication' ? 'publications' : tagVal;
        tagVal = tagVal.toLowerCase();
        const filter = this.algoliaEle.querySelector('nano-algolia-filter[filter-name="tags"]');
        if (filter.value.indexOf(tagVal) === -1) {
            filter.value = filter.value ? [...filter.value, tagVal] : [tagVal];
        }
    };
    changeOrder(ev) {
        this.algoliaEle.replicaIndex = ev.detail.value;
    }
    goback = () => {
        const goBackEvent = this.nanoSearchGoBack.emit();
        if (goBackEvent.defaultPrevented)
            return;
        this.removeAllFilters();
        this.algoliaEle.query = undefined;
        this.algoliaEle.showResults = false;
    };
    removeFilter(facet, filter) {
        this.algoliaEle.removeFilters(facet, filter);
    }
    removeAllFilters() {
        this.algoliaEle.removeFilters();
    }
    closefilters() {
        if (!this.filtersDiv)
            return;
        this.filtersDiv.tabIndex = null;
        this.filtersDiv.classList.remove('show');
        this.filtersDiv.setAttribute('aria-expanded', 'false');
        document.body.style.overflow = '';
        setTimeout(() => this.openFilterBtn?.focus(), 20);
    }
    toggleOldResults(show) {
        if (show)
            this.algoliaEle.filters = this.algoliaEle.filters.filter((f) => !f.startsWith('created > '));
        else
            this.algoliaEle.filters = [...this.algoliaEle.filters, filterOldPosts];
    }
    componentWillLoad() {
        if (Build.isBrowser)
            addGlobalStylesheetToShadow(this.el.shadowRoot);
    }
    connectedCallback() {
        const globalNavTag = transformTag('nano-global-nav');
        this.globalNav = this.el.closest(globalNavTag);
        if (!this.globalNav) {
            const ownerHost = this.el.getRootNode()?.host;
            if (ownerHost && ownerHost.tagName === globalNavTag.toUpperCase()) {
                this.globalNav = ownerHost;
            }
        }
        if (!this.globalNav) {
            console.error('`<nano-global-search-results>` must be a child of `<nano-global-nav>`');
            return;
        }
        this.handleAlgoliaEleChange();
    }
    disconnectedCallback() {
        if (this.ro) {
            this.ro.disconnect();
        }
    }
    componentDidLoad() {
        if (!window['ResizeObserver'])
            return;
        this.ro = new ResizeObserver((entries) => {
            for (const entry of entries) {
                if (!entry.contentRect.width)
                    return;
                this.currentWidth = entry.contentRect.width;
            }
        });
        this.ro.observe(this.el);
    }
    render() {
        return (h(Host, { key: '63af990582466961e1cf02c9e67bd8cffa82e620', class: {
                small: this.currentWidth < 780,
                'nano-global-search-results': true,
            }, dir: this.el.ownerDocument.dir === 'rtl' ? 'rtl' : undefined }, h("nano-algolia", { key: 'ea81b7334b7d2edb65328f65c70db0f75b48820c', storeId: this.queryId, storeMethod: "url-hash-push", class: "main-search__wrap sc-nano-global-search-results", ref: (ele) => requestAnimationFrame(() => (this.algoliaEle = ele)), id: "main-search",
            // @ts-expect-error this bubbles from nano-algolia-filter
            onNanoFilterChanged: () => this.handleNanoFilterChanged() }, h("template", { key: '10cf57aac61c6b40cd3a285ddfd03b483b9d131d', slot: "template" }, 
        /* html */ `<div class="main-search sc-nano-global-search-results">
              <nano-algolia-results id="main-search-results" class="main-search__results sc-nano-global-search-results" infinite-scroll>
                <script type="text/template" slot="start-template">
                  <div class="sc-nano-global-search-results main-search__topbar topbar">
                    <nano-icon-button icon-name="light/chevron-left" class="sc-nano-global-search-results topbar__bkbtn back-btn icon-button"></nano-icon-button>
                    <div>
                      <em class="sc-nano-global-search-results topbar__query">'{{ it.query }}' - </em> <strong>{{ it.totalHitsWithFilters }}</strong> Results
                    </div>

                    <div class="sc-nano-global-search-results topbar__filtering">
                      {{ @if (it.results.length) }}
                        {{ @if (it.searchIndex && it.searchIndex.replicas) }}
                          <nano-select class="sc-nano-global-search-results topbar__order indexchange" value="{{ it.index }}" hide-label="true" label="Sort order" show-inline-error="false">
                          {{ @each(it.searchIndex.replicas) => replica }}
                            <nano-option value="{{ replica.index }}">{{ replica.name }}</nano-option>
                          {{ /each }}
                          </nano-select>
                        {{ /if }}
                      {{ /if }}

                      <button class="sc-nano-global-search-results topbar__show-filters filters-title" aria-controls="main-search-filters">
                        {{ @if (it.appliedFilters && it.appliedFilters.length > 0) }}
                          <span class="sc-nano-global-search-results topbar__filter-count">
                            {{ (it.appliedFilters.reduce(function(a, b) { return a + (b.values ? b.values.length : 0) }, 0)) }}
                          </span>
                        {{ /if }}
                        <nano-icon class="sc-nano-global-search-results" name="light/filter"></nano-icon>
                      </button>
                    </div>
                  </div>

                  {{ @if (it.results.length) }}
                    <div class="sc-nano-global-search-results main-search__applied-filters">
                      {{ @if (it.appliedFilters) }}
                        {{ @each(it.appliedFilters) => filterObj }}
                          {{ @each(filterObj.values) => filterVal }}
                            <nano-tag 
                              closable 
                              size="large" 
                              data-filter-val="{{ filterVal }}" 
                              data-filter="{{ filterObj.name }}" 
                              class="remove-filter"
                            >{{ filterVal | tag_tidy | public_name }}</nano-tag>
                          {{ /each }}
                        {{ /each }}
                      {{ /if }}
                    </div>
                  {{ /if }}
                </script>

                <script type="text/template" slot="result-template">
                  <!-- START NO CONTENT -->
                  {{ @if ((!it.results || !it.results.length)) }}
                    <div class="search-empty">
                      <nano-icon name="light/magnifying-glass" class="search-empty-icon"></nano-icon>
                      <h2>No matches found...</h2>
                      <p>Please try a different search query.</p>
                    </div>
                  {{ /if }}
                  <!-- END NO CONTENT -->

                  {{ @if (it.totalHitsWithFilters > 0) }}
                    {{ @each(it.results) => result, resultIndex }}
                      {{ contentType = result.content_type ? result.content_type : result.type }}
                      <li class="sc-nano-global-search-results">
                        <div class="sc-nano-global-search-results result" data-hit-id="{{ result.objectID }}" data-hit-count="{{ resultIndex }}">
                          <strong class="sc-nano-global-search-results result__title" data-icon-set="{{(iconSet = false)}}">
                            <a href="{{ result.url | abs_url(it, result) }}">
                            {{ @if (result._snippetResult) }}
                              {{ result._snippetResult.title.value | safe }}
                            {{ #else }}
                              {{ result.title | safe }}
                            {{ /if }}
                            {{ @if (contentType === 'technical_document' || contentType === 'literature' || contentType === 'white_paper' || contentType === 'protocol') }}
                              <span class="sc-nano-global-search-results result__pdf">PDF</span>
                            {{ /if }}
                            </a>
                          </strong>
                          {{ @if (result.authors) }}
                            {{ @if (typeof result.authors === 'string') }}
                              <a class="sc-nano-global-search-results result__authors" href="{{ result.url | abs_url(it, result) }}">Authors: {{ result.authors | trim_to(50) }}</a>
                            {{ #else }}
                              <a class="sc-nano-global-search-results result__authors" href="{{ result.url | abs_url(it, result) }}">
                                {{ @each(result.authors) => author, index }}
                                  <!-- {{ @if(index == 0)}} -->
                                    Authors: {{ author | trim_to(60) }}
                                  <!-- {{ /if }} -->
                                {{ /each }}
                              </a>
                            {{ /if }}
                          {{ /if }}
                          {{ @if (contentType === 'video' || contentType === 'lc_lightning_talk' ) }}
                            {{ @if (result.name) }}
                              <a class="sc-nano-global-search-results result__authors" href="{{ result.url | abs_url(it, result) }}">Speaker: {{ result.name | trim_to(50) }}</a>
                            {{ /if }}
                            
                            {{ @if (result.image) }}
                              <div class="sc-nano-global-search-results result__image" style="background-image: url('{{ result.image | abs_url(it, result) }}')">
                                <nano-icon class="sc-nano-global-search-results" name="duotone/play-circle"></nano-icon>
                              </div>
                            {{ /if }}
                            <a class="sc-nano-global-search-results result__video-body" href="{{ result.url | abs_url(it, result) }}">
                              <div class="sc-nano-global-search-results result__body">
                                <div class="sc-nano-global-search-results result__description">
                                  {{ @if (result.description) }}
                                    {{ result._snippetResult.description.value | safe }}
                                  {{ /if }}
                                </div>
                              </div>
                            </a>
                            <div class="sc-nano-global-search-results result__meta">
                              {{ @if (result.type || result.content_type) }}
                                <div class="sc-nano-global-search-results result__type">
                                {{ @if (contentType === 'lc_lightning_talk') }}
                                  Presentation
                                {{ #else }}
                                  {{ contentType }}
                                {{ /if }}
                                </div>
                              {{ /if }}
                              
                              {{ @if (result.source) }}
                                <div class="sc-nano-global-search-results result__source">Source: {{ result.source }}</div>
                              {{ /if }}
                            </div>
                            {{ @if (result.tags) }}
                              <div class="sc-nano-global-search-results result__tags">
                                {{ @if (typeof result.tags === 'string') }}
                                  <nano-tag><button data-value="{{ result.tags | lowercase }}" class="sc-nano-global-search-results result__tags-tag">{{ result.tags }}</button></nano-tag>
                                {{ #else }}
                                  {{ @each(result.tags) => tag, index }}
                                    {{ @if(index < 5)}}
                                      {{ @if (tag !== "No video" && tag !== "Resources" && tag !== "Video") }}
                                        <nano-tag><button data-value="{{ tag | lowercase }}" class="sc-nano-global-search-results result__tags-tag">{{ tag | tag_tidy }}</button></nano-tag>
                                      {{ /if }}
                                    {{ /if }}
                                  {{ /each }}
                                {{ /if }}
                              </div>
                            {{ /if }}
                          {{ /if }}
                          {{ @if (result.body) }}
                            <a class="sc-nano-global-search-results result__body" href="{{ result.url | abs_url(it, result) }}">
                            {{ @if (result._snippetResult) }}
                              {{ result._snippetResult.body.value | safe }}
                            {{ /if }}
                            </a>
                          {{ /if }}
                          {{ @if (contentType === 'product' }}
                            <nano-cta size="small">
                              <a href="{{ result.url | abs_url(it, result) }}">View product</a>
                            </div>
                          {{ /if }}
                          {{ @if (contentType === 'event') }}
                            <a class="sc-nano-global-search-results result__promo" href="{{ result.url | abs_url(it, result) }}">
                              <div class="sc-nano-global-search-results result__promo-box">
                                <div class="sc-nano-global-search-results result__promo-bigdate">
                                  {{ result.start_date | date_long({year: undefined, month: 'short', day: undefined}) }}
                                  <span>{{ result.start_date | date_long({year: undefined, month: undefined, day: 'numeric'}) }}</span>
                                </div>
                                <div>
                                  <div class="sc-nano-global-search-results result__promo-date">
                                    <nano-icon class="sc-nano-global-search-results" name="light/calendar-days"></nano-icon>
                                    {{ @if (result.end_date) }}
                                      {{ @if (result.end_date !== result.start_date) }}
                                        {{ result.start_date | date_long({weekday: 'short', day: 'numeric', month: 'short'}) }} - {{ result.end_date | date_long({weekday: 'short', day: 'numeric', year: 'numeric', month: 'short'}) }}
                                      {{ #else }}
                                        {{ result.start_date | date_long({weekday: 'short', day: 'numeric', year: 'numeric', month: 'short'}) }}
                                      {{ /if }}
                                    {{ #else }}
                                      {{ @if (result.start_date) }}
                                        {{ result.start_date | date_long({weekday: 'short', day: 'numeric', year: 'numeric', month: 'short'}) }}
                                      {{ /if }}
                                    {{ /if }}
                                  </div>
                                  <div class="sc-nano-global-search-results result__promo-venue">
                                    <nano-icon class="sc-nano-global-search-results" name="light/map-marker-alt"></nano-icon>
                                    Venue
                                  </div>
                                </div>
                              </div>
                            </a>
                          {{ /if }}
                          {{ @if (contentType !== 'lc_lightning_talk' && contentType !== 'video') }}
                            <div class="sc-nano-global-search-results result__meta">
                              {{ @if (result.type || result.content_type) }}
                                <div class="sc-nano-global-search-results result__type">
                                {{ @if (contentType === 'news_item') }}
                                  News
                                {{ #elif (contentType === 'static_page' || contentType === 'bespoke') }}
                                  Page
                                {{ #elif (contentType === 'case_study') }}
                                  Case study
                                {{ #elif (contentType === 'lc_poster') }}
                                  Poster
                                {{ #elif (contentType === 'nanopore_live') }}
                                  Live stream
                                {{ #elif (contentType === 'data_release') }}
                                  Data release
                                {{ #elif (contentType === 'research_area') }}
                                  Research area
                                {{ #elif (contentType === 'white_paper') }}
                                  White paper
                                {{ #elif (contentType === 'technical_document') }}
                                  Technical document
                                {{ #elif (contentType === 'info_sheet') }}
                                  Info sheet
                                {{ #elif (contentType === 'lc_home' || contentType === 'lc_venue') }}
                                  London Calling
                                {{ #else }}
                                  {{ contentType }}
                                {{ /if }}
                                </div>
                              {{ /if }}
                              {{ @if (contentType !== 'event') }}
                                {{ @if (result.updated) }}
                                  <div class="sc-nano-global-search-results result__date">{{ result.updated | date_long({year: 'numeric', month: 'short', day: 'numeric'}) }}</div>
                                {{ #else }}
                                  {{ @if (result.created) }}
                                    <div class="sc-nano-global-search-results result__date">{{ result.created | date_long({year: 'numeric', month: 'short', day: 'numeric'}) }}</div>
                                  {{ /if }}
                                {{ /if }}
                              {{ /if }}
                              {{ @if (result.source) }}
                                <div class="sc-nano-global-search-results result__source">Source: {{ result.source }}</div>
                              {{ /if }}
                            </div>
                            {{ @if (result.tags) }}
                              <div class="sc-nano-global-search-results result__tags">
                                {{ @if (typeof result.tags === 'string') }}
                                  {{ @if (result.tags !== "Resources" && result.tags !== "Tools" && result.tags !== "Publications" && result.tags !== "Case studies") }}
                                    <nano-tag><button data-value="{{ result.tags | lowercase }}" class="result__tags-tag">{{ result.tags }}</button></nano-tag>
                                  {{ /if }}
                                {{ #else }}
                                  {{ @each(result.tags) => tag, index }}
                                    {{ @if(index < 5)}}
                                      {{ @if (tag !== "Resources" && tag !== "Tools" && tag !== "Publications" && tag !== "Case studies") }}
                                        <nano-tag><button data-value="{{ tag | lowercase }}" class="result__tags-tag">{{ tag | tag_tidy }}</button></nano-tag>
                                      {{ /if }}
                                    {{ /if }}
                                  {{ /each }}
                                {{ /if }}
                              </div>
                            {{ /if }}
                          {{ /if }}
                        </div>
                      </li>
                    {{ /each }}
                  {{ /if }}
                </script>

                <div slot="start-output"></div>
                <ul slot="result-output" class="sc-nano-global-search-results"></ul>
              </nano-algolia-results>

              {{ @if(Object.keys(it.origFilters).length) }}
                <div class="sc-nano-global-search-results main-search__filters filters close-filters" id="main-search-filters">
                  <div class="sc-nano-global-search-results filters-wrap">
                    {{ @if(it.totalHits) }}
                      <div class="sc-nano-global-search-results filters-header">
                        <strong class="sc-nano-global-search-results filters-title">Filters</strong>
                        <button class="sc-nano-global-search-results filters-reset">Reset</button>
                        <nano-icon-button class="sc-nano-global-search-results filters__close-filters close-filters icon-button" icon-name="light/xmark" aria-controls="main-search-filters"></nano-icon-button>
                      </div>
                    {{ /if }}

                    <div class="sc-nano-global-search-results filters-list">
                      <nano-checkbox value="old-posts" class="old-posts" name="old-posts" checked>
                        <span>Include posts older than 2 years</strong>)</span>
                      </nano-checkbox>
                      {{ @if(it.origFilters['type']) }}
                        <nano-details class="sc-nano-global-search-results" open={true} label="Type" size="small">
                          <nano-algolia-filter store-id="searchf1" store-method="url-hash-push" filter-name="type">
                            <script type="text/template" slot="filter-template">
                              <ul class="sc-nano-global-search-results" data-num="{{(x = 0)}}">
                              {{ @foreach(it.dyn) => filter, filterVal }}
                                <li class="sc-nano-global-search-results" data-num="{{(x++)}}">
                                  <input class="sc-nano-global-search-results filter-cb" type="checkbox" value="{{ filter }}" id="type-{{ filter }}-{{x}}" />
                                  <label class="sc-nano-global-search-results filter-label" for="type-{{ filter }}-{{x}}">
                                    <span>{{ filter | public_name }} (<strong>{{ filterVal }}</strong>)</span>
                                  </label>
                                </li>
                              {{ /foreach }}
                              </ul>
                            </script>
                            <div slot="output"></div>
                          </nano-algolia-filter>
                        </nano-details>
                      {{ /if }}

                      {{ @if(it.origFilters['channel']) }}
                        <nano-details open={true} label="Channels"  size="small">
                          <nano-algolia-filter store-id="searchf2" store-method="url-hash-push" filter-name="channel">
                            <script type="text/template" slot="filter-template">
                              <ul class="sc-nano-global-search-results" data-num="{{(x = 0)}}">
                              {{ @foreach(it.dyn) => filter, filterVal }}
                                <li class="sc-nano-global-search-results" data-num="{{(x++)}}">
                                  <input class="filter-cb sc-nano-global-search-results" type="checkbox" value="{{ filter }}" id="channel-{{ filter }}-{{x}}" />
                                  <label class="filter-label sc-nano-global-search-results" for="channel-{{ filter }}-{{x}}">
                                    <span>{{ filter | public_name }} (<strong>{{ filterVal }}</strong>)</span>
                                  </label>
                                </li>
                              {{ /foreach }}
                              </ul>
                            </script>
                            <div slot="output"></div>
                          </nano-algolia-filter>
                        </nano-details>
                      {{ /if }}

                      {{ @if(it.origFilters['authors']) }}
                        <nano-details open={true} label="Authors" size="small">
                          <nano-algolia-filter store-id="searchf3" store-method="url-hash-push" filter-name="authors">
                            <script type="text/template" slot="filter-template">
                              <ul class="sc-nano-global-search-results" data-num="{{(x = 0)}}">
                              {{ @foreach(it.dyn) => filter, filterVal }}
                                <li class="sc-nano-global-search-results" data-num="{{(x++)}}">
                                  <input class="filter-cb sc-nano-global-search-results" type="checkbox" value="{{ filter }}" id="authors-{{ filter }}-{{x}}" />
                                  <label class="filter-label sc-nano-global-search-results" for="authors-{{ filter }}-{{x}}">
                                    <span>{{ filter | public_name }} (<strong>{{ filterVal }}</strong>)</span>
                                  </label>
                                </li>
                              {{ /foreach }}
                              </ul>
                            </script>
                            <div slot="output"></div>
                          </nano-algolia-filter>
                        </nano-details>
                      {{ /if }}

                      {{ @if(it.origFilters['categories_without_path']) }}
                        <nano-details open={true} label="Categories" size="small">
                          <nano-algolia-filter store-id="searchf4" store-method="url-hash-push" filter-name="categories_without_path">
                            <script type="text/template" slot="filter-template">
                              <ul class="sc-nano-global-search-results" data-num="{{(x = 0)}}">
                              {{ @foreach(it.dyn) => filter, filterVal }}
                                {{ @if(!filter.match(/publication/)) }}
                                  <li class="sc-nano-global-search-results" data-num="{{(x++)}}">
                                    <input class="sc-nano-global-search-results filter-cb" type="checkbox" value="{{ filter }}" id="cwp-{{ filter }}-{{x}}" />
                                    <label class="sc-nano-global-search-results filter-label" for="cwp-{{ filter }}-{{x}}">
                                      <span>{{ filter | public_name }} (<strong>{{ filterVal }}</strong>)</span>
                                    </label>
                                  </li>
                                {{ /if }}
                              {{ /foreach }}
                              </ul>
                            </script>
                            <div slot="output"></div>
                          </nano-algolia-filter>
                        </nano-details>
                      {{ /if }}

                      {{ @if(it.origFilters['tags']) }}
                        <nano-details open={true} label="Tags" size="small">
                          <nano-algolia-filter store-id="searchf5" store-method="url-hash-push" filter-name="tags">
                            <script type="text/template" slot="filter-template">
                              <ul class="sc-nano-global-search-results" data-num="{{(x = 0)}}">
                              {{ @foreach(it.dyn) => filter, filterVal }}
                                {{ @if(!filter.match('>')) }}
                                  <li class="sc-nano-global-search-results" data-num="{{(x++)}}">
                                    <input class="filter-cb sc-nano-global-search-results" type="checkbox" value="{{ filter | lowercase }}" id="tags-{{ filter }}-{{x}}" />
                                    <label class="filter-label sc-nano-global-search-results" for="tags-{{ filter }}-{{x}}">
                                      <span>{{ filter | public_name }} (<strong>{{ filterVal }}</strong>)</span>
                                    </label>
                                  </li>
                                {{ /if }}
                              {{ /foreach }}
                              </ul>
                            </script>
                            <div slot="output"></div>
                          </nano-algolia-filter>
                        </nano-details>
                      {{ /if }}
                    </div>
                  </div>
                </div>
              {{ /if }}
            </div>`), h("div", { key: '531d1aaf58fe5df465d93998f9448207d23de76a', slot: "output" }), h("slot", { key: '66231f02547592a1b03a87b3f3e237c527befc38' }))));
    }
    static get watchers() { return {
        "algoliaEle": ["handleAlgoliaCredsChange", "handleAlgoliaIndexChange", "handleAlgoliaEleChange"],
        "apiKey": ["handleAlgoliaCredsChange"],
        "appId": ["handleAlgoliaCredsChange"],
        "index": ["handleAlgoliaIndexChange"],
        "algoliaResults": ["handleAlgoliaEleChange"]
    }; }
    static get style() { return globalSearchResultsCss; }
}, [257, "nano-global-search-results", {
        "algoliaResults": [32],
        "algoliaEle": [32],
        "currentWidth": [32],
        "apiKey": [32],
        "appId": [32],
        "index": [32],
        "closeSearch": [64]
    }, [[0, "nanoChange", "handleReorder"], [0, "nanoResultsShown", "attachListeners"], [0, "nanoNewResults", "attachResultListeners"], [4, "nanoSearchResult", "onDocNanoSearchResult"], [4, "nanoSearchReset", "onDocNanoSearchReset"]], {
        "algoliaEle": ["handleAlgoliaCredsChange", "handleAlgoliaIndexChange", "handleAlgoliaEleChange"],
        "apiKey": ["handleAlgoliaCredsChange"],
        "appId": ["handleAlgoliaCredsChange"],
        "index": ["handleAlgoliaIndexChange"],
        "algoliaResults": ["handleAlgoliaEleChange"]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["nano-global-search-results", "nano-algolia", "nano-spinner"];
    components.forEach(tagName => { switch (tagName) {
        case "nano-global-search-results":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, GlobalSearchResults);
            }
            break;
        case "nano-algolia":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "nano-spinner":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { GlobalSearchResults as G, defineCustomElement as d, searchInsight as s };
