'use strict';

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

const index = require('./index-fd2bbf0b.js');
const logic = require('./logic-d8c34975.js');
const store = require('./store-9988299d.js');
require('./_commonjsHelpers-a5111d61.js');
require('./index-81aa1bcb.js');
require('./getCache-901b0f67.js');

const popoverSiteServiceCss = ".popover-site-service{--min-width:300px;--offset-y:-50px}popover-site-service ion-accordion-group{background:var(--background-color) !important;--ion-item-background:var(--background-color);--background:var(--background-color);background-color:var(--background-color) !important}popover-site-service ion-list ion-item{--ion-item-background:transparent}popover-site-service fireenjin-input ion-label{font-size:12px !important}";

let PopoverSiteService = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinFetch = index.createEvent(this, "fireenjinFetch", 7);
    this.service = {};
    this.scopeToServiceMap = {};
    this.sites = [];
  }
  async onSuccess(event) {
    var _a;
    if (["editScopeService", "addScopeService", "deleteScopeService"].includes((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.endpoint)) {
      this.accordionEl.requestAccordionToggle(null, false);
    }
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
    const isGeneral = ((_c = (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.tab) === null || _b === void 0 ? void 0 : _b.toLowerCase) === null || _c === void 0 ? void 0 : _c.call(_b)) === "general";
    return [
      index.h("ion-content", null, index.h("ion-item-divider", null, ((_d = this.service) === null || _d === void 0 ? void 0 : _d.name) || "No Name Given"), index.h("ion-accordion-group", { ref: (el) => (this.accordionEl = el), value: this.currentExpanded }, isGeneral ? (index.h("floodteam-form-site-service", { isGeneral: true, serviceId: (_e = this.service) === null || _e === void 0 ? void 0 : _e.id, jobId: this.jobId, siteServiceId: ((_h = (_f = this.scopeToServiceMap) === null || _f === void 0 ? void 0 : _f[`${this.jobId}-${(_g = this.service) === null || _g === void 0 ? void 0 : _g.id}`]) === null || _h === void 0 ? void 0 : _h.id) || null, amount: ((_l = (_j = this.scopeToServiceMap) === null || _j === void 0 ? void 0 : _j[`${this.jobId}-${(_k = this.service) === null || _k === void 0 ? void 0 : _k.id}`]) === null || _l === void 0 ? void 0 : _l.amount) ||
          ((_p = (_m = logic.jsonLogic === null || logic.jsonLogic === void 0 ? void 0 : logic.logic.apply) === null || _m === void 0 ? void 0 : _m.call(logic.jsonLogic, (_o = this.service) === null || _o === void 0 ? void 0 : _o.autofill, {
            service: this.service,
            job: store.state === null || store.state === void 0 ? void 0 : store.state.job,
          })) === null || _p === void 0 ? void 0 : _p.amount) ||
          0, price: ((_s = (_q = this.scopeToServiceMap) === null || _q === void 0 ? void 0 : _q[`${this.jobId}-${(_r = this.service) === null || _r === void 0 ? void 0 : _r.id}`]) === null || _s === void 0 ? void 0 : _s.price) ||
          ((_v = (_t = logic.jsonLogic === null || logic.jsonLogic === void 0 ? void 0 : logic.logic.apply) === null || _t === void 0 ? void 0 : _t.call(logic.jsonLogic, (_u = this.service) === null || _u === void 0 ? void 0 : _u.autofill, {
            service: this.service,
            job: store.state === null || store.state === void 0 ? void 0 : store.state.job,
          })) === null || _v === void 0 ? void 0 : _v.price) ||
          ((_x = (_w = this.service) === null || _w === void 0 ? void 0 : _w.prices) === null || _x === void 0 ? void 0 : _x.default), quantity: ((_0 = (_y = this.scopeToServiceMap) === null || _y === void 0 ? void 0 : _y[`${this.jobId}-${(_z = this.service) === null || _z === void 0 ? void 0 : _z.id}`]) === null || _0 === void 0 ? void 0 : _0.quantity) ||
          ((_3 = (_1 = logic.jsonLogic === null || logic.jsonLogic === void 0 ? void 0 : logic.logic.apply) === null || _1 === void 0 ? void 0 : _1.call(logic.jsonLogic, (_2 = this.service) === null || _2 === void 0 ? void 0 : _2.autofill, {
            service: this.service,
            job: store.state === null || store.state === void 0 ? void 0 : store.state.job,
          })) === null || _3 === void 0 ? void 0 : _3.quantity) ||
          1, unit: (_4 = this.service) === null || _4 === void 0 ? void 0 : _4.unit })) : ((this.sites || [])
        .sort((a, b) => ((a === null || a === void 0 ? void 0 : a.name) > (b === null || b === void 0 ? void 0 : b.name) ? 1 : -1))
        .map((site) => {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
        return (index.h("floodteam-form-site-service", { siteId: site === null || site === void 0 ? void 0 : site.id, jobId: this.jobId, serviceId: (_a = this.service) === null || _a === void 0 ? void 0 : _a.id, siteServiceId: ((_d = (_b = this.scopeToServiceMap) === null || _b === void 0 ? void 0 : _b[`${site === null || site === void 0 ? void 0 : site.id}-${(_c = this.service) === null || _c === void 0 ? void 0 : _c.id}`]) === null || _d === void 0 ? void 0 : _d.id) || null, amount: ((_g = (_e = this.scopeToServiceMap) === null || _e === void 0 ? void 0 : _e[`${site === null || site === void 0 ? void 0 : site.id}-${(_f = this.service) === null || _f === void 0 ? void 0 : _f.id}`]) === null || _g === void 0 ? void 0 : _g.amount) ||
            ((_k = (_h = logic.jsonLogic === null || logic.jsonLogic === void 0 ? void 0 : logic.logic.apply) === null || _h === void 0 ? void 0 : _h.call(logic.jsonLogic, (_j = this.service) === null || _j === void 0 ? void 0 : _j.autofill, {
              service: this.service,
              job: store.state === null || store.state === void 0 ? void 0 : store.state.job,
            })) === null || _k === void 0 ? void 0 : _k.amount) ||
            0, price: ((_o = (_l = this.scopeToServiceMap) === null || _l === void 0 ? void 0 : _l[`${site === null || site === void 0 ? void 0 : site.id}-${(_m = this.service) === null || _m === void 0 ? void 0 : _m.id}`]) === null || _o === void 0 ? void 0 : _o.price) ||
            ((_r = (_p = logic.jsonLogic === null || logic.jsonLogic === void 0 ? void 0 : logic.logic.apply) === null || _p === void 0 ? void 0 : _p.call(logic.jsonLogic, (_q = this.service) === null || _q === void 0 ? void 0 : _q.autofill, {
              service: this.service,
              job: store.state === null || store.state === void 0 ? void 0 : store.state.job,
            })) === null || _r === void 0 ? void 0 : _r.price) ||
            ((_t = (_s = this.service) === null || _s === void 0 ? void 0 : _s.prices) === null || _t === void 0 ? void 0 : _t.default), quantity: ((_w = (_u = this.scopeToServiceMap) === null || _u === void 0 ? void 0 : _u[`${site === null || site === void 0 ? void 0 : site.id}-${(_v = this.service) === null || _v === void 0 ? void 0 : _v.id}`]) === null || _w === void 0 ? void 0 : _w.quantity) ||
            ((_z = (_x = logic.jsonLogic === null || logic.jsonLogic === void 0 ? void 0 : logic.logic.apply) === null || _x === void 0 ? void 0 : _x.call(logic.jsonLogic, (_y = this.service) === null || _y === void 0 ? void 0 : _y.autofill, {
              service: this.service,
              job: store.state === null || store.state === void 0 ? void 0 : store.state.job,
            })) === null || _z === void 0 ? void 0 : _z.quantity) ||
            1, name: site === null || site === void 0 ? void 0 : site.name, unit: (_0 = this.service) === null || _0 === void 0 ? void 0 : _0.unit }));
      })))),
    ];
  }
};
PopoverSiteService.style = popoverSiteServiceCss;

exports.popover_site_service = PopoverSiteService;

//# sourceMappingURL=popover-site-service.cjs.entry.js.map