'use strict';

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

const index = require('./index-ee190ee0.js');
const getInvoiceTypes = require('./getInvoiceTypes-6482a668.js');
const getLocationOptions = require('./getLocationOptions-73836f05.js');
const store = require('./store-27073b3b.js');
const getStatusOptions = require('./getStatusOptions-64f3eefc.js');
require('./index-4901314f.js');
require('./getHandlebarsHelpers-8ef28401.js');
require('./_commonjsHelpers-a5111d61.js');
require('./index-ba857994.js');
require('./localforage-af1b8c0e.js');

const SelectJobServiceTypes = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = index.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.getInvoiceTypes();
    return (index.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,
            },
          },
        });
      } }, index.h("ion-icon", { name: this.icon, class: "ft-icon-style" }), index.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 index.getElement(this); }
};

const SelectLocation = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = index.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 (index.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.getLocationOptions(),
              value: this.value,
            },
          },
        });
      } }, index.h("ion-icon", { name: "business", class: "ft-icon-style" }), index.h("ion-label", { class: "ion-text-capitalize" }, ((_a = ((store.state === null || store.state === void 0 ? void 0 : store.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 index.getElement(this); }
};

const SelectStatus = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = index.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 (index.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.getStatusOptions(),
              value: this.value,
            },
          },
        });
      } }, index.h("ion-icon", { name: "help-circle", class: "ft-icon-style" }), index.h("ion-label", { class: "ion-text-capitalize" }, this.value || "No Status")));
  }
  get selectStatusEl() { return index.getElement(this); }
};

exports.floodteam_select_job_service_types = SelectJobServiceTypes;
exports.floodteam_select_location = SelectLocation;
exports.floodteam_select_status = SelectStatus;
