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 VegaImageUploaderInputRenderer class is a TypeScript React component that renders an input element of type "file" for uploading images and provides methods for accessing and manipulating the file input element. */
export class VegaImageUploaderInputRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * The below method is e2e-test covered in
     * @see{module:the-value-will-be-changed-when-selected-the-image-file}
     */
    /* istanbul ignore next */
    this.handleFileInputChange = (e) => {
      e.stopPropagation();
      const input = e.target;
      if (!input.files.length) {
        return;
      }
      this.valueController.setValue(input.files[0]);
    };
  }
  /**
   * The `getFileInputRef()` method is returning a reference to the HTMLInputElement that represents the
   * file input element in the component's render method. This allows other parts of the code to access
   * and manipulate the file input element if needed.
   *
   * @returns {HTMLInputElement} the input ref
   */
  getFileInputRef() {
    return this.fileInputRef;
  }
  /** The `render()` method is defining the JSX/HTML structure that will be rendered by this component. In this case, it is returning an `<input>` element of type "file". */
  render() {
    return (h("input", { type: "file", accept: this.accept, class: "v-hidden", ref: (ref) => (this.fileInputRef = ref), onChange: this.handleFileInputChange }));
  }
}
__decorate([
  MapToComponentField({ componentFieldName: 'vegaImageUploaderValueController' })
], VegaImageUploaderInputRenderer.prototype, "valueController", void 0);
__decorate([
  MapToComponentField()
], VegaImageUploaderInputRenderer.prototype, "accept", void 0);
