import '@das-fed/upf-ui/packages/business-components/app-container/style.css';
import { withInstall as B } from "@das-fed/upf-utils/with-install/index";
import { defineComponent as R, ref as P, computed as U, watch as z, onMounted as M, openBlock as s, createBlock as f, unref as l, withCtx as g, createElementVNode as i, createElementBlock as r, Fragment as _, renderList as y, createCommentVNode as q, normalizeStyle as $, toDisplayString as S, withDirectives as D, createTextVNode as H } from "vue";
import { ElRow as G, ElCol as J } from "element-plus";
import "element-plus/es/components/row/style/css";
import "element-plus/es/components/col/style/css";
import { DasEmpty as K } from "@das-fed/upf-ui/packages/components/empty/index";
import { vDasTooltip as N } from "@das-fed/upf-ui/packages/components/text-tooltip/index";
import { DasScrollbar as O } from "@das-fed/upf-ui/packages/components/scrollbar/index";
import { pureImageSrc as E } from "@das-fed/upf-utils/pure-image-src";
const Q = { class: "application-content" }, X = {
  key: 0,
  class: "application-list"
}, Y = { class: "table" }, Z = { class: "table-cell column_1" }, b = { class: "app-name" }, A = { class: "table-cell column_2" }, tt = { class: "column_2_content" }, et = ["onClick"], ot = { class: "sub-app-item" }, nt = ["src"], ct = { class: "sub-app-item-content" }, st = { class: "name" }, at = { class: "describe" }, it = /* @__PURE__ */ R({
  __name: "index",
  props: {
    appCategorys: { default: () => [] }
  },
  emits: ["open-app"],
  setup(m, { emit: T }) {
    const d = m, F = T, I = (e) => F("open-app", e), v = P("18px"), w = (e, o) => {
      if (!o) return;
      if (o.offsetWidth > e) {
        const a = parseInt(window.getComputedStyle(o).fontSize) - 1;
        o.style.fontSize = a + "px", v.value = a + "px", w(e, o);
      }
    }, L = () => new Promise((e) => {
      const o = () => {
        const n = document.querySelectorAll(".application-content .column_1 .app-name");
        if (n != null && n.length && n.length === d.appCategorys.length) return e();
        setTimeout(() => o(), 50);
      };
      o();
    }), C = async () => {
      await L();
      const e = document.querySelectorAll(".application-content .column_1 .app-name")[0];
      if (!e) return;
      const o = parseInt(getComputedStyle(e).paddingLeft) || 0, n = parseInt(getComputedStyle(e).paddingRight) || 0, c = e.clientWidth - o - n;
      let a = 0, t = null;
      document.querySelectorAll(".application-content .column_1 .app-name > .text").forEach((p) => {
        const h = p.offsetWidth;
        h > a && (a = h, t = p);
      }), w(c, t);
    }, V = () => new Promise((e) => {
      const o = () => {
        const n = document.querySelectorAll(".application-content .column_1"), c = document.querySelectorAll(".application-content .column_2");
        if (n != null && n.length && n.length === d.appCategorys.length && (c != null && c.length) && c.length === d.appCategorys.length)
          return e();
        setTimeout(() => o(), 50);
      };
      o();
    }), x = async () => {
      await V(), document.querySelectorAll(".application-content .application-list .table .table-row").forEach((o) => {
        const n = o.querySelector(".column_1"), c = o.querySelector(".column_2>.column_2_content"), a = n.offsetHeight, t = c.offsetHeight;
        if (a > t) {
          const u = a - t, p = c.querySelectorAll(".app-row"), h = p.length;
          p.forEach((k) => {
            const j = k.offsetHeight;
            k.style.height = j + u / h + "px";
          });
        }
      });
    }, W = U(() => d.appCategorys.map((e) => e.name));
    return z(() => W.value, C, { deep: !0 }), z(() => d.appCategorys, x, { deep: !0 }), M(() => {
      C(), x();
    }), (e, o) => (s(), f(l(O), null, {
      default: g(() => [
        i("div", Q, [
          m.appCategorys && m.appCategorys.length ? (s(), r("div", X, [
            (s(!0), r(
              _,
              null,
              y(m.appCategorys, (n, c) => (s(), r("div", Y, [
                (s(), r("div", {
                  key: c,
                  class: "table-row"
                }, [
                  q(" 第一列 "),
                  i("div", Z, [
                    i("div", b, [
                      i(
                        "span",
                        {
                          class: "text",
                          style: $({ fontSize: v.value })
                        },
                        S(n.name),
                        5
                        /* TEXT, STYLE */
                      )
                    ])
                  ]),
                  q(" 第二列 "),
                  i("div", A, [
                    i("div", tt, [
                      (s(!0), r(
                        _,
                        null,
                        y(n.apps, (a) => (s(), f(
                          l(G),
                          {
                            class: "app-row",
                            gutter: 20
                          },
                          {
                            default: g(() => [
                              (s(!0), r(
                                _,
                                null,
                                y(a, (t, u) => (s(), f(
                                  l(J),
                                  {
                                    class: "app-col",
                                    key: u,
                                    span: 6
                                  },
                                  {
                                    default: g(() => [
                                      i("div", {
                                        class: "sub-app",
                                        onClick: (p) => I(t)
                                      }, [
                                        i("div", ot, [
                                          i("img", {
                                            class: "img",
                                            src: t != null && t.iconDomain ? t.iconDomain + l(E)(t == null ? void 0 : t.iconUrl) : l(E)(t == null ? void 0 : t.iconUrl),
                                            alt: ""
                                          }, null, 8, nt),
                                          i("div", ct, [
                                            D((s(), r("div", st, [
                                              H(
                                                S(t.name),
                                                1
                                                /* TEXT */
                                              )
                                            ])), [
                                              [l(N)]
                                            ]),
                                            D((s(), r("div", at, [
                                              H(
                                                S(t.description),
                                                1
                                                /* TEXT */
                                              )
                                            ])), [
                                              [l(N)]
                                            ])
                                          ])
                                        ])
                                      ], 8, et)
                                    ]),
                                    _: 2
                                    /* DYNAMIC */
                                  },
                                  1024
                                  /* DYNAMIC_SLOTS */
                                ))),
                                128
                                /* KEYED_FRAGMENT */
                              ))
                            ]),
                            _: 2
                            /* DYNAMIC */
                          },
                          1024
                          /* DYNAMIC_SLOTS */
                        ))),
                        256
                        /* UNKEYED_FRAGMENT */
                      ))
                    ])
                  ])
                ]))
              ]))),
              256
              /* UNKEYED_FRAGMENT */
            ))
          ])) : (s(), f(l(K), {
            key: 1,
            size: "large"
          }))
        ])
      ]),
      _: 1
      /* STABLE */
    }));
  }
}), _t = B(it);
export {
  _t as DasAppContainer
};
