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 { Component, Host, h, Element, Prop, Watch, Event } from '@stencil/core';
import { sanitizeVegaComponent } from '../../utils/component';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
import { VegaFileUploaderRenderer } from './slimmers/renderers/vega-file-uploader-renderer';
import { VegaFileUploaderContainerRenderer } from './slimmers/renderers/vega-file-uploader-container-renderer';
import { VegaFileUploaderFileListRenderer } from './slimmers/renderers/vega-file-uploader-file-list-renderer';
import { VegaFileUploaderFileStatusRenderer } from './slimmers/renderers/vega-file-uploader-file-status-renderer';
import { createEventEmitSlimmer, } from '../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaChange, VegaPreview, VegaRemove, VegaRetry, VegaSelectFileChange, } from '../../helpers/event-manager/event-id/vega-event-id';
import { VegaFileUploaderValueController } from './slimmers/controllers/vega-file-uploader-value-controller';
import { FormFieldControllerSlimmer } from '../../helpers/slimmers/form-field-controller-slimmer';
import { FileUploaderRequiredRule } from '../../helpers/validator/rules/file-uploader-required-rule';
import { DropFileAcceptFilterSlimmer } from '../../helpers/slimmers/drop-file-accept-filter-slimmer';
import { TranslationSlimmer } from '../../helpers/slimmers/translation';
import { VegaFileUploaderFileLimitController } from './slimmers/controllers/vega-file-uploader-file-limit-controller';
/**
 * @vegaVersion 2.25.0
 */
export class VegaFileUploader {
  constructor() {
    this.globalSlimmers = {};
    this.translationSlimmer = new TranslationSlimmer();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => isRequired ? new FileUploaderRequiredRule() : null,
        },
      ],
      validationRulesName: 'validationRules',
      defaultValue: [],
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.vegaFileUploaderContainerRenderer.getUploaderContainerRef(),
      touchableAreaGetter: () => [this.vegaFileUploaderContainerRenderer.getUploaderContainerRef()],
    });
    this.vegaFileUploaderRenderer = new VegaFileUploaderRenderer();
    this.vegaFileUploaderContainerRenderer = new VegaFileUploaderContainerRenderer();
    this.vegaFileUploaderFileListRenderer = new VegaFileUploaderFileListRenderer();
    this.vegaFileUploaderFileStatusRenderer = new VegaFileUploaderFileStatusRenderer();
    this.vegaFileUploaderValueController = new VegaFileUploaderValueController();
    this.dropFileFilterController = new DropFileAcceptFilterSlimmer();
    this.fileLimitController = new VegaFileUploaderFileLimitController();
    this.changeEventEmitter = createEventEmitSlimmer(VegaFileUploader, VegaChange);
    this.selectFileChangeEventEmitter = createEventEmitSlimmer(VegaFileUploader, VegaSelectFileChange);
    this.removeEventEmitter = createEventEmitSlimmer(VegaFileUploader, VegaRemove);
    this.retryEventEmitter = createEventEmitSlimmer(VegaFileUploader, VegaRetry);
    this.previewEventEmitter = createEventEmitSlimmer(VegaFileUploader, VegaPreview);
    /**
     * Specifies the label or title for the field.
     *
     * It provides descriptive text that helps identify the
     *    purpose or content expected in the field.
     *
     * @vegaVersion 2.25.0
     */
    this.label = '';
    /**
     * Specifies the uploader type that activates when clicked
     *    or when a file is dragged, determining how users
     *    interact with the file uploader.
     *
     * @vegaVersion 2.25.0
     */
    this.variant = 'uploadArea';
    /**
     * Provides a supplementary prompt message that assists users in
     *    understanding the expected value for the file uploader field.
     *
     * @vegaVersion 2.25.0
     */
    this.hint = '';
    /**
     * Specifies the initial file content to display, enabling a preview
     *    of the uploaded file or a default placeholder.
     *
     * @vegaVersion 2.25.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = [];
    /**
     * Specifies whether the File Uploader field is disabled.
     *
     * @vegaVersion 2.25.0
     */
    this.disabled = false;
    /**
     * Specifies the maximum number of files that can be uploaded using the File Uploader. The value must be a positive integer.
     *
     * @vegaVersion 2.36.0
     */
    this.maxCount = null;
    /**
     * Specifies whether uploading a file is mandatory.
     *
     * @vegaVersion 2.25.0
     */
    this.required = false;
    /**
     * Defines custom validation rules for the File Uploader field.
     *
     * @vegaVersion 2.25.0
     */
    this.validationRules = [];
    /**
     * Determines whether the input field should undergo automatic validation
     *    during the user's input.
     *
     * @vegaVersion 2.25.0
     */
    this.autoValidation = true;
    /**
     * Specifies the validation status of the file uploader component.
     *
     * @vegaVersion 2.25.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
  }
  /**
   * Watches the value change.
   *
   * @param {VegaFileUploaderFile[]} newValue The new value
   */
  watchValue(newValue) {
    methodPlaceholder(newValue);
  }
  /**
   * Watches the maxCount change.
   */
  watchMaxCount() {
    methodPlaceholder();
  }
  watchValidationRules() {
    methodPlaceholder();
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.vegaFileUploaderRenderer.render()), this.host);
  }
  static get is() { return "vega-file-uploader"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-file-uploader.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-file-uploader.css"]
  }; }
  static get properties() { return {
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Specifies the label or title for the field.\n\nIt provides descriptive text that helps identify the\n   purpose or content expected in the field."
      },
      "attribute": "label",
      "reflect": false,
      "defaultValue": "''"
    },
    "variant": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "VegaFileUploaderType",
        "resolved": "\"uploadArea\" | \"uploadButton\"",
        "references": {
          "VegaFileUploaderType": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Specifies the uploader type that activates when clicked\n   or when a file is dragged, determining how users\n   interact with the file uploader."
      },
      "attribute": "variant",
      "reflect": false,
      "defaultValue": "'uploadArea'"
    },
    "hint": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Provides a supplementary prompt message that assists users in\n   understanding the expected value for the file uploader field."
      },
      "attribute": "hint",
      "reflect": false,
      "defaultValue": "''"
    },
    "value": {
      "type": "unknown",
      "mutable": true,
      "complexType": {
        "original": "VegaFileUploaderFile[] | null",
        "resolved": "VegaFileUploaderFile[]",
        "references": {
          "VegaFileUploaderFile": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Specifies the initial file content to display, enabling a preview\n   of the uploaded file or a default placeholder."
      },
      "defaultValue": "[]"
    },
    "disabled": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Specifies whether the File Uploader field is disabled."
      },
      "attribute": "disabled",
      "reflect": false,
      "defaultValue": "false"
    },
    "maxCount": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number | null",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.36.0"
          }],
        "text": "Specifies the maximum number of files that can be uploaded using the File Uploader. The value must be a positive integer."
      },
      "attribute": "max-count",
      "reflect": false,
      "defaultValue": "null"
    },
    "required": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Specifies whether uploading a file is mandatory."
      },
      "attribute": "required",
      "reflect": false,
      "defaultValue": "false"
    },
    "validationRules": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "FormFieldValidationRule<unknown>[]",
        "resolved": "FormFieldValidationRule<unknown>[]",
        "references": {
          "FormFieldValidationRule": {
            "location": "import",
            "path": "../../helpers/validator/rules/form-field-validation-rule"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Defines custom validation rules for the File Uploader field."
      },
      "defaultValue": "[]"
    },
    "autoValidation": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Determines whether the input field should undergo automatic validation\n   during the user's input."
      },
      "attribute": "auto-validation",
      "reflect": true,
      "defaultValue": "true"
    },
    "isValid": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean | null",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "Specifies the validation status of the file uploader component."
      },
      "attribute": "is-valid",
      "reflect": true,
      "defaultValue": "null"
    },
    "accept": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }, {
            "name": "link",
            "text": "https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept"
          }],
        "text": "Specifies the allowed file types for upload."
      },
      "attribute": "accept",
      "reflect": false
    }
  }; }
  static get events() { return [{
      "method": "vegaChange",
      "name": "vegaChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying a change in the file list."
      },
      "complexType": {
        "original": "VegaFileUploaderFiles",
        "resolved": "VegaFileUploaderFile[]",
        "references": {
          "VegaFileUploaderFiles": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "change",
      "name": "change",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying a change in the file list."
      },
      "complexType": {
        "original": "VegaFileUploaderFiles",
        "resolved": "VegaFileUploaderFile[]",
        "references": {
          "VegaFileUploaderFiles": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "vegaSelectedFileChange",
      "name": "vegaSelectedFileChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying a file selection change. By default, the component value\n  is updated, but this behavior can be prevented."
      },
      "complexType": {
        "original": "VegaFileUploaderFiles",
        "resolved": "VegaFileUploaderFile[]",
        "references": {
          "VegaFileUploaderFiles": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "selectedFileChange",
      "name": "selectedFileChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying a file selection change. By default, the component value\n  is updated, but this behavior can be prevented."
      },
      "complexType": {
        "original": "VegaFileUploaderFiles",
        "resolved": "VegaFileUploaderFile[]",
        "references": {
          "VegaFileUploaderFiles": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "vegaRemove",
      "name": "vegaRemove",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that a selected file will be removed. By default, the component value\n  is updated, but this behavior can be prevented."
      },
      "complexType": {
        "original": "VegaFileUploaderFile",
        "resolved": "{ key: string; name: string; url: string | File; previewable?: boolean; status?: VegaFileUploaderFileStatus; errorMessage?: string; uploadingPercent?: number; }",
        "references": {
          "VegaFileUploaderFile": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "remove",
      "name": "remove",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that a selected file will be removed. By default, the component value\n  is updated, but this behavior can be prevented."
      },
      "complexType": {
        "original": "VegaFileUploaderFile",
        "resolved": "{ key: string; name: string; url: string | File; previewable?: boolean; status?: VegaFileUploaderFileStatus; errorMessage?: string; uploadingPercent?: number; }",
        "references": {
          "VegaFileUploaderFile": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "vegaRetry",
      "name": "vegaRetry",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that a file will be re-uploaded."
      },
      "complexType": {
        "original": "VegaFileUploaderFile",
        "resolved": "{ key: string; name: string; url: string | File; previewable?: boolean; status?: VegaFileUploaderFileStatus; errorMessage?: string; uploadingPercent?: number; }",
        "references": {
          "VegaFileUploaderFile": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "retry",
      "name": "retry",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that a file will be re-uploaded."
      },
      "complexType": {
        "original": "VegaFileUploaderFile",
        "resolved": "{ key: string; name: string; url: string | File; previewable?: boolean; status?: VegaFileUploaderFileStatus; errorMessage?: string; uploadingPercent?: number; }",
        "references": {
          "VegaFileUploaderFile": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "vegaPreview",
      "name": "vegaPreview",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that a file will be opened for preview."
      },
      "complexType": {
        "original": "VegaFileUploaderFile",
        "resolved": "{ key: string; name: string; url: string | File; previewable?: boolean; status?: VegaFileUploaderFileStatus; errorMessage?: string; uploadingPercent?: number; }",
        "references": {
          "VegaFileUploaderFile": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "preview",
      "name": "preview",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that a file will be opened for preview."
      },
      "complexType": {
        "original": "VegaFileUploaderFile",
        "resolved": "{ key: string; name: string; url: string | File; previewable?: boolean; status?: VegaFileUploaderFileStatus; errorMessage?: string; uploadingPercent?: number; }",
        "references": {
          "VegaFileUploaderFile": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }]; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "value",
      "methodName": "watchValue"
    }, {
      "propName": "maxCount",
      "methodName": "watchMaxCount"
    }, {
      "propName": "validationRules",
      "methodName": "watchValidationRules"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaFileUploader.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "translationSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "vegaFileUploaderRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "vegaFileUploaderContainerRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "vegaFileUploaderFileListRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "vegaFileUploaderFileStatusRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "vegaFileUploaderValueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "dropFileFilterController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "fileLimitController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "selectFileChangeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "removeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "retryEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFileUploader.prototype, "previewEventEmitter", void 0);
