import { r as registerInstance, d as createEvent, B as Build, h } from './index-26447f8a.js';
import { s as state } from './store-838a3050.js';
import './index-b0d3ac50.js';
import './getHandlebarsHelpers-0376b57c.js';
import './_commonjsHelpers-7c4ea794.js';
import './index-e6b3332e.js';
import './localforage-c63d55c8.js';

const appFlowListCss = "";

const AppFlowList = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinFetch = createEvent(this, "fireenjinFetch", 7);
    this.flows = undefined;
  }
  onSuccess(event) {
    var _a, _b, _c;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "listFlows") {
      this.flows = ((_c = (_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.flows) || [];
      console.log(this.flows, "flows");
    }
  }
  fetchFlow() {
    this.fireenjinFetch.emit({
      endpoint: "listFlows",
    });
  }
  componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    this.fetchFlow();
  }
  render() {
    var _a;
    return [
      h("ion-content", { class: "ion-padding" }, h("floodteam-title-bar", null, h("ion-router-link", { href: "/flows" }, "Flows"), h("ion-buttons", { slot: "end" }, h("ion-button", { fill: "solid", color: "primary", href: "/flows/new" }, "Add"))), h("div", { class: "ion-padding" }, (this.flows || []).map((flow) => (h("ion-item", { href: `/flows/${flow.id}`, detail: true, lines: "full" }, h("ion-grid", null, h("ion-row", { class: "ion-align-items-center ion-justify-content-between" }, h("ion-col", null, h("ion-label", null, h("h2", null, flow.name)))))))))),
      h("floodteam-navigation-footer", null, h("floodteam-title-bar", { back: "/dashboard" }, h("ion-breadcrumbs", null, h("ion-breadcrumb", { onClick: () => this.fireenjinTrigger.emit({
          name: "pin",
          payload: {
            icon: "flash",
            href: `/flows`,
            name: "Flows",
          },
        }) }, h("ion-icon", { color: ((_a = ((state === null || state === void 0 ? void 0 : state.pins) || [])
          .map((pin) => pin === null || pin === void 0 ? void 0 : pin.href)) === null || _a === void 0 ? void 0 : _a.includes(`/flows`))
          ? "primary"
          : null, slot: "start", name: "pin" }), "Flows")), h("ion-buttons", { slot: "end" }, h("ion-button", { fill: "solid", color: "primary", href: "/flows/new" }, "Add")))),
    ];
  }
};
AppFlowList.style = appFlowListCss;

export { AppFlowList as app_flow_list };
