import { useCssVars as he, computed as h, onMounted as de, ref as m, watch as ve, openBlock as o, createElementBlock as n, normalizeClass as $, normalizeStyle as ye, createBlock as U, createCommentVNode as c, unref as v, createSlots as fe, withCtx as q, renderSlot as x, normalizeProps as H, guardReactiveProps as X, createVNode as me, createElementVNode as d, Fragment as F, renderList as R, toDisplayString as ge } from "vue";
import { u as pe, o as ke, e as J, g as xe, c as _e, t as be, a as we, p as _, b as Ce, v as f, d as P, X as $e, s as Fe, i as Pe, f as Ie } from "./index-DK7qqHGP.js";
import { _ as Ye } from "./Title-Cxlu3Etv.js";
import { u as Oe, U as Me } from "./usePrinter-Cza87yNE.js";
import Ne from "./vue-ui-skeleton-CQnYuosp.js";
import { u as K } from "./useNestedProp-0nRX_rTi.js";
import { _ as Se } from "./PackageVersion-I1_4jcn_.js";
import { _ as Ue } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const qe = ["id"], Le = {
  key: 0,
  style: "width:100%"
}, Te = ["xmlns", "viewBox"], Ge = {
  id: "vueUiPill",
  clipPathUnits: "objectBoundingBox"
}, Ve = ["fill"], We = ["id"], Ee = ["stop-color"], ze = ["stop-color"], Be = ["stop-color"], je = { "clip-path": "url(#vueUiPill)" }, Ae = ["x", "y", "height", "width"], De = ["x", "y", "height", "width", "fill"], He = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], Xe = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], Re = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], Je = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], Ke = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], Qe = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], Ze = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], et = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], tt = ["x", "y", "height", "width"], st = ["y", "x", "fill", "font-size", "font-weight"], lt = {
  key: 3,
  class: "vue-data-ui-watermark"
}, at = {
  __name: "vue-ui-thermometer",
  props: {
    dataset: {
      type: Object,
      default() {
        return {};
      }
    },
    config: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  setup(b, { expose: Q }) {
    const a = b;
    he((s) => ({
      ff9f54a6: ae.value,
      "727be881": le.value,
      "673ba9ae": se.value
    }));
    const { vue_ui_thermometer: Z } = pe(), I = h(() => !!a.dataset && Object.keys(a.dataset).length);
    de(() => {
      L();
    });
    function L() {
      ke(a.dataset) ? J({
        componentName: "VueUiThermometer",
        type: "dataset"
      }) : xe({
        datasetObject: a.dataset,
        requiredAttributes: ["value", "from", "to"]
      }).forEach((s) => {
        J({
          componentName: "VueUiThermometer",
          type: "datasetAttribute",
          property: s
        });
      });
    }
    const g = m(_e()), T = m(null), G = m(0), V = m(0), e = h({
      get: () => W(),
      set: (s) => s
    });
    function W() {
      const s = K({
        userConfig: a.config,
        defaultConfig: Z
      });
      return s.theme ? {
        ...K({
          userConfig: be.vue_ui_thermometer[s.theme] || a.config,
          defaultConfig: s
        }),
        customPalette: we[s.theme] || _
      } : s;
    }
    ve(() => a.config, (s) => {
      e.value = W(), L(), V.value += 1;
    }, { deep: !0 });
    const { isPrinting: E, isImaging: z, generatePdf: B, generateImage: j } = Oe({
      elementId: `thermometer__${g.value}`,
      fileName: e.value.style.title.text || "vue-ui-thermometer"
    }), w = h(() => Ce(e.value.customPalette)), ee = h(() => e.value.style.chart.thermometer.width), y = h(() => a.dataset.steps || 10), i = m({
      top: e.value.style.chart.padding.top,
      left: e.value.style.chart.padding.left,
      right: e.value.style.chart.padding.right,
      bottom: e.value.style.chart.padding.bottom
    });
    function C(s, r, t) {
      const u = [], N = A(s), S = A(r);
      for (let k = 0; k < t; k++) {
        const ue = Y(N.red, S.red, k, t), ne = Y(N.green, S.green, k, t), ie = Y(N.blue, S.blue, k, t), ce = `#${O(ue)}${O(ne)}${O(ie)}`;
        u.push(ce);
      }
      return u;
    }
    function A(s) {
      const r = s.slice(1);
      return {
        red: parseInt(r.slice(0, 2), 16),
        green: parseInt(r.slice(2, 4), 16),
        blue: parseInt(r.slice(4, 6), 16)
      };
    }
    function Y(s, r, t, u) {
      return Math.round(s + (r - s) * t / u);
    }
    function O(s) {
      return s.toString(16).padStart(2, "0");
    }
    const l = h(() => {
      const s = ee.value + i.value.left + i.value.right, r = e.value.style.chart.height;
      return {
        width: s,
        left: i.value.left,
        right: s - i.value.right,
        top: i.value.top,
        bottom: r - i.value.bottom,
        height: r
      };
    }), te = h(() => l.value), M = h(() => {
      const s = f(a.dataset.from) < 0 ? Math.abs(f(a.dataset.from)) : f(a.dataset.from), r = f(a.dataset.to) < 0 ? Math.abs(f(a.dataset.to)) : f(a.dataset.to);
      let t = 0;
      return f(a.dataset.to) > 0 ? t = s + r : s > r ? t = s - r : t = r - s, (1 - (Math.abs(f(a.dataset.from)) + f(a.dataset.value)) / t) * (l.value.height - i.value.top - i.value.bottom);
    }), se = h(() => `${M.value}px`), le = h(() => `${l.value.height - e.value.style.chart.padding.bottom - i.value.top}px`), ae = h(() => `${e.value.style.chart.animation.speedMs}ms`), oe = h(() => {
      if (a.dataset.colors) {
        if (!a.dataset.colors.from)
          return C(w.value[0] || _[0], P(a.dataset.colors.to), y.value || 10);
        if (!a.dataset.colors.to)
          return C(P(a.dataset.colors.from), w.value[1] || _[1], y.value || 10);
      } else
        return C(w.value[1] || _[1], w.value[0] || _[0], y.value || 10);
      return C(P(a.dataset.colors.from), P(a.dataset.colors.to), y.value || 10);
    }), D = h(() => {
      const s = [];
      let r = 0;
      const t = l.value.height - i.value.top - i.value.bottom;
      for (let u = 0; u < t - 1; u += t / y.value)
        s.push({
          x: l.value.left,
          y: l.value.top + u,
          qYLess: l.value.top + u + t / y.value / 4,
          halfY: l.value.top + u + t / y.value / 2,
          qYMore: l.value.top + u + t / y.value / 4 * 3,
          color: oe.value[r],
          height: t / y.value
        }), r += 1;
      return s;
    }), p = m(!1);
    function re(s) {
      p.value = s, G.value += 1;
    }
    return Q({
      generatePdf: B,
      generateImage: j
    }), (s, r) => (o(), n("div", {
      ref_key: "thermoChart",
      ref: T,
      class: $(`vue-ui-thermometer ${p.value ? "vue-data-ui-wrapper-fullscreen" : ""}`),
      style: ye(`width:100%;background:${e.value.style.chart.backgroundColor};color:${e.value.style.chart.color};font-family:${e.value.style.fontFamily}`),
      id: `thermometer__${g.value}`
    }, [
      e.value.style.title.text ? (o(), n("div", Le, [
        (o(), U(Ye, {
          key: `title_${V.value}`,
          config: {
            title: {
              cy: "thermometer-div-title",
              ...e.value.style.title
            },
            subtitle: {
              cy: "thermometer-div-subtitle",
              ...e.value.style.title.subtitle
            }
          }
        }, null, 8, ["config"]))
      ])) : c("", !0),
      e.value.userOptions.show && I.value ? (o(), U(Me, {
        ref: "details",
        key: `user_options_${G.value}`,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        isImaging: v(z),
        isPrinting: v(E),
        uid: g.value,
        hasPdf: e.value.userOptions.buttons.pdf,
        hasImg: e.value.userOptions.buttons.img,
        hasFullscreen: e.value.userOptions.buttons.fullscreen,
        hasXls: !1,
        isFullscreen: p.value,
        titles: { ...e.value.userOptions.buttonTitles },
        chartElement: T.value,
        position: e.value.userOptions.position,
        onToggleFullscreen: re,
        onGeneratePdf: v(B),
        onGenerateImage: v(j)
      }, fe({ _: 2 }, [
        s.$slots.optionPdf ? {
          name: "optionPdf",
          fn: q(() => [
            x(s.$slots, "optionPdf", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        s.$slots.optionImg ? {
          name: "optionImg",
          fn: q(() => [
            x(s.$slots, "optionImg", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0,
        s.$slots.optionFullscreen ? {
          name: "optionFullscreen",
          fn: q(({ toggleFullscreen: t, isFullscreen: u }) => [
            x(s.$slots, "optionFullscreen", H(X({ toggleFullscreen: t, isFullscreen: u })), void 0, !0)
          ]),
          key: "2"
        } : void 0
      ]), 1032, ["backgroundColor", "color", "isImaging", "isPrinting", "uid", "hasPdf", "hasImg", "hasFullscreen", "isFullscreen", "titles", "chartElement", "position", "onGeneratePdf", "onGenerateImage"])) : c("", !0),
      I.value ? (o(), n("svg", {
        key: 2,
        xmlns: v($e),
        class: $({ "vue-data-ui-fullscreen--on": p.value, "vue-data-ui-fulscreen--off": !p.value }),
        width: "100%",
        viewBox: `0 0 ${l.value.width} ${l.value.height}`,
        style: "background:transparent"
      }, [
        me(Se),
        d("defs", null, [
          d("clipPath", Ge, [
            d("rect", {
              x: "0",
              y: "0",
              width: "1",
              height: "1",
              rx: "0.5",
              ry: "0.07",
              fill: e.value.style.chart.backgroundColor
            }, null, 8, Ve)
          ]),
          (o(!0), n(F, null, R(D.value, (t, u) => (o(), n("linearGradient", {
            id: `vueUiThermometerGradient_${u}_${g.value}`,
            x1: "0%",
            y1: "0%",
            x2: "100%",
            y2: "0%"
          }, [
            d("stop", {
              offset: "0%",
              "stop-color": t.color
            }, null, 8, Ee),
            d("stop", {
              offset: "50%",
              "stop-color": v(Fe)(t.color, 100 - e.value.style.chart.graduations.gradient.intensity)
            }, null, 8, ze),
            d("stop", {
              offset: "100%",
              "stop-color": t.color
            }, null, 8, Be)
          ], 8, We))), 256))
        ]),
        d("g", je, [
          d("rect", {
            x: l.value.left,
            y: l.value.top,
            height: l.value.height - i.value.top - i.value.bottom,
            width: l.value.width - i.value.left - i.value.right,
            fill: "#FFFFFF"
          }, null, 8, Ae),
          (o(!0), n(F, null, R(D.value, (t, u) => (o(), n("g", {
            key: `graduation_${u}`
          }, [
            d("rect", {
              x: t.x,
              y: t.y,
              height: t.height,
              width: l.value.width - e.value.style.chart.padding.left - e.value.style.chart.padding.right,
              fill: e.value.style.chart.graduations.gradient.show ? `url(#vueUiThermometerGradient_${u}_${g.value})` : t.color,
              "shape-rendering": "crispEdges"
            }, null, 8, De),
            e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
              key: 0,
              x1: t.x,
              x2: t.x + 10,
              y1: t.y,
              y2: t.y,
              "stroke-width": e.value.style.chart.graduations.strokeWidth,
              stroke: e.value.style.chart.graduations.stroke,
              "stroke-linecap": "round"
            }, null, 8, He)) : c("", !0),
            e.value.style.chart.graduations.showIntermediate ? (o(), n(F, { key: 1 }, [
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
                key: 0,
                x1: t.x,
                x2: t.x + 5,
                y1: t.halfY,
                y2: t.halfY,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, Xe)) : c("", !0),
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
                key: 1,
                x1: t.x,
                x2: t.x + 2.5,
                y1: t.qYLess,
                y2: t.qYLess,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, Re)) : c("", !0),
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
                key: 2,
                x1: t.x,
                x2: t.x + 2.5,
                y1: t.qYMore,
                y2: t.qYMore,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, Je)) : c("", !0)
            ], 64)) : c("", !0),
            e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
              key: 2,
              x1: l.value.right,
              x2: l.value.right - 10,
              y1: t.y,
              y2: t.y,
              "stroke-width": e.value.style.chart.graduations.strokeWidth,
              stroke: e.value.style.chart.graduations.stroke,
              "stroke-linecap": "round"
            }, null, 8, Ke)) : c("", !0),
            e.value.style.chart.graduations.showIntermediate ? (o(), n(F, { key: 3 }, [
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
                key: 0,
                x1: l.value.right,
                x2: l.value.right - 5,
                y1: t.halfY,
                y2: t.halfY,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, Qe)) : c("", !0),
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
                key: 1,
                x1: l.value.right,
                x2: l.value.right - 2.5,
                y1: t.qYLess,
                y2: t.qYLess,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, Ze)) : c("", !0),
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (o(), n("line", {
                key: 2,
                x1: l.value.right,
                x2: l.value.right - 2.5,
                y1: t.qYMore,
                y2: t.qYMore,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, et)) : c("", !0)
            ], 64)) : c("", !0)
          ]))), 128)),
          d("rect", {
            class: $({ "vue-ui-thermometer-temperature": e.value.style.chart.animation.use }),
            x: l.value.left,
            y: l.value.top,
            height: M.value,
            width: l.value.width - e.value.style.chart.padding.left - e.value.style.chart.padding.right,
            fill: "#FFFFFF66"
          }, null, 10, tt)
        ]),
        d("text", {
          class: $({ "vue-ui-thermometer-temperature-value": e.value.style.chart.animation.use }),
          y: M.value + l.value.top + e.value.style.chart.label.fontSize / 3,
          x: l.value.left - 10,
          "text-anchor": "end",
          fill: e.value.style.chart.label.color,
          "font-size": e.value.style.chart.label.fontSize,
          "font-weight": e.value.style.chart.label.bold ? "bold" : "normal"
        }, ge(v(Pe)(
          e.value.style.chart.label.formatter,
          b.dataset.value,
          v(Ie)({
            p: e.value.style.chart.label.prefix,
            v: b.dataset.value,
            s: e.value.style.chart.label.suffix,
            r: e.value.style.chart.label.rounding
          }),
          { datapoint: b.dataset }
        )), 11, st),
        x(s.$slots, "svg", { svg: te.value }, void 0, !0)
      ], 10, Te)) : c("", !0),
      s.$slots.watermark ? (o(), n("div", lt, [
        x(s.$slots, "watermark", H(X({ isPrinting: v(E) || v(z) })), void 0, !0)
      ])) : c("", !0),
      I.value ? c("", !0) : (o(), U(Ne, {
        key: 4,
        config: {
          type: "thermometer",
          style: {
            backgroundColor: e.value.style.chart.backgroundColor,
            thermometer: {
              color: "#CCCCCC"
            }
          }
        }
      }, null, 8, ["config"]))
    ], 14, qe));
  }
}, vt = /* @__PURE__ */ Ue(at, [["__scopeId", "data-v-cef2c8d4"]]);
export {
  vt as default
};
