import { r as registerInstance, d as createEvent, B as Build, h } from './index-33e43734.js';
import { s as state } from './store-729235b6.js';
import { g as getStatusOptions } from './getStatusOptions-bebaf81a.js';
import './index-91eb4513.js';
import './getCache-f7c123d8.js';
import './_commonjsHelpers-cca61ea8.js';
import './logic-2eecfe1e.js';
import './index-964da72a.js';

const appDashboardCss = "app-dashboard floodteam-activity-feed .feed-header h3{color:#fff}app-dashboard fireenjin-map{background:var(--ion-color-light-shade);border-radius:15px;display:block;margin:20px auto 0;overflow:hidden;max-width:calc(100% - 30px)}app-dashboard h1 a{padding:0}app-dashboard ion-grid{margin-top:0;padding-top:0}app-dashboard .title-divider{display:flex;justify-content:space-between;align-items:baseline}app-dashboard .title-divider>span{display:flex;align-items:baseline;padding-inline-end:5px;margin-top:auto}app-dashboard .title-divider>span>ion-button{margin-right:5px}";

let AppDashboard = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.unreadCount = 0;
    this.selectedStatuses = ["book", "evaluate", "claim", "mitigate", "monitor", "review"];
  }
  async onTrigger(event) {
    var _a, _b, _c, _d, _e;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.trigger) === "set" &&
      ((_c = (_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.payload) === null || _c === void 0 ? void 0 : _c.name) === "status") {
      await this.mapEl.clearMarkers();
      this.selectedStatuses = ((_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) || [];
    }
  }
  filterJobsByStatus(jobs, statuses) {
    return jobs.filter((job) => statuses.includes(job === null || job === void 0 ? void 0 : job.status));
  }
  componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
  }
  render() {
    var _a, _b, _c;
    return [
      h("ion-content", { class: "truck-background ion-padding" }, h("floodteam-title-bar", null, h("ion-router-link", { href: "/profile" }, "Welcome Back", " ", ((_a = state === null || state === void 0 ? void 0 : state.profile) === null || _a === void 0 ? void 0 : _a.firstName) ? `, ${state.profile.firstName}` : "", "!")), h("article", { id: "myjobs" }, h("fireenjin-map", { googleMapsKey: (_c = (_b = state === null || state === void 0 ? void 0 : state.config) === null || _b === void 0 ? void 0 : _b.firebase) === null || _c === void 0 ? void 0 : _c.apiKey, ref: (el) => (this.mapEl = el), markers: this.filterJobsByStatus(state === null || state === void 0 ? void 0 : state.myJobs, this.selectedStatuses).map((job) => {
          var _a, _b;
          return ({
            payload: { job },
            name: job === null || job === void 0 ? void 0 : job.title,
            icon: null,
            position: {
              lat: (_a = job === null || job === void 0 ? void 0 : job.address) === null || _a === void 0 ? void 0 : _a.lat,
              lng: (_b = job === null || job === void 0 ? void 0 : job.address) === null || _b === void 0 ? void 0 : _b.lng,
            },
          });
        }) }), h("floodteam-title-bar", null, h("ion-router-link", { href: "/jobs" }, "My Jobs", " ", h("ion-badge", { style: { borderRadius: "15px" } }, h("small", null, this.filterJobsByStatus(state === null || state === void 0 ? void 0 : state.myJobs, this.selectedStatuses)
        .length || 0))), h("ion-buttons", { slot: "end" }, h("ion-button", { onClick: (event) => this.fireenjinTrigger.emit({
          event,
          name: "filter",
          type: "status",
          payload: {
            control: {
              name: "status",
              label: "Status",
              icon: "help-circle",
              multiple: true,
              options: getStatusOptions(),
              value: this.selectedStatuses,
            },
          },
        }), color: "medium", fill: "outline", size: "small" }, "Filter", h("ion-icon", { slot: "end", name: "funnel" })))), h("ion-card", null, h("ion-list", null, this.filterJobsByStatus(state === null || state === void 0 ? void 0 : state.myJobs, this.selectedStatuses).map((job) => (h("floodteam-item-job", { job: job }))))))),
      h("floodteam-navigation-footer", null),
    ];
  }
};
AppDashboard.style = appDashboardCss;

export { AppDashboard as app_dashboard };

//# sourceMappingURL=app-dashboard.entry.js.map