import*as Search from"../search/search.js";import*as UI from"../ui/ui.js";import{SourcesSearchScope}from"./SourcesSearchScope.js";let searchSourcesViewInstance,actionDelegateInstance;export class SearchSourcesView extends Search.SearchView.SearchView{constructor(){super("sources")}static instance(){return searchSourcesViewInstance||(searchSourcesViewInstance=new SearchSourcesView),searchSourcesViewInstance}static async openSearch(e,a){const c=UI.ViewManager.ViewManager.instance().view("sources.search-sources-tab");(await UI.ViewManager.ViewManager.instance().resolveLocation("drawer-view")).appendView(c),await UI.ViewManager.ViewManager.instance().revealView(c);const r=await c.widget();return r.toggle(e,Boolean(a)),r}createScope(){return new SourcesSearchScope}}export class ActionDelegate{static instance(e={forceNew:null}){const{forceNew:a}=e;return actionDelegateInstance&&!a||(actionDelegateInstance=new ActionDelegate),actionDelegateInstance}handleAction(e,a){return this._showSearch(),!0}_showSearch(){const e=UI.InspectorView.InspectorView.instance().element.window().getSelection();let a="";return e&&e.rangeCount&&(a=e.toString().replace(/\r?\n.*/,"")),SearchSourcesView.openSearch(a)}}