import { defineComponent as E, ref as h, createVNode as e, Fragment as A, resolveComponent as t } from "vue";
import { useRoute as T } from "vue-router";
import { ElButton as _, ElTooltip as y, ElDrawer as C, ElMessage as p } from "element-plus";
import { request as g } from "@/utils";
import { a5 as v, _ as i, A as o, T as u, a6 as P, D as w, a7 as I } from "./main-DXvReGBc.js";
import { appSchema as b } from "@klweb/compose-app-engine";
import { e as R } from "./index-ClGUov3E.js";
const {
  IconSystemSet: V
} = R, M = /* @__PURE__ */ E({
  name: "KlEditorHeadActions",
  components: {
    ElButton: _,
    ElTooltip: y,
    ElDrawer: C,
    EditorSystemSetter: v
  },
  setup() {
    const c = T(), {
      app_id: d,
      type: s
    } = c.query, a = h(!1), m = () => {
      const l = `/renderer/#${document.querySelector(".kl-editor-main-iframe").getAttribute("src").split("#")[1]}&preview=true`;
      window.open(l, "_blank");
    }, S = () => {
      const n = s === "1" ? API_URL.updateAppSchema : API_URL.updateAppTemplateSchema, r = new FormData();
      r.append("id", String(d)), r.append(s === "1" ? "appContent" : "appTemplateContent", JSON.stringify(b.value)), g.post(n, r, {
        loaderOpts: {
          type: "overlay",
          option: {
            text: u.SAVING
          }
        }
      }).then((l) => {
        l.code === 0 ? (P(w[8], String(Date.now()), "local"), p.success(u.SAVE_SUCCESSFULLY)) : p.error(l.msg);
      });
    }, f = () => {
      I();
    };
    return () => e(A, null, [e("span", {
      class: i["editor-header-action"]
    }, [e(t("el-button"), {
      plain: !0,
      onClick: f
    }, {
      default: () => [o.RESET_PAGE]
    }), e(t("el-button"), {
      plain: !0,
      onClick: m
    }, {
      default: () => [o.PREVIEW]
    }), e(t("el-button"), {
      type: "primary",
      onClick: S
    }, {
      default: () => [o.SAVE]
    }), e(t("el-tooltip"), {
      effect: "dark",
      "hide-after": 0,
      placement: "top",
      content: o.SYSTEM_SETTING
    }, {
      default: () => [e(t("el-button"), {
        plain: !0,
        class: i["button--icon"],
        icon: V,
        onClick: () => a.value = !a.value
      }, null)]
    })]), e(t("el-drawer"), {
      modelValue: a.value,
      "onUpdate:modelValue": (n) => a.value = n,
      size: 300,
      title: o.SYSTEM_SETTING,
      "append-to-body": !0
    }, {
      default: () => [e(t("editor-system-setter"), null, null)]
    })]);
  }
});
export {
  M as default
};
