'use strict';

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

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

const modalTemplateSettingsCss = "fireenjin-mx-modal-template-settings .head-input,fireenjin-mx-modal-template-settings .routes-input{display:block;width:100%}fireenjin-mx-modal-template-settings .head-input ion-label,fireenjin-mx-modal-template-settings .routes-input ion-label{font-size:16px !important;font-weight:bold !important;display:block;background:transparent;text-align:left;font-family:var(--ion-font-family);position:relative;font-size:inherit;text-align:inherit;padding:0 0 20px 25px}fireenjin-mx-modal-template-settings .head-input fireenjin-code-editor,fireenjin-mx-modal-template-settings .routes-input fireenjin-code-editor{min-height:300px !important}";

let ModalTemplateSettings = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.pageTitle = "Edit Template Info";
    this.template = {};
    this.partials = [];
    this.hideTemplateSelect = false;
    this.showAdvanced = false;
    this.tags = [];
    this.helpers = {
      formatUSD: (amount) => {
        const formatter = new Intl.NumberFormat("en-US", {
          style: "currency",
          currency: "USD",
          minimumFractionDigits: 2,
        });
        return formatter.format(amount ? amount : 0);
      },
    };
    this.types = [
      {
        label: "Component",
        value: "component",
      },
      {
        label: "Email",
        value: "email",
      },
      {
        label: "Contract",
        value: "contract",
      },
      {
        label: "Frame",
        value: "frame",
      },
      {
        label: "PDF",
        value: "pdf",
      },
      {
        label: "Feed Card",
        value: "feed",
      },
      {
        label: "Message",
        value: "message",
      },
      {
        label: "Web Page",
        value: "page",
      },
    ];
  }
  async onSubmit() {
    this.fireenjinTrigger.emit({ name: "closeModal" });
  }
  async onReset() {
    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.head = event.detail.value;
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    return [
      index.h("ion-header", null, index.h("ion-toolbar", null, index.h("ion-title", null, this.pageTitle), index.h("ion-buttons", { slot: "end" }, 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", null, index.h("fireenjin-form", { ref: (el) => (this.formEl = el), endpoint: this.templateId ? "editTemplate" : "addTemplate", documentId: this.templateId, hideControls: true, beforeSubmit: async (data) => {
          var _a;
          return ({
            ...data,
            head: this.head || ((_a = this.template) === null || _a === void 0 ? void 0 : _a.head),
            attachments: ((data === null || data === void 0 ? void 0 : data.attachments) || []).map((href) => ({
              href,
              filename: href.split("/").pop(),
            })),
          });
        } }, index.h("fireenjin-input", { labelPosition: "stacked", name: "subject", label: "Subject", value: (_a = this.template) === null || _a === void 0 ? void 0 : _a.subject }), index.h("fireenjin-input", { labelPosition: "stacked", name: "description", label: "Description", value: (_b = this.template) === null || _b === void 0 ? void 0 : _b.description }), index.h("fireenjin-input", { labelPosition: "stacked", label: "Text Only Version", name: "text", value: (_c = this.template) === null || _c === void 0 ? void 0 : _c.text }), index.h("fireenjin-select-tags", { labelPosition: "stacked", label: "Tags", lines: "full", options: this.tags, allowAdding: true, value: ((_d = this.template) === null || _d === void 0 ? void 0 : _d.tags) || [] }), index.h("ion-accordion-group", null, index.h("ion-accordion", null, index.h("ion-item", { slot: "header" }, index.h("ion-label", null, "Advanced")), index.h("ion-list", { slot: "content" }, index.h("fireenjin-input", { labelPosition: "stacked", name: "name", label: "Name", value: (_e = this.template) === null || _e === void 0 ? void 0 : _e.name }), index.h("fireenjin-select-tags", { labelPosition: "stacked", label: "Attachments", lines: "full", options: (((_f = this.template) === null || _f === void 0 ? void 0 : _f.attachments) || []).map((attachment) => ({
          label: attachment === null || attachment === void 0 ? void 0 : attachment.filename,
          value: attachment === null || attachment === void 0 ? void 0 : attachment.path,
        })), allowAdding: true, value: ((_g = this.template) === null || _g === void 0 ? void 0 : _g.attachments) || [] }), index.h("fireenjin-input", { labelPosition: "stacked", label: "AMP Version", name: "amp", value: (_h = this.template) === null || _h === void 0 ? void 0 : _h.amp })))))),
    ];
  }
  get modalEl() { return index.getElement(this); }
};
ModalTemplateSettings.style = modalTemplateSettingsCss;

exports.fireenjin_mx_modal_template_settings = ModalTemplateSettings;

//# sourceMappingURL=fireenjin-mx-modal-template-settings.cjs.entry.js.map