import { ref as a, defineComponent as R, watch as U, createElementBlock as A, openBlock as O, createVNode as v, unref as r, withCtx as g, createElementVNode as x, createCommentVNode as b, createTextVNode as V, toDisplayString as k } from "vue";
import { t as n } from "@das-fed/web/packages/i18n/index";
import { DasMessage as N } from "@das-fed/ui/packages/components/message/index";
import { DasButton as D } from "@das-fed/ui/packages/components/button/index";
import { DasTree as $ } from "@das-fed/ui/packages/components/tree/index";
import { DasDialog as M } from "@das-fed/ui/packages/components/dialog/index";
import { s as P, g as j, _ as q } from "./index-SfzdqhGf.js";
const G = (f) => (a(null), { saveKnow: async (o) => {
  var s;
  const h = (s = o.dom.textContent) == null ? void 0 : s.replace(/^\s*[\r\n]/gm, ""), c = {
    folderId: o.folderId,
    // 文件夹id
    title: o.sendVal,
    // 标题20-50 第一次输入内容/语音转为文字的内容为标题（超出部分切断），
    sourceType: 3,
    // 来源类型 0：手动创建 3-为系统自动创建，
    mainBody: h
    // 正文
  };
  f.value = !0;
  const [u, m] = await P(c).run();
  return f.value = !1, u ? !1 : (o.currentItem.saved = !0, N.success(n("保存成功")), !0);
} }), H = { class: "das-ai-folder-dialog" }, J = { class: "das-ai-folder-dialog-box" }, Q = { class: "foot-btn-box" }, W = {
  name: "index"
}, X = /* @__PURE__ */ R({
  ...W,
  props: {
    dialogShow: { type: Boolean, default: !1 },
    content: {}
  },
  emits: ["submit", "cancel", "close"],
  setup(f, { emit: T }) {
    const o = f, h = a(n("选择文件夹")), c = T, u = a(!1), m = a([]), s = a(""), d = a(""), _ = a(null), C = a(null), p = a(!1);
    a(!1), U(
      () => o.dialogShow,
      (e) => {
        e && (o.content, L()), u.value = e;
      }
    );
    const { saveKnow: I } = G(p), L = async () => {
      const e = {
        folderName: "",
        // 文件夹名称
        // authority:true,//权限标识 true：有 false：无
        excludeType: !0
        // 是否排除内置文件夹  默认不排除
      };
      p.value = !0;
      const [t, l] = await j(e).run();
      if (p.value = !1, t)
        return;
      let i = l;
      i && i.length && i.forEach((K) => {
        w(K);
      }), m.value = i;
    }, w = (e, t, l) => {
      e.disabled = !e.authority, e.path = t ? t + `/${e.id}` : e.id, e.pathName = l ? l + `/${e.folderName}` : e.folderName, e.childFolderList && e.childFolderList.length && e.childFolderList.forEach((i) => {
        w(i, e.path, e.pathName);
      });
    }, B = (e) => {
      d.value = e.id, _.value = e;
    }, y = () => {
      s.value = "", _.value = null, d.value = "", m.value = [];
    }, F = () => {
      y(), c("cancel");
    }, z = async () => {
      if (!d.value) {
        N.warning(n("请选择文件夹"));
        return;
      }
      const e = await I({
        ...o.content,
        folderId: d.value
      });
      e && (c("submit", e), y());
    }, E = () => {
      c("close"), y();
    };
    return (e, t) => (O(), A("div", H, [
      v(r(M), {
        onClose: E,
        size: "mini",
        modelValue: u.value,
        "onUpdate:modelValue": t[2] || (t[2] = (l) => u.value = l),
        title: h.value,
        "destroy-on-close": "",
        loading: p.value,
        height: "500px",
        width: "610px",
        "append-to-body": "",
        "body-style": { padding: 0 }
      }, {
        footer: g(() => [
          x("div", Q, [
            v(r(D), {
              size: "middle",
              onClick: F
            }, {
              default: g(() => [
                V(
                  k(r(n)("取消")),
                  1
                  /* TEXT */
                )
              ]),
              _: 1
              /* STABLE */
            }),
            v(r(D), {
              btnType: "primary",
              size: "middle",
              onClick: z
            }, {
              default: g(() => [
                V(
                  k(r(n)("确定")),
                  1
                  /* TEXT */
                )
              ]),
              _: 1
              /* STABLE */
            })
          ])
        ]),
        default: g(() => [
          x("div", J, [
            v(r($), {
              ref_key: "folderTreeRef",
              ref: C,
              data: m.value,
              isFilter: "",
              "node-key": "id",
              isEllipsis: "",
              props: { label: "folderName", children: "childFolderList" },
              inputOptions: { placeholder: r(n)("搜索文件夹名称") },
              modelValue: d.value,
              "onUpdate:modelValue": t[0] || (t[0] = (l) => d.value = l),
              "filter-value": s.value,
              "onUpdate:filterValue": t[1] || (t[1] = (l) => s.value = l),
              onNodeClick: B
            }, null, 8, ["data", "inputOptions", "modelValue", "filter-value"]),
            b(` <das-tree\r
          ref="folderTreeRef"\r
          node-key="id"\r
          :input-options="{ placeholder: t('搜索文件夹名称') }"\r
          :data="folderTreeData"\r
          v-model="folderId"\r
          is-ellipsis\r
          v-model:filter-value="treekeywords"\r
          :search="searchTreeNode"\r
          height="388"\r
          :load="getLazyTreeData"\r
          style="margin-top: 8px"\r
        >\r
        </das-tree> `),
            b(` <das-tree-v2\r
          v-if="dialogVisible"\r
          ref="folderTreeRef"\r
          node-key="id"\r
          :input-options="{ placeholder: t('搜索文件夹名称') }"\r
          :data="userTreeData"\r
          v-model="changeDepartmentList"\r
          is-ellipsis\r
          v-model:filter-value="treekeywords"\r
          :search="searchTreeNode"\r
          :load="getLazyTreeData"\r
        >\r
        </das-tree-v2> `)
          ])
        ]),
        _: 1
        /* STABLE */
      }, 8, ["modelValue", "title", "loading"])
    ]));
  }
}), oe = /* @__PURE__ */ q(X, [["__scopeId", "data-v-71075df3"]]);
export {
  oe as default
};
