import { NestedField } from '@dvn/core/doldurma/src/fields/nested/nested';
import { Component, h, Host, Prop } from '@stencil/core';
const fieldTagMap = {
  number: 'dvn-field-display-number',
  'multiple-choice': 'dvn-field-display-multiple-choice',
  'single-choice': 'dvn-field-display-single-choice',
  text: 'dvn-field-display-text',
  date: 'dvn-field-display-date',
  attachment: 'dvn-field-display-attachment',
  'raw-data': 'dvn-field-display-raw-data',
  range: 'dvn-field-display-range',
  reference: 'dvn-field-display-reference',
  'relation-reference': 'dvn-field-display-relation-reference',
};
export class DvnFieldDisplay {
  constructor() {
    this.showTitle = true;
  }
  render() {
    const { field, infoTitle, meta, showTitle, value } = this;
    let fieldToPass = field;
    let Tag = fieldTagMap[field.type];
    if (field.type === NestedField.type) {
      Tag = fieldTagMap[field.nestedField.type];
      fieldToPass = field.nestedField;
    }
    return (h(Host, null,
      showTitle && h("div", { class: "title" }, (infoTitle || '').toUpperCase()),
      Tag
        ? h(Tag, { field: fieldToPass, value: value, meta: meta, fixHeight: false })
        : h("span", null, value)));
  }
  static get is() { return "dvn-field-display"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["dvn-field-display.css"]
  }; }
  static get styleUrls() { return {
    "$": ["dvn-field-display.css"]
  }; }
  static get properties() { return {
    "infoTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "info-title",
      "reflect": false
    },
    "field": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "BaseField",
        "resolved": "BaseField",
        "references": {
          "BaseField": {
            "location": "import",
            "path": "@dvn/core/doldurma/src/BaseField"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "value": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "value",
      "reflect": false
    },
    "meta": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "meta",
      "reflect": false
    },
    "showTitle": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "show-title",
      "reflect": false,
      "defaultValue": "true"
    }
  }; }
}
