"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__, {
    ToolCallSection: ()=>ToolCallSection
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const CheckCircle_namespaceObject = require("@mui/icons-material/CheckCircle");
var CheckCircle_default = /*#__PURE__*/ __webpack_require__.n(CheckCircle_namespaceObject);
const Error_namespaceObject = require("@mui/icons-material/Error");
var Error_default = /*#__PURE__*/ __webpack_require__.n(Error_namespaceObject);
const KeyboardArrowRight_namespaceObject = require("@mui/icons-material/KeyboardArrowRight");
var KeyboardArrowRight_default = /*#__PURE__*/ __webpack_require__.n(KeyboardArrowRight_namespaceObject);
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_NestedValue_cjs_namespaceObject = require("./NestedValue.cjs");
const SectionArrowIcon = (0, material_namespaceObject.styled)(KeyboardArrowRight_default(), {
    shouldForwardProp: (prop)=>'expanded' !== prop
})(({ expanded })=>({
        marginRight: apollo_core_default().Spacing.SpacingXs,
        transition: 'transform 0.2s ease',
        cursor: 'pointer',
        transform: expanded ? 'rotate(90deg)' : 'none'
    }));
const SectionHeader = (0, material_namespaceObject.styled)('div')({
    display: 'flex',
    alignItems: 'center',
    padding: apollo_core_default().Spacing.SpacingMicro,
    borderRadius: apollo_core_default().Spacing.SpacingMicro,
    cursor: 'pointer',
    '&:hover': {
        backgroundColor: 'var(--color-background-hover)'
    },
    '&:focus-visible': {
        outline: `${apollo_core_default().Border.BorderThickS} solid var(--color-focus-indicator)`,
        outlineOffset: '-1px'
    }
});
const SectionContent = (0, material_namespaceObject.styled)('div', {
    shouldForwardProp: (prop)=>'expanded' !== prop
})(({ expanded })=>({
        marginLeft: apollo_core_default().Spacing.SpacingXl,
        overflow: 'hidden',
        transition: 'max-height 0.2s ease',
        maxHeight: expanded ? 'fit-content' : '0'
    }));
const KeyValueContainer = (0, material_namespaceObject.styled)('div')({
    maxHeight: '180px',
    overflowY: 'auto',
    backgroundColor: 'var(--color-background-secondary)',
    padding: `${apollo_core_default().Spacing.SpacingXs} ${apollo_core_default().Spacing.SpacingS}`,
    margin: `${apollo_core_default().Spacing.SpacingXs} 0`,
    borderRadius: apollo_core_default().Spacing.SpacingMicro
});
const KeyValuePair = (0, material_namespaceObject.styled)('div')({
    display: 'flex',
    marginBottom: apollo_core_default().Spacing.SpacingMicro,
    fontSize: apollo_core_default().FontFamily.FontSSize,
    '&:last-child': {
        marginBottom: 0
    }
});
const Key = (0, material_namespaceObject.styled)('span')({
    fontWeight: apollo_core_default().FontFamily.FontWeightMedium,
    marginRight: apollo_core_default().Spacing.SpacingXs,
    minWidth: 'max-content'
});
const UrlValue = (0, material_namespaceObject.styled)('span')({
    color: 'var(--color-foreground-link)',
    a: {
        textDecoration: 'none',
        '&:hover': {
            textDecoration: 'underline'
        }
    }
});
const CompletedStatus = (0, material_namespaceObject.styled)(CheckCircle_default())({
    width: apollo_core_default().FontFamily.FontLSize,
    color: 'var(--color-success-icon)',
    fill: 'var(--color-success-icon)'
});
const WaitingStatus = (0, material_namespaceObject.styled)(Error_default())({
    width: apollo_core_default().FontFamily.FontLSize,
    color: 'var(--color-warning-icon)',
    fill: 'var(--color-warning-icon)'
});
const TaskUrlKey = (0, material_namespaceObject.styled)('span')({
    fontWeight: apollo_core_default().FontFamily.FontWeightMedium,
    marginTop: apollo_core_default().Spacing.SpacingMicro,
    marginRight: apollo_core_default().Spacing.SpacingXs,
    minWidth: 'max-content'
});
const TaskUrlsContainer = (0, material_namespaceObject.styled)('div')({
    display: 'flex',
    flexDirection: 'column',
    gap: apollo_core_default().Spacing.SpacingXs
});
const TaskUrlItem = (0, material_namespaceObject.styled)('div')({
    display: 'flex',
    alignItems: 'center',
    gap: apollo_core_default().Spacing.SpacingXs
});
const TaskUrlLink = (0, material_namespaceObject.styled)('a')({
    color: 'inherit',
    textDecoration: 'none',
    '&:hover': {
        textDecoration: 'underline'
    },
    '&:focus-visible': {
        outline: `${apollo_core_default().Border.BorderThickS} solid var(--color-focus-indicator)`,
        outlineOffset: '1px'
    }
});
const StringContent = (0, material_namespaceObject.styled)('div')({
    backgroundColor: 'var(--color-background-secondary)',
    padding: `${apollo_core_default().Spacing.SpacingXs} ${apollo_core_default().Spacing.SpacingS}`,
    margin: `${apollo_core_default().Spacing.SpacingXs} 0`,
    borderRadius: apollo_core_default().Spacing.SpacingMicro,
    fontSize: apollo_core_default().FontFamily.FontSSize,
    whiteSpace: 'pre-wrap',
    wordBreak: 'break-word',
    maxHeight: '180px',
    overflowY: 'auto'
});
const ToolCallSection = ({ title, isExpanded, onToggle, data, children })=>{
    const isStringData = 'string' == typeof data;
    const showKeyValuePairs = !isStringData && data && Object.keys(data).length > 0;
    const handleKeyDown = (event)=>{
        if ('Enter' === event.key || ' ' === event.key) {
            event.preventDefault();
            onToggle();
        }
    };
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(SectionHeader, {
                onClick: onToggle,
                onKeyDown: handleKeyDown,
                role: "button",
                tabIndex: 0,
                "aria-expanded": isExpanded,
                children: [
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SectionArrowIcon, {
                        fontSize: "small",
                        expanded: isExpanded
                    }),
                    title
                ]
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(SectionContent, {
                expanded: isExpanded,
                "aria-hidden": !isExpanded,
                ...!isExpanded && {
                    inert: true
                },
                children: [
                    isStringData && data && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StringContent, {
                        children: data
                    }),
                    showKeyValuePairs && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(KeyValueContainer, {
                        children: Object.entries(data).map(([key, value])=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(KeyValuePair, {
                                children: 'taskUrls' === key && Array.isArray(value) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                                    children: [
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(TaskUrlKey, {
                                            children: [
                                                value.length > 1 ? 'taskUrls' : 'taskUrl',
                                                ":"
                                            ]
                                        }),
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TaskUrlsContainer, {
                                            children: value.map((item, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(TaskUrlItem, {
                                                    children: [
                                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(UrlValue, {
                                                            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TaskUrlLink, {
                                                                href: item.taskUrl,
                                                                target: "_blank",
                                                                rel: "noopener noreferrer",
                                                                children: item.taskUrl
                                                            })
                                                        }),
                                                        'unset' === item.status ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(WaitingStatus, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CompletedStatus, {})
                                                    ]
                                                }, index))
                                        })
                                    ]
                                }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                                    children: [
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Key, {
                                            children: [
                                                key,
                                                ":"
                                            ]
                                        }),
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NestedValue_cjs_namespaceObject.NestedValue, {
                                            value: value
                                        })
                                    ]
                                })
                            }, key))
                    }),
                    children
                ]
            })
        ]
    });
};
exports.ToolCallSection = __webpack_exports__.ToolCallSection;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "ToolCallSection"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
