"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AutopilotChatSettings: ()=>AutopilotChatSettings,
    default: ()=>chat_settings
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const material_namespaceObject = require("@mui/material");
const apollo_core_namespaceObject = require("@uipath/apollo-core");
var apollo_core_default = /*#__PURE__*/ __webpack_require__.n(apollo_core_namespaceObject);
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const external_react_focus_lock_namespaceObject = require("react-focus-lock");
var external_react_focus_lock_default = /*#__PURE__*/ __webpack_require__.n(external_react_focus_lock_namespaceObject);
const chat_service_provider_cjs_namespaceObject = require("../../providers/chat-service.provider.cjs");
const chat_state_provider_cjs_namespaceObject = require("../../providers/chat-state-provider.cjs");
const index_cjs_namespaceObject = require("../../service/index.cjs");
const external_chat_settings_header_cjs_namespaceObject = require("./chat-settings-header.cjs");
const ChatSettingsContainer = (0, material_namespaceObject.styled)('div')(({ isFullScreen })=>({
        display: 'flex',
        flexDirection: 'column',
        gap: apollo_core_default().Spacing.SpacingL,
        backgroundColor: 'var(--color-background-secondary)',
        height: '100%',
        zIndex: 1,
        boxSizing: 'border-box',
        overflow: 'hidden',
        whiteSpace: 'nowrap',
        width: 'var(--settings-width)',
        paddingLeft: 'var(--settings-padding-left)',
        paddingRight: 'var(--settings-padding-right)',
        paddingTop: apollo_core_default().Spacing.SpacingBase,
        paddingBottom: apollo_core_default().Spacing.SpacingBase,
        transition: 'width 0.3s ease, padding-left 0.3s ease, padding-right 0.3s ease',
        ...isFullScreen ? {
            borderTopLeftRadius: apollo_core_default().Spacing.SpacingXs
        } : {
            position: 'absolute',
            right: 0
        },
        '& .chat-settings-content': {
            outline: 'none',
            flex: 1,
            overflowY: 'auto',
            marginRight: `calc(-${apollo_core_default().Spacing.SpacingBase})`,
            paddingRight: apollo_core_default().Spacing.SpacingBase
        }
    }));
const AutopilotChatSettings = ({ open, isFullScreen })=>{
    const containerRef = (0, external_react_namespaceObject.useRef)(null);
    const chatService = (0, chat_service_provider_cjs_namespaceObject.useChatService)();
    const { settingsOpen } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
    const cssVars = external_react_default().useMemo(()=>{
        const width = open ? isFullScreen ? `calc(${index_cjs_namespaceObject.CHAT_DRAWER_WIDTH_FULL_SCREEN}px + 2 * ${apollo_core_default().Spacing.SpacingBase})` : '100%' : '0';
        const padding = open ? apollo_core_default().Spacing.SpacingBase : '0';
        return {
            '--settings-width': width,
            '--settings-padding-left': padding,
            '--settings-padding-right': padding
        };
    }, [
        open,
        isFullScreen
    ]);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (!containerRef.current || !chatService) return;
        const config = chatService.getConfig();
        const settingsRenderer = config.settingsRenderer;
        if (!settingsRenderer) return;
        containerRef.current.innerHTML = '';
        if (!settingsOpen) return;
        try {
            settingsRenderer(containerRef.current);
        } catch (error) {
            return;
        }
    }, [
        chatService,
        settingsOpen
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_focus_lock_default(), {
        disabled: !open || !settingsOpen || isFullScreen,
        returnFocus: false,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ChatSettingsContainer, {
            isOpen: open,
            isFullScreen: isFullScreen,
            style: cssVars,
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_chat_settings_header_cjs_namespaceObject.AutopilotChatSettingsHeader, {
                    isFullScreen: isFullScreen,
                    isSettingsOpen: settingsOpen
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                    ref: containerRef,
                    className: "chat-settings-content"
                })
            ]
        })
    });
};
const chat_settings = AutopilotChatSettings;
exports.AutopilotChatSettings = __webpack_exports__.AutopilotChatSettings;
exports["default"] = __webpack_exports__["default"];
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AutopilotChatSettings",
    "default"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
