var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { h } from '@stencil/core';
import { MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
/** The VegaImageUploaderPreviewContentRenderer class is responsible for rendering an image preview container with an image and optional actions element. */
export class VegaImageUploaderPreviewContentRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * Prevents the browser's default behavior on drag/drop events over the image preview.
     * Without this, dropping a file onto the already-populated preview would cause the browser
     * to navigate to (and open) the dropped file. The component does not support replacing the
     * image via drag-and-drop while a preview is shown, so we simply no-op here, matching the
     * disabled-state behavior.
     *
     * @param {DragEvent} e drag event object
     */
    this.preventDefaultDragEvent = (e) => {
      e.preventDefault();
    };
  }
  /**
   * The function renders an image preview container with an image and optional actions element.
   *
   * @param {string} imagePreviewURL - A string representing the URL of the image to be previewed.
   * @returns {HTMLDivElement} an HTMLDivElement includes an image and action buttons
   */
  render(imagePreviewURL) {
    const actionsElement = this.actionsRenderer.render();
    return (h("div", { class: {
        'image-preview-container': true,
        'actions-backdrop': actionsElement ? true : false,
      }, tabIndex: 0, role: "menu", onDrop: this.preventDefaultDragEvent, onDragEnter: this.preventDefaultDragEvent, onDragOver: this.preventDefaultDragEvent },
      h("img", { src: imagePreviewURL, alt: "" }),
      actionsElement));
  }
}
__decorate([
  MapToComponentField({ componentFieldName: 'vegaImageUploaderActionsRenderer' })
], VegaImageUploaderPreviewContentRenderer.prototype, "actionsRenderer", void 0);
