'use strict';

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

const index = require('./index-e0385008.js');
const store = require('./store-8d1de66f.js');
const getUserRoleOptions = require('./getUserRoleOptions-5ac36c7c.js');
require('./index-37fc02d8.js');
require('./getHandlebarsHelpers-1b368c8a.js');
require('./_commonjsHelpers-a5111d61.js');
require('./index-ba857994.js');
require('./localforage-af1b8c0e.js');

const FormUser = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinFetch = index.createEvent(this, "fireenjinFetch", 7);
    this.userId = undefined;
    this.user = undefined;
    this.invoiceType = undefined;
    this.showPhoto = false;
    this.hideControls = false;
  }
  onSuccess(event) {
    var _a, _b, _c;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) !== "findUser")
      return;
    this.user = (_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.user;
  }
  componentDidLoad() {
    if (!(index.Build === null || index.Build === void 0 ? void 0 : index.Build.isBrowser) || !this.userId)
      return;
    this.fireenjinFetch.emit({
      endpoint: "findUser",
      params: {
        id: this.userId,
        withFriends: true,
        withRoles: false,
      },
    });
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
    return (index.h(index.Host, null, index.h("fireenjin-form", { hideControls: this.hideControls, endpoint: this.userId === "new" ? "addUser" : "editUser", documentId: this.userId === "new" ? null : this.userId, resetButton: null }, index.h("ion-list", null, this.showPhoto && (index.h("fireenjin-input-photo", { name: "photo", documentId: this.userId, value: ((_a = this.user) === null || _a === void 0 ? void 0 : _a.photo) || "/assets/svg/ft-person-suit.svg" })), index.h("ion-grid", null, ((_b = store.state === null || store.state === void 0 ? void 0 : store.state.claims) === null || _b === void 0 ? void 0 : _b.admin) && (index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-select", { label: "Team Role", name: "role", options: getUserRoleOptions.getUserRoleOptions(), value: (_c = this.user) === null || _c === void 0 ? void 0 : _c.role })))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-input", { name: "firstName", label: "First Name", labelPosition: "stacked", value: (_d = this.user) === null || _d === void 0 ? void 0 : _d.firstName })), index.h("ion-col", null, index.h("fireenjin-input", { name: "lastName", labelPosition: "stacked", label: "Last Name", value: (_e = this.user) === null || _e === void 0 ? void 0 : _e.lastName }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-input", { name: "email", labelPosition: "stacked", label: "Email Address", value: (_f = this.user) === null || _f === void 0 ? void 0 : _f.email }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-input", { name: "phone", label: "Phone Number", labelPosition: "stacked", value: (_g = this.user) === null || _g === void 0 ? void 0 : _g.phone }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-input", { name: "slackHandle", label: "Slack Handle", labelPosition: "stacked", value: (_h = this.user) === null || _h === void 0 ? void 0 : _h.slackHandle }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-input-address", { name: "address", label: "Address", labelPosition: "stacked", value: (_j = this.user) === null || _j === void 0 ? void 0 : _j.address, googleMapsKey: (_l = (_k = store.state === null || store.state === void 0 ? void 0 : store.state.config) === null || _k === void 0 ? void 0 : _k.firebase) === null || _l === void 0 ? void 0 : _l.apiKey }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-input-address", { name: "billingAddress", label: "Billing Address", labelPosition: "stacked", value: (_m = this.user) === null || _m === void 0 ? void 0 : _m.billingAddress, googleMapsKey: (_p = (_o = store.state === null || store.state === void 0 ? void 0 : store.state.config) === null || _o === void 0 ? void 0 : _o.firebase) === null || _p === void 0 ? void 0 : _p.apiKey }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-select", { label: "Location", name: "locationId", options: ((store.state === null || store.state === void 0 ? void 0 : store.state.locations) || []).map((location) => ({
        label: (location === null || location === void 0 ? void 0 : location.name) || "No Location Name",
        value: location === null || location === void 0 ? void 0 : location.id,
      })), value: (_r = (_q = this.user) === null || _q === void 0 ? void 0 : _q.location) === null || _r === void 0 ? void 0 : _r.id }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-select", { name: "companyId", label: "Company", labelPosition: "stacked", value: (_t = (_s = this.user) === null || _s === void 0 ? void 0 : _s.company) === null || _t === void 0 ? void 0 : _t.id, endpoint: "listCompanies", limit: 100, resultsKey: "companies" }))), index.h("ion-row", null, index.h("ion-col", null, index.h("fireenjin-select-tags", { name: "tags", labelPosition: "stacked", label: "Tags", value: ((_u = this.user) === null || _u === void 0 ? void 0 : _u.tags) || [], allowAdding: true, options: [
        {
          label: "Important",
          value: "important",
        },
        {
          label: "Referral",
          value: "referral",
        },
        {
          label: "Plumber",
          value: "plumber",
        },
        {
          label: "Staff",
          value: "staff",
        },
        {
          label: "Agent",
          value: "agent",
        },
        {
          label: "Property Manager",
          value: "property manager",
        },
        {
          label: "PEU",
          value: "peu",
        },
      ] }))))))));
  }
};

exports.floodteam_form_user = FormUser;
