import { r as registerInstance, j as createEvent, h } from './index-07845439.js';
import { d as dist } from './index-ea5ab071.js';
import { A as Account } from './index-0a60c67f.js';
import './_commonjsHelpers-9bc404fc.js';
import './index-614b6d2f.js';

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

const PayfuncAccounts = 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("payfunc-filter", { template: Account.template, filter: this.filter }),
      h("payfunc-accounts-actions", { whitelist: this.whitelist, selected: this.selected }),
      h("payfunc-accounts-table", { accounts: this.accountsFiltered, orders: this.orders, selected: this.selected, whitelist: this.whitelist }),
      h("payfunc-account-create-popup", { hidden: true, onCreate: (e) => this.onCreate(e) }),
      h("payfunc-accounts-footer", { accounts: this.accountsFiltered }),
    ];
  }
  static get watchers() { return {
    "accounts": ["filterAccounts"],
    "filter": ["filterAccounts"]
  }; }
};
PayfuncAccounts.style = styleCss;

export { PayfuncAccounts as payfunc_accounts };
