import { a6 as u, nR as Ie, F as t, X as l, jd as ke, eQ as $, nS as Pe, av as Se, nT as Ce, nU as Re, nV as Ae, gh as L, gJ as F, ge as k, nW as G, nX as Te, hX as S, hY as v, iB as U, cD as oe, nY as Le, nZ as Oe, Y as o, n_ as Me, n$ as Ee, o0 as Ue, o1 as Be, cC as w, o2 as ne, o3 as Ne, iH as W, iI as R, o4 as H, G as P, o5 as J, o6 as $e, o7 as re, ez as j, o8 as ae, o9 as De, oa as Ve, di as V, ob as ze, oc as q, od as se, nm as le, j6 as de, oe as We, of as Fe, iJ as ce, og as Ge, oh as He, ah as pe, oi as je, al as _e, oj as O, jC as he, gg as me, gf as A, iG as T, iE as Xe, iD as Ye, iC as Je, is as ue, jB as qe, fo as Ke, ok as Ze, ol as Qe, iN as et, om as tt, on as it, oo as ot, op as nt, oq as rt, or as at, os as st, ot as lt, ou as dt, me as ct, mX as pt, i9 as ht, ov as mt, fA as ut, ow as ft, ox as K, iU as gt, oy as bt, oz as xt, oA as Z, oB as Q, cs as yt, oC as wt } from "./603b75d9.js";
import vt, { useState as y, useEffect as M, useMemo as fe, useContext as ge, useRef as It } from "react";
import { a as kt } from "./d13144d5.js";
const Pt = (e) => e.ui.folder.folders, St = l.header`
  display: flex;
  width: 100%;
  height: ${ke};
  background-color: #2c2c2c;
  /* filter: drop-shadow(0px 1px 0px #ebebeb); */
  padding: ${(e) => e.$isEditViewPreview ? "8px 24px 8px 8px" : "8px 24px"};
  justify-content: space-between;

  > div:nth-of-type(1) svg {
    max-width: ${(e) => e.$isEditViewPreview && "24px"};
  }
`, Ct = l.div`
  display: flex;
  align-items: center;
`, Rt = l.div`
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
`, At = l.div`
  display: flex;
  align-items: center;
`;
function Ni(e) {
  const {
    headerStart: i,
    headerMiddle: a,
    headerEnd: r
  } = e, n = /\/edit|\/view|\/preview/, s = !!window.location.pathname.match(n);
  return /* @__PURE__ */ u(St, {
    className: Ie,
    $isEditViewPreview: s,
    style: e.style,
    children: [/* @__PURE__ */ t(Ct, {
      children: i
    }), /* @__PURE__ */ t(Rt, {
      children: a
    }), /* @__PURE__ */ t(At, {
      children: r
    })]
  });
}
const Tt = l.div`
  width: ${(e) => e.$side || 34}px;
  height: ${(e) => e.$side || 34}px;
  display: flex;
  align-items: center;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  justify-content: center;
  cursor: default;
  background-color: #0093E9;
  background-image: linear-gradient(160deg, #0093E9 0%, #80D0C7 100%);

  & span {
    color: #ffffff;
    letter-spacing: normal;
    white-space: nowrap;
    font-size: ${(e) => e.$fontSize ?? 13}px;
    display: inline-block;
    ${(e) => e.$fontSize && e.$fontSize < 12 ? "-webkit-transform:scale(" + e.$fontSize / 12 + ");" : ""};
  }

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
  }
`;
function E(e) {
  const i = $(e.userName, !0), [a, r] = y(!1), n = Pe(e.source), s = (n || e.svg) && !a;
  return /* @__PURE__ */ t(Tt, {
    $fontSize: e.fontSize,
    style: e.style,
    className: e.className,
    $side: e.side,
    title: e.userName,
    children: s ? e.source ? /* @__PURE__ */ t("img", {
      onError: () => r(!0),
      onLoad: () => r(!1),
      src: n
    }) : e.svg : /* @__PURE__ */ t("span", {
      children: i[0]
    })
  });
}
const _ = Se`
  input {
    border-radius: 4px;
    font-size: 13px;
    line-height: 13px;
    height: 32px;
  }

  input::placeholder {
    font-size: 13px;
    line-height: 13px;
  }
`, Lt = l(Ce)`
  margin-bottom: 16px;
  ${_};
`, z = l(Re)`
  margin-bottom: 16px;
  ${_};
`;
l(Ae)`
  ${_};
  margin-bottom: 24px;

  span {
    font-size: 16px;
    line-height: 16px;
  }

  div {
    border-radius: 4px;
  }

  button {
    width: 110px;
    padding: 0 12px;
    margin: 0;
    font-size: 13px;
    line-height: 13px;
  }
`;
const be = l(L)`
  border-radius: 4px;
  height: 28px;
  font-size: 13px;
  line-height: 13px;
  width: 76px;
  margin-left: auto;
  margin-top: 8px;
`, xe = l.div`
  display: flex;
  flex-direction: column;
  margin-top: 6px;
`, Ot = l.div`
  display: flex;
  align-items: center;
  width: 81px;
  height: 13px;

  img {
    width: 16px;
    height: 16px;
    margin-right: 6px;
  }
`, Mt = l(F)`
  transform: scaleX(-1) scaleY(-1) rotate(-90deg);
`, Et = l.div`
  display: flex;
  align-items: center;
  margin-bottom: 19px;

  &:last-child {
    margin-bottom: 4px;
  }

  button {
    margin-left: auto;
    cursor: pointer;
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    height: 13px;

    font-size: 13px;
    color: #4965f2;
    text-align: right;
    line-height: 13px;
    background: #ffffff;
  }

  button:hover svg g path {
    fill: #4965f2;
  }

  button:disabled,
  button:disabled button:hover {
    color: #b8b9bf;
    cursor: not-allowed;

    svg g path {
      fill: #b8b9bf;
    }
  }
`, Ut = l(E)`
  span {
    font-size: 16px;
    font-weight: 500;
  }
`, Bt = l.div`
  position: relative;
`, Nt = l.div`
  font-size: 13px;
  position: absolute;
  width: 72px;
  height: 72px;
  line-height: 72px;
  left: 0;
  top: 0;
  border-radius: 50%;
  text-align: center;
  color: #ffffff;
  opacity: 0;
  cursor: pointer;

  &:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
`, $t = l.div`
  display: flex;
  align-items: center;
  padding: 0 0 27px 0;

  > * {
    margin-left: 16px;
  }

  > *:first-child {
    margin-left: 0;
  }
`;
function ee(e) {
  return /* @__PURE__ */ u(Et, {
    children: [/* @__PURE__ */ u(Ot, {
      children: [e.icon, /* @__PURE__ */ t(k, {
        children: e.titleLabel
      })]
    }), e.value ? /* @__PURE__ */ t(k, {
      style: {
        marginLeft: "7px",
        whiteSpace: "break-spaces"
      },
      children: e.value
    }) : /* @__PURE__ */ t(G, {
      style: {
        marginLeft: "7px",
        maxWidth: "165px"
      },
      children: e.infoLabel
    }), !e.actionButtonConfig.hidden && /* @__PURE__ */ u("button", {
      onClick: () => e.actionButtonConfig.onClick(),
      disabled: e.actionButtonConfig.disabled,
      children: [/* @__PURE__ */ t("span", {
        children: e.actionButtonConfig.label
      }), /* @__PURE__ */ t(Mt, {})]
    })]
  });
}
function Dt(e, i) {
  var r;
  const a = (r = e.connections) == null ? void 0 : r.find((n) => n.source === i);
  return a != null && a.name ? Te(a.name) : "";
}
function Vt() {
  const e = S(), i = v(U), a = (r) => {
    r.file.status === "done" && Ue(r.file.originFileObj, (n) => {
      e(Be({
        avatarUrl: n
      }));
    }), r.file.status === "error" && w.error(o("profile.uploadError"));
  };
  return i ? /* @__PURE__ */ u($t, {
    children: [/* @__PURE__ */ t("div", {
      style: {
        height: "72px"
      },
      children: /* @__PURE__ */ t(oe, {
        accept: "image/*",
        showUploadList: !1,
        action: Le,
        onChange: a,
        beforeUpload: Oe,
        withCredentials: !0,
        children: /* @__PURE__ */ u(Bt, {
          children: [/* @__PURE__ */ t(Ut, {
            side: 72,
            source: i.avatarUrl,
            userName: i.username
          }), /* @__PURE__ */ t(Nt, {
            children: o("profile.editProfilePicture")
          })]
        })
      })
    }), /* @__PURE__ */ t(Me, {
      valueCheck: {
        rule: (r) => r.trim() !== "",
        message: o("profile.nameCheck")
      },
      inputStyle: {
        width: "248px",
        height: " 32px"
      },
      label: o("profile.name"),
      mustFill: !0,
      placeholder: o("profile.namePlaceholder"),
      defaultValue: i.username,
      onFinish: (r) => {
        e(Ee({
          name: r
        }));
      }
    })]
  }) : null;
}
function zt() {
  const [e, i] = y(""), a = S(), r = v(ne), n = r == null ? void 0 : r.form.id, s = (c) => {
    W.bindEmail({
      email: c,
      authId: n
    }).then((d) => {
      R(d) && (w.success(o("profile.bindEmailSuccess")), a(H()));
    }).catch((d) => {
      w.error(d.message);
    });
  };
  return /* @__PURE__ */ u(xe, {
    children: [/* @__PURE__ */ t(Lt, {
      mustFill: !0,
      label: o("profile.email"),
      onChange: (c, d) => i(d ? c : ""),
      placeholder: o("profile.emailPlaceholder"),
      checkRule: {
        check: (c) => Ne(c),
        errorMsg: o("profile.emailCheck")
      }
    }), /* @__PURE__ */ t(be, {
      buttonType: "primary",
      disabled: !e,
      onClick: () => s(e),
      children: o("profile.submit")
    })]
  });
}
function Wt(e) {
  const [i, a] = y(""), [r, n] = y(""), s = S(), c = () => {
    const d = e.hasPass ? W.updatePassword({
      oldPassword: i,
      newPassword: r
    }) : W.setPassword({
      password: r
    }), p = e.hasPass ? o("profile.passwordModifiedSuccess") : o("profile.passwordSetSuccess");
    d.then((m) => {
      R(m) && (w.success(p), s(H()));
    }).catch((m) => {
      w.error(m.message);
    });
  };
  return /* @__PURE__ */ u(xe, {
    children: [e.hasPass ? /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t(z, {
        passInputConf: {
          label: o("profile.oldPassword"),
          placeholder: o("profile.inputCurrentPassword")
        },
        onChange: (d, p) => {
          a(p ? d : "");
        }
      }), /* @__PURE__ */ t(z, {
        doubleCheck: !0,
        valueCheck: J,
        onChange: (d, p) => n(p ? d : ""),
        passInputConf: {
          label: o("profile.newPassword"),
          placeholder: o("profile.inputNewPassword")
        },
        confirmPassConf: {
          label: o("profile.confirmNewPassword"),
          placeholder: o("profile.inputNewPasswordAgain")
        }
      })]
    }) : /* @__PURE__ */ t(z, {
      doubleCheck: !0,
      valueCheck: J,
      onChange: (d, p) => n(p ? d : "")
    }), /* @__PURE__ */ t(be, {
      buttonType: "primary",
      disabled: e.hasPass && !i || !r,
      onClick: c,
      children: o("profile.submit")
    })]
  });
}
function Ft(e) {
  const i = v(U), {
    setModalContent: a,
    setTitle: r,
    setShowBackLink: n
  } = e, s = i.hasPassword, c = Dt(i, $e.email);
  return /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ t(Vt, {}), /* @__PURE__ */ t(ee, {
      titleLabel: o("profile.bindEmail"),
      infoLabel: o("profile.loginAfterBind", {
        name: o("profile.email")
      }),
      value: c,
      actionButtonConfig: {
        label: c ? o("profile.binding") : o("profile.toBind"),
        disabled: !!c,
        onClick: () => {
          a(/* @__PURE__ */ t(zt, {})), r(o("profile.bindName", {
            name: o("profile.email")
          })), n(!0);
        }
      }
    }, "email"), /* @__PURE__ */ t(ee, {
      titleLabel: o("profile.password"),
      infoLabel: s ? o("profile.alreadySetPassword") : o("profile.setPassPlaceholder"),
      actionButtonConfig: {
        label: s ? o("profile.modifyPassword") : o("profile.setPassword"),
        onClick: () => {
          a(/* @__PURE__ */ t(Wt, {
            hasPass: s
          })), r(s ? o("profile.modifyPassword") : o("profile.setPassword")), n(!0);
        },
        hidden: !1
      }
    }, "password")]
  });
}
function Gt() {
  const e = v(re), i = S(), [a, r] = y(o("profile.personalInfo")), [n, s] = y(!1), [c, d] = y(), p = /* @__PURE__ */ t(Ft, {
    setModalContent: d,
    setShowBackLink: s,
    setTitle: r
  }), m = (h) => {
    h.data.type === De.THIRD_PARTY_BIND && (h.data.success ? (i(H()), w.info(o("profile.bindingSuccess", {
      sourceName: h.data.sourceName
    }))) : (w.error(h.data.message), d(p)));
  };
  return M(() => (d(p), window.addEventListener("message", m), () => window.removeEventListener("message", m)), []), /* @__PURE__ */ t(j, {
    title: a,
    open: e,
    onCancel: () => i(ae(!1)),
    showOkButton: !1,
    showCancelButton: !1,
    showBackLink: n,
    onBack: () => {
      s(!1), d(p), r(o("profile.personalInfo"));
    },
    children: c
  });
}
const {
  Item: Ht
} = _e, jt = l.div`
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 12px 0;

  p {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    word-break: keep-all;
  }

  svg {
    visibility: hidden;
  }

  :hover svg {
    visibility: visible;

    g g {
      fill: #3377ff;
    }
  }
`, _t = l(pe)`
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: end;
`, Xt = l(F)`
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
`;
l((e) => /* @__PURE__ */ t(Ht, {
  ...e
}))`
  .ant-dropdown-menu-item-icon {
    position: absolute;
    right: 0;
    width: 16px;
    height: 16px;
    margin-right: 8px;
  }

  .ant-dropdown-menu-title-content {
    color: #4965f2;
    padding-right: 22px;
  }
`;
l(je)`
  min-width: 192px;

  .ant-dropdown-menu-item {
    height: 29px;
  }

  .ant-dropdown-menu-item-divider,
  .ant-dropdown-menu-submenu-title-divider {
    background-color: #e1e3eb;
  }
`;
const Yt = l.div`
  width: 160px;
  text-align: center;
  position: relative;
  margin-top: -3px;
  display: flex;
  justify-content: center;

  p {
    font-weight: 500;
    font-size: 14px;
    line-height: 16px;
    color: #222222;
    padding-left: 16px;
  }
`, Jt = l.div`
  font-size: 12px;
  color: #4965f2;
  line-height: 14px;
  border: 1px solid #d6e4ff;
  border-radius: 8px;
  padding: 1px 5px;
`;
function $i(e) {
  const {
    avatarUrl: i,
    username: a,
    orgs: r,
    currentOrgId: n
  } = e.user, s = e.user.orgRoleMap.get(n), c = fe(() => e.user.orgs.find((g) => g.id === n), [e.user, n]), d = v(re), p = v(ne), m = S(), h = (g) => {
    if (g.key === "profile") {
      if (V(window.innerWidth))
        return;
      m(ae(!0));
    } else
      g.key === "logout" ? m(We({})) : g.keyPath.includes("switchOrg") && (g.key === "newOrganization" ? (m(Fe(r)), ce.push(Ge)) : n !== g.key && m(He(g.key)));
  };
  let f = [{
    key: "profile",
    label: /* @__PURE__ */ u(jt, {
      children: [/* @__PURE__ */ t(E, {
        source: i,
        userName: a,
        side: 48
      }), /* @__PURE__ */ u(Yt, {
        children: [/* @__PURE__ */ t(Ve, {
          title: a,
          children: a
        }), !V(window.innerWidth) && /* @__PURE__ */ t(ze, {})]
      }), c && /* @__PURE__ */ t(G, {
        style: {
          width: "130px",
          textAlign: "center",
          lineHeight: "15px"
        },
        children: c.name
      }), s && q[s] && /* @__PURE__ */ t(Jt, {
        children: q[s].name
      })]
    })
  }, {
    key: "logout",
    label: o("profile.logout")
  }];
  if (r && r.length > 0 && kt(e.user, p)) {
    const g = r.map((b) => ({
      key: b.id,
      icon: n === b.id && /* @__PURE__ */ t(se, {}),
      label: b.name
    }));
    let C = [];
    V(window.innerWidth) || (C = [{
      type: "divider"
    }, {
      key: "newOrganization",
      icon: /* @__PURE__ */ t(le, {}),
      label: o("profile.createOrg")
    }]);
    const x = {
      key: "switchOrg",
      label: o("profile.switchOrg"),
      popupOffset: [4, -12],
      children: [{
        key: "joinedOrg",
        label: /* @__PURE__ */ t(k, {
          style: {
            margin: "8px",
            color: "#B8B9BF"
          },
          children: o("profile.joinedOrg")
        }),
        disabled: !0
      }, ...g, ...C]
    };
    f.splice(1, 0, x);
  }
  const I = /* @__PURE__ */ t(de, {
    style: {
      width: "192px"
    },
    onClick: h,
    expandIcon: /* @__PURE__ */ t(Xt, {}),
    items: f
  });
  return /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ t(_t, {
      dropdownRender: () => I,
      trigger: ["click"],
      children: /* @__PURE__ */ t("div", {
        children: /* @__PURE__ */ t(E, {
          style: {
            cursor: "pointer",
            userSelect: "none"
          },
          source: i,
          userName: a,
          side: e.profileSide,
          fontSize: e.fontSize
        })
      })
    }), d && /* @__PURE__ */ t(Gt, {})]
  });
}
l(oe)`
  .ant-upload-wrapper .ant-upload-select {
    display: block;
  }
`;
const qt = (e) => {
  const i = "t--export-app-link", a = document.getElementById(i);
  a && a.remove();
  const r = document.createElement("a");
  O.getApplicationDetail({
    applicationId: e,
    type: "editing"
  }).then((n) => {
    if (R(n)) {
      const s = n.data.data, c = s.applicationInfoView.name, d = {
        applicationInfo: {
          name: c,
          createAt: s.applicationInfoView.createAt,
          createBy: s.applicationInfoView.createBy,
          applicationId: s.applicationInfoView.applicationId,
          applicationType: s.applicationInfoView.applicationType
        },
        applicationDSL: s.applicationDSL
      }, p = new Blob([JSON.stringify(d)], {
        type: "application/json"
      }), m = URL.createObjectURL(p);
      r.href = m, r.download = c + ".json", r.id = i, document.body.appendChild(r), r.click(), r.remove(), URL.revokeObjectURL(m);
      return;
    }
  }).catch((n) => w.error(o("home.exportError", {
    message: n.message
  })));
};
function Kt(e) {
  var g, C;
  const [i, a] = y(""), r = v(U), n = v(Pt), [s, c] = y(((g = n.find((x) => {
    var b, Y;
    return ((b = x.subApplications) == null ? void 0 : b.length) && ((Y = x.subApplications) == null ? void 0 : Y.findIndex((D) => (D == null ? void 0 : D.applicationId) === e.id)) > -1;
  })) == null ? void 0 : g.folderId) || ""), {
    visible: d,
    close: p,
    name: m,
    type: h,
    id: f
  } = e, I = m.length > 25 ? `${m.substring(0, 25)}...` : m;
  return /* @__PURE__ */ t(j, {
    title: o("home.copyModalTitle", {
      name: I
    }),
    open: d,
    okButtonProps: {
      disabled: !i
    },
    destroyOnClose: !0,
    onCancel: p,
    onOk: async () => {
      let x = null;
      await O.getApplicationDetail({
        applicationId: f,
        type: "editing"
      }).then(async (b) => {
        R(b) && b.data.data && (x = b.data.data.applicationDSL);
      }), x && await O.createApplicationWithDSL({
        name: i,
        orgId: r.currentOrgId,
        applicationType: h,
        editingApplicationDSL: x || {},
        folderId: s
      }).then(async (b) => {
        if (R(b) && b.data.data)
          return window.open(he(b.data.data.applicationInfoView.applicationId, "edit")), window.location.reload(), b.data.data;
      }).catch((b) => {
        w.error(o("copyError"));
      });
    },
    children: /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t("span", {
        style: {
          display: "block",
          marginBottom: "4px"
        },
        children: o("home.copyNameLabel", {
          type: N[h]
        })
      }), /* @__PURE__ */ t(me, {
        placeholder: o("home.copyNamePlaceholder", {
          type: (C = N[h]) == null ? void 0 : C.toLowerCase()
        }),
        onChange: (x) => {
          a(x.target.value);
        }
      }), !!n.length && /* @__PURE__ */ u(P, {
        children: [/* @__PURE__ */ t("span", {
          style: {
            display: "block",
            margin: "15px 0 4px"
          },
          children: o("home.copyModalfolderLabel")
        }), /* @__PURE__ */ t(A, {
          defaultValue: s,
          style: {
            width: "100%"
          },
          onChange: (x) => c(x),
          options: [{
            label: o("home.rootFolder"),
            value: ""
          }, ...n.map((x) => ({
            label: x.name,
            value: x.folderId
          }))],
          filterOption: (x, b) => (b == null ? void 0 : b.label).includes(x)
        })]
      })]
    })
  });
}
const Zt = l(F)`
  transform: rotate(180deg);
  margin-left: 4px;
  min-width: 18px;

  path {
    fill: #ffffff;
  }
`, Qt = l(pe)`
  &.ant-dropdown-open {
    background-color: #8b8fa34c;
  }
`, ei = l(de)`
  .ant-dropdown-menu-item:hover {
    background: #edf4fa;
  }
`, ti = l(k)`
  color: #f73131;
`, ii = l.div`
  display: inline-flex;
  align-items: center;
  margin-right: 4px;

  &.module svg {
    visibility: visible;
  }
`, N = {
  [T.Application]: o("home.app"),
  [T.Module]: o("home.module"),
  [T.NavLayout]: o("home.navLayout"),
  [T.MobileTabLayout]: o("home.mobileTabLayout")
};
function Di(e) {
  const i = v(U), a = v(Xe), r = Ye(), n = v(Je), [s, c] = y(!1), d = S(), {
    appType: p
  } = ge(ue), m = p === T.Module, h = qe(i, n), f = e.isViewMarketplaceMode, I = fe(() => {
    var C;
    const g = [{
      key: "export",
      label: /* @__PURE__ */ t(k, {
        children: o("header.export")
      }),
      visible: !0
    }, {
      key: "duplicate",
      label: /* @__PURE__ */ t(k, {
        children: o("header.duplicate", {
          type: (C = N[n == null ? void 0 : n.applicationType]) == null ? void 0 : C.toLowerCase()
        })
      }),
      visible: !0
    }];
    return f || g.unshift({
      key: "edit",
      label: /* @__PURE__ */ t(k, {
        children: o("header.editName")
      }),
      visible: h
    }, {
      key: "delete",
      label: /* @__PURE__ */ t(ti, {
        children: o("home.moveToTrash")
      }),
      visible: h
    }), g;
  }, [h, f]);
  return /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ t(Qt, {
      placement: "bottomLeft",
      trigger: ["click"],
      disabled: a,
      dropdownRender: () => /* @__PURE__ */ t(ei, {
        style: {
          minWidth: "136px",
          maxWidth: "288px",
          borderRadius: "4px"
        },
        onClick: (g) => {
          g.key === "edit" ? e.setEdit() : g.key === "export" ? qt(r) : g.key === "duplicate" ? c(!0) : g.key === "delete" && j.confirm({
            title: o("home.moveToTrash"),
            content: Ke("home.moveToTrashSubTitle", {
              type: N[n == null ? void 0 : n.applicationType],
              name: /* @__PURE__ */ t("b", {
                children: (n == null ? void 0 : n.name) || ""
              })
            }),
            onConfirm: () => d(Ze({
              applicationId: r,
              folderId: ""
            }, () => {
              w.success(o("success")), ce.push(it);
            }, () => w.error(o("home.deleteErrorMsg")))),
            confirmBtnType: "delete",
            okText: o("home.moveToTrash")
          });
        },
        items: I.filter((g) => g.visible)
      }),
      children: /* @__PURE__ */ u(Qe, {
        style: {
          width: "fit-content",
          maxWidth: "288px",
          padding: "0 8px"
        },
        disabled: a,
        children: [m && /* @__PURE__ */ t(ii, {
          className: "module",
          children: /* @__PURE__ */ t(et, {})
        }), /* @__PURE__ */ t(tt, {
          className: "taco-edit-text-body",
          children: (n == null ? void 0 : n.name) ?? ""
        }), /* @__PURE__ */ t(Zt, {
          style: {
            visibility: a ? "hidden" : "visible"
          }
        })]
      })
    }), /* @__PURE__ */ t(Kt, {
      name: (n == null ? void 0 : n.name) || "",
      id: r,
      type: n == null ? void 0 : n.applicationType,
      visible: s,
      close: () => c(!1)
    })]
  });
}
const ye = l(A)`
  margin-left: auto;

  .ant-select-arrow {
    right: 0;
  }

  .ant-select-selector {
    border: none !important;
  }

  .ant-select:hover {
    .ant-select-selector .ant-select-selection-item {
      color: #4965f2;
    }

    .ant-select-arrow svg g path {
      fill: #4965f2;
    }
  }

  .ant-select .ant-select-selector .ant-select-selection-item {
    padding-right: 12px;

    font-size: 13px;
    color: #333333;
    text-align: right;
    line-height: 15px;
  }
`, oi = l.div`
  display: flex;
  align-items: center;
  font-size: 13px;
  line-height: 15px;
  height: fit-content;
`, X = l(ot)`
  width: ${(e) => e.$side ?? 16}px;
  height: ${(e) => e.$side ?? 16}px;

  g g {
    fill: ${(e) => e.$color};
  }
`, ni = l(nt)`
  width: 16px;
  height: 16px;

  g path {
    fill: ${(e) => e.$color};
  }
`, we = l.div`
  font-weight: 500;
  font-size: 14px;
  color: #333333;
  line-height: 16px;
  margin-left: 12px;
  max-width: 276px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
`;
function ve(e) {
  return /* @__PURE__ */ t(oi, {
    children: /* @__PURE__ */ t("div", {
      children: e.role
    })
  });
}
const ri = l(rt)`
  height: 353px;
  width: 100%;
`, ai = l.li`
  display: flex;
  align-items: center;
  padding: 8px 8px;
  width: 424px;

  &:hover {
    background: #f2f7fc;
    border-radius: 4px;
  }
`, si = l.ul`
  padding: 0;
  height: ${(e) => e.$height}px;
  overflow-y: overlay !important;
  overflow-x: hidden;
  margin: 0 -16px 0 -8px;

  &::-webkit-scrollbar {
    width: 16px;
  }

  &::-webkit-scrollbar-thumb {
    border: 5px solid transparent;
    background-clip: content-box;
    border-radius: 9999px;
    background-color: rgba(139, 143, 163, 0.12);
  }

  &::-webkit-scrollbar-thumb:hover {
    background-color: rgba(139, 143, 163, 0.25);
  }
`, li = l.div`
  background: #ffffff;
  border: 1px solid #d6e4ff;
  border-radius: 8px;

  font-size: 12px;
  color: #4965f2;
  line-height: 12px;
  width: fit-content;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 0 4px;
`;
function di(e) {
  const {
    permissionItem: i,
    isCreator: a
  } = e;
  let r;
  return i.type === "GROUP" ? r = X : i.type === "ORG_ADMIN" && (r = ni), /* @__PURE__ */ u(ai, {
    children: [/* @__PURE__ */ t(E, {
      side: 32,
      userName: i.name,
      source: i.avatar && at(i.avatar),
      svg: r && /* @__PURE__ */ t(r, {
        $color: $(i.name)[1]
      })
    }), /* @__PURE__ */ u(we, {
      title: i.name,
      children: [i.type === "GROUP" && o("home.groupWithSquareBrackets"), i.name]
    }), a && /* @__PURE__ */ t(li, {
      children: o("home.creator")
    }), a || i.type === "ORG_ADMIN" ? /* @__PURE__ */ t(G, {
      style: {
        color: "color: #B8B9BF",
        margin: "0 24px 0 auto"
      },
      children: e.ownerLabel
    }) : /* @__PURE__ */ u(ye, {
      style: {
        marginRight: "4px"
      },
      dropdownStyle: {
        width: "100px"
      },
      defaultValue: i.role,
      variant: "borderless",
      optionLabelProp: "label",
      onSelect: (n, s) => {
        s.key === "delete" ? e.deletePermission(s.permissionid) : e.updatePermission(s.permissionid, s.key);
      },
      children: [e.supportRoles.map((n) => /* @__PURE__ */ t(A.Option, {
        label: n.label,
        value: n.value,
        permissionid: i.permissionId,
        children: /* @__PURE__ */ t(ve, {
          role: n.label
        })
      }, n.value)), /* @__PURE__ */ t(A.Option, {
        label: o("remove"),
        value: "delete",
        permissionid: i.permissionId,
        children: /* @__PURE__ */ t(st, {
          $fontSize: 13,
          children: o("remove")
        })
      }, "delete")]
    })]
  }, i.permissionId);
}
const te = (e) => /* @__PURE__ */ u(P, {
  children: [/* @__PURE__ */ t(k, {
    style: {
      marginBottom: "4px"
    },
    children: o("home.memberPermissionList")
  }), /* @__PURE__ */ t(si, {
    $height: 201,
    children: e.permissionItems.map((i, a) => /* @__PURE__ */ t(di, {
      isCreator: i.isCreator,
      permissionItem: i.permissionItem,
      ...e
    }, a))
  })]
}), ci = (e) => e.ui.org.orgUsers, pi = (e) => e.ui.org.orgGroups, hi = l.div`
  display: flex;
  flex-direction: column;
`, mi = l.div`
  margin: 8px -16px 0 -8px;

  > div {
    position: inherit !important;
  }

  .custom-ant-select-dropdown {
    height: 240px;
    position: inherit !important;
    box-shadow: none;
    border: none;
    padding: 0;

    .ant-select-item {
      width: 424px;
      transition: unset;
      padding: 0;

      .ant-select-item-option-state {
        width: 16px;
        height: 16px;
        margin-right: 8px;
      }
    }

    .rc-virtual-list-holder {
      overflow-y: overlay !important;

      &::-webkit-scrollbar {
        width: 16px;
      }

      &::-webkit-scrollbar-thumb {
        border: 5px solid transparent;
        background-clip: content-box;
        border-radius: 9999px;
        background-color: rgba(139, 143, 163, 0.12);
      }

      &::-webkit-scrollbar-thumb:hover {
        background-color: rgba(139, 143, 163, 0.25);
      }
    }
  }
`, ui = l.div`
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin-top: 8px;
  background: #fdfdfd;
  outline: 1px solid #d7d9e0;
  border-radius: 4px;

  .ant-select {
    font-size: 13px;
    line-height: 13px;
  }

  &:hover {
    outline: 1px solid #8b8fa3;
  }

  &:focus-within {
    outline: 1px solid #315efb;
    border-radius: 4px;
    box-shadow: 0 0 0 3px rgb(24 144 255 / 20%);
  }

  .ant-select-selection-item {
    padding: 0;
    display: flex;
    align-items: center;
  }
`, fi = l(A)`
  width: 328px;
  max-height: 64px;
  overflow-y: scroll;
  overflow-x: hidden;

  &::-webkit-scrollbar {
    display: none;
  }

  &&& {
    .ant-select,
    .ant-select .ant-select-selector {
      width: 100%;
      border: none;
      box-shadow: none;
      padding: 0;
    }
  }

  .ant-select-selection-placeholder {
    color: #b8b9bf;
  }
`, gi = l.div`
  display: flex;
  align-items: center;
  padding: 8px 0 8px 8px;
`, bi = l.div`
  margin: 4px 0 0 auto;
  display: flex;

  button {
    width: 76px;
    height: 28px;
  }
`, xi = l(ct)`
  height: 24px;
  display: flex;
  background: #efeff1;
  border-radius: 12px;
  padding: 0 8px 0 3px;

  margin: 2px 0;

  .ant-tag-close-icon {
    display: flex;
    align-items: center;
    margin-left: 8px;

    &:hover svg g line {
      stroke: #222222;
    }
  }
`, yi = l(E)`
  && > span {
    font-size: 1px;
    transform: scale(0.5, 0.5);
  }
`, wi = l(ye)`
  .ant-select {
    height: 24px;
  }

  display: ${(e) => e.$isVisible ? "unset" : "none"};
`;
function vi(e, i, a, r) {
  let n = e.map((s) => ({
    type: "GROUP",
    id: s.groupId,
    name: s.groupName
  }));
  return n = n.concat(i.map((s) => ({
    type: "USER",
    id: s.userId,
    name: s.name,
    avatarUrl: s.avatarUrl
  }))), n = n.filter((s) => !r.find((c) => c.id === s.id && c.type === s.type) && !(s.type === "USER" && s.id === a.id)), n;
}
function Ii(e) {
  const {
    optionView: i
  } = e, a = i.type === "GROUP" && /* @__PURE__ */ t(X, {
    $color: $(i.name)[1]
  });
  return /* @__PURE__ */ u(gi, {
    children: [/* @__PURE__ */ t(E, {
      userName: i.name,
      side: 32,
      source: i.avatarUrl,
      svg: a
    }), /* @__PURE__ */ t(we, {
      title: i.name,
      children: i.name
    })]
  });
}
function ki(e) {
  const {
    view: i
  } = e, a = i.type === "GROUP" && /* @__PURE__ */ t(X, {
    $color: $(i.name)[1],
    $side: 9
  });
  return /* @__PURE__ */ u("div", {
    style: {
      display: "flex",
      alignItems: "center"
    },
    children: [/* @__PURE__ */ t(yi, {
      userName: i.name,
      side: 18,
      source: i.avatarUrl,
      svg: a
    }), /* @__PURE__ */ t(k, {
      style: {
        marginLeft: "4px",
        maxWidth: "240px",
        overflow: "hidden",
        whiteSpace: "nowrap",
        textOverflow: "ellipsis",
        lineHeight: "15px"
      },
      children: i.name
    })]
  });
}
function Pi(e) {
  const {
    label: i,
    value: a,
    closable: r,
    onClose: n
  } = e;
  return /* @__PURE__ */ t(xi, {
    closeIcon: /* @__PURE__ */ t(ht, {
      style: {
        width: "12px",
        height: "12px"
      }
    }),
    color: a,
    closable: r,
    onClose: n,
    style: {
      marginRight: 3
    },
    children: i
  });
}
var B = /* @__PURE__ */ ((e) => (e.Viewer = "viewer", e.Editor = "editor", e.Owner = "owner", e))(B || {});
const Si = (e) => {
  const i = v(pi), a = v(ci), {
    selectedItems: r,
    setSelectRole: n,
    setSelectedItems: s,
    user: c
  } = e, d = vi(i, a, c, e.filterItems), [p, m] = y(!1), h = It(null);
  return M(() => {
    m(r.length > 0), h && h.current && (h.current.scrollTop = h.current.scrollHeight);
  }, [r]), /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ u(ui, {
      children: [/* @__PURE__ */ t(fi, {
        open: !0,
        ref: h,
        placeholder: o("home.addPermissionPlaceholder"),
        mode: "multiple",
        getPopupContainer: () => document.getElementById("add-app-user-permission-dropdown"),
        optionLabelProp: "label",
        tagRender: Pi,
        listHeight: 240,
        menuItemSelectedIcon: /* @__PURE__ */ t(se, {}),
        notFoundContent: /* @__PURE__ */ t(pt, {
          style: {
            paddingRight: "8px"
          }
        }),
        onSelect: (f, I) => {
          s(r.concat({
            id: I.entityid,
            type: I.type,
            key: I.key
          }));
        },
        onDeselect: (f, I) => {
          s(r.filter((g) => g.key !== I.key));
        },
        children: d.map((f) => /* @__PURE__ */ t(A.Option, {
          entityid: f.id,
          type: f.type,
          value: f.name,
          label: /* @__PURE__ */ t(ki, {
            view: f
          }),
          children: /* @__PURE__ */ t(Ii, {
            optionView: f
          })
        }, `${f.type}-${f.id}`))
      }), /* @__PURE__ */ t(wi, {
        dropdownStyle: {
          width: "fit-content"
        },
        $isVisible: p,
        variant: "borderless",
        defaultValue: e.supportRoles[0],
        optionLabelProp: "label",
        onChange: (f) => n(f),
        children: e.supportRoles.map((f) => /* @__PURE__ */ t(A.Option, {
          value: f.value,
          label: f.label,
          children: /* @__PURE__ */ t(ve, {
            role: f.label
          })
        }, f.value))
      })]
    }), /* @__PURE__ */ t(mi, {
      id: "add-app-user-permission-dropdown"
    })]
  });
}, Ci = (e) => {
  const {
    onCancel: i
  } = e, a = S(), r = v(U), [n, s] = y("viewer"), [c, d] = y([]);
  return M(() => {
    a(lt(r.currentOrgId)), a(dt(r.currentOrgId));
  }, []), /* @__PURE__ */ u(hi, {
    children: [/* @__PURE__ */ t(k, {
      style: {
        marginTop: "16px"
      },
      children: o("home.searchMemberOrGroup")
    }), /* @__PURE__ */ t(Si, {
      selectedItems: c,
      setSelectRole: s,
      setSelectedItems: d,
      user: r,
      filterItems: e.filterItems,
      supportRoles: e.supportRoles
    }), /* @__PURE__ */ u(bi, {
      children: [/* @__PURE__ */ t(L, {
        style: {
          marginRight: "8px"
        },
        onClick: i,
        children: o("cancel") + " "
      }), /* @__PURE__ */ t(L, {
        buttonType: "primary",
        onClick: () => {
          const p = c.filter((h) => h.type === "USER").map((h) => h.id), m = c.filter((h) => h.type === "GROUP").map((h) => h.id);
          if (p.length === 0 && m.length === 0) {
            i();
            return;
          }
          e.addPermission(p, m, n);
        },
        children: o("finish") + " "
      })]
    })]
  });
}, Ri = l.div`
  margin: 12px 16px 0 16px;
  display: flex;
`, Ai = l(L)`
  &,
  &:hover,
  &:focus {
    border: none;
    box-shadow: none;
    padding: 0;
    display: flex;
    align-items: center;
    font-size: 14px;
    line-height: 14px;
    background: #ffffff;
    transition: unset;
  }

  svg {
    margin-right: 4px;
  }

  &:hover {
    color: #315efb;

    svg g path {
      fill: #315efb;
    }
  }
`, Ti = (e) => {
  const {
    supportRoles: i,
    permissionItems: a,
    visible: r,
    onVisibleChange: n,
    addPermission: s,
    viewBodyRender: c
  } = e, [d, p] = y("view");
  return /* @__PURE__ */ t(mt, {
    open: r,
    destroyOnClose: !0,
    onCancel: () => {
      p("view"), n(!1);
    },
    showOkButton: !1,
    showCancelButton: !1,
    width: "440px",
    onStepChange: p,
    activeStepKey: d,
    steps: [{
      key: "view",
      titleRender: () => e.title,
      bodyRender: () => c ? c(/* @__PURE__ */ t(te, {
        ...e
      })) : /* @__PURE__ */ t(te, {
        ...e
      }),
      footerRender: (m) => /* @__PURE__ */ u(Ri, {
        children: [/* @__PURE__ */ t(Ai, {
          style: {
            height: 28
          },
          icon: /* @__PURE__ */ t(le, {
            style: {
              color: ut
            }
          }),
          onClick: () => {
            m.next();
          },
          children: o("home.addMember")
        }), /* @__PURE__ */ t(L, {
          buttonType: "primary",
          onClick: () => n(!1),
          style: {
            marginLeft: "auto",
            width: "76px",
            height: "28px"
          },
          children: o("finish") + " "
        })]
      })
    }, {
      key: "add",
      titleRender: () => o("home.addMember"),
      bodyRender: (m) => /* @__PURE__ */ t(Ci, {
        supportRoles: i,
        filterItems: a.map((h) => h.permissionItem),
        onCancel: m.back,
        addPermission: (h, f, I) => s(h, f, I, m.back)
      }),
      footerRender: (m) => null
    }]
  });
}, Vi = vt.memo((e) => {
  const {
    applicationId: i
  } = e, a = S(), r = v(ft), {
    appType: n
  } = ge(ue), s = n === T.Module;
  M(() => {
    a(K({
      applicationId: i
    }));
  }, [i, a]);
  let c = [];
  if (r) {
    const d = r.permissions.find((p) => p.type === "USER" && p.id === r.creatorId);
    c = [{
      permissionItem: {
        permissionId: "orgAdmin",
        id: "orgAdmin",
        role: "owner",
        name: o("home.orgName", {
          orgName: r.orgName
        }),
        type: "ORG_ADMIN"
      }
    }, ...r.permissions.filter((p) => !(p.type === "USER" && p.id === r.creatorId)).map((p) => ({
      permissionItem: p
    }))], d && (c = [{
      isCreator: !0,
      permissionItem: d
    }, ...c]);
  }
  return /* @__PURE__ */ t(Ti, {
    ...e,
    title: gt,
    ownerLabel: o("home.allPermissions"),
    viewBodyRender: (d) => r ? /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t(Mi, {
        isModule: s,
        applicationId: i,
        permissionInfo: r
      }), d]
    }) : /* @__PURE__ */ t(ri, {
      size: 18
    }),
    supportRoles: [{
      label: o("share.viewer"),
      value: B.Viewer
    }, {
      label: o("share.editor"),
      value: B.Editor
    }, {
      label: o("share.owner"),
      value: B.Owner
    }],
    permissionItems: c,
    addPermission: (d, p, m, h) => O.grantAppPermission({
      applicationId: i,
      userIds: d,
      groupIds: p,
      role: m
    }).then((f) => {
      R(f) && (a(K({
        applicationId: i
      })), h());
    }).catch((f) => {
      w.error(o("home.addPermissionErrorMessage", {
        message: f.message
      }));
    }),
    updatePermission: (d, p) => a(bt({
      applicationId: i,
      role: p,
      permissionId: d
    })),
    deletePermission: (d) => a(xt({
      applicationId: i,
      permissionId: d
    }))
  });
}), Li = l.div`
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;

  button {
    width: 76px;
  }
`, Oi = (e) => {
  const i = window.location.origin + he(e.appId, "view");
  return /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ t(k, {
      style: {
        marginTop: "16px"
      },
      children: o("home.shareLink")
    }), /* @__PURE__ */ u(Li, {
      children: [/* @__PURE__ */ t(me, {
        disabled: !0,
        value: i
      }), /* @__PURE__ */ t(L, {
        buttonType: "primary",
        onClick: () => {
          wt(i) ? w.success(o("copySuccess")) : w.error(o("copyError"));
        },
        children: o("home.copyLink")
      })]
    })]
  });
}, ie = l.div`
  display: flex;
  align-items: center;
  margin-top: 8px;
`;
function Mi(e) {
  const {
    applicationId: i,
    permissionInfo: a,
    isModule: r
  } = e, [n, s] = y(a.publicToAll), [c, d] = y(a.publicToMarketplace), p = S();
  return M(() => {
    s(a.publicToAll);
  }, [a.publicToAll]), M(() => {
    d(a.publicToMarketplace);
  }, [a.publicToMarketplace]), /* @__PURE__ */ u("div", {
    style: {
      marginBottom: "22px"
    },
    children: [/* @__PURE__ */ t(ie, {
      children: /* @__PURE__ */ t(Z, {
        checked: n,
        onChange: (m) => {
          s(m), O.publicToAll(i, m).then((h) => {
            R(h), p(Q({
              publicToAll: m
            }));
          }).catch((h) => {
            w.error(h.message);
          });
        },
        label: r ? o("home.modulePublicMessage") : o("home.appPublicMessage")
      })
    }), n && /* @__PURE__ */ t(ie, {
      children: /* @__PURE__ */ t(Z, {
        checked: c,
        onChange: (m) => {
          d(m), O.publicToMarketplace(i, m).then((h) => {
            R(h), p(Q({
              publicToMarketplace: m
            }));
          }).catch((h) => {
            w.error(h.message);
          });
        },
        label: r ? o("home.moduleMarketplaceMessage") : o("home.appMarketplaceMessage")
      })
    }), c && /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t("div", {
        style: {
          margin: "10px 22px 22px 22px"
        },
        children: o("home.marketplaceGoodPublishing")
      }), /* @__PURE__ */ t(yt, {})]
    }), n && /* @__PURE__ */ t(Oi, {
      appId: i
    })]
  });
}
export {
  Vi as A,
  Di as H,
  E as P,
  Ni as a,
  $i as b
};
