import { r as registerInstance, j as createEvent, h } from './index-07845439.js';
import { d as dist } from './index-82c01ab3.js';
import { A as Account } from './index-aeffd5c5.js';
import './_commonjsHelpers-9bc404fc.js';

const styleCss = ".sc-ig-accounts-h{display:block;width:100%;max-width:90em;margin:auto}ig-account-create-popup.sc-ig-accounts{bottom:3.5em;margin-right:2.5em}";

const IntergiroAccounts = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.updateAccounts = createEvent(this, "updateAccounts", 7);
    this.selected = {};
  }
  componentWillLoad() {
    if (!this.accountsFiltered)
      this.filterAccounts();
  }
  handleFilterChanged(event) {
    this.filter = event.detail;
    event.stopPropagation();
  }
  filterAccounts() {
    const result = this.accounts && (this.filter ? dist.filter(this.filter, this.accounts) : [...this.accounts]);
    this.accountsFiltered = result;
  }
  handleSelectedChanged(event) {
    this.selected = event.detail;
  }
  onCreate(e) {
    this.updateAccounts.emit(e.detail);
  }
  render() {
    return [
      h("ig-filter", { template: Account.template, filter: this.filter }),
      h("ig-accounts-actions", { whitelist: this.whitelist, selected: this.selected }),
      h("ig-accounts-table", { accounts: this.accountsFiltered, orders: this.orders, selected: this.selected, whitelist: this.whitelist }),
      h("ig-account-create-popup", { hidden: true, onCreate: (e) => this.onCreate(e) }),
      h("ig-accounts-footer", { accounts: this.accountsFiltered }),
    ];
  }
  static get watchers() { return {
    "accounts": ["filterAccounts"],
    "filter": ["filterAccounts"]
  }; }
};
IntergiroAccounts.style = styleCss;

export { IntergiroAccounts as ig_accounts };
