import { useCssVars as kt, unref as t, computed as d, onMounted as vt, ref as m, watch as bt, openBlock as a, createElementBlock as i, normalizeClass as P, normalizeStyle as tt, createBlock as F, createCommentVNode as h, createSlots as xt, withCtx as O, renderSlot as p, normalizeProps as E, guardReactiveProps as G, createVNode as _t, createElementVNode as y, Fragment as I, renderList as et, toDisplayString as wt } from "vue";
import { u as Ct, o as $t, e as st, g as Pt, c as Ft, t as Ot, a as It, p as x, b as At, v as g, d as A, X as Mt, s as Ut, i as Yt, f as Nt } from "./index-WrV3SAID.js";
import { _ as St } from "./Title-BR-xoRp4.js";
import { u as Tt, U as qt } from "./usePrinter-kVpf1iV8.js";
import Lt from "./vue-ui-skeleton-Qec_XSRf.js";
import { u as ot } from "./useNestedProp-Cj0kHD7k.js";
import { _ as Vt } from "./PackageVersion-1NslmM8M.js";
import { P as Et } from "./PenAndPaper-BF1ZRVm3.js";
import { u as Gt } from "./useUserOptionState-BIvW1Kz7.js";
import { _ as Wt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const jt = ["id"], zt = {
  key: 1,
  ref: "noTitle",
  class: "vue-data-ui-no-title-space",
  style: "height:36px; width: 100%;background:transparent"
}, Bt = {
  key: 2,
  style: "width:100%"
}, Dt = ["xmlns", "viewBox"], Ht = ["width", "height"], Xt = {
  id: "vueUiPill",
  clipPathUnits: "objectBoundingBox"
}, Rt = ["fill"], Jt = ["id"], Kt = ["stop-color"], Qt = ["stop-color"], Zt = ["stop-color"], te = { "clip-path": "url(#vueUiPill)" }, ee = ["x", "y", "height", "width"], se = ["x", "y", "height", "width", "fill"], oe = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], re = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ae = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], le = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ne = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ie = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ue = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], he = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ce = ["x", "y", "height", "width"], de = ["y", "x", "fill", "font-size", "font-weight"], ye = {
  key: 5,
  class: "vue-data-ui-watermark"
}, fe = {
  key: 6,
  ref: "source",
  dir: "auto"
}, ge = {
  __name: "vue-ui-thermometer",
  props: {
    dataset: {
      type: Object,
      default() {
        return {};
      }
    },
    config: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  setup(_, { expose: rt }) {
    kt((o) => ({
      "0db7fa96": t(ct),
      d42e3e90: t(ht),
      "51b178b6": t(ut)
    }));
    const { vue_ui_thermometer: at } = Ct(), l = _, M = d(() => !!l.dataset && Object.keys(l.dataset).length);
    vt(() => {
      W();
    });
    function W() {
      $t(l.dataset) ? st({
        componentName: "VueUiThermometer",
        type: "dataset"
      }) : Pt({
        datasetObject: l.dataset,
        requiredAttributes: ["value", "from", "to"]
      }).forEach((o) => {
        st({
          componentName: "VueUiThermometer",
          type: "datasetAttribute",
          property: o
        });
      });
    }
    const k = m(Ft()), U = m(null), j = m(0), z = m(0), e = d({
      get: () => H(),
      set: (o) => o
    }), { userOptionsVisible: Y, setUserOptionsVisibility: B, keepUserOptionState: D } = Gt({ config: e.value });
    function H() {
      const o = ot({
        userConfig: l.config,
        defaultConfig: at
      });
      return o.theme ? {
        ...ot({
          userConfig: Ot.vue_ui_thermometer[o.theme] || l.config,
          defaultConfig: o
        }),
        customPalette: It[o.theme] || x
      } : o;
    }
    bt(() => l.config, (o) => {
      e.value = H(), Y.value = !e.value.showOnChartHover, W(), z.value += 1;
    }, { deep: !0 });
    const { isPrinting: X, isImaging: R, generatePdf: J, generateImage: K } = Tt({
      elementId: `thermometer__${k.value}`,
      fileName: e.value.style.title.text || "vue-ui-thermometer"
    }), lt = d(() => e.value.userOptions.show && !e.value.style.title.text), w = d(() => At(e.value.customPalette)), nt = d(() => e.value.style.chart.thermometer.width), f = d(() => l.dataset.steps || 10), c = 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(o, n, s) {
      const u = [], L = Q(o), V = Q(n);
      for (let b = 0; b < s; b++) {
        const ft = N(L.red, V.red, b, s), gt = N(L.green, V.green, b, s), pt = N(L.blue, V.blue, b, s), mt = `#${S(ft)}${S(gt)}${S(pt)}`;
        u.push(mt);
      }
      return u;
    }
    function Q(o) {
      const n = o.slice(1);
      return {
        red: parseInt(n.slice(0, 2), 16),
        green: parseInt(n.slice(2, 4), 16),
        blue: parseInt(n.slice(4, 6), 16)
      };
    }
    function N(o, n, s, u) {
      return Math.round(o + (n - o) * s / u);
    }
    function S(o) {
      return o.toString(16).padStart(2, "0");
    }
    const r = d(() => {
      const o = nt.value + c.value.left + c.value.right, n = e.value.style.chart.height;
      return {
        width: o,
        left: c.value.left,
        right: o - c.value.right,
        top: c.value.top,
        bottom: n - c.value.bottom,
        height: n
      };
    }), it = d(() => r.value), T = d(() => {
      const o = g(l.dataset.from) < 0 ? Math.abs(g(l.dataset.from)) : g(l.dataset.from), n = g(l.dataset.to) < 0 ? Math.abs(g(l.dataset.to)) : g(l.dataset.to);
      let s = 0;
      return g(l.dataset.to) > 0 ? s = o + n : o > n ? s = o - n : s = n - o, (1 - (Math.abs(g(l.dataset.from)) + g(l.dataset.value)) / s) * (r.value.height - c.value.top - c.value.bottom);
    }), ut = d(() => `${T.value}px`), ht = d(() => `${r.value.height - e.value.style.chart.padding.bottom - c.value.top}px`), ct = d(() => `${e.value.style.chart.animation.speedMs}ms`), dt = d(() => {
      if (l.dataset.colors) {
        if (!l.dataset.colors.from)
          return C(w.value[0] || x[0], A(l.dataset.colors.to), f.value || 10);
        if (!l.dataset.colors.to)
          return C(A(l.dataset.colors.from), w.value[1] || x[1], f.value || 10);
      } else
        return C(w.value[1] || x[1], w.value[0] || x[0], f.value || 10);
      return C(A(l.dataset.colors.from), A(l.dataset.colors.to), f.value || 10);
    }), Z = d(() => {
      const o = [];
      let n = 0;
      const s = r.value.height - c.value.top - c.value.bottom;
      for (let u = 0; u < s - 1; u += s / f.value)
        o.push({
          x: r.value.left,
          y: r.value.top + u,
          qYLess: r.value.top + u + s / f.value / 4,
          halfY: r.value.top + u + s / f.value / 2,
          qYMore: r.value.top + u + s / f.value / 4 * 3,
          color: dt.value[n],
          height: s / f.value
        }), n += 1;
      return o;
    }), v = m(!1);
    function yt(o) {
      v.value = o, j.value += 1;
    }
    const $ = m(!1);
    function q() {
      $.value = !$.value;
    }
    return rt({
      generatePdf: J,
      generateImage: K,
      toggleAnnotator: q
    }), (o, n) => (a(), i("div", {
      ref_key: "thermoChart",
      ref: U,
      class: P(`vue-ui-thermometer ${t(v) ? "vue-data-ui-wrapper-fullscreen" : ""}`),
      style: tt(`width:100%;background:${t(e).style.chart.backgroundColor};color:${t(e).style.chart.color};font-family:${t(e).style.fontFamily}`),
      id: `thermometer__${t(k)}`,
      onMouseenter: n[0] || (n[0] = () => t(B)(!0)),
      onMouseleave: n[1] || (n[1] = () => t(B)(!1))
    }, [
      t(e).userOptions.buttons.annotator ? (a(), F(Et, {
        key: 0,
        parent: t(U),
        backgroundColor: t(e).style.chart.backgroundColor,
        color: t(e).style.chart.color,
        active: t($),
        onClose: q
      }, null, 8, ["parent", "backgroundColor", "color", "active"])) : h("", !0),
      t(lt) ? (a(), i("div", zt, null, 512)) : h("", !0),
      t(e).style.title.text ? (a(), i("div", Bt, [
        (a(), F(St, {
          key: `title_${t(z)}`,
          config: {
            title: {
              cy: "thermometer-div-title",
              ...t(e).style.title
            },
            subtitle: {
              cy: "thermometer-div-subtitle",
              ...t(e).style.title.subtitle
            }
          }
        }, null, 8, ["config"]))
      ])) : h("", !0),
      t(e).userOptions.show && t(M) && (t(D) || t(Y)) ? (a(), F(qt, {
        ref: "details",
        key: `user_options_${t(j)}`,
        backgroundColor: t(e).style.chart.backgroundColor,
        color: t(e).style.chart.color,
        isImaging: t(R),
        isPrinting: t(X),
        uid: t(k),
        hasPdf: t(e).userOptions.buttons.pdf,
        hasImg: t(e).userOptions.buttons.img,
        hasFullscreen: t(e).userOptions.buttons.fullscreen,
        hasXls: !1,
        isFullscreen: t(v),
        titles: { ...t(e).userOptions.buttonTitles },
        chartElement: t(U),
        position: t(e).userOptions.position,
        hasAnnotator: t(e).userOptions.buttons.annotator,
        isAnnotation: t($),
        onToggleFullscreen: yt,
        onGeneratePdf: t(J),
        onGenerateImage: t(K),
        onToggleAnnotator: q,
        style: tt({
          visibility: t(D) ? t(Y) ? "visible" : "hidden" : "visible"
        })
      }, xt({ _: 2 }, [
        o.$slots.optionPdf ? {
          name: "optionPdf",
          fn: O(() => [
            p(o.$slots, "optionPdf", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        o.$slots.optionImg ? {
          name: "optionImg",
          fn: O(() => [
            p(o.$slots, "optionImg", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0,
        o.$slots.optionFullscreen ? {
          name: "optionFullscreen",
          fn: O(({ toggleFullscreen: s, isFullscreen: u }) => [
            p(o.$slots, "optionFullscreen", E(G({ toggleFullscreen: s, isFullscreen: u })), void 0, !0)
          ]),
          key: "2"
        } : void 0,
        o.$slots.optionAnnotator ? {
          name: "optionAnnotator",
          fn: O(({ toggleAnnotator: s, isAnnotator: u }) => [
            p(o.$slots, "optionAnnotator", E(G({ toggleAnnotator: s, isAnnotator: u })), void 0, !0)
          ]),
          key: "3"
        } : void 0
      ]), 1032, ["backgroundColor", "color", "isImaging", "isPrinting", "uid", "hasPdf", "hasImg", "hasFullscreen", "isFullscreen", "titles", "chartElement", "position", "hasAnnotator", "isAnnotation", "onGeneratePdf", "onGenerateImage", "style"])) : h("", !0),
      t(M) ? (a(), i("svg", {
        key: 4,
        xmlns: t(Mt),
        class: P({ "vue-data-ui-fullscreen--on": t(v), "vue-data-ui-fulscreen--off": !t(v) }),
        width: "100%",
        viewBox: `0 0 ${t(r).width} ${t(r).height}`,
        style: "background:transparent"
      }, [
        _t(Vt),
        o.$slots["chart-background"] ? (a(), i("foreignObject", {
          key: 0,
          x: 0,
          y: 0,
          width: t(r).width,
          height: t(r).height,
          style: {
            pointerEvents: "none"
          }
        }, [
          p(o.$slots, "chart-background", {}, void 0, !0)
        ], 8, Ht)) : h("", !0),
        y("defs", null, [
          y("clipPath", Xt, [
            y("rect", {
              x: "0",
              y: "0",
              width: "1",
              height: "1",
              rx: "0.5",
              ry: "0.07",
              fill: t(e).style.chart.backgroundColor
            }, null, 8, Rt)
          ]),
          (a(!0), i(I, null, et(t(Z), (s, u) => (a(), i("linearGradient", {
            id: `vueUiThermometerGradient_${u}_${t(k)}`,
            x1: "0%",
            y1: "0%",
            x2: "100%",
            y2: "0%"
          }, [
            y("stop", {
              offset: "0%",
              "stop-color": s.color
            }, null, 8, Kt),
            y("stop", {
              offset: "50%",
              "stop-color": t(Ut)(s.color, 100 - t(e).style.chart.graduations.gradient.intensity)
            }, null, 8, Qt),
            y("stop", {
              offset: "100%",
              "stop-color": s.color
            }, null, 8, Zt)
          ], 8, Jt))), 256))
        ]),
        y("g", te, [
          y("rect", {
            x: t(r).left,
            y: t(r).top,
            height: t(r).height - t(c).top - t(c).bottom,
            width: t(r).width - t(c).left - t(c).right,
            fill: "#FFFFFF"
          }, null, 8, ee),
          (a(!0), i(I, null, et(t(Z), (s, u) => (a(), i("g", {
            key: `graduation_${u}`
          }, [
            y("rect", {
              x: s.x,
              y: s.y,
              height: s.height,
              width: t(r).width - t(e).style.chart.padding.left - t(e).style.chart.padding.right,
              fill: t(e).style.chart.graduations.gradient.show ? `url(#vueUiThermometerGradient_${u}_${t(k)})` : s.color,
              "shape-rendering": "crispEdges"
            }, null, 8, se),
            t(e).style.chart.graduations.show && ["both", "left"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
              key: 0,
              x1: s.x,
              x2: s.x + 10,
              y1: s.y,
              y2: s.y,
              "stroke-width": t(e).style.chart.graduations.strokeWidth,
              stroke: t(e).style.chart.graduations.stroke,
              "stroke-linecap": "round"
            }, null, 8, oe)) : h("", !0),
            t(e).style.chart.graduations.showIntermediate ? (a(), i(I, { key: 1 }, [
              t(e).style.chart.graduations.show && ["both", "left"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
                key: 0,
                x1: s.x,
                x2: s.x + 5,
                y1: s.halfY,
                y2: s.halfY,
                "stroke-width": t(e).style.chart.graduations.strokeWidth / 2,
                stroke: t(e).style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, re)) : h("", !0),
              t(e).style.chart.graduations.show && ["both", "left"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
                key: 1,
                x1: s.x,
                x2: s.x + 2.5,
                y1: s.qYLess,
                y2: s.qYLess,
                "stroke-width": t(e).style.chart.graduations.strokeWidth / 2,
                stroke: t(e).style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, ae)) : h("", !0),
              t(e).style.chart.graduations.show && ["both", "left"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
                key: 2,
                x1: s.x,
                x2: s.x + 2.5,
                y1: s.qYMore,
                y2: s.qYMore,
                "stroke-width": t(e).style.chart.graduations.strokeWidth / 2,
                stroke: t(e).style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, le)) : h("", !0)
            ], 64)) : h("", !0),
            t(e).style.chart.graduations.show && ["both", "right"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
              key: 2,
              x1: t(r).right,
              x2: t(r).right - 10,
              y1: s.y,
              y2: s.y,
              "stroke-width": t(e).style.chart.graduations.strokeWidth,
              stroke: t(e).style.chart.graduations.stroke,
              "stroke-linecap": "round"
            }, null, 8, ne)) : h("", !0),
            t(e).style.chart.graduations.showIntermediate ? (a(), i(I, { key: 3 }, [
              t(e).style.chart.graduations.show && ["both", "right"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
                key: 0,
                x1: t(r).right,
                x2: t(r).right - 5,
                y1: s.halfY,
                y2: s.halfY,
                "stroke-width": t(e).style.chart.graduations.strokeWidth / 2,
                stroke: t(e).style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, ie)) : h("", !0),
              t(e).style.chart.graduations.show && ["both", "right"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
                key: 1,
                x1: t(r).right,
                x2: t(r).right - 2.5,
                y1: s.qYLess,
                y2: s.qYLess,
                "stroke-width": t(e).style.chart.graduations.strokeWidth / 2,
                stroke: t(e).style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, ue)) : h("", !0),
              t(e).style.chart.graduations.show && ["both", "right"].includes(t(e).style.chart.graduations.sides) ? (a(), i("line", {
                key: 2,
                x1: t(r).right,
                x2: t(r).right - 2.5,
                y1: s.qYMore,
                y2: s.qYMore,
                "stroke-width": t(e).style.chart.graduations.strokeWidth / 2,
                stroke: t(e).style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, he)) : h("", !0)
            ], 64)) : h("", !0)
          ]))), 128)),
          y("rect", {
            class: P({ "vue-ui-thermometer-temperature": t(e).style.chart.animation.use }),
            x: t(r).left,
            y: t(r).top,
            height: t(T),
            width: t(r).width - t(e).style.chart.padding.left - t(e).style.chart.padding.right,
            fill: "#FFFFFF66"
          }, null, 10, ce)
        ]),
        y("text", {
          class: P({ "vue-ui-thermometer-temperature-value": t(e).style.chart.animation.use }),
          y: t(T) + t(r).top + t(e).style.chart.label.fontSize / 3,
          x: t(r).left - 10,
          "text-anchor": "end",
          fill: t(e).style.chart.label.color,
          "font-size": t(e).style.chart.label.fontSize,
          "font-weight": t(e).style.chart.label.bold ? "bold" : "normal"
        }, wt(t(Yt)(
          t(e).style.chart.label.formatter,
          _.dataset.value,
          t(Nt)({
            p: t(e).style.chart.label.prefix,
            v: _.dataset.value,
            s: t(e).style.chart.label.suffix,
            r: t(e).style.chart.label.rounding
          }),
          { datapoint: _.dataset }
        )), 11, de),
        p(o.$slots, "svg", { svg: t(it) }, void 0, !0)
      ], 10, Dt)) : h("", !0),
      o.$slots.watermark ? (a(), i("div", ye, [
        p(o.$slots, "watermark", E(G({ isPrinting: t(X) || t(R) })), void 0, !0)
      ])) : h("", !0),
      o.$slots.source ? (a(), i("div", fe, [
        p(o.$slots, "source", {}, void 0, !0)
      ], 512)) : h("", !0),
      t(M) ? h("", !0) : (a(), F(Lt, {
        key: 7,
        config: {
          type: "thermometer",
          style: {
            backgroundColor: t(e).style.chart.backgroundColor,
            thermometer: {
              color: "#CCCCCC"
            }
          }
        }
      }, null, 8, ["config"]))
    ], 46, jt));
  }
}, Pe = /* @__PURE__ */ Wt(ge, [["__scopeId", "data-v-f5875a02"]]);
export {
  Pe as default
};
