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