import { ad as u, ne as Ie, H as t, a3 as l, iI as ke, eY as B, nf as Pe, aC as Se, ng as Ce, nh as Re, ni as Ae, ii as L, hr as F, ip as k, nj as H, nk as Te, hi as S, hj as v, h$ as $, cU as ne, nl as Le, nm as Oe, a4 as n, nn as Me, no as Ee, np as $e, nq as Ne, cT as w, nr as oe, ns as Ue, i5 as z, i6 as R, nt as G, I as P, nu as K, nv as Be, nw as ae, cW as j, nx as re, ny as Ve, nz as De, cS as D, nA as We, nB as X, nC as se, lI as le, iB as de, nD as ze, nE as Fe, i7 as ce, nF as He, nG as Ge, ao as pe, nH as je, as as _e, nI as O, j6 as he, k_ as me, gd as A, i4 as T, i2 as Ye, i1 as Je, i0 as Ke, hS as ue, j5 as Xe, fz as qe, nJ as Ze, nK as Qe, ib as et, nL as tt, nM as it, nN as nt, nO as ot, nP as at, nQ as rt, nR as st, nS as lt, nT as dt, nU as ct, nV as pt, nW as ht, nX as mt, hy as ut, nY as ft, ht as gt, nZ as bt, n_ as q, ik as xt, n$ as yt, o0 as wt, o1 as Z, o2 as Q, cI as vt, o3 as It } from "./56c67d3b.js";
import kt, { useState as y, useEffect as M, useMemo as fe, useContext as ge, useRef as Pt } from "react";
import { a as St } from "./0d7df38d.js";
import { f as Ct } from "./0a391aff.js";
const Rt = 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"};
  }
`, At = l.div`
  display: flex;
  align-items: center;
`, Tt = l.div`
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
`, Lt = l.div`
  display: flex;
  align-items: center;
`;
function Bi(e) {
  const {
    headerStart: i,
    headerMiddle: r,
    headerEnd: a
  } = e, o = /\/edit|\/view|\/preview/, s = !!window.location.pathname.match(o);
  return /* @__PURE__ */ u(Rt, {
    className: Ie,
    $isEditViewPreview: s,
    style: e.style,
    children: [/* @__PURE__ */ t(At, {
      children: i
    }), /* @__PURE__ */ t(Tt, {
      children: r
    }), /* @__PURE__ */ t(Lt, {
      children: a
    })]
  });
}
const Ot = 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 = B(e.userName, !0), [r, a] = y(!1), o = Pe(e.source), s = (o || e.svg) && !r;
  return /* @__PURE__ */ t(Ot, {
    $fontSize: e.fontSize,
    style: e.style,
    className: e.className,
    $side: e.side,
    title: e.userName,
    children: s ? e.source ? /* @__PURE__ */ t("img", {
      onError: () => a(!0),
      onLoad: () => a(!1),
      src: o
    }) : 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;
  }
`, Mt = l(Ce)`
  margin-bottom: 16px;
  ${_};
`, W = 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;
`, Et = l.div`
  display: flex;
  align-items: center;
  width: 81px;
  height: 13px;

  img {
    width: 16px;
    height: 16px;
    margin-right: 6px;
  }
`, $t = l(F)`
  transform: scaleX(-1) scaleY(-1) rotate(-90deg);
`, Nt = 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;
`, Vt = 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);
  }
`, Dt = 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(Nt, {
    children: [/* @__PURE__ */ u(Et, {
      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(H, {
      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($t, {})]
    })]
  });
}
function Wt(e, i) {
  var a;
  const r = (a = e.connections) == null ? void 0 : a.find((o) => o.source === i);
  return r != null && r.name ? Te(r.name) : "";
}
function zt() {
  const e = S(), i = v($), r = (a) => {
    a.file.status === "done" && $e(a.file.originFileObj, (o) => {
      e(Ne({
        avatarUrl: o
      }));
    }), a.file.status === "error" && w.error(n("profile.uploadError"));
  };
  return i ? /* @__PURE__ */ u(Dt, {
    children: [/* @__PURE__ */ t("div", {
      style: {
        height: "72px"
      },
      children: /* @__PURE__ */ t(ne, {
        accept: "image/*",
        showUploadList: !1,
        action: Le,
        onChange: r,
        beforeUpload: Oe,
        withCredentials: !0,
        children: /* @__PURE__ */ u(Bt, {
          children: [/* @__PURE__ */ t(Ut, {
            side: 72,
            source: i.avatarUrl,
            userName: i.username
          }), /* @__PURE__ */ t(Vt, {
            children: n("profile.editProfilePicture")
          })]
        })
      })
    }), /* @__PURE__ */ t(Me, {
      valueCheck: {
        rule: (a) => a.trim() !== "",
        message: n("profile.nameCheck")
      },
      inputStyle: {
        width: "248px",
        height: " 32px"
      },
      label: n("profile.name"),
      mustFill: !0,
      placeholder: n("profile.namePlaceholder"),
      defaultValue: i.username,
      onFinish: (a) => {
        e(Ee({
          name: a
        }));
      }
    })]
  }) : null;
}
function Ft() {
  const [e, i] = y(""), r = S(), a = v(oe), o = a == null ? void 0 : a.form.id, s = (c) => {
    z.bindEmail({
      email: c,
      authId: o
    }).then((d) => {
      R(d) && (w.success(n("profile.bindEmailSuccess")), r(G()));
    }).catch((d) => {
      w.error(d.message);
    });
  };
  return /* @__PURE__ */ u(xe, {
    children: [/* @__PURE__ */ t(Mt, {
      mustFill: !0,
      label: n("profile.email"),
      onChange: (c, d) => i(d ? c : ""),
      placeholder: n("profile.emailPlaceholder"),
      checkRule: {
        check: (c) => Ue(c),
        errorMsg: n("profile.emailCheck")
      }
    }), /* @__PURE__ */ t(be, {
      buttonType: "primary",
      disabled: !e,
      onClick: () => s(e),
      children: n("profile.submit")
    })]
  });
}
function Ht(e) {
  const [i, r] = y(""), [a, o] = y(""), s = S(), c = () => {
    const d = e.hasPass ? z.updatePassword({
      oldPassword: i,
      newPassword: a
    }) : z.setPassword({
      password: a
    }), p = e.hasPass ? n("profile.passwordModifiedSuccess") : n("profile.passwordSetSuccess");
    d.then((m) => {
      R(m) && (w.success(p), s(G()));
    }).catch((m) => {
      w.error(m.message);
    });
  };
  return /* @__PURE__ */ u(xe, {
    children: [e.hasPass ? /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t(W, {
        passInputConf: {
          label: n("profile.oldPassword"),
          placeholder: n("profile.inputCurrentPassword")
        },
        onChange: (d, p) => {
          r(p ? d : "");
        }
      }), /* @__PURE__ */ t(W, {
        doubleCheck: !0,
        valueCheck: K,
        onChange: (d, p) => o(p ? d : ""),
        passInputConf: {
          label: n("profile.newPassword"),
          placeholder: n("profile.inputNewPassword")
        },
        confirmPassConf: {
          label: n("profile.confirmNewPassword"),
          placeholder: n("profile.inputNewPasswordAgain")
        }
      })]
    }) : /* @__PURE__ */ t(W, {
      doubleCheck: !0,
      valueCheck: K,
      onChange: (d, p) => o(p ? d : "")
    }), /* @__PURE__ */ t(be, {
      buttonType: "primary",
      disabled: e.hasPass && !i || !a,
      onClick: c,
      children: n("profile.submit")
    })]
  });
}
function Gt(e) {
  const i = v($), {
    setModalContent: r,
    setTitle: a,
    setShowBackLink: o
  } = e, s = i.hasPassword, c = Wt(i, Be.email);
  return /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ t(zt, {}), /* @__PURE__ */ t(ee, {
      titleLabel: n("profile.bindEmail"),
      infoLabel: n("profile.loginAfterBind", {
        name: n("profile.email")
      }),
      value: c,
      actionButtonConfig: {
        label: c ? n("profile.binding") : n("profile.toBind"),
        disabled: !!c,
        onClick: () => {
          r(/* @__PURE__ */ t(Ft, {})), a(n("profile.bindName", {
            name: n("profile.email")
          })), o(!0);
        }
      }
    }, "email"), /* @__PURE__ */ t(ee, {
      titleLabel: n("profile.password"),
      infoLabel: s ? n("profile.alreadySetPassword") : n("profile.setPassPlaceholder"),
      actionButtonConfig: {
        label: s ? n("profile.modifyPassword") : n("profile.setPassword"),
        onClick: () => {
          r(/* @__PURE__ */ t(Ht, {
            hasPass: s
          })), a(s ? n("profile.modifyPassword") : n("profile.setPassword")), o(!0);
        },
        hidden: !1
      }
    }, "password")]
  });
}
function jt() {
  const e = v(ae), i = S(), [r, a] = y(n("profile.personalInfo")), [o, s] = y(!1), [c, d] = y(), p = /* @__PURE__ */ t(Gt, {
    setModalContent: d,
    setShowBackLink: s,
    setTitle: a
  }), m = (h) => {
    h.data.type === Ve.THIRD_PARTY_BIND && (h.data.success ? (i(G()), w.info(n("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: r,
    open: e,
    onCancel: () => i(re(!1)),
    showOkButton: !1,
    showCancelButton: !1,
    showBackLink: o,
    onBack: () => {
      s(!1), d(p), a(n("profile.personalInfo"));
    },
    children: c
  });
}
const {
  Item: _t
} = _e, Yt = 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;
    }
  }
`, Jt = l(pe)`
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: end;
`, Kt = l(F)`
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
`;
l((e) => /* @__PURE__ */ t(_t, {
  ...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 Xt = 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;
  }
`, qt = l.div`
  font-size: 12px;
  color: #4965f2;
  line-height: 14px;
  border: 1px solid #d6e4ff;
  border-radius: 8px;
  padding: 1px 5px;
`;
function Vi(e) {
  const {
    avatarUrl: i,
    username: r,
    orgs: a,
    currentOrgId: o
  } = e.user, s = e.user.orgRoleMap.get(o), c = fe(() => e.user.orgs.find((g) => g.id === o), [e.user, o]), d = v(ae), p = v(oe), m = S(), h = (g) => {
    if (g.key === "profile") {
      if (D(window.innerWidth))
        return;
      m(re(!0));
    } else
      g.key === "logout" ? m(ze({})) : g.keyPath.includes("switchOrg") && (g.key === "newOrganization" ? (m(Fe(a)), ce.push(He)) : o !== g.key && m(Ge(g.key)));
  };
  let f = [{
    key: "profile",
    label: /* @__PURE__ */ u(Yt, {
      children: [/* @__PURE__ */ t(E, {
        source: i,
        userName: r,
        side: 48
      }), /* @__PURE__ */ u(Xt, {
        children: [/* @__PURE__ */ t(De, {
          title: r,
          children: r
        }), !D(window.innerWidth) && /* @__PURE__ */ t(We, {})]
      }), c && /* @__PURE__ */ t(H, {
        style: {
          width: "130px",
          textAlign: "center",
          lineHeight: "15px"
        },
        children: c.name
      }), s && X[s] && /* @__PURE__ */ t(qt, {
        children: X[s].name
      })]
    })
  }, {
    key: "logout",
    label: n("profile.logout")
  }];
  if (a && a.length > 0 && St(e.user, p)) {
    const g = a.map((b) => ({
      key: b.id,
      icon: o === b.id && /* @__PURE__ */ t(se, {}),
      label: b.name
    }));
    let C = [];
    D(window.innerWidth) || (C = [{
      type: "divider"
    }, {
      key: "newOrganization",
      icon: /* @__PURE__ */ t(le, {}),
      label: n("profile.createOrg")
    }]);
    const x = {
      key: "switchOrg",
      label: n("profile.switchOrg"),
      popupOffset: [4, -12],
      children: [{
        key: "joinedOrg",
        label: /* @__PURE__ */ t(k, {
          style: {
            margin: "8px",
            color: "#B8B9BF"
          },
          children: n("profile.joinedOrg")
        }),
        disabled: !0
      }, ...g, ...C]
    };
    f.splice(1, 0, x);
  }
  const I = /* @__PURE__ */ t(de, {
    style: {
      width: "192px"
    },
    onClick: h,
    expandIcon: /* @__PURE__ */ t(Kt, {}),
    items: f
  });
  return /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ t(Jt, {
      dropdownRender: () => I,
      trigger: ["click"],
      children: /* @__PURE__ */ t("div", {
        children: /* @__PURE__ */ t(E, {
          style: {
            cursor: "pointer",
            userSelect: "none"
          },
          source: i,
          userName: r,
          side: e.profileSide,
          fontSize: e.fontSize
        })
      })
    }), d && /* @__PURE__ */ t(jt, {})]
  });
}
l(ne)`
  .ant-upload-wrapper .ant-upload-select {
    display: block;
  }
`;
const Zt = (e) => {
  const i = "t--export-app-link", r = document.getElementById(i);
  r && r.remove();
  const a = document.createElement("a");
  O.getApplicationDetail({
    applicationId: e,
    type: "editing"
  }).then((o) => {
    if (R(o)) {
      const s = o.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);
      a.href = m, a.download = c + ".json", a.id = i, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(m);
      return;
    }
  }).catch((o) => w.error(n("home.exportError", {
    message: o.message
  })));
};
function Qt(e) {
  var g, C;
  const [i, r] = y(""), a = v($), o = v(Ct), [s, c] = y(((g = o.find((x) => {
    var b, J;
    return ((b = x.subApplications) == null ? void 0 : b.length) && ((J = x.subApplications) == null ? void 0 : J.findIndex((V) => (V == null ? void 0 : V.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: n("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: a.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(n("copyError"));
      });
    },
    children: /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t("span", {
        style: {
          display: "block",
          marginBottom: "4px"
        },
        children: n("home.copyNameLabel", {
          type: U[h]
        })
      }), /* @__PURE__ */ t(me, {
        placeholder: n("home.copyNamePlaceholder", {
          type: (C = U[h]) == null ? void 0 : C.toLowerCase()
        }),
        onChange: (x) => {
          r(x.target.value);
        }
      }), !!o.length && /* @__PURE__ */ u(P, {
        children: [/* @__PURE__ */ t("span", {
          style: {
            display: "block",
            margin: "15px 0 4px"
          },
          children: n("home.copyModalfolderLabel")
        }), /* @__PURE__ */ t(A, {
          defaultValue: s,
          style: {
            width: "100%"
          },
          onChange: (x) => c(x),
          options: [{
            label: n("home.rootFolder"),
            value: ""
          }, ...o.map((x) => ({
            label: x.name,
            value: x.folderId
          }))],
          filterOption: (x, b) => (b == null ? void 0 : b.label).includes(x)
        })]
      })]
    })
  });
}
const ei = l(F)`
  transform: rotate(180deg);
  margin-left: 4px;
  min-width: 18px;

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

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

  g g {
    fill: ${(e) => e.$color};
  }
`, ri = l(ot)`
  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(ai, {
    children: /* @__PURE__ */ t("div", {
      children: e.role
    })
  });
}
const si = l(at)`
  height: 353px;
  width: 100%;
`, li = l.li`
  display: flex;
  align-items: center;
  padding: 8px 8px;
  width: 424px;

  &:hover {
    background: #f2f7fc;
    border-radius: 4px;
  }
`, di = 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);
  }
`, ci = 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 pi(e) {
  const {
    permissionItem: i,
    isCreator: r
  } = e;
  let a;
  return i.type === "GROUP" ? a = Y : i.type === "ORG_ADMIN" && (a = ri), /* @__PURE__ */ u(li, {
    children: [/* @__PURE__ */ t(E, {
      side: 32,
      userName: i.name,
      source: i.avatar && rt(i.avatar),
      svg: a && /* @__PURE__ */ t(a, {
        $color: B(i.name)[1]
      })
    }), /* @__PURE__ */ u(we, {
      title: i.name,
      children: [i.type === "GROUP" && n("home.groupWithSquareBrackets"), i.name]
    }), r && /* @__PURE__ */ t(ci, {
      children: n("home.creator")
    }), r || i.type === "ORG_ADMIN" ? /* @__PURE__ */ t(H, {
      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: (o, s) => {
        s.key === "delete" ? e.deletePermission(s.permissionid) : e.updatePermission(s.permissionid, s.key);
      },
      children: [e.supportRoles.map((o) => /* @__PURE__ */ t(A.Option, {
        label: o.label,
        value: o.value,
        permissionid: i.permissionId,
        children: /* @__PURE__ */ t(ve, {
          role: o.label
        })
      }, o.value)), /* @__PURE__ */ t(A.Option, {
        label: n("remove"),
        value: "delete",
        permissionid: i.permissionId,
        children: /* @__PURE__ */ t(st, {
          $fontSize: 13,
          children: n("remove")
        })
      }, "delete")]
    })]
  }, i.permissionId);
}
const te = (e) => /* @__PURE__ */ u(P, {
  children: [/* @__PURE__ */ t(k, {
    style: {
      marginBottom: "4px"
    },
    children: n("home.memberPermissionList")
  }), /* @__PURE__ */ t(di, {
    $height: 201,
    children: e.permissionItems.map((i, r) => /* @__PURE__ */ t(pi, {
      isCreator: i.isCreator,
      permissionItem: i.permissionItem,
      ...e
    }, r))
  })]
}), 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, r, a) {
  let o = e.map((s) => ({
    type: "GROUP",
    id: s.groupId,
    name: s.groupName
  }));
  return o = o.concat(i.map((s) => ({
    type: "USER",
    id: s.userId,
    name: s.name,
    avatarUrl: s.avatarUrl
  }))), o = o.filter((s) => !a.find((c) => c.id === s.id && c.type === s.type) && !(s.type === "USER" && s.id === r.id)), o;
}
function Ii(e) {
  const {
    optionView: i
  } = e, r = i.type === "GROUP" && /* @__PURE__ */ t(Y, {
    $color: B(i.name)[1]
  });
  return /* @__PURE__ */ u(gi, {
    children: [/* @__PURE__ */ t(E, {
      userName: i.name,
      side: 32,
      source: i.avatarUrl,
      svg: r
    }), /* @__PURE__ */ t(we, {
      title: i.name,
      children: i.name
    })]
  });
}
function ki(e) {
  const {
    view: i
  } = e, r = i.type === "GROUP" && /* @__PURE__ */ t(Y, {
    $color: B(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: r
    }), /* @__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: r,
    closable: a,
    onClose: o
  } = e;
  return /* @__PURE__ */ t(xi, {
    closeIcon: /* @__PURE__ */ t(ut, {
      style: {
        width: "12px",
        height: "12px"
      }
    }),
    color: r,
    closable: a,
    onClose: o,
    style: {
      marginRight: 3
    },
    children: i
  });
}
var N = /* @__PURE__ */ ((e) => (e.Viewer = "viewer", e.Editor = "editor", e.Owner = "owner", e))(N || {});
const Si = (e) => {
  const i = v(pt), r = v(ht), {
    selectedItems: a,
    setSelectRole: o,
    setSelectedItems: s,
    user: c
  } = e, d = vi(i, r, c, e.filterItems), [p, m] = y(!1), h = Pt(null);
  return M(() => {
    m(a.length > 0), h && h.current && (h.current.scrollTop = h.current.scrollHeight);
  }, [a]), /* @__PURE__ */ u(P, {
    children: [/* @__PURE__ */ u(ui, {
      children: [/* @__PURE__ */ t(fi, {
        open: !0,
        ref: h,
        placeholder: n("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(mt, {
          style: {
            paddingRight: "8px"
          }
        }),
        onSelect: (f, I) => {
          s(a.concat({
            id: I.entityid,
            type: I.type,
            key: I.key
          }));
        },
        onDeselect: (f, I) => {
          s(a.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) => o(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, r = S(), a = v($), [o, s] = y("viewer"), [c, d] = y([]);
  return M(() => {
    r(lt(a.currentOrgId)), r(dt(a.currentOrgId));
  }, []), /* @__PURE__ */ u(hi, {
    children: [/* @__PURE__ */ t(k, {
      style: {
        marginTop: "16px"
      },
      children: n("home.searchMemberOrGroup")
    }), /* @__PURE__ */ t(Si, {
      selectedItems: c,
      setSelectRole: s,
      setSelectedItems: d,
      user: a,
      filterItems: e.filterItems,
      supportRoles: e.supportRoles
    }), /* @__PURE__ */ u(bi, {
      children: [/* @__PURE__ */ t(L, {
        style: {
          marginRight: "8px"
        },
        onClick: i,
        children: n("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, o);
        },
        children: n("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: r,
    visible: a,
    onVisibleChange: o,
    addPermission: s,
    viewBodyRender: c
  } = e, [d, p] = y("view");
  return /* @__PURE__ */ t(ft, {
    open: a,
    destroyOnClose: !0,
    onCancel: () => {
      p("view"), o(!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: gt
            }
          }),
          onClick: () => {
            m.next();
          },
          children: n("home.addMember")
        }), /* @__PURE__ */ t(L, {
          buttonType: "primary",
          onClick: () => o(!1),
          style: {
            marginLeft: "auto",
            width: "76px",
            height: "28px"
          },
          children: n("finish") + " "
        })]
      })
    }, {
      key: "add",
      titleRender: () => n("home.addMember"),
      bodyRender: (m) => /* @__PURE__ */ t(Ci, {
        supportRoles: i,
        filterItems: r.map((h) => h.permissionItem),
        onCancel: m.back,
        addPermission: (h, f, I) => s(h, f, I, m.back)
      }),
      footerRender: (m) => null
    }]
  });
}, Wi = kt.memo((e) => {
  const {
    applicationId: i
  } = e, r = S(), a = v(bt), {
    appType: o
  } = ge(ue), s = o === T.Module;
  M(() => {
    r(q({
      applicationId: i
    }));
  }, [i, r]);
  let c = [];
  if (a) {
    const d = a.permissions.find((p) => p.type === "USER" && p.id === a.creatorId);
    c = [{
      permissionItem: {
        permissionId: "orgAdmin",
        id: "orgAdmin",
        role: "owner",
        name: n("home.orgName", {
          orgName: a.orgName
        }),
        type: "ORG_ADMIN"
      }
    }, ...a.permissions.filter((p) => !(p.type === "USER" && p.id === a.creatorId)).map((p) => ({
      permissionItem: p
    }))], d && (c = [{
      isCreator: !0,
      permissionItem: d
    }, ...c]);
  }
  return /* @__PURE__ */ t(Ti, {
    ...e,
    title: xt,
    ownerLabel: n("home.allPermissions"),
    viewBodyRender: (d) => a ? /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t(Mi, {
        isModule: s,
        applicationId: i,
        permissionInfo: a
      }), d]
    }) : /* @__PURE__ */ t(si, {
      size: 18
    }),
    supportRoles: [{
      label: n("share.viewer"),
      value: N.Viewer
    }, {
      label: n("share.editor"),
      value: N.Editor
    }, {
      label: n("share.owner"),
      value: N.Owner
    }],
    permissionItems: c,
    addPermission: (d, p, m, h) => O.grantAppPermission({
      applicationId: i,
      userIds: d,
      groupIds: p,
      role: m
    }).then((f) => {
      R(f) && (r(q({
        applicationId: i
      })), h());
    }).catch((f) => {
      w.error(n("home.addPermissionErrorMessage", {
        message: f.message
      }));
    }),
    updatePermission: (d, p) => r(yt({
      applicationId: i,
      role: p,
      permissionId: d
    })),
    deletePermission: (d) => r(wt({
      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: n("home.shareLink")
    }), /* @__PURE__ */ u(Li, {
      children: [/* @__PURE__ */ t(me, {
        disabled: !0,
        value: i
      }), /* @__PURE__ */ t(L, {
        buttonType: "primary",
        onClick: () => {
          It(i) ? w.success(n("copySuccess")) : w.error(n("copyError"));
        },
        children: n("home.copyLink")
      })]
    })]
  });
}, ie = l.div`
  display: flex;
  align-items: center;
  margin-top: 8px;
`;
function Mi(e) {
  const {
    applicationId: i,
    permissionInfo: r,
    isModule: a
  } = e, [o, s] = y(r.publicToAll), [c, d] = y(r.publicToMarketplace), p = S();
  return M(() => {
    s(r.publicToAll);
  }, [r.publicToAll]), M(() => {
    d(r.publicToMarketplace);
  }, [r.publicToMarketplace]), /* @__PURE__ */ u("div", {
    style: {
      marginBottom: "22px"
    },
    children: [/* @__PURE__ */ t(ie, {
      children: /* @__PURE__ */ t(Z, {
        checked: o,
        onChange: (m) => {
          s(m), O.publicToAll(i, m).then((h) => {
            R(h), p(Q({
              publicToAll: m
            }));
          }).catch((h) => {
            w.error(h.message);
          });
        },
        label: a ? n("home.modulePublicMessage") : n("home.appPublicMessage")
      })
    }), o && /* @__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: a ? n("home.moduleMarketplaceMessage") : n("home.appMarketplaceMessage")
      })
    }), c && /* @__PURE__ */ u(P, {
      children: [/* @__PURE__ */ t("div", {
        style: {
          margin: "10px 22px 22px 22px"
        },
        children: n("home.marketplaceGoodPublishing")
      }), /* @__PURE__ */ t(vt, {})]
    }), o && /* @__PURE__ */ t(Oi, {
      appId: i
    })]
  });
}
export {
  Wi as A,
  Di as H,
  E as P,
  Bi as a,
  Vi as b
};
