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