define(["require", "exports", "tslib", "react", "../../Utilities", "./DialogContent.types", "../../Modal", "../../utilities/decorators/withResponsiveMode", "./DialogContent"], function (require, exports, tslib_1, React, Utilities_1, DialogContent_types_1, Modal_1, withResponsiveMode_1, DialogContent_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var getClassNames = Utilities_1.classNamesFunction();
    var DefaultModalProps = {
        isDarkOverlay: false,
        isBlocking: false,
        className: '',
        containerClassName: '',
        topOffsetFixed: false
    };
    var DefaultDialogContentProps = {
        type: DialogContent_types_1.DialogType.normal,
        className: '',
        topButtonsProps: []
    };
    var DialogBase = /** @class */ (function (_super) {
        tslib_1.__extends(DialogBase, _super);
        function DialogBase(props) {
            var _this = _super.call(this, props) || this;
            _this._getSubTextId = function () {
                var _a = _this.props, ariaDescribedById = _a.ariaDescribedById, modalProps = _a.modalProps, dialogContentProps = _a.dialogContentProps, subText = _a.subText;
                var id = ariaDescribedById || (modalProps && modalProps.subtitleAriaId);
                if (!id) {
                    id = (subText || (dialogContentProps && dialogContentProps.subText)) && _this._defaultSubTextId;
                }
                return id;
            };
            _this._getTitleTextId = function () {
                var _a = _this.props, ariaLabelledById = _a.ariaLabelledById, modalProps = _a.modalProps, dialogContentProps = _a.dialogContentProps, title = _a.title;
                var id = ariaLabelledById || (modalProps && modalProps.titleAriaId);
                if (!id) {
                    id = (title || (dialogContentProps && dialogContentProps.title)) && _this._defaultTitleTextId;
                }
                return id;
            };
            _this._id = Utilities_1.getId('Dialog');
            _this._defaultTitleTextId = _this._id + '-title';
            _this._defaultSubTextId = _this._id + '-subText';
            
            return _this;
        }
        DialogBase.prototype.render = function () {
            var _a = this.props, className = _a.className, containerClassName = _a.containerClassName, contentClassName = _a.contentClassName, elementToFocusOnDismiss = _a.elementToFocusOnDismiss, firstFocusableSelector = _a.firstFocusableSelector, forceFocusInsideTrap = _a.forceFocusInsideTrap, styles = _a.styles, hidden = _a.hidden, ignoreExternalFocusing = _a.ignoreExternalFocusing, isBlocking = _a.isBlocking, isClickableOutsideFocusTrap = _a.isClickableOutsideFocusTrap, isDarkOverlay = _a.isDarkOverlay, isOpen = _a.isOpen, onDismiss = _a.onDismiss, onDismissed = _a.onDismissed, onLayerDidMount = _a.onLayerDidMount, responsiveMode = _a.responsiveMode, subText = _a.subText, theme = _a.theme, title = _a.title, topButtonsProps = _a.topButtonsProps, type = _a.type, minWidth = _a.minWidth, maxWidth = _a.maxWidth, modalProps = _a.modalProps;
            var mergedLayerProps = tslib_1.__assign({}, (modalProps ? modalProps.layerProps : { onLayerDidMount: onLayerDidMount }));
            if (onLayerDidMount && !mergedLayerProps.onLayerDidMount) {
                mergedLayerProps.onLayerDidMount = onLayerDidMount;
            }
            var dialogDraggableClassName;
            var dragOptions;
            // if we are draggable, make sure we are using the correct
            // draggable classname and selectors
            if (modalProps && modalProps.dragOptions && !modalProps.dragOptions.dragHandleSelector) {
                dialogDraggableClassName = 'ms-Dialog-draggable-header';
                dragOptions = tslib_1.__assign({}, modalProps.dragOptions, { dragHandleSelector: "." + dialogDraggableClassName });
            }
            else {
                dragOptions = modalProps && modalProps.dragOptions;
            }
            var mergedModalProps = tslib_1.__assign({}, DefaultModalProps, modalProps, { layerProps: mergedLayerProps, dragOptions: dragOptions });
            var dialogContentProps = tslib_1.__assign({}, DefaultDialogContentProps, this.props.dialogContentProps, { draggableHeaderClassName: dialogDraggableClassName });
            var classNames = getClassNames(styles, {
                theme: theme,
                className: className || mergedModalProps.className,
                containerClassName: containerClassName || mergedModalProps.containerClassName,
                hidden: hidden,
                dialogDefaultMinWidth: minWidth,
                dialogDefaultMaxWidth: maxWidth
            });
            return (React.createElement(Modal_1.Modal, tslib_1.__assign({ elementToFocusOnDismiss: elementToFocusOnDismiss, firstFocusableSelector: firstFocusableSelector, forceFocusInsideTrap: forceFocusInsideTrap, ignoreExternalFocusing: ignoreExternalFocusing, isClickableOutsideFocusTrap: isClickableOutsideFocusTrap, onDismissed: onDismissed, responsiveMode: responsiveMode }, mergedModalProps, { isDarkOverlay: isDarkOverlay !== undefined ? isDarkOverlay : mergedModalProps.isDarkOverlay, isBlocking: isBlocking !== undefined ? isBlocking : mergedModalProps.isBlocking, isOpen: isOpen !== undefined ? isOpen : !hidden, className: classNames.root, containerClassName: classNames.main, onDismiss: onDismiss ? onDismiss : mergedModalProps.onDismiss, subtitleAriaId: this._getSubTextId(), titleAriaId: this._getTitleTextId() }),
                React.createElement(DialogContent_1.DialogContent, tslib_1.__assign({ titleId: this._defaultTitleTextId, subTextId: this._defaultSubTextId, title: title, subText: subText, showCloseButton: isBlocking !== undefined ? !isBlocking : !mergedModalProps.isBlocking, topButtonsProps: topButtonsProps ? topButtonsProps : dialogContentProps.topButtonsProps, type: type !== undefined ? type : dialogContentProps.type, onDismiss: onDismiss ? onDismiss : dialogContentProps.onDismiss, className: contentClassName || dialogContentProps.className }, dialogContentProps), this.props.children)));
        };
        DialogBase.defaultProps = {
            hidden: true
        };
        DialogBase = tslib_1.__decorate([
            withResponsiveMode_1.withResponsiveMode
        ], DialogBase);
        return DialogBase;
    }(React.Component));
    exports.DialogBase = DialogBase;
});
//# sourceMappingURL=Dialog.base.js.map