import { defineComponent as F, resolveComponent as g, createBlock as p, openBlock as u, withCtx as v, createCommentVNode as y, createElementVNode as w, toDisplayString as M, renderSlot as P, mergeModels as T, useModel as f, ref as C, watch as I, createElementBlock as x, createVNode as D, unref as c } from "vue";
import { d as n, G as O, C as B } from "./global-loader-CbmVhJAK.js";
import { b as V } from "./index-BWqDfeY6.js";
import { detectLocale as $ } from "@feedmepos/mf-common";
const Y = { class: "fm-typo-en-body-md-600 text-ellipsis overflow-hidden whitespace-nowrap" }, j = { class: "fm-typo-en-body-md-600 text-ellipsis overflow-hidden whitespace-nowrap" }, k = /* @__PURE__ */ F({
  __name: "FilterChip",
  props: {
    label: {
      type: String,
      default: ""
    },
    leftIcon: {
      type: String,
      default: ""
    },
    rightIcon: {
      type: String,
      default: ""
    }
  },
  setup(a) {
    const r = a;
    return (d, l) => {
      const e = g("FmIcon"), t = g("FmChip");
      return u(), p(t, { class: "bg-fm-color-neutral-gray-100 text-fm-color-neutral-gray-400 max-w-fit" }, {
        default: v(() => [
          a.leftIcon ? (u(), p(e, {
            key: 0,
            name: r.leftIcon,
            size: "sm",
            outline: ""
          }, null, 8, ["name"])) : y("", !0),
          w("p", Y, M(r.label), 1),
          a.rightIcon ? (u(), p(e, {
            key: 1,
            name: a.rightIcon,
            size: "sm",
            outline: ""
          }, null, 8, ["name"])) : y("", !0),
          w("div", j, [
            P(d.$slots, "default")
          ])
        ]),
        _: 3
      });
    };
  }
}), N = { class: "flex gap-2 items-center" }, i = "YYYY-MM-DD", G = /* @__PURE__ */ F({
  __name: "DateRangeSelect",
  props: /* @__PURE__ */ T({
    compare: {
      type: Boolean,
      default: !1
    },
    datePredefinedRanges: {
      type: Array,
      default: () => O
    }
  }, {
    compareType: {
      type: String,
      default: B.PrecedingPeriod
    },
    compareTypeModifiers: {},
    dateRange: {
      type: Object,
      default: () => ({
        startDate: void 0,
        endDate: void 0
      })
    },
    dateRangeModifiers: {},
    compareDateRange: {
      type: Object,
      default: () => ({
        startDate: void 0,
        endDate: void 0
      })
    },
    compareDateRangeModifiers: {}
  }),
  emits: ["update:compareType", "update:dateRange", "update:compareDateRange"],
  setup(a) {
    var S, R, b;
    const r = f(a, "compareType"), d = f(a, "dateRange"), l = f(a, "compareDateRange"), e = C({
      startDate: (S = n(d.value.startDate)) == null ? void 0 : S.local().format(i),
      endDate: (R = n(d.value.endDate)) == null ? void 0 : R.local().format(i)
    }), t = C({
      startDate: l.value.startDate ? (b = n(l.value.startDate)) == null ? void 0 : b.local().format(i) : void 0,
      endDate: l.value.endDate ? n(l.value.endDate).local().format(i) : void 0
    });
    I(
      [() => e.value],
      () => {
        e.value.endDate || (e.value.endDate = e.value.startDate), d.value = {
          startDate: n(e.value.startDate).toISOString(),
          endDate: n(e.value.endDate).toISOString()
        };
      },
      { deep: !0 }
    ), I([() => t.value], () => {
      l.value = {
        startDate: t.value.startDate ? n(t.value.startDate).toISOString() : void 0,
        endDate: t.value.endDate ? n(t.value.endDate).toISOString() : void 0
      };
    });
    function _(m) {
      r.value = m;
    }
    return (m, s) => {
      const h = g("FmSimpleDateRangePicker");
      return u(), x("div", N, [
        D(h, {
          modelValue: e.value,
          "onUpdate:modelValue": s[0] || (s[0] = (o) => e.value = o),
          "show-predefined-range": "",
          "predefined-range": a.datePredefinedRanges.map((o) => ({
            ...o,
            label: m.$t(`report.date.${o.label}`)
          })),
          class: "w-2/6"
        }, {
          "trigger-button": v(() => [
            D(k, {
              "left-icon": "calendar_month",
              label: `${c(V)({
                startDate: e.value.startDate ?? "",
                endDate: e.value.endDate ?? "",
                locale: c($)()
              })}`
            }, null, 8, ["label"])
          ]),
          _: 1
        }, 8, ["modelValue", "predefined-range"]),
        a.compare ? (u(), p(h, {
          key: 0,
          modelValue: t.value,
          "onUpdate:modelValue": s[1] || (s[1] = (o) => t.value = o),
          "show-predefined-range": "",
          "compare-target": e.value,
          "default-compare-type": r.value,
          onSelectComparison: _
        }, {
          "trigger-button": v(() => [
            D(k, {
              label: `${m.$t("report.common.compare")}: ${c(V)({
                startDate: t.value.startDate ?? null,
                endDate: t.value.endDate ?? null,
                locale: c($)()
              })}`
            }, null, 8, ["label"])
          ]),
          _: 1
        }, 8, ["modelValue", "compare-target", "default-compare-type"])) : y("", !0)
      ]);
    };
  }
});
export {
  G as _,
  k as a
};
