const _ = (o) => {
  let t = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  if (!t)
    return;
  let l = 100 * (t / 1920);
  return o * l;
}, w = ["#DDB868", "#CF9747", "#D3702C", "#546E98", "#769CC9", "#8EC2CC"], x = [
  {
    type: "linear",
    x: 0,
    y: 0,
    x2: 1,
    y2: 0,
    colorStops: [
      {
        offset: 0,
        color: "rgba(224,104,15,0.8)"
      },
      {
        offset: 1,
        color: "rgba(242,161,34,0.8)"
      }
    ],
    globalCoord: !1
  },
  {
    type: "linear",
    x: 0,
    y: 0,
    x2: 1,
    y2: 0,
    colorStops: [
      {
        offset: 0,
        color: "rgba(248,231,28,0.9)"
      },
      {
        offset: 1,
        color: "rgba(255,190,0,0.9)"
      }
    ],
    globalCoord: !1
  },
  {
    type: "linear",
    x: 0,
    y: 0,
    x2: 1,
    y2: 0,
    colorStops: [
      {
        offset: 0,
        color: "rgba(28,189,180,0.9)"
      },
      {
        offset: 1,
        color: "rgba(143,243,121,0.9)"
      }
    ],
    globalCoord: !1
  },
  {
    type: "linear",
    x: 0,
    y: 0,
    x2: 1,
    y2: 0,
    colorStops: [
      {
        offset: 0,
        color: "rgba(7,185,249,0.9)"
      },
      {
        offset: 1,
        color: "rgba(104,243,202,0.9)"
      }
    ],
    globalCoord: !1
  },
  {
    type: "linear",
    x: 0,
    y: 0,
    x2: 1,
    y2: 0,
    colorStops: [
      {
        offset: 0,
        color: "rgba(187,155,241,0.9)"
      },
      {
        offset: 1,
        color: "rgba(136,123,242,0.9)"
      }
    ],
    globalCoord: !1
  }
];
function L(o = 1, t = 100) {
  return Math.floor(Math.random() * (t - o + 1)) + o;
}
function v(o = 7) {
  let t = [];
  for (let l = 0; l < o; l++)
    t.push(L());
  return t;
}
function O(o) {
  let t = /* @__PURE__ */ new Map([
    ["0", ""],
    [0, ""],
    ["100", "line"],
    [100, "line"],
    ["200", "bar"],
    [200, "bar"],
    ["201", "bar"],
    [201, "bar"],
    ["202", "bar"],
    [202, "bar"],
    ["203", "bar"],
    [203, "bar"],
    ["300", "pie"],
    [300, "pie"],
    [301, "pie"],
    ["301", "pie"],
    [302, "pie"],
    ["400", "pie"],
    [400, "pie"],
    ["500", "map"],
    [500, "map"],
    ["700", "radar"],
    [700, "radar"],
    ["1601", "sankey"],
    [1601, "sankey"],
    ["2000", "pictorialBar"],
    [2e3, "pictorialBar"]
  ]);
  return t.get(o), console.log("777", t.get(o)), t.get(o);
}
class F {
  constructor() {
    this.resetDefault();
  }
  getEchartOption() {
    return {
      grid: {},
      title: {},
      color: [],
      legend: {
        data: []
      },
      toolTip: {},
      xAxis: {},
      yAxis: {},
      series: {
        name: "",
        type: "line",
        symbol: "emptyCircle",
        showSymbol: !0,
        smooth: !1,
        areaStyle: !1,
        stack: !1,
        emphasis: {
          focus: "series"
        },
        data: v(8)
      }
    };
  }
  resetDefault() {
    this.defaultTitle = {}, this.defaultColors = [], this.defaultLegends = {
      data: []
    }, this.defaultGrid = {}, this.defaultXAxis = [], this.defaultYAxis = [], this.defaultseries = [], this.angleAxis = [], this.radiusAxis = {}, this.polar = {
      center: ["50%", "53%"],
      radius: "60%"
    };
  }
  getChartsOption(t = {}) {
    var f, S, b, c, y;
    const {
      color: l = [],
      xAxis: h = [],
      yAxis: a = [],
      series: p = [],
      directionFlag: m = !1,
      legendFlag: d = !0,
      tooltip: s = {},
      legend: n = {},
      grid: g = {},
      pieOptions: u = {},
      chartScroll: i = {},
      linerAareaColor: r
    } = t;
    this.formatColors(r), this.formatAxis(t), this.formatSeries(t);
    let e = {
      color: this.defaultColors,
      tooltip: {
        trigger: "item",
        show: !0,
        ...s
      },
      legend: {
        show: !!d,
        itemGap: 40,
        textStyle: {
          fontSize: _(0.18),
          color: "rgba(0,0,0,0.85)",
          fontFamily: "FZRuiZhengHeiS-R-GB",
          padding: [0, 0, 0, 8]
        },
        itemWidth: _(0.18),
        itemHeight: _(0.18),
        ...n
      },
      grid: {
        top: "15%",
        bottom: "15%",
        ...g
      },
      series: this.defaultseries
    };
    return ((f = p[0]) == null ? void 0 : f.type) == 201 ? e = {
      ...e,
      angleAxis: this.defaultYAxis[0],
      polar: this.polar,
      radiusAxis: this.radiusAxis
    } : ((S = p[0]) == null ? void 0 : S.type) == 200 || ((b = p[0]) == null ? void 0 : b.type) == 203 || ((c = p[0]) == null ? void 0 : c.type) == 100 ? e = {
      ...e,
      xAxis: this.defaultXAxis,
      yAxis: this.defaultYAxis
    } : ((y = p[0]) == null ? void 0 : y.type) == 500 && (e = {
      tooltip: {
        trigger: "item",
        show: !0,
        ...s
      },
      visualMap: {
        min: 0,
        max: Math.max.apply(null, p[0].data),
        left: "left",
        top: "bottom",
        text: ["\u9AD8", "\u4F4E"],
        inRange: {
          color: ["#FFE1CC", "#FF6A00"]
        },
        show: !0
      },
      geo: {
        map: "china",
        roam: !1,
        zoom: 1.23,
        label: {
          normal: {
            show: !1,
            fontSize: "10",
            color: "rgba(0,0,0,0.7)"
          },
          emphasis: {
            show: !1,
            textStyle: {
              color: "#fff"
            }
          }
        },
        itemStyle: {
          normal: {
            borderColor: "rgba(0, 0, 0, 0.2)"
          },
          emphasis: {
            areaColor: "#F3B329",
            shadowOffsetX: 0,
            shadowOffsetY: 0,
            shadowBlur: 20,
            borderWidth: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)"
          }
        }
      },
      series: this.defaultseries
    }), i.dataZoom && (e = {
      ...e,
      dataZoom: i.dataZoom
    }), {
      ...e
    };
  }
  formatTitle({
    title: t,
    titleText: l
  }) {
    return !t && l && (t = {
      text: l,
      top: "3%",
      left: "5%",
      textStyle: {
        color: "#ffffff",
        fontSize: 14,
        fontWeight: 500
      }
    }), t;
  }
  formatColors(t = []) {
    let l = t && t.length > 0 ? t.map(
      (h) => h.length == 1 ? h[0] : {
        type: "linear",
        x: 0,
        y: 0,
        x2: 1,
        y2: 0,
        colorStops: [
          {
            offset: 0,
            color: h[0]
          },
          {
            offset: 1,
            color: h[1]
          }
        ],
        opacity: 0.85,
        global: !1,
        globalCoord: !1
      }
    ) : x;
    Object.assign(this.defaultColors, l);
  }
  formatAxis({
    xAxis: t = [],
    yAxis: l = [],
    series: h,
    directionFlag: a,
    barOptions: p = {},
    categoryOptions: m = {},
    yAxisOptions: d = {},
    xAxisOptions: s = {}
  }) {
    let n = {
      axisLabelFormatter: "{value}",
      axisLabelXFormatter: "{value}",
      sortAndDirectionFlag: !1,
      nameTextStyle: {
        color: "#000",
        fontSize: 17,
        fontWeight: 400,
        padding: a ? [0, 8, 10, -20] : [0, 8, 0, 40]
      },
      ...p
    }, g = {
      axisLabel: {},
      ...m
    }, u = {
      showUnit: !0,
      ...d
    };
    ({
      ...s
    });
    let i = {
      type: "value",
      axisLine: {
        show: !1,
        color: "#9b9b9d"
      },
      axisLabel: {
        show: !n.sortAndDirectionFlag,
        fontSize: 16,
        color: "#000",
        interval: 0,
        formatter: n.axisLabelFormatter
      },
      axisTick: {
        show: !1
      },
      nameTextStyle: n.nameTextStyle,
      splitLine: {
        show: !n.sortAndDirectionFlag
      }
    };
    console.log("ajsvnjav", g);
    let r = {
      type: "category",
      axisTick: {
        show: !n.sortAndDirectionFlag
      },
      axisLabel: {
        interval: 0,
        fontSize: 16,
        color: "#000",
        formatter: n.axisLabelXFormatter,
        ...g.axisLabel
      },
      axisLine: {
        show: !n.sortAndDirectionFlag,
        style: {
          stroke: "#9b9b9d"
        }
      }
    };
    if (t.length > 0 && t[0].type == "category") {
      let e = a ? t.map((f) => ({
        ...r,
        data: f.data || []
      })) : l.map((f) => ({
        ...i,
        name: u.showUnit ? f.unit : ""
      }));
      h[0].type == 201 ? e[0].axisLabel = {
        formatter: (f) => f < 0 ? -f : f
      } : h[0].type == 202 ? e[0].axisLabel = {
        formatter: (f) => f < 0 ? -f : f
      } : h[0].type == 100 && (e[0].boundaryGap = !0), Object.assign(this.defaultXAxis, e);
    }
    if (l.length > 0 && l[0].type == "value") {
      let e = a ? l.map((f) => ({
        ...i,
        name: u.showUnit ? f.unit : ""
      })) : t.map((f) => ({
        ...r,
        data: f.data || []
      }));
      Object.assign(this.defaultYAxis, e);
    }
  }
  formatSeries({
    series: t = [],
    xAxis: l = [],
    pieOptions: h = {},
    linerAareaColor: a,
    barOptions: p = {},
    linerOptions: m = {}
  }) {
    console.log("10010", t);
    let d = {
      pieShowLabel: !1,
      labelFormatter: (u) => `${u.data.value}`,
      pieCenter: ["50%", "50%"],
      label: null,
      pieRadius: [20, 80],
      itemStyle: {
        borderRadius: 4
      },
      ...h
    }, s = {
      barBorderRadius: [0, 0, 0, 0],
      barWidth: "auto",
      barGap: "30%",
      ...p
    }, n = {
      smooth: !0,
      showLinerAarea: !0,
      ...m
    }, g = t.map((u, i) => {
      var f, S;
      const {
        type: r
      } = u;
      let e = {
        ...u,
        type: O(r)
      };
      if (r == 100 || r == 200 || r == 201 || r == 202 || r == 203)
        r == 100 ? (e = {
          ...e,
          smooth: n.smooth,
          symbol: "none",
          lineStyle: {
            color: a ? a[i % a.length] && a[i % a.length][0] : w[i % w.length]
          },
          itemStyle: {
            color: a ? a[i % a.length] && a[i % a.length][0] : w[i % w.length]
          }
        }, a && ((f = a[i]) == null ? void 0 : f.length) && n.showLinerAarea && (e.areaStyle = {
          color: {
            type: "linear",
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
              offset: 0,
              color: a[i % a.length][0]
            }, {
              offset: 1,
              color: a[i % a.length][1]
            }],
            global: !1
          },
          opacity: 0.25
        })) : r == 200 || r == 202 || r == 203 ? (e.itemStyle = {
          normal: {
            barBorderRadius: s.barBorderRadius
          }
        }, e.barWidth = s.barWidth, e.barGap = s.barGap) : r == 201 && (e.coordinateSystem = "polar");
      else if (r == 300 || r == 301 || r == 302)
        e = {
          ...e,
          radius: h.pieRadius ? h.pieRadius : r == 300 ? "50%" : r == 301 ? ["30%", "60%"] : [20, 80],
          center: d.pieCenter,
          data: u.data.map((b, c) => ({
            value: b,
            name: l[0].data[c],
            label: d.label ? d.label : {
              show: d.pieShowLabel,
              fontSize: _(0.15),
              formatter: function(y) {
                return d.labelFormatter(y);
              }
            },
            labelLine: {
              show: d.pieShowLabel,
              length: 20,
              length2: 10,
              lineStyle: d.pieShowLabel ? {
                color: a ? a[c % a.length][0] : x[c][0],
                width: 1,
                type: "solid"
              } : {}
            }
          }))
        }, r == 302 && (e.roseType = "area", e.itemStyle = {
          ...d.itemStyle
        });
      else if (r == 500) {
        let b = [];
        u.data.map((c, y) => {
          b.push({
            value: c,
            name: l[0].data[y]
          });
        }), e = {
          name: "\u4FE1\u606F\u91CF",
          type: "map",
          geoIndex: 0,
          data: b
        };
      } else
        ((S = t[0]) == null ? void 0 : S.type) == 1601 && (delete initOption.color, delete initOption.legend);
      return e;
    });
    console.log("anjsvknajksvna", g), Object.assign(this.defaultseries, g);
  }
  getPieChartsOption(t) {
    return t;
  }
}
function R(o, t, l, h, a, p, m, d) {
  var s = typeof o == "function" ? o.options : o;
  t && (s.render = t, s.staticRenderFns = l, s._compiled = !0), h && (s.functional = !0), p && (s._scopeId = "data-v-" + p);
  var n;
  if (m ? (n = function(i) {
    i = i || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !i && typeof __VUE_SSR_CONTEXT__ < "u" && (i = __VUE_SSR_CONTEXT__), a && a.call(this, i), i && i._registeredComponents && i._registeredComponents.add(m);
  }, s._ssrRegister = n) : a && (n = d ? function() {
    a.call(
      this,
      (s.functional ? this.parent : this).$root.$options.shadowRoot
    );
  } : a), n)
    if (s.functional) {
      s._injectStyles = n;
      var g = s.render;
      s.render = function(r, e) {
        return n.call(e), g(r, e);
      };
    } else {
      var u = s.beforeCreate;
      s.beforeCreate = u ? [].concat(u, n) : [n];
    }
  return {
    exports: o,
    options: s
  };
}
const D = {
  name: "yk-bar-chart",
  props: {
    chartOption: {
      type: Object,
      default: () => ({})
    },
    width: {
      type: String,
      default: "100%"
    },
    height: {
      type: String,
      default: "100%"
    }
  },
  data() {
    return {
      ChartData: {},
      staging: {
        width: null,
        height: null
      }
    };
  },
  mounted() {
  },
  watch: {
    chartOption: {
      deep: !0,
      immediate: !0,
      handler(o) {
        this.ChartData = new F().getChartsOption(o), console.log("20220202", this.ChartData);
      }
    },
    width: {
      deep: !0,
      immediate: !0,
      handler(o) {
        o && (this.staging.width = o);
      }
    },
    height: {
      deep: !0,
      immediate: !0,
      handler(o) {
        o && (this.staging.height = o);
      }
    }
  }
};
var T = function() {
  var t = this, l = t._self._c;
  return t.ChartData.legend && t.staging.width && t.staging.height ? l("div", { staticClass: "bar-chart" }, [l("yk-base-chart", { style: { width: t.staging.width, height: t.staging.height }, attrs: { options: t.ChartData } })], 1) : t._e();
}, W = [], k = /* @__PURE__ */ R(
  D,
  T,
  W,
  !1,
  null,
  "17aeb950",
  null,
  null
);
const C = k.exports, z = {
  install(o) {
    o.component(C.name, C);
  }
};
export {
  z as default
};
