import { ref as R, h as E, defineComponent as Y, resolveComponent as M, openBlock as A, createElementBlock as D, createElementVNode as _, normalizeClass as K, createTextVNode as re, toDisplayString as V, unref as k, createCommentVNode as z, createVNode as F, createBlock as O, Fragment as W, renderList as Q, computed as N, watch as ie, createSlots as Ve, withCtx as j, isRef as je, withModifiers as Je, normalizeStyle as qe, Teleport as Qe, normalizeProps as Xe, guardReactiveProps as Ze, mergeProps as Me } from "vue";
import { u as et, _ as tt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-sUxHOj47.js";
import { useI18n as G, useCoreStore as Ue } from "@feedmepos/mf-common";
import { D as ae, R as B } from "./row-action.enum-DQ9bJ_uv.js";
import { _ as nt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-j3aDZ2cT.js";
import { useDialog as X, useDialogChild as ot, useSnackbar as ue, FmButtonVariant as q, components as H, useProxiedModel as Le, useBreakpoints as st } from "@feedmepos/ui-library";
import { defineStore as Ne, storeToRefs as Be } from "pinia";
import { _ as at, F as le } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
import { u as ye, c as ze, a as Z, I as L, l as lt, D as pe } from "./app-Bpb4394e.js";
import { F as J } from "./form-mode.enum-BKiNVH6A.js";
import { c as rt } from "./component-kqxARxvM.js";
import { f as it } from "./format-time-from-id-BvLCC6cK.js";
import { u as ce } from "./closing-template-ar_kUs4X.js";
import { _ as Ee } from "./TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BKLYNLrJ.js";
import { t as fe, a as Oe, d as He, s as We, r as ut } from "./xlsx.util-BPV2vsSD.js";
import { f as ct, a as mt } from "./date2-DpnYOzUg.js";
import { u as dt } from "./netsuite-BGUUAOqe.js";
import { F as pt } from "./FmDroppableField-J0xUsOTV.js";
import { u as ft } from "./duplicate-template-ct64aRN_.js";
import { A as vt, R as Ke } from "./rules-CoimOM7X.js";
import { d as yt } from "./defineDeepModel-BF0Cvhza.js";
import { u as ht } from "./use-template-enabled-locations-Puw8RG4I.js";
import { a as gt } from "./FmMultiselectDialog-D-38fV59.js";
import { _ as bt } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-qJoe3Rw5.js";
import { _ as _t } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const me = Ne(
  "wastageTable",
  function() {
    const { t: l } = G(), c = X(), v = ve(), d = R({}), i = R(new Array()), m = R(!1), o = ye(), t = ce(), s = R({}), r = R();
    async function h() {
      if (o._currentLocation)
        try {
          r.value = await t.getReasons();
        } catch (u) {
          console.log("Something went wrong when fetching reasons:", u);
        }
    }
    function x() {
      if (!r.value) return !1;
      const e = o.locations.filter((g) => !!o.locationByDbName[g.dbName]), a = e.filter((g) => !!(s.value[g.dbName] || []).find(
        (I) => I._id === r.value._id && (I.updatedAt ? I.updatedAt === r.value.updatedAt : I._rev === r.value._rev)
      )).length;
      return e.length > 0 && a === e.length;
    }
    function w(u) {
      const e = {
        title: u.name,
        doc: u,
        controller: {
          publishAll: async (a) => {
            const S = a || u.locations, g = await t.publishSingleDoc(
              u._id,
              S == null ? void 0 : S.map((y) => y.dbName)
            );
            return s.value = g.publishedRevByLocation || {}, s.value;
          },
          publishAtLocation: async (a) => {
            const S = await t.publishSingleDoc(u._id, [
              a.dbName
            ]);
            return s.value = S.publishedRevByLocation || {}, s.value;
          },
          unpublishAll: async (a) => {
            const S = a || u.locations, g = await t.unpublishSingleDoc(
              u._id,
              S == null ? void 0 : S.map((y) => y.dbName)
            );
            return s.value = g.publishedRevByLocation || {}, s.value;
          },
          unpublishAtLocation: async (a) => {
            const S = await t.unpublishSingleDoc(u._id, [
              a.dbName
            ]);
            return s.value = S.publishedRevByLocation || {}, s.value;
          }
        },
        initialPublishedRev: s.value,
        locations: o.locations,
        enabledLocations: u.locations
      };
      c.open({
        title: "Publish template",
        contentComponent: Ee,
        contentComponentProps: e,
        closeButton: !0,
        minWidth: 700,
        maxHeight: "80vh",
        contentScrollable: !1,
        primaryActions: {
          text: l("common.close"),
          close: !0,
          variant: "tertiary"
        }
      });
    }
    function T() {
      if (!r.value) return;
      const u = {
        title: "Adjustment Reasons",
        doc: r.value,
        controller: {
          publishAll: async (e) => {
            const a = await t.publishReasonDoc(
              e == null ? void 0 : e.map((S) => S.dbName)
            );
            return s.value = a.publishedRevByLocation || {}, s.value;
          },
          publishAtLocation: async (e) => {
            const a = await t.publishReasonDoc([e.dbName]);
            return s.value = a.publishedRevByLocation || {}, s.value;
          },
          unpublishAll: async () => s.value,
          unpublishAtLocation: async () => s.value
        },
        initialPublishedRev: s.value,
        locations: o.locations,
        enabledLocations: null,
        hideUnpublish: !0
      };
      c.open({
        title: "Publish reasons",
        contentComponent: Ee,
        contentComponentProps: u,
        closeButton: !0,
        minWidth: 700,
        maxHeight: "80vh",
        contentScrollable: !1,
        primaryActions: {
          text: l("common.close"),
          close: !0,
          variant: "tertiary"
        }
      });
    }
    async function $() {
      if (i.value = [], !!o._currentLocation) {
        m.value = !0;
        try {
          const [u, e, a] = await Promise.all([
            t.readTemplates(),
            t.getRecentPublishingJob(),
            t.getRecentPublishInfo()
          ]).delayed(1e3);
          i.value = u, d.value = e, s.value = (a == null ? void 0 : a.publishedRevByLocation) || {}, await h();
        } catch (u) {
          console.log("Something went wrong when fetching templates:", u);
        } finally {
          m.value = !1;
        }
      }
    }
    async function b(u) {
      if (!i.value.find((e) => e._id) && o._currentLocation) {
        m.value = !0;
        try {
          const [e] = await Promise.all([
            t.getTemplate(u),
            new Promise((a) => setTimeout(a, 1e3))
          ]);
          i.value = [e];
        } catch (e) {
          console.log("Something went wrong when fetching templates:", e);
        } finally {
          m.value = !1;
        }
      }
    }
    function n(u, e) {
      switch (e = ze(e), u) {
        case B.Details:
          return v.viewTemplate(e);
        case B.Edit:
          return v.updateTemplate(e);
        case B.Delete:
          return v.deleteTemplate(e, m, $);
        case B.Publish:
          return w(e);
        case B.Duplicate:
          return v.duplicateTemplate(e, m, $);
      }
    }
    return {
      columnDefs: [
        {
          id: "_id",
          accessorKey: "_id",
          header: () => l("inventory.adjustment.template.table.createdAt"),
          cell(u) {
            return it(`${u.getValue()}`);
          },
          enableSorting: !0
        },
        {
          id: "name",
          accessorKey: "name",
          header: () => l("inventory.adjustment.template.table.name"),
          enableSorting: !0,
          size: 200
        },
        {
          id: "noOfItems",
          accessorKey: "items.length",
          header: () => l("inventory.adjustment.template.table.noOfItems"),
          enableSorting: !1,
          meta: {
            width: "10rem",
            textAlign: "right"
          }
        },
        {
          id: "enabledLocations",
          accessorKey: "locations.length",
          header: () => l("inventory.adjustment.template.table.enabledOutlets"),
          cell(u) {
            var a;
            const e = (a = u.row.original.locations) == null ? void 0 : a.length;
            return e ? `${e}` : "All";
          },
          enableSorting: !1,
          meta: {
            width: "10rem",
            textAlign: "right"
          }
        },
        {
          id: "status",
          header: () => l("inventory.adjustment.template.table.status"),
          enableSorting: !1,
          cell(u) {
            const e = u.row.original, S = (u.row.original.locations || o.locations).filter((C) => !!o.locationByDbName[C.dbName]), g = S.filter((C) => !!(s.value[C.dbName] || []).find(
              (U) => U._id === e._id && (U.updatedAt ? U.updatedAt === e.updatedAt : U._rev === e._rev)
            )).length, y = S.length > 0 && g === S.length;
            return E(
              "div",
              {
                class: "flex items-center gap-8"
              },
              E(
                "div",
                {
                  class: [
                    "fm-status-badge",
                    y ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
                  ]
                },
                y ? "Published" : "Unpublished"
              )
            );
          }
        },
        {
          id: "action",
          cell(u) {
            const e = u.row.original, a = [
              ae[B.Edit],
              ae[B.Duplicate],
              ae[B.Delete],
              ae[B.Publish]
            ];
            return rt(a, (S) => n(S, e));
          },
          enableSorting: !1,
          size: 40,
          meta: {
            cellClass: "",
            headerClass: ""
          }
        }
      ],
      recentPublish: d,
      templates: i,
      reasons: r,
      isReasonPublished: x,
      showReasonPublishDialog: T,
      loading: m,
      fetchTemplates: $,
      loadTemplate: b
    };
  }
);
var he = /* @__PURE__ */ ((p) => (p.Ingredients = "Ingredients", p))(he || {});
function Ye(p, l, c) {
  var d, i, m;
  const v = [];
  if (p.type == L.Enum.sku) {
    const o = new Set(p.disabledMeasurements), t = (d = l.sku) == null ? void 0 : d.find((s) => s._id === p.id);
    if (t) {
      const s = {
        type: p.type,
        code: p.code,
        name: p.name,
        unit: t.unit.abbrev,
        enabled: !o.has(t.unit._id)
      };
      v.push(
        s,
        ...t.unit.measurements.map((r) => ({
          unit: r.abbrev,
          enabled: !o.has(r.id)
        }))
      );
    }
  }
  return p.type == L.Enum.recipe && ((i = l.recipe) != null && i.find((t) => t._id === p.id)) && v.push(p), p.type == L.Enum.menu && ((m = c == null ? void 0 : c.modules.item) != null && m.find((t) => t._id === p.id)) && v.push(p), v;
}
function Ge() {
  return [
    {
      id: "code",
      name: "Code"
    },
    {
      id: "type",
      name: "Type"
    },
    {
      id: "name",
      name: "Name"
    },
    {
      id: "unit",
      name: "Unit"
    },
    {
      id: "enabled",
      name: "Enabled (Unit)"
    }
  ];
}
function xt(p) {
  var s;
  const l = Ue(), c = Z(), v = c.menu.cache, d = l.currentBusiness.value, m = (s = p.map((r) => {
    var b;
    const h = r.items.flatMap(
      (n) => Ye(n, c.state.inventory, v)
    ), x = Ge(), w = [
      ["Template ID", r._id],
      ["Template name", r.name],
      ["Business name", d == null ? void 0 : d.name],
      ["Business ID", d == null ? void 0 : d._id],
      ["Menu version", d == null ? void 0 : d.menuVersion],
      [
        "Locations",
        ...(b = r.locations) != null && b.length ? r.locations.map((n) => `${n.name} (${n.dbName})`) : ["All"]
      ],
      //   ['Reference', template.ref ?? ''],
      [],
      x.map((n) => n.name),
      ...h.map((n) => x.map((f) => n[f.id]))
    ], T = x.map((n) => `system:${n.id}`), $ = fe(w, T);
    return { name: r.name, sheet: $ };
  }).reduce(
    (r, h) => {
      var w;
      const x = h.name.slice(0, 12);
      return (w = r.sheetOccurence)[x] ?? (w[x] = 0), r.sheetOccurence[x] += 1, r.sheets[`${x} (${r.sheetOccurence[x]})`] = h.sheet, r;
    },
    {
      sheets: {},
      sheetOccurence: {}
    }
  )) == null ? void 0 : s.sheets, o = `${d == null ? void 0 : d.name} adjustment templates (${ct(/* @__PURE__ */ new Date())}).xlsx`, t = Oe(m);
  return He(t, o), o;
}
function wt() {
  var b;
  const p = Ue(), l = Z(), c = dt(), v = (b = l.state.inventory.sku) == null ? void 0 : b[0];
  if (!v)
    throw new Error("No inventory items");
  const i = Ye(
    {
      type: L.Enum.sku,
      code: v.code,
      id: v._id,
      name: v.name
    },
    l.state.inventory,
    l.menu.cache
  )[0], m = p.currentBusiness.value, o = Ge(), t = [
    ["Template ID (leave empty to create new)", ""],
    ["Template Name", "New template"],
    ["Business name", m == null ? void 0 : m.name],
    ["Business ID", m == null ? void 0 : m._id],
    ["Menu version", m == null ? void 0 : m.menuVersion],
    [
      "Location codes (leave empty to enable all)",
      "Example outlet (restaurant_xxx)",
      "Example outlet 2 (restaurant_xxx)"
    ],
    // ['Reference:'],
    [],
    o.map((n) => n.name),
    o.map((n) => i[n.id])
  ], s = o.map((n) => `system:${n.id}`), r = fe(t, s), h = c.isEnabled ? c.state.setting.childItems ?? [] : [], x = h.reduce(
    (n, f) => {
      var g, y;
      const u = (g = c.netSuiteItemIdToSkuId.get(f.parentNetSuiteId)) == null ? void 0 : g[0], e = (y = c.netSuiteMeasurementIdToMeasurementId.get(
        f.unitOfMeasureId
      )) == null ? void 0 : y[0];
      if (!f.externalId)
        return n;
      if (!u)
        return console.error(`Item ${f.externalId} cannot be mapped to parent FdoInventorySku.`, f), n;
      const a = l.skuById[u], S = a.unit.measurements.find((C) => C.id === e);
      return S ? (n[f.externalId] = {
        sku: a,
        measurement: S
      }, n) : (console.error(
        `Item ${f.externalId} found parent FdoInventorySku of ${a.code} ${a.name} but the measurement of netsuite id ${f.unitOfMeasureId} cannot be found.`,
        f
      ), n);
    },
    {}
  ), w = fe(
    [
      ...l.skus.flatMap((n) => [
        [n.code, n.name, n.unit.abbrev, !0],
        ...n.unit.measurements.map((u) => [
          "",
          "",
          u.abbrev,
          !u.abbrev.toLocaleLowerCase("en-us").includes("inactive")
        ])
      ]),
      ...Object.entries(x).map(([n, { sku: f, measurement: u }]) => [
        f.code,
        f.name,
        u.abbrev,
        !u.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
        n
      ])
    ],
    [
      "Code",
      "Type",
      "Name",
      "Units",
      "Enabled (true/false)",
      ...h.length ? ["Netsuite Parent"] : []
    ]
  ), T = Oe({
    Template: r,
    Ingredients: w
  }), $ = `${m == null ? void 0 : m.name} transfer templates import.xlsx`;
  return He(T, $), $;
}
function Tt(p) {
  if (!p.length || `${p[0]}`.toLocaleLowerCase() === "all")
    return [];
  const l = /(.*) \(((warehouse_|restaurant_).{24,})\)/, v = ye().locationByDbName;
  return p.map((d) => {
    const i = new Array(), m = d.trim(), o = l.exec(m);
    if (!o)
      return i.push(`Enabled location value of ${m} cannot be read.`), {
        errors: i
      };
    const t = o[1], s = o[2], r = v[s];
    return r ? (t !== r.name && i.push(
      `Location id ${s} has non-matching name. Found ${t} but expected ${r.name}`
    ), {
      errors: i,
      location: r
    }) : (i.push(`Location (${t}) of id ${s} is not found.`), {
      errors: i
    });
  });
}
function kt(p) {
  const [
    l,
    c,
    v,
    d,
    i,
    m,
    o,
    t
  ] = We(p);
  return {
    id: `${c[1] ?? ""}`.trim(),
    name: `${v[1] ?? ""}`.trim(),
    locations: o.slice(1).map((s) => `${s}`.trim()).filter((s) => s),
    reference: `${t[1] ?? ""}`.trim()
  };
}
function $t(p) {
  const [
    l,
    c,
    v,
    d,
    i,
    m,
    o,
    t,
    s,
    ...r
  ] = We(p);
  if (!l || !l.length || l.some(($) => $.length && !$.startsWith("system:")))
    throw new Error("Missing meta header. Excel file does not come from the template.");
  const h = l.map(($) => $.split(":")[1]), w = [
    "code",
    "type",
    "name",
    "unit",
    "enabled"
  ].filter(($) => !h.includes($));
  if (w.length)
    throw new Error(
      `Missing meta headers (${w.join()}). Excel file does not come from the template.`
    );
  return r.map(($, b) => {
    const n = {};
    for (const f in h) {
      const u = h[f];
      Object.assign(n, { [u]: $[f] });
    }
    return {
      index: b,
      data: n
    };
  });
}
function St(p) {
  return p.reduce(
    (l, c) => {
      var i;
      const v = c.data, d = c.index;
      if (v.type == L.Enum.recipe)
        l.result.push({ parent: c, children: [] });
      else if (v.type == L.Enum.menu)
        v.code ? l.result.push({ parent: c, children: [] }) : l.errors.push(`Menu item row ${d + 9} does not have a code.`);
      else {
        if (!v.unit) return l;
        v.code ? l.result.push({ parent: c, children: [] }) : l.result.length ? (i = l.result.at(-1)) == null || i.children.push(c) : l.errors.push(`Cannot find parent for row ${d + 9}`);
      }
      return l;
    },
    { result: new Array(), errors: new Array() }
  );
}
function It(p) {
  var t;
  const l = p.parent.data, c = new Array(), v = Z();
  if (p.parent.data.type == L.Enum.menu) {
    const s = v.menu.cache, r = (t = s == null ? void 0 : s.modules.item) == null ? void 0 : t.find((x) => x.code === l.code);
    if (!r)
      return c.push(`Cannot find menu module of id ${l.code}`), { errors: c };
    const h = {
      type: L.Enum.menu,
      code: r.code,
      id: r._id,
      name: r.name ?? ""
    };
    return { errors: c, templateItem: h };
  }
  if (p.parent.data.type == L.Enum.recipe) {
    const r = v.recipes.find((x) => x.name === l.name);
    if (!r)
      return c.push(`Cannot find recipe module of id ${l.code}`), { errors: c };
    const h = {
      type: L.Enum.recipe,
      id: r._id,
      name: r.name ?? ""
    };
    return { errors: c, templateItem: h };
  }
  const d = v.skuByCode[l.code ?? ""];
  if (!d)
    return c.push(`Cannot find ingredient of code [${l.code}] [${l.name}]`), { errors: c };
  const i = {
    type: L.Enum.sku,
    code: l.code,
    id: d._id,
    name: l.name ?? "",
    disabledMeasurements: []
  }, m = d.unit.measurements.find((s) => s.abbrev === l.unit);
  l.unit !== d.unit.abbrev && !m ? c.push(
    `Cannot find measurement unit of ${l.unit} for (${l.code}) ${l.name}.`
  ) : (!l.enabled || `${l.enabled}`.toLocaleLowerCase() === "false") && (i.disabledMeasurements ?? (i.disabledMeasurements = []), i.disabledMeasurements.push((m == null ? void 0 : m.id) ?? d.unit._id));
  for (const s of p.children) {
    const r = s.data, h = r.unit === d.unit.abbrev ? d.unit : void 0, x = d.unit.measurements.find((w) => w.abbrev === r.unit);
    if (!x && !h) {
      c.push(
        `Cannot find measurement unit of ${r.unit} for (${l.code}) ${l.name}.`
      );
      continue;
    }
    (!r.enabled || `${r.enabled}`.toLocaleLowerCase() === "false") && (i.disabledMeasurements ?? (i.disabledMeasurements = []), i.disabledMeasurements.push((x == null ? void 0 : x.id) ?? (h == null ? void 0 : h._id) ?? ""));
  }
  const o = new Set(i.disabledMeasurements);
  return o.has(d.unit._id) && d.unit.measurements.every((s) => o.has(s.id)) && c.push(`Ingredient ${d.code} - ${d.name} must have at least one unit enabled.`), { errors: c, templateItem: i };
}
function At(p) {
  const l = p.SheetNames.filter(
    (i) => !Object.values(he).map(String).includes(i)
  ), v = me().templates, d = lt(v, "_id");
  try {
    return l.reduce(
      (m, o) => {
        const t = new Array(), s = p.Sheets[o], r = kt(s), h = Tt(r.locations), x = h.filter((u) => u.location).map((u) => u.location);
        t.push(...h.flatMap((u) => u.errors));
        const w = $t(s).filter((u) => {
          const e = u.data;
          return e.type == L.Enum.menu ? e.code : e.type == L.Enum.recipe ? e.name : u.data.code || u.data.unit;
        }), T = St(w);
        t.push(...T.errors);
        const $ = T.result.map(
          (u) => It(u)
        );
        t.push(...$.flatMap((u) => u.errors));
        const b = $.filter((u) => u.templateItem).map((u) => u.templateItem);
        if (r.id) {
          const u = d[r.id];
          if (!u) {
            const a = {
              type: pe.Enum.WASTAGE,
              _id: r.id,
              _rev: "",
              name: r.name || `(unnamed from sheet ${o || "<unnamed sheet>"})`,
              items: []
            };
            return t.push(`Template ID ${r.id} is not found.`), m.importUpdateResult.push({
              type: "update",
              original: a,
              template: a,
              excelSheetName: o,
              errors: t
            }), m;
          }
          const e = {
            type: "update",
            original: u,
            template: {
              ...u,
              name: r.name,
              locations: x.length ? x : null,
              items: b
            },
            excelSheetName: o,
            errors: t
          };
          return m.importUpdateResult.push(e), m;
        }
        const f = {
          type: "create",
          template: {
            type: pe.Enum.WASTAGE,
            name: r.name,
            locations: x.length ? x : null,
            items: b
          },
          excelSheetName: o,
          errors: t
        };
        return m.importCreateResult.push(f), m;
      },
      {
        invalidExcel: !1,
        importCreateResult: new Array(),
        importUpdateResult: new Array()
      }
    );
  } catch (i) {
    return {
      invalidExcel: !0,
      invalidExcelMessage: (i == null ? void 0 : i.message) ?? "Invalid excel",
      importCreateResult: [],
      importUpdateResult: []
    };
  }
}
const Ft = { class: "flex" }, Ct = { class: "flex flex-col flex-1" }, Rt = { class: "flex flex-col" }, Dt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Mt = {
  key: 0,
  class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
}, Et = { key: 0 }, Pt = { class: "ml-auto" }, Vt = { key: 0 }, Pe = /* @__PURE__ */ Y({
  __name: "AdjustmentTemplateImportItem",
  props: {
    type: {},
    name: {},
    locations: {},
    items: {},
    errors: {}
  },
  setup(p) {
    const l = p, { t: c } = G(), v = R(!1), d = () => {
      l.errors.length && (v.value = !v.value);
    };
    return (i, m) => {
      var t, s, r;
      const o = M("FmIcon");
      return A(), D("div", Ft, [
        m[0] || (m[0] = _("div", null, "•", -1)),
        _("div", Ct, [
          _("div", {
            class: K(["flex items-center gap-12 pl-8", {
              "cursor-pointer": i.errors.length
            }]),
            onClick: d
          }, [
            _("div", Rt, [
              _("div", Dt, [
                _("div", {
                  class: K({
                    "text-fm-color-system-error-300": i.errors.length
                  })
                }, [
                  re(V(i.name) + " ", 1),
                  i.type === "create" ? (A(), D("span", Mt, "(" + V(k(c)("inventory.closing.template.import.new")) + ")", 1)) : z("", !0)
                ], 2),
                i.errors.length ? (A(), D("div", Et, [
                  F(o, {
                    name: "error",
                    size: "sm",
                    color: "system-error-300"
                  })
                ])) : z("", !0)
              ]),
              _("div", {
                class: K([
                  "fm-typo-en-body-sm-400",
                  {
                    "text-fm-color-system-error-200": i.errors.length,
                    "text-fm-color-typo-secondary": !i.errors.length
                  }
                ])
              }, V((t = i.locations) != null && t.length ? k(c)("inventory.closing.template.import.nLocations", { count: (s = i.locations) == null ? void 0 : s.length }) : k(c)("inventory.closing.template.import.allLocations")) + ", " + V(k(c)("inventory.closing.template.import.nItems", { count: (r = i.items) == null ? void 0 : r.length })), 3)
            ]),
            _("div", Pt, [
              i.errors.length ? (A(), O(o, {
                key: 0,
                name: v.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
                size: "md"
              }, null, 8, ["name"])) : z("", !0)
            ])
          ], 2),
          v.value ? (A(), D("div", {
            key: 0,
            class: K(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
              "text-fm-color-typo-secondary": !i.errors.length,
              "text-fm-color-system-error-300": i.errors.length
            }])
          }, [
            i.errors.length ? (A(), D("div", Vt, [
              _("ol", null, [
                (A(!0), D(W, null, Q(i.errors, (h, x) => (A(), D("li", { key: x }, V(h), 1))), 128))
              ])
            ])) : z("", !0)
          ], 2)) : z("", !0)
        ])
      ]);
    };
  }
}), jt = { class: "flex flex-col gap-24" }, Ut = { class: "fm-typo-en-body-md-400" }, Lt = {
  key: 0,
  class: "flex items-center gap-8"
}, Nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bt = { class: "flex flex-col gap-8" }, zt = { class: "line-clamp-2 text-ellipsis break-all" }, Ot = {
  key: 2,
  class: "shrink-0"
}, Ht = {
  key: 0,
  class: "flex flex-col"
}, Wt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Kt = {
  key: 0,
  class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
}, Yt = { class: "fm-typo-en-body-lg-600" }, Gt = /* @__PURE__ */ Y({
  __name: "AdjustmentTemplateImport",
  setup(p) {
    const l = R(null), c = ot(), v = ue(), d = R(!1), i = R(!1), m = R(new Array()), o = R([]), t = R([]), s = N(
      () => !!m.value.length || o.value.some((w) => w.errors.length) || t.value.some((w) => w.errors.length)
    ), r = N(
      () => !!o.value.length || !!t.value.length
    ), { t: h } = G();
    async function x(w) {
      m.value = [], o.value = [], t.value = [];
      try {
        d.value = !0;
        const [T] = await Promise.all([
          ut(w),
          // fake buffer
          new Promise((f) => setTimeout(f, 1e3))
        ]);
        if (!T.SheetNames.filter(
          (f) => !Object.values(he).map(String).includes(f)
        ).find((f) => f)) {
          m.value.push(h("inventory.ingredient.import.fileError.noSheet"));
          return;
        }
        const n = At(T);
        if (n.invalidExcel) {
          m.value.push(
            n.invalidExcelMessage ?? h("inventory.ingredient.import.fileError.invalidExcel")
          );
          return;
        }
        if (o.value = n.importCreateResult, t.value = n.importUpdateResult, !o.value.length && !t.value.length) {
          m.value.push(h("inventory.ingredient.import.fileError.noData"));
          return;
        }
        c.emitData(n);
      } catch (T) {
        v.open({
          title: h("inventory.ingredient.import.fileError.unableToRead"),
          message: T == null ? void 0 : T.message,
          type: "error"
        }), console.error("Error in reading file", T);
      } finally {
        m.value.length && v.open({
          title: h("inventory.ingredient.import.fileError.invalidExcel"),
          type: "error"
        }), d.value = !1;
      }
    }
    return ie(l, (w) => {
      w && x(w);
    }), (w, T) => {
      const $ = M("FmCircularProgress"), b = M("FmIcon"), n = M("FmButton");
      return A(), D("div", jt, [
        _("div", Ut, V(k(h)("inventory.adjustment.template.import.message")), 1),
        i.value ? (A(), D("div", Lt, [
          _("div", null, [
            F($, {
              size: "md",
              color: "neutral-gray-200"
            })
          ]),
          _("div", Nt, V(k(h)("inventory.formField.loading")), 1)
        ])) : (A(), D(W, { key: 1 }, [
          F(pt, {
            class: K({
              "w-full": !0,
              "h-[200px]": !l.value
            }),
            accept: ".xlsx",
            onFileUpload: T[0] || (T[0] = (f) => l.value = f),
            label: k(h)("inventory.ingredient.import.uploadTemplate"),
            "button-label": k(h)("inventory.ingredient.import.selectFile")
          }, Ve({ _: 2 }, [
            l.value ? {
              name: "default",
              fn: j(({ openFileDialog: f }) => [
                _("div", Bt, [
                  _("div", {
                    class: K([
                      "fm-corner-radius-md p-16 flex items-center gap-16",
                      {
                        "border border-fm-color-neutral-gray-100": d.value,
                        "border border-fm-color-neutral-gray-200": !d.value && !s.value,
                        "border border-fm-color-system-error-200": s.value
                      }
                    ])
                  }, [
                    d.value ? (A(), O($, {
                      key: 0,
                      size: "md",
                      color: "neutral-gray-200"
                    })) : (A(), O(b, {
                      key: 1,
                      name: s.value ? "error" : "attach_file",
                      outline: "",
                      color: s.value ? "system-error-300" : void 0
                    }, null, 8, ["name", "color"])),
                    _("div", {
                      class: K([
                        "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
                        {
                          "text-fm-color-typo-disabled": d.value,
                          "text-fm-color-typo-primary": !d.value
                        }
                      ])
                    }, [
                      _("div", zt, V(l.value.name), 1)
                    ], 2),
                    d.value ? z("", !0) : (A(), D("div", Ot, [
                      F(n, {
                        label: k(h)("inventory.ingredient.import.replaceFile"),
                        variant: s.value ? "destructive" : "secondary",
                        "prepend-icon": s.value ? void 0 : "autorenew",
                        onClick: f
                      }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
                    ]))
                  ], 2),
                  m.value.length ? (A(), D("div", Ht, [
                    (A(!0), D(W, null, Q(m.value, (u, e) => (A(), D("div", {
                      key: e,
                      class: "flex gap-8 items-center"
                    }, [
                      F(b, {
                        name: "error",
                        size: "sm",
                        color: "system-error-300"
                      }),
                      _("div", Wt, V(u), 1)
                    ]))), 128))
                  ])) : z("", !0)
                ])
              ]),
              key: "0"
            } : void 0
          ]), 1032, ["class", "label", "button-label"]),
          r.value ? (A(), D("div", Kt, [
            _("div", Yt, V(k(h)("inventory.ingredient.import.summary")), 1),
            (A(!0), D(W, null, Q(o.value, (f, u) => (A(), O(Pe, {
              key: u,
              name: f.template.name,
              locations: f.template.locations,
              items: f.template.items,
              errors: f.errors,
              type: "create"
            }, null, 8, ["name", "locations", "items", "errors"]))), 128)),
            (A(!0), D(W, null, Q(t.value, (f) => (A(), O(Pe, {
              key: f.template._id,
              name: f.template.name,
              locations: f.template.locations,
              items: f.template.items,
              errors: f.errors,
              type: "update"
            }, null, 8, ["name", "locations", "items", "errors"]))), 128))
          ])) : z("", !0)
        ], 64))
      ]);
    };
  }
}), ve = Ne("wastageTemplateAction", () => {
  const { t: p } = G(), l = X(), c = ue(), v = ce(), d = ft(), i = me(), { loading: m } = Be(i), o = R({});
  function t() {
    o.value = {
      mode: J.CREATE,
      show: !0,
      "onUpdate:show"(e) {
        o.value.show = e;
      }
    };
  }
  function s(e) {
    o.value = {
      mode: J.UPDATE,
      modelValue: e,
      show: !0,
      "onUpdate:show"(a) {
        o.value.show = a;
      }
    };
  }
  function r(e, a, S) {
    l.open({
      title: `Confirm deleting template ${e.name}?`,
      message: "Deleted template can no longer be retrieved",
      primaryActions: {
        text: "Delete",
        variant: q.Destructive,
        close: !0
      },
      secondaryActions: {
        text: "Cancel",
        variant: q.Plain,
        close: !0
      }
    }).onPrimary(async () => {
      c.open({
        title: `Deleting ${e.name}`,
        type: "info"
      });
      try {
        a.value = !0;
        const [g] = await Promise.allSettled([
          v.deleteTemplate(e),
          new Promise((y) => setTimeout(y, 1e3))
        ]);
        if (g.status === "rejected") throw g.reason;
        c.open({
          title: `Deleted "${e.name}"`,
          type: "success"
        });
      } catch (g) {
        c.open({
          title: `Unable to delete "${e.name}"`,
          message: g.message,
          type: "error"
        });
      } finally {
        a.value = !1, S();
      }
    });
  }
  function h(e, a, S) {
    l.open({
      title: `Confirm unpublishing template "${e.name}"?`,
      message: "Unpublished template will no longer be available at locations",
      primaryActions: {
        text: "Unpublish",
        variant: q.Destructive,
        close: !0
      },
      secondaryActions: {
        text: "Cancel",
        variant: q.Plain,
        close: !0
      }
    }).onPrimary(async () => {
      c.open({
        title: `Unpublishing "${e.name}"`,
        type: "info"
      });
      try {
        a.value = !0;
        const [g] = await Promise.allSettled([
          v.unpublishSingleDoc(e._id),
          new Promise((y) => setTimeout(y, 1e3))
        ]);
        if (g.status === "rejected") throw g.reason;
        c.open({
          title: `Unpublished "${e.name}"`,
          type: "success"
        });
      } catch (g) {
        c.open({
          title: `Unable to unpublish "${e.name}"`,
          message: `See error from server: ${g}`,
          type: "error"
        }), console.error("error on unpublishing adjustment template", g);
      } finally {
        a.value = !1, S();
      }
    });
  }
  function x(e, a, S) {
    let g;
    l.open({
      title: `Confirm duplicating template "${e.name}"?`,
      message: "Duplicated template can be edited after creation",
      primaryActions: {
        text: "Duplicate",
        variant: q.Destructive,
        close: !0
      },
      secondaryActions: {
        text: "Cancel",
        variant: q.Plain,
        close: !0
      },
      contentComponent: Y({
        props: ["modelValue"],
        emits: ["update:modelValue"],
        setup(y) {
          return () => E(H.FmTextField, {
            modelValue: y.modelValue,
            "onUpdate:modelValue": (C) => g = C,
            label: "New Template Name",
            size: "md",
            variant: "primary"
          });
        }
      })
    }).onPrimary(async () => {
      c.open({
        title: `Duplicating "${e.name}"`,
        type: "info"
      });
      try {
        a.value = !0;
        const [y] = await Promise.allSettled([
          d.duplicateWastagetemplate(e._id, g),
          new Promise((C) => setTimeout(C, 1e3))
        ]);
        if (y.status === "rejected") throw y.reason;
        c.open({
          title: `Duplicated "${e.name}"`,
          type: "success"
        });
      } catch (y) {
        c.open({
          title: `Unable to duplicate "${e.name}"`,
          message: `See error from server: ${y}`,
          type: "error"
        }), console.error("error on duplicating adjustment template", y);
      } finally {
        a.value = !1, S();
      }
    });
  }
  const w = R({});
  function T(e) {
    w.value = {
      template: e,
      show: !0,
      "onUpdate:show"(a) {
        w.value.show = a;
      },
      "onAction:edit"() {
        w.value.show = !1, s(ze(e));
      }
    };
  }
  function $() {
    if (!i.templates.length) {
      c.open({
        title: "No data to export",
        type: "error"
      });
      return;
    }
    const e = xt(i.templates);
    c.open({
      title: p("inventory.ingredient.export.success"),
      message: p("inventory.ingredient.export.filename", [e]),
      type: "success"
    });
  }
  function b() {
    i.loading || l.open({
      title: p("inventory.adjustment.template.import.title"),
      contentComponent: Gt,
      overlay: !0,
      closeButton: !0,
      primaryActions: {
        text: p("common.import"),
        close: !1
      },
      secondaryActions: {
        text: p("common.close"),
        close: !0
      },
      tertiaryActions: {
        text: p("inventory.ingredient.import.actions.downloadTemplate"),
        close: !1,
        variant: "plain"
      }
    }).onPrimary((e) => {
      if (!e) {
        c.open({
          title: p("inventory.ingredient.import.error.noData"),
          type: "error"
        });
        return;
      }
      if (!e.importCreateResult.length && !e.importUpdateResult.length) {
        c.open({
          title: p("inventory.ingredient.import.error.invalidContent"),
          message: p("inventory.ingredient.import.error.noImportData"),
          type: "error"
        });
        return;
      }
      if (e.importCreateResult.some((a) => a.errors.length) || e.importUpdateResult.some((a) => a.errors.length)) {
        c.open({
          title: p("inventory.ingredient.import.error.invalidContent"),
          message: p("inventory.ingredient.import.error.hasErrors"),
          type: "error"
        });
        return;
      }
      l.close(), n(e);
    }).onTertiary(wt);
  }
  async function n(e) {
    m.value = !0;
    try {
      const a = [
        ...e.importCreateResult.map(
          (C) => C.template
        ),
        ...e.importUpdateResult.map(
          (C) => C.template
        )
      ], S = 100;
      let g = 0;
      const y = () => {
        g += S, c.open({
          title: p("inventory.ingredient.import.progress", [
            Math.min(g, a.length),
            a.length
          ])
        });
      };
      for (const C of a.chunk(100))
        y(), await v.importTemplates(C);
      c.open({
        title: p("inventory.ingredient.import.success"),
        type: "success"
      });
    } catch (a) {
      c.open({
        title: p("inventory.ingredient.import.error.failed"),
        message: p("inventory.ingredient.import.error.systemMessage", [a == null ? void 0 : a.message]),
        type: "error"
      }), console.error("Error in importing skus", e, a);
    } finally {
      m.value = !1, i.fetchTemplates();
    }
  }
  const f = R({});
  function u() {
    f.value = {
      show: !0,
      "onUpdate:show"(e) {
        f.value.show = e;
      }
    };
  }
  return {
    createTemplate: t,
    viewTemplate: T,
    updateTemplate: s,
    deleteTemplate: r,
    unpublishTemplate: h,
    duplicateTemplate: x,
    exportTemplates: $,
    importTemplates: b,
    viewReason: u,
    templateDialogProps: o,
    templateDetailsProps: w,
    templateReasonProps: f
  };
});
function Jt(p) {
  const l = Z(), c = N(() => {
    const i = /* @__PURE__ */ new Map();
    for (const m of l.skus)
      i.set(m._id, m);
    return i;
  }), v = N(() => {
    const i = [];
    for (const m of p.items)
      m.type === "sku" && (c.value.get(m.id) || i.push(m));
    return i;
  });
  return {
    columnDefs: N(() => {
      const i = p.items.map((o) => {
        if (o.type !== "sku") return 0;
        const t = c.value.get(o.id);
        return t ? t.unit.measurements.length : 0;
      }).reduce((o, t) => Math.max(o, t), 0);
      return [
        {
          id: "Delete",
          header: "",
          cell(o) {
            const t = o.row.original;
            return E(
              "div",
              { class: "w-full flex justify-end" },
              E(H.FmButton, {
                class: "delete-button",
                key: t.id,
                type: "button",
                icon: "delete",
                variant: "tertiary",
                size: "md",
                disabled: p.disabled,
                onClick: () => {
                  p.deleteItem(t);
                }
              })
            );
          },
          enableSorting: !1,
          size: 40,
          meta: {
            cellClass: "",
            headerClass: ""
          }
        },
        {
          id: "Name",
          header: () => "Name",
          enableSorting: !1,
          size: 400,
          minSize: 400,
          accessorFn: (o) => `${o.name} ${o.code}`,
          cell(o) {
            const t = o.row.original;
            return E("div", { class: "flex", style: { minWidth: "400px" } }, [
              E(
                "div",
                {
                  class: "flex flex-col grow"
                },
                [
                  E(
                    H.FmTooltip,
                    {
                      content: t.name,
                      placement: "top",
                      variant: "plain",
                      zIndex: 50
                    },
                    E(
                      "span",
                      {
                        class: "flex-auto fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1"
                      },
                      t.name
                    )
                  ),
                  E(
                    "span",
                    { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
                    t.code ?? ""
                  )
                ]
              ),
              E(
                "div",
                {
                  class: "flex flex-col justify-center"
                },
                [
                  E(
                    H.FmChip,
                    {
                      compact: !0
                    },
                    t.type === "sku" ? "Ingredient" : t.type === "recipe" ? "Recipe" : "Menu"
                  )
                ]
              )
            ]);
          }
        },
        {
          id: "Unit",
          header: () => "Enable unit",
          enableSorting: !1,
          minSize: 200,
          maxSize: 400,
          cell(o) {
            var r, h, x;
            const t = o.row.original;
            if (t.type !== "sku") return E("span", "N/A");
            const s = c.value.get(t.id);
            return E("div", { class: "flex items-center gap-32" }, [
              E(
                H.FmFormGroup,
                {
                  value: s.unit._id,
                  modelValue: !((r = t.disabledMeasurements) != null && r.includes(s.unit._id))
                },
                E(
                  "div",
                  {
                    class: "flex items-center gap-4",
                    style: { width: "120px" }
                  },
                  [
                    E(H.FmCheckbox, {
                      value: s.unit._id,
                      modelValue: !((h = t.disabledMeasurements) != null && h.includes(s.unit._id)),
                      disabled: p.disabled || !((x = t.disabledMeasurements) != null && x.includes(s.unit._id)) && s.unit.measurements.every(
                        (w) => {
                          var T;
                          return (T = t.disabledMeasurements) == null ? void 0 : T.includes(w.id);
                        }
                      ),
                      "onUpdate:modelValue"(w) {
                        var T;
                        if (console.log("active", w), w)
                          p.updateItem({
                            ...t,
                            disabledMeasurements: (T = t.disabledMeasurements) == null ? void 0 : T.filter(
                              ($) => $ !== s.unit._id
                            )
                          });
                        else {
                          const $ = t.disabledMeasurements ?? [];
                          p.updateItem({
                            ...t,
                            disabledMeasurements: [...$, s.unit._id]
                          });
                        }
                      }
                    }),
                    E(
                      H.FmTooltip,
                      { zIndex: 51 },
                      {
                        content() {
                          return c.value.get(t.id).unit.abbrev;
                        },
                        default() {
                          const w = c.value.get(t.id);
                          return E(
                            "div",
                            { class: "line-clamp-2 fm-typo-en-body-lg-400" },
                            w.unit.abbrev
                          );
                        }
                      }
                    )
                  ]
                )
              ),
              ...Array.from({ length: Math.max(i, 0) }).map((w, T) => {
                var f, u, e, a;
                const $ = o.row.original, b = c.value.get($.id), n = b.unit.measurements[T];
                return n ? E(
                  H.FmFormGroup,
                  {
                    modelValue: !((f = $.disabledMeasurements) != null && f.includes(n.id)),
                    value: n.id
                  },
                  E(
                    "div",
                    {
                      class: "flex items-center gap-4",
                      style: { width: "120px" }
                    },
                    [
                      E(H.FmCheckbox, {
                        value: n.id,
                        modelValue: !((u = $.disabledMeasurements) != null && u.includes(n.id)),
                        disabled: p.disabled || !((e = $.disabledMeasurements) != null && e.includes(n.id)) && ((a = $.disabledMeasurements) == null ? void 0 : a.includes(b.unit._id)) && b.unit.measurements.filter((S) => S.id != n.id).every((S) => {
                          var g;
                          return (g = $.disabledMeasurements) == null ? void 0 : g.includes(S.id);
                        }),
                        "onUpdate:modelValue"(S) {
                          var g;
                          if (console.log("active", S), S)
                            p.updateItem({
                              ...$,
                              disabledMeasurements: (g = $.disabledMeasurements) == null ? void 0 : g.filter(
                                (y) => y !== n.id
                              )
                            });
                          else {
                            const y = $.disabledMeasurements ?? [];
                            p.updateItem({
                              ...$,
                              disabledMeasurements: [...y, n.id]
                            });
                          }
                        }
                      }),
                      E(
                        H.FmTooltip,
                        { zIndex: 51 },
                        {
                          content() {
                            return n.abbrev;
                          },
                          default() {
                            return E(
                              "div",
                              { class: "line-clamp-2 fm-typo-en-body-lg-400" },
                              n.abbrev
                            );
                          }
                        }
                      )
                    ]
                  )
                ) : null;
              })
            ]);
          }
        }
      ];
    }),
    missingSKUs: v
  };
}
const qt = { class: "flex flex-col gap-16" }, Qt = { class: "flex items-center" }, Xt = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Zt = {
  key: 0,
  class: "flex flex-col gap-8 p-16 bg-fm-color-system-warning-100 border border-fm-color-system-warning-400 rounded-lg"
}, en = { class: "fm-typo-en-title-xs-600 text-fm-color-system-warning-400 flex items-center gap-8" }, tn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, nn = { class: "list-disc pl-20 mt-8" }, on = /* @__PURE__ */ Y({
  __name: "WastageTemplateItemTable",
  props: {
    modelValue: {},
    disabled: { type: Boolean }
  },
  emits: ["update:modelValue"],
  setup(p, { expose: l, emit: c }) {
    const v = p, d = R(v.modelValue), { t: i } = G(), m = c, o = Z(), t = X(), s = R(), r = R("");
    l({
      validateInputs: () => {
        var b, n;
        (n = (b = s.value) == null ? void 0 : b.validateInputs) == null || n.call(b);
      },
      resetInputsValidation: () => {
        var b, n;
        (n = (b = s.value) == null ? void 0 : b.resetInputsValidation) == null || n.call(b);
      },
      resetInputs: () => {
        var b, n;
        (n = (b = s.value) == null ? void 0 : b.resetInputs) == null || n.call(b);
      }
    });
    const h = Jt({
      updateItem: (b) => {
        d.value = d.value.map((n) => n.id !== b.id ? n : b), m("update:modelValue", T.value);
      },
      deleteItem: (b) => {
        d.value = d.value.filter((n) => n.id !== b.id), m("update:modelValue", T.value);
      },
      get items() {
        return d.value;
      },
      get disabled() {
        return v.disabled;
      }
    }), x = N(() => h.columnDefs.value), w = N(() => h.missingSKUs.value), T = N(() => {
      const b = new Set(w.value.map((n) => n.id));
      return d.value.filter((n) => !b.has(n.id));
    });
    ie(
      () => T.value,
      (b, n) => {
        w.value.length > 0 && JSON.stringify(b) !== JSON.stringify(n) && m("update:modelValue", b);
      },
      { immediate: !0 }
    );
    function $() {
      var g;
      const b = o.skus.map((y) => {
        var C, I;
        return {
          type: "sku",
          name: y.name,
          description: y.code,
          data: y,
          searchKeys: (C = y.customAttributes) != null && C.tag ? [(I = y.customAttributes) == null ? void 0 : I.tag] : void 0
        };
      }), n = o.recipes.map((y) => {
        var C, I;
        return {
          type: "recipe",
          name: y.name,
          description: "",
          data: y,
          searchKeys: (C = y.customAttributes) != null && C.tag ? [(I = y.customAttributes) == null ? void 0 : I.tag] : void 0
        };
      }), f = ((g = o.menu.cache) == null ? void 0 : g.modules.item.map((y) => ({
        type: "menu",
        name: y.name,
        description: `${y.code}`,
        data: y
      }))) ?? [], u = [...b, ...n, ...f].map((y) => {
        var I;
        const C = [y.type == "sku" ? "Ingredient" : y.type == "recipe" ? "Recipe" : "Menu"];
        if (y.type == "sku" || y.type == "recipe") {
          const U = (I = y.data.customAttributes) == null ? void 0 : I.tag;
          U && C.push(U);
        }
        return {
          label: y.name,
          sublabel: y.description,
          value: y,
          tags: C,
          searchKeys: y.searchKeys
        };
      }), e = /* @__PURE__ */ new Set();
      u.forEach((y) => {
        y.tags && y.tags.forEach((C) => {
          e.add(C);
        });
      });
      const a = e.size > 0 ? [
        {
          type: "string",
          key: "tags",
          entity: "item",
          values: Array.from(e)
        }
      ] : [], S = u.filter((y) => d.value.find((C) => C.id === y.value.data._id)).map((y) => y.value);
      t.open({
        title: i("inventory.closing.form.items.selectItem"),
        closeButton: !0,
        contentComponent: gt,
        contentComponentProps: {
          modelValue: S,
          items: u,
          virtualScroll: !0,
          filterAttributes: a
        },
        primaryActions: {
          text: i("common.confirm"),
          close: !0
        },
        secondaryActions: {
          text: i("common.close"),
          close: !0,
          variant: "tertiary"
        }
      }).onPrimary((y) => {
        const C = d.value ?? [], I = y.map((P) => {
          const U = C.find((ee) => ee.id === P.data._id);
          return U ? {
            ...U
          } : {
            id: P.data._id,
            name: P.name,
            code: P.description,
            type: P.type,
            disabledMeasurements: []
          };
        });
        I.sort((P, U) => P.name.localeCompare(U.name)), console.log(d.value), d.value = I, m("update:modelValue", T.value);
      });
    }
    return (b, n) => {
      const f = M("FmButton"), u = M("FmIcon"), e = M("FmTextField"), a = M("FmTable"), S = M("FmFormGroup");
      return A(), D("div", qt, [
        _("div", Qt, [
          _("div", Xt, V(k(i)("inventory.closing.form.items.title")), 1),
          F(f, {
            disabled: b.disabled,
            label: k(i)("inventory.closing.form.items.addItem"),
            "prepend-icon": "add",
            variant: "plain",
            class: "border-2 rounded-lg border-fm-color-primary",
            onClick: n[0] || (n[0] = (g) => $()),
            size: "md"
          }, null, 8, ["disabled", "label"])
        ]),
        w.value.length > 0 ? (A(), D("div", Zt, [
          _("div", en, [
            F(u, {
              name: "warning",
              size: "sm"
            }),
            n[3] || (n[3] = _("span", null, "Invalid items", -1))
          ]),
          _("div", tn, [
            re(" The following " + V(w.value.length) + " item(s) no longer exist in the system and have been excluded: ", 1),
            _("ul", nn, [
              (A(!0), D(W, null, Q(w.value, (g) => (A(), D("li", {
                key: g.id
              }, "(" + V(g.code) + ") " + V(g.name), 1))), 128))
            ])
          ])
        ])) : z("", !0),
        F(e, {
          placeholder: "Filter items",
          modelValue: r.value,
          "onUpdate:modelValue": n[2] || (n[2] = (g) => r.value = g)
        }, Ve({ _: 2 }, [
          r.value ? {
            name: "append",
            fn: j(() => [
              F(u, {
                name: "close",
                onClick: n[1] || (n[1] = (g) => r.value = ""),
                class: "cursor-pointer"
              })
            ]),
            key: "0"
          } : void 0
        ]), 1032, ["modelValue"]),
        (A(), O(a, {
          "search-value": r.value,
          "column-defs": x.value,
          "row-data": T.value,
          key: T.value.map((g) => g.id).join("."),
          "hide-footer": T.value.length <= 10,
          "page-size": Math.min(10, T.value.length)
        }, null, 8, ["search-value", "column-defs", "row-data", "hide-footer", "page-size"])),
        F(S, {
          "model-value": T.value.length,
          rules: [k(vt)(1)]
        }, null, 8, ["model-value", "rules"])
      ]);
    };
  }
}), sn = { class: "flex flex-col gap-16" }, an = { class: "flex flex-col gap-24" }, ln = { class: "flex flex-col gap-16" }, rn = { class: "flex items-center" }, un = { class: "flex-1 fm-typo-en-title-sm-600" }, cn = /* @__PURE__ */ Y({
  __name: "WastageTemplateForm",
  props: {
    modelValue: {},
    disabled: { type: Boolean }
  },
  setup(p, { expose: l }) {
    const c = yt(), { t: v } = G(), {
      promptSelectLocations: d,
      columnDefs: i,
      rowData: m
    } = ht({
      getLocations() {
        return c.locations;
      },
      setLocations(t) {
        c.locations = t;
      }
    }), o = R();
    return l({
      validateInputs: () => {
        var t, s;
        (s = (t = o.value) == null ? void 0 : t.validateInputs) == null || s.call(t);
      },
      resetInputsValidation: () => {
        var t, s;
        (s = (t = o.value) == null ? void 0 : t.resetInputsValidation) == null || s.call(t);
      },
      resetInputs: () => {
        var t, s;
        (s = (t = o.value) == null ? void 0 : t.resetInputs) == null || s.call(t);
      }
    }), (t, s) => {
      const r = M("FmTextField"), h = M("FmButton"), x = M("FmTable"), w = M("FmForm");
      return A(), O(w, {
        ref_key: "formRef",
        ref: o,
        class: "flex flex-col gap-32",
        disabled: t.disabled
      }, {
        default: j(() => [
          _("div", sn, [
            _("div", an, [
              F(r, {
                label: k(v)("inventory.closing.form.name"),
                "label-mark": "required",
                modelValue: k(c).name,
                "onUpdate:modelValue": s[0] || (s[0] = (T) => k(c).name = T),
                rules: [k(Ke)()]
              }, null, 8, ["label", "modelValue", "rules"])
            ])
          ]),
          _("div", ln, [
            _("div", rn, [
              _("div", un, V(k(v)("inventory.closing.form.locations")), 1),
              F(h, {
                disabled: t.disabled,
                label: k(v)("inventory.closing.form.selectLocation"),
                "prepend-icon": "add",
                variant: "plain",
                class: "border-2 rounded-lg border-fm-color-primary",
                onClick: k(d)
              }, null, 8, ["disabled", "label", "onClick"])
            ]),
            F(x, {
              "column-defs": k(i),
              "row-data": k(m),
              "shrink-at": 9999,
              onRowClick: k(d),
              "hide-footer": ""
            }, null, 8, ["column-defs", "row-data", "onRowClick"])
          ]),
          F(on, {
            "model-value": k(c).items,
            "onUpdate:modelValue": s[1] || (s[1] = (T) => k(c).items = T)
          }, null, 8, ["model-value"])
        ]),
        _: 1
      }, 8, ["disabled"]);
    };
  }
}), mn = { class: "flex items-center" }, dn = { class: "fm-typo-en-title-md-600" }, pn = { class: "flex justify-between" }, fn = { class: "fm-typo-en-body-lg-600" }, vn = { class: "flex flex-col gap-8" }, yn = { class: "flex flex-col gap-4" }, hn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, gn = { class: "flex items-center gap-8" }, bn = { class: "fm-typo-en-body-lg-600" }, _n = { class: "flex gap-4" }, xn = /* @__PURE__ */ Y({
  __name: "WastageTemplateDialog",
  props: {
    mode: {},
    modelValue: {},
    show: { type: Boolean }
  },
  emits: ["update:show", "submitted"],
  setup(p, { expose: l, emit: c }) {
    var u;
    const v = p, d = c, i = ce(), m = ue(), { t: o } = G(), t = Le(v, "show");
    function s() {
      return {
        _id: "",
        name: "",
        type: pe.Enum.WASTAGE,
        items: []
      };
    }
    const r = R(v.modelValue ?? s()), h = R(((u = v.modelValue) == null ? void 0 : u._id) ?? `${Math.random()}`);
    ie(
      () => v.show,
      (e) => {
        var a;
        e && (r.value = v.modelValue ?? s(), h.value = ((a = v.modelValue) == null ? void 0 : a._id) ?? `${Math.random()}`);
      }
    );
    const x = R(!1), w = N(() => {
      switch (v.mode) {
        case J.READ:
          return "";
        case J.CREATE:
          return o("inventory.adjustment.template.create.title");
        case J.UPDATE:
          return o("inventory.adjustment.template.update.title");
      }
      return "";
    }), T = R();
    l({
      validateInputs: () => {
        var e, a;
        (a = (e = T.value) == null ? void 0 : e.validateInputs) == null || a.call(e);
      },
      resetInputsValidation: () => {
        var e, a;
        (a = (e = T.value) == null ? void 0 : e.resetInputsValidation) == null || a.call(e);
      },
      resetInputs: () => {
        var e, a;
        (a = (e = T.value) == null ? void 0 : e.resetInputs) == null || a.call(e);
      }
    });
    async function $() {
      const e = r.value;
      if (e) {
        x.value = !0;
        try {
          await i.createTemplate(e), await new Promise((a) => setTimeout(a, 1e3)), m.open({
            title: o("inventory.adjustment.template.create.success"),
            message: o("inventory.adjustment.template.create.successMessage"),
            type: "success"
          }), d("update:show", !1), d("submitted");
        } catch (a) {
          m.open({
            title: o("inventory.adjustment.template.create.error"),
            message: o("inventory.adjustment.template.create.errorMessage"),
            type: "error"
          }), console.error("Error in creating adjustment template", a);
        } finally {
          x.value = !1;
        }
      }
    }
    async function b() {
      const e = r.value;
      if (e) {
        x.value = !0;
        try {
          await i.updateTemplate({
            ...e,
            _rev: e._rev ?? ""
          }), await new Promise((a) => setTimeout(a, 1e3)), m.open({
            title: o("inventory.adjustment.template.update.success"),
            message: o("inventory.adjustment.template.update.successMessage"),
            type: "success"
          }), d("update:show", !1), d("submitted");
        } catch (a) {
          m.open({
            title: o("inventory.adjustment.template.update.error"),
            message: o("inventory.adjustment.template.update.errorMessage"),
            type: "error"
          }), console.error("Error in updating adjustment template", a);
        } finally {
          x.value = !1;
        }
      }
    }
    function n() {
      switch (v.mode) {
        case J.CREATE:
          return $();
        case J.UPDATE:
          return b();
      }
    }
    function f() {
      var e, a;
      (a = (e = T.value) == null ? void 0 : e.validateInputs) == null || a.call(e);
    }
    return (e, a) => {
      const S = M("FmMenuDivider"), g = M("FmCard"), y = M("FmButton"), C = M("FmSideSheet");
      return A(), O(C, {
        modelValue: k(t),
        "onUpdate:modelValue": a[2] || (a[2] = (I) => je(t) ? t.value = I : null),
        "dismiss-away": "",
        "close-button": "",
        "max-width": 800
      }, {
        "side-sheet-header": j(() => [
          _("div", mn, [
            _("div", dn, V(w.value), 1)
          ])
        ]),
        default: j(() => [
          r.value.updatedAt ? (A(), D(W, { key: 0 }, [
            r.value.updatedAt ? (A(), O(g, {
              key: 0,
              variant: "outlined",
              class: "flex flex-col gap-8 px-12 py-16 mb-16"
            }, {
              default: j(() => {
                var I;
                return [
                  _("div", pn, [
                    _("div", fn, V(k(o)("inventory.transfer.template.details.templateSummary")), 1)
                  ]),
                  F(S),
                  _("div", vn, [
                    _("div", yn, [
                      _("div", hn, V(k(o)("inventory.transfer.receiveRequest.details.updatedAt")), 1),
                      _("div", gn, [
                        _("div", bn, [
                          re(V(k(mt)(r.value.updatedAt)) + " ", 1),
                          (I = r.value.updatedBy) != null && I.name ? (A(), D(W, { key: 0 }, [
                            re(" (" + V(r.value.updatedBy.name) + ") ", 1)
                          ], 64)) : z("", !0)
                        ]),
                        F(bt, {
                          "adjustment-id": r.value._id
                        }, null, 8, ["adjustment-id"])
                      ])
                    ])
                  ])
                ];
              }),
              _: 1
            })) : z("", !0)
          ], 64)) : z("", !0),
          (A(), O(cn, {
            class: "w-full",
            ref_key: "formRef",
            ref: T,
            onValidationSuccess: n,
            "model-value": r.value,
            "onUpdate:modelValue": a[0] || (a[0] = (I) => r.value = I),
            disabled: x.value,
            key: h.value
          }, null, 8, ["model-value", "disabled"]))
        ]),
        "side-sheet-footer": j(() => [
          _("div", _n, [
            F(y, {
              loading: x.value,
              label: k(o)("common.save"),
              onClick: f
            }, null, 8, ["loading", "label"]),
            F(y, {
              disabled: x.value,
              variant: "tertiary",
              label: k(o)("common.close"),
              onClick: a[1] || (a[1] = (I) => d("update:show", !1))
            }, null, 8, ["disabled", "label"])
          ])
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
}), wn = {};
function Tn(p, l) {
  return A(), D("div");
}
const kn = /* @__PURE__ */ _t(wn, [["render", Tn]]), $n = { class: "flex flex-col gap-16" }, Sn = { class: "flex" }, In = { class: "flex gap-24" }, An = { class: "flex" }, Fn = { class: "flex-1" }, Cn = { class: "flex" }, Rn = { class: "flex gap-8 items-center justify-start" }, Dn = /* @__PURE__ */ Y({
  __name: "WastageTemplateReason",
  props: {
    show: { type: Boolean }
  },
  emits: ["update:show", "submitted"],
  setup(p, { emit: l }) {
    const c = p, v = Le(c, "show"), d = R(""), i = ue(), m = X(), o = R([]), t = l, s = me(), r = ce(), h = R(!1);
    ie(
      () => c.show,
      (n) => {
        var f;
        n && (o.value = ((f = s.reasons) == null ? void 0 : f.value) ?? []);
      }
    );
    const x = (n) => {
      if (o.value.indexOf(o.value[n]) === -1)
        return;
      const f = o.value[n];
      if (f.trim() === "") {
        o.value.splice(n, 1);
        return;
      }
      m.open({
        title: "Delete reason",
        message: `Are you sure you want to delete this reason? "${f}"`,
        primaryActions: {
          text: "Delete",
          close: !0,
          variant: "destructive"
        },
        secondaryActions: {
          text: "Cancel",
          close: !0,
          variant: "secondary"
        }
      }).onPrimary(() => {
        o.value.splice(n, 1);
      });
    }, w = () => {
      o.value.push("");
      const n = d.value.trim();
      if (n) {
        if (o.value.some((f) => f === n)) {
          i.open({
            title: "Reason already exists",
            message: "Please enter a different reason",
            type: "error"
          });
          return;
        }
        d.value = "";
      }
    }, T = async () => {
      const n = o.value.map((f) => f.trim()).filter((f) => f);
      if (s.reasons) {
        h.value = !0;
        try {
          await r.update({
            _id: s.reasons._id,
            _rev: s.reasons._rev,
            value: n
          }), i.open({
            title: "Reasons updated",
            message: "Reasons have been updated successfully",
            type: "success"
          }), t("update:show", !1), t("submitted");
        } catch {
          i.open({
            title: "Error updating reasons",
            message: "There was an error updating reasons",
            type: "error"
          });
        } finally {
          h.value = !1;
        }
      }
    }, $ = R(), b = () => {
      var n, f;
      (f = (n = $.value) == null ? void 0 : n.validateInputs) == null || f.call(n);
    };
    return (n, f) => {
      const u = M("FmButton"), e = M("FmAvatar"), a = M("FmTextField"), S = M("FmList"), g = M("FmForm"), y = M("FmSideSheet");
      return A(), O(y, {
        modelValue: k(v),
        "onUpdate:modelValue": f[0] || (f[0] = (C) => je(v) ? v.value = C : null),
        header: "Reason for wastage",
        "close-button": "",
        "dismiss-away": !h.value,
        "max-width": 500
      }, {
        default: j(() => [
          F(g, {
            ref_key: "formRef",
            ref: $,
            class: "flex flex-col gap-32",
            blameFormChildOnValidationFailed: "",
            onValidationSuccess: T
          }, {
            default: j(() => [
              _("div", $n, [
                _("div", Sn, [
                  F(u, {
                    class: "ml-auto px-5",
                    variant: "primary",
                    label: "Add new reason",
                    size: "md",
                    onClick: w
                  })
                ])
              ]),
              _("div", In, [
                F(S, {
                  class: "w-full",
                  separator: ""
                }, {
                  default: j(() => [
                    (A(!0), D(W, null, Q(o.value, (C, I) => (A(), D("div", {
                      key: I,
                      class: "flex items-center gap-8 px-1 py-2"
                    }, [
                      _("div", An, [
                        F(e, {
                          initials: String(I + 1),
                          size: "sm"
                        }, null, 8, ["initials"])
                      ]),
                      _("div", Fn, [
                        F(a, {
                          class: "cursor-pointer text-fm-color-typo-tertiary",
                          modelValue: o.value[I],
                          "onUpdate:modelValue": (P) => o.value[I] = P,
                          maxLength: 500,
                          rules: [k(Ke)()]
                        }, null, 8, ["modelValue", "onUpdate:modelValue", "rules"])
                      ]),
                      _("div", Cn, [
                        F(u, {
                          variant: "tertiary",
                          size: "md",
                          "prepend-icon": "delete",
                          onClick: (P) => x(I)
                        }, null, 8, ["onClick"])
                      ])
                    ]))), 128))
                  ]),
                  _: 1
                })
              ])
            ]),
            _: 1
          }, 512)
        ]),
        "side-sheet-footer": j(() => [
          _("div", Rn, [
            F(u, {
              variant: "primary",
              label: "Save",
              size: "lg",
              onClick: b,
              disabled: h.value,
              loading: h.value
            }, null, 8, ["disabled", "loading"]),
            F(u, {
              variant: "secondary",
              label: "Close",
              size: "lg"
            })
          ])
        ]),
        _: 1
      }, 8, ["modelValue", "dismiss-away"]);
    };
  }
}), Mn = { class: "flex items-center gap-1" }, En = { class: "flex-1 flex flex-col gap-8" }, Pn = { class: "flex flex-col" }, Vn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Un = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, co = /* @__PURE__ */ Y({
  __name: "WastageTemplateView",
  setup(p) {
    const { t: l } = G(), { createTemplate: c, updateTemplate: v, exportTemplates: d, importTemplates: i, viewReason: m } = ve(), { templateDialogProps: o, templateDetailsProps: t, templateReasonProps: s } = Be(
      ve()
    ), r = ye();
    X();
    const h = me(), x = et(), { breakpoints: w } = st();
    r.watchLocation(h.fetchTemplates);
    const T = N(() => h.loading), $ = R(""), b = N(() => w.value.xs || w.value.sm), n = N(() => b.value ? 10 : 20);
    function f(S) {
      switch (S) {
        case B.Add:
          return c();
        case "import":
          return i();
        case "export":
          return d();
        case "refresh":
          return h.fetchTemplates();
      }
    }
    function u(S) {
      return S;
    }
    const e = N(() => b.value ? [
      {
        label: l("inventory.adjustment.template.create.title"),
        value: B.Add,
        isPrimary: !0,
        prependIcon: "add"
      },
      {
        label: l("inventory.common.refresh"),
        value: "refresh",
        isPrimary: !1
      },
      // {
      //   label: t('inventory.common.publish'),
      //   value: 'publish',
      //   isPrimary: false
      // },
      {
        label: l("inventory.common.import"),
        value: "import",
        isPrimary: !1
      },
      {
        label: l("inventory.common.export"),
        value: "export",
        isPrimary: !1
      }
    ] : [
      {
        label: l("inventory.adjustment.template.create.title"),
        value: B.Add,
        isPrimary: !0,
        prependIcon: "add"
      },
      // {
      //   label: t('inventory.common.publish'),
      //   value: 'publish',
      //   isPrimary: false
      // },
      {
        label: l("inventory.common.import"),
        value: "import",
        isPrimary: !1
      },
      {
        label: l("inventory.common.refresh"),
        value: "refresh",
        isPrimary: !1
      },
      {
        label: l("inventory.common.export"),
        value: "export",
        isPrimary: !1
      }
    ]), a = () => {
      m();
    };
    return (S, g) => {
      const y = M("FmButton"), C = M("FmTable");
      return A(), D(W, null, [
        F(tt, {
          title: k(l)("inventory.adjustment.template.wastage.title"),
          actions: e.value,
          "onClick:action": f
        }, {
          default: j(() => [
            _("div", {
              class: K([
                "flex flex-col gap-8 max-h-full",
                {
                  "p-0": b.value,
                  "px-24 ": !b.value
                }
              ])
            }, [
              _("div", Mn, [
                F(y, {
                  class: "ml-auto",
                  "prepend-icon": "edit",
                  key: "Reason for wastage",
                  label: "Default label",
                  "bg-color": "neutral-gray-100",
                  "text-color": "neutral-gray-400",
                  onClick: a
                }, {
                  default: j(() => g[5] || (g[5] = [
                    _("div", { class: "flex items-center gap-2" }, [
                      _("span", null, "Reasons")
                    ], -1)
                  ])),
                  _: 1
                }),
                F(y, {
                  "prepend-icon": "info",
                  label: "Default label",
                  variant: "tertiary",
                  onClick: g[0] || (g[0] = Je((I) => k(h).showReasonPublishDialog(), ["stop"]))
                }, {
                  default: j(() => [
                    _("div", {
                      class: K([
                        "fm-status-badge",
                        k(h).isReasonPublished() ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
                      ])
                    }, V(k(h).isReasonPublished() ? "Published" : "Unpublished"), 3)
                  ]),
                  _: 1
                }),
                F(nt, {
                  class: "flex-1",
                  searchable: "",
                  search: $.value,
                  "onUpdate:search": g[1] || (g[1] = (I) => $.value = I)
                }, null, 8, ["search"])
              ]),
              F(C, {
                style: qe(k(x).tableHeight),
                "column-defs": k(h).columnDefs,
                "row-data": k(h).templates,
                "search-value": $.value,
                loading: T.value,
                onRowClick: g[2] || (g[2] = (I) => k(v)(I.original)),
                "page-size": n.value
              }, {
                "list-row": j((I) => [
                  F(at, {
                    row: I,
                    onRowClick: (P) => k(v)(P)
                  }, {
                    default: j((P) => {
                      var U, de, ee, te, ge, be, _e, xe, ne, we, Te, ke, $e, Se, Ie, oe, Ae, Fe, Ce, Re, se, De;
                      return [
                        _("div", En, [
                          _("div", Pn, [
                            _("div", Vn, [
                              F(k(le), {
                                render: (ee = (de = (U = P._id) == null ? void 0 : U.column) == null ? void 0 : de.columnDef) == null ? void 0 : ee.cell,
                                props: (ge = (te = P._id) == null ? void 0 : te.getContext) == null ? void 0 : ge.call(te)
                              }, null, 8, ["render", "props"])
                            ]),
                            _("div", jn, [
                              F(k(le), {
                                render: (xe = (_e = (be = P.name) == null ? void 0 : be.column) == null ? void 0 : _e.columnDef) == null ? void 0 : xe.cell,
                                props: (we = (ne = P.name) == null ? void 0 : ne.getContext) == null ? void 0 : we.call(ne)
                              }, null, 8, ["render", "props"])
                            ]),
                            _("div", null, V((Te = I.original.locations) != null && Te.length ? k(l)("inventory.adjustment.template.table.enabledForN", {
                              count: ((ke = I.original.locations) == null ? void 0 : ke.length) ?? 0
                            }) : k(l)("inventory.adjustment.template.table.enabledForAll")), 1),
                            g[6] || (g[6] = _("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, null, -1)),
                            _("div", Un, [
                              F(k(le), {
                                render: (Ie = (Se = ($e = P.ref) == null ? void 0 : $e.column) == null ? void 0 : Se.columnDef) == null ? void 0 : Ie.cell,
                                props: (Ae = (oe = P.ref) == null ? void 0 : oe.getContext) == null ? void 0 : Ae.call(oe)
                              }, null, 8, ["render", "props"])
                            ])
                          ]),
                          _("div", null, [
                            F(k(le), {
                              render: (Re = (Ce = (Fe = P.status) == null ? void 0 : Fe.column) == null ? void 0 : Ce.columnDef) == null ? void 0 : Re.cell,
                              props: (De = (se = P.status) == null ? void 0 : se.getContext) == null ? void 0 : De.call(se)
                            }, null, 8, ["render", "props"])
                          ])
                        ])
                      ];
                    }),
                    _: 2
                  }, 1032, ["row", "onRowClick"])
                ]),
                _: 1
              }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
            ], 2)
          ]),
          _: 1
        }, 8, ["title", "actions"]),
        (A(), O(Qe, { to: "body" }, [
          F(kn, Xe(Ze(k(t))), null, 16),
          F(xn, Me(k(o), {
            onSubmitted: g[3] || (g[3] = (I) => k(h).fetchTemplates())
          }), null, 16),
          F(Dn, Me(k(s), {
            onSubmitted: g[4] || (g[4] = (I) => k(h).fetchTemplates())
          }), null, 16)
        ]))
      ], 64);
    };
  }
});
export {
  co as default
};
