import "../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                       */
/* empty css                                                             */
/* empty css                                                            */
/* empty css                                                               */
import { mergeModels, useModel, computed, createBlock, openBlock, withCtx, createElementVNode, createVNode, unref, toDisplayString } from "vue";
import { getEditConfigData } from "../packages/utils/common.mjs";
import { JsonViewer as Q } from "../../../node_modules/vue3-json-viewer/dist/vue3-json-viewer.mjs";
/* empty css                                                                */
/* empty css                     */
import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElDrawer } from "../../../node_modules/element-plus/es/components/drawer/index.mjs";
import { ElScrollbar } from "../../../node_modules/element-plus/es/components/scrollbar/index.mjs";
const _hoisted_1 = { class: "drawer-header" };
const _hoisted_2 = { class: "json-stats" };
const _hoisted_3 = { class: "json-viewer-container" };
const _sfc_main = {
  __name: "JsonDataDrawer",
  props: /* @__PURE__ */ mergeModels({
    title: {
      type: String,
      default: "数据结构"
    },
    boxed: {
      type: Boolean,
      default: false
    }
  }, {
    "modelValue": { required: true },
    "modelModifiers": {}
  }),
  emits: ["update:modelValue"],
  setup(__props) {
    const drawerVisible = useModel(__props, "modelValue");
    const editConfigData = computed(() => {
      return getEditConfigData();
    });
    const fieldCount = computed(() => {
      var _a;
      try {
        const data = editConfigData.value;
        return ((_a = data.fieldsData) == null ? void 0 : _a.length) || 0;
      } catch {
        return 0;
      }
    });
    const dataSize = computed(() => {
      const bytes = new Blob([JSON.stringify(editConfigData.value)]).size;
      if (bytes < 1024) return `${bytes} B`;
      if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
      return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
    });
    return (_ctx, _cache) => {
      const _component_el_scrollbar = ElScrollbar;
      const _component_el_drawer = ElDrawer;
      return openBlock(), createBlock(_component_el_drawer, {
        modelValue: drawerVisible.value,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => drawerVisible.value = $event),
        direction: "rtl",
        size: "35%",
        class: "json-data-dev-drawer"
      }, {
        header: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            _cache[1] || (_cache[1] = createElementVNode("span", { class: "json-header-title" }, "数据结构", -1)),
            createElementVNode("div", _hoisted_2, [
              createElementVNode("span", null, "字段: " + toDisplayString(unref(fieldCount)), 1),
              createElementVNode("span", null, toDisplayString(unref(dataSize)), 1)
            ])
          ])
        ]),
        default: withCtx(() => [
          createElementVNode("div", _hoisted_3, [
            createVNode(_component_el_scrollbar, null, {
              default: withCtx(() => [
                createVNode(unref(Q), {
                  value: unref(editConfigData),
                  copyable: { copyText: "复制", copiedText: "已复制" },
                  "show-array-index": false,
                  boxed: __props.boxed
                }, null, 8, ["value", "boxed"])
              ]),
              _: 1
            })
          ])
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
};
const JsonDataDrawer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-26fb683d"]]);
export {
  JsonDataDrawer as default
};
