import { defineStore as p } from "pinia";
import { useDialog as y } from "@feedmepos/ui-library";
import { useI18n as v } from "@feedmepos/mf-common";
import { a } from "./FmMultiselectDialog-D-38fV59.js";
import { h as S } from "vue";
const w = p("inventoryMultiSelectDialog", () => {
  const l = y(), { t: n } = v();
  return { multiSelect: async (s, t, c) => {
    const o = c ?? ((e) => e), { promise: i, resolve: r } = Promise.withResolvers();
    return l.open({
      title: "Select items",
      closeButton: !0,
      contentComponent: a,
      contentComponentProps: {
        modelValue: t ?? [],
        items: s,
        virtualScroll: !0,
        onClose: () => r(null)
      },
      primaryActions: {
        text: n("common.confirm"),
        close: !0
      },
      secondaryActions: {
        text: n("common.close"),
        close: !0,
        variant: "tertiary"
      }
    }).onPrimary((e) => {
      const m = e.map((u) => o(u));
      r(m);
    }), i;
  }, singleSelect: async (s, t, c) => {
    const o = c ?? ((e) => e), { promise: i, resolve: r } = Promise.withResolvers();
    return l.open({
      title: "Select items",
      closeButton: !0,
      contentComponent: a,
      contentComponentProps: {
        modelValue: t ? [t] : [],
        items: s,
        virtualScroll: !0,
        onClose: () => r(void 0),
        singleSelect: !0
      },
      primaryActions: {
        text: n("common.confirm"),
        close: !0
      },
      secondaryActions: {
        text: n("common.close"),
        close: !0,
        variant: "tertiary"
      }
    }).onPrimary((e) => {
      if (!e.length)
        return r(null);
      const m = o(e[0]);
      r(m);
    }), i;
  }, alert: (s, t) => {
    const { promise: c, resolve: o } = Promise.withResolvers();
    return l.open({
      title: s,
      closeButton: !0,
      contentComponent: typeof t == "string" ? S("div", t) : t,
      secondaryActions: {
        text: n("common.close"),
        close: !0,
        variant: "tertiary"
      }
    }).onSecondary(() => o()).onClose(() => o()), c;
  } };
});
export {
  w as u
};
