'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-e0385008.js');

const appImportCss = "app-import ion-card,app-import ion-card-content{overflow:visible !important}";

const AppImport = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.importId = undefined;
    this.results = [];
    this.query = undefined;
  }
  onSuccess(event) {
    var _a, _b, _c, _d;
    console.log(event);
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) !== "importer")
      return;
    this.results = ((_d = (_c = (_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.importer) === null || _d === void 0 ? void 0 : _d.results) || [];
  }
  onChange(event) {
    var _a, _b;
    console.log(event);
    const targetEl = event === null || event === void 0 ? void 0 : event.target;
    if ((targetEl === null || targetEl === void 0 ? void 0 : targetEl.tagName) === "ION-SEARCHBAR") {
      this.query = ((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) > 0 ? event.target.value : null;
    }
  }
  render() {
    return [
      index.h("ion-content", { class: "ion-padding" }, index.h("floodteam-title-bar", null, index.h("ion-router-link", { href: "/imports" }, "Import"), index.h("ion-buttons", { slot: "end" }, index.h("ion-button", { disabled: true, fill: "outline" }, "Import"), index.h("ion-button", { fill: "solid", color: "primary", onClick: () => { var _a, _b; return (_b = (_a = this.formEl) === null || _a === void 0 ? void 0 : _a.submit) === null || _b === void 0 ? void 0 : _b.call(_a); } }, "Search"))), index.h("fireenjin-form", { ref: (el) => (this.formEl = el), hideControls: true, endpoint: "importer", beforeSubmit: (data) => ({
          ...data,
          limit: parseInt(data === null || data === void 0 ? void 0 : data.limit) > 0 ? parseInt(data.limit) : null,
        }) }, index.h("ion-card", null, index.h("ion-card-header", null, index.h("ion-grid", null, index.h("ion-row", null, index.h("ion-col", null, index.h("ion-item", null, index.h("ion-label", { position: "stacked" }, "Import"), index.h("ion-select", { name: "type" }, index.h("ion-select-option", { value: "ftms-users" }, "FTMS Users"), index.h("ion-select-option", { value: "ftms-jobs" }, "FTMS Jobs")))), index.h("ion-col", null, index.h("fireenjin-input", { label: "Limit", labelPosition: "stacked", name: "limit", type: "number", step: "1", min: "0" }))))), index.h("ion-card-content", null, index.h("div", { class: "table-responsive" }, index.h("table", { class: "table", style: { background: "var(--background-color)" } }, index.h("tbody", null, (this.results || []).map((result, index$1) => [
        index$1 === 0 && (index.h("tr", { style: {
            color: "var(--ion-text-color)",
            borderBottom: "1px solid var(--ion-color-light-shade)",
          } }, Object.keys(result).map((columnName) => (index.h("td", null, columnName))))),
        index.h("tr", null, Object.values(result).map((value) => {
          return (index.h("td", null, ["string", "number"].includes(typeof value) ? (value) : (value === null || value === void 0 ? void 0 : value._path) ? (value._path.segments.join("/")) : (index.h("code", null, JSON.stringify(value, null, 4)))));
        })),
      ])))))))),
      index.h("floodteam-navigation-footer", null),
    ];
  }
};
AppImport.style = appImportCss;

exports.app_import = AppImport;
