import { useCssVars as K, ref as f, computed as d, watch as L, onMounted as Y, openBlock as v, createElementBlock as h, createElementVNode as i, normalizeStyle as S, createVNode as ee, renderSlot as te, createCommentVNode as k, unref as le, Fragment as z, renderList as E, withDirectives as P, vModelText as R, toDisplayString as A, pushScopeId as ae, popScopeId as ie } from "vue";
import ne from "./BaseIcon-ZChy8GeS.js";
import { t as oe, u as ue } from "./useResponsive-NZB-WLRF.js";
import { c as re, R as V, Q as B, X as se } from "./index-DK7qqHGP.js";
import { _ as de } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const O = (l) => (ae("data-v-54291cff"), l = l(), ie(), l), me = {
  "data-html2canvas-ignore": "",
  style: { padding: "0 24px" }
}, ce = {
  class: "vue-data-ui-slicer-labels",
  style: { position: "relative", "z-index": "1", "pointer-events": "none" }
}, ve = {
  key: 0,
  style: { width: "100%", position: "relative" }
}, he = {
  key: 0,
  class: "minimap",
  style: { width: "100%" }
}, pe = ["xmlns", "viewBox"], fe = ["id"], ye = ["stop-color"], ge = /* @__PURE__ */ O(() => /* @__PURE__ */ i("stop", {
  offset: "100%",
  "stop-color": "transparent"
}, null, -1)), xe = ["d", "stroke"], be = ["x", "width", "height", "fill", "rx"], Se = ["d", "fill"], ke = ["x", "width", "height", "fill"], Ce = ["x", "width", "height", "fill"], we = ["d", "fill"], Ne = ["d", "stroke"], $e = ["cx", "cy", "stroke", "fill"], Le = ["cx", "cy", "stroke", "fill"], Me = ["x1", "x2", "y2", "stroke"], Ie = ["x", "height", "width", "onMouseenter"], Fe = /* @__PURE__ */ O(() => /* @__PURE__ */ i("div", { class: "slider-track" }, null, -1)), ze = ["min", "max"], Ee = ["min", "max"], Pe = {
  __name: "Slicer",
  props: {
    background: {
      type: String,
      default: "#FFFFFF"
    },
    borderColor: {
      type: String,
      default: "#FFFFFF"
    },
    fontSize: {
      type: Number,
      default: 14
    },
    labelLeft: {
      type: String,
      default: ""
    },
    labelRight: {
      type: String,
      default: ""
    },
    textColor: {
      type: String,
      default: "#1A1A1A"
    },
    inputColor: {
      type: String,
      default: "#1A1A1A"
    },
    max: {
      type: Number,
      default: 0
    },
    min: {
      type: Number,
      default: 0
    },
    selectColor: {
      type: String,
      default: "#4A4A4A"
    },
    useResetSlot: {
      type: Boolean,
      default: !1
    },
    valueStart: {
      type: [Number, String],
      default: 0
    },
    valueEnd: {
      type: [Number, String],
      default: 0
    },
    minimap: {
      type: Array,
      default: []
    },
    smoothMinimap: {
      type: Boolean,
      default: !1
    },
    minimapSelectedColor: {
      type: String,
      default: "#1f77b4"
    },
    minimapSelectionRadius: {
      type: Number,
      default: 12
    },
    minimapLineColor: {
      type: String,
      default: "#2D353C"
    },
    minimapSelectedColorOpacity: {
      type: Number,
      default: 0.2
    },
    minimapSelectedIndex: {
      type: Number,
      default: null
    },
    minimapIndicatorColor: {
      type: String,
      default: "#2D353C"
    }
  },
  emits: ["update:start", "update:end", "reset", "trapMouse"],
  setup(l, { emit: y }) {
    const e = l;
    K((t) => ({
      e0176a96: D.value,
      "27e9d329": x.value,
      "22b19dda": U.value,
      "081f1459": l.selectColor,
      "12e0ab32": T.value
    }));
    const u = f(e.min), r = f(e.max), g = d(() => !!e.minimap.length), C = f(re()), _ = d(() => {
      const t = e.max - e.min, n = (u.value - e.min) / t * 100, o = (r.value - e.min) / t * 100;
      return {
        left: `${n}%`,
        width: `${o - n}%`,
        background: e.selectColor
      };
    }), D = d(() => e.inputColor), T = d(() => e.background), U = d(() => `${e.selectColor}33`), x = d(() => e.borderColor), M = d(() => {
      let t = [];
      for (let n = 0; n < e.minimap.length; n += 1)
        t.push(n);
      return t;
    });
    function I() {
      y("reset");
    }
    function W() {
      Number(u.value) > Number(r.value) - 1 && (u.value = Number(r.value) - 1), y("update:start", Number(u.value));
    }
    function X() {
      Number(r.value) < Number(u.value) + 1 && (r.value = Number(u.value) + 1), y("update:end", Number(r.value));
    }
    L(
      () => e.min,
      (t) => {
        Number(u.value) < Number(t) && (u.value = Number(t)), Number(r.value) < Number(t) && (r.value = Number(t));
      }
    ), L(
      () => e.max,
      (t) => {
        Number(u.value) > Number(t) && (u.value = Number(t)), Number(r.value) > Number(t) && (r.value = Number(t));
      }
    );
    const w = f(null), a = f({
      width: 1,
      height: 1
    }), F = f(null);
    Y(() => {
      if (g.value) {
        const t = oe(() => {
          const { width: n, height: o } = ue({
            chart: w.value
          });
          a.value.width = n, a.value.height = o - 47;
        });
        F.value = new ResizeObserver(t), F.value.observe(w.value);
      }
    });
    const s = d(() => e.minimap.length ? a.value.width / e.minimap.length : 0), m = d(() => {
      if (!e.minimap.length) return [];
      const t = Math.max(...e.minimap), n = Math.min(...e.minimap) - 10, o = t - (n > 0 ? 0 : n), c = e.minimap.map((Q, H) => {
        const J = Q - n;
        return {
          x: a.value.width / e.minimap.length * H + s.value / 2,
          y: a.value.height - J / o * (a.value.height * 0.9)
        };
      }), N = e.smoothMinimap ? V(c) : B(c), $ = [...c].slice(e.valueStart, e.valueEnd), G = e.smoothMinimap ? V($) : B($);
      return {
        fullSet: N,
        selectionSet: G,
        sliced: $,
        firstPlot: c[e.valueStart],
        lastPlot: c[e.valueEnd - 1]
      };
    }), p = d(() => ({
      x: s.value * u.value + s.value / 2,
      width: a.value.width * ((r.value - u.value) / e.max) - s.value
    })), j = d(() => ({
      left: 0,
      color: e.textColor,
      fontSize: `${e.fontSize}px`,
      top: g.value ? "28px" : "-28px",
      pointerEvents: "none"
    })), Z = d(() => ({
      right: 0,
      color: e.textColor,
      fontSize: `${e.fontSize}px`,
      top: g.value ? "28px" : "-28px",
      direction: "rtl",
      pointerEvents: "none"
    })), b = f(e.minimapSelectedIndex);
    L(() => e.minimapSelectedIndex, (t) => {
      b.value = t + e.valueStart;
    }, { immediate: !0 });
    function q(t) {
      b.value = t, t >= e.valueStart && t < e.valueEnd && y("trapMouse", t - e.valueStart);
    }
    return (t, n) => (v(), h("div", me, [
      i("div", ce, [
        l.valueStart > 0 || l.valueEnd < l.max ? (v(), h("div", ve, [
          l.useResetSlot ? te(t.$slots, "reset-action", {
            key: 1,
            reset: I
          }, void 0, !0) : (v(), h("button", {
            key: 0,
            "data-cy-reset": "",
            tabindex: "0",
            role: "button",
            class: "vue-data-ui-refresh-button",
            style: S({
              top: g.value ? "36px" : "-16px",
              pointerEvents: "all !important"
            }),
            onClick: I
          }, [
            ee(ne, {
              name: "refresh",
              stroke: l.textColor
            }, null, 8, ["stroke"])
          ], 4))
        ])) : k("", !0)
      ]),
      i("div", {
        class: "double-range-slider",
        ref_key: "minimapWrapper",
        ref: w,
        style: { "z-index": "0" }
      }, [
        g.value ? (v(), h("div", he, [
          (v(), h("svg", {
            xmlns: le(se),
            viewBox: `0 0 ${a.value.width < 0 ? 0 : a.value.width} ${a.value.height < 0 ? 0 : a.value.height}`
          }, [
            i("defs", null, [
              i("linearGradient", {
                id: C.value,
                x1: "0%",
                y1: "0%",
                x2: "0%",
                y2: "100%"
              }, [
                i("stop", {
                  offset: "0%",
                  "stop-color": `${l.minimapLineColor}50`
                }, null, 8, ye),
                ge
              ], 8, fe)
            ]),
            i("path", {
              d: `M${m.value.fullSet}`,
              stroke: `${l.minimapLineColor}`,
              fill: "none",
              "stroke-width": "1",
              "stroke-linecap": "round",
              "stroke-linejoin": "round",
              style: { opacity: "1" }
            }, null, 8, xe),
            i("rect", {
              x: p.value.x,
              width: p.value.width < 0 ? 0 : p.value.width,
              height: a.value.height,
              y: 0,
              fill: x.value,
              rx: l.minimapSelectionRadius,
              stroke: "none"
            }, null, 8, be),
            i("path", {
              d: `M${s.value / 2},${a.value.height} ${m.value.fullSet} L${a.value.width - s.value / 2},${a.value.height}Z`,
              fill: `url(#${C.value})`,
              stroke: "none",
              style: { opacity: "1" }
            }, null, 8, Se),
            i("rect", {
              x: p.value.x,
              width: p.value.width < 0 ? 0 : p.value.width,
              height: a.value.height,
              y: 0,
              fill: x.value
            }, null, 8, ke),
            i("rect", {
              x: p.value.x,
              width: p.value.width < 0 ? 0 : p.value.width,
              height: a.value.height,
              y: 0,
              fill: l.minimapSelectedColor,
              style: S({
                opacity: l.minimapSelectedColorOpacity
              })
            }, null, 12, Ce),
            i("path", {
              d: `M${m.value.sliced[0].x},${a.value.height} ${m.value.selectionSet} L${m.value.sliced.at(-1).x},${a.value.height}Z`,
              fill: `url(#${C.value})`,
              stroke: "none",
              style: { opacity: "1" }
            }, null, 8, we),
            i("path", {
              d: `M ${m.value.selectionSet}`,
              stroke: `${l.minimapLineColor}`,
              fill: "transparent",
              "stroke-width": "2",
              "stroke-linecap": "round",
              "stroke-linejoin": "round"
            }, null, 8, Ne),
            i("circle", {
              cx: m.value.firstPlot.x,
              cy: m.value.firstPlot.y,
              "stroke-width": "0.5",
              stroke: x.value,
              r: "3",
              fill: l.minimapLineColor
            }, null, 8, $e),
            i("circle", {
              cx: m.value.lastPlot.x,
              cy: m.value.lastPlot.y,
              "stroke-width": "0.5",
              stroke: x.value,
              r: "3",
              fill: l.minimapLineColor
            }, null, 8, Le),
            b.value !== null ? (v(!0), h(z, { key: 0 }, E(M.value, (o, c) => (v(), h("g", null, [
              b.value === o && o >= l.valueStart && o < l.valueEnd ? (v(), h("line", {
                key: 0,
                x1: s.value * c + s.value / 2,
                x2: s.value * c + s.value / 2,
                y1: 0,
                y2: a.value.height,
                stroke: l.minimapIndicatorColor,
                "stroke-linecap": "round",
                "stroke-dasharray": "2",
                "stroke-width": "1"
              }, null, 8, Me)) : k("", !0)
            ]))), 256)) : k("", !0),
            (v(!0), h(z, null, E(M.value, (o, c) => (v(), h("rect", {
              x: s.value * c,
              y: 0,
              height: a.value.height,
              width: s.value,
              fill: "transparent",
              style: { "pointer-events": "all !important" },
              onMouseenter: (N) => q(o),
              onMouseleave: n[0] || (n[0] = (N) => {
                b.value = null, y("trapMouse", null);
              })
            }, null, 40, Ie))), 256))
          ], 8, pe))
        ])) : k("", !0),
        Fe,
        i("div", {
          class: "range-highlight",
          style: S(_.value)
        }, null, 4),
        P(i("input", {
          type: "range",
          class: "range-left",
          min: l.min,
          max: l.max,
          "onUpdate:modelValue": n[1] || (n[1] = (o) => u.value = o),
          onInput: W
        }, null, 40, ze), [
          [R, u.value]
        ]),
        i("div", {
          class: "thumb-label thumb-label-left",
          style: S(j.value)
        }, A(l.labelLeft), 5),
        P(i("input", {
          type: "range",
          class: "range-right",
          min: l.min,
          max: l.max,
          "onUpdate:modelValue": n[2] || (n[2] = (o) => r.value = o),
          onInput: X
        }, null, 40, Ee), [
          [R, r.value]
        ]),
        i("div", {
          class: "thumb-label thumb-label-right",
          style: S(Z.value)
        }, A(l.labelRight), 5)
      ], 512)
    ]));
  }
}, _e = /* @__PURE__ */ de(Pe, [["__scopeId", "data-v-54291cff"]]);
export {
  _e as S
};
