import { r as registerInstance, h, H as Host } from './index-ecdfb761.js';
import { B as BaseField } from './BaseField-0b01dc2c.js';
import './index-150b6a59.js';
import { i as injectContext } from './index-28758765.js';
import './FieldGenerator-3ae403b2.js';
import './state-tunnel-04c0b67a.js';

const DvnMemberInfoForm = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.onSubmit = (event) => {
      const data = event.detail.values;
      this.progressing = true;
      this.apiUye.updateMembership(this.membership.config._id, this.membership._id, data)
        .then(this.onUpdateSucceed, this.onUpdateFail)
        .finally(() => this.progressing = false);
    };
    this.onUpdateSucceed = () => {
      this.appContextInvalidator();
    };
    this.onUpdateFail = (error) => {
      this.error = error;
    };
  }
  render() {
    const { membership, progressing } = this;
    if (!membership) {
      return null;
    }
    return (h(Host, { class: "d-block" }, h("doldurma-form", { fields: membership.config.fields
        .filter(field => field.id !== 'user') // remove the user from the form
        .map(field => (BaseField.decode(Object.assign(Object.assign({}, field), { value: membership[field.id] })))), onSubmit: this.onSubmit, submitButtonLabel: "Save", progressing: progressing })));
  }
};
injectContext(DvnMemberInfoForm);

export { DvnMemberInfoForm as dvn_member_info_form };
