import { defineStore as y } from "pinia";
import { a as S } from "./app-Bpb4394e.js";
import { a as b } from "./FmMultiselectDialog-D-38fV59.js";
import { useDialog as A } from "@feedmepos/ui-library";
import { useI18n as I } from "@feedmepos/mf-common";
const B = y(
  "ingredientSelectDialog",
  function() {
    const { t: s } = I(), n = S(), m = A();
    async function a(l, u) {
      const p = n.skus, g = u ?? ((t) => n.skuByCode[t]), d = p.map(
        (t) => {
          var e, o, i, c;
          return {
            label: t.name,
            sublabel: t.code,
            value: t._id,
            searchKeys: (e = t.customAttributes) != null && e.tag ? [(o = t.customAttributes) == null ? void 0 : o.tag] : void 0,
            tags: (i = t.customAttributes) != null && i.tag ? [(c = t.customAttributes) == null ? void 0 : c.tag] : void 0
          };
        }
      ), f = l, { promise: v, resolve: r } = Promise.withResolvers();
      return m.open({
        title: s("inventory.transfer.form.items.selectItem"),
        closeButton: !0,
        contentComponent: b,
        contentComponentProps: {
          modelValue: f,
          items: d,
          virtualScroll: !0,
          onClose: () => r(null)
        },
        primaryActions: {
          text: s("common.confirm"),
          close: !0
        },
        secondaryActions: {
          text: s("common.close"),
          close: !0,
          variant: "tertiary"
        }
      }).onPrimary((t) => {
        const e = t.map((o) => g(o));
        r(e);
      }), v;
    }
    return { promptSelectIngredients: a };
  }
);
export {
  B as u
};
