"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../node_modules/element-plus/es/index.js");
;/* empty css                                                       */
;/* empty css                                                             */
;/* empty css                                                            */
;/* empty css                                                               */
const Vue = require("vue");
const common = require("../packages/utils/common.js");
const vue3JsonViewer = require("../../../node_modules/vue3-json-viewer/dist/vue3-json-viewer.js");
;/* empty css                                                                */
;/* empty css                     */
const _pluginVue_exportHelper = require("../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../node_modules/element-plus/es/components/drawer/index.js");
const index$1 = require("../../../node_modules/element-plus/es/components/scrollbar/index.js");
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__ */ Vue.mergeModels({
    title: {
      type: String,
      default: "数据结构"
    },
    boxed: {
      type: Boolean,
      default: false
    }
  }, {
    "modelValue": { required: true },
    "modelModifiers": {}
  }),
  emits: ["update:modelValue"],
  setup(__props) {
    const drawerVisible = Vue.useModel(__props, "modelValue");
    const editConfigData = Vue.computed(() => {
      return common.getEditConfigData();
    });
    const fieldCount = Vue.computed(() => {
      var _a;
      try {
        const data = editConfigData.value;
        return ((_a = data.fieldsData) == null ? void 0 : _a.length) || 0;
      } catch {
        return 0;
      }
    });
    const dataSize = Vue.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 = index$1.ElScrollbar;
      const _component_el_drawer = index.ElDrawer;
      return Vue.openBlock(), Vue.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: Vue.withCtx(() => [
          Vue.createElementVNode("div", _hoisted_1, [
            _cache[1] || (_cache[1] = Vue.createElementVNode("span", { class: "json-header-title" }, "数据结构", -1)),
            Vue.createElementVNode("div", _hoisted_2, [
              Vue.createElementVNode("span", null, "字段: " + Vue.toDisplayString(Vue.unref(fieldCount)), 1),
              Vue.createElementVNode("span", null, Vue.toDisplayString(Vue.unref(dataSize)), 1)
            ])
          ])
        ]),
        default: Vue.withCtx(() => [
          Vue.createElementVNode("div", _hoisted_3, [
            Vue.createVNode(_component_el_scrollbar, null, {
              default: Vue.withCtx(() => [
                Vue.createVNode(Vue.unref(vue3JsonViewer.JsonViewer), {
                  value: Vue.unref(editConfigData),
                  copyable: { copyText: "复制", copiedText: "已复制" },
                  "show-array-index": false,
                  boxed: __props.boxed
                }, null, 8, ["value", "boxed"])
              ]),
              _: 1
            })
          ])
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
};
const JsonDataDrawer = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-26fb683d"]]);
exports.default = JsonDataDrawer;
