import { r as registerInstance, d as createEvent, h } from './index-33e43734.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%}";

let ModalEditor = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.pageTitle = "Sample Data";
    this.name = "sampleData";
    this.endpoint = "editTemplate";
  }
  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 [
      h("ion-header", null, h("ion-toolbar", null, h("ion-title", null, this.pageTitle || "Sample Data"), h("ion-buttons", { slot: "end" }, this.documentId && (h("ion-button", { onClick: () => this.formEl.submit() }, h("ion-icon", { slot: "icon-only", name: "save" }))), h("ion-button", { onClick: () => this.fireenjinTrigger.emit({
          name: "closeModal",
          el: this.modalEl,
          component: "mx-modal-send-email",
        }) }, h("ion-icon", { slot: "icon-only", name: "close-circle-outline" }))))),
      h("ion-content", { style: {
          "--background": "var(--ion-color-base)",
        } }, 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,
        }) }, h("fireenjin-code-editor", { name: this.name || "sampleData", language: this.language || "json", value: this.value }))),
    ];
  }
};
ModalEditor.style = modalCodeEditorCss;

export { ModalEditor as fireenjin_mx_modal_code_editor };

//# sourceMappingURL=fireenjin-mx-modal-code-editor.entry.js.map