import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-090d31ca.js';
import { M as MinStringLengthRule, a as MaxStringLengthRule } from './min-string-length-rule-c31c89f4.js';
import { R as RequiredFieldRule } from './required-field-rule-ab4bdc47.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { F as FormFieldControllerSlimmer } from './form-field-controller-slimmer-899864a8.js';
import { F as FORM_ELEMENT_VALUE_CHANGE } from './static-subject-title-52f93124.js';
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-32da9d90.js';
import { h as VegaChange, H as VegaBlur, x as VegaLabelButtonClick } from './vega-event-id-4ede557a.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-9c24d4fc.js';
import { D as DomNodeSubjectObserverFactory } from './dom-node-subject-observer-factory-aca0116e.js';
import './internal-form-field-validation-rule.abstract-f5b6bdbf.js';
import './string-a953eafc.js';
import './observer-3959f9dd.js';
import './ui-b7600a48.js';
import './misc-9fdbcfbb.js';
import './dynamic-slimmer-90b8af32.js';
import './vega-internal-event-id-194bac82.js';
import './internal-translation-controller-4fb104b2.js';
import './index-3b327f29.js';
import './try-get-document-bef0f526.js';
import './page-resize-observer-slimmer-e24d36c5.js';
import './breakpoints-332702ed.js';
import './ui-93922c59.js';
import './breakpoints-d9faf11c.js';
import './mutation-observer-slimmer-58ebc13c.js';
import './mutation-observer-filters-1a054fb0.js';
import './array-7888f339.js';
import './number-4398f2e1.js';
import './sub-state-observer-slimmer-090c500a.js';
import './internal-vega-event-manager-8a657bac.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-30f7b625.js';
import './index-bfc6dfa2.js';

const VegaTextareaRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'AUTO_VALIDATION_IS_TRUE',
    payloadDescription: 'Determines whether automatic validation should be implemented for the text area',
    /**
     * The function checks if the `autoValidation` property of the `host` element is equal to 'true'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.autoValidation === true,
  },
  {
    payloadKey: 'AUTO_VALIDATION_IS_FALSE',
    payloadDescription: 'Determines whether automatic validation should be implemented for the text area',
    /**
     * The function checks if the `autoValidation` property of the `host` element is equal to 'false'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.autoValidation === false,
  },
];

const vegaTextareaCss = ":host{display:inline-block;width:100%;text-align:left}:host .vega-textarea-container{display:flex;position:relative;width:100%;resize:vertical;box-sizing:border-box;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));border-radius:8px;overflow:hidden;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1));min-height:50px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-textarea-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-textarea-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-textarea-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}:host textarea{display:block;position:relative;padding-top:12px;padding-right:16px;padding-bottom:32px;padding-left:16px;width:100%;resize:vertical;box-sizing:border-box;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));border-radius:8px;outline:2px solid transparent;outline-offset:2px;border-style:none;overflow:auto;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1));min-height:48px}@media screen and (min-width: 768px) and (max-width: 1023px){:host textarea{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host textarea{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host textarea{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}:host .vega-textarea-container.vega-textarea-not-resizable{resize:none}:host .vega-textarea-container.vega-textarea-not-resizable textarea{resize:none}:host vega-field-label{margin-bottom:8px}:host .vega-textarea-counter{position:absolute;bottom:8px;right:8px;display:flex;padding-left:4px;padding-right:4px;padding-top:2px;padding-bottom:2px;border-radius:4px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-inverted-primary, 252, 252, 252, 1));background-color:rgba(var(--v-bg-textarea-count, 4, 4, 28, 0.6))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-textarea-counter{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-textarea-counter{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-textarea-counter{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .vega-textarea-counter.counter-exceed-max-length{background-color:rgba(var(--v-bg-textarea-counter-exceed-max-length, 214, 46, 81))}:host textarea::placeholder{color:rgba(var(--v-text-input-placeholder, 176, 180, 181, 1))}:host .vega-error{display:inline-block;padding-left:8px;padding-right:8px;padding-top:12px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-error, 189, 41, 71, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host vega-text{padding-left:8px;padding-right:8px;padding-top:12px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-secondary, 107, 116, 125, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host vega-text{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host vega-text{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host vega-text{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .vega-textarea-container:hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1))}:host .vega-textarea-container:focus-within{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:3px;border:1px solid rgba(var(--v-border-color-input-field-focus, 19, 98, 226, 1))}:host .vega-textarea-container.error{border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1))}:host .vega-textarea-container.error:hover{border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1))}:host .vega-textarea-container.error:focus-within{border:1px solid rgba(var(--v-border-input-field-danger-focus, 233, 71, 104, 1));outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:3px;border:1px solid rgba(var(--v-border-color-input-field-danger-focus, 233, 71, 104, 1))}:host(.disabled) textarea{color:rgba(var(--v-text-input-disabled, 107, 116, 125, 1));background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1))}:host(.disabled) .vega-textarea-container{border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}:host .vega-hidden{display:none}";

var __decorate = (undefined && undefined.__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;
};
const VegaTextarea = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.vegaBlur = createEvent(this, "vegaBlur", 7);
    this.blur = createEvent(this, "blur", 7);
    this.vegaLabelButtonClick = createEvent(this, "vegaLabelButtonClick", 7);
    this.labelButtonClick = createEvent(this, "labelButtonClick", 7);
    this.globalSlimmers = {};
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
        {
          propertyName: 'minLength',
          ruleFactory: (minLength) => minLength ? new MinStringLengthRule({ minStrLength: minLength }) : null,
        },
        {
          propertyName: 'maxLength',
          ruleFactory: (maxLength) => maxLength ? new MaxStringLengthRule({ maxStrLength: maxLength }) : null,
        },
      ],
      validationRulesName: 'validationRules',
      defaultValue: '',
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.inputContainerRef,
      touchableAreaGetter: () => [this.textareaRef],
    });
    this.changeEventEmitter = createEventEmitSlimmer(VegaTextarea, VegaChange);
    this.blurEventEmitter = createEventEmitSlimmer(VegaTextarea, VegaBlur);
    this.labelButtonClickEventEmitter = createEventEmitSlimmer(VegaTextarea, VegaLabelButtonClick);
    this.textareaEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.inputContainerRef);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaTextareaRuntimeMetricsPayloadDefinition);
    this.currentCharCount = 0;
    /**
     * Specifies a placeholder string that displays as a temporary hint or
     * example within the text area. The placeholder text is shown when the
     * field is empty and disappears once the user begins typing.
     *
     * Use this to indicate the expected format or content of the input,
     * for example `'Enter your comments here...'`.
     *
     * @default ''
     * @vegaVersion 1.11.0
     */
    this.placeholder = '';
    /**
     * Provides a supplementary helper message displayed below the text area
     * that assists users in understanding the expected value or format.
     *
     * The hint is visible at all times (not just on focus) and is typically
     * used for guidance such as character requirements or formatting rules.
     *
     * @default ''
     * @vegaVersion 1.11.0
     */
    this.hint = '';
    /**
     * Specifies whether the text area is disabled. When `true`, the text area
     * is non-interactive — the user cannot type, focus, or select the field.
     * The disabled state is reflected as an HTML attribute for CSS styling.
     *
     * @default false
     * @vegaVersion 1.11.0
     */
    this.disabled = false;
    /**
     * Specifies the visible label text rendered above the text area. The label
     * helps identify the purpose or content expected within the field and also
     * serves as the accessible `aria-label` for screen readers when present.
     *
     * Clicking the label will focus the text area.
     *
     * @default ''
     * @vegaVersion 1.11.0
     */
    this.label = '';
    /**
     * Configuration object for an optional suffix button rendered beside the
     * field label. Use this to provide an inline action (e.g., a help or info
     * button) next to the label text.
     *
     * When the button is clicked, the `vegaLabelButtonClick` event is emitted.
     * Set to `null` to hide the suffix button.
     *
     * @default null
     * @vegaVersion 2.68.0
     */
    this.labelSuffixButtonConfig = null;
    /**
     * Determines whether to display a live character counter below the text area.
     *
     * When `true`, the counter shows the current character count. If `maxLength`
     * is also set, the counter displays in the format `current/max` and visually
     * highlights when the limit is exceeded.
     *
     * @default false
     * @vegaVersion 1.11.0
     */
    this.showCounter = false;
    /**
     * The current value (content) of the text area field.
     *
     * This property is mutable and will be updated programmatically when the
     * user types into the text area. It can also be set externally to
     * pre-populate or reset the field. Changes to this property trigger the
     * `vegaChange` event and update the character counter if `showCounter`
     * is enabled. Supports two-way binding in framework wrappers.
     *
     * @default ''
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = '';
    /**
     * Reflects the current validation status of the text area.
     *
     * - `true` — the field value passes all validation rules.
     * - `false` — one or more validation rules have failed.
     * - `null` — the field has not been validated yet (initial state).
     *
     * This property is mutable: it is updated automatically when
     * `autoValidation` is enabled, but can also be set manually to override
     * the validation state. The value is reflected as an HTML attribute.
     *
     * @default null
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
    /**
     * Determines whether the text area should be validated automatically as the
     * user types. When `true`, validation rules (including `required`, `minLength`,
     * `maxLength`, and custom `validationRules`) are evaluated on blur and the
     * `isValid` property is updated accordingly.
     *
     * Set to `false` to handle validation manually.
     *
     * @default true
     * @vegaVersion 1.11.0
     */
    this.autoValidation = true;
    /**
     * Determines whether the text area must have a non-empty value before the
     * form can be submitted. When `true`, a required-field indicator is shown
     * on the label and the built-in `RequiredFieldRule` is applied during
     * validation.
     *
     * @default false
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.required = false;
    /**
     * Specifies the maximum number of characters (UTF-16 code units) that the
     * user can enter in the text area. The native `maxlength` attribute is
     * applied to the inner `<textarea>` element.
     *
     * When `showCounter` is `true`, the maximum value is displayed alongside
     * the current character count (e.g., `42/200`). Exceeding this limit
     * triggers a visual warning on the counter and fails the
     * `MaxStringLengthRule` during validation.
     *
     * Set to `null` to allow unlimited input.
     *
     * @default null
     * @vegaVersion 1.11.0
     */
    this.maxLength = null;
    /**
     * Specifies the minimum number of characters (UTF-16 code units) that the
     * user must enter in the text area for the value to be considered valid.
     * The native `minlength` attribute is applied to the inner `<textarea>`
     * element.
     *
     * When set, the `MinStringLengthRule` is applied during validation. Set to
     * `null` to impose no minimum length.
     *
     * @default null
     * @vegaVersion 1.11.0
     */
    this.minLength = null;
    /**
     * Determines whether the user can vertically resize the text area by
     * dragging its bottom-right corner. When `false`, the resize handle is
     * hidden via CSS and the text area height is fixed.
     *
     * @default true
     * @vegaVersion 2.19.0
     */
    this.resizable = true;
    /**
     * Specifies the number of visible text lines in the text area, controlling
     * its initial height. Accepts integers ≥ 2. For optimal display, values
     * below 2 are internally adjusted to 4 rows.
     *
     * @default 5
     * @vegaVersion 2.63.0
     */
    this.rows = 5;
    /**
     * An array of custom validation rules applied to the text area in addition
     * to the built-in rules (`RequiredFieldRule`, `MinStringLengthRule`,
     * `MaxStringLengthRule`). Each rule must implement the
     * `FormFieldValidationRule` interface.
     *
     * Rules are evaluated in order when `autoValidation` is enabled or when
     * validation is triggered programmatically.
     *
     * @default []
     * @vegaVersion 1.11.0
     */
    this.validationRules = [];
    this.renderTextareaContainer = () => {
      return (h("div", { class: { 'vega-textarea-container': true, 'vega-textarea-not-resizable': !this.resizable }, ref: (e) => (this.inputContainerRef = e) }, h("textarea", { rows: this.rows >= 2 ? this.rows - 1 : 4, placeholder: this.placeholder, disabled: this.disabled, required: this.required, ref: this.setTextareaRef, maxLength: this.maxLength, minLength: this.minLength, value: this.value, onBlur: this.handleTextareaBlur, "aria-label": this.label || 'No label defined' }), this.showCounter && this.renderCharacterCounter()));
    };
    this.renderHintMessage = () => {
      return h("vega-text", null, this.hint);
    };
    this.renderCharacterCounter = () => {
      return (h("div", { class: {
          'vega-textarea-counter': true,
          'counter-exceed-max-length': this.isExceedMaxLength(this.value, this.maxLength),
        } }, h("span", { id: "current" }, this.currentCharCount), this.maxLength != null && this.renderMaxLengthNumber()));
    };
    this.renderMaxLengthNumber = () => {
      return h("span", { id: "maximum" }, "/", this.maxLength);
    };
    this.setTextareaRef = (textareaRef) => {
      if (textareaRef && this.textareaRef !== textareaRef) {
        this.textareaRef = textareaRef;
      }
    };
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-textarea-focus-e2e}
     */
    /* istanbul ignore next */
    this.inputFocus = () => {
      this.textareaRef.focus();
    };
    this.handleTextareaBlur = (e) => {
      this.blurEventEmitter.emit(undefined, e);
    };
    this.isExceedMaxLength = (value, maxLength) => {
      return maxLength != null ? value.length > maxLength : false;
    };
    this.handleLabelButtonClick = () => {
      this.labelButtonClickEventEmitter.emit();
    };
  }
  watchValue(value) {
    this.changeEventEmitter.emit(value);
    if (this.textareaRef.value !== this.value) {
      this.textareaRef.value = this.value;
    }
    if (value) {
      this.currentCharCount = value.length;
    }
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: value,
    });
  }
  watchValidationRules() {
  }
  componentWillLoad() {
    this.currentCharCount = this.value.length;
  }
  /**
   * The below method is e2e-test covered in
   * @see{module:vega-textarea-on-value-input}
   */
  /* istanbul ignore next */
  handleValueTextarea() {
    this.value = this.textareaRef.value;
    this.currentCharCount = this.value.length;
  }
  render() {
    return sanitizeVegaComponent(h(Host, { class: {
        disabled: this.disabled,
      } }, this.renderLabelDom(), this.renderTextareaContainer(), this.hint && this.renderHintMessage()), this.host);
  }
  renderLabelDom() {
    return (h("vega-field-label", { onClick: this.inputFocus, "is-field-required": this.required, disabled: this.disabled, label: this.label, suffixButtonConfig: this.labelSuffixButtonConfig, ref: (node) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, VegaLabelButtonClick, this.handleLabelButtonClick);
      } }));
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "value": ["watchValue"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaTextarea.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTextarea.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTextarea.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTextarea.prototype, "blurEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTextarea.prototype, "labelButtonClickEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTextarea.prototype, "textareaEventPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTextarea.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaTextarea.style = vegaTextareaCss;

export { VegaTextarea as vega_textarea };
