'use strict';

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

const index = require('./index-3e5ae956.js');

const modalCodeEditorCss = "fireenjin-mx-modal-code-editor fireenjin-code-editor{position:absolute;top:0;left:0;right:0;bottom:0;height:100%;width:100%;min-height:100%;min-width:100%}";

const ModalEditor = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.pageTitle = "Sample Data";
    this.name = "sampleData";
  }
  async onSubmit() {
    this.fireenjinTrigger.emit({ name: "closeModal" });
  }
  onCodeChange(event) {
    var _a;
    if (!((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.value))
      return;
    this.value = event.detail.value;
  }
  render() {
    return [
      index.h("ion-header", null, index.h("ion-toolbar", null, index.h("ion-title", null, this.pageTitle || "Sample Data"), index.h("ion-buttons", { slot: "end" }, this.documentId && (index.h("ion-button", { onClick: () => this.formEl.submit() }, index.h("ion-icon", { slot: "icon-only", name: "save" }))), index.h("ion-button", { onClick: () => this.fireenjinTrigger.emit({
          name: "closeModal",
          el: this.modalEl,
          component: "mx-modal-send-email",
        }) }, index.h("ion-icon", { slot: "icon-only", name: "close-circle-outline" }))))),
      index.h("ion-content", { style: {
          "--background": "var(--ion-color-base)",
        } }, index.h("fireenjin-form", { ref: (el) => (this.formEl = el), endpoint: this.endpoint, documentId: this.documentId, hideControls: true, beforeSubmit: async () => ({
          [this.name]: typeof this.value === "string" && this.language === "json"
            ? JSON.parse(this.value)
            : this.value || null,
        }) }, index.h("fireenjin-code-editor", { name: this.name || "sampleData", language: this.language || "json", value: this.value }))),
    ];
  }
};
ModalEditor.style = modalCodeEditorCss;

exports.fireenjin_mx_modal_code_editor = ModalEditor;
