import { useCssVars as me, computed as d, onMounted as ke, ref as p, watch as be, openBlock as a, createElementBlock as n, normalizeClass as P, normalizeStyle as ee, unref as h, createBlock as F, createCommentVNode as i, createSlots as xe, withCtx as O, renderSlot as g, normalizeProps as E, guardReactiveProps as G, createVNode as _e, createElementVNode as v, Fragment as I, renderList as te, toDisplayString as we } from "vue";
import { u as Ce, o as $e, e as se, g as Pe, c as Fe, t as Oe, a as Ie, p as x, b as Ae, v as f, d as A, X as Me, s as Ue, i as Ye, f as Ne } from "./index-BVNcFEqn.js";
import { _ as Se } from "./Title-DyUTj8GI.js";
import { u as Te, U as qe } from "./usePrinter-Bcfs_I6G.js";
import Le from "./vue-ui-skeleton-Bgf16k10.js";
import { u as oe } from "./useNestedProp-D79dWdel.js";
import { _ as Ve } from "./PackageVersion-B9_Ed72C.js";
import { P as Ee } from "./PenAndPaper-CzjoEhsO.js";
import { u as Ge } from "./useUserOptionState-BIvW1Kz7.js";
import { _ as We } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const je = ["id"], ze = {
  key: 1,
  ref: "noTitle",
  class: "vue-data-ui-no-title-space",
  style: "height:36px; width: 100%;background:transparent"
}, Be = {
  key: 2,
  style: "width:100%"
}, De = ["xmlns", "viewBox"], He = ["width", "height"], Xe = {
  id: "vueUiPill",
  clipPathUnits: "objectBoundingBox"
}, Re = ["fill"], Je = ["id"], Ke = ["stop-color"], Qe = ["stop-color"], Ze = ["stop-color"], et = { "clip-path": "url(#vueUiPill)" }, tt = ["x", "y", "height", "width"], st = ["x", "y", "height", "width", "fill"], ot = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], at = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], lt = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], rt = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], nt = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ut = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], it = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ht = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ct = ["x", "y", "height", "width"], dt = ["y", "x", "fill", "font-size", "font-weight"], vt = {
  key: 5,
  class: "vue-data-ui-watermark"
}, yt = {
  key: 6,
  ref: "source",
  dir: "auto"
}, ft = {
  __name: "vue-ui-thermometer",
  props: {
    dataset: {
      type: Object,
      default() {
        return {};
      }
    },
    config: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  setup(_, { expose: ae }) {
    const l = _;
    me((s) => ({
      "7f5072bd": ce.value,
      "575f6d71": he.value,
      "041baa9e": ie.value
    }));
    const { vue_ui_thermometer: le } = Ce(), M = d(() => !!l.dataset && Object.keys(l.dataset).length);
    ke(() => {
      W();
    });
    function W() {
      $e(l.dataset) ? se({
        componentName: "VueUiThermometer",
        type: "dataset"
      }) : Pe({
        datasetObject: l.dataset,
        requiredAttributes: ["value", "from", "to"]
      }).forEach((s) => {
        se({
          componentName: "VueUiThermometer",
          type: "datasetAttribute",
          property: s
        });
      });
    }
    const m = p(Fe()), U = p(null), j = p(0), z = p(0), e = d({
      get: () => H(),
      set: (s) => s
    }), { userOptionsVisible: Y, setUserOptionsVisibility: B, keepUserOptionState: D } = Ge({ config: e.value });
    function H() {
      const s = oe({
        userConfig: l.config,
        defaultConfig: le
      });
      return s.theme ? {
        ...oe({
          userConfig: Oe.vue_ui_thermometer[s.theme] || l.config,
          defaultConfig: s
        }),
        customPalette: Ie[s.theme] || x
      } : s;
    }
    be(() => l.config, (s) => {
      e.value = H(), Y.value = !e.value.showOnChartHover, W(), z.value += 1;
    }, { deep: !0 });
    const { isPrinting: X, isImaging: R, generatePdf: J, generateImage: K } = Te({
      elementId: `thermometer__${m.value}`,
      fileName: e.value.style.title.text || "vue-ui-thermometer"
    }), re = d(() => e.value.userOptions.show && !e.value.style.title.text), w = d(() => Ae(e.value.customPalette)), ne = d(() => e.value.style.chart.thermometer.width), y = d(() => l.dataset.steps || 10), c = p({
      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 = [], L = Q(s), V = Q(r);
      for (let b = 0; b < t; b++) {
        const ye = N(L.red, V.red, b, t), fe = N(L.green, V.green, b, t), ge = N(L.blue, V.blue, b, t), pe = `#${S(ye)}${S(fe)}${S(ge)}`;
        u.push(pe);
      }
      return u;
    }
    function Q(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 N(s, r, t, u) {
      return Math.round(s + (r - s) * t / u);
    }
    function S(s) {
      return s.toString(16).padStart(2, "0");
    }
    const o = d(() => {
      const s = ne.value + c.value.left + c.value.right, r = e.value.style.chart.height;
      return {
        width: s,
        left: c.value.left,
        right: s - c.value.right,
        top: c.value.top,
        bottom: r - c.value.bottom,
        height: r
      };
    }), ue = d(() => o.value), T = d(() => {
      const s = f(l.dataset.from) < 0 ? Math.abs(f(l.dataset.from)) : f(l.dataset.from), r = f(l.dataset.to) < 0 ? Math.abs(f(l.dataset.to)) : f(l.dataset.to);
      let t = 0;
      return f(l.dataset.to) > 0 ? t = s + r : s > r ? t = s - r : t = r - s, (1 - (Math.abs(f(l.dataset.from)) + f(l.dataset.value)) / t) * (o.value.height - c.value.top - c.value.bottom);
    }), ie = d(() => `${T.value}px`), he = d(() => `${o.value.height - e.value.style.chart.padding.bottom - c.value.top}px`), ce = d(() => `${e.value.style.chart.animation.speedMs}ms`), de = d(() => {
      if (l.dataset.colors) {
        if (!l.dataset.colors.from)
          return C(w.value[0] || x[0], A(l.dataset.colors.to), y.value || 10);
        if (!l.dataset.colors.to)
          return C(A(l.dataset.colors.from), w.value[1] || x[1], y.value || 10);
      } else
        return C(w.value[1] || x[1], w.value[0] || x[0], y.value || 10);
      return C(A(l.dataset.colors.from), A(l.dataset.colors.to), y.value || 10);
    }), Z = d(() => {
      const s = [];
      let r = 0;
      const t = o.value.height - c.value.top - c.value.bottom;
      for (let u = 0; u < t - 1; u += t / y.value)
        s.push({
          x: o.value.left,
          y: o.value.top + u,
          qYLess: o.value.top + u + t / y.value / 4,
          halfY: o.value.top + u + t / y.value / 2,
          qYMore: o.value.top + u + t / y.value / 4 * 3,
          color: de.value[r],
          height: t / y.value
        }), r += 1;
      return s;
    }), k = p(!1);
    function ve(s) {
      k.value = s, j.value += 1;
    }
    const $ = p(!1);
    function q() {
      $.value = !$.value;
    }
    return ae({
      generatePdf: J,
      generateImage: K,
      toggleAnnotator: q
    }), (s, r) => (a(), n("div", {
      ref_key: "thermoChart",
      ref: U,
      class: P(`vue-ui-thermometer ${k.value ? "vue-data-ui-wrapper-fullscreen" : ""}`),
      style: ee(`width:100%;background:${e.value.style.chart.backgroundColor};color:${e.value.style.chart.color};font-family:${e.value.style.fontFamily}`),
      id: `thermometer__${m.value}`,
      onMouseenter: r[0] || (r[0] = () => h(B)(!0)),
      onMouseleave: r[1] || (r[1] = () => h(B)(!1))
    }, [
      e.value.userOptions.buttons.annotator ? (a(), F(Ee, {
        key: 0,
        parent: U.value,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        active: $.value,
        onClose: q
      }, null, 8, ["parent", "backgroundColor", "color", "active"])) : i("", !0),
      re.value ? (a(), n("div", ze, null, 512)) : i("", !0),
      e.value.style.title.text ? (a(), n("div", Be, [
        (a(), F(Se, {
          key: `title_${z.value}`,
          config: {
            title: {
              cy: "thermometer-div-title",
              ...e.value.style.title
            },
            subtitle: {
              cy: "thermometer-div-subtitle",
              ...e.value.style.title.subtitle
            }
          }
        }, null, 8, ["config"]))
      ])) : i("", !0),
      e.value.userOptions.show && M.value && (h(D) || h(Y)) ? (a(), F(qe, {
        ref: "details",
        key: `user_options_${j.value}`,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        isImaging: h(R),
        isPrinting: h(X),
        uid: m.value,
        hasPdf: e.value.userOptions.buttons.pdf,
        hasImg: e.value.userOptions.buttons.img,
        hasFullscreen: e.value.userOptions.buttons.fullscreen,
        hasXls: !1,
        isFullscreen: k.value,
        titles: { ...e.value.userOptions.buttonTitles },
        chartElement: U.value,
        position: e.value.userOptions.position,
        hasAnnotator: e.value.userOptions.buttons.annotator,
        isAnnotation: $.value,
        onToggleFullscreen: ve,
        onGeneratePdf: h(J),
        onGenerateImage: h(K),
        onToggleAnnotator: q,
        style: ee({
          visibility: h(D) ? h(Y) ? "visible" : "hidden" : "visible"
        })
      }, xe({ _: 2 }, [
        s.$slots.optionPdf ? {
          name: "optionPdf",
          fn: O(() => [
            g(s.$slots, "optionPdf", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        s.$slots.optionImg ? {
          name: "optionImg",
          fn: O(() => [
            g(s.$slots, "optionImg", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0,
        s.$slots.optionFullscreen ? {
          name: "optionFullscreen",
          fn: O(({ toggleFullscreen: t, isFullscreen: u }) => [
            g(s.$slots, "optionFullscreen", E(G({ toggleFullscreen: t, isFullscreen: u })), void 0, !0)
          ]),
          key: "2"
        } : void 0,
        s.$slots.optionAnnotator ? {
          name: "optionAnnotator",
          fn: O(({ toggleAnnotator: t, isAnnotator: u }) => [
            g(s.$slots, "optionAnnotator", E(G({ toggleAnnotator: t, 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"])) : i("", !0),
      M.value ? (a(), n("svg", {
        key: 4,
        xmlns: h(Me),
        class: P({ "vue-data-ui-fullscreen--on": k.value, "vue-data-ui-fulscreen--off": !k.value }),
        width: "100%",
        viewBox: `0 0 ${o.value.width} ${o.value.height}`,
        style: "background:transparent"
      }, [
        _e(Ve),
        s.$slots["chart-background"] ? (a(), n("foreignObject", {
          key: 0,
          x: 0,
          y: 0,
          width: o.value.width,
          height: o.value.height,
          style: {
            pointerEvents: "none"
          }
        }, [
          g(s.$slots, "chart-background", {}, void 0, !0)
        ], 8, He)) : i("", !0),
        v("defs", null, [
          v("clipPath", Xe, [
            v("rect", {
              x: "0",
              y: "0",
              width: "1",
              height: "1",
              rx: "0.5",
              ry: "0.07",
              fill: e.value.style.chart.backgroundColor
            }, null, 8, Re)
          ]),
          (a(!0), n(I, null, te(Z.value, (t, u) => (a(), n("linearGradient", {
            id: `vueUiThermometerGradient_${u}_${m.value}`,
            x1: "0%",
            y1: "0%",
            x2: "100%",
            y2: "0%"
          }, [
            v("stop", {
              offset: "0%",
              "stop-color": t.color
            }, null, 8, Ke),
            v("stop", {
              offset: "50%",
              "stop-color": h(Ue)(t.color, 100 - e.value.style.chart.graduations.gradient.intensity)
            }, null, 8, Qe),
            v("stop", {
              offset: "100%",
              "stop-color": t.color
            }, null, 8, Ze)
          ], 8, Je))), 256))
        ]),
        v("g", et, [
          v("rect", {
            x: o.value.left,
            y: o.value.top,
            height: o.value.height - c.value.top - c.value.bottom,
            width: o.value.width - c.value.left - c.value.right,
            fill: "#FFFFFF"
          }, null, 8, tt),
          (a(!0), n(I, null, te(Z.value, (t, u) => (a(), n("g", {
            key: `graduation_${u}`
          }, [
            v("rect", {
              x: t.x,
              y: t.y,
              height: t.height,
              width: o.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, st),
            e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (a(), 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, ot)) : i("", !0),
            e.value.style.chart.graduations.showIntermediate ? (a(), n(I, { key: 1 }, [
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (a(), 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, at)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (a(), 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, lt)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (a(), 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, rt)) : i("", !0)
            ], 64)) : i("", !0),
            e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (a(), n("line", {
              key: 2,
              x1: o.value.right,
              x2: o.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, nt)) : i("", !0),
            e.value.style.chart.graduations.showIntermediate ? (a(), n(I, { key: 3 }, [
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (a(), n("line", {
                key: 0,
                x1: o.value.right,
                x2: o.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, ut)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (a(), n("line", {
                key: 1,
                x1: o.value.right,
                x2: o.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, it)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (a(), n("line", {
                key: 2,
                x1: o.value.right,
                x2: o.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, ht)) : i("", !0)
            ], 64)) : i("", !0)
          ]))), 128)),
          v("rect", {
            class: P({ "vue-ui-thermometer-temperature": e.value.style.chart.animation.use }),
            x: o.value.left,
            y: o.value.top,
            height: T.value,
            width: o.value.width - e.value.style.chart.padding.left - e.value.style.chart.padding.right,
            fill: "#FFFFFF66"
          }, null, 10, ct)
        ]),
        v("text", {
          class: P({ "vue-ui-thermometer-temperature-value": e.value.style.chart.animation.use }),
          y: T.value + o.value.top + e.value.style.chart.label.fontSize / 3,
          x: o.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"
        }, we(h(Ye)(
          e.value.style.chart.label.formatter,
          _.dataset.value,
          h(Ne)({
            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, dt),
        g(s.$slots, "svg", { svg: ue.value }, void 0, !0)
      ], 10, De)) : i("", !0),
      s.$slots.watermark ? (a(), n("div", vt, [
        g(s.$slots, "watermark", E(G({ isPrinting: h(X) || h(R) })), void 0, !0)
      ])) : i("", !0),
      s.$slots.source ? (a(), n("div", yt, [
        g(s.$slots, "source", {}, void 0, !0)
      ], 512)) : i("", !0),
      M.value ? i("", !0) : (a(), F(Le, {
        key: 7,
        config: {
          type: "thermometer",
          style: {
            backgroundColor: e.value.style.chart.backgroundColor,
            thermometer: {
              color: "#CCCCCC"
            }
          }
        }
      }, null, 8, ["config"]))
    ], 46, je));
  }
}, Pt = /* @__PURE__ */ We(ft, [["__scopeId", "data-v-f7910f15"]]);
export {
  Pt as default
};
