import { r as registerInstance, d as createEvent, h, e as getElement } from './index-26447f8a.js';
import { g as getInvoiceTypes } from './getInvoiceTypes-8686f775.js';
import { g as getLocationOptions } from './getLocationOptions-214931d1.js';
import { s as state } from './store-838a3050.js';
import { g as getStatusOptions } from './getStatusOptions-6f716ba9.js';
import './index-b0d3ac50.js';
import './getHandlebarsHelpers-0376b57c.js';
import './_commonjsHelpers-7c4ea794.js';
import './index-e6b3332e.js';
import './localforage-c63d55c8.js';

const SelectJobServiceTypes = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = createEvent(this, "fireenjinSubmit", 7);
    this.name = "serviceTypes";
    this.value = undefined;
    this.jobId = undefined;
    this.locationId = undefined;
    this.disabled = false;
    this.icon = "reader";
  }
  onTrigger(event) {
    var _a, _b, _c, _d, _e;
    if (((_c = (_b = (_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.event) === null || _b === void 0 ? void 0 : _b.detail) === null || _c === void 0 ? void 0 : _c.type) !== this.name)
      return;
    this.value = ((_e = (_d = event === null || event === void 0 ? void 0 : event.detail) === null || _d === void 0 ? void 0 : _d.payload) === null || _e === void 0 ? void 0 : _e.value) || null;
    this.fireenjinSubmit.emit({
      endpoint: this.jobId
        ? "editJob"
        : this.locationId
          ? "editLocation"
          : null,
      id: this.jobId || this.locationId || null,
      data: {
        serviceTypes: this.value || [],
      },
    });
  }
  render() {
    const options = getInvoiceTypes();
    return (h("ion-chip", { onClick: (event) => {
        if (this.disabled)
          return;
        event.preventDefault();
        event.stopPropagation();
        this.fireenjinTrigger.emit({
          event,
          name: "filter",
          type: this.name,
          el: this.selectLocationEl,
          payload: {
            control: {
              multiple: true,
              name: this.name,
              label: "Service Types",
              icon: this.icon,
              options,
              value: this.value,
            },
          },
        });
      } }, h("ion-icon", { name: this.icon, class: "ft-icon-style" }), h("ion-label", { class: "ion-text-capitalize" }, (options || [])
      .filter((option) => (this.value || []).includes(option === null || option === void 0 ? void 0 : option.value))
      .map((option) => option === null || option === void 0 ? void 0 : option.value)
      .join(", ") || "No Service Types Set")));
  }
  get selectLocationEl() { return getElement(this); }
};

const SelectLocation = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = createEvent(this, "fireenjinSubmit", 7);
    this.name = "status";
    this.value = undefined;
    this.jobId = undefined;
    this.disabled = false;
  }
  onTrigger(event) {
    var _a, _b, _c, _d;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.name) !== "select" ||
      this.selectLocationEl !== ((_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.el))
      return;
    this.value = ((_d = (_c = event === null || event === void 0 ? void 0 : event.detail) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.value) || null;
    this.fireenjinSubmit.emit({
      endpoint: "editJob",
      id: this.jobId,
      data: {
        locationId: this.value,
      },
    });
  }
  render() {
    var _a;
    return (h("ion-chip", { onClick: (event) => {
        if (this.disabled)
          return;
        event.preventDefault();
        event.stopPropagation();
        this.fireenjinTrigger.emit({
          event,
          name: "filter",
          type: "location",
          el: this.selectLocationEl,
          payload: {
            control: {
              name: "location",
              label: "Location",
              icon: "business",
              options: getLocationOptions(),
              value: this.value,
            },
          },
        });
      } }, h("ion-icon", { name: "business", class: "ft-icon-style" }), h("ion-label", { class: "ion-text-capitalize" }, ((_a = ((state === null || state === void 0 ? void 0 : state.locations) || []).find((location) => (location === null || location === void 0 ? void 0 : location.id) === this.value)) === null || _a === void 0 ? void 0 : _a.name) || "No Location Set")));
  }
  get selectLocationEl() { return getElement(this); }
};

const SelectStatus = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = createEvent(this, "fireenjinSubmit", 7);
    this.name = "status";
    this.value = undefined;
    this.jobId = undefined;
    this.disabled = false;
  }
  onTrigger(event) {
    var _a, _b, _c, _d;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.name) !== "select" ||
      this.selectStatusEl !== ((_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.el))
      return;
    this.value = ((_d = (_c = event === null || event === void 0 ? void 0 : event.detail) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.value) || null;
    this.fireenjinSubmit.emit({
      endpoint: "editJob",
      id: this.jobId,
      data: {
        status: this.value,
      },
    });
  }
  render() {
    return (h("ion-chip", { onClick: (event) => {
        if (this.disabled)
          return;
        event.preventDefault();
        event.stopPropagation();
        this.fireenjinTrigger.emit({
          event,
          name: "filter",
          type: "status",
          el: this.selectStatusEl,
          payload: {
            control: {
              name: "status",
              label: "Status",
              icon: "help-circle",
              options: getStatusOptions(),
              value: this.value,
            },
          },
        });
      } }, h("ion-icon", { name: "help-circle", class: "ft-icon-style" }), h("ion-label", { class: "ion-text-capitalize" }, this.value || "No Status")));
  }
  get selectStatusEl() { return getElement(this); }
};

export { SelectJobServiceTypes as floodteam_select_job_service_types, SelectLocation as floodteam_select_location, SelectStatus as floodteam_select_status };
