/**
 * DevExtreme (cjs/__internal/ui/radio_group/m_radio_collection.js)
 * Version: 23.2.9 (build 24294-0112)
 * Build date: Sun Oct 20 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.default = void 0;
var _renderer = _interopRequireDefault(require("../../../core/renderer"));
var _common = require("../../../core/utils/common");
var _extend = require("../../../core/utils/extend");
var _ui = _interopRequireDefault(require("../../../ui/editor/ui.data_expression"));
var _edit = _interopRequireDefault(require("../../ui/collection/edit"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}
const RADIO_BUTTON_CHECKED_CLASS = "dx-radiobutton-checked";
const RADIO_BUTTON_ICON_CHECKED_CLASS = "dx-radiobutton-icon-checked";
const RADIO_BUTTON_ICON_CLASS = "dx-radiobutton-icon";
const RADIO_BUTTON_ICON_DOT_CLASS = "dx-radiobutton-icon-dot";
const RADIO_VALUE_CONTAINER_CLASS = "dx-radio-value-container";
const RADIO_BUTTON_CLASS = "dx-radiobutton";
let RadioCollection = function(_CollectionWidget) {
    _inheritsLoose(RadioCollection, _CollectionWidget);

    function RadioCollection() {
        return _CollectionWidget.apply(this, arguments) || this
    }
    var _proto = RadioCollection.prototype;
    _proto._focusTarget = function() {
        return (0, _renderer.default)(this.element()).parent()
    };
    _proto._nullValueSelectionSupported = function() {
        return true
    };
    _proto._getDefaultOptions = function() {
        const defaultOptions = _CollectionWidget.prototype._getDefaultOptions.call(this);
        return (0, _extend.extend)(defaultOptions, _ui.default._dataExpressionDefaultOptions(), {
            _itemAttributes: {
                role: "radio"
            }
        })
    };
    _proto._initMarkup = function() {
        _CollectionWidget.prototype._initMarkup.call(this);
        (0, _common.deferRender)(() => {
            this._itemElements().addClass("dx-radiobutton")
        })
    };
    _proto._keyboardEventBindingTarget = function() {
        return this._focusTarget()
    };
    _proto._postprocessRenderItem = function(args) {
        const {
            itemData: {
                html: html
            },
            itemElement: itemElement
        } = args;
        if (!html) {
            const $radio = (0, _renderer.default)("<div>").addClass("dx-radiobutton-icon");
            (0, _renderer.default)("<div>").addClass("dx-radiobutton-icon-dot").appendTo($radio);
            const $radioContainer = (0, _renderer.default)("<div>").append($radio).addClass("dx-radio-value-container");
            (0, _renderer.default)(itemElement).prepend($radioContainer)
        }
        _CollectionWidget.prototype._postprocessRenderItem.call(this, args)
    };
    _proto._processSelectableItem = function($itemElement, isSelected) {
        _CollectionWidget.prototype._processSelectableItem.call(this, $itemElement, isSelected);
        $itemElement.toggleClass("dx-radiobutton-checked", isSelected).find(".".concat("dx-radiobutton-icon")).first().toggleClass("dx-radiobutton-icon-checked", isSelected);
        this.setAria("checked", isSelected, $itemElement)
    };
    _proto._refreshContent = function() {
        this._prepareContent();
        this._renderContent()
    };
    _proto._supportedKeys = function() {
        const parent = _CollectionWidget.prototype._supportedKeys.call(this);
        return (0, _extend.extend)({}, parent, {
            enter(e) {
                e.preventDefault();
                return parent.enter.apply(this, arguments)
            },
            space(e) {
                e.preventDefault();
                return parent.space.apply(this, arguments)
            }
        })
    };
    _proto._itemElements = function() {
        return this._itemContainer().children(this._itemSelector())
    };
    _proto._setAriaSelectionAttribute = function() {};
    return RadioCollection
}(_edit.default);
var _default = RadioCollection;
exports.default = _default;
