import { r as registerInstance, c as createEvent, h, H as Host } from './index-419dc51e.js';

const CorejamFormContainer = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.formEvent = createEvent(this, "formEvent", 7);
    this.formSubmit = createEvent(this, "formSubmit", 7);
    this.sendForm = createEvent(this, "sendForm", 7);
    this.formData = {};
  }
  handleSubmit(e) {
    if (e.detail.name == this.name) {
      console.info("form submit");
      const data = Object.assign({}, this.formData);
      if (this.submitHandler)
        this.submitHandler(data);
      this.sendForm.emit(data);
    }
  }
  receivedFormEvent(event) {
    if (event.detail.name == this.name) {
      const formData = Object.assign(Object.assign({}, this.formData), { formId: this.name });
      console.log(formData);
      formData[event.detail.key] = event.detail;
      this.formData = formData;
    }
  }
  render() {
    return (h(Host, { as: "form" }, h("form", { name: this.name }, h("slot", null))));
  }
};

export { CorejamFormContainer as corejam_form_container };
