// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { PageCallbackRouter, PageHandlerFactory, PageHandlerRemote } from '//resources/mojo/components/omnibox/browser/searchbox.mojom-webui.js';
export function createAutocompleteMatch(modifiers = {}) {
    const base = {
        isHidden: false,
        a11yLabel: '',
        actions: [],
        allowedToBeDefaultMatch: false,
        isSearchType: false,
        isEnterpriseSearchAggregatorPeopleType: false,
        swapContentsAndDescription: false,
        supportsDeletion: false,
        suggestionGroupId: -1,
        contents: '',
        contentsClass: [{ offset: 0, style: 0 }],
        description: '',
        descriptionClass: [{ offset: 0, style: 0 }],
        destinationUrl: '',
        inlineAutocompletion: '',
        fillIntoEdit: '',
        iconPath: '',
        iconUrl: '',
        imageDominantColor: '',
        imageUrl: '',
        isContextualSuggestion: false,
        isNoncannedAimSuggestion: false,
        removeButtonA11yLabel: '',
        type: '',
        isRichSuggestion: false,
        isWeatherAnswerSuggestion: null,
        answer: null,
        tailSuggestCommonPrefix: null,
        hasInstantKeyword: false,
        keywordChipHint: '',
        keywordChipA11y: '',
    };
    return Object.assign(base, modifiers);
}
export function createAutocompleteResultForTesting(modifiers = {}) {
    const base = {
        queryId: 0,
        input: '',
        matches: [],
        suggestionGroupsMap: {},
        smartComposeInlineHint: null,
        sequenceId: 0,
    };
    return Object.assign(base, modifiers);
}
export function createSearchMatchForTesting(modifiers = {}) {
    const base = createAutocompleteMatch({
        isSearchType: true,
        contents: 'hello world',
        contentsClass: [{ offset: 0, style: 0 }],
        description: 'Google search',
        descriptionClass: [{ offset: 0, style: 4 }],
        destinationUrl: 'https://www.google.com/search?q=hello+world',
        fillIntoEdit: 'hello world',
        type: 'search-what-you-typed',
    });
    return Object.assign(base, modifiers);
}
export class SearchboxBrowserProxy {
    static getInstance() {
        return instance || (instance = new SearchboxBrowserProxy());
    }
    static setInstance(newInstance) {
        instance = newInstance;
    }
    handler;
    callbackRouter;
    constructor() {
        const handler = new PageHandlerRemote();
        this.handler = handler;
        this.callbackRouter = new PageCallbackRouter();
        PageHandlerFactory.getRemote().createPageHandler(this.callbackRouter.$.bindNewPipeAndPassRemote(), handler.$.bindNewPipeAndPassReceiver());
    }
}
let instance = null;
