import { r as registerInstance, h } from './index-8dc1a0b7.js';
import { c as coreState } from './core-6e4b87fa.js';
import './_commonjsHelpers-66ac50f5.js';
import './index-2f7827f5.js';
import './runStore-08a7baa7.js';
import { a as authStore } from './authStore-62b9ecb0.js';
import './index-313b8a90.js';
import { a as userUpdateGQL } from './Mutations-823a697d.js';

const Account = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.profileFormId = "profile";
  }
  async formEventHandler({ detail }) {
    if (detail.formId != this.profileFormId)
      return;
    return this.updateProfile(detail);
  }
  async updateProfile(detail) {
    const userInput = {};
    Object.keys(detail).map((value) => {
      if (detail[value].key) {
        userInput[detail[value].key] = detail[value].value;
      }
    });
    await coreState.client.mutate(userUpdateGQL, {
      userInput,
    });
  }
  render() {
    var _a, _b;
    return ((_a = authStore.identity) === null || _a === void 0 ? void 0 : _a.user) ? (h("corejam-box", { max: "xl", mx: "auto", mt: 12, px: 4, lgPx: 0 }, h("corejam-box", { mb: 16 }, h("corejam-type", { as: "h2", size: "3xl", align: "center", weight: "bold" }, "My Account")), h("corejam-box", { flex: true }, h("corejam-box", { w: "3", pt: 8, bWidthTop: 1, bColor: "gray-500", mr: 24 }, h("corejam-box", { flex: true, direction: "col" }, h("corejam-box", { mb: 4 }, h("corejam-base-link", { href: "#", class: "py-4 mb-1" }, "Account details")), h("corejam-box", { mb: 4 }, h("corejam-base-link", { href: "#", class: "py-4 mb-1" }, "Settings")))), h("corejam-box", { w: "9", pt: 8, bWidthTop: 1, bColor: "gray-500" }, h("corejam-form-container", { name: this.profileFormId }, h("corejam-box", { flex: true, mb: 8 }, h("corejam-box", { w: "6", pl: 4 }, h("corejam-form-input", { name: "email", type: "email", formId: this.profileFormId, required: true, label: "Email Address", value: (_b = authStore.identity) === null || _b === void 0 ? void 0 : _b.user.email, placeholder: "Email" }))), h("corejam-form-submit", { formId: this.profileFormId }, h("corejam-type", { size: "sm", weight: "bold", transform: "uppercase", decoration: "underline" }, "Save"))), h("auth-reset-password-form", null))))) : (h("div", null, "Login"));
  }
};

export { Account as auth_account };
