import '@das-fed/ui/packages/components/pagination/style.css';
import { defineComponent as B, createElementBlock as _, openBlock as u, createElementVNode as D, ref as T, computed as d, createBlock as N, withCtx as C, withDirectives as H, createVNode as m, createTextVNode as L, toDisplayString as S, unref as o, normalizeClass as h, Fragment as j, renderList as J, reactive as K, watch as Q, onMounted as W, nextTick as X, createCommentVNode as b, mergeProps as Y, isRef as M, renderSlot as Z } from "vue";
import { withInstall as ee } from "@das-fed/utils/with-install/index";
import { t as P, currentLang as ae, setI18nRule as te } from "@das-fed/web/packages/i18n/index";
import { DasAutoRegisterIcon as oe, DasIcon as x } from "@das-fed/ui/packages/components/icon/index";
import { ElConfigProvider as le, ElPagination as ne } from "element-plus";
import "element-plus/es/components/pagination/style/css";
import { useModelValue as U } from "@das-fed/utils/vue";
import se from "element-plus/dist/locale/zh-cn.mjs";
import ie from "element-plus/dist/locale/en.mjs";
import { ElDropdown as re, ElIcon as pe, ElDropdownMenu as ue, ElDropdownItem as ce } from "element-plus/es";
import "element-plus/es/components/base/style/css";
import "element-plus/es/components/dropdown/style/css";
import "element-plus/es/components/dropdown-menu/style/css";
import "element-plus/es/components/dropdown-item/style/css";
import "element-plus/es/components/icon/style/css";
import { vDasTooltip as de } from "@das-fed/ui/packages/components/text-tooltip/index";
import { setThemeRule as ge } from "@das-fed/web/packages/theme/index";
/*! Element Plus Icons Vue v2.3.1 */
var me = /* @__PURE__ */ B({
  name: "ArrowDown",
  __name: "arrow-down",
  setup(v) {
    return (f, n) => (u(), _("svg", {
      xmlns: "http://www.w3.org/2000/svg",
      viewBox: "0 0 1024 1024"
    }, [
      D("path", {
        fill: "currentColor",
        d: "M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"
      })
    ]));
  }
}), ve = me;
const fe = { class: "sizes-dropdown-link" }, _e = { class: "current-page-size" }, ze = {
  name: "DasPaginationSizes"
}, Ce = /* @__PURE__ */ B({
  ...ze,
  props: {
    pageSizes: { default: () => [20, 50, 100] },
    pageSize: { default: 20 }
  },
  emits: ["update:pageSize", "size-change"],
  setup(v, { emit: f }) {
    const n = v, l = f, k = T(!1), g = d({
      get: () => n.pageSize,
      set: (p) => {
        l("update:pageSize", p);
      }
    }), s = (p) => {
      k.value = p;
    }, E = (p) => {
      g.value = p, l("size-change", p);
    };
    return (p, I) => {
      const z = pe, w = ce, e = ue, c = re;
      return u(), N(c, {
        "popper-class": "pagination-sizes-popper",
        trigger: "click",
        onVisibleChange: s,
        onCommand: E
      }, {
        dropdown: C(() => [
          m(e, null, {
            default: C(() => [
              (u(!0), _(
                j,
                null,
                J(p.pageSizes, (i) => (u(), N(w, {
                  class: h(["sizes-item", i === p.pageSize ? "selected" : ""]),
                  key: i,
                  command: i
                }, {
                  default: C(() => [
                    L(
                      S(o(P)("pagination-items_per_page", i)),
                      1
                      /* TEXT */
                    )
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, 1032, ["class", "command"]))),
                128
                /* KEYED_FRAGMENT */
              ))
            ]),
            _: 1
            /* STABLE */
          })
        ]),
        default: C(() => [
          D("span", fe, [
            H((u(), _("span", _e, [
              L(
                S(o(P)("pagination-items_per_page", g.value)),
                1
                /* TEXT */
              )
            ])), [
              [o(de)]
            ]),
            m(z, {
              class: h(["arrow-icon", k.value ? "rotate180" : ""])
            }, {
              default: C(() => [
                m(o(ve))
              ]),
              _: 1
              /* STABLE */
            }, 8, ["class"])
          ])
        ]),
        _: 1
        /* STABLE */
      });
    };
  }
}), R = (v, f) => {
  const n = v.__vccOpts || v;
  for (const [l, k] of f)
    n[l] = k;
  return n;
}, ke = /* @__PURE__ */ R(Ce, [["__scopeId", "data-v-c341a216"]]), he = { class: "total-page" }, we = {
  name: "TotalPage"
}, ye = /* @__PURE__ */ B({
  ...we,
  props: {
    totalPage: {}
  },
  setup(v) {
    return (f, n) => (u(), _(
      "div",
      he,
      S(o(P)("pagination-total_page", f.totalPage)),
      1
      /* TEXT */
    ));
  }
}), Se = /* @__PURE__ */ R(ye, [["__scopeId", "data-v-917c488b"]]), Pe = { class: "das-ui-pagination" }, $e = {
  key: 0,
  style: { color: "#212121", "font-size": "12px" }
}, be = {
  key: 1,
  style: { "margin-left": "12px" },
  class: "page-container flex-center__y"
}, xe = { class: "flex-center__y" }, De = { class: "flex-center__y" }, Ne = /* @__PURE__ */ B({
  __name: "Pagination",
  props: {
    modelValue: { default: 1 },
    pageSize: { default: 20 },
    total: { default: 0 },
    pageSizes: { default: () => [20, 50, 100] },
    small: { type: Boolean, default: !0 },
    layout: {},
    background: { type: Boolean, default: !1 },
    disabled: { type: Boolean, default: !1 },
    simple: { type: Boolean, default: !1 },
    popperClass: {}
  },
  emits: ["update:modelValue", "update:pageSize", "size-change", "current-change", "prev-click", "next-click", "first-click", "last-click"],
  setup(v, { emit: f }) {
    const n = v, l = f;
    oe({
      "arrow-first": import("@das-fed/ui/packages/icons/arrow-first"),
      left: import("@das-fed/ui/packages/icons/left"),
      right: import("@das-fed/ui/packages/icons/right"),
      "arrow-last": import("@das-fed/ui/packages/icons/arrow-last")
    });
    const k = d(() => ae.value === "zh-CN" ? se : ie), g = T(), s = K({
      first: !1,
      pre: !1,
      next: !1,
      last: !1
    }), E = d(() => n.layout), p = d(() => n.background), I = d(() => n.pageSizes), z = d(() => n.total), w = d(() => n.simple), e = U(n, "modelValue"), c = U(n, "pageSize"), i = d(() => Math.ceil(z.value / c.value)), V = d(() => w.value ? "prev, slot, next" : E.value || "total,jumper,slot,sizes"), A = d(() => V.value.replace(/\s*/g, "").split(",").filter((a) => a !== "total" && a !== "sizes").join(",")), F = (t) => {
      l("update:pageSize", t), l("size-change", t);
    }, y = (t) => {
      l("update:modelValue", t), l("current-change", t);
    }, O = () => l("prev-click", e.value), q = () => l("next-click", e.value), G = () => {
      s.first = i.value === 0 || e.value <= 1, s.pre = i.value === 0 || e.value <= 1, s.next = i.value === 0 || e.value === i.value, s.last = i.value === 0 || e.value === i.value;
    };
    Q(
      () => [e.value, i.value],
      () => {
        G();
      },
      {
        immediate: !0
      }
    );
    const $ = (t, a) => {
      const r = /* @__PURE__ */ new Map([
        [
          "first",
          () => {
            e.value <= 1 || (e.value = 1, y(e.value), l("first-click", e.value));
          }
        ],
        [
          "pre",
          () => {
            e.value <= 1 || (e.value--, y(e.value), l("prev-click", e.value));
          }
        ],
        [
          "next",
          () => {
            e.value !== z.value && (e.value++, y(e.value), l("next-click", e.value));
          }
        ],
        [
          "last",
          () => {
            e.value !== z.value && (e.value = i.value, y(e.value), l("last-click", e.value));
          }
        ]
      ]);
      if (a) return;
      r.get(t)();
    };
    return W(() => {
      X(() => {
        var t, a, r;
        (t = g.value) != null && t.$el && ((a = g.value.$el) != null && a.getElementsByClassName("el-pagination__goto")[0] && (g.value.$el.getElementsByClassName("el-pagination__goto")[0].innerText = P("第")), (r = g.value.$el) != null && r.getElementsByClassName("el-pagination__classifier")[0] && (g.value.$el.getElementsByClassName("el-pagination__classifier")[0].innerText = P("页")));
      });
    }), (t, a) => (u(), _("div", Pe, [
      V.value.includes("total") ? (u(), N(o(Se), {
        key: 0,
        "total-page": i.value,
        style: { "margin-right": "12px" }
      }, null, 8, ["total-page"])) : b("v-if", !0),
      m(o(le), { locale: k.value }, {
        default: C(() => [
          m(o(ne), Y({
            ref_key: "dasPagination",
            ref: g,
            class: { background: p.value, simple: w.value },
            currentPage: o(e),
            "onUpdate:currentPage": a[4] || (a[4] = (r) => M(e) ? e.value = r : null),
            "page-size": o(c),
            "onUpdate:pageSize": a[5] || (a[5] = (r) => M(c) ? c.value = r : null),
            "page-sizes": I.value,
            layout: A.value,
            total: z.value,
            small: t.small,
            background: p.value,
            disabled: t.disabled,
            "popper-class": t.popperClass ? `das-pagination-popper ${t.popperClass}` : "das-pagination-popper",
            teleported: !1,
            onCurrentChange: y,
            onPrevClick: O,
            onNextClick: q
          }, t.$attrs), {
            default: C(() => [
              A.value.includes("slot") ? Z(t.$slots, "default", { key: 0 }, () => [
                t.$slots.default ? b("v-if", !0) : (u(), _(
                  j,
                  { key: 0 },
                  [
                    w.value ? (u(), _(
                      "div",
                      $e,
                      S(o(e)) + "/" + S(Math.ceil(z.value / o(c))),
                      1
                      /* TEXT */
                    )) : (u(), _("div", be, [
                      D("div", xe, [
                        m(o(x), {
                          class: h(["page-icon", s.first ? "disabled" : ""]),
                          icon: "arrow-first",
                          iconColor: "#666666",
                          size: "medium",
                          onClick: a[0] || (a[0] = (r) => $("first", s.first))
                        }, null, 8, ["class"]),
                        m(o(x), {
                          class: h(["page-icon", s.pre ? "disabled" : ""]),
                          icon: "left",
                          iconColor: "#666666",
                          size: "medium",
                          onClick: a[1] || (a[1] = (r) => $("pre", s.pre))
                        }, null, 8, ["class"])
                      ]),
                      D("div", De, [
                        m(o(x), {
                          class: h(["page-icon", s.next ? "disabled" : ""]),
                          icon: "right",
                          iconColor: "#666666",
                          size: "medium",
                          onClick: a[2] || (a[2] = (r) => $("next", s.next))
                        }, null, 8, ["class"]),
                        m(o(x), {
                          class: h(["page-icon", s.last ? "disabled" : ""]),
                          icon: "arrow-last",
                          iconColor: "#666666",
                          size: "medium",
                          onClick: a[3] || (a[3] = (r) => $("last", s.last))
                        }, null, 8, ["class"])
                      ])
                    ]))
                  ],
                  64
                  /* STABLE_FRAGMENT */
                ))
              ], !0) : b("v-if", !0)
            ]),
            _: 3
            /* FORWARDED */
          }, 16, ["class", "currentPage", "page-size", "page-sizes", "layout", "total", "small", "background", "disabled", "popper-class"])
        ]),
        _: 3
        /* FORWARDED */
      }, 8, ["locale"]),
      V.value.includes("sizes") ? (u(), N(o(ke), {
        key: 1,
        "page-sizes": I.value,
        pageSize: o(c),
        "onUpdate:pageSize": a[6] || (a[6] = (r) => M(c) ? c.value = r : null),
        onSizeChange: F
      }, null, 8, ["page-sizes", "pageSize"])) : b("v-if", !0)
    ]));
  }
}), Be = /* @__PURE__ */ R(Ne, [["__scopeId", "data-v-d1fdaf0e"]]), Ee = {
  "--das-ui-pagination-simple-border-color": "#D9D9D9",
  "--das-ui-pagination-size-color": "#212121",
  "--das-ui-pagination-size--icon-hover-color": "#3761CA",
  "--das-ui-pagination-size--poppver-item-hover-bg-color": "#f5f5f5",
  "--das-ui-pagination-size--poppver-item-click-color": "#5582f3",
  "--das-ui-pagination-totalpage-color": "#666666"
}, Ie = {
  第: { "zh-CN": "第", en: "Page", _appCode: "framework" },
  页: { "zh-CN": "页", en: " ", _appCode: "framework" },
  "pagination-total_page": { "zh-CN": "共$0页", en: "Total $0", _appCode: "framework" },
  "pagination-items_per_page": { "zh-CN": "$0条/页", en: "$0 Records/Page", _appCode: "framework" }
};
te(Ie);
ge(Ee);
const Ye = () => T(null), Ze = ee(Be);
export {
  Ze as DasPagination,
  Ye as DasPaginationRef,
  Ze as default
};
