import { r as registerInstance, h } from './index-000d2977.js';
import { t as toastController } from './overlays-2be0c50d.js';
import { s as state } from './store-f6a9eb30.js';
import './ionic-global-8913b6b6.js';
import './helpers-7e937ffa.js';
import './getHandlebarsHelpers-91de4454.js';
import './_commonjsHelpers-4ed75ef8.js';
import './logic-88140d62.js';
import './index-d4e79b88.js';
import './localforage-9daa31d6.js';

const appLocationCss = "";

const AppLocation = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  async onSuccess(event) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
    if (event.detail.endpoint === "addLocation") {
      const routerEl = document.querySelector("ion-router");
      if (!routerEl || !((_c = (_b = (_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.addLocation) === null || _c === void 0 ? void 0 : _c.id))
        return;
      routerEl.push(`/locations/${event.detail.data.addLocation.id}`);
    }
    else if (event.detail.endpoint === "editLocation") {
      this.presentToast();
    }
    else if (((_d = event === null || event === void 0 ? void 0 : event.detail) === null || _d === void 0 ? void 0 : _d.endpoint) === "findLocation") {
      this.location = ((_f = (_e = event === null || event === void 0 ? void 0 : event.detail) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.location) || null;
    }
    else if (((_g = event === null || event === void 0 ? void 0 : event.detail) === null || _g === void 0 ? void 0 : _g.endpoint) === "upload") {
      this.location[(_h = event === null || event === void 0 ? void 0 : event.detail) === null || _h === void 0 ? void 0 : _h.name] =
        ((_l = (_k = (_j = event === null || event === void 0 ? void 0 : event.detail) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.upload) === null || _l === void 0 ? void 0 : _l.url) || null;
      this.location = { ...this.location };
    }
  }
  async presentToast() {
    const toast = await toastController.create({
      message: "The location has been updated.",
      duration: 2000,
    });
    toast.present();
  }
  render() {
    var _a, _b, _c, _d, _e;
    return [
      h("ion-content", { scrollEvents: true, class: "ion-padding" }, h("floodteam-title-bar", null, h("ion-router-link", { href: "/locations" }, "Locations")), h("ion-card", { class: "ion-padding" }, h("fireenjin-form", { fetch: this.locationId === "new" ? false : "findLocation", fetchKey: "location", endpoint: this.locationId === "new" ? "addLocation" : "editLocation", documentId: this.locationId === "new" ? null : this.locationId, filterData: [
          "name",
          "phone",
          "email",
          "address",
          "ownerId",
          "defaultPayModelId",
          "website",
          "googleTagManagerId",
          "googleTagManagerCampaignId",
          "googleTagManagerPhoneId",
          "tags",
          "bannerPhoto",
          "photo",
          "teamPhoto",
          "taxId",
        ], beforeSubmit: (data) => ({ ...this.location, ...data }), resetButton: null }, h("ion-list", null, h("ion-grid", null, h("ion-row", null, h("ion-col", null, h("ion-card", null, h("fireenjin-input-photo", { name: "photo", value: (_a = this.location) === null || _a === void 0 ? void 0 : _a.photo, type: "location" }), h("ion-item", null, h("ion-label", { class: "ion-text-center" }, "Photo")))), h("ion-col", null, h("ion-card", null, h("fireenjin-input-photo", { name: "bannerPhoto", value: (_b = this.location) === null || _b === void 0 ? void 0 : _b.bannerPhoto }), h("ion-item", null, h("ion-label", { class: "ion-text-center" }, "Banner")))), h("ion-col", null, h("ion-card", null, h("fireenjin-input-photo", { name: "teamPhoto", value: (_c = this.location) === null || _c === void 0 ? void 0 : _c.teamPhoto }), h("ion-item", null, h("ion-label", { class: "ion-text-center" }, "Team")))))), h("fireenjin-input", { "data-fill": true, name: "name", label: "Location Name", labelPosition: "stacked" }), h("fireenjin-input", { "data-fill": true, name: "email", type: "email", label: "E-Mail", labelPosition: "stacked" }), h("fireenjin-input", { "data-fill": true, name: "website", label: "Website", labelPosition: "stacked" }), h("fireenjin-input", { "data-fill": true, name: "phone", type: "phone", label: "Phone Number", labelPosition: "stacked" }), h("fireenjin-input-address", { "data-fill": true, name: "address", label: "Address", labelPosition: "stacked", googleMapsKey: (_e = (_d = state === null || state === void 0 ? void 0 : state.config) === null || _d === void 0 ? void 0 : _d.firebase) === null || _e === void 0 ? void 0 : _e.apiKey }), h("fireenjin-input-search-user", { "data-fill": true, label: "Owner", labelPosition: "stacked", name: "ownerId", autofocus: true, placeholder: "Search Users", mode: "popover", required: true }), h("fireenjin-input", { "data-fill": true, name: "taxId", label: "Location EIN (Tax ID)", labelPosition: "stacked" }), h("fireenjin-select", { "data-fill": true, name: "defaultPayModelId", label: "Default Pay Model", endpoint: "listPayModels", limit: 100, dataPropsMap: {
          payModels: "results",
        } }), h("fireenjin-select-tags", { "data-fill": true, name: "tags", label: "Tags", labelPosition: "stacked", allowAdding: true, options: [] }), h("fireenjin-input", { "data-fill": true, name: "googleTagManagerId", label: "Google Tag Manager ID", labelPosition: "stacked" }), h("fireenjin-input", { "data-fill": true, name: "googleTagManagerCampaignId", label: "Google Tag Manager Campaign ID", labelPosition: "stacked" }), h("fireenjin-input", { "data-fill": true, name: "googleTagManagerPhoneId", label: "Google TM Phone Campaign ID", labelPosition: "stacked" }))))),
      h("floodteam-navigation-footer", null),
    ];
  }
};
AppLocation.style = appLocationCss;

export { AppLocation as app_location };
