import { Component, Element, Event, h, Listen, Prop, State } from "@stencil/core";
import { Identifier } from "authly";
import { Key } from "@payfunc/model";
import * as translation from "./translation";
export class Onboard {
  async componentWillLoad() {
    this.merchant = await Key.unpack(this.apiKey, "public", "customer", "private");
    this.t = translation.create(this.element);
    if (!this.number)
      this.number = Identifier.generate(16);
  }
  onCreate(event) {
    this.create.emit(event.detail);
  }
  render() {
    const t = this.t;
    return !this.merchant ? (h("p", null, this.t("No valid API key."))) : ([
      h("smoothly-notifier", null,
        h("ig-onboard-form", { cosmetic: this.cosmetic, merchant: this.merchant, customer: this.customer, "api-key": this.apiKey, number: this.number, "response-timer": this.responseTimer }),
        h("merchant-terms", { merchant: this.merchant, buttonName: t("Submit") }),
        h("card-logotypes", null)),
    ]);
  }
  static get is() { return "payfunc-onboard"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "apiKey": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "api-key",
      "reflect": false
    },
    "customer": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Customer | undefined",
        "resolved": "Customer | undefined",
        "references": {
          "Customer": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "number": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string | undefined",
        "resolved": "string | undefined",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "number",
      "reflect": false
    },
    "cosmetic": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "| string\n\t\t| {\n\t\t\t\theader?: { background?: string; color?: string }\n\t\t\t\ttext?: { background?: string; color?: string }\n\t\t\t\tlineColor?: string\n\t\t\t\tsubmit?: { background?: string; color?: string }\n\t\t\t\tfontFamily?: string\n\t\t\t\tdangerColor?: string\n\t\t  }",
        "resolved": "string | undefined | { header?: { background?: string | undefined; color?: string | undefined; } | undefined; text?: { background?: string | undefined; color?: string | undefined; } | undefined; lineColor?: string | undefined; submit?: { background?: string | undefined; color?: string | undefined; } | undefined; fontFamily?: string | undefined; dangerColor?: string | undefined; }",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "cosmetic",
      "reflect": false
    },
    "responseTimer": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number | undefined",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "response-timer",
      "reflect": false
    }
  }; }
  static get states() { return {
    "t": {}
  }; }
  static get events() { return [{
      "method": "create",
      "name": "create",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "Customer",
        "resolved": "Customer",
        "references": {
          "Customer": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      }
    }]; }
  static get elementRef() { return "element"; }
  static get listeners() { return [{
      "name": "createCustomer",
      "method": "onCreate",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
