import { r as registerInstance, h, H as Host } from './index-e0adbd54.js';

const ModalComponentSelect = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.partials = undefined;
    this.blockId = undefined;
  }
  async selectPartial(partial, event) {
    if (event)
      event.preventDefault();
    document.dispatchEvent(new CustomEvent("fireenjinEditorClick", {
      detail: {
        event: event,
        template: {
          id: partial.id,
          name: partial.name ? partial.name : partial.subject,
          html: partial.html,
        },
        blockId: this.blockId,
      },
    }));
  }
  render() {
    return (h(Host, null, h("ion-header", null, h("ion-toolbar", null, h("ion-title", null, "Select a Template"), h("ion-buttons", { slot: "primary" }, h("ion-button", { onClick: (event) => document.dispatchEvent(new CustomEvent("fireenjinModalClose", {
        detail: { event },
      })) }, h("ion-icon", { slot: "icon-only", name: "close" }))))), h("ion-content", { class: "ion-padding" }, h("ion-grid", null, h("ion-row", null, (this.partials || []).map((partial) => (h("ion-col", { size: "12", sizeMd: "6" }, h("ion-item", { onClick: (event) => this.selectPartial(partial, event), detail: true, href: "#" }, h("ion-label", null, h("h2", null, (partial === null || partial === void 0 ? void 0 : partial.name) || (partial === null || partial === void 0 ? void 0 : partial.subject) || "No Name"), h("fireenjin-render-template", { template: {
        html: (partial === null || partial === void 0 ? void 0 : partial.html) || "",
        id: "partial",
      }, zoom: 0.5, partials: this.partials, style: {
        height: "250px",
        width: "250px",
      } })))))))))));
  }
};

export { ModalComponentSelect as fireenjin_modal_component_select };
