import { isDemo } from "@saasquatch/component-boilerplate";
import { withHooks } from "@saasquatch/stencil-hooks";
import { Component, h, Prop, State } from "@stencil/core";
import deepmerge from "deepmerge";
import { NameFieldsView } from "./sqm-name-fields-view";
import { useNameFields } from "./useNameFields";
/**
 * @uiName Form Name Fields
 * @validParents ["sqm-portal-register","sqm-portal-registration-form", "sqm-portal-google-registration-form"]
 * @exampleGroup Microsite Components
 * @example Form Name Fields - <sqm-name-fields first-name-label="First Name" last-name-label="Last Name"></sqm-name-fields>
 */
export class NameFields {
  constructor() {
    this.ignored = true;
    /**
     * @uiName First name label
     */
    this.firstNameLabel = "First Name";
    /**
     * @uiName Last name label
     */
    this.lastNameLabel = "Last Name";
    /**
     * @uiName Optional
     * @uiWidget
     */
    this.optional = false;
    withHooks(this);
  }
  disconnectedCallback() { }
  render() {
    const { states } = isDemo() ? useNameFieldsDemo(this) : useNameFields(this);
    return h(NameFieldsView, { states: states });
  }
  static get is() { return "sqm-name-fields"; }
  static get properties() { return {
    "firstNameLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "First name label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "first-name-label",
      "reflect": false,
      "defaultValue": "\"First Name\""
    },
    "lastNameLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Last name label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "last-name-label",
      "reflect": false,
      "defaultValue": "\"Last Name\""
    },
    "optional": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Optional",
            "name": "uiName"
          }, {
            "text": undefined,
            "name": "uiWidget"
          }],
        "text": ""
      },
      "attribute": "optional",
      "reflect": false,
      "defaultValue": "false"
    },
    "demoData": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DemoData<NameFieldsViewProps>",
        "resolved": "{ states?: { optional: boolean; registrationFormState?: RegistrationFormState; content: { firstNameLabel: string; lastNameLabel: string; }; }; }",
        "references": {
          "DemoData": {
            "location": "import",
            "path": "../../global/demo"
          },
          "NameFieldsViewProps": {
            "location": "import",
            "path": "./sqm-name-fields-view"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": undefined,
            "name": "undocumented"
          }, {
            "text": "object",
            "name": "uiType"
          }],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "ignored": {}
  }; }
}
function useNameFieldsDemo(props) {
  return deepmerge({
    states: {
      optional: props.optional,
      validationErrors: [],
      content: {
        firstNameLabel: props.firstNameLabel,
        lastNameLabel: props.lastNameLabel,
      },
    },
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
}
