function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import { useEffect, useRef, useState } from "react";
/**
 * 布局管理 Hook
 * 管理组件布局相关的状态和逻辑
 */ export var useMarkdownInputFieldLayout = function useMarkdownInputFieldLayout() {
    var _useState = _sliced_to_array(useState(function() {
        if (typeof window === 'undefined') return false;
        if (window.innerWidth < 460) return true;
        return false;
    }), 2), collapseSendActions = _useState[0], setCollapseSendActions = _useState[1];
    var _useState1 = _sliced_to_array(useState(64), 2), rightPadding = _useState1[0], setRightPadding = _useState1[1];
    var _useState2 = _sliced_to_array(useState(0), 2), topRightPadding = _useState2[0], setTopRightPadding = _useState2[1];
    var _useState3 = _sliced_to_array(useState(0), 2), quickRightOffset = _useState3[0], setQuickRightOffset = _useState3[1];
    var _useState4 = _sliced_to_array(useState({
        width: 0,
        height: 0
    }), 2), dimensions = _useState4[0], setDimensions = _useState4[1];
    var inputRef = useRef(null);
    useEffect(function() {
        if (!inputRef.current) return;
        if (process.env.NODE_ENV === 'test') return;
        var handleResize = function handleResize() {
            var _inputRef_current;
            if (!inputRef.current) return;
            if (process.env.NODE_ENV === 'test') return;
            if (((_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.clientWidth) < 481) {
                setCollapseSendActions(true);
            } else {
                setCollapseSendActions(false);
            }
        };
        var resizeObserver = new ResizeObserver(function(entries) {
            var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
            try {
                for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
                    var entry = _step.value;
                    // 使用 contentRect 获取更准确的尺寸
                    setDimensions({
                        width: entry.contentRect.width,
                        height: entry.contentRect.height
                    });
                    handleResize();
                }
            } catch (err) {
                _didIteratorError = true;
                _iteratorError = err;
            } finally{
                try {
                    if (!_iteratorNormalCompletion && _iterator.return != null) {
                        _iterator.return();
                    }
                } finally{
                    if (_didIteratorError) {
                        throw _iteratorError;
                    }
                }
            }
        });
        // 初始化尺寸
        if (inputRef.current) {
            setDimensions({
                width: inputRef.current.clientWidth,
                height: inputRef.current.clientHeight
            });
        }
        resizeObserver.observe(inputRef.current);
        return function() {
            resizeObserver.disconnect();
        };
    }, []);
    return {
        collapseSendActions: collapseSendActions,
        setCollapseSendActions: setCollapseSendActions,
        rightPadding: rightPadding,
        setRightPadding: setRightPadding,
        topRightPadding: topRightPadding,
        setTopRightPadding: setTopRightPadding,
        quickRightOffset: quickRightOffset,
        setQuickRightOffset: setQuickRightOffset,
        inputRef: inputRef,
        dimensions: dimensions
    };
};
