import { Component, Event, h, Listen, Prop, State, Watch } from "@stencil/core";
export class PayfuncAccounts {
  constructor() {
    this.selected = {};
  }
  componentWillLoad() {
    this.accountsChanged();
  }
  accountsChanged() {
    if (!this.accountsFiltered)
      this.accountsFiltered = this.accounts;
  }
  handleFilterChanged(event) {
    this.accountsFiltered = event.detail;
    event.stopPropagation();
  }
  handleSelectedChanged(event) {
    this.selected = event.detail;
  }
  onCreate(e) {
    this.updateAccounts.emit(e.detail);
  }
  render() {
    return [
      h("payfunc-filter", { filter: this.filter, value: this.accounts }),
      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 is() { return "payfunc-accounts"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "accounts": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Account[]",
        "resolved": "Account[] | undefined",
        "references": {
          "Account": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "orders": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "{ [id: string]: Order[] | undefined }",
        "resolved": "undefined | { [id: string]: Order[] | undefined; }",
        "references": {
          "Order": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "filter": {
      "type": "any",
      "mutable": true,
      "complexType": {
        "original": "Criteria",
        "resolved": "Helper[] | Rule | number | string | undefined | { [property: string]: string | number | Rule | any | Helper[]; }",
        "references": {
          "Criteria": {
            "location": "import",
            "path": "selectively"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "filter",
      "reflect": false
    },
    "whitelist": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean | undefined",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "whitelist",
      "reflect": false
    }
  }; }
  static get states() { return {
    "accountsFiltered": {},
    "selected": {}
  }; }
  static get events() { return [{
      "method": "updateAccounts",
      "name": "updateAccounts",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
  static get watchers() { return [{
      "propName": "accounts",
      "methodName": "accountsChanged"
    }]; }
  static get listeners() { return [{
      "name": "filterChanged",
      "method": "handleFilterChanged",
      "target": undefined,
      "capture": false,
      "passive": false
    }, {
      "name": "selectedChanged",
      "method": "handleSelectedChanged",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
