import { Component, h, Prop, State } from "@stencil/core";
import * as selectively from "selectively";
import { ClientIdentifier } from "smoothly";
import { sort } from "@payfunc/model";
export class PortalDeferView {
  constructor() {
    this.filter = {
      client: selectively.is(ClientIdentifier.value),
      status: selectively.some(selectively.or("created", "ordered", "denied", "pending")),
    };
    this.deferFilter = {
      client: selectively.is(ClientIdentifier.value),
      status: selectively.some(selectively.or("deferred")),
    };
  }
  componentWillLoad() {
    const result = this.orders && selectively.filter(selectively.and(selectively.parse("deferred")).generalize(), this.orders);
    this.filteredOrders = result && sort(result, "created");
  }
  render() {
    return [
      h("portal-create-order", { orders: this.orders, emailOption: this.emailOption, currency: this.currency }),
      h("portal-display-defer-list", { orders: this.orders, filter: this.deferFilter }),
      h("ig-orders", { orders: this.filteredOrders }),
    ];
  }
  static get is() { return "portal-defer-view"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "emailOption": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "email-option",
      "reflect": false
    },
    "currency": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "Currency",
        "resolved": "Currency | undefined",
        "references": {
          "Currency": {
            "location": "import",
            "path": "isoly"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "currency",
      "reflect": false
    },
    "orders": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Order[]",
        "resolved": "Order[] | undefined",
        "references": {
          "Order": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "filteredOrders": {},
    "filter": {},
    "deferFilter": {}
  }; }
}
