'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1206254d.js');

const CorejamFormContainer = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.formEvent = index.createEvent(this, "formEvent", 7);
    this.formSubmit = index.createEvent(this, "formSubmit", 7);
    this.sendForm = index.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 (index.h(index.Host, { as: "form" }, index.h("form", { name: this.name }, index.h("slot", null))));
  }
};

exports.corejam_form_container = CorejamFormContainer;
