'use strict';

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

const index = require('./index-e0385008.js');
const store = require('./store-8d1de66f.js');
require('./index-37fc02d8.js');
require('./getHandlebarsHelpers-1b368c8a.js');
require('./_commonjsHelpers-a5111d61.js');
require('./index-ba857994.js');
require('./localforage-af1b8c0e.js');

const appFlowListCss = "";

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

exports.app_flow_list = AppFlowList;
