text: "use strict";
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  }) : (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      o[k2] = m[k];
  }));
  var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
      Object.defineProperty(o, "default", { enumerable: true, value: v });
  }) : function(o, v) {
      o["default"] = v;
  });
  var __importStar = (this && this.__importStar) || function (mod) {
      if (mod && mod.__esModule) return mod;
      var result = {};
      if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
      __setModuleDefault(result, mod);
      return result;
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.useMultilineState = void 0;
  const React = __importStar(require("react"));
  const react_utilities_1 = require("@fluentui/react-utilities");
  const useMultilineState = (state) => {
      const { autoAdjust, defaultValue, value, autocomplete, disabled, helperText, required, error, placeholder, label, onChange, } = state;
      const { id } = state.root;
      const inputRef = react_utilities_1.useMergedRefs(state.textarea.ref);
      const labelId = label ? react_utilities_1.useId('multiline-label', id) : undefined;
      const helperTextId = helperText ? react_utilities_1.useId('multiline-label', id) : undefined;
      const [currentValue, setCurrentValue] = react_utilities_1.useControllableState({
          defaultState: defaultValue,
          state: value,
          initialState: '',
      });
      /**
       * Updates the controlled `currentValue` to the new `incomingValue` and clamps it.
       */
      const updateValue = react_utilities_1.useEventCallback((incomingValue, ev) => {
          onChange?.(ev, { value: incomingValue });
          setCurrentValue(incomingValue);
      });
      /**
       * Updates the textarea height to the current scroll height.
       */
      const updateTextareaHeight = React.useCallback(() => {
          inputRef.current.style.height = '';
          inputRef.current.style.height = inputRef.current.scrollHeight + 'px';
      }, []);
      const onInputChange = React.useCallback((ev) => {
          updateValue(ev.target.value, ev);
          autoAdjust && updateTextareaHeight();
      }, [updateValue, autoAdjust, updateTextareaHeight]);
      const onClick = React.useCallback(ev => {
          ev.preventDefault();
          ev.stopPropagation();
          inputRef.current.focus();
      }, []);
      // Border Props
      state.textFieldBorder['aria-hidden'] = true;
      state.textFieldBorder.onClick = onClick;
      // Label Props
      label && (state.textFieldLabel.children = label);
      label && (state.textFieldLabel.htmlFor = labelId);
      // Helper Text Props
      helperText && (state.textFieldHelperText.children = helperText);
      helperText && (state.textFieldHelperText.id = helperTextId);
      // Legend Props
      label && (state.textFieldLegend.children = label);
      // Textarea Props
      state.textarea.value = currentValue;
      // state.textarea.style = textareaStyles;
      state.textarea.onChange = onInputChange;
      state.textarea.autoComplete = autocomplete;
      state.textarea.disabled = disabled;
      helperText && (state.textarea['aria-describedby'] = helperTextId);
      error && (state.textarea['aria-invalid'] = error);
      label && (state.textarea.id = labelId);
      required && (state.textarea.required = required);
      placeholder && (state.textarea.placeholder = placeholder);
      state.textarea.ref = inputRef;
      return state;
  };
  exports.useMultilineState = useMultilineState;
  //# sourceMappingURL=useMultilineState.js.map