import { Component, Event, h } from "@stencil/core";
import state from "../../../store";
import pick from "../../../helpers/pick";
import isAdmin from "../../../helpers/auth/isAdmin";
import isInternalTeam from "../../../helpers/auth/isInternalTeam";
import isLoggedIn from "../../../helpers/auth/isLoggedIn";
export class NavigationMenu {
  constructor() {
    this.items = [
      {
        id: "alerts",
        href: "/alerts",
        icon: "notifications",
        name: "Alerts",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "appointments",
        href: "/appointments",
        icon: "calendar",
        name: "Appointments",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "atmospherics",
        href: "/atmospherics",
        icon: "cloud-circle-outline",
        name: "Atmospheric Readings",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "campaigns",
        href: "/campaigns",
        icon: "magnet",
        name: "Campaigns",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "companies",
        href: "/companies",
        icon: "briefcase",
        name: "Companies",
        add: "/companies/new",
        permissionCheck: isInternalTeam.bind(this),
      },
      {
        id: "contracts",
        href: "/contracts",
        icon: "create",
        name: "Contracts",
        permissionCheck: isInternalTeam.bind(this),
      },
      {
        id: "dots",
        href: "/dots",
        icon: "ellipse",
        name: "Dots",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "exhausts",
        href: "/exhausts",
        icon: "exit",
        name: "Exhaust Readings",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "jobs",
        href: "/jobs",
        icon: "water",
        name: "Jobs",
        add: "/jobs/refer",
        permissionCheck: isLoggedIn.bind(this),
      },
      {
        id: "import",
        href: "/import",
        icon: "download",
        name: "Import",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "inventory",
        href: "/inventory",
        icon: "barcode-outline",
        name: "Inventory",
        permissionCheck: isInternalTeam.bind(this),
      },
      {
        id: "locations",
        href: "/locations",
        icon: "business",
        name: "Locations",
        add: "/locations/new",
        permissionCheck: isInternalTeam.bind(this),
      },
      {
        id: "logs",
        href: "/logs",
        icon: "journal",
        name: "Logs",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "moisturecontents",
        href: "/moisturecontents",
        icon: "water",
        name: "MC Readings",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "paymodels",
        href: "/paymodels",
        icon: "pie-chart",
        name: "Pay Models",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "payments",
        href: "/payments",
        icon: "cash",
        name: "Payments",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "phonenumbers",
        href: "/phonenumbers",
        icon: "call",
        name: "Phone Numbers",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "pins",
        href: "/pins",
        icon: "pin",
        name: "Pins",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "services",
        href: "/services",
        icon: "reader",
        name: "Services",
        permissionCheck: isInternalTeam.bind(this),
      },
      {
        id: "templates",
        href: "/templates",
        icon: "create",
        name: "Templates",
        add: "/templates/new",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "totallers",
        href: "/totallers",
        icon: "calculator",
        name: "Totallers",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "triggers",
        href: "/triggers",
        icon: "flash",
        name: "Triggers",
        add: "/triggers/new",
        permissionCheck: isAdmin.bind(this),
      },
      {
        id: "users",
        href: "/users",
        icon: "people",
        name: "Users",
        add: "/users/new",
        permissionCheck: isInternalTeam.bind(this),
      },
      {
        id: "vehicles",
        href: "/vehicles",
        icon: "car",
        name: "Vehicles",
        permissionCheck: isInternalTeam.bind(this),
      },
      {
        id: "weather",
        href: "/weather",
        icon: "rainy",
        name: "Weather",
        permissionCheck: isAdmin.bind(this),
      },
    ];
  }
  async toggleNavPin(event, item) {
    event.preventDefault();
    event.stopPropagation();
    this.fireenjinTrigger.emit({
      name: "pin",
      payload: pick(item, ["icon", "name", "href"]),
    });
  }
  render() {
    var _a;
    return (h("ion-list", { style: { background: "transparent" } },
      h("div", { style: {
          display: ((_a = state === null || state === void 0 ? void 0 : state.session) === null || _a === void 0 ? void 0 : _a.uid) ? "none" : "block",
        } },
        h("slot", null)),
      this.items.map((item) => {
        var _a, _b, _c, _d;
        return ((_a = item === null || item === void 0 ? void 0 : item.permissionCheck) === null || _a === void 0 ? void 0 : _a.call(item)) ? (h("ion-menu-toggle", { autoHide: false },
          h("ion-item", { style: { "--background": "transparent" }, title: (item === null || item === void 0 ? void 0 : item.title) || (item === null || item === void 0 ? void 0 : item.name), href: (item === null || item === void 0 ? void 0 : item.href) || "#" },
            h("ion-icon", { slot: "start", class: "ft-icon-style", name: item === null || item === void 0 ? void 0 : item.icon, color: "primary" }),
            h("ion-label", null, (item === null || item === void 0 ? void 0 : item.name) || ""),
            h("ion-buttons", { slot: "end" },
              (item === null || item === void 0 ? void 0 : item.add) && (h("ion-button", { fill: "clear", onClick: (event) => event.stopPropagation(), href: item.add },
                h("ion-icon", { name: "add-circle", slot: "icon-only", color: "primary" }))),
              h("ion-button", { fill: "clear", onClick: (event) => this.toggleNavPin(event, item) },
                h("ion-icon", { name: "pin", slot: "icon-only", color: ((_d = (_c = (_b = state === null || state === void 0 ? void 0 : state.pins) === null || _b === void 0 ? void 0 : _b.map) === null || _c === void 0 ? void 0 : _c.call(_b, (pin) => pin === null || pin === void 0 ? void 0 : pin.href)) === null || _d === void 0 ? void 0 : _d.includes(item === null || item === void 0 ? void 0 : item.href))
                    ? "primary"
                    : null })))))) : null;
      })));
  }
  static get is() { return "floodteam-navigation-menu"; }
  static get events() { return [{
      "method": "fireenjinTrigger",
      "name": "fireenjinTrigger",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "FireEnjinTriggerInput",
        "resolved": "FireEnjinTriggerInput",
        "references": {
          "FireEnjinTriggerInput": {
            "location": "import",
            "path": "@fireenjin/sdk"
          }
        }
      }
    }]; }
}
//# sourceMappingURL=navigation-menu.js.map