import*as i18n from"../i18n/i18n.js";import*as Platform from"../platform/platform.js";import*as UI from"../ui/ui.js";const UIStrings={refresh:"Refresh",filter:"Filter",clearAll:"Clear All",deleteSelected:"Delete Selected"},str_=i18n.i18n.registerUIStrings("resources/StorageItemsView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class StorageItemsView extends UI.Widget.VBox{constructor(e,t){super(!1),this._filterRegex=null,this._refreshButton=this._addButton(i18nString(UIStrings.refresh),"largeicon-refresh",this.refreshItems),this._mainToolbar=new UI.Toolbar.Toolbar("top-resources-toolbar",this.element),this._filterItem=new UI.Toolbar.ToolbarInput(i18nString(UIStrings.filter),"",.4),this._filterItem.addEventListener(UI.Toolbar.ToolbarInput.Event.TextChanged,this._filterChanged,this);const l=new UI.Toolbar.ToolbarSeparator;this._deleteAllButton=this._addButton(i18nString(UIStrings.clearAll),"largeicon-clear",this.deleteAllItems),this._deleteSelectedButton=this._addButton(i18nString(UIStrings.deleteSelected),"largeicon-delete",this.deleteSelectedItem),this._deleteAllButton.element.id="storage-items-delete-all";const r=[this._refreshButton,this._filterItem,l,this._deleteAllButton,this._deleteSelectedButton];for(const s of r)this._mainToolbar.appendToolbarItem(s)}setDeleteAllTitle(e){this._deleteAllButton.setTitle(e)}setDeleteAllGlyph(e){this._deleteAllButton.setGlyph(e)}appendToolbarItem(e){this._mainToolbar.appendToolbarItem(e)}_addButton(e,t,l){const r=new UI.Toolbar.ToolbarButton(e,t);return r.addEventListener(UI.Toolbar.ToolbarButton.Events.Click,l,this),r}_filterChanged(e){const t=e.data;this._filterRegex=t?new RegExp(Platform.StringUtilities.escapeForRegExp(t),"i"):null,this.refreshItems()}filter(e,t){if(this._filterRegex){const l=this._filterRegex;return e.filter((e=>l.test(t(e))))}return e}hasFilter(){return Boolean(this._filterRegex)}wasShown(){this.refreshItems()}setCanDeleteAll(e){this._deleteAllButton.setEnabled(e)}setCanDeleteSelected(e){this._deleteSelectedButton.setEnabled(e)}setCanRefresh(e){this._refreshButton.setEnabled(e)}setCanFilter(e){this._filterItem.setEnabled(e)}deleteAllItems(){}deleteSelectedItem(){}refreshItems(){}}