import { ref as d } from "vue";
import { m as w, i as g } from "./app-Bpb4394e.js";
import { useCoreStore as h } from "@feedmepos/mf-common";
import { useSnackbar as y } from "@feedmepos/ui-library";
const p = w((s, r) => {
  const u = h(), c = y();
  return r.onError(async (e) => {
    if (e instanceof g)
      throw c == null || c.open({
        title: e.title,
        message: e.message,
        type: "error"
      }), e;
  }), {
    async browse() {
      var t;
      const e = ((t = u.currentBusiness.value) == null ? void 0 : t._id) ?? "", n = `${s.inventoryBackendUrl}/${e}/surcharge`;
      return await r.get(n);
    },
    async create(e) {
      var a;
      const n = ((a = u.currentBusiness.value) == null ? void 0 : a._id) ?? "", t = `${s.inventoryBackendUrl}/${n}/surcharge`;
      return await r.post(t, e);
    },
    async read(e) {
      var a;
      const n = ((a = u.currentBusiness.value) == null ? void 0 : a._id) ?? "", t = `${s.inventoryBackendUrl}/${n}/surcharge/${e}`;
      return await r.get(t);
    },
    async update(e, n) {
      var i;
      const t = ((i = u.currentBusiness.value) == null ? void 0 : i._id) ?? "", a = `${s.inventoryBackendUrl}/${t}/surcharge/${e}`;
      return await r.put(a, n);
    },
    async delete(e) {
      var a;
      const n = ((a = u.currentBusiness.value) == null ? void 0 : a._id) ?? "", t = `${s.inventoryBackendUrl}/${n}/surcharge/${e}`;
      return await r.delete(t);
    },
    urls: s
  };
});
function l() {
  return {
    surcharges: []
  };
}
const o = d(l());
function f() {
  const s = p();
  return {
    get surcharges() {
      return o.value.surcharges;
    },
    async browse() {
      o.value.surcharges = await s.browse();
    },
    async create(r) {
      await s.create(r), await this.browse();
    },
    async update(r, u) {
      await s.update(r, u), await this.browse();
    },
    async delete(r) {
      await s.delete(r), await this.browse();
    }
  };
}
export {
  f as u
};
