import { r as registerInstance, h, H as Host, g as getElement } from './index-55faf181.js';
import { a as getUserInitials } from './User-d2ee8b71.js';
import { i as injectContext } from './index-8d5c9a8e.js';
import './data-model-f5160369.js';
import './context-8273b228.js';
import './state-tunnel-04c0b67a.js';

const dvnAppActivateMembershipCss = "dvn-app-activate-membership{display:block}dvn-app-activate-membership .space-logo{width:48px;height:48px;-ms-flex:0 0 48px;flex:0 0 48px;margin-right:0.5rem}";

function wrapContent(content) {
  return (h(Host, { class: "d-block row justify-content-center pt-3" }, h("div", { class: "col mt-3" }, content)));
}
const DvnAppActivateMembership = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.renderTrigger = 0;
    this.isProgressing = false;
  }
  async activateMembership() {
    const { membership } = this;
    const result = await this.apiUye.activateMembership(membership.config._id, membership._id).catch(e => {
      console.log(e);
    });
    if (!result)
      return;
    this.appContextInvalidator();
  }
  render() {
    const { membership, user } = this;
    if (!membership) {
      return wrapContent(h("dvn-progress", { indefinite: true }));
    }
    // TODO handle this scenario
    // if membership and session users don't match, show 'mismatch user' message
    // if (isUserLoggedIn() && getSessionData().uid !== membership.user._id) {
    //   return wrapContent(
    //     <div class="d-flex flex-column align-items-center">
    //       <p>
    //         This membership is created for <b>{membership.user.email} </b>
    //         but you're logged in from a different account. Please logout in order to proceed.
    //       </p>
    //       <kimlik-logout-action redirectTo={location.pathname} sendApiRequest={false}>
    //         <dvn-button shape="rounded" tint="primary">
    //           Logout
    //         </dvn-button>
    //       </kimlik-logout-action>
    //     </div>
    //   );
    // }
    return wrapContent(h("div", { class: "text-centered" }, h("div", { class: "d-flex align-items-center justify-content-center" }, h("dvn-image", { bordered: true, src: membership.config.space.logoUrl, size: 64, text: membership.config.space.name[0] }), h("dvn-icon", { iconName: "uil uil-plus", scale: "large" }), h("dvn-image", { bordered: true, src: user.imageUrl, size: 64, shape: "circle", text: getUserInitials(user) })), h("p", null, "You're invited as ", h("i", null, membership.config.roleName), " to join ", membership.config.space.name, "."), h("dvn-button", { onClick: () => this.activateMembership(), tint: "primary" }, "Accept Invitation")));
  }
  get el() { return getElement(this); }
};
injectContext(DvnAppActivateMembership);
DvnAppActivateMembership.style = dvnAppActivateMembershipCss;

export { DvnAppActivateMembership as dvn_app_activate_membership };
